summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-04-07 14:32:51 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-04-07 14:32:51 +0300
commit2c89ab98b84a92c0386700d6911be46ad18edc50 (patch)
treec10a72e0578510d97d9e58b1efcaab8f8076197d /src/mir_app
parent609c3041668b36bc6abfa9511aa4e197bf0060ff (diff)
finally that perversion with double protocol caching in clist died
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/clc.cpp30
-rw-r--r--src/mir_app/src/clcidents.cpp19
-rw-r--r--src/mir_app/src/menu_clist.cpp9
3 files changed, 16 insertions, 42 deletions
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp
index 7dd25496ae..8c0014d50d 100644
--- a/src/mir_app/src/clc.cpp
+++ b/src/mir_app/src/clc.cpp
@@ -124,30 +124,8 @@ static int ClcSettingChanged(WPARAM hContact, LPARAM lParam)
return 0;
}
-static int ClcAccountsChanged(WPARAM, LPARAM)
-{
- int cnt = 0;
- for (auto &pa : accounts)
- if (pa->IsEnabled())
- cnt++;
-
- cli.hClcProtoCount = cnt;
- cli.clcProto = (ClcProtoStatus *)mir_realloc(cli.clcProto, sizeof(ClcProtoStatus) * cli.hClcProtoCount);
-
- cnt = 0;
- for (auto &pa : accounts) {
- if (pa->IsEnabled()) {
- cli.clcProto[cnt].szProto = pa->szModuleName;
- cli.clcProto[cnt].dwStatus = CallProtoServiceInt(0, pa->szModuleName, PS_GETSTATUS, 0, 0);
- ++cnt;
- }
- }
- return 0;
-}
-
static int ClcModulesLoaded(WPARAM, LPARAM)
{
- ClcAccountsChanged(0, 0);
MTG_OnmodulesLoad();
return 0;
}
@@ -174,9 +152,9 @@ static int ClcProtoAck(WPARAM, LPARAM lParam)
WindowList_BroadcastAsync(hClcWindowList, INTM_INVALIDATE, 0, 0);
if (ack->result == ACKRESULT_SUCCESS) {
- for (int i = 0; i < cli.hClcProtoCount; i++) {
- if (!mir_strcmp(cli.clcProto[i].szProto, ack->szModule)) {
- cli.clcProto[i].dwStatus = (WORD)ack->lParam;
+ for (auto &it : g_menuProtos) {
+ if (!mir_strcmp(it->szProto, ack->szModule)) {
+ it->iStatus = (WORD)ack->lParam;
Clist_TrayIconUpdateBase(ack->szModule);
break;
}
@@ -229,7 +207,6 @@ int LoadCLCModule(void)
CreateServiceFunction(MS_CLC_GETINFOTIPHOVERTIME, GetInfoTipHoverTime);
HookEvent(ME_SYSTEM_MODULESLOADED, ClcModulesLoaded);
- HookEvent(ME_PROTO_ACCLISTCHANGED, ClcAccountsChanged);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ClcSettingChanged);
HookEvent(ME_DB_CONTACT_ADDED, ClcContactAdded);
HookEvent(ME_SKIN_ICONSCHANGED, ClcIconsChanged);
@@ -244,7 +221,6 @@ void UnloadClcModule()
if (!bModuleInitialized)
return;
- mir_free(cli.clcProto);
WindowList_Destroy(hClcWindowList); hClcWindowList = nullptr;
FreeDisplayNameCache();
diff --git a/src/mir_app/src/clcidents.cpp b/src/mir_app/src/clcidents.cpp
index e06eba4d51..fbd5e8d245 100644
--- a/src/mir_app/src/clcidents.cpp
+++ b/src/mir_app/src/clcidents.cpp
@@ -223,9 +223,9 @@ MIR_APP_DLL(int) Clist_GetRealStatus(ClcContact *cc, int iDefaultValue)
{
char *szProto = cc->proto;
if (szProto != nullptr)
- for (int i = 0; i < cli.hClcProtoCount; i++)
- if (!mir_strcmp(cli.clcProto[i].szProto, szProto))
- return cli.clcProto[i].dwStatus;
+ for (auto &it : g_menuProtos)
+ if (!mir_strcmp(it->szProto, szProto))
+ return it->iStatus;
return iDefaultValue;
}
@@ -237,13 +237,12 @@ MIR_APP_DLL(int) Clist_GetGeneralizedStatus(char **szProto)
int status = ID_STATUS_OFFLINE;
int statusOnlineness = 0;
- for (int i = 0; i < cli.hClcProtoCount; i++) {
- int thisStatus = cli.clcProto[i].dwStatus;
- if (thisStatus == ID_STATUS_INVISIBLE)
+ for (auto &it : g_menuProtos) {
+ if (it->iStatus == ID_STATUS_INVISIBLE)
return ID_STATUS_INVISIBLE;
int iStatusWeight;
- switch (thisStatus) {
+ switch (it->iStatus) {
case ID_STATUS_FREECHAT: iStatusWeight = 110; break;
case ID_STATUS_ONLINE: iStatusWeight = 100; break;
case ID_STATUS_OCCUPIED: iStatusWeight = 60; break;
@@ -254,14 +253,14 @@ MIR_APP_DLL(int) Clist_GetGeneralizedStatus(char **szProto)
case ID_STATUS_NA: iStatusWeight = 10; break;
case ID_STATUS_INVISIBLE: iStatusWeight = 5; break;
default:
- iStatusWeight = IsStatusConnecting(thisStatus) ? 120 : 0;
+ iStatusWeight = IsStatusConnecting(it->iStatus) ? 120 : 0;
break;
}
if (iStatusWeight > statusOnlineness) {
if (szProto != nullptr)
- *szProto = cli.clcProto[i].szProto;
- status = thisStatus;
+ *szProto = it->szProto;
+ status = it->iStatus;
statusOnlineness = iStatusWeight;
}
}
diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp
index c3dd5a83e8..a44c800dc2 100644
--- a/src/mir_app/src/menu_clist.cpp
+++ b/src/mir_app/src/menu_clist.cpp
@@ -713,8 +713,6 @@ MIR_APP_DLL(int) Clist_GetAccountIndex(int Pos)
void RebuildMenuOrder(void)
{
- BYTE bHideStatusMenu = db_get_b(0, "CLUI", "DontHideStatusMenu", 0); // cool perversion, though
-
// clear statusmenu
RecursiveDeleteMenu(hStatusMenu);
@@ -742,13 +740,13 @@ void RebuildMenuOrder(void)
continue;
PROTOACCOUNT *pa = accounts[i];
- int pos = 0;
- if (!bHideStatusMenu && !pa->IsVisible())
+ if (!pa->IsVisible())
continue;
DWORD flags = pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0);
HICON ic;
wchar_t tbuf[256];
+ int pos = 0;
// adding root
CMenuItem mi;
@@ -794,6 +792,7 @@ void RebuildMenuOrder(void)
pMenu->hIcon = nullptr;
pMenu->pMenu = rootmenu;
pMenu->szProto = mir_strdup(pa->szModuleName);
+ pMenu->iStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
g_menuProtos.insert(pMenu);
char buf[256];
@@ -841,7 +840,7 @@ void RebuildMenuOrder(void)
// add to root menu
for (int j = 0; j < _countof(statusModeList); j++) {
for (auto &pa : accounts) {
- if (!bHideStatusMenu && !pa->IsVisible())
+ if (!pa->IsVisible())
continue;
DWORD flags = pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0);