1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#include "commonheaders.h"
typedef struct {
HICON icon;
SHORT mode;
} ICON_CACHE;
ICON_CACHE *ICONS_CACHE = NULL;
int icons_cache = 0;
// ïðåîáðàçóåò mode â HICON êîòîðûé ÍÅ ÍÓÆÍÎ ðàçðóøàòü â êîíöå
HICON mode2icon(int mode,int type) {
int m=mode&0x0f,s=(mode&SECURED)>>4,i; // ðàçîáðàëè íà ÷àñòè - ðåæèì è ñîñòîÿíèå
HICON icon;
if ( icons_cache ) {
for(i=0;i<icons_cache;i++) {
if ( ICONS_CACHE[i].mode == ((type<<8) | mode)) {
return ICONS_CACHE[i].icon;
}
}
}
i=s;
switch(type) {
case 1: i+=IEC_CL_DIS; break;
case 2: i+=ICO_CM_DIS; break;
case 3: i+=ICO_MW_DIS; break;
}
if ( type==1 ) {
icon = BindOverlayIcon(g_hIEC[i],g_hICO[ICO_OV_NAT+m]);
}
else {
icon = BindOverlayIcon(g_hICO[i],g_hICO[ICO_OV_NAT+m]);
}
ICONS_CACHE = (ICON_CACHE*) mir_realloc(ICONS_CACHE,sizeof(ICON_CACHE)*(icons_cache+1));
ICONS_CACHE[icons_cache].icon = icon;
ICONS_CACHE[icons_cache].mode = (type<<8) | mode;
icons_cache++;
return icon;
}
// îáíîâëÿåò èêîíêè â clist è â messagew
void ShowStatusIcon(HANDLE hContact,int mode)
{
HANDLE hMC = getMetaContact(hContact);
// îáíîâèòü èêîíêè â clist
if (mode != -1) {
HICON hIcon = mode2icon(mode, 1);
ExtraIcon_SetIcon(g_hCLIcon, hContact, hIcon);
if ( hMC )
ExtraIcon_SetIcon(g_hCLIcon, hMC, hIcon);
}
if ( ServiceExists(MS_MSG_MODIFYICON)) { // îáíîâèòü èêîíêè â srmm
StatusIconData sid;
memset(&sid,0,sizeof(sid));
sid.cbSize = sizeof(sid);
sid.szModule = (char*)szModuleName;
for(int i=MODE_NATIVE; i<MODE_CNT;i++) {
sid.dwId = i;
sid.flags = (mode & SECURED) ? 0 : MBF_DISABLED;
if (mode == -1 || (mode & 0x0f) != i || isChatRoom(hContact))
sid.flags |= MBF_HIDDEN; // îòêëþ÷àåì âñå íåíóæíûå èêîíêè
CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
if ( hMC )
CallService(MS_MSG_MODIFYICON, (WPARAM)hMC, (LPARAM)&sid);
}
}
}
void ShowStatusIcon(HANDLE hContact)
{
ShowStatusIcon(hContact,isContactSecured(hContact));
}
void ShowStatusIconNotify(HANDLE hContact)
{
int mode = isContactSecured(hContact);
NotifyEventHooks(g_hEvent[(mode&SECURED)!=0], (WPARAM)hContact, 0);
ShowStatusIcon(hContact,mode);
}
void RefreshContactListIcons(void)
{
HANDLE hContact = db_find_first();
while (hContact) { // è ñíîâà çàæèãàåì èêîíêó
if ( isSecureProtocol(hContact))
ShowStatusIcon(hContact);
hContact = db_find_next(hContact);
}
}
// EOF
|