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