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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
|
/*
Chat module plugin for Miranda IM
Copyright (C) 2003 Jörgen Persson
Copyright 2003-2009 Miranda ICQ/IM project,
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"
HANDLE hSendEvent;
HANDLE hBuildMenuEvent ;
HANDLE g_hHookContactDblClick, g_hHookPrebuildMenu;
CRITICAL_SECTION cs;
#ifdef _WIN64
#define SIZEOF_STRUCT_GCREGISTER_V1 40
#define SIZEOF_STRUCT_GCWINDOW_V1 48
#define SIZEOF_STRUCT_GCEVENT_V1 76
#define SIZEOF_STRUCT_GCEVENT_V2 80
#else
#define SIZEOF_STRUCT_GCREGISTER_V1 28
#define SIZEOF_STRUCT_GCWINDOW_V1 32
#define SIZEOF_STRUCT_GCEVENT_V1 44
#define SIZEOF_STRUCT_GCEVENT_V2 48
#endif
int Chat_SmileyOptionsChanged(WPARAM wParam,LPARAM lParam)
{
SM_BroadcastMessage(NULL, GC_REDRAWLOG, 0, 1, FALSE);
return 0;
}
int Chat_PreShutdown(WPARAM wParam,LPARAM lParam)
{
SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE);
SM_RemoveAll();
MM_RemoveAll();
return 0;
}
int Chat_FontsChanged(WPARAM wParam,LPARAM lParam)
{
LoadLogFonts();
LoadMsgLogBitmaps();
MM_FontsChanged();
MM_FixColors();
SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
return 0;
}
int Chat_IconsChanged(WPARAM wParam,LPARAM lParam)
{
FreeMsgLogBitmaps();
LoadMsgLogBitmaps();
MM_IconsChanged();
SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, FALSE);
return 0;
}
static INT_PTR Service_GetCount(WPARAM wParam,LPARAM lParam)
{
if (!lParam)
return -1;
mir_cslock lock(cs);
return SM_GetCount((char*)lParam);
}
static INT_PTR Service_GetInfo(WPARAM wParam,LPARAM lParam)
{
GC_INFO *gci = (GC_INFO *) lParam;
if (!gci || !gci->pszModule)
return 1;
SESSION_INFO *si = NULL;
mir_cslock lock(cs);
if (gci->Flags & BYINDEX)
si = SM_FindSessionByIndex( gci->pszModule, gci->iItem );
else
si = SM_FindSession( gci->pszID, gci->pszModule );
if (si == NULL)
return 1;
if (gci->Flags & DATA) gci->dwItemData = si->dwItemData;
if (gci->Flags & HCONTACT) gci->hContact = si->windowData.hContact;
if (gci->Flags & TYPE) gci->iType = si->iType;
if (gci->Flags & COUNT) gci->iCount = si->nUsersInNicklist;
if (gci->Flags & USERS) gci->pszUsers = SM_GetUsers(si);
if (si->dwFlags & GC_UNICODE) {
if (gci->Flags & ID) gci->pszID = si->ptszID;
if (gci->Flags & NAME) gci->pszName = si->ptszName;
}
return 0;
}
void LoadModuleIcons(MODULEINFO *mi)
{
HIMAGELIST hList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0);
int overlayIcon = ImageList_AddIcon(hList, GetCachedIcon("chat_overlay"));
ImageList_SetOverlayImage(hList, overlayIcon, 1);
mi->hOnlineIconBig = LoadSkinnedProtoIconBig(mi->pszModule, ID_STATUS_ONLINE);
mi->hOnlineIcon = LoadSkinnedProtoIcon(mi->pszModule, ID_STATUS_ONLINE);
int index = ImageList_AddIcon(hList, mi->hOnlineIcon);
mi->hOnlineTalkIcon = ImageList_GetIcon(hList, index, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
mi->hOfflineIconBig = LoadSkinnedProtoIconBig(mi->pszModule, ID_STATUS_OFFLINE);
mi->hOfflineIcon = LoadSkinnedProtoIcon(mi->pszModule, ID_STATUS_OFFLINE);
index = ImageList_AddIcon(hList, mi->hOfflineIcon);
mi->hOfflineTalkIcon = ImageList_GetIcon(hList, index, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
ImageList_Destroy(hList);
}
static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam)
{
GCREGISTER *gcr = (GCREGISTER *)lParam;
if (gcr == NULL)
return GC_REGISTER_ERROR;
if (gcr->cbSize != SIZEOF_STRUCT_GCREGISTER_V1)
return GC_REGISTER_WRONGVER;
mir_cslock lock(cs);
MODULEINFO *mi = MM_AddModule( gcr->pszModule );
if (mi == NULL)
return GC_REGISTER_ERROR;
mi->ptszModDispName = a2tf( gcr->ptszModuleDispName, gcr->dwFlags );
mi->bBold = gcr->dwFlags&GC_BOLD;
mi->bUnderline = gcr->dwFlags&GC_UNDERLINE ;
mi->bItalics = gcr->dwFlags&GC_ITALICS ;
mi->bColor = gcr->dwFlags&GC_COLOR ;
mi->bBkgColor = gcr->dwFlags&GC_BKGCOLOR ;
mi->bFontSize = gcr->dwFlags&GC_FONTSIZE;
mi->bAckMsg = gcr->dwFlags&GC_ACKMSG ;
mi->bChanMgr = gcr->dwFlags&GC_CHANMGR ;
mi->bSingleFormat = gcr->dwFlags&GC_SINGLEFORMAT;
mi->iMaxText= gcr->iMaxText;
mi->nColorCount = gcr->nColors;
if ( gcr->nColors > 0) {
mi->crColors = (COLORREF *)mir_alloc(sizeof(COLORREF) * gcr->nColors);
memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF) * gcr->nColors);
}
CheckColorsInModule((char*)gcr->pszModule);
CList_SetAllOffline(TRUE, gcr->pszModule);
return 0;
}
static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam)
{
GCSESSION *gcw = (GCSESSION*)lParam;
if (gcw == NULL)
return GC_NEWSESSION_ERROR;
if (gcw->cbSize != SIZEOF_STRUCT_GCWINDOW_V1)
return GC_NEWSESSION_WRONGVER;
mir_cslock lock(cs);
MODULEINFO *mi = MM_FindModule(gcw->pszModule);
if (mi == NULL)
return GC_NEWSESSION_ERROR;
TCHAR *ptszID = a2tf( gcw->ptszID, gcw->dwFlags );
SESSION_INFO *si = SM_AddSession( ptszID, gcw->pszModule);
if (mi->hOfflineIcon == NULL)
LoadModuleIcons(mi);
// create a new session and set the defaults
if (si != NULL) {
TCHAR szTemp[256];
si->dwItemData = gcw->dwItemData;
if ( gcw->iType != GCW_SERVER )
si->wStatus = ID_STATUS_ONLINE;
si->iType = gcw->iType;
si->dwFlags = gcw->dwFlags;
si->ptszName = a2tf( gcw->ptszName, gcw->dwFlags );
si->ptszStatusbarText = a2tf( gcw->ptszStatusbarText, gcw->dwFlags );
si->iSplitterX = g_Settings.iSplitterX;
si->iSplitterY = g_Settings.iSplitterY;
si->iLogFilterFlags = (int)db_get_dw(NULL, "Chat", "FilterFlags", 0x03E0);
si->bFilterEnabled = db_get_b(NULL, "Chat", "FilterEnabled", 0);
si->bNicklistEnabled = db_get_b(NULL, "Chat", "ShowNicklist", 1);
if ( !(gcw->dwFlags & GC_UNICODE)) {
si->pszID = mir_strdup( gcw->pszID );
si->pszName = mir_strdup( gcw->pszName );
}
if (mi->bColor) {
si->iFG = 4;
si->bFGSet = TRUE;
}
if (mi->bBkgColor) {
si->iBG = 2;
si->bBGSet = TRUE;
}
if (si->iType == GCW_SERVER)
mir_sntprintf(szTemp, SIZEOF(szTemp), LPGENT("Server: %s"), si->ptszName);
else
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName);
si->windowData.hContact = CList_AddRoom( gcw->pszModule, ptszID, szTemp, si->iType);
si->windowData.codePage = db_get_w(si->windowData.hContact, si->pszModule, "CodePage", (WORD) CP_ACP);
si->pszHeader = Log_CreateRtfHeader(mi, si);
db_set_s(si->windowData.hContact, si->pszModule , "Topic", "");
db_unset(si->windowData.hContact, "CList", "StatusMsg");
if (si->ptszStatusbarText)
db_set_ts(si->windowData.hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
else
db_set_s(si->windowData.hContact, si->pszModule, "StatusBar", "");
}
else {
SESSION_INFO *si2 = SM_FindSession( ptszID, gcw->pszModule );
if (si2) {
UM_RemoveAll(&si2->pUsers);
TM_RemoveAll(&si2->pStatuses);
si2->iStatusCount = 0;
si2->nUsersInNicklist = 0;
if (si2->hWnd )
RedrawWindow(GetDlgItem(si2->hWnd, IDC_CHAT_LIST), NULL, NULL, RDW_INVALIDATE);
}
}
mir_free( ptszID );
return 0;
}
static INT_PTR DoControl(GCEVENT *gce, WPARAM wp)
{
SESSION_INFO *si;
if ( gce->pDest->iType == GC_EVENT_CONTROL ) {
switch (wp) {
case WINDOW_HIDDEN:
if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
si->bInitDone = TRUE;
SetActiveSession(si->ptszID, si->pszModule);
if (si->hWnd)
ShowRoom(si, wp, FALSE);
}
return 0;
case WINDOW_MINIMIZE:
case WINDOW_MAXIMIZE:
case WINDOW_VISIBLE:
case SESSION_INITDONE:
if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
si->bInitDone = TRUE;
if (wp != SESSION_INITDONE || db_get_b(NULL, "Chat", "PopupOnJoin", 0) == 0)
ShowRoom(si, wp, TRUE);
return 0;
}
break;
case SESSION_OFFLINE:
SM_SetOffline(gce->pDest->ptszID, gce->pDest->pszModule);
// fall through
case SESSION_ONLINE:
SM_SetStatus( gce->pDest->ptszID, gce->pDest->pszModule, wp==SESSION_ONLINE?ID_STATUS_ONLINE:ID_STATUS_OFFLINE);
break;
case WINDOW_CLEARLOG:
if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
LM_RemoveAll(&si->pLog, &si->pLogEnd);
si->iEventCount = 0;
si->LastTime = 0;
}
break;
case SESSION_TERMINATE:
return SM_RemoveSession(gce->pDest->ptszID, gce->pDest->pszModule, (gce->dwFlags & GCEF_REMOVECONTACT) != 0);
}
SM_SendMessage(gce->pDest->ptszID, gce->pDest->pszModule, GC_EVENT_CONTROL + WM_USER + 500, wp, 0);
}
else if (gce->pDest->iType == GC_EVENT_CHUID && gce->pszText)
{
SM_ChangeUID( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszNick, gce->ptszText);
}
else if (gce->pDest->iType == GC_EVENT_CHANGESESSIONAME && gce->pszText)
{
if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
replaceStrT(si->ptszName, gce->ptszText);
if (si->hWnd)
SendMessage(si->hWnd, DM_UPDATETITLEBAR, 0, 0);
}
}
else if (gce->pDest->iType == GC_EVENT_SETITEMDATA) {
if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule))
si->dwItemData = gce->dwItemData;
}
else if (gce->pDest->iType ==GC_EVENT_GETITEMDATA) {
if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
gce->dwItemData = si->dwItemData;
return si->dwItemData;
}
return 0;
}
else if (gce->pDest->iType ==GC_EVENT_SETSBTEXT)
{
if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
replaceStrT(si->ptszStatusbarText, gce->ptszText);
if (si->ptszStatusbarText)
db_set_ts(si->windowData.hContact, si->pszModule, "StatusBar", si->ptszStatusbarText);
else
db_set_s(si->windowData.hContact, si->pszModule, "StatusBar", "");
if (si->hWnd)
SendMessage(si->hWnd, DM_UPDATESTATUSBAR, 0, 0);
}
}
else if (gce->pDest->iType == GC_EVENT_ACK)
{
SM_SendMessage(gce->pDest->ptszID, gce->pDest->pszModule, GC_ACKMESSAGE, 0, 0);
}
else if (gce->pDest->iType == GC_EVENT_SENDMESSAGE && gce->pszText)
{
SM_SendUserMessage( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszText);
}
else if (gce->pDest->iType == GC_EVENT_SETSTATUSEX)
{
SM_SetStatusEx( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszText, gce->dwItemData);
}
else return 1;
return 0;
}
static void AddUser(GCEVENT * gce)
{
SESSION_INFO *si = SM_FindSession( gce->pDest->ptszID, gce->pDest->pszModule);
if (si == NULL) return;
WORD status = TM_StringToWord(si->pStatuses, gce->ptszStatus);
USERINFO *ui = SM_AddUser(si, gce->ptszUID, gce->ptszNick, status);
if (ui == NULL) return;
ui->pszNick = mir_tstrdup(gce->ptszNick);
if (gce->bIsMe)
si->pMe = ui;
ui->Status = status;
ui->Status |= si->pStatuses->Status;
if (si->hWnd)
SendMessage(si->hWnd, GC_UPDATENICKLIST, 0, 0);
}
void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground)
{
HWND hParent = NULL;
if (!si)
return;
//Do we need to create a window?
if (si->hWnd == NULL)
{
hParent = GetParentWindow(si->windowData.hContact, TRUE);
si->hWnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_CHANNEL), hParent, RoomWndProc, (LPARAM)si);
}
SendMessage(si->hWnd, DM_UPDATETABCONTROL, -1, (LPARAM)si);
SendMessage(GetParent(si->hWnd), CM_ACTIVATECHILD, 0, (LPARAM)si->hWnd);
SendMessage(GetParent(si->hWnd), CM_POPUPWINDOW, 0, (LPARAM)si->hWnd);
SendMessage(si->hWnd, WM_MOUSEACTIVATE, 0, 0);
SetFocus(GetDlgItem(si->hWnd, IDC_CHAT_MESSAGE));
}
static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam)
{
GCEVENT *gce = (GCEVENT*)lParam, save_gce;
GCDEST save_gcd;
SESSION_INFO *si;
TCHAR* pWnd = NULL;
char* pMod = NULL;
BOOL bIsHighlighted = FALSE;
BOOL bRemoveFlag = FALSE;
int iRetVal = GC_EVENT_ERROR;
if (gce == NULL)
return GC_EVENT_ERROR;
GCDEST *gcd = gce->pDest;
if (gcd == NULL)
return GC_EVENT_ERROR;
if (gce->cbSize != SIZEOF_STRUCT_GCEVENT_V1 && gce->cbSize != SIZEOF_STRUCT_GCEVENT_V2)
return GC_EVENT_WRONGVER;
if ( !IsEventSupported(gcd->iType))
return GC_EVENT_ERROR;
EnterCriticalSection(&cs);
if ( !( gce->dwFlags & GC_UNICODE)) {
save_gce = *gce;
save_gcd = *gce->pDest;
gce->pDest->ptszID = a2tf(gce->pDest->ptszID, gce->dwFlags);
gce->ptszUID = a2tf(gce->ptszUID, gce->dwFlags);
gce->ptszNick = a2tf(gce->ptszNick, gce->dwFlags);
gce->ptszStatus = a2tf(gce->ptszStatus, gce->dwFlags);
gce->ptszText = a2tf(gce->ptszText, gce->dwFlags);
gce->ptszUserInfo = a2tf(gce->ptszUserInfo, gce->dwFlags);
}
// Do different things according to type of event
switch(gcd->iType) {
case GC_EVENT_ADDGROUP:
{
STATUSINFO *si = SM_AddStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszStatus);
if (si && gce->dwItemData)
si->hIcon = CopyIcon((HICON)gce->dwItemData);
}
iRetVal = 0;
goto LBL_Exit;
case GC_EVENT_CHUID:
case GC_EVENT_CHANGESESSIONAME:
case GC_EVENT_SETITEMDATA:
case GC_EVENT_GETITEMDATA:
case GC_EVENT_CONTROL:
case GC_EVENT_SETSBTEXT:
case GC_EVENT_ACK:
case GC_EVENT_SENDMESSAGE :
case GC_EVENT_SETSTATUSEX :
iRetVal = DoControl(gce, wParam);
goto LBL_Exit;
case GC_EVENT_SETCONTACTSTATUS:
iRetVal = SM_SetContactStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData);
goto LBL_Exit;
case GC_EVENT_TOPIC:
if (si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
if (gce->pszText) {
replaceStrT(si->ptszTopic, gce->ptszText);
db_set_ts(si->windowData.hContact, si->pszModule , "Topic", RemoveFormatting(si->ptszTopic));
if ( db_get_b( NULL, "Chat", "TopicOnClist", 0 ))
db_set_ts(si->windowData.hContact, "CList" , "StatusMsg", RemoveFormatting(si->ptszTopic));
}
}
break;
case GC_EVENT_ADDSTATUS:
SM_GiveStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
break;
case GC_EVENT_REMOVESTATUS:
SM_TakeStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
break;
case GC_EVENT_MESSAGE:
case GC_EVENT_ACTION:
if (!gce->bIsMe && gce->pDest->ptszID && gce->pszText) {
if (si = SM_FindSession( gce->pDest->ptszID, gce->pDest->pszModule))
if ( IsHighlighted(si, gce->ptszText))
bIsHighlighted = TRUE;
}
break;
case GC_EVENT_NICK:
SM_ChangeNick( gce->pDest->ptszID, gce->pDest->pszModule, gce);
break;
case GC_EVENT_JOIN:
AddUser(gce);
break;
case GC_EVENT_PART:
case GC_EVENT_QUIT:
case GC_EVENT_KICK:
bRemoveFlag = TRUE;
break;
}
// Decide which window (log) should have the event
if (gcd->ptszID) {
pWnd = gcd->ptszID;
pMod = gcd->pszModule;
}
else if (gcd->iType == GC_EVENT_NOTICE || gcd->iType == GC_EVENT_INFORMATION) {
SESSION_INFO *si = GetActiveSession();
if (si && !lstrcmpA(si->pszModule, gcd->pszModule)) {
pWnd = si->ptszID;
pMod = si->pszModule;
}
else {
iRetVal = 0;
goto LBL_Exit;
}
}
else {
// Send the event to all windows with a user pszUID. Used for broadcasting QUIT etc
SM_AddEventToAllMatchingUID(gce);
if (!bRemoveFlag) {
iRetVal = 0;
goto LBL_Exit;
}
}
// add to log
if (pWnd) {
si = SM_FindSession(pWnd, pMod);
// fix for IRC's old stuyle mode notifications. Should not affect any other protocol
if ((gce->pDest->iType == GC_EVENT_ADDSTATUS || gce->pDest->iType == GC_EVENT_REMOVESTATUS) && !(gce->dwFlags & GCEF_ADDTOLOG)) {
iRetVal = 0;
goto LBL_Exit;
}
if (gce && gce->pDest->iType == GC_EVENT_JOIN && gce->time == 0) {
iRetVal = 0;
goto LBL_Exit;
}
if (si && (si->bInitDone || gce->pDest->iType == GC_EVENT_TOPIC || (gce->pDest->iType == GC_EVENT_JOIN && gce->bIsMe))) {
if (SM_AddEvent(pWnd, pMod, gce, bIsHighlighted) && si->hWnd)
SendMessage(si->hWnd, GC_ADDLOG, 0, 0);
else if (si->hWnd)
SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0);
if (!(gce->dwFlags & GCEF_NOTNOTIFY))
DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.LoggingEnabled)
LogToFile(si, gce);
}
if (!bRemoveFlag) {
iRetVal = 0;
goto LBL_Exit;
}
}
if (bRemoveFlag)
iRetVal = ( SM_RemoveUser( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID ) == 0 ) ? 1 : 0;
LBL_Exit:
LeaveCriticalSection(&cs);
if ( !( gce->dwFlags & GC_UNICODE )) {
mir_free((void*)gce->ptszText);
mir_free((void*)gce->ptszNick);
mir_free((void*)gce->ptszUID);
mir_free((void*)gce->ptszStatus);
mir_free((void*)gce->ptszUserInfo);
mir_free((void*)gce->pDest->ptszID);
*gce = save_gce;
*gce->pDest = save_gcd;
}
return iRetVal;
}
static INT_PTR Service_GetAddEventPtr(WPARAM wParam, LPARAM lParam)
{
GCPTRS * gp = (GCPTRS *) lParam;
EnterCriticalSection(&cs);
gp->pfnAddEvent = Service_AddEvent;
LeaveCriticalSection(&cs);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
// Service creation
void HookEvents(void)
{
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, CList_PrebuildContactMenu);
}
void CreateServiceFunctions(void)
{
CreateServiceFunction(MS_GC_REGISTER, Service_Register);
CreateServiceFunction(MS_GC_NEWSESSION, Service_NewChat);
CreateServiceFunction(MS_GC_EVENT, Service_AddEvent);
CreateServiceFunction(MS_GC_GETEVENTPTR, Service_GetAddEventPtr);
CreateServiceFunction(MS_GC_GETINFO, Service_GetInfo);
CreateServiceFunction(MS_GC_GETSESSIONCOUNT, Service_GetCount);
CreateServiceFunction("GChat/DblClickEvent", CList_EventDoubleclickedSvc);
CreateServiceFunction("GChat/PrebuildMenuEvent", CList_PrebuildContactMenuSvc);
CreateServiceFunction("GChat/JoinChat", CList_JoinChat);
CreateServiceFunction("GChat/LeaveChat", CList_LeaveChat);
}
void CreateHookableEvents(void)
{
hSendEvent = CreateHookableEvent(ME_GC_EVENT);
hBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU);
}
void DestroyHookableEvents(void)
{
DestroyHookableEvent(hSendEvent);
DestroyHookableEvent(hBuildMenuEvent);
}
|