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
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
|
/*
Copyright (c) 2013-15 Miranda NG project (http://miranda-ng.org)
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 version 2
of the License.
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, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
//////////////////////////////////////////////////////////////////////////////
// Account manager dialog
INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CVkProto *ppro = (CVkProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
ppro = (CVkProto*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon, 1));
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon));
{
ptrT ptszLogin(ppro->getTStringA("Login"));
if (ptszLogin != NULL)
SetDlgItemText(hwndDlg, IDC_LOGIN, ptszLogin);
ptrT ptszPassw(ppro->GetUserStoredPassword());
if (ptszPassw != NULL)
SetDlgItemText(hwndDlg, IDC_PASSWORD, ptszPassw);
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_URL:
Utils_OpenUrl("http://vk.com");
break;
case IDC_LOGIN:
case IDC_PASSWORD:
if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
}
break;
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
TCHAR str[1025];
bool bNeedClearToken = false;
GetDlgItemText(hwndDlg, IDC_LOGIN, str, _countof(str));
CMString tszLogin(ptrT(ppro->getTStringA("Login")));
if (tszLogin != str) {
bNeedClearToken = true;
ppro->setTString("Login", str);
}
GetDlgItemText(hwndDlg, IDC_PASSWORD, str, _countof(str));
CMString tszPassw(ptrT(ppro->GetUserStoredPassword()));
T2Utf szRawPasswd(str);
if (szRawPasswd != NULL && tszPassw != str) {
bNeedClearToken = true;
ppro->setString("Password", szRawPasswd);
}
if (bNeedClearToken)
ppro->ClearAccessToken();
}
break;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
break;
case WM_DESTROY:
IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
break;
}
return FALSE;
}
INT_PTR CVkProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam)
{
return (INT_PTR)CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, VKAccountProc, (LPARAM)this);
}
//////////////////////////////////////////////////////////////////////////////
// Options
INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CVkProto *ppro = (CVkProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
ppro = (CVkProto*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon, 1));
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon));
{
ptrT ptszLogin(ppro->getTStringA("Login"));
if (ptszLogin != NULL)
SetDlgItemText(hwndDlg, IDC_LOGIN, ptszLogin);
ptrT ptszPassw(ppro->GetUserStoredPassword());
if (ptszPassw != NULL)
SetDlgItemText(hwndDlg, IDC_PASSWORD, ptszPassw);
SetDlgItemText(hwndDlg, IDC_GROUPNAME, ppro->getGroup());
}
CheckDlgButton(hwndDlg, IDC_DELIVERY, ppro->m_bServerDelivery ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_USE_LOCAL_TIME, ppro->m_bUseLocalTime ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_AUTOCLEAN, ppro->getBool("AutoClean") ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ONREAD, (ppro->m_iMarkMessageReadOn == markOnRead) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ONRECEIVE, (ppro->m_iMarkMessageReadOn == markOnReceive) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ONREPLY, (ppro->m_iMarkMessageReadOn == markOnReply) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ONTYPING, (ppro->m_iMarkMessageReadOn == markOnTyping) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SYNC_OFF, (ppro->m_iSyncHistoryMetod == syncOff) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SYNC_AUTO, (ppro->m_iSyncHistoryMetod == syncAuto) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SYNC_LAST1DAY, (ppro->m_iSyncHistoryMetod == sync1Days) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SYNC_LAST3DAY, (ppro->m_iSyncHistoryMetod == sync3Days) ? BST_CHECKED : BST_UNCHECKED);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_URL:
Utils_OpenUrl("http://vk.com");
break;
case IDC_LOGIN:
case IDC_PASSWORD:
case IDC_GROUPNAME:
if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_DELIVERY:
case IDC_USE_LOCAL_TIME:
case IDC_AUTOCLEAN:
case IDC_ONREAD:
case IDC_ONRECEIVE:
case IDC_ONREPLY:
case IDC_ONTYPING:
case IDC_SYNC_OFF:
case IDC_SYNC_AUTO:
case IDC_SYNC_LAST1DAY:
case IDC_SYNC_LAST3DAY:
if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
break;
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
TCHAR str[1025];
bool bNeedClearToken = false;
GetDlgItemText(hwndDlg, IDC_LOGIN, str, _countof(str));
CMString tszLogin(ptrT(ppro->getTStringA("Login")));
if (tszLogin != str) {
bNeedClearToken = true;
ppro->setTString("Login", str);
}
GetDlgItemText(hwndDlg, IDC_PASSWORD, str, _countof(str));
CMString tszPassw(ptrT(ppro->GetUserStoredPassword()));
T2Utf szRawPasswd(str);
if (szRawPasswd != NULL && tszPassw != str) {
bNeedClearToken = true;
ppro->setString("Password", szRawPasswd);
}
GetDlgItemText(hwndDlg, IDC_GROUPNAME, str, _countof(str));
if (mir_tstrcmp(ppro->getGroup(), str)) {
ppro->setGroup(str);
ppro->setTString("ProtoGroup", str);
}
ppro->m_bServerDelivery = IsDlgButtonChecked(hwndDlg, IDC_DELIVERY) == BST_CHECKED;
ppro->setByte("ServerDelivery", ppro->m_bServerDelivery);
ppro->setByte("AutoClean", IsDlgButtonChecked(hwndDlg, IDC_AUTOCLEAN) == BST_CHECKED);
ppro->m_bUseLocalTime = IsDlgButtonChecked(hwndDlg, IDC_USE_LOCAL_TIME) == BST_CHECKED;
ppro->setByte("UseLocalTime", ppro->m_bUseLocalTime);
if (IsDlgButtonChecked(hwndDlg, IDC_ONREAD) == BST_CHECKED)
ppro->m_iMarkMessageReadOn = markOnRead;
if (IsDlgButtonChecked(hwndDlg, IDC_ONRECEIVE) == BST_CHECKED)
ppro->m_iMarkMessageReadOn = markOnReceive;
if (IsDlgButtonChecked(hwndDlg, IDC_ONREPLY) == BST_CHECKED)
ppro->m_iMarkMessageReadOn = markOnReply;
if (IsDlgButtonChecked(hwndDlg, IDC_ONTYPING) == BST_CHECKED)
ppro->m_iMarkMessageReadOn = markOnTyping;
ppro->setByte("MarkMessageReadOn", ppro->m_iMarkMessageReadOn);
if (IsDlgButtonChecked(hwndDlg, IDC_SYNC_OFF) == BST_CHECKED)
ppro->m_iSyncHistoryMetod = syncOff;
if (IsDlgButtonChecked(hwndDlg, IDC_SYNC_AUTO) == BST_CHECKED)
ppro->m_iSyncHistoryMetod = syncAuto;
if (IsDlgButtonChecked(hwndDlg, IDC_SYNC_LAST1DAY) == BST_CHECKED)
ppro->m_iSyncHistoryMetod = sync1Days;
if (IsDlgButtonChecked(hwndDlg, IDC_SYNC_LAST3DAY) == BST_CHECKED)
ppro->m_iSyncHistoryMetod = sync3Days;
ppro->setByte("SyncHistoryMetod", ppro->m_iSyncHistoryMetod);
if (bNeedClearToken)
ppro->ClearAccessToken();
}
break;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
break;
case WM_DESTROY:
IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
break;
}
return FALSE;
}
INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CVkProto *ppro = (CVkProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
ppro = (CVkProto*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon, 1));
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon));
CheckDlgButton(hwndDlg, IDC_HIDECHATS, ppro->m_bHideChats ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SYNC_MSG_STATUS, ppro->m_bSyncReadMessageStatusFromServer ? BST_CHECKED : BST_UNCHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_MESASUREAD), IsDlgButtonChecked(hwndDlg, IDC_SYNC_MSG_STATUS) == BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_MESASUREAD, ppro->m_bMesAsUnread ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_FORCE_ONLINE_ON_ACT, ppro->m_bUserForceOnlineOnActivity ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_USENOSTDURLENCODE, ppro->m_bUseNonStandardUrlEncode ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_USENOSTDPOPUPS, ppro->m_bUseNonStandardNotifications ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_REPORT_ABUSE, ppro->m_bReportAbuse ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CLEAR_SERVER_HISTORY, ppro->m_bClearServerHistory ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_REMOVE_FROM_FRENDLIST, ppro->m_bRemoveFromFrendlist ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_REMOVE_FROM_CLIST, ppro->m_bRemoveFromClist ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SEND_MUSIC_NONE, (ppro->m_iMusicSendMetod == sendNone) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SEND_MUSIC_BROADCAST, (ppro->m_iMusicSendMetod == sendBroadcastOnly) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SEND_MUSIC_STATUS, (ppro->m_iMusicSendMetod == sendStatusOnly) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SEND_MUSIC_BROADCAST_AND_STATUS, (ppro->m_iMusicSendMetod == sendBroadcastAndStatus) ? BST_CHECKED : BST_UNCHECKED);
SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_INVIS, UDM_SETRANGE, 0, MAKELONG(60, 0));
SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_INVIS, UDM_SETPOS, 0, ppro->m_iInvisibleInterval);
SetDlgItemText(hwndDlg, IDC_RET_CHAT_MES, ppro->m_ReturnChatMessage);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_ED_INT_INVIS:
if ((HWND)lParam == GetFocus() && (HIWORD(wParam) == EN_CHANGE))
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_SYNC_MSG_STATUS:
if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus()) {
EnableWindow(GetDlgItem(hwndDlg, IDC_MESASUREAD), IsDlgButtonChecked(hwndDlg, IDC_SYNC_MSG_STATUS) == BST_UNCHECKED);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
break;
case IDC_RET_CHAT_MES:
if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_HIDECHATS:
case IDC_MESASUREAD:
case IDC_FORCE_ONLINE_ON_ACT:
case IDC_USENOSTDURLENCODE:
case IDC_USENOSTDPOPUPS:
case IDC_REPORT_ABUSE:
case IDC_CLEAR_SERVER_HISTORY:
case IDC_REMOVE_FROM_FRENDLIST:
case IDC_REMOVE_FROM_CLIST:
case IDC_SEND_MUSIC_NONE:
case IDC_SEND_MUSIC_BROADCAST:
case IDC_SEND_MUSIC_STATUS:
case IDC_SEND_MUSIC_BROADCAST_AND_STATUS:
if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
break;
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
ppro->m_bHideChats = IsDlgButtonChecked(hwndDlg, IDC_HIDECHATS) == BST_CHECKED;
ppro->setByte("HideChats", ppro->m_bHideChats);
ppro->m_bSyncReadMessageStatusFromServer = IsDlgButtonChecked(hwndDlg, IDC_SYNC_MSG_STATUS) == BST_CHECKED;
ppro->setByte("SyncReadMessageStatusFromServer", ppro->m_bSyncReadMessageStatusFromServer);
ppro->m_bMesAsUnread = IsDlgButtonChecked(hwndDlg, IDC_MESASUREAD) == BST_CHECKED;
ppro->setByte("MesAsUnread", ppro->m_bMesAsUnread);
ppro->m_bUserForceOnlineOnActivity = IsDlgButtonChecked(hwndDlg, IDC_FORCE_ONLINE_ON_ACT) == BST_CHECKED;
ppro->setByte("UserForceOnlineOnActivity", ppro->m_bUserForceOnlineOnActivity);
ppro->m_bUseNonStandardUrlEncode = IsDlgButtonChecked(hwndDlg, IDC_USENOSTDURLENCODE) == BST_CHECKED;
ppro->setByte("UseNonStandardUrlEncode", ppro->m_bUseNonStandardUrlEncode);
ppro->m_bUseNonStandardNotifications = IsDlgButtonChecked(hwndDlg, IDC_USENOSTDPOPUPS) == BST_CHECKED;
ppro->setByte("UseNonStandardNotifications", ppro->m_bUseNonStandardNotifications);
ppro->m_bReportAbuse = IsDlgButtonChecked(hwndDlg, IDC_REPORT_ABUSE) == BST_CHECKED;
ppro->setByte("ReportAbuseOnBanUser", ppro->m_bReportAbuse);
ppro->m_bClearServerHistory = IsDlgButtonChecked(hwndDlg, IDC_CLEAR_SERVER_HISTORY) == BST_CHECKED;
ppro->setByte("ClearServerHistoryOnBanUser", ppro->m_bClearServerHistory);
ppro->m_bRemoveFromFrendlist = IsDlgButtonChecked(hwndDlg, IDC_REMOVE_FROM_FRENDLIST) == BST_CHECKED;
ppro->setByte("RemoveFromFrendlistOnBanUser", ppro->m_bRemoveFromFrendlist);
ppro->m_bRemoveFromClist = IsDlgButtonChecked(hwndDlg, IDC_REMOVE_FROM_CLIST) == BST_CHECKED;
ppro->setByte("RemoveFromClistOnBanUser", ppro->m_bRemoveFromClist);
if (IsDlgButtonChecked(hwndDlg, IDC_SEND_MUSIC_NONE) == BST_CHECKED)
ppro->m_iMusicSendMetod = sendNone;
if (IsDlgButtonChecked(hwndDlg, IDC_SEND_MUSIC_BROADCAST) == BST_CHECKED)
ppro->m_iMusicSendMetod = sendBroadcastOnly;
if (IsDlgButtonChecked(hwndDlg, IDC_SEND_MUSIC_STATUS) == BST_CHECKED)
ppro->m_iMusicSendMetod = sendStatusOnly;
if (IsDlgButtonChecked(hwndDlg, IDC_SEND_MUSIC_BROADCAST_AND_STATUS) == BST_CHECKED)
ppro->m_iMusicSendMetod = sendBroadcastAndStatus;
ppro->setByte("MusicSendMetod", ppro->m_iMusicSendMetod);
CMStringA szListeningTo(ppro->m_szModuleName);
szListeningTo += "Enabled";
db_set_b(NULL, "ListeningTo", szListeningTo, ppro->m_iMusicSendMetod == 0 ? 0 : 1);
TCHAR buffer[5] = { 0 };
GetDlgItemText(hwndDlg, IDC_ED_INT_INVIS, buffer, _countof(buffer));
ppro->setDword("InvisibleInterval", ppro->m_iInvisibleInterval = _ttoi(buffer));
TCHAR str[4096];
GetDlgItemText(hwndDlg, IDC_RET_CHAT_MES, str, _countof(str));
CMString tszReturnChatMessage(str);
if (tszReturnChatMessage != ppro->m_ReturnChatMessage) {
tszReturnChatMessage.Trim();
ppro->m_ReturnChatMessage = mir_tstrdup(tszReturnChatMessage.IsEmpty() ? TranslateT("I'm back"): tszReturnChatMessage);
ppro->setTString("ReturnChatMessage", ppro->m_ReturnChatMessage);
}
}
break;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
break;
case WM_DESTROY:
IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
break;
}
return FALSE;
}
INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CVkProto *ppro = (CVkProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
ppro = (CVkProto*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon, 1));
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon));
CheckDlgButton(hwndDlg, IDC_NEWS_ENBL, ppro->m_bNewsEnabled ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NOTIF_ENBL, ppro->m_bNotificationsEnabled ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NOTIF_MARK_VIEWED, ppro->m_bNotificationsMarkAsViewed ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SPEC_CONT_ENBL, ppro->m_bSpecialContactAlwaysEnabled ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NEWSAUTOCLEAR, ppro->m_bNewsAutoClearHistory ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_F_POSTS, ppro->m_bNewsFilterPosts ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_F_PHOTOS, ppro->m_bNewsFilterPhotos ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_F_TAGS, ppro->m_bNewsFilterTags ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_F_WALLPHOTOS, ppro->m_bNewsFilterWallPhotos ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_S_FRIENDS, ppro->m_bNewsSourceFriends ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_S_GROUPS, ppro->m_bNewsSourceGroups ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_S_PAGES, ppro->m_bNewsSourcePages ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_S_FOLLOWING, ppro->m_bNewsSourceFollowing ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_S_BANNED, ppro->m_bNewsSourceIncludeBanned ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_S_NOREPOSTES, ppro->m_bNewsSourceNoReposts ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_N_COMMENTS, ppro->m_bNotificationFilterComments ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_N_LIKES, ppro->m_bNotificationFilterLikes ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_N_REPOSTS, ppro->m_bNotificationFilterReposts ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_N_MENTIONS, ppro->m_bNotificationFilterMentions ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_N_INVITES, ppro->m_bNotificationFilterInvites ? BST_CHECKED : BST_UNCHECKED);
SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_NEWS, UDM_SETRANGE, 0, MAKELONG(60*24, 1));
SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_NEWS, UDM_SETPOS, 0, ppro->m_iNewsInterval);
SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_NOTIF, UDM_SETRANGE, 0, MAKELONG(60 * 24, 1));
SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_NOTIF, UDM_SETPOS, 0, ppro->m_iNotificationsInterval);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_ED_INT_NEWS:
case IDC_ED_INT_NOTIF:
if ((HWND)lParam == GetFocus() && (HIWORD(wParam) == EN_CHANGE))
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_NEWS_ENBL:
case IDC_NOTIF_ENBL:
case IDC_NOTIF_MARK_VIEWED:
case IDC_SPEC_CONT_ENBL:
case IDC_NEWSAUTOCLEAR:
case IDC_F_POSTS:
case IDC_F_PHOTOS:
case IDC_F_TAGS:
case IDC_F_WALLPHOTOS:
case IDC_S_FRIENDS:
case IDC_S_GROUPS:
case IDC_S_PAGES:
case IDC_S_FOLLOWING:
case IDC_S_BANNED:
case IDC_S_NOREPOSTES:
case IDC_N_COMMENTS:
case IDC_N_LIKES:
case IDC_N_REPOSTS:
case IDC_N_MENTIONS:
case IDC_N_INVITES:
if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
break;
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
ppro->m_bNewsEnabled = IsDlgButtonChecked(hwndDlg, IDC_NEWS_ENBL) == BST_CHECKED;
ppro->setByte("NewsEnabled", ppro->m_bNewsEnabled);
ppro->m_bNotificationsEnabled = IsDlgButtonChecked(hwndDlg, IDC_NOTIF_ENBL) == BST_CHECKED;
ppro->setByte("NotificationsEnabled", ppro->m_bNotificationsEnabled);
ppro->m_bNotificationsMarkAsViewed = IsDlgButtonChecked(hwndDlg, IDC_NOTIF_MARK_VIEWED) == BST_CHECKED;
ppro->setByte("NotificationsMarkAsViewed", ppro->m_bNotificationsMarkAsViewed);
ppro->m_bSpecialContactAlwaysEnabled = IsDlgButtonChecked(hwndDlg, IDC_SPEC_CONT_ENBL) == BST_CHECKED;
ppro->setByte("SpecialContactAlwaysEnabled", ppro->m_bSpecialContactAlwaysEnabled);
ppro->m_bNewsAutoClearHistory = IsDlgButtonChecked(hwndDlg, IDC_NEWSAUTOCLEAR) == BST_CHECKED;
ppro->setByte("NewsAutoClearHistory", ppro->m_bNewsAutoClearHistory);
ppro->m_bNewsFilterPosts = IsDlgButtonChecked(hwndDlg, IDC_F_POSTS) == BST_CHECKED;
ppro->setByte("NewsFilterPosts", ppro->m_bNewsFilterPosts);
ppro->m_bNewsFilterPhotos = IsDlgButtonChecked(hwndDlg, IDC_F_PHOTOS) == BST_CHECKED;
ppro->setByte("NewsFilterPhotos", ppro->m_bNewsFilterPhotos);
ppro->m_bNewsFilterTags = IsDlgButtonChecked(hwndDlg, IDC_F_TAGS) == BST_CHECKED;
ppro->setByte("NewsFilterTags", ppro->m_bNewsFilterTags);
ppro->m_bNewsFilterWallPhotos = IsDlgButtonChecked(hwndDlg, IDC_F_WALLPHOTOS) == BST_CHECKED;
ppro->setByte("NewsFilterWallPhotos", ppro->m_bNewsFilterWallPhotos);
ppro->m_bNewsSourceFriends = IsDlgButtonChecked(hwndDlg, IDC_S_FRIENDS) == BST_CHECKED;
ppro->setByte("NewsSourceFriends", ppro->m_bNewsSourceFriends);
ppro->m_bNewsSourceGroups = IsDlgButtonChecked(hwndDlg, IDC_S_GROUPS) == BST_CHECKED;
ppro->setByte("NewsSourceGroups", ppro->m_bNewsSourceGroups);
ppro->m_bNewsSourcePages = IsDlgButtonChecked(hwndDlg, IDC_S_PAGES) == BST_CHECKED;
ppro->setByte("NewsSourcePages", ppro->m_bNewsSourcePages);
ppro->m_bNewsSourceFollowing = IsDlgButtonChecked(hwndDlg, IDC_S_FOLLOWING) == BST_CHECKED;
ppro->setByte("NewsSourceFollowing", ppro->m_bNewsSourceFollowing);
ppro->m_bNewsSourceIncludeBanned = IsDlgButtonChecked(hwndDlg, IDC_S_BANNED) == BST_CHECKED;
ppro->setByte("NewsSourceIncludeBanned", ppro->m_bNewsSourceIncludeBanned);
ppro->m_bNewsSourceNoReposts = IsDlgButtonChecked(hwndDlg, IDC_S_NOREPOSTES) == BST_CHECKED;
ppro->setByte("NewsSourceNoReposts", ppro->m_bNewsSourceNoReposts);
ppro->m_bNotificationFilterComments = IsDlgButtonChecked(hwndDlg, IDC_N_COMMENTS) == BST_CHECKED;
ppro->setByte("NotificationFilterComments", ppro->m_bNotificationFilterComments);
ppro->m_bNotificationFilterLikes = IsDlgButtonChecked(hwndDlg, IDC_N_LIKES) == BST_CHECKED;
ppro->setByte("NotificationFilterLikes", ppro->m_bNotificationFilterLikes);
ppro->m_bNotificationFilterReposts = IsDlgButtonChecked(hwndDlg, IDC_N_REPOSTS) == BST_CHECKED;
ppro->setByte("NotificationFilterReposts", ppro->m_bNotificationFilterReposts);
ppro->m_bNotificationFilterMentions = IsDlgButtonChecked(hwndDlg, IDC_N_MENTIONS) == BST_CHECKED;
ppro->setByte("NotificationFilterMentions", ppro->m_bNotificationFilterMentions);
ppro->m_bNotificationFilterInvites = IsDlgButtonChecked(hwndDlg, IDC_N_INVITES) == BST_CHECKED;
ppro->setByte("NotificationFilterInvites", ppro->m_bNotificationFilterInvites);
TCHAR buffer[5] = { 0 };
GetDlgItemText(hwndDlg, IDC_ED_INT_NEWS, buffer, _countof(buffer));
ppro->setDword("NewsInterval", ppro->m_iNewsInterval = _ttoi(buffer));
GetDlgItemText(hwndDlg, IDC_ED_INT_NOTIF, buffer, _countof(buffer));
ppro->setDword("NotificationsInterval", ppro->m_iNotificationsInterval = _ttoi(buffer));
}
break;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
break;
case WM_DESTROY:
IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
break;
}
return FALSE;
}
INT_PTR CALLBACK CVkProto::OptionsViewProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CVkProto *ppro = (CVkProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
ppro = (CVkProto*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon, 1));
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon));
CheckDlgButton(hwndDlg, IDC_IMG_OFF, (ppro->m_iIMGBBCSupport == imgNo) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_IMG_FULLSIZE, (ppro->m_iIMGBBCSupport == imgFullSize) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_IMG_130, (ppro->m_iIMGBBCSupport == imgPreview130) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_IMG_604, (ppro->m_iIMGBBCSupport == imgPreview604) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NEWSBBC_OFF, (ppro->m_iBBCForNews == bbcNo) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NEWSBBC_BASIC, (ppro->m_iBBCForNews == bbcBasic) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NEWSBBC_ADV, (ppro->m_iBBCForNews == bbcAdvanced) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_BBC_ATT_NEWS, ppro->m_bUseBBCOnAttacmentsAsNews ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ATTBBC_OFF, (ppro->m_iBBCForAttachments == bbcNo) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ATTBBC_BASIC, (ppro->m_iBBCForAttachments == bbcBasic) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ATTBBC_ADV, (ppro->m_iBBCForAttachments == bbcAdvanced) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_STICKERS_AS_SMYLES, ppro->m_bStikersAsSmyles ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SHOTEN_LINKS_FOR_AUDIO, ppro->m_bShortenLinksForAudio ? BST_CHECKED : BST_UNCHECKED);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_IMG_OFF:
case IDC_IMG_FULLSIZE:
case IDC_IMG_130:
case IDC_IMG_604:
case IDC_NEWSBBC_OFF:
case IDC_NEWSBBC_BASIC:
case IDC_NEWSBBC_ADV:
case IDC_BBC_ATT_NEWS:
case IDC_ATTBBC_OFF:
case IDC_ATTBBC_BASIC:
case IDC_ATTBBC_ADV:
case IDC_STICKERS_AS_SMYLES:
case IDC_SHOTEN_LINKS_FOR_AUDIO:
if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
break;
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
if (IsDlgButtonChecked(hwndDlg, IDC_IMG_OFF) == BST_CHECKED)
ppro->m_iIMGBBCSupport = imgNo;
if (IsDlgButtonChecked(hwndDlg, IDC_IMG_FULLSIZE) == BST_CHECKED)
ppro->m_iIMGBBCSupport = imgFullSize;
if (IsDlgButtonChecked(hwndDlg, IDC_IMG_130) == BST_CHECKED)
ppro->m_iIMGBBCSupport = imgPreview130;
if (IsDlgButtonChecked(hwndDlg, IDC_IMG_604) == BST_CHECKED)
ppro->m_iIMGBBCSupport = imgPreview604;
ppro->setByte("IMGBBCSupport", ppro->m_iIMGBBCSupport);
if (IsDlgButtonChecked(hwndDlg, IDC_NEWSBBC_OFF) == BST_CHECKED)
ppro->m_iBBCForNews = bbcNo;
if (IsDlgButtonChecked(hwndDlg, IDC_NEWSBBC_BASIC) == BST_CHECKED)
ppro->m_iBBCForNews = bbcBasic;
if (IsDlgButtonChecked(hwndDlg, IDC_NEWSBBC_ADV) == BST_CHECKED)
ppro->m_iBBCForNews = bbcAdvanced;
ppro->setByte("BBCForNews", ppro->m_iBBCForNews);
ppro->m_bUseBBCOnAttacmentsAsNews = IsDlgButtonChecked(hwndDlg, IDC_BBC_ATT_NEWS) == BST_CHECKED;
ppro->setByte("UseBBCOnAttacmentsAsNews", ppro->m_bStikersAsSmyles);
if (IsDlgButtonChecked(hwndDlg, IDC_ATTBBC_OFF) == BST_CHECKED)
ppro->m_iBBCForAttachments = bbcNo;
if (IsDlgButtonChecked(hwndDlg, IDC_ATTBBC_BASIC) == BST_CHECKED)
ppro->m_iBBCForAttachments = bbcBasic;
if (IsDlgButtonChecked(hwndDlg, IDC_ATTBBC_ADV) == BST_CHECKED)
ppro->m_iBBCForAttachments = bbcAdvanced;
ppro->setByte("BBCForAttachments", ppro->m_iBBCForAttachments);
ppro->m_bStikersAsSmyles = IsDlgButtonChecked(hwndDlg, IDC_STICKERS_AS_SMYLES) == BST_CHECKED;
ppro->setByte("StikersAsSmyles", ppro->m_bStikersAsSmyles);
ppro->m_bShortenLinksForAudio = IsDlgButtonChecked(hwndDlg, IDC_SHOTEN_LINKS_FOR_AUDIO) == BST_CHECKED;
ppro->setByte("ShortenLinksForAudio", ppro->m_bShortenLinksForAudio);
}
break;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
break;
case WM_DESTROY:
IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
break;
}
return FALSE;
}
int CVkProto::OnOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = hInst;
odp.ptszTitle = m_tszUserName;
odp.dwInitParam = LPARAM(this);
odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE;
odp.ptszGroup = LPGENT("Network");
odp.ptszTab = LPGENT("Account");
odp.position = 1;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MAIN);
odp.pfnDlgProc = &CVkProto::OptionsProc;
Options_AddPage(wParam, &odp);
odp.ptszTab = LPGENT("Advanced");
odp.position = 2;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_ADV);
odp.pfnDlgProc = &CVkProto::OptionsAdvProc;
Options_AddPage(wParam, &odp);
odp.ptszTab = LPGENT("News and notifications");
odp.position = 3;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FEEDS);
odp.pfnDlgProc = &CVkProto::OptionsFeedsProc;
Options_AddPage(wParam, &odp);
odp.ptszTab = LPGENT("View");
odp.position = 4;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_VIEW);
odp.pfnDlgProc = &CVkProto::OptionsViewProc;
Options_AddPage(wParam, &odp);
return 0;
}
|