* Now we have a hardcoded list of apps which shall not be terminated on

shutdown (input, app, debug server, and registrar).
* Fixed crashing bug, if the shutdown was aborted before the window was
  created.
* The text of the confirmation alert depends on whether we reboot or
  shut down.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13643 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2005-07-12 12:36:08 +00:00
parent c458888ae0
commit 29aa57037d
3 changed files with 29 additions and 32 deletions
+10 -9
View File
@@ -621,10 +621,8 @@ ShutdownProcess::ShutdownProcess(TRoster *roster, EventQueue *eventQueue)
ShutdownProcess::~ShutdownProcess() ShutdownProcess::~ShutdownProcess()
{ {
// terminate the GUI // terminate the GUI
if (fHasGUI) { if (fHasGUI && fWindow && fWindow->Lock())
fWindow->Lock();
fWindow->Quit(); fWindow->Quit();
}
// remove and delete the quit request reply handler // remove and delete the quit request reply handler
if (fQuitRequestReplyHandler) { if (fQuitRequestReplyHandler) {
@@ -1109,7 +1107,7 @@ status_t
ShutdownProcess::_ShutDown() ShutdownProcess::_ShutDown()
{ {
#ifdef __HAIKU__ #ifdef __HAIKU__
return _kern_shutdown(fReboot); RETURN_ERROR(_kern_shutdown(fReboot));
#else #else
// we can't do anything on R5 // we can't do anything on R5
return B_ERROR; return B_ERROR;
@@ -1225,9 +1223,13 @@ ShutdownProcess::_WorkerDoShutdown()
// ask the user to confirm the shutdown, if desired // ask the user to confirm the shutdown, if desired
bool askUser; bool askUser;
if (fHasGUI && fRequest->FindBool("confirm", &askUser) == B_OK && askUser) { if (fHasGUI && fRequest->FindBool("confirm", &askUser) == B_OK && askUser) {
BAlert *alert = new BAlert("Shut Down?", const char *title = (fReboot ? "Reboot?" : "Shut Down?");
"Do you really want to shut down the system?", const char *text = (fReboot
"Shut Down", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); ? "Do you really want to reboot the system?"
: "Do you really want to shut down the system?");
const char *buttonText = (fReboot ? "Reboot" : "Shut Down");
BAlert *alert = new BAlert(title, text, buttonText, "Cancel", NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
int32 result = alert->Go(); int32 result = alert->Go();
if (result != 0) if (result != 0)
@@ -1266,6 +1268,7 @@ ShutdownProcess::_WorkerDoShutdown()
// we're through: do the shutdown // we're through: do the shutdown
_SetPhase(DONE_PHASE); _SetPhase(DONE_PHASE);
_SetShutdownWindowWaitForShutdown();
_ShutDown(); _ShutDown();
PRINT((" _kern_shutdown() failed\n")); PRINT((" _kern_shutdown() failed\n"));
@@ -1273,8 +1276,6 @@ ShutdownProcess::_WorkerDoShutdown()
// shutdown failed: This can happen for power off mode -- reboot should // shutdown failed: This can happen for power off mode -- reboot should
// always work. // always work.
if (fHasGUI) { if (fHasGUI) {
_SetShutdownWindowWaitForShutdown();
// wait for the reboot event // wait for the reboot event
uint32 event; uint32 event;
do { do {
+19 -22
View File
@@ -1294,28 +1294,40 @@ TRoster::GetShutdownApps(AppInfoList &userApps, AppInfoList &systemApps,
status_t error = B_OK; status_t error = B_OK;
// add ourself to the vital system apps and try to find the app server // get the vital system apps:
// * ourself
// * app server
// * input server
// * debug server
if (error == B_OK) { if (error == B_OK) {
// ourself // ourself
vitalSystemApps.insert(be_app->Team()); vitalSystemApps.insert(be_app->Team());
// the app server // app server
port_id appServerPort = find_port(SERVER_PORT_NAME); port_id appServerPort = find_port(SERVER_PORT_NAME);
port_info portInfo; port_info portInfo;
if (appServerPort >= 0 if (appServerPort >= 0
&& get_port_info(appServerPort, &portInfo) == B_OK) { && get_port_info(appServerPort, &portInfo) == B_OK) {
vitalSystemApps.insert(portInfo.team); vitalSystemApps.insert(portInfo.team);
} }
// input server
RosterAppInfo *info
= fRegisteredApps.InfoFor("application/x-vnd.Be-input_server");
if (info)
vitalSystemApps.insert(info->team);
// debug server
info = fRegisteredApps.InfoFor("application/x-vnd.haiku-debug-server");
if (info)
vitalSystemApps.insert(info->team);
} }
// populate the other groups
for (AppInfoList::Iterator it(fRegisteredApps.It()); for (AppInfoList::Iterator it(fRegisteredApps.It());
RosterAppInfo *info = *it; RosterAppInfo *info = *it;
++it) { ++it) {
if (vitalSystemApps.find(info->team) != vitalSystemApps.end()) { if (vitalSystemApps.find(info->team) == vitalSystemApps.end()) {
// must be us or the app server
} else if (_IsVitalSystemApp(info)) {
vitalSystemApps.insert(info->team);
} else {
RosterAppInfo *clonedInfo = info->Clone(); RosterAppInfo *clonedInfo = info->Clone();
if (clonedInfo) { if (clonedInfo) {
if (info->flags & B_BACKGROUND_APP) { if (info->flags & B_BACKGROUND_APP) {
@@ -1644,21 +1656,6 @@ TRoster::_HandleGetRecentEntries(BMessage *request)
FUNCTION_END(); FUNCTION_END();
} }
// _IsVitalSystemApp
bool
TRoster::_IsVitalSystemApp(RosterAppInfo *info) const
{
BPath path;
status_t error = path.SetTo(&info->ref);
if (error != B_OK)
return false;
int len = strlen(path.Path());
int prefixLen = strlen(kVitalSystemAppPathPrefix);
return (len > prefixLen
&& strncmp(path.Path(), kVitalSystemAppPathPrefix, prefixLen) == 0);
}
// _IsSystemApp // _IsSystemApp
bool bool
TRoster::_IsSystemApp(RosterAppInfo *info) const TRoster::_IsSystemApp(RosterAppInfo *info) const
-1
View File
@@ -113,7 +113,6 @@ private:
void _HandleGetRecentEntries(BMessage *request); void _HandleGetRecentEntries(BMessage *request);
bool _IsVitalSystemApp(RosterAppInfo *info) const;
bool _IsSystemApp(RosterAppInfo *info) const; bool _IsSystemApp(RosterAppInfo *info) const;
status_t _LoadRosterSettings(const char *path = NULL); status_t _LoadRosterSettings(const char *path = NULL);