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
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
|
/////////////////////////////////////////////////////////////////////////////////////////
// Miranda NG: the free IM client for Microsoft* Windows*
//
// Copyright (C) 2012-24 Miranda NG team,
// Copyright (c) 2000-09 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.
//
// part of tabSRMM messaging plugin for Miranda.
//
// (C) 2005-2010 by silvercircle _at_ gmail _dot_ com and contributors
//
// these are generic message handlers which are used by the message dialog window procedure.
// calling them directly instead of using SendMessage() is faster.
// also contains various callback functions for custom buttons
#include "stdafx.h"
/////////////////////////////////////////////////////////////////////////////////////////
// Save message log for given session as RTF document
/*
void CMsgDialog::DM_SaveLogAsRTF() const
{
if (m_hwndIEView != nullptr) {
IEVIEWEVENT event = { sizeof(event) };
event.hwnd = m_hwndIEView;
event.hContact = m_hContact;
event.iType = IEE_SAVE_DOCUMENT;
CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&event);
}
else {
wchar_t szFilter[MAX_PATH], szFilename[MAX_PATH];
mir_snwprintf(szFilter, L"%s%c*.rtf%c%c", TranslateT("Rich Edit file"), 0, 0, 0);
mir_snwprintf(szFilename, L"%s.rtf", m_cache->getNick());
Utils::sanitizeFilename(szFilename);
wchar_t szInitialDir[MAX_PATH + 2];
mir_snwprintf(szInitialDir, L"%s%s\\", M.getDataPath(), L"\\Saved message logs");
CreateDirectoryTreeW(szInitialDir);
OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = m_hwnd;
ofn.lpstrFile = szFilename;
ofn.lpstrFilter = szFilter;
ofn.lpstrInitialDir = szInitialDir;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY;
ofn.lpstrDefExt = L"rtf";
if (GetSaveFileName(&ofn)) {
EDITSTREAM stream = { 0 };
stream.dwCookie = (DWORD_PTR)szFilename;
stream.dwError = 0;
stream.pfnCallback = Utils::StreamOut;
m_rtf.SendMsg(EM_STREAMOUT, SF_RTF | SF_USECODEPAGE, (LPARAM)&stream);
}
}
}
*/
/////////////////////////////////////////////////////////////////////////////////////////
// checks if the balloon tooltip can be dismissed (usually called by WM_MOUSEMOVE events)
void CMsgDialog::DM_DismissTip(const POINT& pt)
{
if (!IsWindowVisible(m_hwndTip))
return;
RECT rc;
GetWindowRect(m_hwndTip, &rc);
if (PtInRect(&rc, pt))
return;
if (abs(pt.x - m_ptTipActivation.x) > 5 || abs(pt.y - m_ptTipActivation.y) > 5) {
SendMessage(m_hwndTip, TTM_TRACKACTIVATE, FALSE, 0);
m_ptTipActivation.x = m_ptTipActivation.y = 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// initialize the balloon tooltip for message window notifications
void CMsgDialog::DM_InitTip()
{
m_hwndTip = CreateWindowEx(0, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_NOPREFIX | TTS_BALLOON, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, m_hwnd, nullptr, g_plugin.getInst(), (LPVOID)nullptr);
memset(&ti, 0, sizeof(ti));
ti.cbSize = sizeof(ti);
ti.lpszText = TranslateT("No status message");
ti.hinst = g_plugin.getInst();
ti.hwnd = m_hwnd;
ti.uFlags = TTF_TRACK | TTF_IDISHWND | TTF_TRANSPARENT;
ti.uId = (UINT_PTR)m_hwnd;
SendMessage(m_hwndTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
SetWindowPos(m_hwndTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
/////////////////////////////////////////////////////////////////////////////////////////
// checks generic hotkeys valid for both IM and MUC sessions
//
// returns 1 for handled hotkeys, 0 otherwise.
bool CMsgDialog::DM_GenericHotkeysCheck(MSG *message)
{
LRESULT mim_hotkey_check = Hotkey_Check(message, TABSRMM_HK_SECTION_GENERIC);
switch (mim_hotkey_check) {
case TABSRMM_HK_PASTEANDSEND:
HandlePasteAndSend();
return true;
case TABSRMM_HK_HISTORY:
m_btnHistory.Click();
return true;
case TABSRMM_HK_CONTAINEROPTIONS:
m_pContainer->OptionsDialog();
return true;
case TABSRMM_HK_TOGGLEINFOPANEL:
if (!isChat()) {
m_pPanel.setActive(!m_pPanel.isActive());
m_pPanel.showHide();
}
return true;
case TABSRMM_HK_TOGGLETOOLBAR:
SendMessage(m_hwnd, WM_COMMAND, IDC_TOGGLETOOLBAR, 0);
return true;
case TABSRMM_HK_CLEARLOG:
tabClearLog();
return true;
case TABSRMM_HK_TOGGLESIDEBAR:
if (m_pContainer->m_pSideBar->isActive())
SendMessage(m_hwnd, WM_COMMAND, IDC_TOGGLESIDEBAR, 0);
return true;
case TABSRMM_HK_CLOSE_OTHER:
CloseOtherTabs(m_pContainer->m_hwndTabs, *this);
return true;
}
return false;
}
LRESULT CMsgDialog::DM_MsgWindowCmdHandler(UINT cmd, WPARAM wParam, LPARAM lParam)
{
RECT rc;
int iSelection;
HMENU submenu;
switch (cmd) {
case IDC_SRMM_BOLD:
case IDC_SRMM_ITALICS:
case IDC_SRMM_UNDERLINE:
case IDC_SRMM_STRIKEOUT:
if (m_bSendFormat) { // dont use formatting if disabled
auto *pCtrl = (CCtrlButton*)FindControl(cmd);
if (!pCtrl->Enabled())
break;
CHARFORMAT2 cf = {}, cfOld = {};
cfOld.cbSize = cf.cbSize = sizeof(cf);
cfOld.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT;
m_message.SendMsg(EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cfOld);
int mask, effect;
switch (cmd) {
case IDC_SRMM_BOLD: mask = CFM_BOLD, effect = CFE_BOLD; break;
case IDC_SRMM_ITALICS: mask = CFM_ITALIC, effect = CFE_ITALIC; break;
case IDC_SRMM_UNDERLINE: mask = CFM_UNDERLINE, effect = CFE_UNDERLINE; break;
default: mask = CFM_STRIKEOUT, effect = CFM_STRIKEOUT; break;
}
BOOL isOn = (cfOld.dwEffects & effect) && (cfOld.dwMask & mask);
pCtrl->Push(!isOn);
cf.dwEffects = isOn ? 0 : effect;
cf.dwMask = mask;
m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
return TRUE;
case IDCANCEL:
ShowWindow(m_pContainer->m_hwnd, SW_MINIMIZE);
return FALSE;
case IDC_CLOSE:
PostMessage(m_hwnd, WM_CLOSE, 1, 0);
break;
case IDC_NAME:
if (GetKeyState(VK_SHIFT) & 0x8000) // copy UIN
Utils_ClipboardCopy(MClipUnicode(m_cache->getUIN()));
else
CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)(m_cache->getActiveContact()), 0);
break;
case IDC_TIME:
submenu = GetSubMenu(PluginConfig.g_hMenuContext, 2);
MsgWindowUpdateMenu(submenu, MENU_LOGMENU);
GetWindowRect(GetDlgItem(m_hwnd, IDC_TIME), &rc);
iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, nullptr);
return MsgWindowMenuHandler(iSelection, MENU_LOGMENU);
case IDC_PROTOMENU:
submenu = GetSubMenu(PluginConfig.g_hMenuContext, 4);
GetWindowRect(GetDlgItem(m_hwnd, IDC_PROTOCOL), &rc);
CheckMenuItem(submenu, ID_MODE_GLOBAL, !m_bSplitterOverride ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(submenu, ID_MODE_PRIVATE, m_bSplitterOverride ? MF_CHECKED : MF_UNCHECKED);
iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, nullptr);
switch (iSelection) {
case ID_MODE_GLOBAL:
m_bSplitterOverride = false;
db_set_b(m_hContact, SRMSGMOD_T, "splitoverride", 0);
LoadSplitter();
AdjustBottomAvatarDisplay();
DM_RecalcPictureSize();
Resize();
break;
case ID_MODE_PRIVATE:
m_bSplitterOverride = true;
db_set_b(m_hContact, SRMSGMOD_T, "splitoverride", 1);
LoadSplitter();
AdjustBottomAvatarDisplay();
DM_RecalcPictureSize();
Resize();
break;
}
break;
case IDC_TOGGLETOOLBAR:
if (lParam == 1)
m_pContainer->cfg.flags.m_bNoMenuBar = !m_pContainer->cfg.flags.m_bNoMenuBar;
else
m_pContainer->cfg.flags.m_bHideToolbar = !m_pContainer->cfg.flags.m_bHideToolbar;
m_pContainer->ApplySetting(true);
break;
case IDC_SENDMENU:
submenu = GetSubMenu(PluginConfig.g_hMenuContext, 3);
GetWindowRect(GetDlgItem(m_hwnd, IDOK), &rc);
CheckMenuItem(submenu, ID_SENDMENU_SENDTOMULTIPLEUSERS, (m_sendMode & SMODE_MULTIPLE) ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(submenu, ID_SENDMENU_SENDDEFAULT, m_sendMode == 0 ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(submenu, ID_SENDMENU_SENDTOCONTAINER, (m_sendMode & SMODE_CONTAINER) ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(submenu, ID_SENDMENU_SENDLATER, (m_sendMode & SMODE_SENDLATER) ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(submenu, ID_SENDMENU_SENDWITHOUTTIMEOUTS, (m_sendMode & SMODE_NOACK) ? MF_CHECKED : MF_UNCHECKED);
if (lParam)
iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, nullptr);
else
iSelection = HIWORD(wParam);
switch (iSelection) {
case ID_SENDMENU_SENDTOMULTIPLEUSERS:
m_sendMode ^= SMODE_MULTIPLE;
if (m_sendMode & SMODE_MULTIPLE)
DM_CreateClist();
else if (IsWindow(GetDlgItem(m_hwnd, IDC_CLIST)))
DestroyWindow(GetDlgItem(m_hwnd, IDC_CLIST));
break;
case ID_SENDMENU_SENDDEFAULT:
m_sendMode = 0;
break;
case ID_SENDMENU_SENDTOCONTAINER:
m_sendMode ^= SMODE_CONTAINER;
RedrawWindow(m_hwnd, nullptr, nullptr, RDW_ERASENOW | RDW_UPDATENOW);
break;
case ID_SENDMENU_SENDLATER:
if (SendLater::Avail)
m_sendMode ^= SMODE_SENDLATER;
else
CWarning::show(CWarning::WARN_NO_SENDLATER, MB_OK | MB_ICONINFORMATION);
break;
case ID_SENDMENU_SENDWITHOUTTIMEOUTS:
m_sendMode ^= SMODE_NOACK;
if (m_sendMode & SMODE_NOACK)
db_set_b(m_hContact, SRMSGMOD_T, "no_ack", 1);
else
db_unset(m_hContact, SRMSGMOD_T, "no_ack");
break;
}
db_set_b(m_hContact, SRMSGMOD_T, "no_ack", (uint8_t)(m_sendMode & SMODE_NOACK ? 1 : 0));
SetWindowPos(m_message.GetHwnd(), nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE);
if (m_sendMode & SMODE_MULTIPLE || m_sendMode & SMODE_CONTAINER) {
SetWindowPos(m_message.GetHwnd(), nullptr, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_FRAMECHANGED | SWP_NOZORDER |
SWP_NOMOVE | SWP_NOSIZE | SWP_NOCOPYBITS);
RedrawWindow(m_hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN);
}
else {
if (IsWindow(GetDlgItem(m_hwnd, IDC_CLIST)))
DestroyWindow(GetDlgItem(m_hwnd, IDC_CLIST));
SetWindowPos(m_message.GetHwnd(), nullptr, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_FRAMECHANGED | SWP_NOZORDER |
SWP_NOMOVE | SWP_NOSIZE | SWP_NOCOPYBITS);
RedrawWindow(m_hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN);
}
m_pContainer->QueryClientArea(rc);
Resize();
DM_ScrollToBottom(1, 1);
Utils::showDlgControl(m_hwnd, IDC_MULTISPLITTER, (m_sendMode & SMODE_MULTIPLE) ? SW_SHOW : SW_HIDE);
Utils::showDlgControl(m_hwnd, IDC_CLIST, (m_sendMode & SMODE_MULTIPLE) ? SW_SHOW : SW_HIDE);
break;
case IDC_TOGGLESIDEBAR:
SendMessage(m_pContainer->m_hwnd, WM_COMMAND, IDC_TOGGLESIDEBAR, 0);
break;
case IDM_CLEAR:
tabClearLog();
break;
case IDC_PROTOCOL:
submenu = Menu_BuildContactMenu(m_hContact);
if (lParam == 0)
GetWindowRect(GetDlgItem(m_hwnd, IDC_PROTOCOL), &rc);
else
GetWindowRect((HWND)lParam, &rc);
iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, m_hwnd, nullptr);
if (iSelection)
Clist_MenuProcessCommand(LOWORD(iSelection), MPCF_CONTACTMENU, m_hContact);
DestroyMenu(submenu);
break;
// error control
case IDC_CANCELSEND:
DM_ErrorDetected(MSGERROR_CANCEL, 0);
break;
case IDC_RETRY:
DM_ErrorDetected(MSGERROR_RETRY, 0);
break;
case IDC_MSGSENDLATER:
DM_ErrorDetected(MSGERROR_SENDLATER, 0);
break;
case IDC_SELFTYPING:
if (AllowTyping()) {
int iCurrentTypingMode = g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_plugin.bTypingNew);
if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON && iCurrentTypingMode) {
DM_NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
m_nTypeMode = PROTOTYPE_SELFTYPING_OFF;
}
g_plugin.setByte(m_hContact, SRMSGSET_TYPING, (uint8_t)!iCurrentTypingMode);
}
break;
default:
return 0;
}
return 1;
}
/////////////////////////////////////////////////////////////////////////////////////////
// initialize rich edit control (log and edit control) for both MUC and
// standard IM session windows.
void CMsgDialog::DM_InitRichEdit()
{
char *szStreamOut = nullptr;
if (!isChat() && GetWindowTextLength(m_message.GetHwnd()) > 0)
szStreamOut = m_message.GetRichTextRtf();
SetWindowText(m_message.GetHwnd(), L"");
m_message.SendMsg(EM_SETBKGNDCOLOR, 0, m_pContainer->m_theme.inputbg);
LOGFONTW &lf = m_pContainer->m_theme.logFonts[MSGFONTID_MESSAGEAREA];
CHARFORMAT2 cf2 = {};
cf2.cbSize = sizeof(cf2);
cf2.dwMask = CFM_COLOR | CFM_BACKCOLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC;
cf2.crBackColor = m_pContainer->m_theme.inputbg;
cf2.crTextColor = m_pContainer->m_theme.fontColors[MSGFONTID_MESSAGEAREA];
cf2.bCharSet = lf.lfCharSet;
wcsncpy_s(cf2.szFaceName, lf.lfFaceName, _TRUNCATE);
cf2.dwEffects = ((lf.lfWeight >= FW_BOLD) ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0) | (lf.lfUnderline ? CFE_UNDERLINE : 0) | (lf.lfStrikeOut ? CFE_STRIKEOUT : 0);
cf2.wWeight = (uint16_t)lf.lfWeight;
cf2.bPitchAndFamily = lf.lfPitchAndFamily;
cf2.yHeight = abs(lf.lfHeight) * 15;
m_message.SendMsg(EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf2);
m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2); /* WINE: fix send colour text. */
m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf2); /* WINE: fix send colour text. */
// setup the rich edit control(s)
// LOG is always set to RTL, because this is needed for proper bidirectional operation later.
// The real text direction is then enforced by the streaming code which adds appropiate paragraph
// and textflow formatting commands to the
PARAFORMAT2 pf2 = {};
pf2.cbSize = sizeof(pf2);
pf2.wEffects = PFE_RTLPARA;
pf2.dwMask = PFM_RTLPARA;
if (FindRTLLocale())
m_message.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
if (!(m_dwFlags & MWF_LOG_RTL)) {
pf2.wEffects = 0;
m_message.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
}
m_message.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_message.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD);
if (m_dwFlags & MWF_LOG_RTL)
SetWindowLongPtr(m_message.GetHwnd(), GWL_EXSTYLE, GetWindowLongPtr(m_message.GetHwnd(), GWL_EXSTYLE) | WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR);
else
SetWindowLongPtr(m_message.GetHwnd(), GWL_EXSTYLE, GetWindowLongPtr(m_message.GetHwnd(), GWL_EXSTYLE) & ~(WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR));
if (szStreamOut != nullptr) {
SETTEXTEX stx = { ST_DEFAULT, CP_UTF8 };
m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)szStreamOut);
mir_free(szStreamOut);
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// set the states of defined database action buttons(only if button is a toggle)
void CMsgDialog::DM_SetDBButtonStates()
{
ButtonItem *buttonItem = m_pContainer->m_buttonItems;
MCONTACT hFinalContact = 0;
HWND hwndContainer = m_pContainer->m_hwnd;
while (buttonItem) {
HWND hWnd = GetDlgItem(hwndContainer, buttonItem->uId);
if (buttonItem->pfnCallback)
buttonItem->pfnCallback(buttonItem, m_hwnd, this, hWnd);
if (!(buttonItem->dwFlags & BUTTON_ISTOGGLE && buttonItem->dwFlags & BUTTON_ISDBACTION)) {
buttonItem = buttonItem->nextItem;
continue;
}
BOOL result = FALSE;
char *szModule = buttonItem->szModule;
char *szSetting = buttonItem->szSetting;
if (buttonItem->dwFlags & BUTTON_DBACTIONONCONTACT || buttonItem->dwFlags & BUTTON_ISCONTACTDBACTION) {
if (buttonItem->dwFlags & BUTTON_ISCONTACTDBACTION)
szModule = Proto_GetBaseAccountName(m_hContact);
hFinalContact = m_hContact;
}
else hFinalContact = 0;
switch (buttonItem->type) {
case DBVT_BYTE:
result = (db_get_b(hFinalContact, szModule, szSetting, 0) == buttonItem->bValuePush[0]);
break;
case DBVT_WORD:
result = (db_get_w(hFinalContact, szModule, szSetting, 0) == *((uint16_t *)&buttonItem->bValuePush));
break;
case DBVT_DWORD:
result = (db_get_dw(hFinalContact, szModule, szSetting, 0) == *((uint32_t *)&buttonItem->bValuePush));
break;
case DBVT_ASCIIZ:
ptrA szValue(db_get_sa(hFinalContact, szModule, szSetting));
if (szValue)
result = !mir_strcmp((char*)buttonItem->bValuePush, szValue);
break;
}
SendMessage(hWnd, BM_SETCHECK, result, 0);
buttonItem = buttonItem->nextItem;
}
}
void CMsgDialog::DM_ScrollToBottom(WPARAM wParam, LPARAM lParam)
{
if (m_bScrollingDisabled)
return;
if (IsIconic(m_pContainer->m_hwnd))
m_bDeferredScroll = true;
if (m_iLogMode == WANT_BUILTIN_LOG)
LOG()->ScrollToBottom(wParam != 0, lParam != 0);
else
m_pLog->ScrollToBottom();
}
void CMsgDialog::DM_RecalcPictureSize()
{
HBITMAP hbm = ((m_pPanel.isActive()) && m_pContainer->cfg.avatarMode != 3) ? m_hOwnPic : (m_ace ? m_ace->hbmPic : PluginConfig.g_hbmUnknown);
if (hbm) {
BITMAP bminfo;
GetObject(hbm, sizeof(bminfo), &bminfo);
if (CalcDynamicAvatarSize(&bminfo))
Resize();
}
else m_pic.cy = m_pic.cx = 60;
}
void CMsgDialog::DM_UpdateLastMessage() const
{
if (m_pContainer->m_hwndStatus == nullptr || m_pContainer->m_hwndActive != m_hwnd)
return;
HICON hIcon = 0;
CMStringW szBuf;
if (m_bShowTyping) {
hIcon = PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING];
szBuf.Format(TranslateT("%s is typing a message..."), m_cache->getNick());
}
else if (m_bStatusSet) {
hIcon = m_szStatusIcon;
szBuf = m_szStatusText;
}
else {
if (m_pContainer->cfg.flags.m_bUinStatusBar)
szBuf.Format(L"UID: %s", m_cache->getUIN());
else if (m_lastMessage) {
wchar_t date[64], time[64];
TimeZone_PrintTimeStamp(nullptr, m_lastMessage, L"d", date, _countof(date), 0);
if (m_pContainer->cfg.flags.m_bUinStatusBar && mir_wstrlen(date) > 6)
date[mir_wstrlen(date) - 5] = 0;
TimeZone_PrintTimeStamp(nullptr, m_lastMessage, L"t", time, _countof(time), 0);
szBuf.Format(TranslateT("Last received: %s at %s"), date, time);
}
}
SendMessage(m_pContainer->m_hwndStatus, SB_SETICON, 0, (LPARAM)hIcon);
SendMessage(m_pContainer->m_hwndStatus, SB_SETTEXT, 0, (LPARAM)szBuf.c_str());
}
/////////////////////////////////////////////////////////////////////////////////////////
// create embedded contact list control
HWND CMsgDialog::DM_CreateClist()
{
if (!SendLater::Avail) {
CWarning::show(CWarning::WARN_NO_SENDLATER, MB_OK | MB_ICONINFORMATION);
m_sendMode &= ~SMODE_MULTIPLE;
return nullptr;
}
HWND hwndClist = CreateWindowExA(0, "CListControl", "", WS_TABSTOP | WS_VISIBLE | WS_CHILD | 0x248, 184, 0, 30, 30, m_hwnd, (HMENU)IDC_CLIST, g_plugin.getInst(), nullptr);
SendMessage(hwndClist, WM_TIMER, 14, 0);
HANDLE hItem = (HANDLE)SendMessage(hwndClist, CLM_FINDCONTACT, m_hContact, 0);
SetWindowLongPtr(hwndClist, GWL_EXSTYLE, GetWindowLongPtr(hwndClist, GWL_EXSTYLE) & ~CLS_EX_TRACKSELECT);
SetWindowLongPtr(hwndClist, GWL_EXSTYLE, GetWindowLongPtr(hwndClist, GWL_EXSTYLE) | (CLS_EX_NOSMOOTHSCROLLING | CLS_EX_NOTRANSLUCENTSEL));
if (!g_plugin.bAllowOfflineMultisend)
SetWindowLongPtr(hwndClist, GWL_STYLE, GetWindowLongPtr(hwndClist, GWL_STYLE) | CLS_HIDEOFFLINE);
if (hItem)
SendMessage(hwndClist, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
SendMessage(hwndClist, CLM_SETHIDEEMPTYGROUPS, Clist::HideEmptyGroups, 0);
SendMessage(hwndClist, CLM_SETUSEGROUPS, Clist::UseGroups, 0);
SendMessage(hwndClist, CLM_FIRST + 106, 0, 1);
SendMessage(hwndClist, CLM_AUTOREBUILD, 0, 0);
if (hwndClist)
RedrawWindow(hwndClist, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW);
return hwndClist;
}
LRESULT CMsgDialog::DM_MouseWheelHandler(WPARAM wParam, LPARAM lParam)
{
POINT pt;
GetCursorPos(&pt);
RECT rc;
GetWindowRect(m_message.GetHwnd(), &rc);
if (PtInRect(&rc, pt))
return 1;
if (isChat()) { // scroll nick list by just hovering it
RECT rcNicklist;
GetWindowRect(m_nickList.GetHwnd(), &rcNicklist);
if (PtInRect(&rcNicklist, pt)) {
m_nickList.SendMsg(WM_MOUSEWHEEL, wParam, lParam);
return 0;
}
}
GetWindowRect(m_pLog->GetHwnd(), &rc);
if (PtInRect(&rc, pt)) {
short wDirection = (short)HIWORD(wParam);
if (LOWORD(wParam) & MK_SHIFT || M.GetByte("fastscroll", 0)) {
if (wDirection < 0)
SendMessage(m_pLog->GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_PAGEDOWN, 0), 0);
else if (wDirection > 0)
SendMessage(m_pLog->GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_PAGEUP, 0), 0);
}
else SendMessage(m_pLog->GetHwnd(), WM_MOUSEWHEEL, wParam, lParam);
return 0;
}
if (GetTabItemFromMouse(m_pContainer->m_hwndTabs, &pt) != -1) {
SendMessage(m_pContainer->m_hwndTabs, WM_MOUSEWHEEL, wParam, -1);
return 0;
}
return 1;
}
void CMsgDialog::DM_FreeTheme()
{
if (m_hTheme) {
CloseThemeData(m_hTheme);
m_hTheme = nullptr;
}
if (m_hThemeIP) {
CloseThemeData(m_hThemeIP);
m_hThemeIP = nullptr;
}
if (m_hThemeToolbar) {
CloseThemeData(m_hThemeToolbar);
m_hThemeToolbar = nullptr;
}
}
void CMsgDialog::DM_ThemeChanged()
{
CSkinItem *item_log = &SkinItems[ID_EXTBKHISTORY];
CSkinItem *item_msg = &SkinItems[ID_EXTBKINPUTAREA];
m_hTheme = OpenThemeData(m_hwnd, L"EDIT");
if (m_hTheme != nullptr || (CSkin::m_skinEnabled && !item_log->IGNORED)) {
if (m_iLogMode == WANT_BUILTIN_LOG)
LOG()->DisableStaticEdge();
if (isChat())
SetWindowLongPtr(m_nickList.GetHwnd(), GWL_EXSTYLE, GetWindowLongPtr(m_nickList.GetHwnd(), GWL_EXSTYLE) & ~(WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
}
if (m_hTheme != nullptr || (CSkin::m_skinEnabled && !item_msg->IGNORED))
SetWindowLongPtr(m_message.GetHwnd(), GWL_EXSTYLE, GetWindowLongPtr(m_message.GetHwnd(), GWL_EXSTYLE) & ~WS_EX_STATICEDGE);
m_hThemeIP = M.isAero() ? OpenThemeData(m_hwnd, L"ButtonStyle") : nullptr;
m_hThemeToolbar = (M.isAero() || (!CSkin::m_skinEnabled && M.isVSThemed())) ? OpenThemeData(m_hwnd, L"REBAR") : nullptr;
}
/////////////////////////////////////////////////////////////////////////////////////////
// send out message typing notifications (MTN) when the
// user is typing/editing text in the message input area.
void CMsgDialog::DM_NotifyTyping(int mode)
{
const char *szProto = m_cache->getActiveProto();
MCONTACT hContact = m_cache->getActiveContact();
// editing user notes or preparing a message for queued delivery -> don't send MTN
if (m_sendMode & SMODE_SENDLATER)
return;
// allow supression of sending out TN for the contact (NOTE: for metacontacts, do NOT use the subcontact handle)
if (!g_plugin.getByte(hContact, SRMSGSET_TYPING, g_plugin.bTypingNew))
return;
if (szProto == nullptr) // should not, but who knows...
return;
// check status and capabilities of the protocol
uint32_t typeCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0);
if (!(typeCaps & PF4_SUPPORTTYPING))
return;
if (isChat()) {
m_nTypeMode = mode;
Chat_DoEventHook(m_si, GC_USER_TYPNOTIFY, 0, 0, m_nTypeMode);
}
else {
uint32_t protoStatus = Proto_GetStatus(szProto);
if (protoStatus < ID_STATUS_ONLINE)
return;
// don't send to contacts which are not permanently added to the contact list,
// unless the option to ignore added status is set.
if (!Contact::OnList(m_hContact) && !g_plugin.bTypingUnknown)
return;
// End user check
m_nTypeMode = mode;
CallService(MS_PROTO_SELFISTYPING, hContact, m_nTypeMode);
}
}
void CMsgDialog::OnOptionsApplied()
{
CSuper::OnOptionsApplied();
m_szMicroLf[0] = 0;
if (!m_pContainer->m_theme.isPrivate) {
m_pContainer->LoadThemeDefaults();
m_dwFlags = m_pContainer->m_theme.dwFlags;
}
DM_InitRichEdit();
if (isChat()) {
m_btnOk.SendMsg(BUTTONSETASNORMAL, TRUE, 0);
m_nickList.SetItemHeight(0, g_Settings.iNickListFontHeight);
InvalidateRect(m_nickList.GetHwnd(), nullptr, TRUE);
UpdateChatOptions();
}
LoadLocalFlags();
m_hTimeZone = TimeZone_CreateByContact(m_hContact, nullptr, TZF_KNOWNONLY);
m_bShowUIElements = (m_pContainer->cfg.flags.m_bHideToolbar) == 0;
m_bSplitterOverride = M.GetByte(m_hContact, "splitoverride", 0) != 0;
m_pPanel.getVisibility();
// small inner margins (padding) for the text areas
m_message.SendMsg(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3));
SetDialogToType();
SendMessage(m_hwnd, DM_CONFIGURETOOLBAR, 0, 0);
if (m_hwnd == m_pContainer->m_hwndActive)
SendMessage(m_pContainer->m_hwnd, WM_SIZE, 0, 0);
InvalidateRect(m_message.GetHwnd(), nullptr, FALSE);
ScheduleRedrawLog();
ShowWindow(m_hwndPanelPicParent, SW_SHOW);
EnableWindow(m_hwndPanelPicParent, TRUE);
UpdateWindowIcon();
}
void CMsgDialog::DM_Typing(bool fForceOff)
{
HWND hwndContainer = m_pContainer->m_hwnd;
HWND hwndStatus = m_pContainer->m_hwndStatus;
if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON && GetTickCount() - m_nLastTyping > TIMEOUT_TYPEOFF)
DM_NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
if (m_bShowTyping == 1) {
if (m_nTypeSecs > 0) {
m_nTypeSecs--;
if (GetForegroundWindow() == hwndContainer)
UpdateWindowIcon();
}
else {
if (!fForceOff) {
m_bShowTyping = 2;
m_nTypeSecs = 86400;
if (!isChat())
mir_snwprintf(m_wszStatusBar, TranslateT("%s has entered text."), m_cache->getNick());
if (hwndStatus && m_pContainer->m_hwndActive == m_hwnd)
SendMessage(hwndStatus, SB_SETTEXT, 0, (LPARAM)m_wszStatusBar);
}
UpdateWindowIcon();
HandleIconFeedback(this, (HICON)-1);
if (!m_pContainer->cfg.flags.m_bNoFlash && PluginConfig.m_FlashOnMTN)
m_pContainer->ReflashContainer();
}
}
else if (m_bShowTyping == 2) {
if (m_nTypeSecs > 0)
m_nTypeSecs--;
else {
m_wszStatusBar[0] = 0;
m_bShowTyping = 0;
}
tabUpdateStatusBar();
}
else if (m_nTypeSecs > 0) {
mir_snwprintf(m_wszStatusBar, TranslateT("%s is typing a message"),
(m_pUserTyping) ? m_pUserTyping->pszNick : m_cache->getNick());
m_nTypeSecs--;
if (hwndStatus && m_pContainer->m_hwndActive == m_hwnd) {
SendMessage(hwndStatus, SB_SETTEXT, 0, (LPARAM)m_wszStatusBar);
SendMessage(hwndStatus, SB_SETICON, 0, (LPARAM)PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]);
}
if (IsIconic(hwndContainer) || !IsActive())
if (!m_pContainer->cfg.flags.m_bNoFlash && PluginConfig.m_FlashOnMTN)
m_pContainer->ReflashContainer();
if (m_pContainer->m_hwndActive != m_hwnd) {
if (m_bCanFlashTab)
m_iFlashIcon = PluginConfig.g_IconTypingEvent;
HandleIconFeedback(this, PluginConfig.g_IconTypingEvent);
}
else { // active tab may show icon if status bar is disabled
if (!hwndStatus) {
if (TabCtrl_GetItemCount(m_hwndParent) > 1 || !m_pContainer->cfg.flags.m_bHideTabs)
HandleIconFeedback(this, PluginConfig.g_IconTypingEvent);
}
}
if ((GetForegroundWindow() != hwndContainer) || (m_pContainer->m_hwndStatus == nullptr) || (m_pContainer->m_hwndActive != m_hwnd))
m_pContainer->SetIcon(this, PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]);
m_bShowTyping = 1;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// sync splitter position for all open sessions.
// This cares about private / per container / MUC <> IM splitter syncing and everything.
// called from IM and MUC windows via DM_SPLITTERGLOBALEVENT
int CMsgDialog::DM_SplitterGlobalEvent(WPARAM wParam, LPARAM lParam)
{
CMsgDialog *srcDat = PluginConfig.lastSPlitterPos.pSrcDat;
TContainerData *srcCnt = PluginConfig.lastSPlitterPos.pSrcContainer;
bool fCntGlobal = (!m_pContainer->cfg.fPrivate ? true : false);
if (m_bIsAutosizingInput)
return 0;
RECT rcWin;
GetWindowRect(m_hwnd, &rcWin);
LONG newPos;
if (wParam == 0 && lParam == 0) {
if (m_bSplitterOverride && this != srcDat)
return 0;
if (srcDat->isChat() == isChat())
newPos = PluginConfig.lastSPlitterPos.pos;
else if (!srcDat->isChat() && isChat())
newPos = PluginConfig.lastSPlitterPos.pos + PluginConfig.lastSPlitterPos.off_im;
else if (srcDat->isChat() && !isChat())
newPos = PluginConfig.lastSPlitterPos.pos + PluginConfig.lastSPlitterPos.off_im;
else
newPos = 0;
if (this == srcDat) {
m_pContainer->cfg.iSplitterY = m_iSplitterY;
if (fCntGlobal)
SaveSplitter();
return 0;
}
if (!fCntGlobal && m_pContainer != srcCnt)
return 0;
if (srcCnt->cfg.fPrivate && m_pContainer != srcCnt)
return 0;
// for inactive sessions, delay the splitter repositioning until they become
// active (faster, avoid redraw/resize problems for minimized windows)
if (IsIconic(m_pContainer->m_hwnd) || m_pContainer->m_hwndActive != m_hwnd) {
m_bDelayedSplitter = true;
m_wParam = newPos;
m_lParam = PluginConfig.lastSPlitterPos.lParam;
return 0;
}
}
else newPos = wParam;
LoadSplitter();
AdjustBottomAvatarDisplay();
DM_RecalcPictureSize();
Resize();
DM_ScrollToBottom(1, 1);
if (this != srcDat)
UpdateToolbarBG();
return 0;
}
void CMsgDialog::DM_AddDivider()
{
if (!m_bDividerSet && g_plugin.bUseDividers)
if (GetWindowTextLength(m_pLog->GetHwnd()) > 0)
m_bDividerSet = m_bDividerWanted = true;
}
/////////////////////////////////////////////////////////////////////////////////////////
void CMsgDialog::DM_HandleAutoSizeRequest(REQRESIZE* rr)
{
if (rr == nullptr || GetForegroundWindow() != m_pContainer->m_hwnd)
return;
if (!m_bIsAutosizingInput || m_iInputAreaHeight == -1 || m_bReadOnly)
return;
LONG heightLimit = M.GetDword("autoSplitMinLimit", 0);
LONG iNewHeight = rr->rc.bottom - rr->rc.top;
if (CSkin::m_skinEnabled && !SkinItems[ID_EXTBKINPUTAREA].IGNORED)
iNewHeight += (SkinItems[ID_EXTBKINPUTAREA].MARGIN_TOP + SkinItems[ID_EXTBKINPUTAREA].MARGIN_BOTTOM - 2);
if (heightLimit && iNewHeight < heightLimit)
iNewHeight = heightLimit;
if (iNewHeight == m_iInputAreaHeight)
return;
RECT rc;
GetClientRect(m_hwnd, &rc);
LONG cy = rc.bottom - rc.top;
LONG panelHeight = (m_pPanel.isActive() ? m_pPanel.getHeight() : 0);
if (iNewHeight > (cy - panelHeight) / 2)
iNewHeight = (cy - panelHeight) / 2;
m_dynaSplitter = iNewHeight - DPISCALEY_S(2);
if (m_pContainer->cfg.flags.m_bBottomToolbar)
m_dynaSplitter += DPISCALEY_S(22);
m_iSplitterY = m_dynaSplitter + DPISCALEY_S(34);
DM_RecalcPictureSize();
m_iInputAreaHeight = iNewHeight;
UpdateToolbarBG();
DM_ScrollToBottom(1, 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
// status icon stuff (by sje, used for indicating encryption status in the status bar
// this is now part of the message window api
static int OnSrmmIconChanged(WPARAM hContact, LPARAM)
{
if (hContact == 0)
Srmm_Broadcast(DM_STATUSICONCHANGE, 0, 0);
else {
HWND hwnd = Srmm_FindWindow(hContact);
if (hwnd)
PostMessage(hwnd, DM_STATUSICONCHANGE, 0, 0);
}
return 0;
}
void CMsgDialog::DrawStatusIcons(HDC hDC, const RECT &rc, int gap)
{
int x = rc.left;
int y = (rc.top + rc.bottom - PluginConfig.m_smcxicon) >> 1;
SetBkMode(hDC, TRANSPARENT);
int nIcon = 0;
while (StatusIconData *sid = Srmm_GetNthIcon(m_hContact, nIcon++)) {
bool bDrawOverlay = false;
if (!mir_strcmp(sid->szModule, MSG_ICON_MODULE)) {
if (sid->dwId == MSG_ICON_SOUND) {
DrawIconEx(hDC, x, y, PluginConfig.g_buttonBarIcons[ICON_DEFAULT_SOUNDS],
PluginConfig.m_smcxicon, PluginConfig.m_smcyicon, 0, nullptr, DI_NORMAL);
bDrawOverlay = m_pContainer->cfg.flags.m_bNoSound;
}
else if (sid->dwId == MSG_ICON_UTN) {
if (AllowTyping()) {
DrawIconEx(hDC, x, y, PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING], PluginConfig.m_smcxicon, PluginConfig.m_smcyicon, 0, nullptr, DI_NORMAL);
bDrawOverlay = !g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_plugin.bTypingNew);
}
else CSkin::DrawDimmedIcon(hDC, x, y, PluginConfig.m_smcxicon, PluginConfig.m_smcyicon, PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING], 50);
}
}
else {
bDrawOverlay = (sid->flags & MBF_DISABLED) != 0;
DrawIconEx(hDC, x, y, sid->hIcon, 16, 16, 0, nullptr, DI_NORMAL);
}
if (bDrawOverlay)
DrawIconEx(hDC, x, y, PluginConfig.g_iconOverlayDisabled, PluginConfig.m_smcxicon, PluginConfig.m_smcyicon, 0, nullptr, DI_NORMAL);
x += PluginConfig.m_smcxicon + gap;
}
}
void CMsgDialog::CheckStatusIconClick(POINT pt, const RECT &rc, int gap, int code)
{
if (code == NM_CLICK || code == NM_RCLICK) {
POINT ptScreen;
GetCursorPos(&ptScreen);
if (!PtInRect(&rcLastStatusBarClick, ptScreen))
return;
}
UINT iconNum = (pt.x - (rc.left + 0)) / (PluginConfig.m_smcxicon + gap);
StatusIconData *sid = Srmm_GetNthIcon(m_hContact, iconNum);
if (sid == nullptr)
return;
if (!mir_strcmp(sid->szModule, MSG_ICON_MODULE)) {
if (sid->dwId == MSG_ICON_SOUND && code != NM_RCLICK) {
if (GetKeyState(VK_SHIFT) & 0x8000) {
for (TContainerData *p = pFirstContainer; p; p = p->pNext) {
p->cfg.flags.m_bNoSound = m_pContainer->cfg.flags.m_bNoSound;
InvalidateRect(m_pContainer->m_hwndStatus, nullptr, TRUE);
}
}
else {
m_pContainer->cfg.flags.m_bNoSound = !m_pContainer->cfg.flags.m_bNoSound;
InvalidateRect(m_pContainer->m_hwndStatus, nullptr, TRUE);
}
}
else if (sid->dwId == MSG_ICON_UTN && code != NM_RCLICK && AllowTyping()) {
SendMessage(m_pContainer->m_hwndActive, WM_COMMAND, IDC_SELFTYPING, 0);
InvalidateRect(m_pContainer->m_hwndStatus, nullptr, TRUE);
}
}
else {
StatusIconClickData sicd = { sizeof(sicd) };
GetCursorPos(&sicd.clickLocation);
sicd.dwId = sid->dwId;
sicd.szModule = sid->szModule;
sicd.flags = (code == NM_RCLICK ? MBCF_RIGHTBUTTON : 0);
Srmm_ClickStatusIcon(m_hContact, &sicd);
InvalidateRect(m_pContainer->m_hwndStatus, nullptr, TRUE);
}
}
void CMsgDialog::DM_ErrorDetected(int type, int flag)
{
switch (type) {
case MSGERROR_CANCEL:
case MSGERROR_SENDLATER:
if (m_bErrorState) {
m_cache->saveHistory();
if (type == MSGERROR_SENDLATER)
sendQueue->doSendLater(m_iCurrentQueueError, this); // to be implemented at a later time
m_iOpenJobs--;
sendQueue->dec();
if (m_iCurrentQueueError >= 0 && m_iCurrentQueueError < SendQueue::NR_SENDJOBS)
sendQueue->clearJob(m_iCurrentQueueError);
m_iCurrentQueueError = -1;
sendQueue->showErrorControls(this, FALSE);
if (type != MSGERROR_CANCEL || flag == 0)
m_message.SetText(L"");
sendQueue->checkQueue(this);
int iNextFailed = sendQueue->findNextFailed(this);
if (iNextFailed >= 0)
sendQueue->handleError(this, iNextFailed);
}
break;
case MSGERROR_RETRY:
if (m_bErrorState) {
int resent = 0;
m_cache->saveHistory();
if (m_iCurrentQueueError >= 0 && m_iCurrentQueueError < SendQueue::NR_SENDJOBS) {
SendJob *job = sendQueue->getJobByIndex(m_iCurrentQueueError);
if (job->iSendId == 0 && job->hContact == 0)
break;
job->iSendId = ProtoChainSend(job->hContact, PSS_MESSAGE, job->hEvent, (LPARAM)job->szSendBuffer);
resent++;
}
if (resent) {
SendJob *job = sendQueue->getJobByIndex(m_iCurrentQueueError);
SetTimer(m_hwnd, TIMERID_MSGSEND + m_iCurrentQueueError, PluginConfig.m_MsgTimeout, nullptr);
job->iStatus = SendQueue::SQ_INPROGRESS;
m_iCurrentQueueError = -1;
sendQueue->showErrorControls(this, FALSE);
m_message.SetText(L"");
sendQueue->checkQueue(this);
int iNextFailed = sendQueue->findNextFailed(this);
if (iNextFailed >= 0)
sendQueue->handleError(this, iNextFailed);
}
}
}
}
int SI_InitStatusIcons()
{
StatusIconData sid = {};
sid.szModule = MSG_ICON_MODULE;
sid.dwId = MSG_ICON_SOUND; // Sounds
Srmm_AddIcon(&sid, &g_plugin);
sid.dwId = MSG_ICON_UTN;
Srmm_AddIcon(&sid, &g_plugin);
HookEvent(ME_MSG_ICONSCHANGED, OnSrmmIconChanged);
return 0;
}
|