* Added BRoster::ShutDown().
* Adjusted the shutdown command to use BRoster::ShutDown(). Removed the alert. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13416 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -62,6 +62,20 @@ reply fields:
|
|||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
shut down
|
||||||
|
|
||||||
|
target: registrar app looper (preferred handler)
|
||||||
|
message: B_REG_SHUT_DOWN
|
||||||
|
"reboot": B_BOOL_TYPE
|
||||||
|
reply: standard success
|
||||||
|
on error: - B_NO_REPLY (fatal)
|
||||||
|
- standard error (fatal)
|
||||||
|
|
||||||
|
message fields:
|
||||||
|
- "reboot": If true, the system reboots instead of turning the power off.
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
Roster Requests
|
Roster Requests
|
||||||
---------------
|
---------------
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ private:
|
|||||||
class ArgVector;
|
class ArgVector;
|
||||||
friend class Private;
|
friend class Private;
|
||||||
|
|
||||||
|
status_t ShutDown(bool reboot);
|
||||||
|
|
||||||
status_t AddApplication(const char *mimeSig, const entry_ref *ref,
|
status_t AddApplication(const char *mimeSig, const entry_ref *ref,
|
||||||
uint32 flags, team_id team, thread_id thread,
|
uint32 flags, team_id team, thread_id thread,
|
||||||
port_id port, bool fullReg, uint32 *pToken,
|
port_id port, bool fullReg, uint32 *pToken,
|
||||||
|
|||||||
@@ -45,10 +45,13 @@ enum {
|
|||||||
B_REG_SUCCESS = 'rgsu',
|
B_REG_SUCCESS = 'rgsu',
|
||||||
B_REG_ERROR = 'rger',
|
B_REG_ERROR = 'rger',
|
||||||
B_REG_RESULT = 'rgrz',
|
B_REG_RESULT = 'rgrz',
|
||||||
|
|
||||||
// general requests
|
// general requests
|
||||||
B_REG_GET_MIME_MESSENGER = 'rgmm',
|
B_REG_GET_MIME_MESSENGER = 'rgmm',
|
||||||
B_REG_GET_CLIPBOARD_MESSENGER = 'rgcm',
|
B_REG_GET_CLIPBOARD_MESSENGER = 'rgcm',
|
||||||
B_REG_GET_DISK_DEVICE_MESSENGER = 'rgdm',
|
B_REG_GET_DISK_DEVICE_MESSENGER = 'rgdm',
|
||||||
|
B_REG_SHUT_DOWN = 'rgsh',
|
||||||
|
|
||||||
// roster requests
|
// roster requests
|
||||||
B_REG_ADD_APP = 'rgaa',
|
B_REG_ADD_APP = 'rgaa',
|
||||||
B_REG_COMPLETE_REGISTRATION = 'rgcr',
|
B_REG_COMPLETE_REGISTRATION = 'rgcr',
|
||||||
@@ -74,6 +77,7 @@ enum {
|
|||||||
B_REG_CLEAR_RECENT_APPS = 'rgxa',
|
B_REG_CLEAR_RECENT_APPS = 'rgxa',
|
||||||
B_REG_LOAD_RECENT_LISTS = 'rglr',
|
B_REG_LOAD_RECENT_LISTS = 'rglr',
|
||||||
B_REG_SAVE_RECENT_LISTS = 'rgsr',
|
B_REG_SAVE_RECENT_LISTS = 'rgsr',
|
||||||
|
|
||||||
// MIME requests
|
// MIME requests
|
||||||
B_REG_MIME_SET_PARAM = 'rgsp',
|
B_REG_MIME_SET_PARAM = 'rgsp',
|
||||||
B_REG_MIME_DELETE_PARAM = 'rgdp',
|
B_REG_MIME_DELETE_PARAM = 'rgdp',
|
||||||
@@ -89,14 +93,18 @@ enum {
|
|||||||
B_REG_MIME_UPDATE_MIME_INFO = 'rgup',
|
B_REG_MIME_UPDATE_MIME_INFO = 'rgup',
|
||||||
B_REG_MIME_CREATE_APP_META_MIME = 'rgca',
|
B_REG_MIME_CREATE_APP_META_MIME = 'rgca',
|
||||||
B_REG_MIME_UPDATE_THREAD_FINISHED = 'rgtf',
|
B_REG_MIME_UPDATE_THREAD_FINISHED = 'rgtf',
|
||||||
|
|
||||||
// message runner requests
|
// message runner requests
|
||||||
B_REG_REGISTER_MESSAGE_RUNNER = 'rgrr',
|
B_REG_REGISTER_MESSAGE_RUNNER = 'rgrr',
|
||||||
B_REG_UNREGISTER_MESSAGE_RUNNER = 'rgru',
|
B_REG_UNREGISTER_MESSAGE_RUNNER = 'rgru',
|
||||||
B_REG_SET_MESSAGE_RUNNER_PARAMS = 'rgrx',
|
B_REG_SET_MESSAGE_RUNNER_PARAMS = 'rgrx',
|
||||||
B_REG_GET_MESSAGE_RUNNER_INFO = 'rgri',
|
B_REG_GET_MESSAGE_RUNNER_INFO = 'rgri',
|
||||||
|
|
||||||
// internal registrar messages
|
// internal registrar messages
|
||||||
B_REG_ROSTER_SANITY_EVENT = 'rgir',
|
B_REG_ROSTER_SANITY_EVENT = 'rgir',
|
||||||
|
B_REG_SHUTDOWN_FINISHED = 'rgsf',
|
||||||
B_REG_ROSTER_DEVICE_RESCAN = 'rgrs',
|
B_REG_ROSTER_DEVICE_RESCAN = 'rgrs',
|
||||||
|
|
||||||
// clipboard handler requests
|
// clipboard handler requests
|
||||||
B_REG_ADD_CLIPBOARD = 'rgCa',
|
B_REG_ADD_CLIPBOARD = 'rgCa',
|
||||||
B_REG_GET_CLIPBOARD_COUNT = 'rgCc',
|
B_REG_GET_CLIPBOARD_COUNT = 'rgCc',
|
||||||
@@ -104,6 +112,7 @@ enum {
|
|||||||
B_REG_CLIPBOARD_STOP_WATCHING = 'rgCx',
|
B_REG_CLIPBOARD_STOP_WATCHING = 'rgCx',
|
||||||
B_REG_DOWNLOAD_CLIPBOARD = 'rgCd',
|
B_REG_DOWNLOAD_CLIPBOARD = 'rgCd',
|
||||||
B_REG_UPLOAD_CLIPBOARD = 'rgCu',
|
B_REG_UPLOAD_CLIPBOARD = 'rgCu',
|
||||||
|
|
||||||
// disk device request
|
// disk device request
|
||||||
B_REG_NEXT_DISK_DEVICE = 'rgnx',
|
B_REG_NEXT_DISK_DEVICE = 'rgnx',
|
||||||
B_REG_GET_DISK_DEVICE = 'rgdd',
|
B_REG_GET_DISK_DEVICE = 'rgdd',
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ public:
|
|||||||
status_t SendTo(BMessage *message, BMessage *reply, bool mime);
|
status_t SendTo(BMessage *message, BMessage *reply, bool mime);
|
||||||
bool IsMessengerValid(bool mime) const;
|
bool IsMessengerValid(bool mime) const;
|
||||||
|
|
||||||
|
status_t ShutDown(bool reboot)
|
||||||
|
{ return fRoster->ShutDown(reboot); }
|
||||||
|
|
||||||
// needed by BApplication
|
// needed by BApplication
|
||||||
|
|
||||||
status_t AddApplication(const char *mimeSig, const entry_ref *ref,
|
status_t AddApplication(const char *mimeSig, const entry_ref *ref,
|
||||||
|
|||||||
+11
-362
@@ -1,6 +1,6 @@
|
|||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
//
|
//
|
||||||
// Copyright (c) 2002, Haiku
|
// Copyright (c) 2002-2005, Haiku
|
||||||
//
|
//
|
||||||
// This software is part of the Haiku distribution and is covered
|
// This software is part of the Haiku distribution and is covered
|
||||||
// by the MIT license.
|
// by the MIT license.
|
||||||
@@ -13,32 +13,17 @@
|
|||||||
// This program behaves identically as the BeOS R5 version, with these
|
// This program behaves identically as the BeOS R5 version, with these
|
||||||
// added arguments:
|
// added arguments:
|
||||||
//
|
//
|
||||||
// -a alert user while counting down
|
|
||||||
// -c cancels any running shutdown
|
// -c cancels any running shutdown
|
||||||
//
|
//
|
||||||
// There seem to be a race condition (sometimes crashes on quit with
|
|
||||||
// "the looper must be locked"), if you find it, tell me,
|
|
||||||
// tried 3 hours to find it.
|
|
||||||
// Some code from Shard's Archiver from BeBits (was BSD/MIT too :).
|
// Some code from Shard's Archiver from BeBits (was BSD/MIT too :).
|
||||||
//
|
//
|
||||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
|
||||||
// ToDo: I think we should remove the shutdown alert again - we already have one
|
|
||||||
// in the roster, and that should really be enough.
|
|
||||||
// Also, I don't quite see a lot of sense in the delayed shutdown, either -- axeld.
|
|
||||||
|
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <Application.h>
|
#include <Roster.h>
|
||||||
#include <Bitmap.h>
|
#include <RosterPrivate.h>
|
||||||
#include <Button.h>
|
|
||||||
#include <Messenger.h>
|
|
||||||
#include <Mime.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <StringView.h>
|
|
||||||
#include <View.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -47,326 +32,9 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
// timer should be handled better (with system_time())
|
|
||||||
#define PULSE_RATE 100000
|
|
||||||
#define PULSE_MODULO 10
|
|
||||||
|
|
||||||
//from bdb-ing /bin/shutdown:
|
|
||||||
#define B_SYSTEM_SHUTDOWN 0x12d
|
|
||||||
#define B_SYSTEM_REBOOT 0x12e
|
|
||||||
|
|
||||||
#ifdef __HAIKU__
|
|
||||||
static const char *kRosterSignature = "application/x-vnd.haiku-registrar";
|
|
||||||
#else
|
|
||||||
static const char *kRosterSignature = "application/x-vnd.Be-ROST";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// globals
|
|
||||||
const char kIconBits[] = {
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x00,
|
|
||||||
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f,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ff,
|
|
||||||
0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x00, 0x3f,
|
|
||||||
0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff,
|
|
||||||
0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00,
|
|
||||||
0x00, 0x3f, 0x00, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x00, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x00, 0x00,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
|
||||||
};
|
|
||||||
|
|
||||||
const char kElectronBits[] = {
|
|
||||||
0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0x00, 0x25, 0x24, 0x26, 0x00, 0xff, 0xff,
|
|
||||||
0x00, 0x25, 0x21, 0x21, 0x22, 0x26, 0x00, 0xff,
|
|
||||||
0x00, 0x21, 0x3f, 0x22, 0x22, 0x25, 0x00, 0xff,
|
|
||||||
0x00, 0x25, 0x22, 0x22, 0x24, 0x24, 0x00, 0xff,
|
|
||||||
0xff, 0x00, 0x23, 0x23, 0x25, 0x00, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
|
||||||
};
|
|
||||||
|
|
||||||
#define EL_POS_COUNT 17
|
|
||||||
|
|
||||||
static const int electron1_table[][2] = {
|
|
||||||
{3, 8}, {7, 8}, {12, 8}, {17, 10},
|
|
||||||
{22, 12}, {26, 16}, {28, 20}, {28, 24},
|
|
||||||
{26, 26}, {22, 27}, {18, 26}, {14, 25},
|
|
||||||
{10, 24}, {5, 22}, {3, 18}, {1, 14},
|
|
||||||
{1, 10}, {-1, -1}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int electron2_table[][2] = {
|
|
||||||
{23, 18}, {21, 22}, {18, 25}, {14, 27},
|
|
||||||
{10, 27}, {5, 26}, {0, 25}, {1, 18},
|
|
||||||
{4, 15}, {8, 12}, {12, 10}, {16, 8},
|
|
||||||
{20, 8}, {24, 9}, {28, 11}, {27, 13},
|
|
||||||
{25, 15}, {-1, -1}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
uint32 gTimeToSleep = 0;
|
uint32 gTimeToSleep = 0;
|
||||||
bool gReboot = false;
|
bool gReboot = false;
|
||||||
|
|
||||||
|
|
||||||
class SView : public BView {
|
|
||||||
public:
|
|
||||||
SView(BRect frame);
|
|
||||||
~SView();
|
|
||||||
|
|
||||||
void Draw(BRect updateRect);
|
|
||||||
void Pulse();
|
|
||||||
|
|
||||||
BButton *fButton;
|
|
||||||
BString *fTitleStr;
|
|
||||||
BStringView *fTitle;
|
|
||||||
|
|
||||||
BBitmap *fIcon;
|
|
||||||
BBitmap *fElectron;
|
|
||||||
int fElectronPos;
|
|
||||||
|
|
||||||
int fPulseDivider;
|
|
||||||
|
|
||||||
int32 fWidth;
|
|
||||||
int32 fHeight;
|
|
||||||
|
|
||||||
int32 fLeftMargin;
|
|
||||||
unsigned long fTimeLeft;
|
|
||||||
|
|
||||||
static const int32 fTopMargin = 8;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ShutdownWindow : public BWindow {
|
|
||||||
public:
|
|
||||||
ShutdownWindow(thread_id id);
|
|
||||||
~ShutdownWindow();
|
|
||||||
|
|
||||||
void MessageReceived(BMessage *msg);
|
|
||||||
bool QuitRequested();
|
|
||||||
|
|
||||||
private:
|
|
||||||
SView *fView;
|
|
||||||
thread_id fShutdownThread;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ShutdownApp : public BApplication {
|
|
||||||
public:
|
|
||||||
ShutdownApp(thread_id id);
|
|
||||||
~ShutdownApp();
|
|
||||||
|
|
||||||
private:
|
|
||||||
ShutdownWindow *fWindow;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
SView::SView(BRect frame)
|
|
||||||
:BView(frame, "SView", B_FOLLOW_LEFT_RIGHT, B_PULSE_NEEDED | B_WILL_DRAW),
|
|
||||||
fButton(NULL),
|
|
||||||
fTitleStr(NULL),
|
|
||||||
fTitle(NULL),
|
|
||||||
fIcon(NULL),
|
|
||||||
fElectron(NULL),
|
|
||||||
fElectronPos(0),
|
|
||||||
fPulseDivider(PULSE_MODULO+1),
|
|
||||||
fWidth(0),
|
|
||||||
fHeight(0),
|
|
||||||
fLeftMargin(B_LARGE_ICON + 8),
|
|
||||||
fTimeLeft(gTimeToSleep)
|
|
||||||
{
|
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
SetLowColor(ViewColor());
|
|
||||||
SetDrawingMode(B_OP_OVER);
|
|
||||||
fIcon = new BBitmap(BRect(0, 0, B_LARGE_ICON-1, B_LARGE_ICON-1), B_CMAP8);
|
|
||||||
fIcon->SetBits(kIconBits, B_LARGE_ICON*B_LARGE_ICON, 0, B_CMAP8);
|
|
||||||
fElectron = new BBitmap(BRect(0, 0, 7, 7), B_CMAP8);
|
|
||||||
fElectron->SetBits(kElectronBits, 8*8, 0, B_CMAP8);
|
|
||||||
fTitleStr = new BString;
|
|
||||||
if (gReboot)
|
|
||||||
*fTitleStr << "Rebooting in " << (int32)fTimeLeft << " seconds !";
|
|
||||||
else
|
|
||||||
*fTitleStr << "Shutting down in " << (int32)fTimeLeft << " seconds !";
|
|
||||||
|
|
||||||
fTitle = new BStringView(BRect(55, 10, 260, 35), "", fTitleStr->String());
|
|
||||||
fButton = new BButton(BRect(159, 42, 259, 66), "quit", "Cancel", new BMessage('_QRQ'));
|
|
||||||
fButton->MakeDefault(true);
|
|
||||||
AddChild(fTitle);
|
|
||||||
AddChild(fButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SView::~SView()
|
|
||||||
{
|
|
||||||
delete fButton;
|
|
||||||
delete fTitle;
|
|
||||||
delete fIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SView::Pulse()
|
|
||||||
{
|
|
||||||
fPulseDivider--;
|
|
||||||
if (fPulseDivider <= 0) {
|
|
||||||
fPulseDivider = PULSE_MODULO;
|
|
||||||
fTimeLeft--;
|
|
||||||
fTitleStr->SetTo("");
|
|
||||||
if (gReboot)
|
|
||||||
*fTitleStr << "Rebooting in " << (int32)fTimeLeft << " seconds !";
|
|
||||||
else
|
|
||||||
*fTitleStr << "Shutting down in " << (int32)fTimeLeft << " seconds !";
|
|
||||||
fTitle->SetText(fTitleStr->String());
|
|
||||||
}
|
|
||||||
fElectronPos += 1;
|
|
||||||
fElectronPos %= EL_POS_COUNT;
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
SView::Draw(BRect updateRect)
|
|
||||||
{
|
|
||||||
BRect bounds = Bounds();
|
|
||||||
|
|
||||||
// left margin background
|
|
||||||
// SetHighColor(tint_color(ViewColor(), B_HIGHLIGHT_BACKGROUND_TINT));
|
|
||||||
SetHighColor(0xB8, 0xB8, 0xB8); // same color as the registrar shutdown dialog
|
|
||||||
FillRect(BRect(0, 0, B_LARGE_ICON, bounds.bottom));
|
|
||||||
|
|
||||||
if (fIcon != NULL)
|
|
||||||
DrawBitmap(fIcon, BPoint((B_LARGE_ICON / 2), fTopMargin));
|
|
||||||
|
|
||||||
if (fIcon != NULL) {
|
|
||||||
DrawBitmap(fElectron, BPoint((B_LARGE_ICON / 2) + electron1_table[fElectronPos][0], fTopMargin + electron1_table[fElectronPos][1]));
|
|
||||||
DrawBitmap(fElectron, BPoint((B_LARGE_ICON / 2) + electron2_table[fElectronPos][0], fTopMargin + electron2_table[fElectronPos][1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Window())
|
|
||||||
Window()->Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ShutdownWindow::ShutdownWindow(thread_id id)
|
|
||||||
: BWindow(BRect( 139, 81, 407, 156), "Shutdown Status", B_TITLED_WINDOW_LOOK,
|
|
||||||
B_NORMAL_WINDOW_FEEL,
|
|
||||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_ASYNCHRONOUS_CONTROLS),
|
|
||||||
fView(NULL)
|
|
||||||
{
|
|
||||||
fShutdownThread = id;
|
|
||||||
SetPulseRate(PULSE_RATE);
|
|
||||||
fView = new SView(Bounds());
|
|
||||||
AddChild(fView);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ShutdownWindow::~ShutdownWindow()
|
|
||||||
{
|
|
||||||
fView->LockLooper();
|
|
||||||
fView->RemoveSelf();
|
|
||||||
delete fView;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ShutdownWindow::MessageReceived(BMessage *msg)
|
|
||||||
{
|
|
||||||
switch (msg->what) {
|
|
||||||
default:
|
|
||||||
BWindow::MessageReceived(msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
ShutdownWindow::QuitRequested()
|
|
||||||
{
|
|
||||||
SetPulseRate(0);
|
|
||||||
kill(fShutdownThread, SIGUSR1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ShutdownApp::ShutdownApp(thread_id id)
|
|
||||||
: BApplication("application/x-vnd.ShutDown-app")
|
|
||||||
{
|
|
||||||
fWindow = new ShutdownWindow(id);
|
|
||||||
fWindow->SetWorkspaces(0xFFFFFFFF);
|
|
||||||
fWindow->Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ShutdownApp::~ShutdownApp()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32
|
|
||||||
app_thread(void *arg)
|
|
||||||
{
|
|
||||||
thread_id tid = (thread_id) arg;
|
|
||||||
(new ShutdownApp(tid))->Run();
|
|
||||||
delete be_app;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
// we get here when shutdown is cancelled.
|
// we get here when shutdown is cancelled.
|
||||||
// then sleep() returns
|
// then sleep() returns
|
||||||
|
|
||||||
@@ -414,7 +82,6 @@ usage(const char *arg0)
|
|||||||
"\t-r reboot,\n"
|
"\t-r reboot,\n"
|
||||||
"\t-q quick shutdown (don't broadcast apps),\n"
|
"\t-q quick shutdown (don't broadcast apps),\n"
|
||||||
"\t-c cancel a running shutdown,\n"
|
"\t-c cancel a running shutdown,\n"
|
||||||
"\t-a alerts user while waiting,\n"
|
|
||||||
"\t-d delay shutdown by <time> seconds.\n", program);
|
"\t-d delay shutdown by <time> seconds.\n", program);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -424,7 +91,6 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
bool quick = false;
|
bool quick = false;
|
||||||
bool alert = false;
|
|
||||||
|
|
||||||
for (int32 i = 1; i < argc; i++) {
|
for (int32 i = 1; i < argc; i++) {
|
||||||
char *arg = argv[i];
|
char *arg = argv[i];
|
||||||
@@ -463,9 +129,6 @@ main(int argc, char **argv)
|
|||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'a':
|
|
||||||
alert = true;
|
|
||||||
break;
|
|
||||||
case 'd':
|
case 'd':
|
||||||
if (parseTime(arg + 1, argv[i + 1], &i)) {
|
if (parseTime(arg + 1, argv[i + 1], &i)) {
|
||||||
arg = NULL;
|
arg = NULL;
|
||||||
@@ -482,28 +145,14 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gTimeToSleep > 0) {
|
if (gTimeToSleep > 0) {
|
||||||
thread_id appThread = -1;
|
|
||||||
int32 left;
|
int32 left;
|
||||||
|
|
||||||
signal(SIGUSR1, handle_usr1);
|
signal(SIGUSR1, handle_usr1);
|
||||||
|
|
||||||
if (alert) {
|
printf("Delaying %s by %lu seconds...\n", gReboot ? "reboot" : "shutdown", gTimeToSleep);
|
||||||
// BApplication::Run() blocks
|
|
||||||
appThread = spawn_thread(app_thread, "ShutdownApp", B_NORMAL_PRIORITY, (void *)find_thread(NULL));
|
|
||||||
resume_thread(appThread);
|
|
||||||
} else
|
|
||||||
printf("Delaying %s by %lu seconds...\n", gReboot ? "reboot" : "shutdown", gTimeToSleep);
|
|
||||||
|
|
||||||
left = sleep(gTimeToSleep);
|
left = sleep(gTimeToSleep);
|
||||||
|
|
||||||
if (alert) {
|
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
|
||||||
|
|
||||||
status_t err;
|
|
||||||
wait_for_thread(appThread, &err);
|
|
||||||
snooze(100000);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (left > 0) {
|
if (left > 0) {
|
||||||
fprintf(stderr, "Shutdown cancelled.\n");
|
fprintf(stderr, "Shutdown cancelled.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
@@ -511,17 +160,17 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (quick) {
|
if (quick) {
|
||||||
|
#ifdef __HAIKU__
|
||||||
_kern_shutdown(gReboot);
|
_kern_shutdown(gReboot);
|
||||||
|
#endif // __HAIKU__
|
||||||
fprintf(stderr, "Shutdown failed!\n");
|
fprintf(stderr, "Shutdown failed!\n");
|
||||||
return 2;
|
return 2;
|
||||||
} else {
|
} else {
|
||||||
BMessenger messenger(kRosterSignature);
|
BRoster roster;
|
||||||
|
BRoster::Private rosterPrivate(roster);
|
||||||
status_t err = messenger.SendMessage(gReboot ? B_SYSTEM_REBOOT : B_SYSTEM_SHUTDOWN);
|
status_t error = rosterPrivate.ShutDown(gReboot);
|
||||||
if (err != B_OK) {
|
fprintf(stderr, "Shutdown failed: %s\n", strerror(error));
|
||||||
fprintf(stderr, "Failed to send message to roster server: %s\n", strerror(err));
|
return 2;
|
||||||
exit(2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ const char *kRAppLooperPortName = "rAppLooperPort";
|
|||||||
const char *
|
const char *
|
||||||
get_roster_port_name()
|
get_roster_port_name()
|
||||||
{
|
{
|
||||||
return (BPrivate::is_running_on_haiku()
|
return "_haiku_roster_port_";
|
||||||
? "_roster_port_" : "_obos_roster_port_");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|||||||
@@ -1266,6 +1266,42 @@ BRoster::AddToRecentFolders(const entry_ref *folder, const char *appSig) const
|
|||||||
|
|
||||||
/*----- Private or reserved ------------------------------*/
|
/*----- Private or reserved ------------------------------*/
|
||||||
|
|
||||||
|
// ShutDown
|
||||||
|
/*! \brief Shuts down the system.
|
||||||
|
|
||||||
|
When the method succeeds, it doesn't return.
|
||||||
|
|
||||||
|
\param reboot If \c true, the system will be rebooted instead of being
|
||||||
|
powered off.
|
||||||
|
\return
|
||||||
|
- \c B_SHUTTING_DOWN, when there's already a shutdown process in
|
||||||
|
progress,
|
||||||
|
- \c B_SHUTDOWN_CANCELLED, when the user cancelled the shutdown process,
|
||||||
|
- another error code in case something went wrong.
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
BRoster::ShutDown(bool reboot)
|
||||||
|
{
|
||||||
|
status_t error = B_OK;
|
||||||
|
|
||||||
|
// compose the request message
|
||||||
|
BMessage request(B_REG_SHUT_DOWN);
|
||||||
|
if (error == B_OK)
|
||||||
|
error = request.AddBool("reboot", reboot);
|
||||||
|
|
||||||
|
// send the request
|
||||||
|
BMessage reply;
|
||||||
|
if (error == B_OK)
|
||||||
|
error = fMess.SendMessage(&request, &reply);
|
||||||
|
|
||||||
|
// evaluate the reply
|
||||||
|
if (error == B_OK && reply.what != B_REG_SUCCESS)
|
||||||
|
reply.FindInt32("error", &error);
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// AddApplication
|
// AddApplication
|
||||||
/*! \brief (Pre-)Registers an application with the registrar.
|
/*! \brief (Pre-)Registers an application with the registrar.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user