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
|
#include "common.h"
extern BOOL _saveDlgItemInt(HWND hDialog, int controlID, char* option);
void EnablePopupControls(HWND hwnd, BOOL enable)
{
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_NOTIFY_BLOCKED), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_NOTIFY_APPROVED), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_NOTIFY_CHALLENGE), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_BLOCKED_FOREGROUND), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_BLOCKED_BACKGROUND), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_APPROVED_FOREGROUND), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_APPROVED_BACKGROUND), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_CHALLENGE_FOREGROUND), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_CHALLENGE_BACKGROUND), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_BLOCKED_TIMEOUT), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_APPROVED_TIMEOUT), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_CHALLENGE_TIMEOUT), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_DEFAULT_COLORS), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_WINDOWS_COLORS), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_DEFAULT_TIMEOUT), enable);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_PREVIEW), enable);
}
void EnablePopupColors(HWND hwnd, BOOL enableDefault, BOOL enableWindows)
{
BOOL enable, bEnabled;
bEnabled = IsDlgButtonChecked(hwnd, IDC_OPT_POPUPS_ENABLED);
enable = enableDefault || enableWindows;
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_BLOCKED_FOREGROUND), !enable && bEnabled);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_BLOCKED_BACKGROUND), !enable && bEnabled);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_APPROVED_FOREGROUND), !enable && bEnabled);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_APPROVED_BACKGROUND), !enable && bEnabled);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_CHALLENGE_FOREGROUND), !enable && bEnabled);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_CHALLENGE_BACKGROUND), !enable && bEnabled);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_WINDOWS_COLORS), !enableDefault && bEnabled);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_DEFAULT_COLORS), !enableWindows && bEnabled);
}
void EnablePopupTimeouts(HWND hwnd, BOOL enable)
{
BOOL bEnabled = IsDlgButtonChecked(hwnd, IDC_OPT_POPUPS_ENABLED);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_BLOCKED_TIMEOUT), !enable && bEnabled);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_APPROVED_TIMEOUT), !enable && bEnabled);
EnableWindow(GetDlgItem(hwnd, IDC_OPT_POPUPS_CHALLENGE_TIMEOUT), !enable && bEnabled);
}
INT_PTR CALLBACK DlgProcOptionsPopups(HWND optDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
BOOL bEnabled;
static int bInitializing = 0;
switch (msg) {
case WM_INITDIALOG:
bInitializing = 1;
TranslateDialogDefault(optDlg);
bEnabled = _getOptB("NotifyPopup", defaultNotifyPopup);
CheckDlgButton(optDlg, IDC_OPT_POPUPS_ENABLED, bEnabled ? BST_CHECKED : BST_UNCHECKED);
EnablePopupControls(optDlg, bEnabled);
CheckDlgButton(optDlg, IDC_OPT_POPUPS_NOTIFY_BLOCKED, _getOptB("NotifyPopupBlocked", defaultNotifyPopupBlocked) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(optDlg, IDC_OPT_POPUPS_NOTIFY_APPROVED, _getOptB("NotifyPopupApproved", defaultNotifyPopupApproved) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(optDlg, IDC_OPT_POPUPS_NOTIFY_CHALLENGE, _getOptB("NotifyPopupChallenge", defaultNotifyPopupChallenge) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(optDlg, IDC_OPT_POPUPS_DEFAULT_COLORS, _getOptB("PopupDefaultColors", defaultPopupDefaultColors) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(optDlg, IDC_OPT_POPUPS_WINDOWS_COLORS, _getOptB("PopupWindowsColors", defaultPopupWindowsColors) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(optDlg, IDC_OPT_POPUPS_DEFAULT_TIMEOUT, _getOptB("PopupDefaultTimeout", defaultPopupDefaultTimeout) ? BST_CHECKED : BST_UNCHECKED);
SetDlgItemInt(optDlg, IDC_OPT_POPUPS_BLOCKED_TIMEOUT, _getOptD("PopupBlockedTimeout", defaultPopupBlockedTimeout), FALSE);
SetDlgItemInt(optDlg, IDC_OPT_POPUPS_APPROVED_TIMEOUT, _getOptD("PopupApprovedTimeout", defaultPopupApprovedTimeout), FALSE);
SetDlgItemInt(optDlg, IDC_OPT_POPUPS_CHALLENGE_TIMEOUT, _getOptD("PopupChallengeTimeout", defaultPopupChallengeTimeout), FALSE);
SendDlgItemMessage(optDlg, IDC_OPT_POPUPS_BLOCKED_FOREGROUND, CPM_SETCOLOUR, 0, _getOptD("PopupBlockedForeground", defaultPopupBlockedForeground));
SendDlgItemMessage(optDlg, IDC_OPT_POPUPS_BLOCKED_BACKGROUND, CPM_SETCOLOUR, 0, _getOptD("PopupBlockedBackground", defaultPopupBlockedBackground));
SendDlgItemMessage(optDlg, IDC_OPT_POPUPS_APPROVED_FOREGROUND, CPM_SETCOLOUR, 0, _getOptD("PopupApprovedForeground", defaultPopupApprovedForeground));
SendDlgItemMessage(optDlg, IDC_OPT_POPUPS_APPROVED_BACKGROUND, CPM_SETCOLOUR, 0, _getOptD("PopupApprovedBackground", defaultPopupApprovedBackground));
SendDlgItemMessage(optDlg, IDC_OPT_POPUPS_CHALLENGE_FOREGROUND, CPM_SETCOLOUR, 0, _getOptD("PopupChallengeForeground", defaultPopupChallengeForeground));
SendDlgItemMessage(optDlg, IDC_OPT_POPUPS_CHALLENGE_BACKGROUND, CPM_SETCOLOUR, 0, _getOptD("PopupChallengeBackground", defaultPopupChallengeBackground));
EnablePopupTimeouts(optDlg, IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_DEFAULT_TIMEOUT));
EnablePopupColors(optDlg,
_getOptB("PopupDefaultColors", defaultPopupDefaultColors),
_getOptB("PopupWindowsColors", defaultPopupWindowsColors));
bInitializing = 0;
break;
case WM_COMMAND:
if (bInitializing)
return FALSE;
switch (LOWORD(wParam)) {
case IDC_OPT_POPUPS_ENABLED:
bEnabled = IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_ENABLED);
EnablePopupControls(optDlg, bEnabled);
case IDC_OPT_POPUPS_NOTIFY_BLOCKED:
case IDC_OPT_POPUPS_NOTIFY_APPROVED:
case IDC_OPT_POPUPS_NOTIFY_CHALLENGE:
case IDC_OPT_POPUPS_DEFAULT_COLORS:
case IDC_OPT_POPUPS_WINDOWS_COLORS:
case IDC_OPT_POPUPS_DEFAULT_TIMEOUT:
EnablePopupColors(optDlg,
IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_DEFAULT_COLORS),
IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_WINDOWS_COLORS));
EnablePopupTimeouts(optDlg, IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_DEFAULT_TIMEOUT));
if (HIWORD(wParam) != BN_CLICKED)
return FALSE;
break;
case IDC_OPT_POPUPS_BLOCKED_TIMEOUT:
case IDC_OPT_POPUPS_APPROVED_TIMEOUT:
case IDC_OPT_POPUPS_CHALLENGE_TIMEOUT:
if (HIWORD(wParam) != EN_CHANGE)
return FALSE;
break;
case IDC_OPT_POPUPS_PREVIEW:
ShowPopupPreview(optDlg, POPUP_BLOCKED, NULL, TranslateT("Message blocked due to preview action"));
ShowPopupPreview(optDlg, POPUP_APPROVED, NULL, TranslateT("Contact approved due to preview action"));
ShowPopupPreview(optDlg, POPUP_CHALLENGE, NULL, TranslateT("Challenge sent to preview contact"));
return FALSE;
}
SendMessage(GetParent(optDlg), PSM_CHANGED, 0, 0);
break;
case WM_NOTIFY:
switch (((NMHDR*)lParam)->code) {
case PSN_APPLY:
_setOptB("NotifyPopup", IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_ENABLED));
_setOptB("NotifyPopupBlocked", IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_NOTIFY_BLOCKED));
_setOptB("NotifyPopupApproved", IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_NOTIFY_APPROVED));
_setOptB("NotifyPopupChallenge", IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_NOTIFY_CHALLENGE));
_setOptB("PopupDefaultColors", IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_DEFAULT_COLORS));
_setOptB("PopupWindowsColors", IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_WINDOWS_COLORS));
_setOptB("PopupDefaultTimeout", IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_DEFAULT_TIMEOUT));
_saveDlgItemInt(optDlg, IDC_OPT_POPUPS_BLOCKED_TIMEOUT, "PopupBlockedTimeout");
_saveDlgItemInt(optDlg, IDC_OPT_POPUPS_APPROVED_TIMEOUT, "PopupApprovedTimeout");
_saveDlgItemInt(optDlg, IDC_OPT_POPUPS_CHALLENGE_TIMEOUT, "PopupChallengeTimeout");
_setOptD("PopupBlockedForeground", SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_BLOCKED_FOREGROUND,CPM_GETCOLOUR,0,0));
_setOptD("PopupBlockedBackground", SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_BLOCKED_BACKGROUND,CPM_GETCOLOUR,0,0));
_setOptD("PopupApprovedForeground", SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_APPROVED_FOREGROUND,CPM_GETCOLOUR,0,0));
_setOptD("PopupApprovedBackground", SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_APPROVED_BACKGROUND,CPM_GETCOLOUR,0,0));
_setOptD("PopupChallengeForeground", SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_CHALLENGE_FOREGROUND,CPM_GETCOLOUR,0,0));
_setOptD("PopupChallengeBackground", SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_CHALLENGE_BACKGROUND,CPM_GETCOLOUR,0,0));
break;
}
break;
case WM_DESTROY:
break;
}
return FALSE;
}
int ShowPopupPreview(HWND optDlg, BYTE popupType, TCHAR *line1, TCHAR *line2)
{
POPUPDATAT ppdp = {0};
switch (popupType)
{
case POPUP_DEFAULT:
ppdp.colorText = SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_APPROVED_FOREGROUND,CPM_GETCOLOUR,0,0);
ppdp.colorBack = SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_APPROVED_BACKGROUND,CPM_GETCOLOUR,0,0);
break;
case POPUP_BLOCKED:
ppdp.colorText = SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_BLOCKED_FOREGROUND,CPM_GETCOLOUR,0,0);
ppdp.colorBack = SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_BLOCKED_BACKGROUND,CPM_GETCOLOUR,0,0);
ppdp.iSeconds = GetDlgItemInt(optDlg, IDC_OPT_POPUPS_BLOCKED_TIMEOUT, NULL, TRUE);
ppdp.lchIcon = Skin_LoadIcon(SKINICON_OTHER_DELETE);
break;
case POPUP_APPROVED:
ppdp.colorText = SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_APPROVED_FOREGROUND,CPM_GETCOLOUR,0,0);
ppdp.colorBack = SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_APPROVED_BACKGROUND,CPM_GETCOLOUR,0,0);
ppdp.iSeconds = GetDlgItemInt(optDlg, IDC_OPT_POPUPS_APPROVED_TIMEOUT, NULL, TRUE);
ppdp.lchIcon = Skin_LoadIcon(SKINICON_OTHER_ADDCONTACT);
break;
case POPUP_CHALLENGE:
ppdp.colorText = SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_CHALLENGE_FOREGROUND,CPM_GETCOLOUR,0,0);
ppdp.colorBack = SendDlgItemMessage(optDlg,IDC_OPT_POPUPS_CHALLENGE_BACKGROUND,CPM_GETCOLOUR,0,0);
ppdp.iSeconds = GetDlgItemInt(optDlg, IDC_OPT_POPUPS_CHALLENGE_TIMEOUT, NULL, TRUE);
ppdp.lchIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE);
break;
}
if (IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_WINDOWS_COLORS)) {
ppdp.colorText = GetSysColor(COLOR_WINDOWTEXT);
ppdp.colorBack = GetSysColor(COLOR_WINDOW);
}
if (IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_DEFAULT_COLORS)) {
ppdp.colorText = NULL;
ppdp.colorBack = NULL;
}
if (ppdp.iSeconds < 1)
ppdp.iSeconds = -1;
if (IsDlgButtonChecked(optDlg, IDC_OPT_POPUPS_DEFAULT_TIMEOUT) || popupType == POPUP_DEFAULT)
ppdp.iSeconds = 0;
ppdp.lchContact = NULL;
_tcsncpy_s(ppdp.lptzContactName, (line1 ? line1 : _T(PLUGIN_NAME)), _TRUNCATE);
if (line2)
_tcsncpy_s(ppdp.lptzText, line2, _TRUNCATE);
return PUAddPopupT(&ppdp);
}
int ShowPopup(MCONTACT hContact, BYTE popupType, TCHAR *line1, TCHAR *line2)
{
POPUPDATAT ppdp = {0};
switch (popupType)
{
case POPUP_DEFAULT:
ppdp.colorText = _getOptD("PopupApprovedForeground", defaultPopupApprovedForeground);
ppdp.colorBack = _getOptD("PopupApprovedBackground", defaultPopupApprovedBackground);
break;
case POPUP_BLOCKED:
ppdp.colorText = _getOptD("PopupBlockedForeground", defaultPopupBlockedForeground);
ppdp.colorBack = _getOptD("PopupBlockedBackground", defaultPopupBlockedBackground);
ppdp.iSeconds = _getOptD("PopupBlockedTimeout", defaultPopupBlockedTimeout);
ppdp.lchIcon = Skin_LoadIcon(SKINICON_OTHER_DELETE);
break;
case POPUP_APPROVED:
ppdp.colorText = _getOptD("PopupApprovedForeground", defaultPopupApprovedForeground);
ppdp.colorBack = _getOptD("PopupApprovedBackground", defaultPopupApprovedBackground);
ppdp.iSeconds = _getOptD("PopupApprovedTimeout", defaultPopupApprovedTimeout);
ppdp.lchIcon = Skin_LoadIcon(SKINICON_OTHER_ADDCONTACT);
break;
case POPUP_CHALLENGE:
ppdp.colorText = _getOptD("PopupChallengeForeground", defaultPopupChallengeForeground);
ppdp.colorBack = _getOptD("PopupChallengeBackground", defaultPopupChallengeBackground);
ppdp.iSeconds = _getOptD("PopupChallengeTimeout", defaultPopupChallengeTimeout);
ppdp.lchIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE);
break;
}
if (_getOptB("PopupWindowsColors", defaultPopupWindowsColors)) {
ppdp.colorText = GetSysColor(COLOR_WINDOWTEXT);
ppdp.colorBack = GetSysColor(COLOR_WINDOW);
}
if (_getOptB("PopupDefaultColors", defaultPopupDefaultColors)) {
ppdp.colorText = NULL;
ppdp.colorBack = NULL;
}
if (ppdp.iSeconds < 1)
ppdp.iSeconds = -1;
if (_getOptB("PopupDefaultTimeout", defaultPopupDefaultTimeout) || popupType == POPUP_DEFAULT)
ppdp.iSeconds = 0;
ppdp.lchContact = hContact;
_tcsncpy_s(ppdp.lptzContactName, (line1 ? line1 : _T(PLUGIN_NAME)), _TRUNCATE);
if (line2)
_tcsncpy_s(ppdp.lptzText, line2, _TRUNCATE);
return PUAddPopupT(&ppdp);
}
|