Added a "confirm" parameter to BRoster::Shutdown() which causes the registrar
to ask the user to confirm shutting down the system. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13563 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f86c9cb7e8
commit
a13df0dc01
@ -73,6 +73,7 @@ on error: - B_NO_REPLY (fatal)
|
||||
|
||||
message fields:
|
||||
- "reboot": If true, the system reboots instead of turning the power off.
|
||||
- "confirm": If true, the user will be asked to confirm to shut down the system.
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
|
@ -143,7 +143,7 @@ private:
|
||||
class ArgVector;
|
||||
friend class Private;
|
||||
|
||||
status_t ShutDown(bool reboot);
|
||||
status_t ShutDown(bool reboot, bool confirm);
|
||||
|
||||
status_t AddApplication(const char *mimeSig, const entry_ref *ref,
|
||||
uint32 flags, team_id team, thread_id thread,
|
||||
|
@ -20,8 +20,8 @@ public:
|
||||
status_t SendTo(BMessage *message, BMessage *reply, bool mime);
|
||||
bool IsMessengerValid(bool mime) const;
|
||||
|
||||
status_t ShutDown(bool reboot)
|
||||
{ return fRoster->ShutDown(reboot); }
|
||||
status_t ShutDown(bool reboot, bool confirm)
|
||||
{ return fRoster->ShutDown(reboot, confirm); }
|
||||
|
||||
// needed by BApplication
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
// This program behaves identically as the BeOS R5 version, with these
|
||||
// added arguments:
|
||||
//
|
||||
// -a asks the user to confirm the shutdown
|
||||
// -c cancels any running shutdown
|
||||
//
|
||||
// Some code from Shard's Archiver from BeBits (was BSD/MIT too :).
|
||||
@ -81,6 +82,7 @@ usage(const char *arg0)
|
||||
fprintf(stderr, "usage: %s [-rqca] [-d time]\n"
|
||||
"\t-r reboot,\n"
|
||||
"\t-q quick shutdown (don't broadcast apps),\n"
|
||||
"\t-a ask user to confirm the shutdown (ignored when -q is given),\n"
|
||||
"\t-c cancel a running shutdown,\n"
|
||||
"\t-d delay shutdown by <time> seconds.\n", program);
|
||||
exit(1);
|
||||
@ -90,6 +92,7 @@ usage(const char *arg0)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
bool askUser = false;
|
||||
bool quick = false;
|
||||
|
||||
for (int32 i = 1; i < argc; i++) {
|
||||
@ -100,6 +103,9 @@ main(int argc, char **argv)
|
||||
|
||||
while (arg && isalpha((++arg)[0])) {
|
||||
switch (arg[0]) {
|
||||
case 'a':
|
||||
askUser = true;
|
||||
break;
|
||||
case 'q':
|
||||
quick = true;
|
||||
break;
|
||||
@ -168,7 +174,7 @@ main(int argc, char **argv)
|
||||
} else {
|
||||
BRoster roster;
|
||||
BRoster::Private rosterPrivate(roster);
|
||||
status_t error = rosterPrivate.ShutDown(gReboot);
|
||||
status_t error = rosterPrivate.ShutDown(gReboot, askUser);
|
||||
fprintf(stderr, "Shutdown failed: %s\n", strerror(error));
|
||||
return 2;
|
||||
}
|
||||
|
@ -1273,6 +1273,8 @@ BRoster::AddToRecentFolders(const entry_ref *folder, const char *appSig) const
|
||||
|
||||
\param reboot If \c true, the system will be rebooted instead of being
|
||||
powered off.
|
||||
\param confirm If \c true, the user will be asked to confirm to shut down
|
||||
the system.
|
||||
\return
|
||||
- \c B_SHUTTING_DOWN, when there's already a shutdown process in
|
||||
progress,
|
||||
@ -1280,7 +1282,7 @@ BRoster::AddToRecentFolders(const entry_ref *folder, const char *appSig) const
|
||||
- another error code in case something went wrong.
|
||||
*/
|
||||
status_t
|
||||
BRoster::ShutDown(bool reboot)
|
||||
BRoster::ShutDown(bool reboot, bool confirm)
|
||||
{
|
||||
status_t error = B_OK;
|
||||
|
||||
@ -1288,6 +1290,8 @@ BRoster::ShutDown(bool reboot)
|
||||
BMessage request(B_REG_SHUT_DOWN);
|
||||
if (error == B_OK)
|
||||
error = request.AddBool("reboot", reboot);
|
||||
if (error == B_OK)
|
||||
error = request.AddBool("confirm", confirm);
|
||||
|
||||
// send the request
|
||||
BMessage reply;
|
||||
|
Loading…
Reference in New Issue
Block a user