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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
/*
Miranda IM: the free IM client for Microsoft* Windows*
Copyright 2000-2003 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "commonheaders.h"
extern int DefaultImageListColorDepth;
int InitCustomMenus(void);
void UninitCustomMenus(void);
int ContactSettingChanged(WPARAM wParam,LPARAM lParam);
int CListOptInit(WPARAM wParam,LPARAM lParam);
INT_PTR ContactChangeGroup(WPARAM wParam,LPARAM lParam);
INT_PTR HotkeysProcessMessage(WPARAM wParam,LPARAM lParam) { return pcli->pfnHotkeysProcessMessage(wParam, lParam); }
void InitTrayMenus(void);
HIMAGELIST hCListImages;
HANDLE hContactIconChangedEvent;
extern BYTE nameOrder[];
static HANDLE hSettingChanged, hProtoAckHook;
/////////// End by FYR ////////
int cli_IconFromStatusMode(const char *szProto,int nStatus, HANDLE hContact)
{
int result=-1;
if (hContact && szProto) {
char * szActProto=(char*)szProto;
char AdvancedService[255]={0};
int nActStatus=nStatus;
HANDLE hActContact=hContact;
if (!DBGetContactSettingByte(NULL,"CLC","Meta",0) && !strcmp(szActProto,"MetaContacts")) {
// substitute params by mostonline contact datas
HANDLE hMostOnlineContact=(HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hActContact,0);
if (hMostOnlineContact && hMostOnlineContact != (HANDLE)CALLSERVICE_NOTFOUND) {
pdisplayNameCacheEntry cacheEntry;
cacheEntry=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hMostOnlineContact);
if (cacheEntry && cacheEntry->szProto) {
szActProto=cacheEntry->szProto;
nActStatus=cacheEntry->status;
hActContact=hMostOnlineContact;
}
}
}
_snprintf(AdvancedService,sizeof(AdvancedService),"%s%s",szActProto,"/GetAdvancedStatusIcon");
if (ServiceExists(AdvancedService))
result = CallService(AdvancedService,(WPARAM)hActContact, (LPARAM)0);
if (result==-1 || !(LOWORD(result)))
// result == -1 means no Advanced icon. LOWORD(result) == 0 happens when Advanced icon returned by ICQ (i.e. no transpot)
result = saveIconFromStatusMode(szActProto,nActStatus,NULL);
}
else result=saveIconFromStatusMode(szProto,nStatus,NULL);
return result;
}
////////// By FYR/////////////
int ExtIconFromStatusMode(HANDLE hContact, const char *szProto,int status)
{
/* if ( DBGetContactSettingByte( NULL, "CLC", "Meta", 0 ) == 1 )
return pcli->pfnIconFromStatusMode(szProto,status,hContact);
if ( szProto != NULL ) {
if (strcmp(szProto,"MetaContacts") == 0 ) {
hContact=(HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(UINT)hContact,0);
if ( hContact != 0 ) {
szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(UINT)hContact,0);
status=DBGetContactSettingWord(hContact,szProto,"Status",ID_STATUS_OFFLINE);
}
}
}*/
return pcli->pfnIconFromStatusMode(szProto,status,hContact);
}
/////////// End by FYR ////////
static int ProtocolAck(WPARAM wParam,LPARAM lParam)
{
ACKDATA *ack=(ACKDATA*)lParam;
if (ack->type==ACKTYPE_AWAYMSG && ack->lParam) {
DBVARIANT dbv;
if (!DBGetContactSettingString(ack->hContact, "CList", "StatusMsg", &dbv)) {
if (!strcmp(dbv.pszVal, (char *)ack->lParam)) {
DBFreeVariant(&dbv);
return 0;
}
DBFreeVariant(&dbv);
}
if ( DBGetContactSettingByte(NULL,"CList","ShowStatusMsg",0) || DBGetContactSettingByte(ack->hContact,"CList","StatusMsgAuto",0))
DBWriteContactSettingString(ack->hContact, "CList", "StatusMsg", (char *)ack->lParam);
}
return 0;
}
static INT_PTR GetStatusMode(WPARAM wParam, LPARAM lParam)
{
return pcli->currentDesiredStatusMode;
}
static int ContactListShutdownProc(WPARAM wParam,LPARAM lParam)
{
UnhookEvent(hProtoAckHook);
UninitCustomMenus();
return 0;
}
int LoadContactListModule(void)
{
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
while (hContact!=NULL) {
DBWriteContactSettingString(hContact, "CList", "StatusMsg", "");
hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
hCListImages = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0);
DefaultImageListColorDepth=DBGetContactSettingDword(NULL,"CList","DefaultImageListColorDepth",ILC_COLOR32);
hProtoAckHook = (HANDLE) HookEvent(ME_PROTO_ACK, ProtocolAck);
HookEvent(ME_OPT_INITIALISE,CListOptInit);
HookEvent(ME_SYSTEM_SHUTDOWN,ContactListShutdownProc);
hSettingChanged=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,ContactSettingChanged);
hContactIconChangedEvent=CreateHookableEvent(ME_CLIST_CONTACTICONCHANGED);
CreateServiceFunction(MS_CLIST_CONTACTCHANGEGROUP,ContactChangeGroup);
CreateServiceFunction(MS_CLIST_HOTKEYSPROCESSMESSAGE,HotkeysProcessMessage);
CreateServiceFunction(MS_CLIST_GETSTATUSMODE, GetStatusMode);
InitCustomMenus();
InitTrayMenus();
return 0;
}
|