The Deskbar can now shutdown or reboot Haiku, but we should have a way to shutdown asynchronously, see TODO

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13712 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2005-07-17 11:07:55 +00:00
parent f67fe71e9e
commit 5fb214d470
4 changed files with 51 additions and 6 deletions

View File

@ -47,6 +47,10 @@ All rights reserved.
#include <Path.h>
#include <Roster.h>
#if __HAIKU__
# include <RosterPrivate.h>
#endif
#include "FavoritesConfig.h"
#include "icons.h"
@ -457,6 +461,26 @@ TBarApp::MessageReceived(BMessage *message)
fSwitcherMess.SendMessage(message);
break;
#if __HAIKU__
case CMD_REBOOT_SYSTEM:
case CMD_SUSPEND_SYSTEM:
case CMD_SHUTDOWN_SYSTEM: {
// TODO: Deskbar cannot quit because BRoster::Private::Shutdown() is synchronous,
// so we launch a thread which does the shutdown, this should be reworked so
// that we can simply send a message to the roster and be done with it
void* cookie = message->what == CMD_SHUTDOWN_SYSTEM ? NULL : (void*)1;
thread_id thread = spawn_thread(_shutdown, "shutdown thread", B_NORMAL_PRIORITY, cookie);
if (thread >= B_OK) {
status_t ret = resume_thread(thread);
if (ret < B_OK)
fprintf(stderr, "error resuming shutdown thread: %s\n", strerror(ret));
} else
fprintf(stderr, "error spawning shutdown thread: %s\n", strerror(thread));
break;
}
#endif // __HAIKU__
default:
BApplication::MessageReceived(message);
break;
@ -643,6 +667,19 @@ TBarApp::ShowConfigWindow()
}
}
#if __HAIKU__
// _shutdown
int32
TBarApp::_shutdown(void* cookie)
{
BRoster roster;
BRoster::Private rosterPrivate(roster);
status_t error = rosterPrivate.ShutDown(cookie != NULL, false);
fprintf(stderr, "Shutdown failed: %s\n", strerror(error));
return 0;
}
#endif // __HAIKU__
// #pragma mark -

View File

@ -46,7 +46,6 @@ All rights reserved.
#define _FLOATER_W_TYPE_ 4
#define _STD_W_TYPE_ 0
class BarTeamInfo {
public:
BarTeamInfo(BList *teams, uint32 flags, char *sig, BBitmap *icon,
@ -77,6 +76,11 @@ const uint32 msg_sortRunningApps = 'SAps';
const uint32 msg_superExpando = 'SprE';
const uint32 msg_expandNewTeams = 'ExTm';
// from roster_private.h
const uint32 CMD_SHUTDOWN_SYSTEM = 301;
const uint32 CMD_REBOOT_SYSTEM = 302;
const uint32 CMD_SUSPEND_SYSTEM = 304;
/* --------------------------------------------- */
// if you want to extend this structure, maintain the
@ -154,6 +158,10 @@ private:
void ShowConfigWindow();
#if __HAIKU__
static int32 _shutdown(void* cookie);
#endif
TBarWindow *fBarWindow;
BMessenger fSwitcherMess;
BMessenger fStatusViewMess;

View File

@ -48,11 +48,6 @@ All rights reserved.
#include "StatusView.h"
#include "IconMenuItem.h"
// from roster_private.h
const uint32 CMD_SHUTDOWN_SYSTEM = 301;
const uint32 CMD_REBOOT_SYSTEM = 302;
const uint32 CMD_SUSPEND_SYSTEM = 304;
#define ROSTER_SIG "application/x-vnd.Be-ROST"
#ifdef B_BEOS_VERSION_5
@ -455,7 +450,11 @@ TBeMenu::ResetTargets()
case CMD_SUSPEND_SYSTEM:
case CMD_SHUTDOWN_SYSTEM:
// restart/shutdown
#if __HAIKU__
item->SetTarget(be_app);
#else
item->SetTarget(BMessenger(ROSTER_SIG));
#endif
break;
}
}

View File

@ -1,5 +1,6 @@
SubDir OBOS_TOP src apps deskbar ;
UsePrivateHeaders app ;
UsePrivateHeaders shared ;
UsePrivateHeaders tracker ;
SubDirHdrs $(OBOS_TOP) src kits tracker ;