diff options
-rw-r--r-- | include/m_protocols.h | 3 | ||||
-rw-r--r-- | src/mir_app/src/clistmod.cpp | 48 | ||||
-rw-r--r-- | src/mir_app/src/protocols.cpp | 1 |
3 files changed, 24 insertions, 28 deletions
diff --git a/include/m_protocols.h b/include/m_protocols.h index cc1e8fe0e0..7ae638bf58 100644 --- a/include/m_protocols.h +++ b/include/m_protocols.h @@ -275,9 +275,10 @@ struct MIR_APP_EXPORT PROTOACCOUNT HWND hwndAccMgrUI;
int iOrder; // account order in various menus & lists
- PROTO_INTERFACE *ppro; // pointer to the underlying object
+ PROTO_INTERFACE *ppro; // pointer to the underlying object
char* szUniqueId; // setting's unique id for any contact in the account
+ int iIconBase; // index of the first icon in ClistImages
bool IsEnabled(void) const;
bool IsLocked(void) const;
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index 04245f11f5..dfd1c71e4d 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -44,14 +44,6 @@ HIMAGELIST hCListImages; extern BYTE nameOrder[];
-struct ProtoIconIndex
-{
- char *szProto;
- int iIconBase;
-};
-
-OBJLIST<ProtoIconIndex> protoIconIndex(5, PtrKeySortT);
-
MIR_APP_DLL(wchar_t*) Clist_GetStatusModeDescription(int mode, int flags)
{
static wchar_t szMode[64];
@@ -126,9 +118,9 @@ int fnIconFromStatusMode(const char *szProto, int status, MCONTACT) if (szProto == nullptr)
return index + 1;
- for (auto &it : protoIconIndex)
- if (!mir_strcmp(szProto, it->szProto))
- return it->iIconBase + index;
+ PROTOACCOUNT *pa = Proto_GetAccount(szProto);
+ if (pa && pa->iIconBase != -1)
+ return pa->iIconBase + index;
return 1;
}
@@ -142,23 +134,16 @@ MIR_APP_DLL(int) Clist_GetContactIcon(MCONTACT hContact) static void AddProtoIconIndex(PROTOACCOUNT *pa)
{
- ProtoIconIndex *pii = new ProtoIconIndex;
- pii->szProto = pa->szModuleName;
- for (int i = 0; i < _countof(statusModeList); i++) {
- int iImg = ImageList_AddIcon_ProtoIconLibLoaded(hCListImages, pa->szModuleName, statusModeList[i]);
- if (i == 0)
- pii->iIconBase = iImg;
+ for (auto &it : statusModeList) {
+ int iImg = ImageList_AddIcon_ProtoIconLibLoaded(hCListImages, pa->szModuleName, it);
+ if (it == ID_STATUS_OFFLINE)
+ pa->iIconBase = iImg;
}
- protoIconIndex.insert(pii);
}
static void RemoveProtoIconIndex(PROTOACCOUNT *pa)
{
- for (auto &it : protoIconIndex)
- if (mir_strcmp(it->szProto, pa->szModuleName) == 0) {
- protoIconIndex.remove(it);
- break;
- }
+ pa->iIconBase = -1;
}
static int ContactListModulesLoaded(WPARAM, LPARAM)
@@ -180,15 +165,18 @@ static int ContactListModulesLoaded(WPARAM, LPARAM) static int ContactListAccountsChanged(WPARAM eventCode, LPARAM lParam)
{
+ PROTOACCOUNT *pa = (PROTOACCOUNT*)lParam;
+
switch (eventCode) {
case PRAC_ADDED:
- AddProtoIconIndex((PROTOACCOUNT*)lParam);
+ AddProtoIconIndex(pa);
break;
case PRAC_REMOVED:
- RemoveProtoIconIndex((PROTOACCOUNT*)lParam);
+ pa->iIconBase = -1;
break;
}
+
Menu_ReloadProtoMenus();
Clist_TrayIconIconsChanged();
Clist_Broadcast(INTM_RELOADOPTIONS, 0, 0);
@@ -228,9 +216,15 @@ static int CListIconsChanged(WPARAM, LPARAM) ImageList_ReplaceIcon_IconLibLoaded(hCListImages, i + 1, Skin_LoadIcon(skinIconStatusList[i]));
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPOPEN, Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN));
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPSHUT, Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT));
- for (auto &it : protoIconIndex)
+
+ for (auto &it : accounts) {
+ if (it->iIconBase == -1)
+ continue;
+
for (int j = 0; j < _countof(statusModeList); j++)
- ImageList_ReplaceIcon_IconLibLoaded(hCListImages, it->iIconBase + j, Skin_LoadProtoIcon(it->szProto, statusModeList[j]));
+ ImageList_ReplaceIcon_IconLibLoaded(hCListImages, it->iIconBase + j, Skin_LoadProtoIcon(it->szModuleName, statusModeList[j]));
+ }
+
Clist_TrayIconIconsChanged();
cli.pfnInvalidateRect(cli.hwndContactList, nullptr, TRUE);
return 0;
diff --git a/src/mir_app/src/protocols.cpp b/src/mir_app/src/protocols.cpp index 53b00388da..7d9c992a94 100644 --- a/src/mir_app/src/protocols.cpp +++ b/src/mir_app/src/protocols.cpp @@ -129,6 +129,7 @@ MIR_APP_DLL(int) Proto_RegisterModule(PROTOCOLDESCRIPTOR *pd) pa->tszAccountName = mir_a2u(pd->szName);
pa->bIsVisible = pa->bIsEnabled = true;
pa->iOrder = accounts.getCount();
+ pa->iIconBase = -1;
accounts.insert(pa);
}
pa->bOldProto = true;
|