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
|
/*
Miranda NG: the free IM client for Microsoft* Windows*
Copyright (c) 2012-18 Miranda NG team (https://miranda-ng.org),
Copyright (c) 2000-03 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 "stdafx.h"
#include <m_genmenu.h>
#include <m_ignore.h>
#include "cluiframes.h"
#pragma hdrstop
extern IconItemT iconItem[];
void InitIconLibMenuIcons();
INT_PTR CloseAction(WPARAM, LPARAM)
{
cfg::shutDown = 1;
if (Miranda_OkToExit()) {
DestroyWindow(pcli->hwndContactList);
PostQuitMessage(0);
Sleep(0);
}
return 0;
}
static MWindowList hWindowListIGN = nullptr;
// dialog procedure for handling the contact ignore dialog (available from the contact menu
static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hWnd, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
{
DWORD dwMask;
ClcContact *contact = nullptr;
int pCaps;
HWND hwndAdd;
hContact = lParam;
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)hContact);
dwMask = db_get_dw(hContact, "Ignore", "Mask1", 0);
SendMessage(hWnd, WM_USER + 100, hContact, dwMask);
SendMessage(hWnd, WM_USER + 120, 0, 0);
TranslateDialogDefault(hWnd);
hwndAdd = GetDlgItem(hWnd, IDC_IGN_ADDPERMANENTLY); // CreateWindowEx(0, L"CLCButtonClass", L"FOO", WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_hInst, NULL);
CustomizeButton(hwndAdd, false, true, false);
SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_ADDCONTACT));
SetWindowText(hwndAdd, TranslateT("Add permanently"));
EnableWindow(hwndAdd, db_get_b(hContact, "CList", "NotOnList", 0));
hwndAdd = GetDlgItem(hWnd, IDC_DSP_LOADDEFAULT); // CreateWindowEx(0, L"CLCButtonClass", L"FOO", WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_hInst, NULL);
CustomizeButton(hwndAdd, false, true, false);
SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_DELETE));
SetWindowText(hwndAdd, TranslateT("Revert to default"));
EnableWindow(hwndAdd, TRUE);
SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Default (global setting)"));
SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Show always when available"));
SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Hide always"));
SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Default (global setting)"));
SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Never"));
SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Always"));
SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When space is available"));
SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When needed by status message"));
if (cfg::clcdat) {
Clist_FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr);
if (contact && contact->type != CLCIT_CONTACT) {
DestroyWindow(hWnd);
return FALSE;
}
else {
wchar_t szTitle[512];
DWORD dwFlags = db_get_dw(hContact, "CList", "CLN_Flags", 0);
BYTE bSecondLine = db_get_b(hContact, "CList", "CLN_2ndline", -1);
mir_snwprintf(szTitle, TranslateT("Contact list display and ignore options for %s"), contact ? contact->szText : Clist_GetContactDisplayName(hContact));
SetWindowText(hWnd, szTitle);
Window_SetSkinIcon_IcoLib(hWnd, SKINICON_OTHER_MIRANDA);
pCaps = CallProtoService(contact ? contact->proto : GetContactProto(hContact), PS_GETCAPS, PFLAGNUM_1, 0);
Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSONLINE, pCaps & PF1_INVISLIST ? TRUE : FALSE);
Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSOFFLINE, pCaps & PF1_VISLIST ? TRUE : FALSE);
CheckDlgButton(hWnd, IDC_IGN_PRIORITY, db_get_b(hContact, "CList", "Priority", 0) ? BST_CHECKED : BST_UNCHECKED);
Utils::enableDlgControl(hWnd, IDC_IGN_PRIORITY, TRUE);
Utils::enableDlgControl(hWnd, IDC_AVATARDISPMODE, TRUE);
Utils::enableDlgControl(hWnd, IDC_SECONDLINEMODE, TRUE);
if (dwFlags & ECF_FORCEAVATAR)
SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 1, 0);
else if (dwFlags & ECF_HIDEAVATAR)
SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 2, 0);
else
SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 0, 0);
if (dwFlags & ECF_FORCEOVERLAY)
CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_CHECKED);
else if (dwFlags & ECF_HIDEOVERLAY)
CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_UNCHECKED);
else
CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_INDETERMINATE);
if (dwFlags & ECF_FORCELOCALTIME)
CheckDlgButton(hWnd, IDC_SHOWLOCALTIME1, BST_CHECKED);
else if (dwFlags & ECF_HIDELOCALTIME)
CheckDlgButton(hWnd, IDC_SHOWLOCALTIME1, BST_UNCHECKED);
else
CheckDlgButton(hWnd, IDC_SHOWLOCALTIME1, BST_INDETERMINATE);
if (bSecondLine == 0xff)
SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, 0, 0);
else
SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, (WPARAM)(bSecondLine + 1), 0);
}
}
WindowList_Add(hWindowListIGN, hWnd, hContact);
ShowWindow(hWnd, SW_SHOWNORMAL);
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_IGN_PRIORITY:
SendMessage(pcli->hwndContactTree, CLM_TOGGLEPRIORITYCONTACT, hContact, 0);
return 0;
case IDC_IGN_ALL:
SendMessage(hWnd, WM_USER + 100, hContact, (LPARAM)0xffffffff);
return 0;
case IDC_IGN_NONE:
SendMessage(hWnd, WM_USER + 100, hContact, 0);
return 0;
case IDC_IGN_ALWAYSONLINE:
if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSONLINE))
CheckDlgButton(hWnd, IDC_IGN_ALWAYSOFFLINE, BST_UNCHECKED);
break;
case IDC_IGN_ALWAYSOFFLINE:
if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSOFFLINE))
CheckDlgButton(hWnd, IDC_IGN_ALWAYSONLINE, BST_UNCHECKED);
break;
case IDC_HIDECONTACT:
db_set_b(hContact, "CList", "Hidden", (BYTE)(IsDlgButtonChecked(hWnd, IDC_HIDECONTACT) ? 1 : 0));
break;
case IDC_IGN_ADDPERMANENTLY:
Contact_Add(hContact, hWnd);
Utils::enableDlgControl(hWnd, IDC_IGN_ADDPERMANENTLY, db_get_b(hContact, "CList", "NotOnList", 0));
break;
case IDC_DSP_LOADDEFAULT:
SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 0, 0);
SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, 0, 0);
CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_INDETERMINATE);
CheckDlgButton(hWnd, IDC_LOCALTIME, BST_INDETERMINATE);
break;
case IDOK:
{
DWORD newMask = 0;
ClcContact *contact = nullptr;
SendMessage(hWnd, WM_USER + 110, 0, (LPARAM)&newMask);
db_set_dw(hContact, "Ignore", "Mask1", newMask);
SendMessage(hWnd, WM_USER + 130, 0, 0);
if (cfg::clcdat) {
LRESULT iSel = SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_GETCURSEL, 0, 0);
DWORD dwFlags = db_get_dw(hContact, "CList", "CLN_Flags", 0), dwXMask = 0;
LRESULT checked = 0;
Clist_FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr);
if (iSel != CB_ERR) {
dwFlags &= ~(ECF_FORCEAVATAR | ECF_HIDEAVATAR);
if (iSel == 1)
dwFlags |= ECF_FORCEAVATAR;
else if (iSel == 2)
dwFlags |= ECF_HIDEAVATAR;
if (contact)
LoadAvatarForContact(contact);
}
dwFlags &= ~(ECF_FORCEOVERLAY | ECF_HIDEOVERLAY | ECF_FORCELOCALTIME | ECF_HIDELOCALTIME);
checked = IsDlgButtonChecked(hWnd, IDC_OVERLAYICON);
if (checked == BST_CHECKED)
dwFlags |= ECF_FORCEOVERLAY;
else if (checked == BST_UNCHECKED)
dwFlags |= ECF_HIDEOVERLAY;
checked = IsDlgButtonChecked(hWnd, IDC_SHOWLOCALTIME1);
if (checked == BST_CHECKED)
dwFlags |= ECF_FORCELOCALTIME;
else if (checked == BST_UNCHECKED)
dwFlags |= ECF_HIDELOCALTIME;
db_set_dw(hContact, "CList", "CLN_Flags", dwFlags);
if ((iSel = SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_GETCURSEL, 0, 0)) != CB_ERR) {
if (iSel == 0) {
db_unset(hContact, "CList", "CLN_2ndline");
if (contact)
contact->bSecondLine = cfg::dat.dualRowMode;
}
else {
db_set_b(hContact, "CList", "CLN_2ndline", (BYTE)(iSel - 1));
if (contact)
contact->bSecondLine = (BYTE)(iSel - 1);
}
}
db_set_dw(hContact, "CList", "CLN_xmask", dwXMask);
if (contact) {
if (contact->pExtra)
contact->pExtra->dwDFlags = dwFlags;
}
else {
TExtraCache *p = cfg::getCache(hContact, nullptr);
if (p)
p->dwDFlags = dwFlags;
}
db_set_b(hContact, "CList", "Priority", (BYTE)(IsDlgButtonChecked(hWnd, IDC_IGN_PRIORITY) ? 1 : 0));
Clist_Broadcast(CLM_AUTOREBUILD, 0, 0);
}
}
case IDCANCEL:
DestroyWindow(hWnd);
break;
}
break;
case WM_USER + 100: // fill dialog (wParam = hContact, lParam = mask)
CheckDlgButton(hWnd, IDC_IGN_MSGEVENTS, lParam & (1 << (IGNOREEVENT_MESSAGE - 1)) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_IGN_FILEEVENTS, lParam & (1 << (IGNOREEVENT_FILE - 1)) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_IGN_URLEVENTS, lParam & (1 << (IGNOREEVENT_URL - 1)) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_IGN_AUTH, lParam & (1 << (IGNOREEVENT_AUTHORIZATION - 1)) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_IGN_ADD, lParam & (1 << (IGNOREEVENT_YOUWEREADDED - 1)) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_IGN_ONLINE, lParam & (1 << (IGNOREEVENT_USERONLINE - 1)) ? BST_CHECKED : BST_UNCHECKED);
return 0;
case WM_USER + 110: // retrieve value
{
DWORD *dwNewMask = (DWORD *)lParam, dwMask = 0;
dwMask = (IsDlgButtonChecked(hWnd, IDC_IGN_MSGEVENTS) ? (1 << (IGNOREEVENT_MESSAGE - 1)) : 0) |
(IsDlgButtonChecked(hWnd, IDC_IGN_FILEEVENTS) ? (1 << (IGNOREEVENT_FILE - 1)) : 0) |
(IsDlgButtonChecked(hWnd, IDC_IGN_URLEVENTS) ? (1 << (IGNOREEVENT_URL - 1)) : 0) |
(IsDlgButtonChecked(hWnd, IDC_IGN_AUTH) ? (1 << (IGNOREEVENT_AUTHORIZATION - 1)) : 0) |
(IsDlgButtonChecked(hWnd, IDC_IGN_ADD) ? (1 << (IGNOREEVENT_YOUWEREADDED - 1)) : 0) |
(IsDlgButtonChecked(hWnd, IDC_IGN_ONLINE) ? (1 << (IGNOREEVENT_USERONLINE - 1)) : 0);
if (dwNewMask)
*dwNewMask = dwMask;
}
return 0;
case WM_USER + 120: // set visibility status
{
ClcContact *contact = nullptr;
if (Clist_FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr)) {
if (contact) {
WORD wApparentMode = db_get_w(contact->hContact, contact->proto, "ApparentMode", 0);
CheckDlgButton(hWnd, IDC_IGN_ALWAYSOFFLINE, wApparentMode == ID_STATUS_OFFLINE ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_IGN_ALWAYSONLINE, wApparentMode == ID_STATUS_ONLINE ? BST_CHECKED : BST_UNCHECKED);
}
}
}
return 0;
case WM_USER + 130: // update apparent mode
{
ClcContact *contact = nullptr;
if (Clist_FindItem(pcli->hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr)) {
if (contact) {
WORD wApparentMode = 0;
if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSONLINE))
wApparentMode = ID_STATUS_ONLINE;
else if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSOFFLINE))
wApparentMode = ID_STATUS_OFFLINE;
ProtoChainSend(hContact, PSS_SETAPPARENTMODE, (WPARAM)wApparentMode, 0);
SendMessage(hWnd, WM_USER + 120, 0, 0);
}
}
}
return 0;
case WM_DESTROY:
SetWindowLongPtr(hWnd, GWLP_USERDATA, 0);
WindowList_Remove(hWindowListIGN, hWnd);
break;
}
return FALSE;
}
/*
* service function: Open ignore settings dialog for the contact handle in wParam
* (clist_nicer+ specific service)
*
* Servicename = CList/SetContactIgnore
*
* ensure that dialog is only opened once (the dialog proc saves the window handle of an open dialog
* of this type to the contacts database record).
*
* if dialog is already open, focus it.
*/
static INT_PTR SetContactIgnore(WPARAM wParam, LPARAM)
{
HWND hWnd = nullptr;
if (hWindowListIGN == nullptr)
hWindowListIGN = WindowList_Create();
hWnd = WindowList_Find(hWindowListIGN, wParam);
if (wParam) {
if (hWnd == nullptr)
CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_QUICKIGNORE), nullptr, IgnoreDialogProc, (LPARAM)wParam);
else if (IsWindow(hWnd))
SetFocus(hWnd);
}
return 0;
}
int InitCustomMenus(void)
{
InitIconLibMenuIcons();
CreateServiceFunction("CloseAction", CloseAction);
CreateServiceFunction("CList/SetContactIgnore", SetContactIgnore);
CMenuItem mi;
SET_UID(mi, 0xe3b08c6f, 0x8a01, 0x4c94, 0xb3, 0xf5, 0x9d, 0x38, 0x6, 0x63, 0x7a, 0xa9);
mi.position = 200000;
mi.pszService = "CList/SetContactIgnore";
mi.hIcolibItem = iconItem[0].hIcolib;
mi.name.a = LPGEN("&Contact list settings...");
Menu_AddContactMenuItem(&mi);
return 0;
}
void UninitCustomMenus(void)
{
WindowList_Destroy(hWindowListIGN);
}
|