diff options
-rw-r--r-- | include/delphi/m_clistint.inc | 6 | ||||
-rw-r--r-- | include/m_clistint.h | 1 | ||||
-rw-r--r-- | include/m_protocols.h | 6 | ||||
-rw-r--r-- | src/mir_app/src/clc.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/clistcore.cpp | 1 | ||||
-rw-r--r-- | src/mir_app/src/clisttray.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/menu_clist.cpp | 47 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/miranda.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/proto_accs.cpp | 46 | ||||
-rw-r--r-- | src/mir_app/src/proto_opts.cpp | 4 |
12 files changed, 58 insertions, 65 deletions
diff --git a/include/delphi/m_clistint.inc b/include/delphi/m_clistint.inc index 699b138f4f..97be0ac711 100644 --- a/include/delphi/m_clistint.inc +++ b/include/delphi/m_clistint.inc @@ -501,11 +501,7 @@ type * Miranda NG additions
*************************************************************************************)
- pfnGetContactIcon :function (hContact:TMCONTACT):int; cdecl;
- pfnTrayCalcChanged :function (szChangedProto:PAnsiChar; averageMode:int; iProtoCount:int):int; cdecl;
- pfnGetAverageMode :function (pNetProtoCount:pint):int; cdecl;
- pfnInitAutoRebuild :procedure(hwnd:HWND); cdecl;
- pfnSetContactCheckboxes:procedure(cc:PClcContact; checked:int); cdecl;
+ pfnGetContactIcon: function (hContact:TMCONTACT):int; cdecl;
end;
function Clist_GetInterface : PCLIST_INTERFACE; stdcall; external AppDll;
diff --git a/include/m_clistint.h b/include/m_clistint.h index 6a58baf1c1..81865b6ea7 100644 --- a/include/m_clistint.h +++ b/include/m_clistint.h @@ -485,7 +485,6 @@ struct CLIST_INTERFACE *************************************************************************************/
int (*pfnGetContactIcon)(MCONTACT hContact);
int (*pfnTrayCalcChanged)(const char *szChangedProto, int averageMode, int iProtoCount);
- int (*pfnGetAverageMode)(int *pNetProtoCount);
void (*pfnInitAutoRebuild)(HWND hwnd);
void (*pfnSetContactCheckboxes)(ClcContact *cc, int checked);
};
diff --git a/include/m_protocols.h b/include/m_protocols.h index 3aaf125906..cc1e8fe0e0 100644 --- a/include/m_protocols.h +++ b/include/m_protocols.h @@ -300,10 +300,10 @@ MIR_APP_DLL(LIST<PROTOACCOUNT>&) Accounts(void); EXTERN_C MIR_APP_DLL(PROTOACCOUNT*) Proto_CreateAccount(const char *pszInternal, const char *pszBaseProto, const wchar_t *ptszAccountName);
/////////////////////////////////////////////////////////////////////////////////////////
-// constructs the appropriate PROTOACCOUNT::ppro member if needed
-// returns true if succeeded
+// calculates the average protocol status among all visible & active accounts
+// returns the common status or -1 if statuses differ
-EXTERN_C MIR_APP_DLL(bool) Proto_ActivateAccount(PROTOACCOUNT *pAccount);
+EXTERN_C MIR_APP_DLL(int) Proto_GetAverageStatus(int *pAccountNumber = nullptr);
/////////////////////////////////////////////////////////////////////////////////////////
// retrieves an account's interface by its physical name (database module)
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))
|