diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-03 12:01:18 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-03 12:01:27 +0300 |
commit | dfe4c13573386072b6fcf177e8f52fafc81891f1 (patch) | |
tree | 4a0a851588943eb0e018f1983ec961bd3e57547d | |
parent | 2c431e118800147b0f67966c173b2fe1d6247832 (diff) |
Clist_modern: fix for calculating common protocol status even for old protocols
-rw-r--r-- | plugins/Clist_modern/src/modern_clisttray.cpp | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index 1890142851..cc56258329 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -272,36 +272,35 @@ void SettingsMigrate(void) // calculates number of accounts to be displayed
// and the number of the most active account
-int GetGoodAccNum(bool *bDiffers, bool *bConn)
+static int GetGoodAccNum(bool *bDiffers, bool *bConn = nullptr)
{
PROTOACCOUNT **acc;
- int AccNum, i;
+ int AccNum;
Proto_EnumAccounts(&AccNum, &acc);
+ *bDiffers = false;
if (bConn)
- *bConn = FALSE;
-
- WORD s = 0;
- BYTE d = 0;
- for (i = AccNum, AccNum = 0; i--;) {
- PROTOACCOUNT *pa = acc[i];
- if (pcli->pfnGetProtocolVisibility(pa->szModuleName) && pa->ppro) {
- AccNum++;
- if (!d) {
- s = pa->ppro->m_iStatus;
- d = 1;
- }
- else if (s != pa->ppro->m_iStatus)
- d = 2;
+ *bConn = false;
- if (bConn)
- if (IsStatusConnecting(pa->ppro->m_iStatus))
- *bConn = TRUE;
- }
+ int iPrevStatus = 0, res = 0;
+ while (AccNum--) {
+ PROTOACCOUNT *pa = acc[AccNum];
+ if (!pcli->pfnGetProtocolVisibility(pa->szModuleName))
+ continue;
+
+ res++;
+ int iStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
+ if (!iPrevStatus)
+ iPrevStatus = iStatus;
+ else if (iPrevStatus != iStatus)
+ *bDiffers = true;
+
+ if (bConn)
+ if (IsStatusConnecting(iStatus))
+ *bConn = true;
}
- *bDiffers = d == 2;
- return AccNum;
+ return res;
}
BYTE OldMode; //
@@ -323,7 +322,7 @@ int cliTrayIconInit(HWND hwnd) // Нужно узнать количество годных аккаунтов и неодинаковость их статусов.
bool bDiffers;
- pcli->trayIconCount = GetGoodAccNum(&bDiffers, nullptr);
+ pcli->trayIconCount = GetGoodAccNum(&bDiffers);
// Если таковых аккаунтов не нашлось вообще, то будем показывать основную иконку Миранды.
if (!pcli->trayIconCount) {
pcli->trayIconCount = 1;
|