Added app restart capabilities
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19720 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ddcd53aaf0
commit
98969dd0a4
@ -10,6 +10,7 @@
|
||||
#include <Alert.h>
|
||||
#include <OS.h>
|
||||
#include <MediaDefs.h>
|
||||
#include <be_apps/ServicesDaemon/ServicesDaemon.h>
|
||||
|
||||
enum {
|
||||
M_RELAUNCH_DESKBAR = 'rtsk',
|
||||
@ -22,7 +23,7 @@ enum {
|
||||
M_RELAUNCH_MIDI
|
||||
};
|
||||
|
||||
// Time delay in microseconds - 1 seconds
|
||||
// Time delay in microseconds - 1 second
|
||||
const bigtime_t kRelaunchDelay = 1000000;
|
||||
|
||||
const char *gSignatures[] = {
|
||||
@ -75,6 +76,11 @@ App::~App(void)
|
||||
|
||||
int32 dummyval;
|
||||
wait_for_thread(fRelauncherID, &dummyval);
|
||||
|
||||
for (int32 i = 0; i < fSignatureList.CountItems(); i++) {
|
||||
BString *item = (BString*) fSignatureList.ItemAt(i);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -87,6 +93,7 @@ App::QuitRequested(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
App::MessageReceived(BMessage *msg)
|
||||
{
|
||||
@ -96,6 +103,19 @@ App::MessageReceived(BMessage *msg)
|
||||
if (msg->FindString("be:signature",&string) != B_OK)
|
||||
return;
|
||||
|
||||
// See if the signature belongs to an app that has requested
|
||||
// a restart
|
||||
for (int32 i = 0; i < fSignatureList.CountItems(); i++) {
|
||||
BString *item = (BString*) fSignatureList.ItemAt(i);
|
||||
if (string.Compare(*item) == 0) {
|
||||
fSignatureList.RemoveItem(item);
|
||||
delete item;
|
||||
|
||||
be_roster->Launch(string.String());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while (gSignatures[i]) {
|
||||
// Checking to see if it's one of the supported signatures
|
||||
@ -112,6 +132,12 @@ App::MessageReceived(BMessage *msg)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case B_SERVICES_DAEMON_RESTART: {
|
||||
BString signature;
|
||||
if (msg->FindString("signature",&signature) == B_OK)
|
||||
fSignatureList.AddItem(new BString(signature));
|
||||
break;
|
||||
}
|
||||
case M_RELAUNCH_DESKBAR: {
|
||||
be_roster->Launch(gSignatures[msg->what - M_RELAUNCH_DESKBAR]);
|
||||
break;
|
||||
@ -142,6 +168,7 @@ App::MessageReceived(BMessage *msg)
|
||||
be_roster->Launch(gSignatures[msg->what - M_RELAUNCH_DESKBAR]);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BApplication::MessageReceived(msg);
|
||||
}
|
||||
@ -175,10 +202,11 @@ App::RelauncherThread(void *data)
|
||||
|
||||
if (msg) {
|
||||
// Attempt to work around R5 shutdown procedures by checking for
|
||||
// debug_server running state. If it's shut down, then chances are that
|
||||
// the system is shutting down or has already done so. We use the
|
||||
// debug server in particular because it's one of the few services
|
||||
// that is available in safe mode which is closed on system shutdown.
|
||||
// debug_server running state. If it's shut down, then chances
|
||||
// are that the system is shutting down or has already done so.
|
||||
// We use the debug server in particular because it's one of
|
||||
// the few services that is available in safe mode which is
|
||||
// closed on system shutdown.
|
||||
|
||||
if (be_roster->IsRunning("application/x-vnd.Be-DBSV")) {
|
||||
snooze(kRelaunchDelay);
|
||||
@ -193,6 +221,7 @@ App::RelauncherThread(void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@ -19,6 +19,8 @@ private:
|
||||
thread_id fRelauncherID;
|
||||
status_t fStatus;
|
||||
BMessageQueue fRelaunchQueue;
|
||||
|
||||
BList fSignatureList;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user