RosterPrivate: add IsShutDownInProgress()

enable to check whether a shutdown process is in progress.

Change-Id: I8efdddb3caa80e9fd188f202b6e92a888a7608e5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2042
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Jérôme Duval 2019-12-21 17:27:33 +01:00 committed by waddlesplash
parent a02f7c7bae
commit feeb4b5d93
6 changed files with 61 additions and 0 deletions

View File

@ -147,6 +147,7 @@ private:
status_t _ShutDown(bool reboot, bool confirm,
bool synchronous);
status_t _IsShutDownInProgress(bool* inProgress);
status_t _AddApplication(const char* signature,
const entry_ref* ref, uint32 flags,

View File

@ -46,6 +46,7 @@ enum {
B_REG_GET_CLIPBOARD_MESSENGER = 'rgcm',
B_REG_GET_DISK_DEVICE_MESSENGER = 'rgdm',
B_REG_SHUT_DOWN = 'rgsh',
B_REG_IS_SHUT_DOWN_IN_PROGRESS = 'rgsi',
// roster requests
B_REG_ADD_APP = 'rgaa',

View File

@ -39,6 +39,8 @@ class BRoster::Private {
status_t ShutDown(bool reboot, bool confirm, bool synchronous)
{ return fRoster->_ShutDown(reboot, confirm, synchronous); }
status_t IsShutDownInProgress(bool* inProgress)
{ return fRoster->_IsShutDownInProgress(inProgress); }
// needed by BApplication

View File

@ -1343,6 +1343,43 @@ BRoster::_ShutDown(bool reboot, bool confirm, bool synchronous)
}
/*! Checks whether a shutdown process is in progress.
\param inProgress: Pointer to a pre-allocated bool to be filled in
by this method, indicating whether or not a shutdown process
is in progress.
\return A status code, \c B_OK on success or another error code in case
something went wrong.
*/
status_t
BRoster::_IsShutDownInProgress(bool* inProgress)
{
status_t error = B_OK;
// compose the request message
BMessage request(B_REG_IS_SHUT_DOWN_IN_PROGRESS);
// send the request
BMessage reply;
if (error == B_OK)
error = fMessenger.SendMessage(&request, &reply);
// evaluate the reply
if (error == B_OK) {
if (reply.what == B_REG_SUCCESS) {
if (inProgress != NULL
&& reply.FindBool("in-progress", inProgress) != B_OK) {
error = B_ERROR;
}
} else if (reply.FindInt32("error", &error) != B_OK)
error = B_ERROR;
}
return error;
}
/*! (Pre-)Registers an application with the registrar.
This methods is invoked either to register or to pre-register an

View File

@ -248,6 +248,13 @@ Registrar::_MessageReceived(BMessage *message)
_HandleShutDown(message);
break;
}
case B_REG_IS_SHUT_DOWN_IN_PROGRESS:
{
PRINT("B_REG_IS_SHUT_DOWN_IN_PROGRESS\n");
_HandleIsShutDownInProgress(message);
break;
}
case B_REG_TEAM_DEBUGGER_ALERT:
{
if (fShutdownProcess != NULL)
@ -416,6 +423,18 @@ Registrar::_HandleShutDown(BMessage *request)
}
/*! \brief Handle a is shut down in progress request message.
\param request The request to be handled.
*/
void
Registrar::_HandleIsShutDownInProgress(BMessage *request)
{
BMessage reply(B_REG_SUCCESS);
reply.AddBool("in-progress", fShutdownProcess != NULL);
request->SendReply(&reply);
}
// #pragma mark -

View File

@ -58,6 +58,7 @@ public:
private:
void _MessageReceived(BMessage *message);
void _HandleShutDown(BMessage *message);
void _HandleIsShutDownInProgress(BMessage *message);
TRoster *fRoster;
ClipboardHandler *fClipboardHandler;