From 753aa1585f9e0939cba3073f8ef2c70972a47b62 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 19 Nov 2012 14:48:03 +0000 Subject: fix for SecureIM icons git-svn-id: http://svn.miranda-ng.org/main/trunk@2375 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SecureIM/src/commonheaders.h | 1 + plugins/SecureIM/src/crypt.h | 1 + plugins/SecureIM/src/crypt_icons.cpp | 94 +++++++++++++++++++++--------------- plugins/SecureIM/src/svcs_clist.cpp | 2 +- 4 files changed, 57 insertions(+), 41 deletions(-) (limited to 'plugins/SecureIM') diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h index 1f4e94b8e8..8328d39e83 100644 --- a/plugins/SecureIM/src/commonheaders.h +++ b/plugins/SecureIM/src/commonheaders.h @@ -76,6 +76,7 @@ #include "newpluginapi.h" #include "m_stdhdr.h" #include "m_system.h" +#include "m_system_cpp.h" #include "m_database.h" #include "m_protomod.h" #include "m_protosvc.h" diff --git a/plugins/SecureIM/src/crypt.h b/plugins/SecureIM/src/crypt.h index be936d420f..1e0bea6060 100644 --- a/plugins/SecureIM/src/crypt.h +++ b/plugins/SecureIM/src/crypt.h @@ -139,6 +139,7 @@ BOOL isSecureIM(HANDLE hContact, BOOL emptyMirverAsSecureIM=FALSE); // crypt_icons.cpp HICON mode2icon(int,int); +HANDLE mode2clicon(int mode, int type); void RefreshContactListIcons(void); void ShowStatusIcon(HANDLE,UINT); void ShowStatusIcon(HANDLE); diff --git a/plugins/SecureIM/src/crypt_icons.cpp b/plugins/SecureIM/src/crypt_icons.cpp index 0c87625c07..917d3e1682 100644 --- a/plugins/SecureIM/src/crypt_icons.cpp +++ b/plugins/SecureIM/src/crypt_icons.cpp @@ -1,49 +1,57 @@ #include "commonheaders.h" -typedef struct { - HICON icon; - SHORT mode; -} ICON_CACHE; - - -ICON_CACHE *ICONS_CACHE = NULL; -int icons_cache = 0; +struct ICON_CACHE +{ + HICON icon; + HANDLE hCLIcon; + SHORT mode; +}; +OBJLIST arIcoList(10); // преобразует mode в HICON который НЕ НУЖНО разрушать в конце -HICON mode2icon(int mode,int type) { - - int m=mode&0x0f,s=(mode&SECURED)>>4,i; // разобрали на части - режим и состояние +static ICON_CACHE& getCacheItem(int mode, int type) +{ + int m = mode & 0x0f, s = (mode & SECURED)>>4, i; // разобрали на части - режим и состояние HICON icon; - if ( icons_cache ) { - for(i=0;iicon = icon; + p->mode = (type << 8) | mode; + p->hCLIcon = NULL; + arIcoList.insert(p); - return icon; + return *p; +} + +HICON mode2icon(int mode, int type) +{ + return getCacheItem(mode, type).icon; +} + +HANDLE mode2clicon(int mode, int type) +{ + ICON_CACHE &p = getCacheItem(mode, type); + if (p.hCLIcon == NULL) + p.hCLIcon = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)p.icon, 0); + + return p.hCLIcon; } // обновляет иконки в clist и в messagew @@ -53,18 +61,21 @@ void ShowStatusIcon(HANDLE hContact, int mode) // обновить иконки в clist if (mode != -1) { - HICON hIcon = mode2icon(mode, 1); + HANDLE hIcon = mode2clicon(mode, 1); ExtraIcon_SetIcon(g_hCLIcon, hContact, hIcon); - if ( hMC ) + if (hMC) ExtraIcon_SetIcon(g_hCLIcon, hMC, hIcon); } + else { + ExtraIcon_Clear(g_hCLIcon, hContact); + if (hMC) + ExtraIcon_Clear(g_hCLIcon, hMC); + } if ( ServiceExists(MS_MSG_MODIFYICON)) { // обновить иконки в srmm - StatusIconData sid; - memset(&sid,0,sizeof(sid)); - sid.cbSize = sizeof(sid); + StatusIconData sid = {sizeof(sid) }; sid.szModule = (char*)szModuleName; - for(int i=MODE_NATIVE; i