* Style cleanup, added missing copyrights.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30743 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7cec697c0b
commit
1c38b061f8
@ -1,8 +1,14 @@
|
||||
/*
|
||||
* Copyright 2005-2008, Ingo Weinhold, bonefish@users.sf.net.
|
||||
* Copyright 2006-2009, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Copyright 2006-2008, Stephan Aßmus.
|
||||
* Copyright 2006, Ryan Leavengood.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include "ShutdownProcess.h"
|
||||
|
||||
#include <new>
|
||||
#include <string.h>
|
||||
|
||||
@ -28,9 +34,7 @@
|
||||
#include <TokenSpace.h>
|
||||
#include <util/DoublyLinkedList.h>
|
||||
|
||||
#ifdef __HAIKU__
|
||||
#include <syscalls.h>
|
||||
#endif
|
||||
|
||||
#include "AppInfoListMessagingTargetSet.h"
|
||||
#include "Debug.h"
|
||||
@ -39,7 +43,6 @@
|
||||
#include "MessageEvent.h"
|
||||
#include "Registrar.h"
|
||||
#include "RosterAppInfo.h"
|
||||
#include "ShutdownProcess.h"
|
||||
#include "TRoster.h"
|
||||
|
||||
using std::nothrow;
|
||||
@ -98,16 +101,14 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
// inverse_compare_by_registration_time
|
||||
static
|
||||
bool
|
||||
static bool
|
||||
inverse_compare_by_registration_time(const RosterAppInfo* info1,
|
||||
const RosterAppInfo* info2)
|
||||
{
|
||||
return (info2->registration_time < info1->registration_time);
|
||||
}
|
||||
|
||||
// throw_error
|
||||
|
||||
/*! \brief Used to avoid type matching problems when throwing a constant.
|
||||
*/
|
||||
static inline
|
||||
@ -117,7 +118,7 @@ throw_error(status_t error)
|
||||
throw error;
|
||||
}
|
||||
|
||||
// TimeoutEvent
|
||||
|
||||
class ShutdownProcess::TimeoutEvent : public MessageEvent {
|
||||
public:
|
||||
TimeoutEvent(BHandler* target)
|
||||
@ -159,12 +160,12 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// InternalEvent
|
||||
class ShutdownProcess::InternalEvent
|
||||
: public DoublyLinkedListLinkImpl<InternalEvent> {
|
||||
public:
|
||||
InternalEvent(uint32 type, team_id team, int32 phase)
|
||||
: fType(type),
|
||||
:
|
||||
fType(type),
|
||||
fTeam(team),
|
||||
fPhase(phase)
|
||||
{
|
||||
@ -181,12 +182,10 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// InternalEventList
|
||||
struct ShutdownProcess::InternalEventList : DoublyLinkedList<InternalEvent> {
|
||||
};
|
||||
|
||||
|
||||
// QuitRequestReplyHandler
|
||||
class ShutdownProcess::QuitRequestReplyHandler : public BHandler {
|
||||
public:
|
||||
QuitRequestReplyHandler(ShutdownProcess* shutdownProcess)
|
||||
@ -222,7 +221,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// ShutdownWindow
|
||||
class ShutdownProcess::ShutdownWindow : public BWindow {
|
||||
public:
|
||||
ShutdownWindow()
|
||||
@ -529,7 +527,8 @@ private:
|
||||
|
||||
class TAlertView : public BView {
|
||||
public:
|
||||
TAlertView(BRect frame, const char *name, uint32 resizeMask, uint32 flags)
|
||||
TAlertView(BRect frame, const char* name, uint32 resizeMask,
|
||||
uint32 flags)
|
||||
: BView(frame, name, resizeMask, flags | B_WILL_DRAW),
|
||||
fAppInfo(NULL)
|
||||
{
|
||||
@ -579,9 +578,10 @@ private:
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
// constructor
|
||||
|
||||
ShutdownProcess::ShutdownProcess(TRoster* roster, EventQueue* eventQueue)
|
||||
: BLooper("shutdown process"),
|
||||
:
|
||||
BLooper("shutdown process"),
|
||||
EventMaskWatcher(BMessenger(this), B_REQUEST_QUIT),
|
||||
fWorkerLock("worker lock"),
|
||||
fRequest(NULL),
|
||||
@ -601,7 +601,7 @@ ShutdownProcess::ShutdownProcess(TRoster *roster, EventQueue *eventQueue)
|
||||
{
|
||||
}
|
||||
|
||||
// destructor
|
||||
|
||||
ShutdownProcess::~ShutdownProcess()
|
||||
{
|
||||
// terminate the GUI
|
||||
@ -655,7 +655,7 @@ ShutdownProcess::~ShutdownProcess()
|
||||
delete fRequest;
|
||||
}
|
||||
|
||||
// Init
|
||||
|
||||
status_t
|
||||
ShutdownProcess::Init(BMessage* request)
|
||||
{
|
||||
@ -729,7 +729,7 @@ ShutdownProcess::Init(BMessage *request)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// MessageReceived
|
||||
|
||||
void
|
||||
ShutdownProcess::MessageReceived(BMessage* message)
|
||||
{
|
||||
@ -857,7 +857,7 @@ PRINT(("MSG_PHASE_TIMED_OUT: phase: %ld, team: %ld\n", phase, team));
|
||||
}
|
||||
}
|
||||
|
||||
// SendReply
|
||||
|
||||
void
|
||||
ShutdownProcess::SendReply(BMessage* request, status_t error)
|
||||
{
|
||||
@ -871,7 +871,7 @@ ShutdownProcess::SendReply(BMessage *request, status_t error)
|
||||
}
|
||||
}
|
||||
|
||||
// _SendReply
|
||||
|
||||
void
|
||||
ShutdownProcess::_SendReply(status_t error)
|
||||
{
|
||||
@ -881,7 +881,7 @@ ShutdownProcess::_SendReply(status_t error)
|
||||
}
|
||||
}
|
||||
|
||||
// _SetPhase
|
||||
|
||||
void
|
||||
ShutdownProcess::_SetPhase(int32 phase)
|
||||
{
|
||||
@ -896,7 +896,7 @@ ShutdownProcess::_SetPhase(int32 phase)
|
||||
fEventQueue->RemoveEvent(fTimeoutEvent);
|
||||
}
|
||||
|
||||
// _ScheduleTimeoutEvent
|
||||
|
||||
void
|
||||
ShutdownProcess::_ScheduleTimeoutEvent(bigtime_t timeout, team_id team)
|
||||
{
|
||||
@ -914,7 +914,7 @@ ShutdownProcess::_ScheduleTimeoutEvent(bigtime_t timeout, team_id team)
|
||||
fEventQueue->AddEvent(fTimeoutEvent);
|
||||
}
|
||||
|
||||
// _SetShowShutdownWindow
|
||||
|
||||
void
|
||||
ShutdownProcess::_SetShowShutdownWindow(bool show)
|
||||
{
|
||||
@ -930,7 +930,7 @@ ShutdownProcess::_SetShowShutdownWindow(bool show)
|
||||
}
|
||||
}
|
||||
|
||||
// _InitShutdownWindow
|
||||
|
||||
void
|
||||
ShutdownProcess::_InitShutdownWindow()
|
||||
{
|
||||
@ -959,7 +959,7 @@ ShutdownProcess::_InitShutdownWindow()
|
||||
}
|
||||
}
|
||||
|
||||
// _AddShutdownWindowApps
|
||||
|
||||
void
|
||||
ShutdownProcess::_AddShutdownWindowApps(AppInfoList& infos)
|
||||
{
|
||||
@ -1027,7 +1027,7 @@ ShutdownProcess::_AddShutdownWindowApps(AppInfoList &infos)
|
||||
}
|
||||
}
|
||||
|
||||
// _RemoveShutdownWindowApp
|
||||
|
||||
void
|
||||
ShutdownProcess::_RemoveShutdownWindowApp(team_id team)
|
||||
{
|
||||
@ -1038,7 +1038,7 @@ ShutdownProcess::_RemoveShutdownWindowApp(team_id team)
|
||||
}
|
||||
}
|
||||
|
||||
// _SetShutdownWindowCurrentApp
|
||||
|
||||
void
|
||||
ShutdownProcess::_SetShutdownWindowCurrentApp(team_id team)
|
||||
{
|
||||
@ -1049,7 +1049,7 @@ ShutdownProcess::_SetShutdownWindowCurrentApp(team_id team)
|
||||
}
|
||||
}
|
||||
|
||||
// _SetShutdownWindowText
|
||||
|
||||
void
|
||||
ShutdownProcess::_SetShutdownWindowText(const char* text)
|
||||
{
|
||||
@ -1060,7 +1060,7 @@ ShutdownProcess::_SetShutdownWindowText(const char *text)
|
||||
}
|
||||
}
|
||||
|
||||
// _SetShutdownWindowCancelButtonEnabled
|
||||
|
||||
void
|
||||
ShutdownProcess::_SetShutdownWindowCancelButtonEnabled(bool enabled)
|
||||
{
|
||||
@ -1071,7 +1071,7 @@ ShutdownProcess::_SetShutdownWindowCancelButtonEnabled(bool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
// _SetShutdownWindowKillButtonEnabled
|
||||
|
||||
void
|
||||
ShutdownProcess::_SetShutdownWindowKillButtonEnabled(bool enabled)
|
||||
{
|
||||
@ -1082,7 +1082,7 @@ ShutdownProcess::_SetShutdownWindowKillButtonEnabled(bool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
// _SetShutdownWindowWaitForShutdown
|
||||
|
||||
void
|
||||
ShutdownProcess::_SetShutdownWindowWaitForShutdown()
|
||||
{
|
||||
@ -1093,7 +1093,7 @@ ShutdownProcess::_SetShutdownWindowWaitForShutdown()
|
||||
}
|
||||
}
|
||||
|
||||
// _SetShutdownWindowWaitForAbortedOK
|
||||
|
||||
void
|
||||
ShutdownProcess::_SetShutdownWindowWaitForAbortedOK()
|
||||
{
|
||||
@ -1104,7 +1104,7 @@ ShutdownProcess::_SetShutdownWindowWaitForAbortedOK()
|
||||
}
|
||||
}
|
||||
|
||||
// _NegativeQuitRequestReply
|
||||
|
||||
void
|
||||
ShutdownProcess::_NegativeQuitRequestReply(thread_id thread)
|
||||
{
|
||||
@ -1116,7 +1116,7 @@ ShutdownProcess::_NegativeQuitRequestReply(thread_id thread)
|
||||
_PushEvent(ABORT_EVENT, thread, fCurrentPhase);
|
||||
}
|
||||
|
||||
// _PrepareShutdownMessage
|
||||
|
||||
void
|
||||
ShutdownProcess::_PrepareShutdownMessage(BMessage& message) const
|
||||
{
|
||||
@ -1126,22 +1126,15 @@ ShutdownProcess::_PrepareShutdownMessage(BMessage &message) const
|
||||
BMessage::Private(message).SetReply(BMessenger(fQuitRequestReplyHandler));
|
||||
}
|
||||
|
||||
// _ShutDown
|
||||
|
||||
status_t
|
||||
ShutdownProcess::_ShutDown()
|
||||
{
|
||||
PRINT(("Invoking _kern_shutdown(%d)\n", fReboot));
|
||||
|
||||
#ifdef __HAIKU__
|
||||
RETURN_ERROR(_kern_shutdown(fReboot));
|
||||
#else
|
||||
// we can't do anything on R5
|
||||
return B_ERROR;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// _PushEvent
|
||||
status_t
|
||||
ShutdownProcess::_PushEvent(uint32 eventType, team_id team, int32 phase)
|
||||
{
|
||||
@ -1160,7 +1153,7 @@ ShutdownProcess::_PushEvent(uint32 eventType, team_id team, int32 phase)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// _GetNextEvent
|
||||
|
||||
status_t
|
||||
ShutdownProcess::_GetNextEvent(uint32& eventType, thread_id& team, int32& phase,
|
||||
bool block)
|
||||
@ -1210,14 +1203,14 @@ ShutdownProcess::_GetNextEvent(uint32 &eventType, thread_id &team, int32 &phase,
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// _WorkerEntry
|
||||
|
||||
status_t
|
||||
ShutdownProcess::_WorkerEntry(void* data)
|
||||
{
|
||||
return ((ShutdownProcess*)data)->_Worker();
|
||||
}
|
||||
|
||||
// _Worker
|
||||
|
||||
status_t
|
||||
ShutdownProcess::_Worker()
|
||||
{
|
||||
@ -1239,7 +1232,7 @@ ShutdownProcess::_Worker()
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// _WorkerDoShutdown
|
||||
|
||||
void
|
||||
ShutdownProcess::_WorkerDoShutdown()
|
||||
{
|
||||
@ -1333,9 +1326,7 @@ ShutdownProcess::_WorkerDoShutdown()
|
||||
break;
|
||||
} while (event != REBOOT_SYSTEM_EVENT);
|
||||
|
||||
#ifdef __HAIKU__
|
||||
_kern_shutdown(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
// either there's no GUI or reboot failed: we enter the kernel debugger
|
||||
@ -1502,7 +1493,7 @@ ShutdownProcess::_QuitApps(AppInfoList &list, bool systemApps)
|
||||
}
|
||||
}
|
||||
|
||||
// _QuitBackgroundApps
|
||||
|
||||
void
|
||||
ShutdownProcess::_QuitBackgroundApps()
|
||||
{
|
||||
@ -1535,7 +1526,7 @@ ShutdownProcess::_QuitBackgroundApps()
|
||||
PRINT(("ShutdownProcess::_QuitBackgroundApps() done\n"));
|
||||
}
|
||||
|
||||
// _WaitForBackgroundApps
|
||||
|
||||
void
|
||||
ShutdownProcess::_WaitForBackgroundApps()
|
||||
{
|
||||
@ -1569,7 +1560,7 @@ ShutdownProcess::_WaitForBackgroundApps()
|
||||
PRINT(("ShutdownProcess::_WaitForBackgroundApps() done\n"));
|
||||
}
|
||||
|
||||
// _KillBackgroundApps
|
||||
|
||||
void
|
||||
ShutdownProcess::_KillBackgroundApps()
|
||||
{
|
||||
@ -1613,7 +1604,7 @@ ShutdownProcess::_KillBackgroundApps()
|
||||
}
|
||||
}
|
||||
|
||||
// _QuitNonApps
|
||||
|
||||
void
|
||||
ShutdownProcess::_QuitNonApps()
|
||||
{
|
||||
@ -1661,7 +1652,7 @@ ShutdownProcess::_QuitNonApps()
|
||||
PRINT(("ShutdownProcess::_QuitNonApps() done\n"));
|
||||
}
|
||||
|
||||
// _QuitBlockingApp
|
||||
|
||||
void
|
||||
ShutdownProcess::_QuitBlockingApp(AppInfoList& list, team_id team,
|
||||
const char* appName, bool cancelAllowed)
|
||||
@ -1744,7 +1735,7 @@ ShutdownProcess::_QuitBlockingApp(AppInfoList &list, team_id team,
|
||||
}
|
||||
}
|
||||
|
||||
// _DisplayAbortingApp
|
||||
|
||||
void
|
||||
ShutdownProcess::_DisplayAbortingApp(team_id team)
|
||||
{
|
||||
@ -1774,8 +1765,8 @@ ShutdownProcess::_DisplayAbortingApp(team_id team)
|
||||
|
||||
// compose the text to be displayed
|
||||
char buffer[1024];
|
||||
snprintf(buffer, sizeof(buffer), "Application \"%s\" has aborted the shutdown "
|
||||
"process.", appName);
|
||||
snprintf(buffer, sizeof(buffer), "Application \"%s\" has aborted the "
|
||||
"shutdown process.", appName);
|
||||
|
||||
// set up the window
|
||||
_SetShutdownWindowCurrentApp(team);
|
||||
@ -1802,14 +1793,6 @@ ShutdownProcess::_DisplayAbortingApp(team_id team)
|
||||
// stop waiting when the user hit the cancel button
|
||||
if (event == ABORT_EVENT && phase == ABORTED_PHASE && eventTeam < 0)
|
||||
break;
|
||||
|
||||
// This doesn't give us anything; it will just prevent us to see which
|
||||
// app was responsible after all...
|
||||
#if 0
|
||||
// also stop when the responsible app quit
|
||||
if ((event == APP_QUIT_EVENT) && eventTeam == team)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <hash_set>
|
||||
|
||||
#include <Locker.h>
|
||||
#include <Looper.h>
|
||||
|
||||
#include "AppInfoList.h"
|
||||
@ -28,8 +29,9 @@ class TRoster;
|
||||
// EventMaskWatcher fails otherwise.
|
||||
class ShutdownProcess : public BLooper, public EventMaskWatcher {
|
||||
public:
|
||||
ShutdownProcess(TRoster *roster, EventQueue *eventQueue);
|
||||
~ShutdownProcess();
|
||||
ShutdownProcess(TRoster* roster,
|
||||
EventQueue* eventQueue);
|
||||
virtual ~ShutdownProcess();
|
||||
|
||||
status_t Init(BMessage* request);
|
||||
|
||||
@ -45,12 +47,14 @@ private:
|
||||
void _PrepareShutdownMessage(BMessage& message) const;
|
||||
status_t _ShutDown();
|
||||
|
||||
status_t _PushEvent(uint32 eventType, team_id team, int32 phase);
|
||||
status_t _GetNextEvent(uint32 &eventType, team_id &team, int32 &phase,
|
||||
bool block);
|
||||
status_t _PushEvent(uint32 eventType, team_id team,
|
||||
int32 phase);
|
||||
status_t _GetNextEvent(uint32& eventType, team_id& team,
|
||||
int32& phase, bool block);
|
||||
|
||||
void _SetPhase(int32 phase);
|
||||
void _ScheduleTimeoutEvent(bigtime_t timeout, team_id team = -1);
|
||||
void _ScheduleTimeoutEvent(bigtime_t timeout,
|
||||
team_id team = -1);
|
||||
|
||||
bool _LockAppLists();
|
||||
void _UnlockAppLists();
|
||||
@ -61,8 +65,10 @@ private:
|
||||
void _RemoveShutdownWindowApp(team_id team);
|
||||
void _SetShutdownWindowCurrentApp(team_id team);
|
||||
void _SetShutdownWindowText(const char* text);
|
||||
void _SetShutdownWindowCancelButtonEnabled(bool enabled);
|
||||
void _SetShutdownWindowKillButtonEnabled(bool enabled);
|
||||
void _SetShutdownWindowCancelButtonEnabled(
|
||||
bool enabled);
|
||||
void _SetShutdownWindowKillButtonEnabled(
|
||||
bool enabled);
|
||||
void _SetShutdownWindowWaitForShutdown();
|
||||
void _SetShutdownWindowWaitForAbortedOK();
|
||||
|
||||
@ -70,14 +76,15 @@ private:
|
||||
status_t _Worker();
|
||||
|
||||
void _WorkerDoShutdown();
|
||||
bool _WaitForApp(team_id team, AppInfoList *list, bool systemApps);
|
||||
bool _WaitForApp(team_id team, AppInfoList* list,
|
||||
bool systemApps);
|
||||
void _QuitApps(AppInfoList& list, bool systemApps);
|
||||
void _QuitBackgroundApps();
|
||||
void _WaitForBackgroundApps();
|
||||
void _KillBackgroundApps();
|
||||
void _QuitNonApps();
|
||||
void _QuitBlockingApp(AppInfoList &list, team_id team, const char *appName,
|
||||
bool cancelAllowed);
|
||||
void _QuitBlockingApp(AppInfoList& list, team_id team,
|
||||
const char* appName, bool cancelAllowed);
|
||||
void _DisplayAbortingApp(team_id team);
|
||||
void _WaitForDebuggedTeams();
|
||||
|
||||
@ -90,7 +97,8 @@ private:
|
||||
|
||||
friend class QuitRequestReplyHandler;
|
||||
|
||||
BLocker fWorkerLock; // protects fields shared by looper
|
||||
BLocker fWorkerLock;
|
||||
// protects fields shared by looper
|
||||
// and worker
|
||||
BMessage* fRequest;
|
||||
TRoster* fRoster;
|
||||
|
Loading…
Reference in New Issue
Block a user