From 451c98173d83ee1618d7923890e803dd7067de40 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 29 Jul 2013 16:41:17 +0000 Subject: 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 --- plugins/AVS/src/version.h | 2 +- plugins/AuthState/src/main.cpp | 4 +- plugins/BuddyExpectator/src/BuddyExpectator.cpp | 4 +- plugins/Import/src/main.cpp | 2 +- plugins/MetaContacts/src/meta_services.cpp | 20 ++---- plugins/SecureIM/src/commonheaders.h | 2 +- plugins/SecureIM/src/main.cpp | 4 +- plugins/SendScreenshotPlus/src/dlg_msgbox.cpp | 63 +++++++------------ plugins/SendScreenshotPlus/src/mir_icolib.cpp | 56 ++++++++--------- plugins/SendScreenshotPlus/src/mir_string.cpp | 73 ++-------------------- plugins/SendScreenshotPlus/src/mir_string.h | 58 +++-------------- plugins/SplashScreen/src/main.cpp | 34 +++------- .../AdvancedAutoAway/advancedautoaway.cpp | 16 ++--- plugins/StatusPlugins/KeepStatus/keepstatus.cpp | 43 ++++++------- .../StatusPlugins/StartupStatus/startupstatus.cpp | 16 ++--- plugins/StatusPlugins/commonstatus.cpp | 40 +++++------- plugins/TrafficCounter/src/TrafficCounter.cpp | 2 +- 17 files changed, 126 insertions(+), 313 deletions(-) (limited to 'plugins') diff --git a/plugins/AVS/src/version.h b/plugins/AVS/src/version.h index ee1596bb77..70435c2294 100644 --- a/plugins/AVS/src/version.h +++ b/plugins/AVS/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 11 #define __RELEASE_NUM 0 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM diff --git a/plugins/AuthState/src/main.cpp b/plugins/AuthState/src/main.cpp index e7dd62fd74..4771928552 100644 --- a/plugins/AuthState/src/main.cpp +++ b/plugins/AuthState/src/main.cpp @@ -183,7 +183,7 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) return 0; } -int onSystemOKToExit(WPARAM wParam,LPARAM lParam) +static int onShutdown(WPARAM wParam,LPARAM lParam) { DestroyServiceFunction(hAuthMenuSelected); return 0; @@ -194,7 +194,7 @@ extern "C" int __declspec(dllexport) Load(void) mir_getLP(&pluginInfo); HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded); - HookEvent(ME_SYSTEM_OKTOEXIT,onSystemOKToExit); + HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown); HookEvent(ME_DB_CONTACT_SETTINGCHANGED, onContactSettingChanged); bUseAuthIcon = db_get_b(NULL, MODULENAME, "EnableAuthIcon", 1); diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp index 8fd0bcede9..3d0e65dec6 100644 --- a/plugins/BuddyExpectator/src/BuddyExpectator.cpp +++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp @@ -675,7 +675,7 @@ int ContactAdded(WPARAM wParam, LPARAM lParam) return 0; } -int onSystemOKToExit(WPARAM wParam,LPARAM lParam) +int onShutdown(WPARAM wParam,LPARAM lParam) { DestroyServiceFunction(hContactReturnedAction); DestroyServiceFunction(hContactStillAbsentAction); @@ -701,7 +701,7 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SettingChanged); HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); - HookEvent(ME_SYSTEM_OKTOEXIT,onSystemOKToExit); + HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown); HookEvent(ME_DB_CONTACT_ADDED, ContactAdded); diff --git a/plugins/Import/src/main.cpp b/plugins/Import/src/main.cpp index 4329e6a5c5..593154967c 100644 --- a/plugins/Import/src/main.cpp +++ b/plugins/Import/src/main.cpp @@ -100,7 +100,7 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam) static int OnExit(WPARAM wParam, LPARAM lParam) { - if ( hwndWizard ) + if (hwndWizard) SendMessage(hwndWizard, WM_CLOSE, 0, 0); return 0; } diff --git a/plugins/MetaContacts/src/meta_services.cpp b/plugins/MetaContacts/src/meta_services.cpp index 0bc80c7254..8e27411d78 100755 --- a/plugins/MetaContacts/src/meta_services.cpp +++ b/plugins/MetaContacts/src/meta_services.cpp @@ -1351,7 +1351,6 @@ INT_PTR Meta_OnOff(WPARAM wParam, LPARAM lParam) int Meta_PreShutdown(WPARAM wParam, LPARAM lParam) { - //MessageBox(0, "Preshutdown called", "MC", MB_OK); Meta_SetStatus((WPARAM)ID_STATUS_OFFLINE, 0); Meta_UnhideLinkedContacts(); Meta_SuppressStatus(FALSE); @@ -1363,11 +1362,6 @@ int Meta_PreShutdown(WPARAM wParam, LPARAM lParam) { return 0; } -int Meta_OkToExit(WPARAM wParam, LPARAM lParam) { - Meta_SetStatus((WPARAM)ID_STATUS_OFFLINE, 0); - return 0; -} - INT_PTR MenuFunc(WPARAM wParam, LPARAM lParam, LPARAM param) { return Meta_ContactMenuFunc(wParam, param); @@ -1455,19 +1449,17 @@ void Meta_InitServices() // hook other module events we need HookEvent(ME_PROTO_ACK, Meta_HandleACK); - HookEvent(ME_DB_CONTACT_SETTINGCHANGED, Meta_SettingChanged); - HookEvent(ME_SYSTEM_MODULESLOADED, Meta_ModulesLoaded); HookEvent(ME_PROTO_CONTACTISTYPING, Meta_ContactIsTyping); HookEvent(ME_DB_CONTACT_DELETED, Meta_ContactDeleted); - HookEvent(ME_OPT_INITIALISE, Meta_OptInit ); - + HookEvent(ME_DB_CONTACT_SETTINGCHANGED, Meta_SettingChanged); + HookEvent(ME_OPT_INITIALISE, Meta_OptInit); + HookEvent(ME_SYSTEM_MODULESLOADED, Meta_ModulesLoaded); HookEvent(ME_SYSTEM_PRESHUTDOWN, Meta_PreShutdown); - HookEvent(ME_SYSTEM_OKTOEXIT, Meta_OkToExit); // hook our own events, used to call Meta_GetMostOnline which sets nick for metacontact - HookEvent(ME_MC_DEFAULTTCHANGED, Meta_CallMostOnline ); - HookEvent(ME_MC_FORCESEND, Meta_CallMostOnline ); - HookEvent(ME_MC_UNFORCESEND, Meta_CallMostOnline ); + HookEvent(ME_MC_DEFAULTTCHANGED, Meta_CallMostOnline); + HookEvent(ME_MC_FORCESEND, Meta_CallMostOnline); + HookEvent(ME_MC_UNFORCESEND, Meta_CallMostOnline); // redirect nudge events hEventNudge = CreateHookableEvent(META_PROTO "/Nudge"); diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h index b821fbcbc5..e335fddb9b 100644 --- a/plugins/SecureIM/src/commonheaders.h +++ b/plugins/SecureIM/src/commonheaders.h @@ -99,7 +99,7 @@ extern DWORD iCoreVersion; extern CRITICAL_SECTION localQueueMutex; int onModulesLoaded(WPARAM, LPARAM); -int onSystemOKToExit(WPARAM, LPARAM); +int onShutdown(WPARAM, LPARAM); int ModuleLoad(WPARAM wParam, LPARAM lParam); __forceinline int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam) diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index e07e91669c..a08f3c3035 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -95,7 +95,7 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) // hook events HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded); - HookEvent(ME_SYSTEM_OKTOEXIT, onSystemOKToExit); + HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown); HookEvent(ME_SYSTEM_MODULELOAD, ModuleLoad); HookEvent(ME_SYSTEM_MODULEUNLOAD, ModuleLoad); @@ -345,7 +345,7 @@ int onModulesLoaded(WPARAM, LPARAM) return 0; } -int onSystemOKToExit(WPARAM, LPARAM) +int onShutdown(WPARAM, LPARAM) { if (bSavePass) { LPSTR tmp = gpg_get_passphrases(); diff --git a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp index de6d03b297..4ada4d76e9 100644 --- a/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp +++ b/plugins/SendScreenshotPlus/src/dlg_msgbox.cpp @@ -112,77 +112,56 @@ void MakePopupAction(POPUPACTION &pa, INT id) pa.wParam = MAKEWORD(id, BN_CLICKED); pa.lParam = 0; - switch (id) - { + switch (id) { case IDOK: - { - pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK); - mir_strcpy(pa.lpzTitle, MODNAME"/Ok"); - } + pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK); + lstrcpyA(pa.lpzTitle, MODNAME"/Ok"); break; case IDCLOSE: case IDCANCEL: - { - pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL); - mir_strcpy(pa.lpzTitle, MODNAME"/Cancel"); - } + pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL); + lstrcpyA(pa.lpzTitle, MODNAME"/Cancel"); break; case IDABORT: - { - pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL); - mir_strcpy(pa.lpzTitle, MODNAME"/Abort"); - } + pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL); + lstrcpyA(pa.lpzTitle, MODNAME"/Abort"); break; case IDRETRY: - { - pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_UPDATE); - mir_strcpy(pa.lpzTitle, MODNAME"/Retry"); - } + pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_UPDATE); + lstrcpyA(pa.lpzTitle, MODNAME"/Retry"); break; case IDIGNORE: - { - pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK); - mir_strcpy(pa.lpzTitle, MODNAME"/Ignore"); - } + pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK); + lstrcpyA(pa.lpzTitle, MODNAME"/Ignore"); break; case IDYES: - { - pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK); - mir_strcpy(pa.lpzTitle, MODNAME"/Yes"); - } + pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK); + lstrcpyA(pa.lpzTitle, MODNAME"/Yes"); break; case IDNO: - { - pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL); - mir_strcpy(pa.lpzTitle, MODNAME"/No"); - } + pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL); + lstrcpyA(pa.lpzTitle, MODNAME"/No"); break; case IDHELP: - { - pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL); - mir_strcpy(pa.lpzTitle, MODNAME"/Help"); - } + pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL); + lstrcpyA(pa.lpzTitle, MODNAME"/Help"); break; case IDALL: - { - pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK); - mir_strcpy(pa.lpzTitle, MODNAME"/All"); - } + pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_OK); + lstrcpyA(pa.lpzTitle, MODNAME"/All"); break; case IDNONE: - { - pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL); - mir_strcpy(pa.lpzTitle, MODNAME"/None"); - } + pa.lchIcon = IcoLib_GetIcon(ICO_PLUG_CANCEL); + lstrcpyA(pa.lpzTitle, MODNAME"/None"); } } diff --git a/plugins/SendScreenshotPlus/src/mir_icolib.cpp b/plugins/SendScreenshotPlus/src/mir_icolib.cpp index 2523aa196c..041a84b7d0 100644 --- a/plugins/SendScreenshotPlus/src/mir_icolib.cpp +++ b/plugins/SendScreenshotPlus/src/mir_icolib.cpp @@ -26,48 +26,46 @@ this file is taken from UserinfoEx plugin and support UserinfoEx icon pack !!!! #include "global.h" +HICON ghDefIcon = NULL; + +//IDI_PLUG_MAIN must be the first icon from Plugin.dll, all other icon must be IDI_PLUG_MAIN+n -typedef struct _ICODESC +struct { LPSTR pszName; LPSTR pszDesc; LPSTR pszSection; WORD idResource; BYTE size; -} ICODESC; - -HICON ghDefIcon = NULL; - -//IDI_PLUG_MAIN must be the first icon from Plugin.dll, all other icon must be IDI_PLUG_MAIN+n -static ICODESC icoDesc[] = +} +static icoDesc[] = { // common - { ICO_PLUG_SSWINDOW1, LPGEN("Screenshot Icon1"), SECT_COMMON, IDI_PLUG_MAIN, -1 }, - { ICO_PLUG_SSWINDOW2, LPGEN("Screenshot Icon2"), SECT_COMMON, IDI_PLUG_ICON1, 0 }, - { ICO_PLUG_SSTARGET, LPGEN("Target Cursor"), SECT_COMMON, IDI_PLUG_ICON2, 1 }, - { ICO_PLUG_SSMONITOR, LPGEN("Target Desktop"), SECT_COMMON, IDI_PLUG_ICON3, 1 }, - { ICO_PLUG_SSDEFAULT, LPGEN("Default"), SECT_COMMON, IDI_PLUG_DEFAULT, 0 }, + { ICO_PLUG_SSWINDOW1, LPGEN("Screenshot Icon1"), SECT_COMMON, IDI_PLUG_MAIN, -1 }, + { ICO_PLUG_SSWINDOW2, LPGEN("Screenshot Icon2"), SECT_COMMON, IDI_PLUG_ICON1, 0 }, + { ICO_PLUG_SSTARGET, LPGEN("Target Cursor"), SECT_COMMON, IDI_PLUG_ICON2, 1 }, + { ICO_PLUG_SSMONITOR, LPGEN("Target Desktop"), SECT_COMMON, IDI_PLUG_ICON3, 1 }, + { ICO_PLUG_SSDEFAULT, LPGEN("Default"), SECT_COMMON, IDI_PLUG_DEFAULT, 0 }, // overlays - { ICO_PLUG_OVERLAYON, LPGEN("overlay on"), SECT_OVERLAY, IDI_PLUG_OVERLAYON, 0 }, - { ICO_PLUG_OVERLAYOFF, LPGEN("overlay off"), SECT_OVERLAY, IDI_PLUG_OVERLAYOFF,0 }, + { ICO_PLUG_OVERLAYON, LPGEN("overlay on"), SECT_OVERLAY, IDI_PLUG_OVERLAYON, 0 }, + { ICO_PLUG_OVERLAYOFF, LPGEN("overlay off"), SECT_OVERLAY, IDI_PLUG_OVERLAYOFF, 0 }, // button icons - { ICO_PLUG_SSHELP, LPGEN("Help"), SECT_BUTTONS, IDI_PLUG_HELP, 0 }, - { ICO_PLUG_SSFOLDERO, LPGEN("Open Folder"), SECT_BUTTONS, IDI_PLUG_FOLDERO, 0 }, - { ICO_PLUG_SSDESKOFF, LPGEN("description off"), SECT_BUTTONS, IDI_PLUG_DESKOFF, 0 }, - { ICO_PLUG_SSDESKON, LPGEN("description on"), SECT_BUTTONS, IDI_PLUG_DESKON, 0 }, - { ICO_PLUG_SSDELOFF, LPGEN("delete off"), SECT_BUTTONS, IDI_PLUG_DELOFF, 0 }, - { ICO_PLUG_SSDELON, LPGEN("delete on"), SECT_BUTTONS, IDI_PLUG_DELON, 0 }, - { ICO_PLUG_ARROWL, LPGEN("Prev"), SECT_BUTTONS, IDI_PLUG_ARROWL, 0 }, - { ICO_PLUG_ARROWR, LPGEN("Next"), SECT_BUTTONS, IDI_PLUG_ARROWR, 0 }, - - { ICO_PLUG_UPDATE, LPGEN("Update"), SECT_BUTTONS, IDI_PLUG_UPDATE, 0 }, - { ICO_PLUG_OK, LPGEN("OK"), SECT_BUTTONS, IDI_PLUG_OK, 0 }, - { ICO_PLUG_CANCEL, LPGEN("Cancel"), SECT_BUTTONS, IDI_PLUG_CLOSE, 0 }, - { ICO_PLUG_APPLY, LPGEN("Apply"), SECT_BUTTONS, IDI_PLUG_APPLY, 0 }, - { ICO_PLUG_EDIT, LPGEN("Edit"), SECT_BUTTONS, IDI_PLUG_EDIT, 0 }, - { ICO_PLUG_DOWNARROW, LPGEN("Down arrow"), SECT_BUTTONS, IDI_PLUG_DOWNARROW, 0 }, + { ICO_PLUG_SSHELP, LPGEN("Help"), SECT_BUTTONS, IDI_PLUG_HELP, 0 }, + { ICO_PLUG_SSFOLDERO, LPGEN("Open Folder"), SECT_BUTTONS, IDI_PLUG_FOLDERO, 0 }, + { ICO_PLUG_SSDESKOFF, LPGEN("description off"), SECT_BUTTONS, IDI_PLUG_DESKOFF, 0 }, + { ICO_PLUG_SSDESKON, LPGEN("description on"), SECT_BUTTONS, IDI_PLUG_DESKON, 0 }, + { ICO_PLUG_SSDELOFF, LPGEN("delete off"), SECT_BUTTONS, IDI_PLUG_DELOFF, 0 }, + { ICO_PLUG_SSDELON, LPGEN("delete on"), SECT_BUTTONS, IDI_PLUG_DELON, 0 }, + { ICO_PLUG_ARROWL, LPGEN("Prev"), SECT_BUTTONS, IDI_PLUG_ARROWL, 0 }, + { ICO_PLUG_ARROWR, LPGEN("Next"), SECT_BUTTONS, IDI_PLUG_ARROWR, 0 }, + { ICO_PLUG_UPDATE, LPGEN("Update"), SECT_BUTTONS, IDI_PLUG_UPDATE, 0 }, + { ICO_PLUG_OK, LPGEN("OK"), SECT_BUTTONS, IDI_PLUG_OK, 0 }, + { ICO_PLUG_CANCEL, LPGEN("Cancel"), SECT_BUTTONS, IDI_PLUG_CLOSE, 0 }, + { ICO_PLUG_APPLY, LPGEN("Apply"), SECT_BUTTONS, IDI_PLUG_APPLY, 0 }, + { ICO_PLUG_EDIT, LPGEN("Edit"), SECT_BUTTONS, IDI_PLUG_EDIT, 0 }, + { ICO_PLUG_DOWNARROW, LPGEN("Down arrow"), SECT_BUTTONS, IDI_PLUG_DOWNARROW, 0 }, }; /** diff --git a/plugins/SendScreenshotPlus/src/mir_string.cpp b/plugins/SendScreenshotPlus/src/mir_string.cpp index 251b5fd45e..d3550e6a04 100644 --- a/plugins/SendScreenshotPlus/src/mir_string.cpp +++ b/plugins/SendScreenshotPlus/src/mir_string.cpp @@ -27,15 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "global.h" -char *mir_strncpy(char *pszDest, const char *pszSrc, const size_t cchDest) -{ - if (!pszDest || !pszSrc || !cchDest) - return NULL; - pszDest = strncpy(pszDest, pszSrc, cchDest-1); - pszDest[cchDest-1] = 0; - return pszDest; -} - wchar_t *mir_wcsncpy(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest) { if (!pszDest || !pszSrc || !cchDest) @@ -45,15 +36,6 @@ wchar_t *mir_wcsncpy(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDe return pszDest; } -char *mir_strncat(char *pszDest, const char *pszSrc, const size_t cchDest) -{ - if (!pszDest || !pszSrc || !cchDest) - return NULL; - strncat(pszDest, pszSrc, cchDest-1); - pszDest[cchDest-1] = 0; - return pszDest; -} - wchar_t *mir_wcsncat(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest) { if (!pszDest || !pszSrc || !cchDest) @@ -63,55 +45,14 @@ wchar_t *mir_wcsncat(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDe return pszDest; } -char *mir_strncat_c(char *pszDest, const char cSrc) { - size_t lenNew = strlen(pszDest) + 2; - if (!pszDest) - pszDest = (char *) mir_alloc(sizeof(char) * lenNew); - else - pszDest = (char *) mir_realloc(pszDest, sizeof(char) * lenNew); - pszDest[lenNew-2] = cSrc; - pszDest[lenNew-1] = 0; - return pszDest; -} - -wchar_t *mir_wcsncat_c(wchar_t *pwszDest, const wchar_t wcSrc) { - size_t lenNew = wcslen(pwszDest) + 2; - if (!pwszDest) - pwszDest = (wchar_t *) mir_alloc(sizeof(wchar_t) * lenNew); - else - pwszDest = (wchar_t *) mir_realloc(pwszDest, sizeof(wchar_t) * lenNew); - pwszDest[lenNew-2] = wcSrc; - pwszDest[lenNew-1] = 0; - return pwszDest; -} - -char *mir_strnerase(char *pszDest, size_t sizeFrom, size_t sizeTo) { - char *pszReturn = NULL; - size_t sizeNew, sizeLen = strlen(pszDest); - if (sizeFrom >= 0 && sizeFrom < sizeLen && sizeTo >= 0 && sizeTo <= sizeLen && sizeFrom < sizeTo) { - sizeNew = sizeLen - (sizeTo - sizeFrom); - size_t sizeCopy = sizeNew - sizeFrom; - pszReturn = (char *) mir_alloc(sizeNew + 1); - memcpy(pszReturn, pszDest, sizeFrom); - memcpy(pszReturn + sizeFrom, pszDest + sizeTo, sizeCopy); - pszReturn[sizeNew] = 0; - } - - pszDest = (char *) mir_realloc(pszDest, sizeNew + 1); - pszDest = mir_strcpy(pszDest, pszReturn); - mir_free(pszReturn); - return pszDest; -} - //--------------------------------------------------------------------------- void mir_stradd(char* &pszDest, const char *pszSrc) { - if(!pszSrc) { + if(!pszSrc) return; - } - else if(!pszDest) { + + if(!pszDest) pszDest = mir_strdup(pszSrc); - } else { size_t lenDest = strlen(pszDest); size_t lenSrc = strlen(pszSrc); @@ -125,12 +66,11 @@ void mir_stradd(char* &pszDest, const char *pszSrc) void mir_wcsadd(wchar_t* &pszDest, const wchar_t *pszSrc) { - if(!pszSrc) { + if(!pszSrc) return; - } - else if(!pszDest) { + + if(!pszDest) pszDest = mir_wstrdup(pszSrc); - } else { size_t lenDest = wcslen(pszDest); size_t lenSrc = wcslen(pszSrc); @@ -141,4 +81,3 @@ void mir_wcsadd(wchar_t* &pszDest, const wchar_t *pszSrc) pszDest[lenNew-1] = 0; } } - diff --git a/plugins/SendScreenshotPlus/src/mir_string.h b/plugins/SendScreenshotPlus/src/mir_string.h index c560048147..7c03b9dc48 100644 --- a/plugins/SendScreenshotPlus/src/mir_string.h +++ b/plugins/SendScreenshotPlus/src/mir_string.h @@ -1,7 +1,7 @@ /* Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, +Copyright 2000-2009 Miranda ICQ/IM project, This file is part of Send Screenshot Plus, a Miranda IM plugin. Copyright (c) 2010 Ing.U.Horn @@ -27,58 +27,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef _MIR_STRING_H_INCLUDED_ #define _MIR_STRING_H_INCLUDED_ -#define mir_wcsdup mir_wstrdup +#define mir_tcsadd mir_wcsadd +#define mir_tcsncpy mir_wcsncpy +#define mir_tcsncat mir_wcsncat - - #define mir_tcslen mir_wcslen - #define mir_tcscpy mir_wcscpy - #define mir_tcsncpy mir_wcsncpy - #define mir_tcsncat mir_wcsncat - #define mir_tcsdup mir_wcsdup - #define mir_tcscmp mir_wcscmp - #define mir_tcsncmp mir_wcsncmp - #define mir_tcsicmp mir_wcsicmp - #define mir_tcsnicmp mir_wcsnicmp - #define mir_tcschr mir_wcschr - #define mir_tcsrchr mir_wcsrchr - #define mir_tcsncat_c mir_wcsncat_c - #define mir_tcsadd mir_wcsadd - - - -#define mir_strlen(s) (((s)!=0)?strlen(s):0) -#define mir_strcpy(d,s) (((s)!=0&&(d)!=0)?strcpy(d,s):0) -#define mir_strcmp(s1,s2) ((s1)==0||(s2)==0||strcmp((s1),(s2))) -#define mir_strncmp(s1,s2,n) ((s1)==0||(s2)==0||strncmp((s1),(s2),(n))) -#define mir_stricmp(s1,s2) ((s1)==0||(s2)==0||_stricmp((s1),(s2))) -#define mir_strnicmp(s1,s2,n) ((s1)==0||(s2)==0||_strnicmp((s1),(s2),(n))) -#define mir_strchr(s,c) (((s)!=0)?strchr((s),(c)):0) -#define mir_strrchr(s,c) (((s)!=0)?strrchr((s),(c)):0) - -#define mir_wcslen(s) (((s)!=0)?wcslen(s):0) -#define mir_wcscpy(d,s) (((s)!=0&&(d)!=0)?wcscpy(d,s):0) -#define mir_wcscmp(s1,s2) ((s1)==0||(s2)==0||wcscmp((s1),(s2))) -#define mir_wcsncmp(s1,s2,n) ((s1)==0||(s2)==0||wcsncmp((s1),(s2),(n))) -#define mir_wcsicmp(s1,s2) ((s1)==0||(s2)==0||_wcsicmp((s1),(s2))) -#define mir_wcsnicmp(s1,s2,n) ((s1)==0||(s2)==0||_wcsnicmp((s1),(s2),(n))) -#define mir_wcschr(s,c) (((s)!=0)?wcschr((s),(c)):0) -#define mir_wcsrchr(s,c) (((s)!=0)?wcsrchr((s),(c)):0) - -//#define mir_free(ptr) (if (x) mmi.free(x); *(&(x)) = 0;} #define mir_freeAndNil(ptr) {if(ptr) mir_free(ptr); ptr = NULL;} -char * mir_strncpy(char *pszDest, const char *pszSrc, const size_t cchDest); -wchar_t * mir_wcsncpy(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest); - -char * mir_strncat(char *pszDest, const char *pszSrc, const size_t cchDest); -wchar_t * mir_wcsncat(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest); - -char * mir_strncat_c(char *pszDest, const char cSrc); -char * mir_wcsncat_c(char *pszDest, const char cSrc); - -char * mir_strnerase(char *pszDest, size_t sizeFrom, size_t sizeTo); +wchar_t* mir_wcsncpy(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest); +wchar_t* mir_wcsncat(wchar_t *pszDest, const wchar_t *pszSrc, const size_t cchDest); -void mir_stradd(char * &pszDest, const char *pszSrc); -void mir_wcsadd(wchar_t * &pszDest, const wchar_t *pszSrc); +void mir_stradd(char * &pszDest, const char *pszSrc); +void mir_wcsadd(wchar_t * &pszDest, const wchar_t *pszSrc); #endif /* _MIR_STRING_H_INCLUDED_ */ \ No newline at end of file diff --git a/plugins/SplashScreen/src/main.cpp b/plugins/SplashScreen/src/main.cpp index 4ae218f6b4..4a09734466 100644 --- a/plugins/SplashScreen/src/main.cpp +++ b/plugins/SplashScreen/src/main.cpp @@ -37,7 +37,6 @@ BOOL png2dibavail = true; // can we use png2dib service? TCHAR szDllName[MAX_PATH], szSplashFile[MAX_PATH], szSoundFile[MAX_PATH], szhAdvaimgPath[MAX_PATH], szPrefix[128], inBuf[80]; TCHAR * szMirDir; char szVersion[MAX_PATH]; -HANDLE hShowSplashService, hTestService; #ifdef _DEBUG TCHAR szLogFile[MAX_PATH]; #endif @@ -46,7 +45,7 @@ HWND hwndSplash; BOOL (WINAPI *MyUpdateLayeredWindow) (HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags); -HANDLE hSplashThread, hModulesLoaded, hPlugDisableHook, hOptInit, hSystemOKToExit; +HANDLE hSplashThread; PLUGININFOEX pluginInfo={ sizeof(PLUGININFOEX), @@ -255,22 +254,6 @@ void SplashMain() bstartup = false; } -int onSystemOKToExit(WPARAM wParam,LPARAM lParam) -{ - // Hooked events need to be unhooked - UnhookEvent(hModulesLoaded); - UnhookEvent(hSystemOKToExit); - UnhookEvent(hPlugDisableHook); - UnhookEvent(hOptInit); - - DestroyServiceFunction(hShowSplashService); - #ifdef _DEBUG - DestroyServiceFunction(hTestService); - #endif - - return 0; -} - int PlugDisableHook(WPARAM wParam, LPARAM lParam) { #ifdef _DEBUG @@ -323,15 +306,14 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) } // Options initialize hook - hOptInit = HookEvent(ME_OPT_INITIALISE, OptInit); - - hPlugDisableHook = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, PlugDisableHook); + HookEvent(ME_OPT_INITIALISE, OptInit); + HookEvent(ME_DB_CONTACT_SETTINGCHANGED, PlugDisableHook); // Service to call splash - hShowSplashService = CreateServiceFunction(MS_SHOWSPLASH, ShowSplashService); + CreateServiceFunction(MS_SHOWSPLASH, ShowSplashService); #ifdef _DEBUG - hTestService = CreateServiceFunction("Splash/Test", TestService); + CreateServiceFunction("Splash/Test", TestService); CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIF_TCHAR; @@ -357,11 +339,9 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda extern "C" int __declspec(dllexport) Load(void) { - mir_getLP(&pluginInfo); - hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); - hSystemOKToExit = HookEvent(ME_SYSTEM_OKTOEXIT,onSystemOKToExit); + HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); SplashMain(); mir_free(szMirDir); @@ -384,4 +364,4 @@ extern "C" int __declspec(dllexport) Unload(void) #endif return 0; -} \ No newline at end of file +} 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* )&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* )&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* 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; } diff --git a/plugins/TrafficCounter/src/TrafficCounter.cpp b/plugins/TrafficCounter/src/TrafficCounter.cpp index b1ca6dfffb..505a136068 100644 --- a/plugins/TrafficCounter/src/TrafficCounter.cpp +++ b/plugins/TrafficCounter/src/TrafficCounter.cpp @@ -128,7 +128,7 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_SYSTEM_MODULESLOADED,TrafficCounterModulesLoaded); HookEvent(ME_PROTO_ACK,ProtocolAckHook); HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccountsListChange); - HookEvent(ME_SYSTEM_OKTOEXIT, TrafficCounterShutdown); + HookEvent(ME_SYSTEM_PRESHUTDOWN, TrafficCounterShutdown); HookEvent(ME_SYSTEM_MODULELOAD, ModuleLoad); HookEvent(ME_SYSTEM_MODULEUNLOAD, ModuleLoad); -- cgit v1.2.3