I am having difficulty with the AddItem functions of Deskbar? I am
trying to add a view to the Deskbar tray from the notification_server
but the view never shows in the Deskbar and I am getting an (not so
helpful) error on the terminal:
"Can't add deskbar replicant: General system error"
I also get the same error when I just try to send the Deskbar a ref to
any application. I have added a custom view to the deskbar before so I
took the view class I wrote before and used that as a template for my
DeskbarShelfView class. I am able to add replicants to the deskbar with
other apps including desklink just fine. I can even add the
notification_server to the deskbar using the desklink app. But I just
cannot get either my DeskbarShelfView class or a ref to ANY application
added from within the notification_server itself.
Here is the function I created to add a view to the deskbar. The code
that is commented out was me testing adding just a simple ref which
results in the same general system error. I took this code from the
mail_daemon which is also a server so I can't understand why the deskbar
does not accept a simple ref from the notification_server.
void
NotificationServer::_ShowShelfView(bool show)
{
BDeskbar deskbar;
// Don't add another DeskbarShelfView to the Deskbar if one is already
// attached
if (show && !deskbar.HasItem(kShelfviewName)) {
BView* shelfView = new DeskbarShelfView();
status_t status = deskbar.AddItem(shelfView);
if (status < B_OK) {
fprintf(stderr, "Can't add deskbar replicant: %s\n",
strerror(status));
return;
}
delete shelfView;
/* entry_ref ref;
status_t status =
be_roster->FindApp("application/x-vnd.Haiku-notification_server", &ref);
if (status < B_OK) {
fprintf(stderr, "Can't find application to tell deskbar: %s\n",
strerror(status));
return;
}
status = deskbar.AddItem(&ref);
if (status < B_OK) {
fprintf(stderr, "Can't add deskbar replicant: %s\n",
strerror(status));
return;
}*/
}
// Remove DeskbarShelfView if there is one in the deskbar
else if (!show && deskbar.HasItem(kShelfviewName))
deskbar.RemoveItem(kShelfviewName);
}
Here it is on github if you care to take a look.
https://github.com/Perelandra0x309/haiku/blob/n_center/src/servers/notification/NotificationServer.cpp#L119
-Brian