diff options
author | George Hazan <ghazan@miranda.im> | 2017-12-06 20:06:44 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-12-06 20:06:44 +0300 |
commit | 09bce81d5eae2a46dd039e9fa14290c77685d637 (patch) | |
tree | 00d3a8332aff9d667d385eaaeb078de4edc441b4 /plugins/StatusManager/src/StartupStatus | |
parent | 5a16d189158c71db28c481a44706c73c83fd6e76 (diff) |
fixes #1054 (StatusManager cannot enable/disable modules "on the fly")
Diffstat (limited to 'plugins/StatusManager/src/StartupStatus')
3 files changed, 37 insertions, 11 deletions
diff --git a/plugins/StatusManager/src/StartupStatus/ss_options.cpp b/plugins/StatusManager/src/StartupStatus/ss_options.cpp index cbb2aed627..1fdf8141bd 100644 --- a/plugins/StatusManager/src/StartupStatus/ss_options.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_options.cpp @@ -918,7 +918,7 @@ public: int StartupStatusOptionsInit(WPARAM wparam, LPARAM) { - OPTIONSDIALOGPAGE odp = { 0 }; + OPTIONSDIALOGPAGE odp = {}; odp.hInstance = hInst; odp.szGroup.a = LPGEN("Status"); odp.szTitle.a = LPGEN("Startup status"); @@ -927,12 +927,12 @@ int StartupStatusOptionsInit(WPARAM wparam, LPARAM) odp.szTab.a = LPGEN("General"); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_STARTUPSTATUS); odp.pfnDlgProc = StartupStatusOptDlgProc; - Options_AddPage(wparam, &odp); + Options_AddPage(wparam, &odp, SSLangPack); odp.szTab.a = LPGEN("Status profiles"); odp.pszTemplate = nullptr; odp.pfnDlgProc = nullptr; odp.pDialog = new CSSAdvancedOptDlg(); - Options_AddPage(wparam, &odp); + Options_AddPage(wparam, &odp, SSLangPack); return 0; } diff --git a/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp index d90a5a890b..19f9d05ecd 100644 --- a/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp @@ -328,7 +328,9 @@ int DeinitProfilesModule() for (int i = 0; i < pceCount; i++) free(pce[i].szProto); free(pce); + pce = nullptr; } + pceCount = 0; UnregisterHotKeys(); RemoveTopToolbarButtons(); diff --git a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp index 15c5ac289d..1f051800e6 100644 --- a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp +++ b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp @@ -19,6 +19,9 @@ #include "..\stdafx.h" +int SSLangPack; + +static HANDLE hServices[3], hEvents[4]; static UINT_PTR setStatusTimerId = 0; static TSettingsList startupSettings(10, SSCompareSettings); @@ -394,12 +397,12 @@ int SSModuleLoaded(WPARAM, LPARAM) InitProfileModule(); - HookEvent(ME_PROTO_ACCLISTCHANGED, OnSSAccChanged); - HookEvent(ME_OPT_INITIALISE, StartupStatusOptionsInit); + hEvents[0] = HookEvent(ME_PROTO_ACCLISTCHANGED, OnSSAccChanged); + hEvents[1] = HookEvent(ME_OPT_INITIALISE, StartupStatusOptionsInit); /* shutdown hook for normal shutdown */ - HookEvent(ME_SYSTEM_OKTOEXIT, OnOkToExit); - HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown); + hEvents[2] = HookEvent(ME_SYSTEM_OKTOEXIT, OnOkToExit); + hEvents[3] = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown); /* message window for poweroff */ hMessageWindow = CreateWindowEx(0, L"STATIC", nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr); SetWindowLongPtr(hMessageWindow, GWLP_WNDPROC, (LONG_PTR)MessageWndProc); @@ -481,7 +484,13 @@ static INT_PTR SrvGetProfile(WPARAM wParam, LPARAM lParam) void StartupStatusLoad() { - HookEvent(ME_SYSTEM_MODULESLOADED, SSModuleLoaded); + SSLangPack = GetPluginLangId(MIID_LAST, 0); + + if (g_bMirandaLoaded) { + SSModuleLoaded(0, 0); + StartupStatusOptionsInit(0, 0); + } + else HookEvent(ME_SYSTEM_MODULESLOADED, SSModuleLoaded); if (db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1) || db_get_b(0, SSMODULENAME, SETTING_OFFLINECLOSE, 0)) db_set_w(0, "CList", "Status", (WORD)ID_STATUS_OFFLINE); @@ -496,14 +505,29 @@ void StartupStatusLoad() } // Create service functions; the get functions are created here; they don't rely on commonstatus - CreateServiceFunction(MS_SS_GETPROFILE, SrvGetProfile); - CreateServiceFunction(MS_SS_GETPROFILECOUNT, GetProfileCount); - CreateServiceFunction(MS_SS_GETPROFILENAME, GetProfileName); + hServices[0] = CreateServiceFunction(MS_SS_GETPROFILE, SrvGetProfile); + hServices[1] = CreateServiceFunction(MS_SS_GETPROFILECOUNT, GetProfileCount); + hServices[2] = CreateServiceFunction(MS_SS_GETPROFILENAME, GetProfileName); LoadProfileModule(); } void StartupStatusUnload() { + if (g_bMirandaLoaded) + OnShutdown(0, 0); + + KillModuleOptions(SSLangPack); + + for (int i = 0; i < _countof(hServices); i++) { + DestroyServiceFunction(hServices[i]); + hServices[i] = nullptr; + } + + for (int i = 0; i < _countof(hEvents); i++) { + UnhookEvent(hEvents[i]); + hEvents[i] = nullptr; + } + DeinitProfilesModule(); } |