diff options
author | aunsane <aunsane@gmail.com> | 2017-01-06 16:19:32 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-01-06 20:10:47 +0300 |
commit | b7336b2fc97092442ce643532f67466868a87812 (patch) | |
tree | 718b87c37090fe8bf7ae88b9d5da9b3b957c3e3c /plugins/StatusManager/src | |
parent | ac1d88965de3022be2f484c2f58185ae75b4fe00 (diff) |
StatusManager: #662
- files splitted by folders
- main.cpp cleanup
- project cleanup
Diffstat (limited to 'plugins/StatusManager/src')
-rw-r--r-- | plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp (renamed from plugins/StatusManager/src/aaa_msgoptions.cpp) | 2 | ||||
-rw-r--r-- | plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp (renamed from plugins/StatusManager/src/aaa_options.cpp) | 8 | ||||
-rw-r--r-- | plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp (renamed from plugins/StatusManager/src/advancedautoaway.cpp) | 30 | ||||
-rw-r--r-- | plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.h (renamed from plugins/StatusManager/src/advancedautoaway.h) | 12 | ||||
-rw-r--r-- | plugins/StatusManager/src/KeepStatus/keepstatus.cpp (renamed from plugins/StatusManager/src/keepstatus.cpp) | 61 | ||||
-rw-r--r-- | plugins/StatusManager/src/KeepStatus/keepstatus.h (renamed from plugins/StatusManager/src/keepstatus.h) | 14 | ||||
-rw-r--r-- | plugins/StatusManager/src/KeepStatus/ks_options.cpp (renamed from plugins/StatusManager/src/ks_options.cpp) | 6 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/ss_options.cpp (renamed from plugins/StatusManager/src/ss_options.cpp) | 4 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/ss_profiles.cpp (renamed from plugins/StatusManager/src/ss_profiles.cpp) | 12 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp (renamed from plugins/StatusManager/src/ss_toolbars.cpp) | 2 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/startupstatus.cpp (renamed from plugins/StatusManager/src/startupstatus.cpp) | 54 | ||||
-rw-r--r-- | plugins/StatusManager/src/StartupStatus/startupstatus.h (renamed from plugins/StatusManager/src/startupstatus.h) | 16 | ||||
-rw-r--r-- | plugins/StatusManager/src/main.cpp | 87 | ||||
-rw-r--r-- | plugins/StatusManager/src/stdafx.h | 10 |
14 files changed, 171 insertions, 147 deletions
diff --git a/plugins/StatusManager/src/aaa_msgoptions.cpp b/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp index 5647199a43..2484440b2a 100644 --- a/plugins/StatusManager/src/aaa_msgoptions.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/aaa_msgoptions.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" extern char *StatusModeToDbSetting(int status,const char *suffix); diff --git a/plugins/StatusManager/src/aaa_options.cpp b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp index d26678c1ce..93204a033d 100644 --- a/plugins/StatusManager/src/aaa_options.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" int LoadAutoAwaySetting(TAAAProtoSetting &autoAwaySetting, char* protoName); @@ -119,7 +119,7 @@ static void SetDialogStatus(HWND hwndDlg, TAAAProtoSetting *sameSetting) ///////////////////////////////////////////////////////////////////////////////////////// // Rules dialog window procedure -static TAAAProtoSettingList optionSettings(10, CompareSettings); +static TAAAProtoSettingList optionSettings(10, AAACompareSettings); static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -337,7 +337,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM for (int i = 0; i < optionSettings.getCount(); i++) WriteAutoAwaySetting(optionSettings[i], optionSettings[i].szName); } - LoadOptions(autoAwaySettings, FALSE); + AAALoadOptions(autoAwaySettings, FALSE); } break; @@ -402,7 +402,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayGeneralOpts(HWND hwndDlg, UINT msg, WPARA db_set_w(NULL, AAAMODULENAME, SETTING_CONFIRMDELAY, (WORD)GetDlgItemInt(hwndDlg, IDC_CONFIRMDELAY, NULL, FALSE)); db_set_b(NULL, AAAMODULENAME, SETTING_MONITORMOUSE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORMOUSE)); db_set_b(NULL, AAAMODULENAME, SETTING_MONITORKEYBOARD, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORKEYBOARD)); - LoadOptions(autoAwaySettings, FALSE); + AAALoadOptions(autoAwaySettings, FALSE); } break; } diff --git a/plugins/StatusManager/src/advancedautoaway.cpp b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp index 7f09466bd2..d0eb48801c 100644 --- a/plugins/StatusManager/src/advancedautoaway.cpp +++ b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp @@ -20,7 +20,7 @@ Some code is copied from Miranda's AutoAway module */ -#include "stdafx.h" +#include "..\stdafx.h" #ifdef _DEBUG #define SECS_PER_MINUTE 20 /* speedup */ @@ -30,12 +30,7 @@ ///////////////////////////////////////////////////////////////////////////////////////// -int CompareSettings(const TAAAProtoSetting *p1, const TAAAProtoSetting *p2) -{ - return mir_strcmp(p1->szName, p2->szName); -} - -TAAAProtoSettingList autoAwaySettings(10, CompareSettings); +TAAAProtoSettingList autoAwaySettings(10, AAACompareSettings); TAAAProtoSetting::TAAAProtoSetting(PROTOACCOUNT *pa) { @@ -55,7 +50,8 @@ TAAAProtoSetting::~TAAAProtoSetting() ///////////////////////////////////////////////////////////////////////////////////////// -extern HANDLE hStateChangedEvent; +HANDLE hAAAModuleLoadedHook = NULL, + hStateChangedEvent = NULL; static BOOL ignoreLockKeys = FALSE; static BOOL ignoreSysKeys = FALSE; @@ -95,7 +91,7 @@ extern char *StatusModeToDbSetting(int status,const char *suffix); ///////////////////////////////////////////////////////////////////////////////////////// // Load from DB -void LoadOptions(TAAAProtoSettingList &loadSettings, BOOL override) +void AAALoadOptions(TAAAProtoSettingList &loadSettings, BOOL override) { // if override is enabled, samesettings will be ignored (for options loading) int monitorMiranda = FALSE; // use windows hooks? @@ -562,7 +558,7 @@ static int AutoAwayShutdown(WPARAM, LPARAM) return 0; } -int AAACSModuleLoaded(WPARAM, LPARAM) +int AAAModuleLoaded(WPARAM, LPARAM) { HookEvent(ME_PROTO_ACCLISTCHANGED, OnAAAAccChanged); HookEvent(ME_OPT_INITIALISE, AutoAwayOptInitialise); @@ -585,6 +581,18 @@ int AAACSModuleLoaded(WPARAM, LPARAM) //////////////////////////////////////////////////////////////////////////////////////// - LoadOptions(autoAwaySettings, FALSE); + AAALoadOptions(autoAwaySettings, FALSE); return 0; } + +void AdvancedAutoAwayLoad() +{ + hAAAModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, AAAModuleLoaded); + hStateChangedEvent = CreateHookableEvent(ME_AAA_STATECHANGED); +} + +void AdvancedAutoAwayUnload() +{ + UnhookEvent(hAAAModuleLoadedHook); + DestroyHookableEvent(hStateChangedEvent); +}
\ No newline at end of file diff --git a/plugins/StatusManager/src/advancedautoaway.h b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.h index a8177c2a77..70118e0e38 100644 --- a/plugins/StatusManager/src/advancedautoaway.h +++ b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.h @@ -70,6 +70,11 @@ struct TAAAProtoSetting : public PROTOCOLSETTINGEX, public MZeroedObject unsigned int sts1setTimer; }; +static int AAACompareSettings(const TAAAProtoSetting *p1, const TAAAProtoSetting *p2) +{ + return mir_strcmp(p1->szName, p2->szName); +} + struct AAMSGSETTING { short useCustom; @@ -77,14 +82,13 @@ struct AAMSGSETTING char* msg; }; -extern HINSTANCE hInst; - -int CompareSettings( const TAAAProtoSetting *p1, const TAAAProtoSetting *p2 ); +void AdvancedAutoAwayLoad(); +void AdvancedAutoAwayUnload(); typedef OBJLIST<TAAAProtoSetting> TAAAProtoSettingList; extern TAAAProtoSettingList autoAwaySettings; int LoadAutoAwaySetting(TAAAProtoSetting &autoAwaySetting, char *protoName); -void LoadOptions(TAAAProtoSettingList &settings, BOOL override); +void AAALoadOptions(TAAAProtoSettingList &settings, BOOL override); #endif diff --git a/plugins/StatusManager/src/keepstatus.cpp b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp index 41c244cde4..f975b64793 100644 --- a/plugins/StatusManager/src/keepstatus.cpp +++ b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" struct TimerInfo { int timer; @@ -27,6 +27,16 @@ struct TimerInfo { HANDLE hEvent; }; +HANDLE hMainThread = 0; +unsigned long mainThreadId = 0; + +HANDLE hKSModuleLoadedHook = NULL, + hConnectionEvent = NULL, + hStopRecon = NULL, + hEnableProto = NULL, + hIsProtoEnabled = NULL, + hAnnounceStat = NULL; + static mir_cs GenTimerCS, GenStatusCS, CheckContinueslyCS; static HANDLE hProtoAckHook = NULL; @@ -34,9 +44,6 @@ static HANDLE hStatusChangeHook = NULL; static HANDLE hCSStatusChangeHook = NULL; static HANDLE hCSStatusChangeExHook = NULL; -extern HANDLE hConnectionEvent; -extern PLUGININFOEX pluginInfoEx; - static HWND hMessageWindow = NULL; static int CompareConnections(const TConnectionSettings *p1, const TConnectionSettings *p2) @@ -64,7 +71,6 @@ static int showConnectionPopups = 0; // prototypes static int StartTimer(int timer, int timeout, BOOL restart); static int StopTimer(int timer); -int KSLoadMainOptions(); static void GetCurrentConnectionSettings(); static int AssignStatus(TConnectionSettings* connSetting, int status, int lastStatus, wchar_t *szMsg); static int ProcessProtoAck(WPARAM wParam, LPARAM lParam); @@ -83,7 +89,7 @@ INT_PTR IsProtocolEnabledService(WPARAM wParam, LPARAM lParam); static int ProcessPopup(int reason, LPARAM lParam); static INT_PTR ShowPopup(wchar_t *msg, HICON hIcon); -LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK KSPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); static DWORD CALLBACK MessageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); // options.c @@ -106,7 +112,7 @@ TConnectionSettings::~TConnectionSettings() free(szMsg); } -int KSLoadMainOptions() +int KSLoadOptions() { UnhookEvent(hProtoAckHook); UnhookEvent(hStatusChangeHook); @@ -991,7 +997,7 @@ static INT_PTR ShowPopup(wchar_t *msg, HICON hIcon) ppd.colorBack = db_get_dw(NULL, KSMODULENAME, SETTING_POPUP_BACKCOLOR, 0xAAAAAA); ppd.colorText = db_get_dw(NULL, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, 0x0000CC); } - ppd.PluginWindowProc = PopupDlgProc; + ppd.PluginWindowProc = KSPopupDlgProc; switch (db_get_b(NULL, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU)) { case POPUP_DELAYCUSTOM: @@ -1012,7 +1018,7 @@ static INT_PTR ShowPopup(wchar_t *msg, HICON hIcon) return PUAddPopupT(&ppd); } -LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK KSPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CONTEXTMENU: // right @@ -1193,15 +1199,48 @@ static int onShutdown(WPARAM, LPARAM) return 0; } -int KSCSModuleLoaded(WPARAM, LPARAM) +int KSModuleLoaded(WPARAM, LPARAM) { protoList = (OBJLIST<PROTOCOLSETTINGEX>*)&connectionSettings; hMessageWindow = NULL; - KSLoadMainOptions(); + KSLoadOptions(); HookEvent(ME_OPT_INITIALISE, KeepStatusOptionsInit); HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown); HookEvent(ME_PROTO_ACCLISTCHANGED, OnKSAccChanged); return 0; } + +void KeepStatusLoad() +{ + hKSModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, KSModuleLoaded); + + CreateHookableEvent(ME_KS_CONNECTIONEVENT); + + hStopRecon = CreateServiceFunction(MS_KS_STOPRECONNECTING, StopReconnectingService); + hEnableProto = CreateServiceFunction(MS_KS_ENABLEPROTOCOL, EnableProtocolService); + hIsProtoEnabled = CreateServiceFunction(MS_KS_ISPROTOCOLENABLED, IsProtocolEnabledService); + hAnnounceStat = CreateServiceFunction(MS_KS_ANNOUNCESTATUSCHANGE, AnnounceStatusChangeService); + + DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, FALSE, 0); + mainThreadId = GetCurrentThreadId(); +} + +void KeepStatusUnload() +{ + if (hMainThread) + CloseHandle(hMainThread); + + DestroyServiceFunction(hStopRecon); + DestroyServiceFunction(hEnableProto); + DestroyServiceFunction(hIsProtoEnabled); + DestroyServiceFunction(hAnnounceStat); + + if (hMainThread) + CloseHandle(hMainThread); + + DestroyHookableEvent(hConnectionEvent); + + UnhookEvent(hKSModuleLoadedHook); +} diff --git a/plugins/StatusManager/src/keepstatus.h b/plugins/StatusManager/src/KeepStatus/keepstatus.h index d44b312e80..18e13f242c 100644 --- a/plugins/StatusManager/src/keepstatus.h +++ b/plugins/StatusManager/src/KeepStatus/keepstatus.h @@ -113,16 +113,12 @@ typedef struct { #define ME_CS_STATUSCHANGE "CommonStatus/StatusChange" ///////////////////////////////////////////////////////////////////////////////////////// -// main.cpp - -extern HINSTANCE hInst; -extern HANDLE hMainThread; -extern unsigned long mainThreadId; - -///////////////////////////////////////////////////////////////////////////////////////// // keepstatus.cpp -int KSLoadMainOptions(); -LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); +void KeepStatusLoad(); +void KeepStatusUnload(); +int KSLoadOptions(); + +LRESULT CALLBACK KSPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); #endif //__KEEPSTATUS_HEADER diff --git a/plugins/StatusManager/src/ks_options.cpp b/plugins/StatusManager/src/KeepStatus/ks_options.cpp index 890981a8c1..0f321dfd14 100644 --- a/plugins/StatusManager/src/ks_options.cpp +++ b/plugins/StatusManager/src/KeepStatus/ks_options.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" // prototypes INT_PTR CALLBACK OptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); @@ -341,7 +341,7 @@ static INT_PTR CALLBACK DlgProcKsTabs(HWND hwndDlg, UINT msg, WPARAM wParam, LPA SendMessage((HWND)tci.lParam, WM_NOTIFY, 0, lParam); } // let main reload options - KSLoadMainOptions(); + KSLoadOptions(); } break; } @@ -497,7 +497,7 @@ INT_PTR CALLBACK PopupOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l ppd.colorBack = SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0); ppd.colorText = SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, 0); } - ppd.PluginWindowProc = PopupDlgProc; + ppd.PluginWindowProc = KSPopupDlgProc; ppd.PluginData = NULL; if (IsDlgButtonChecked(hwndDlg, IDC_DELAYFROMPU)) { diff --git a/plugins/StatusManager/src/ss_options.cpp b/plugins/StatusManager/src/StartupStatus/ss_options.cpp index 2acf61483f..644be1f1e6 100644 --- a/plugins/StatusManager/src/ss_options.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_options.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" ///////////////////////////////////////////////////////////////////////////////////////// @@ -27,7 +27,7 @@ TSettingsList* GetCurrentProtoSettings() PROTOACCOUNT **protos; Proto_EnumAccounts(&count, &protos); - TSettingsList *result = new TSettingsList(count, CompareSettings); + TSettingsList *result = new TSettingsList(count, SSCompareSettings); if (result == NULL) return NULL; diff --git a/plugins/StatusManager/src/ss_profiles.cpp b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp index 521d498fe9..8abeeaa495 100644 --- a/plugins/StatusManager/src/ss_profiles.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" #define MAX_MMITEMS 6 @@ -199,7 +199,7 @@ INT_PTR LoadAndSetProfile(WPARAM iProfileNo, LPARAM) { // wParam == profile no. int profile = (int)iProfileNo; - TSettingsList profileSettings(10, CompareSettings); + TSettingsList profileSettings(10, SSCompareSettings); if (!GetProfile(profile, profileSettings)) { profile = (profile >= 0) ? profile : db_get_w(NULL, SSMODULENAME, SETTING_DEFAULTPROFILE, 0); @@ -313,6 +313,12 @@ int LoadProfileModule() return 0; } +int UnloadProfileModule() +{ + DestroyServiceFunction(hLoadAndSetProfileService); + return 0; +} + int InitProfileModule() { hTTBModuleLoadedHook = HookEvent(ME_TTB_MODULELOADED, CreateTopToolbarButtons); @@ -337,7 +343,5 @@ int DeinitProfilesModule() UnregisterHotKeys(); RemoveTopToolbarButtons(); - - DestroyServiceFunction(hLoadAndSetProfileService); return 0; } diff --git a/plugins/StatusManager/src/ss_toolbars.cpp b/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp index 2ecf0a6b95..e9d153670a 100644 --- a/plugins/StatusManager/src/ss_toolbars.cpp +++ b/plugins/StatusManager/src/StartupStatus/ss_toolbars.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" #define MAX_MMITEMS 6 diff --git a/plugins/StatusManager/src/startupstatus.cpp b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp index 995aa68934..2af4dc146d 100644 --- a/plugins/StatusManager/src/startupstatus.cpp +++ b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp @@ -17,16 +17,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "stdafx.h" +#include "..\stdafx.h" static UINT_PTR setStatusTimerId = 0; -int CompareSettings(const TSSSetting *p1, const TSSSetting *p2) -{ - return mir_strcmp(p1->szName, p2->szName); -} - -static TSettingsList startupSettings(10, CompareSettings); +static TSettingsList startupSettings(10, SSCompareSettings); TSSSetting::TSSSetting(PROTOACCOUNT *pa) { @@ -343,6 +338,7 @@ static int OnOkToExit(WPARAM, LPARAM) static int OnShutdown(WPARAM, LPARAM) { DeinitProfilesModule(); + UnloadProfileModule(); // set windowstate and docked for next startup if (db_get_b(NULL, SSMODULENAME, SETTING_SETWINSTATE, 0)) { @@ -402,7 +398,7 @@ static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM) return TRUE; } -int SSCSModuleLoaded(WPARAM, LPARAM) +int SSModuleLoaded(WPARAM, LPARAM) { protoList = (OBJLIST<PROTOCOLSETTINGEX>*)&startupSettings; @@ -484,3 +480,45 @@ int SSCSModuleLoaded(WPARAM, LPARAM) return 0; } + +HANDLE hSSModuleLoadedHook = NULL, + hGetProfileService, + hGetProfileCountService, + hGetProfileNameService; + +void StartupStatusLoad() +{ + hSSModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, SSModuleLoaded); + + if (db_get_b(NULL, SSMODULENAME, SETTING_SETPROFILE, 1) || + db_get_b(NULL, SSMODULENAME, SETTING_OFFLINECLOSE, 0)) + db_set_w(NULL, "CList", "Status", (WORD)ID_STATUS_OFFLINE); + + // docking + if (db_get_b(NULL, SSMODULENAME, SETTING_SETDOCKED, 0)) { + int docked = db_get_b(NULL, SSMODULENAME, SETTING_DOCKED, DOCKED_NONE); + if (docked == DOCKED_LEFT || docked == DOCKED_RIGHT) + docked = -docked; + + db_set_b(NULL, MODULE_CLIST, SETTING_DOCKED, (BYTE)docked); + } + + // Create service functions; the get functions are created here; they don't rely on commonstatus + hGetProfileService = CreateServiceFunction(MS_SS_GETPROFILE, SrvGetProfile); + hGetProfileCountService = CreateServiceFunction(MS_SS_GETPROFILECOUNT, GetProfileCount); + hGetProfileNameService = CreateServiceFunction(MS_SS_GETPROFILENAME, GetProfileName); + + LoadProfileModule(); +} + +void StartupStatusUnload() +{ + DeinitProfilesModule(); + UnloadProfileModule(); + + DestroyServiceFunction(hGetProfileService); + DestroyServiceFunction(hGetProfileCountService); + DestroyServiceFunction(hGetProfileNameService); + + UnhookEvent(hSSModuleLoadedHook); +} diff --git a/plugins/StatusManager/src/startupstatus.h b/plugins/StatusManager/src/StartupStatus/startupstatus.h index f106a141d9..5686e03981 100644 --- a/plugins/StatusManager/src/startupstatus.h +++ b/plugins/StatusManager/src/StartupStatus/startupstatus.h @@ -28,6 +28,11 @@ struct TSSSetting : public PROTOCOLSETTINGEX, public MZeroedObject ~TSSSetting(); }; +static int SSCompareSettings(const TSSSetting *p1, const TSSSetting *p2) +{ + return mir_strcmp(p1->szName, p2->szName); +} + typedef OBJLIST<TSSSetting> TSettingsList; struct PROFILECE @@ -130,9 +135,10 @@ int StartupStatusOptionsInit(WPARAM wparam,LPARAM lparam); char* OptName(int i, const char* setting); // startupstatus -int SSLoadMainOptions(); +void StartupStatusLoad(); +void StartupStatusUnload(); -int CompareSettings( const TSSSetting* p1, const TSSSetting* p2 ); +int SSLoadMainOptions(); TSettingsList* GetCurrentProtoSettings(); @@ -140,6 +146,11 @@ TSettingsList* GetCurrentProtoSettings(); int GetProfile(int profileID, TSettingsList& arSettings ); wchar_t *GetStatusMessage(int profile, char *szProto); +static INT_PTR SrvGetProfile(WPARAM wParam, LPARAM lParam) +{ + return GetProfile((int)wParam, *(TSettingsList*)lParam); +} + INT_PTR LoadAndSetProfile(WPARAM wParam, LPARAM lParam); INT_PTR GetProfileCount(WPARAM wParam, LPARAM lParam); INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam); @@ -149,6 +160,7 @@ void RemoveTopToolbarButtons(); int CreateTopToolbarButtons(WPARAM wParam, LPARAM lParam); int LoadProfileModule(); +int UnloadProfileModule(); int InitProfileModule(); int DeinitProfilesModule(); diff --git a/plugins/StatusManager/src/main.cpp b/plugins/StatusManager/src/main.cpp index 41455e029a..2264b63fb2 100644 --- a/plugins/StatusManager/src/main.cpp +++ b/plugins/StatusManager/src/main.cpp @@ -19,21 +19,6 @@ #include "stdafx.h" -unsigned long mainThreadId = 0; - -HANDLE hMainThread = 0, - hCSModuleLoadedHook, - hGetProfileService, - hGetProfileCountService, - hGetProfileNameService, - hStateChangedEvent; - -HANDLE hConnectionEvent = NULL, - hStopRecon = NULL, - hEnableProto = NULL, - hIsProtoEnabled = NULL, - hAnnounceStat = NULL; - HINSTANCE hInst; int hLangpack = 0; CLIST_INTERFACE *pcli; @@ -79,63 +64,16 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_AUTOAW ///////////////////////////////////////////////////////////////////////////////////////// // plugin's entry point -INT_PTR StopReconnectingService(WPARAM wParam, LPARAM lParam); -INT_PTR EnableProtocolService(WPARAM wParam, LPARAM lParam); -INT_PTR IsProtocolEnabledService(WPARAM wParam, LPARAM lParam); -INT_PTR AnnounceStatusChangeService(WPARAM wParam, LPARAM lParam); - -static INT_PTR SrvGetProfile(WPARAM wParam, LPARAM lParam) -{ - return GetProfile((int)wParam, *(TSettingsList*)lParam); -} - extern "C" int __declspec(dllexport) Load(void) { mir_getLP(&pluginInfoEx); pcli = Clist_GetInterface(); - //common InitCommonStatus(); - /* KeepStatus */ - hCSModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, KSCSModuleLoaded); - - hConnectionEvent = CreateHookableEvent(ME_KS_CONNECTIONEVENT); - - hStopRecon = CreateServiceFunction(MS_KS_STOPRECONNECTING, StopReconnectingService); - hEnableProto = CreateServiceFunction(MS_KS_ENABLEPROTOCOL, EnableProtocolService); - hIsProtoEnabled = CreateServiceFunction(MS_KS_ISPROTOCOLENABLED, IsProtocolEnabledService); - hAnnounceStat = CreateServiceFunction(MS_KS_ANNOUNCESTATUSCHANGE, AnnounceStatusChangeService); - - DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, FALSE, 0); - mainThreadId = GetCurrentThreadId(); - - /* StartupStatus */ - hCSModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, SSCSModuleLoaded); - - if (db_get_b(NULL, SSMODULENAME, SETTING_SETPROFILE, 1) || - db_get_b(NULL, SSMODULENAME, SETTING_OFFLINECLOSE, 0)) - db_set_w(NULL, "CList", "Status", (WORD)ID_STATUS_OFFLINE); - - // docking - if (db_get_b(NULL, SSMODULENAME, SETTING_SETDOCKED, 0)) { - int docked = db_get_b(NULL, SSMODULENAME, SETTING_DOCKED, DOCKED_NONE); - if (docked == DOCKED_LEFT || docked == DOCKED_RIGHT) - docked = -docked; - - db_set_b(NULL, MODULE_CLIST, SETTING_DOCKED, (BYTE)docked); - } - - // Create service functions; the get functions are created here; they don't rely on commonstatus - hGetProfileService = CreateServiceFunction(MS_SS_GETPROFILE, SrvGetProfile); - hGetProfileCountService = CreateServiceFunction(MS_SS_GETPROFILECOUNT, GetProfileCount); - hGetProfileNameService = CreateServiceFunction(MS_SS_GETPROFILENAME, GetProfileName); - - LoadProfileModule(); - - /* AdvancedAutoAway */ - hCSModuleLoadedHook = HookEvent(ME_SYSTEM_MODULESLOADED, AAACSModuleLoaded); - hStateChangedEvent = CreateHookableEvent(ME_AAA_STATECHANGED); + KeepStatusLoad(); + StartupStatusLoad(); + AdvancedAutoAwayLoad(); return 0; } @@ -145,22 +83,9 @@ extern "C" int __declspec(dllexport) Load(void) extern "C" int __declspec(dllexport) Unload(void) { - UnhookEvent(hCSModuleLoadedHook); - - // StartupStatus - DestroyHookableEvent(hConnectionEvent); - - if (hMainThread) - CloseHandle(hMainThread); - DestroyServiceFunction(hStopRecon); - DestroyServiceFunction(hEnableProto); - DestroyServiceFunction(hIsProtoEnabled); - DestroyServiceFunction(hAnnounceStat); - - // StartupStatus - DestroyServiceFunction(hGetProfileService); - DestroyServiceFunction(hGetProfileCountService); - DestroyServiceFunction(hGetProfileNameService); + KeepStatusUnload(); + StartupStatusUnload(); + AdvancedAutoAwayUnload(); return 0; } diff --git a/plugins/StatusManager/src/stdafx.h b/plugins/StatusManager/src/stdafx.h index a8fd9051a7..0e481e36ca 100644 --- a/plugins/StatusManager/src/stdafx.h +++ b/plugins/StatusManager/src/stdafx.h @@ -26,12 +26,10 @@ #include "resource.h" #include "commonstatus.h" -#include "keepstatus.h" -#include "startupstatus.h" -#include "advancedautoaway.h" +#include "KeepStatus\keepstatus.h" +#include "StartupStatus\startupstatus.h" +#include "AdvancedAutoAway\advancedautoaway.h" -int KSCSModuleLoaded(WPARAM, LPARAM); -int SSCSModuleLoaded(WPARAM, LPARAM); -int AAACSModuleLoaded(WPARAM, LPARAM); +extern HINSTANCE hInst; #endif //_COMMON_H_ |