diff options
author | George Hazan <george.hazan@gmail.com> | 2013-07-29 16:41:17 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-07-29 16:41:17 +0000 |
commit | 451c98173d83ee1618d7923890e803dd7067de40 (patch) | |
tree | b747494401925ec184b45a6d22d24683d8b3e38f /plugins/StatusPlugins | |
parent | 82637f50c80f6b9b7dad3d3d49535bab277596aa (diff) |
resource clearance moved to ME_SYSTEM_PRESHUTDOWN instead of ME_SYSTEM_OKTOEXIT
git-svn-id: http://svn.miranda-ng.org/main/trunk@5527 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/StatusPlugins')
-rw-r--r-- | plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp | 16 | ||||
-rw-r--r-- | plugins/StatusPlugins/KeepStatus/keepstatus.cpp | 43 | ||||
-rw-r--r-- | plugins/StatusPlugins/StartupStatus/startupstatus.cpp | 16 | ||||
-rw-r--r-- | plugins/StatusPlugins/commonstatus.cpp | 40 |
4 files changed, 41 insertions, 74 deletions
diff --git a/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp b/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp index 1bd878db57..a6de74e205 100644 --- a/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp +++ b/plugins/StatusPlugins/AdvancedAutoAway/advancedautoaway.cpp @@ -71,10 +71,6 @@ static BOOL ignoreAltCombo = FALSE; static BOOL monitorMouse = TRUE;
static BOOL monitorKeyboard = TRUE;
static HWND confirmDialog;
-static HANDLE hAutoAwayOptionsHook;
-static HANDLE hAutoAwayShutDownHook;
-static HANDLE hProtoAckHook;
-static HANDLE hAccChangeHook;
static int mouseStationaryTimer;
HHOOK hMirandaMouseHook = NULL;
HHOOK hMirandaKeyBoardHook = NULL;
@@ -578,10 +574,6 @@ static int AutoAwayShutdown(WPARAM wParam,LPARAM lParam) #ifdef TRIGGERPLUGIN
DeInitTrigger();
#endif
- UnhookEvent(hAutoAwayOptionsHook);
- UnhookEvent(hAutoAwayShutDownHook);
- UnhookEvent(hAccChangeHook);
- UnhookEvent(hProtoAckHook);
UnhookWindowsHooks();
DestroyHookableEvent(hStateChangedEvent);
@@ -600,10 +592,10 @@ int CSModuleLoaded(WPARAM wParam, LPARAM lParam) else
MyGetLastInputInfo = NULL;
- hAccChangeHook = HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccChanged);
- hAutoAwayOptionsHook = HookEvent(ME_OPT_INITIALISE,AutoAwayOptInitialise);
- hAutoAwayShutDownHook = HookEvent(ME_SYSTEM_OKTOEXIT,AutoAwayShutdown);
- hProtoAckHook = HookEvent(ME_PROTO_ACK, ProcessProtoAck);
+ HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccChanged);
+ HookEvent(ME_OPT_INITIALISE, AutoAwayOptInitialise);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, AutoAwayShutdown);
+ HookEvent(ME_PROTO_ACK, ProcessProtoAck);
mouseStationaryTimer = 0;
lastInput = lastMirandaInput = GetTickCount();
diff --git a/plugins/StatusPlugins/KeepStatus/keepstatus.cpp b/plugins/StatusPlugins/KeepStatus/keepstatus.cpp index 024b2c5f40..d2f58536bb 100644 --- a/plugins/StatusPlugins/KeepStatus/keepstatus.cpp +++ b/plugins/StatusPlugins/KeepStatus/keepstatus.cpp @@ -30,9 +30,6 @@ struct TimerInfo { static CRITICAL_SECTION GenTimerCS, GenStatusCS, CheckContinueslyCS;
-static HANDLE hOptionsHook = NULL;
-static HANDLE hShutdownHook = NULL;
-static HANDLE hAccChangeHook = NULL;
static HANDLE hProtoAckHook = NULL;
static HANDLE hStatusChangeHook = NULL;
static HANDLE hCSStatusChangeHook = NULL;
@@ -92,8 +89,6 @@ static INT_PTR ShowPopup(TCHAR *msg, HICON hIcon); LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static DWORD CALLBACK MessageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-static int Exit(WPARAM wParam, LPARAM lParam);
-
// options.c
extern int OptionsInit(WPARAM wparam,LPARAM);
extern int InitCommonStatus();
@@ -1229,27 +1224,8 @@ int OnAccChanged(WPARAM wParam,LPARAM lParam) // =============== init stuff =================
-int CSModuleLoaded(WPARAM,LPARAM)
-{
- InitializeCriticalSection(&GenTimerCS);
- InitializeCriticalSection(&GenStatusCS);
- InitializeCriticalSection(&CheckContinueslyCS);
-
- protoList = ( OBJLIST<PROTOCOLSETTINGEX>* )&connectionSettings;
-
- hMessageWindow = NULL;
- LoadMainOptions();
- hOptionsHook = HookEvent(ME_OPT_INITIALISE, OptionsInit);
- hShutdownHook = HookEvent(ME_SYSTEM_OKTOEXIT, Exit);
- hAccChangeHook = HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccChanged);
- return 0;
-}
-
-static int Exit(WPARAM,LPARAM)
+static int onShutdown(WPARAM,LPARAM)
{
- UnhookEvent(hOptionsHook);
- UnhookEvent(hShutdownHook);
- UnhookEvent(hAccChangeHook);
UnhookEvent(hStatusChangeHook);
UnhookEvent(hProtoAckHook);
UnhookEvent(hCSStatusChangeHook);
@@ -1266,3 +1242,20 @@ static int Exit(WPARAM,LPARAM) DeleteCriticalSection(&CheckContinueslyCS);
return 0;
}
+
+int CSModuleLoaded(WPARAM,LPARAM)
+{
+ InitializeCriticalSection(&GenTimerCS);
+ InitializeCriticalSection(&GenStatusCS);
+ InitializeCriticalSection(&CheckContinueslyCS);
+
+ protoList = ( OBJLIST<PROTOCOLSETTINGEX>* )&connectionSettings;
+
+ hMessageWindow = NULL;
+ LoadMainOptions();
+
+ HookEvent(ME_OPT_INITIALISE, OptionsInit);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown);
+ HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccChanged);
+ return 0;
+}
diff --git a/plugins/StatusPlugins/StartupStatus/startupstatus.cpp b/plugins/StatusPlugins/StartupStatus/startupstatus.cpp index 6ed4a8b9f1..c5c167f0c4 100644 --- a/plugins/StatusPlugins/StartupStatus/startupstatus.cpp +++ b/plugins/StatusPlugins/StartupStatus/startupstatus.cpp @@ -74,9 +74,6 @@ TSSSetting::~TSSSetting() /////////////////////////////////////////////////////////////////////////////////////////
static HANDLE
- hOptionsHook,
- hShutdownHook,
- hAccChangeHook,
hProtoAckHook,
hCSStatusChangeHook,
hStatusChangeHook;
@@ -282,12 +279,9 @@ static VOID CALLBACK SetStatusTimed(HWND hwnd,UINT message, UINT_PTR idEvent,DWO CallService(MS_CS_SETSTATUSEX, (WPARAM)&startupSettings, 0);
}
-static int Exit(WPARAM wParam, LPARAM lParam)
+static int OnShutdown(WPARAM wParam, LPARAM lParam)
{
DeinitProfilesModule();
- UnhookEvent(hOptionsHook);
- UnhookEvent(hShutdownHook);
- UnhookEvent(hAccChangeHook);
// save last protocolstatus
int count;
@@ -371,7 +365,7 @@ static DWORD CALLBACK MessageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM log_debugA("WM_ENDSESSION");
if (wParam) {
log_debugA("WM_ENDSESSION: calling exit");
- Exit(0, 0);
+ OnShutdown(0, 0);
log_debugA("WM_ENDSESSION: exit called");
}
break;
@@ -386,11 +380,11 @@ int CSModuleLoaded(WPARAM wParam, LPARAM lParam) InitProfileModule();
- hAccChangeHook = HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccChanged);
- hOptionsHook = HookEvent(ME_OPT_INITIALISE, OptionsInit);
+ HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccChanged);
+ HookEvent(ME_OPT_INITIALISE, OptionsInit);
/* shutdown hook for normal shutdown */
- hShutdownHook = HookEvent(ME_SYSTEM_OKTOEXIT, Exit);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
/* message window for poweroff */
hMessageWindow = CreateWindowEx(0, _T("STATIC"), NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
SetWindowLongPtr(hMessageWindow, GWLP_WNDPROC, (LONG_PTR)MessageWndProc);
diff --git a/plugins/StatusPlugins/commonstatus.cpp b/plugins/StatusPlugins/commonstatus.cpp index 11b0699bbd..fdc9ddb6e6 100644 --- a/plugins/StatusPlugins/commonstatus.cpp +++ b/plugins/StatusPlugins/commonstatus.cpp @@ -21,11 +21,7 @@ #include "commonstatus.h"
// handles for hooks and other Miranda thingies
-static HANDLE hShutdownHook;
-static HANDLE hCSSetStatusExService;
-static HANDLE hCSShowConfirmDlgExService;
static HANDLE hCSStatusChangedExEvent;
-static HANDLE hCSGetProtoCountService;
OBJLIST<PROTOCOLSETTINGEX>* protoList;
@@ -34,10 +30,8 @@ char *StatusModeToDbSetting(int status,const char *suffix); DWORD StatusModeToProtoFlag(int status);
INT_PTR SetStatusEx(WPARAM wParam, LPARAM lParam);
int InitCommonStatus();
-static int ModulesLoaded(WPARAM wParam, LPARAM lParam);
-static int CreateServices();
int GetProtoCount();
-static int Exit(WPARAM wParam, LPARAM lParam);
+
// extern
extern INT_PTR ShowConfirmDialogEx(WPARAM wParam, LPARAM lParam);
@@ -337,35 +331,29 @@ int GetProtoCount() return pCount;
}
-int InitCommonStatus()
-{
- if (!CreateServices())
- hShutdownHook = HookEvent(ME_SYSTEM_OKTOEXIT, Exit);
-
- return 0;
-}
-
static int CreateServices()
{
if (ServiceExists(MS_CS_SETSTATUSEX))
return -1;
- hCSSetStatusExService = CreateServiceFunction(MS_CS_SETSTATUSEX, SetStatusEx);
- hCSShowConfirmDlgExService = CreateServiceFunction(MS_CS_SHOWCONFIRMDLGEX, ShowConfirmDialogEx);
hCSStatusChangedExEvent = CreateHookableEvent(ME_CS_STATUSCHANGEEX);
- hCSGetProtoCountService = CreateServiceFunction(MS_CS_GETPROTOCOUNT, GetProtocolCountService);
+
+ CreateServiceFunction(MS_CS_SETSTATUSEX, SetStatusEx);
+ CreateServiceFunction(MS_CS_SHOWCONFIRMDLGEX, ShowConfirmDialogEx);
+ CreateServiceFunction(MS_CS_GETPROTOCOUNT, GetProtocolCountService);
return 0;
}
-static int Exit(WPARAM wParam, LPARAM lParam) {
+static int onShutdown(WPARAM wParam, LPARAM lParam)
+{
+ DestroyHookableEvent(hCSStatusChangedExEvent);
+ return 0;
+}
- UnhookEvent(hShutdownHook);
- if (hCSSetStatusExService != 0) {
- DestroyHookableEvent(hCSStatusChangedExEvent);
- DestroyServiceFunction(hCSSetStatusExService);
- DestroyServiceFunction(hCSShowConfirmDlgExService);
- DestroyServiceFunction(hCSGetProtoCountService);
- }
+int InitCommonStatus()
+{
+ if (!CreateServices())
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown);
return 0;
}
|