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:
@@ -73,6 +73,7 @@ on error: - B_NO_REPLY (fatal)
|
|||||||
|
|
||||||
message fields:
|
message fields:
|
||||||
- "reboot": If true, the system reboots instead of turning the power off.
|
- "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;
|
class ArgVector;
|
||||||
friend class Private;
|
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,
|
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,
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ 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)
|
status_t ShutDown(bool reboot, bool confirm)
|
||||||
{ return fRoster->ShutDown(reboot); }
|
{ return fRoster->ShutDown(reboot, confirm); }
|
||||||
|
|
||||||
// needed by BApplication
|
// needed by BApplication
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
// 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 asks the user to confirm the shutdown
|
||||||
// -c cancels any running shutdown
|
// -c cancels any running shutdown
|
||||||
//
|
//
|
||||||
// Some code from Shard's Archiver from BeBits (was BSD/MIT too :).
|
// 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"
|
fprintf(stderr, "usage: %s [-rqca] [-d time]\n"
|
||||||
"\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-a ask user to confirm the shutdown (ignored when -q is given),\n"
|
||||||
"\t-c cancel a running shutdown,\n"
|
"\t-c cancel a running shutdown,\n"
|
||||||
"\t-d delay shutdown by <time> seconds.\n", program);
|
"\t-d delay shutdown by <time> seconds.\n", program);
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -90,6 +92,7 @@ usage(const char *arg0)
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
bool askUser = false;
|
||||||
bool quick = false;
|
bool quick = false;
|
||||||
|
|
||||||
for (int32 i = 1; i < argc; i++) {
|
for (int32 i = 1; i < argc; i++) {
|
||||||
@@ -100,6 +103,9 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
while (arg && isalpha((++arg)[0])) {
|
while (arg && isalpha((++arg)[0])) {
|
||||||
switch (arg[0]) {
|
switch (arg[0]) {
|
||||||
|
case 'a':
|
||||||
|
askUser = true;
|
||||||
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
quick = true;
|
quick = true;
|
||||||
break;
|
break;
|
||||||
@@ -168,7 +174,7 @@ main(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
BRoster roster;
|
BRoster roster;
|
||||||
BRoster::Private rosterPrivate(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));
|
fprintf(stderr, "Shutdown failed: %s\n", strerror(error));
|
||||||
return 2;
|
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
|
\param reboot If \c true, the system will be rebooted instead of being
|
||||||
powered off.
|
powered off.
|
||||||
|
\param confirm If \c true, the user will be asked to confirm to shut down
|
||||||
|
the system.
|
||||||
\return
|
\return
|
||||||
- \c B_SHUTTING_DOWN, when there's already a shutdown process in
|
- \c B_SHUTTING_DOWN, when there's already a shutdown process in
|
||||||
progress,
|
progress,
|
||||||
@@ -1280,7 +1282,7 @@ BRoster::AddToRecentFolders(const entry_ref *folder, const char *appSig) const
|
|||||||
- another error code in case something went wrong.
|
- another error code in case something went wrong.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BRoster::ShutDown(bool reboot)
|
BRoster::ShutDown(bool reboot, bool confirm)
|
||||||
{
|
{
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
|
|
||||||
@@ -1288,6 +1290,8 @@ BRoster::ShutDown(bool reboot)
|
|||||||
BMessage request(B_REG_SHUT_DOWN);
|
BMessage request(B_REG_SHUT_DOWN);
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = request.AddBool("reboot", reboot);
|
error = request.AddBool("reboot", reboot);
|
||||||
|
if (error == B_OK)
|
||||||
|
error = request.AddBool("confirm", confirm);
|
||||||
|
|
||||||
// send the request
|
// send the request
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
|
|||||||
Reference in New Issue
Block a user