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:
@@ -10,6 +10,7 @@
|
|||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
|
#include <be_apps/ServicesDaemon/ServicesDaemon.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
M_RELAUNCH_DESKBAR = 'rtsk',
|
M_RELAUNCH_DESKBAR = 'rtsk',
|
||||||
@@ -22,7 +23,7 @@ enum {
|
|||||||
M_RELAUNCH_MIDI
|
M_RELAUNCH_MIDI
|
||||||
};
|
};
|
||||||
|
|
||||||
// Time delay in microseconds - 1 seconds
|
// Time delay in microseconds - 1 second
|
||||||
const bigtime_t kRelaunchDelay = 1000000;
|
const bigtime_t kRelaunchDelay = 1000000;
|
||||||
|
|
||||||
const char *gSignatures[] = {
|
const char *gSignatures[] = {
|
||||||
@@ -75,6 +76,11 @@ App::~App(void)
|
|||||||
|
|
||||||
int32 dummyval;
|
int32 dummyval;
|
||||||
wait_for_thread(fRelauncherID, &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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
App::MessageReceived(BMessage *msg)
|
App::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
@@ -96,6 +103,19 @@ App::MessageReceived(BMessage *msg)
|
|||||||
if (msg->FindString("be:signature",&string) != B_OK)
|
if (msg->FindString("be:signature",&string) != B_OK)
|
||||||
return;
|
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;
|
int i = 0;
|
||||||
while (gSignatures[i]) {
|
while (gSignatures[i]) {
|
||||||
// Checking to see if it's one of the supported signatures
|
// Checking to see if it's one of the supported signatures
|
||||||
@@ -112,6 +132,12 @@ App::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
break;
|
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: {
|
case M_RELAUNCH_DESKBAR: {
|
||||||
be_roster->Launch(gSignatures[msg->what - M_RELAUNCH_DESKBAR]);
|
be_roster->Launch(gSignatures[msg->what - M_RELAUNCH_DESKBAR]);
|
||||||
break;
|
break;
|
||||||
@@ -142,6 +168,7 @@ App::MessageReceived(BMessage *msg)
|
|||||||
be_roster->Launch(gSignatures[msg->what - M_RELAUNCH_DESKBAR]);
|
be_roster->Launch(gSignatures[msg->what - M_RELAUNCH_DESKBAR]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BApplication::MessageReceived(msg);
|
BApplication::MessageReceived(msg);
|
||||||
}
|
}
|
||||||
@@ -175,10 +202,11 @@ App::RelauncherThread(void *data)
|
|||||||
|
|
||||||
if (msg) {
|
if (msg) {
|
||||||
// Attempt to work around R5 shutdown procedures by checking for
|
// Attempt to work around R5 shutdown procedures by checking for
|
||||||
// debug_server running state. If it's shut down, then chances are that
|
// debug_server running state. If it's shut down, then chances
|
||||||
// the system is shutting down or has already done so. We use the
|
// are that the system is shutting down or has already done so.
|
||||||
// debug server in particular because it's one of the few services
|
// We use the debug server in particular because it's one of
|
||||||
// that is available in safe mode which is closed on system shutdown.
|
// the few services that is available in safe mode which is
|
||||||
|
// closed on system shutdown.
|
||||||
|
|
||||||
if (be_roster->IsRunning("application/x-vnd.Be-DBSV")) {
|
if (be_roster->IsRunning("application/x-vnd.Be-DBSV")) {
|
||||||
snooze(kRelaunchDelay);
|
snooze(kRelaunchDelay);
|
||||||
@@ -193,6 +221,7 @@ App::RelauncherThread(void *data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ private:
|
|||||||
thread_id fRelauncherID;
|
thread_id fRelauncherID;
|
||||||
status_t fStatus;
|
status_t fStatus;
|
||||||
BMessageQueue fRelaunchQueue;
|
BMessageQueue fRelaunchQueue;
|
||||||
|
|
||||||
|
BList fSignatureList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user