From 5da898f7cca8599ecff44b3fa10eafb753308a4d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 4 Apr 2018 20:25:20 +0300 Subject: - static function CLIST_INTERFACE::pfnGetAverageMode exported as Proto_GetAverageStatus - Proto_ActivateAccount is not exported anymore due to the lack of need --- src/mir_app/src/clc.h | 1 - src/mir_app/src/clistcore.cpp | 1 - src/mir_app/src/clisttray.cpp | 6 +++--- src/mir_app/src/menu_clist.cpp | 47 +++++++++++++++++++----------------------- src/mir_app/src/mir_app.def | 2 +- src/mir_app/src/mir_app64.def | 2 +- src/mir_app/src/miranda.h | 1 + src/mir_app/src/proto_accs.cpp | 46 ++++++++++++++++++++++------------------- src/mir_app/src/proto_opts.cpp | 4 ++-- 9 files changed, 54 insertions(+), 56 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h index 2a99f96aff..a0242f6f46 100644 --- a/src/mir_app/src/clc.h +++ b/src/mir_app/src/clc.h @@ -113,7 +113,6 @@ int ClcOptInit(WPARAM wParam, LPARAM lParam); /* clistmenus.c */ HGENMENU fnGetProtocolMenu(const char*); -int fnGetAverageMode(int *pNetProtoCount); int fnGetAccountIndexByPos(int Pos); int fnGetProtoIndexByPos(PROTOCOLDESCRIPTOR **proto, int protoCnt, int Pos); diff --git a/src/mir_app/src/clistcore.cpp b/src/mir_app/src/clistcore.cpp index 1eb461121b..5fac64e3e2 100644 --- a/src/mir_app/src/clistcore.cpp +++ b/src/mir_app/src/clistcore.cpp @@ -197,7 +197,6 @@ void InitClistCore() cli.pfnSetAllExtraIcons = fnSetAllExtraIcons; cli.pfnGetContactIcon = fnGetContactIcon; - cli.pfnGetAverageMode = fnGetAverageMode; cli.pfnInitAutoRebuild = fnInitAutoRebuild; } diff --git a/src/mir_app/src/clisttray.cpp b/src/mir_app/src/clisttray.cpp index ade51e63f5..457e4c0b29 100644 --- a/src/mir_app/src/clisttray.cpp +++ b/src/mir_app/src/clisttray.cpp @@ -222,7 +222,7 @@ int fnTrayIconInit(HWND hwnd) mir_cslock lck(trayLockCS); int netProtoCount = 0; - int averageMode = cli.pfnGetAverageMode(&netProtoCount); + int averageMode = Proto_GetAverageStatus(&netProtoCount); if (cli.cycleTimerId) { KillTimer(nullptr, cli.cycleTimerId); @@ -408,7 +408,7 @@ int fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto) return i; } if ((Clist_GetProtocolVisibility(szPreferredProto)) && - (cli.pfnGetAverageMode(nullptr) == -1) && + (Proto_GetAverageStatus(nullptr) == -1) && (db_get_b(0, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) && !(db_get_b(0, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))) goto LBL_Error; @@ -463,7 +463,7 @@ void fnTrayIconUpdateBase(const char *szChangedProto) int netProtoCount; mir_cslock lck(trayLockCS); - int averageMode = cli.pfnGetAverageMode(&netProtoCount); + int averageMode = Proto_GetAverageStatus(&netProtoCount); if (cli.cycleTimerId) { KillTimer(nullptr, cli.cycleTimerId); diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index 598f7a5f99..a94f7a283f 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -113,29 +113,6 @@ void FreeMenuProtos(void) ////////////////////////////////////////////////////////////////////////// -int fnGetAverageMode(int *pNetProtoCount) -{ - int netProtoCount = 0, averageMode = 0; - - for (auto &pa : accounts) { - if (!pa->IsVisible() || pa->IsLocked()) - continue; - - netProtoCount++; - - if (averageMode == 0) - averageMode = CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0); - else if (averageMode > 0 && averageMode != CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0)) { - averageMode = -1; - if (pNetProtoCount == nullptr) - break; - } - } - - if (pNetProtoCount) *pNetProtoCount = netProtoCount; - return averageMode; -} - static int RecursiveDeleteMenu(HMENU hMenu) { int cnt = GetMenuItemCount(hMenu); @@ -504,7 +481,7 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) } } else if (smep && smep->status && !smep->custom) { - int curProtoStatus = (smep->szProto) ? CallProtoServiceInt(0, smep->szProto, PS_GETSTATUS, 0, 0) : cli.pfnGetAverageMode(nullptr); + int curProtoStatus = (smep->szProto) ? CallProtoServiceInt(0, smep->szProto, PS_GETSTATUS, 0, 0) : Proto_GetAverageStatus(); if (smep->status == curProtoStatus) pimi->mi.flags |= CMIF_CHECKED; else @@ -939,6 +916,25 @@ void RebuildMenuOrder(void) ///////////////////////////////////////////////////////////////////////////////////////// +void BuildProtoMenus() +{ + for (auto &pa : accounts) { + if (!pa->IsVisible()) + continue; + + if (pa->ppro) + pa->ppro->OnEvent(EV_PROTO_ONMENU, 0, 0); + } +} + +void RebuildProtoMenus() +{ + RebuildMenuOrder(); + BuildProtoMenus(); +} + +///////////////////////////////////////////////////////////////////////////////////////// + static int sttRebuildHotkeys(WPARAM, LPARAM) { for (int j = 0; j < _countof(statusModeList); j++) { @@ -976,8 +972,7 @@ static int MenuProtoAck(WPARAM, LPARAM lParam) if (hStatusMainMenuHandles == nullptr) return 0; if (Clist_GetProtocolVisibility(ack->szModule) == 0) return 0; - int overallStatus = cli.pfnGetAverageMode(nullptr); - + int overallStatus = Proto_GetAverageStatus(); if (overallStatus >= ID_STATUS_OFFLINE) { int pos = statustopos(cli.currentStatusMenuItem); if (pos == -1) diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 78bd18a0a5..920787e743 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -489,7 +489,7 @@ GetDatabasePlugin @508 ?AccContacts@PROTO_INTERFACE@@QBE?AVContacts@@XZ @509 NONAME SetServiceModePlugin @510 Proto_CreateAccount @511 -Proto_ActivateAccount @512 +Proto_GetAverageStatus @512 ??0CMPluginBase@@IAE@PBD@Z @513 NONAME ??1CMPluginBase@@IAE@XZ @514 NONAME ??4CMPluginBase@@QAEAAV0@ABV0@@Z @515 NONAME diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 92676a8a6e..f2939a19fd 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -489,7 +489,7 @@ GetDatabasePlugin @508 ?AccContacts@PROTO_INTERFACE@@QEBA?AVContacts@@XZ @509 NONAME SetServiceModePlugin @510 Proto_CreateAccount @511 -Proto_ActivateAccount @512 +Proto_GetAverageStatus @512 ??0CMPluginBase@@IEAA@PEBD@Z @513 NONAME ??1CMPluginBase@@IEAA@XZ @514 NONAME ??4CMPluginBase@@QEAAAEAV0@AEBV0@@Z @515 NONAME diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index d124ecb5cd..2cfd867299 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -149,6 +149,7 @@ PROTOACCOUNT* __fastcall Proto_GetAccount(MCONTACT hContact); PROTO_INTERFACE* AddDefaultAccount(const char *szProtoName); int FreeDefaultAccount(PROTO_INTERFACE* ppi); +bool ActivateAccount(PROTOACCOUNT *pa); void EraseAccount(const char *pszProtoName); void DeactivateAccount(PROTOACCOUNT *pa, bool bIsDynamic, bool bErase); void UnloadAccount(PROTOACCOUNT *pa, bool bIsDynamic, bool bErase); diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp index 109b9e9421..bd6bfc2e3c 100644 --- a/src/mir_app/src/proto_accs.cpp +++ b/src/mir_app/src/proto_accs.cpp @@ -262,7 +262,7 @@ int LoadAccountsModule(void) if (!pa->IsEnabled()) continue; - if (!Proto_ActivateAccount(pa)) + if (!ActivateAccount(pa)) pa->bDynDisabled = true; } @@ -282,7 +282,7 @@ static HANDLE CreateProtoServiceEx(const char* szModule, const char* szService, return CreateServiceFunctionObj(tmp, pFunc, param); } -MIR_APP_DLL(bool) Proto_ActivateAccount(PROTOACCOUNT *pa) +bool ActivateAccount(PROTOACCOUNT *pa) { PROTOCOLDESCRIPTOR* ppd = Proto_IsProtocolLoaded(pa->szProtoName); if (ppd == nullptr) @@ -300,6 +300,29 @@ MIR_APP_DLL(bool) Proto_ActivateAccount(PROTOACCOUNT *pa) return true; } +MIR_APP_DLL(int) Proto_GetAverageStatus(int *pAccountNumber) +{ + int netProtoCount = 0, averageMode = 0; + + for (auto &pa : accounts) { + if (!pa->IsVisible() || pa->IsLocked()) + continue; + + netProtoCount++; + if (averageMode == 0) + averageMode = CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0); + else if (averageMode > 0 && averageMode != CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0)) { + averageMode = -1; + if (pAccountNumber == nullptr) + break; + } + } + + if (pAccountNumber) + *pAccountNumber = netProtoCount; + return averageMode; +} + ///////////////////////////////////////////////////////////////////////////////////////// struct DeactivationThreadParam @@ -417,22 +440,3 @@ void UnloadAccountsModule() for (auto &it : hHooks) UnhookEvent(it); } - -///////////////////////////////////////////////////////////////////////////////////////// - -void BuildProtoMenus() -{ - for (auto &pa : accounts) { - if (!pa->IsVisible()) - continue; - - if (pa->ppro) - pa->ppro->OnEvent(EV_PROTO_ONMENU, 0, 0); - } -} - -void RebuildProtoMenus() -{ - RebuildMenuOrder(); - BuildProtoMenus(); -} diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index d2f21b548d..ea203ba622 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -201,7 +201,7 @@ public: rtrim(buf); m_pa = Proto_CreateAccount(buf, szBaseProto, tszAccName); - if (Proto_ActivateAccount(m_pa)) { + if (ActivateAccount(m_pa)) { if (bModulesLoadedFired) m_pa->ppro->OnEvent(EV_PROTO_ONLOAD, 0, 0); if (!db_get_b(0, "CList", "MoveProtoMenus", true)) @@ -541,7 +541,7 @@ public: pa->bIsEnabled = !pa->bIsEnabled; if (pa->bIsEnabled) { - if (Proto_ActivateAccount(pa)) { + if (ActivateAccount(pa)) { if (bModulesLoadedFired) pa->ppro->OnEvent(EV_PROTO_ONLOAD, 0, 0); if (!db_get_b(0, "CList", "MoveProtoMenus", TRUE)) -- cgit v1.2.3