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
|
/*
NewXstatusNotify YM - Plugin for Miranda IM
Copyright (c) 2001-2004 Luca Santarelli
Copyright (c) 2005-2007 Vasilich
Copyright (c) 2007-2011 yaho
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 "common.h"
void PreviewSound(HWND hList)
{
TCHAR buff[MAX_PATH], stzSoundPath[MAX_PATH];
LVITEM lvi = {0};
lvi.mask = LVIF_PARAM;
lvi.iItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
ListView_GetItem(hList, &lvi);
int hlpStatus = lvi.lParam;
ListView_GetItemText(hList, lvi.iItem, 1, buff, SIZEOF(buff));
if (_tcscmp(buff, TranslateT(DEFAULT_SOUND)) == 0)
{
if (hlpStatus == ID_STATUS_FROMOFFLINE)
SkinPlaySound("UserFromOffline");
else
SkinPlaySound(StatusList[Index(hlpStatus)].lpzSkinSoundName);
}
else
{
PathToAbsoluteT(buff, stzSoundPath);
SkinPlaySoundFile(stzSoundPath);
}
}
BOOL RemoveSoundFromList(HWND hList)
{
int iSel = ListView_GetSelectionMark(hList);
if (iSel != -1)
{
iSel = -1;
while ((iSel = ListView_GetNextItem(hList, iSel, LVNI_SELECTED)) != -1)
ListView_SetItemText(hList, iSel, 1, TranslateT(DEFAULT_SOUND));
return TRUE;
}
return FALSE;
}
TCHAR *SelectSound(HWND hwndDlg, TCHAR *buff)
{
OPENFILENAME ofn = {0};
HWND hList = GetDlgItem(hwndDlg, IDC_INDSNDLIST);
ListView_GetItemText(hList, ListView_GetNextItem(hList,- 1, LVNI_SELECTED), 1, buff, SIZEOF(buff));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = GetParent(hwndDlg);
ofn.hInstance = hInst;
TCHAR filter[MAX_PATH];
if (GetModuleHandle(_T("bass_interface.dll")))
mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%s (*.*)%c*%c"), TranslateT("Sound files"), 0, 0, TranslateT("All files"), 0, 0);
else
mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.wav)%c*.wav%c%s (*.*)%c*%c"), TranslateT("Wave files"), 0, 0, TranslateT("All files"), 0, 0);
ofn.lpstrFilter = filter;
ofn.lpstrFile = buff;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR;
ofn.nMaxFile = MAX_PATH;
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = _T("");
if (GetOpenFileName(&ofn))
return buff;
return NULL;
}
HIMAGELIST GetStatusIconsImgList(char *szProto)
{
HIMAGELIST hList = NULL;
if (szProto)
{
hList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, STATUS_COUNT, 0);
if (hList != NULL)
{
for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX; i++)
ImageList_AddIcon(hList, LoadSkinnedProtoIcon(szProto, StatusList[Index(i)].ID));
ImageList_AddIcon(hList, LoadSkinnedIcon(SKINICON_OTHER_USERONLINE));
}
}
return hList;
}
INT_PTR CALLBACK DlgProcSoundUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static MCONTACT hContact = NULL;
HWND hList = GetDlgItem(hwndDlg, IDC_INDSNDLIST);
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
hContact = lParam;
char *szProto = GetContactProto(hContact);
ListView_SetImageList(hList, GetStatusIconsImgList(szProto), LVSIL_SMALL);
ListView_SetExtendedListViewStyleEx(hList, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
RECT rc = { 0 };
GetClientRect(hList, &rc);
LV_COLUMN lvc = { 0 };
lvc.mask = LVCF_WIDTH | LVCF_TEXT;
lvc.cx = STATUS_COLUMN;
lvc.pszText = TranslateT("Status");
ListView_InsertColumn(hList, 0, &lvc);
lvc.cx = rc.right - STATUS_COLUMN - GetSystemMetrics(SM_CXVSCROLL);
lvc.pszText = TranslateT("Sound for the status");
ListView_InsertColumn(hList, 1, &lvc);
if (szProto) {
DBVARIANT dbv;
TCHAR buff[MAX_PATH];
for (int i = ID_STATUS_MAX; i >= ID_STATUS_MIN; i--) {
int flags = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_2, 0);
if (flags == 0)
flags = PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
if ((flags & Proto_Status2Flag(i)) || i == ID_STATUS_OFFLINE) {
LV_ITEM lvi = { 0 };
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
lvi.iItem = 0;
lvi.iSubItem = 0;
lvi.iImage = Index(i);
lvi.lParam = (LPARAM)i;
lvi.pszText = TranslateTS(StatusList[Index(i)].lpzStandardText);
lvi.iItem = ListView_InsertItem(hList, &lvi);
if (!db_get_ts(hContact, MODULE, StatusList[Index(i)].lpzSkinSoundName, &dbv)) {
_tcscpy(buff, dbv.ptszVal);
db_free(&dbv);
}
else
_tcscpy(buff, TranslateT(DEFAULT_SOUND));
ListView_SetItemText(hList, lvi.iItem, 1, buff);
}
}
LV_ITEM lvi = { 0 };
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
lvi.iItem = 0;
lvi.iSubItem = 0;
lvi.iImage = Index(ID_STATUS_MAX) + 1; // additional icon
lvi.lParam = (LPARAM)ID_STATUS_FROMOFFLINE;
lvi.pszText = TranslateT("From offline");
lvi.iItem = ListView_InsertItem(hList, &lvi);
if (!db_get_ts(hContact, MODULE, "UserFromOffline", &dbv)) {
_tcscpy(buff, dbv.ptszVal);
db_free(&dbv);
}
else _tcscpy(buff, TranslateT(DEFAULT_SOUND));
ListView_SetItemText(hList, lvi.iItem, 1, buff);
}
CheckDlgButton(hwndDlg, IDC_CHECK_NOTIFYSOUNDS, db_get_b(hContact, MODULE, "EnableSounds", 1));
CheckDlgButton(hwndDlg, IDC_CHECK_NOTIFYPOPUPS, db_get_b(hContact, MODULE, "EnablePopups", 1));
ShowWindow(GetDlgItem(hwndDlg, IDC_INDSNDLIST), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_TEXT_ENABLE_IS), opt.UseIndSnd ? SW_HIDE : SW_SHOW);
ShowWindow(GetDlgItem(hwndDlg, IDC_CHANGE), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_PREVIEW), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_DELETE), opt.UseIndSnd ? SW_SHOW : SW_HIDE);
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_PREVIEW:
if (ListView_GetSelectionMark(hList) != -1)
PreviewSound(hList);
break;
case IDC_CHANGE:
{
int iSel = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_INDSNDLIST), -1, LVNI_SELECTED);
if (iSel != -1) {
TCHAR stzFilePath[MAX_PATH];
if (SelectSound(hwndDlg, stzFilePath) != NULL) {
iSel = -1;
while ((iSel = ListView_GetNextItem(hList, iSel, LVNI_SELECTED)) != -1)
ListView_SetItemText(hList, iSel, 1, stzFilePath);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
}
}
break;
case IDC_DELETE:
if (ListView_GetSelectionMark(hList) != -1)
if (RemoveSoundFromList(GetDlgItem(hwndDlg, IDC_INDSNDLIST)))
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHECK_NOTIFYSOUNDS:
db_set_b(hContact, MODULE, "EnableSounds", IsDlgButtonChecked(hwndDlg, IDC_CHECK_NOTIFYSOUNDS) ? 1 : 0);
break;
case IDC_CHECK_NOTIFYPOPUPS:
db_set_b(hContact, MODULE, "EnablePopups", IsDlgButtonChecked(hwndDlg, IDC_CHECK_NOTIFYPOPUPS) ? 1 : 0);
break;
}
break;
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
TCHAR buff[MAX_PATH];
HWND hList = GetDlgItem(hwndDlg, IDC_INDSNDLIST);
LVITEM lvi = { 0 };
lvi.mask = LVIF_PARAM;
//Cycle through the list reading the text associated to each status.
for (lvi.iItem = ListView_GetItemCount(hList) - 1; lvi.iItem >= 0; lvi.iItem--) {
ListView_GetItem(hList, &lvi);
ListView_GetItemText(hList, lvi.iItem, 1, buff, SIZEOF(buff));
if (!_tcscmp(buff, TranslateT(DEFAULT_SOUND))) {
if (lvi.lParam == ID_STATUS_FROMOFFLINE)
db_unset(hContact, MODULE, "UserFromOffline");
else
db_unset(hContact, MODULE, StatusList[Index(lvi.lParam)].lpzSkinSoundName);
}
else {
TCHAR stzSoundPath[MAX_PATH] = { 0 };
PathToRelativeT(buff, stzSoundPath);
if (lvi.lParam == ID_STATUS_FROMOFFLINE)
db_set_ws(hContact, MODULE, "UserFromOffline", stzSoundPath);
else
db_set_ws(hContact, MODULE, StatusList[Index(lvi.lParam)].lpzSkinSoundName, stzSoundPath);
}
}
return TRUE;
}
int hlpControlID = (int)wParam;
switch (hlpControlID) {
case IDC_INDSNDLIST:
if (((LPNMHDR)lParam)->code == NM_DBLCLK) {
TCHAR stzFilePath[MAX_PATH];
if (SelectSound(hwndDlg, stzFilePath) != NULL) {
int iSel = -1;
HWND hList = GetDlgItem(hwndDlg, IDC_INDSNDLIST);
while ((iSel = ListView_GetNextItem(hList, iSel, LVNI_SELECTED)) != -1)
ListView_SetItemText(hList, iSel, 1, stzFilePath);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
return TRUE;
}
else if (((LPNMHDR)lParam)->code == LVN_KEYDOWN) {
LPNMLVKEYDOWN pnkd = (LPNMLVKEYDOWN)lParam;
if (pnkd->wVKey == VK_DELETE)
RemoveSoundFromList(GetDlgItem(hwndDlg, IDC_INDSNDLIST));
}
break;
}
break;
}
return FALSE;
}
int UserInfoInitialise(WPARAM wParam, LPARAM lParam)
{
if (lParam) {
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.position = 100000000;
odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SOUNDS);
odp.pszTitle = LPGEN("Status Notify");
odp.pfnDlgProc = DlgProcSoundUIPage;
UserInfo_AddPage(wParam, &odp);
}
return 0;
}
void ResetListOptions(HWND hwndList)
{
SendMessage(hwndList, CLM_SETBKBITMAP, 0, 0);
SendMessage(hwndList, CLM_SETBKCOLOR, GetSysColor(COLOR_WINDOW), 0);
SendMessage(hwndList, CLM_SETGREYOUTFLAGS, 0, 0);
SendMessage(hwndList, CLM_SETLEFTMARGIN, 4, 0);
SendMessage(hwndList, CLM_SETINDENT, 10, 0);
for (int i = 0; i <= FONTID_MAX; i++)
SendMessage(hwndList, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT));
SetWindowLongPtr(hwndList, GWL_STYLE, GetWindowLongPtr(hwndList,GWL_STYLE) | CLS_SHOWHIDDEN);
}
__inline int GetExtraImage(HWND hwndList, HANDLE hItem, int column)
{
return SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(column, 0));
}
__inline void SetExtraImage(HWND hwndList, HANDLE hItem, int column, int imageID)
{
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(column, imageID));
}
void SetAllContactsIcons(HWND hwndList)
{
BYTE EnableSounds, EnablePopups, EnableXStatus, EnableLogging;
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
if (hItem) {
char *szProto = GetContactProto(hContact);
if (szProto) {
EnableSounds = db_get_b(hContact, MODULE, "EnableSounds", 1);
EnablePopups = db_get_b(hContact, MODULE, "EnablePopups", 1);
EnableXStatus = db_get_b(hContact, MODULE, "EnableXStatusNotify", 1);
EnableLogging = db_get_b(hContact, MODULE, "EnableLogging", 1);
}
else EnableSounds = EnablePopups = EnableXStatus = EnableLogging = 0;
SetExtraImage(hwndList, hItem, EXTRA_IMAGE_SOUND, EnableSounds ? EXTRA_IMAGE_SOUND : EXTRA_IMAGE_DOT);
SetExtraImage(hwndList, hItem, EXTRA_IMAGE_POPUP, EnablePopups? EXTRA_IMAGE_POPUP : EXTRA_IMAGE_DOT);
SetExtraImage(hwndList, hItem, EXTRA_IMAGE_XSTATUS, EnableXStatus ? EXTRA_IMAGE_XSTATUS : EXTRA_IMAGE_DOT);
SetExtraImage(hwndList, hItem, EXTRA_IMAGE_LOGGING, EnableLogging ? EXTRA_IMAGE_LOGGING : EXTRA_IMAGE_DOT);
SetExtraImage(hwndList, hItem, EXTRA_IMAGE_DISABLEALL, EXTRA_IMAGE_DISABLEALL);
SetExtraImage(hwndList, hItem, EXTRA_IMAGE_ENABLEALL, EXTRA_IMAGE_ENABLEALL);
}
}
}
void SetGroupsIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentItem, int *groupChildCount)
{
int iconOn[6] = {1,1,1,1,1,1};
int childCount[6] = {0};
HANDLE hItem;
int typeOfFirst = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0);
if (typeOfFirst == CLCIT_GROUP)
hItem = hFirstItem;
else
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem);
while (hItem)
{
HANDLE hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if (hChildItem)
SetGroupsIcons(hwndList, hChildItem, hItem, childCount);
for (int i = 0; i < SIZEOF(iconOn); i++)
{
if (iconOn[i] && GetExtraImage(hwndList, hItem, i) == EXTRA_IMAGE_DOT)
iconOn[i] = 0;
}
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
}
//check contacts
if (typeOfFirst == CLCIT_CONTACT)
hItem = hFirstItem;
else
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
while(hItem)
{
for (int i = 0; i < SIZEOF(iconOn); i++)
{
int image = GetExtraImage(hwndList, hItem, i);
if (iconOn[i] && image == EXTRA_IMAGE_DOT)
iconOn[i] = 0;
if (image != EMPTY_EXTRA_ICON)
childCount[i]++;
}
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
//set icons
for(int i = 0; i < SIZEOF(iconOn); i++)
{
SetExtraImage(hwndList, hParentItem, i, childCount[i] ? (iconOn[i] ? i : EXTRA_IMAGE_DOT) : EMPTY_EXTRA_ICON);
if (groupChildCount)
groupChildCount[i] += childCount[i];
}
}
void SetAllChildrenIcons(HWND hwndList, HANDLE hFirstItem, int column, int image)
{
HANDLE hItem, hChildItem;
int typeOfFirst = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0);
if (typeOfFirst == CLCIT_GROUP)
hItem = hFirstItem;
else
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem);
while(hItem)
{
hChildItem = (HANDLE)SendMessage(hwndList ,CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if (hChildItem)
SetAllChildrenIcons(hwndList, hChildItem, column, image);
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
}
if (typeOfFirst == CLCIT_CONTACT)
hItem = hFirstItem;
else
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
while(hItem)
{
int oldIcon = GetExtraImage(hwndList, hItem, column);
if (oldIcon != EMPTY_EXTRA_ICON && oldIcon != image)
SetExtraImage(hwndList, hItem, column, image);
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
}
INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HANDLE hItemAll;
switch (msg) {
case WM_INITDIALOG:
{
TranslateDialogDefault(hwndDlg);
HIMAGELIST hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 3, 3);
ImageList_AddIcon(hImageList, LoadIcon(hInst,MAKEINTRESOURCE(IDI_SOUND)));
SendDlgItemMessage(hwndDlg,IDC_SOUNDICON,STM_SETICON, (WPARAM)ImageList_GetIcon(hImageList, EXTRA_IMAGE_SOUND, ILD_NORMAL), 0);
ImageList_AddIcon(hImageList, LoadIcon(hInst, MAKEINTRESOURCE(IDI_POPUP)));
SendDlgItemMessage(hwndDlg, IDC_POPUPICON, STM_SETICON, (WPARAM)ImageList_GetIcon(hImageList, EXTRA_IMAGE_POPUP, ILD_NORMAL), 0);
ImageList_AddIcon(hImageList, LoadIcon(hInst,MAKEINTRESOURCE(IDI_XSTATUS)));
SendDlgItemMessage(hwndDlg, IDC_XSTATUSICON, STM_SETICON, (WPARAM)ImageList_GetIcon(hImageList, EXTRA_IMAGE_XSTATUS, ILD_NORMAL), 0);
ImageList_AddIcon(hImageList, LoadIcon(hInst,MAKEINTRESOURCE(IDI_LOGGING)));
SendDlgItemMessage(hwndDlg, IDC_LOGGINGICON, STM_SETICON, (WPARAM)ImageList_GetIcon(hImageList, EXTRA_IMAGE_LOGGING, ILD_NORMAL), 0);
ImageList_AddIcon(hImageList, LoadIcon(hInst,MAKEINTRESOURCE(IDI_DISABLEALL)));
SendDlgItemMessage(hwndDlg, IDC_DISABLEALLICON, STM_SETICON, (WPARAM)ImageList_GetIcon(hImageList, EXTRA_IMAGE_DISABLEALL, ILD_NORMAL), 0);
ImageList_AddIcon(hImageList, LoadIcon(hInst,MAKEINTRESOURCE(IDI_ENABLEALL)));
SendDlgItemMessage(hwndDlg, IDC_ENABLEALLICON, STM_SETICON, (WPARAM)ImageList_GetIcon(hImageList, EXTRA_IMAGE_ENABLEALL, ILD_NORMAL), 0);
ImageList_AddIcon(hImageList, LoadSkinnedIcon(SKINICON_OTHER_SMALLDOT));
SendDlgItemMessage(hwndDlg, IDC_INDSNDLIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hImageList);
SendDlgItemMessage(hwndDlg, IDC_INDSNDLIST, CLM_SETEXTRACOLUMNS, 6, 0);
HWND hList = GetDlgItem(hwndDlg, IDC_INDSNDLIST);
ResetListOptions(hList);
CLCINFOITEM cii = {0};
cii.cbSize = sizeof(cii);
cii.flags = CLCIIF_GROUPFONT;
cii.pszText = TranslateT("** All contacts **");
hItemAll = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_INDSNDLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
return TRUE;
}
case WM_SETFOCUS:
SetFocus(GetDlgItem(hwndDlg, IDC_INDSNDLIST));
break;
case WM_NOTIFY:
{
HWND hList = GetDlgItem(hwndDlg, IDC_INDSNDLIST);
switch(((LPNMHDR)lParam)->idFrom) {
case IDC_INDSNDLIST:
switch (((LPNMHDR)lParam)->code) {
case CLN_NEWCONTACT:
case CLN_LISTREBUILT:
SetAllContactsIcons(hList);
//fall through
case CLN_CONTACTMOVED:
SetGroupsIcons(hList, (HANDLE)SendMessage(hList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL);
break;
case CLN_OPTIONSCHANGED:
ResetListOptions(hList);
break;
case NM_CLICK:
{
NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
DWORD hitFlags;
// Make sure we have an extra column
if (nm->iColumn == -1) break;
// Find clicked item
HANDLE hItem = (HANDLE)SendMessage(hList, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y));
if (hItem == NULL) break;
if (!(hitFlags & CLCHT_ONITEMEXTRA)) break;
int itemType = SendMessage(hList, CLM_GETITEMTYPE, (WPARAM)hItem, 0);
// Get image in clicked column
int image = GetExtraImage(hList, hItem, nm->iColumn);
if (image == EXTRA_IMAGE_DOT)
image = nm->iColumn;
else if (image >= EXTRA_IMAGE_SOUND && image <= EXTRA_IMAGE_LOGGING)
image = EXTRA_IMAGE_DOT;
// Get item type (contact, group, etc...)
if (itemType == CLCIT_CONTACT)
{
if (image == EXTRA_IMAGE_DISABLEALL)
{
for (int i = 0; i < 4; i++)
SetExtraImage(hList, hItem, i, EXTRA_IMAGE_DOT);
}
else if (image == EXTRA_IMAGE_ENABLEALL)
{
for (int i = 0; i < 4; i++)
SetExtraImage(hList, hItem, i, i);
}
else SetExtraImage(hList, hItem, nm->iColumn, image);
}
else if (itemType == CLCIT_INFO || itemType == CLCIT_GROUP) {
if (itemType == CLCIT_GROUP)
hItem = (HANDLE)SendMessage(hList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if (hItem) {
if (image == EXTRA_IMAGE_DISABLEALL)
{
for (int i = 0; i < 4; i++)
SetAllChildrenIcons(hList, hItem, i, EXTRA_IMAGE_DOT);
}
else if (image == EXTRA_IMAGE_ENABLEALL)
{
for (int i = 0; i < 4; i++)
SetAllChildrenIcons(hList, hItem, i, i);
}
else SetAllChildrenIcons(hList, hItem, nm->iColumn, image);
}
}
// Update the all/none icons
SetGroupsIcons(hList, (HANDLE)SendMessage(hList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL);
// Activate Apply button
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
}
break;
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendMessage(hList, CLM_FINDCONTACT, hContact, 0);
if (hItem) {
if (GetExtraImage(hList, hItem, EXTRA_IMAGE_SOUND) == EXTRA_IMAGE_SOUND)
db_unset(hContact, MODULE, "EnableSounds");
else
db_set_b(hContact, MODULE, "EnableSounds", 0);
if (GetExtraImage(hList, hItem, EXTRA_IMAGE_POPUP) == EXTRA_IMAGE_POPUP)
db_unset(hContact, MODULE, "EnablePopups");
else
db_set_b(hContact, MODULE, "EnablePopups", 0);
if (GetExtraImage(hList, hItem, EXTRA_IMAGE_XSTATUS) == EXTRA_IMAGE_XSTATUS)
db_unset(hContact, MODULE, "EnableXStatusNotify");
else
db_set_b(hContact, MODULE, "EnableXStatusNotify", 0);
if (GetExtraImage(hList, hItem, EXTRA_IMAGE_LOGGING) == EXTRA_IMAGE_LOGGING)
db_unset(hContact, MODULE, "EnableLogging");
else
db_set_b(hContact, MODULE, "EnableLogging", 0);
}
}
return TRUE;
}
}
}
break;
case WM_DESTROY:
HIMAGELIST hImageList = (HIMAGELIST)SendMessage(GetDlgItem(hwndDlg, IDC_INDSNDLIST), CLM_GETEXTRAIMAGELIST, 0, 0);
for (int i = 0; i < ImageList_GetImageCount(hImageList); i++)
DestroyIcon(ImageList_GetIcon(hImageList, i, ILD_NORMAL));
ImageList_Destroy(hImageList);
break;
}
return FALSE;
}
|