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
|
#include "Common.h"
HINSTANCE hInst;
TOPTIONS Options;
HICON hIconMsg;
HICON hIconUrl;
HICON hIconFile;
int hLangpack;
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESCRIPTION,
__AUTHOR,
__AUTHOREMAIL,
__COPYRIGHT,
__AUTHORWEB,
UNICODE_AWARE,
// {1ACB2ED1-C1ED-43EE-89BD-086686F6EBB5}
{0x1acb2ed1, 0xc1ed, 0x43ee, {0x89, 0xbd, 0x8, 0x66, 0x86, 0xf6, 0xeb, 0xb5}}
};
void LoadOptions()
{
ZeroMemory(&Options, sizeof(Options));
Options.MessageRead = (BOOL)db_get_b(NULL, PLUGINNAME, "MessageRead", FALSE);
Options.MessageSend = (BOOL)db_get_b(NULL, PLUGINNAME, "MessageSend", TRUE);
Options.UrlRead = (BOOL)db_get_b(NULL, PLUGINNAME, "UrlRead", FALSE);
Options.UrlSend = (BOOL)db_get_b(NULL, PLUGINNAME, "UrlSend", TRUE);
Options.FileRead = (BOOL)db_get_b(NULL, PLUGINNAME, "FileRead", FALSE);
Options.FileSend = (BOOL)db_get_b(NULL, PLUGINNAME, "FileSend", TRUE);
Options.ChangeTo = (INT)db_get_dw(NULL, PLUGINNAME, "ChangeTo", ID_STATUS_ONLINE);
Options.IfOffline = (BOOL)db_get_b(NULL, PLUGINNAME, "IfOffline", FALSE);
Options.IfOnline = (BOOL)db_get_b(NULL, PLUGINNAME, "IfOnline", FALSE);
Options.IfAway = (BOOL)db_get_b(NULL, PLUGINNAME, "IfAway", TRUE);
Options.IfNA = (BOOL)db_get_b(NULL, PLUGINNAME, "IfNA", TRUE);
Options.IfOccupied = (BOOL)db_get_b(NULL, PLUGINNAME, "IfOccupied", FALSE);
Options.IfDND = (BOOL)db_get_b(NULL, PLUGINNAME, "IfDND", FALSE);
Options.IfFreeforchat = (BOOL)db_get_b(NULL, PLUGINNAME, "IfFreeforchat", FALSE);
Options.IfInvisible = (BOOL)db_get_b(NULL, PLUGINNAME, "IfInvisible", FALSE);
Options.IfOnthephone = (BOOL)db_get_b(NULL, PLUGINNAME, "IfOnthephone", FALSE);
Options.IfOuttolunch = (BOOL)db_get_b(NULL, PLUGINNAME, "IfOuttolunch", FALSE);
}
static int StatusChangeGetMessage(WPARAM wParam, LPARAM lParam)
{
HANDLE hDbEvent = (HANDLE)lParam;
DBEVENTINFO dbe;
int status;
BOOL read, send, change_status;
dbe.cbSize = sizeof(dbe);
dbe.cbBlob = 0;
CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbe);
status = (int)CallProtoService(dbe.szModule, PS_GETSTATUS, 0, 0);
if(!status)
status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
if(status == Options.ChangeTo)
return 0;
switch (status) {
case ID_STATUS_OFFLINE : change_status = Options.IfOffline; break;
case ID_STATUS_ONLINE : change_status = Options.IfOnline; break;
case ID_STATUS_AWAY : change_status = Options.IfAway; break;
case ID_STATUS_NA : change_status = Options.IfNA; break;
case ID_STATUS_OCCUPIED : change_status = Options.IfOccupied; break;
case ID_STATUS_DND : change_status = Options.IfDND; break;
case ID_STATUS_FREECHAT : change_status = Options.IfFreeforchat; break;
case ID_STATUS_INVISIBLE : change_status = Options.IfInvisible; break;
case ID_STATUS_ONTHEPHONE : change_status = Options.IfOnthephone; break;
case ID_STATUS_OUTTOLUNCH : change_status = Options.IfOuttolunch; break;
default : change_status = FALSE; break;
}
if (!change_status)
return 0;
switch (dbe.eventType) {
case EVENTTYPE_MESSAGE :
read = Options.MessageRead;
send = Options.MessageSend;
break;
case EVENTTYPE_URL :
read = Options.UrlRead;
send = Options.UrlSend;
break;
case EVENTTYPE_FILE :
read = Options.FileRead;
send = Options.FileSend;
break;
break;
}
// If is a message sent...
if (((DWORD)(dbe.flags & ((DWORD)DBEF_SENT))) == ((DWORD)(DBEF_SENT))) {
if (send) {
// change status
CallProtoService(dbe.szModule, PS_SETSTATUS, (LPARAM)(Options.ChangeTo), 0);
}
}
// If is a message received...
else {
if (read) {
// change status
CallProtoService(dbe.szModule, PS_SETSTATUS, (LPARAM)(Options.ChangeTo), 0);
}
}
return 0;
}
static INT_PTR CALLBACK DlgProcStatusChangeOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
hIconMsg = (HICON)CopyImage(LoadSkinnedIcon(SKINICON_EVENT_MESSAGE), IMAGE_ICON, 16, 16, LR_COPYFROMRESOURCE);
SendDlgItemMessage(hwndDlg, IDC_MSGICON, STM_SETICON, (WPARAM)hIconMsg, 0);
hIconUrl = (HICON)CopyImage(LoadSkinnedIcon(SKINICON_EVENT_URL), IMAGE_ICON, 16, 16, LR_COPYFROMRESOURCE);
SendDlgItemMessage(hwndDlg, IDC_URLICON, STM_SETICON, (WPARAM)hIconUrl, 0);
hIconFile = (HICON)CopyImage(LoadSkinnedIcon(SKINICON_EVENT_FILE), IMAGE_ICON, 16, 16, LR_COPYFROMRESOURCE);
SendDlgItemMessage(hwndDlg, IDC_FILEICON, STM_SETICON, (WPARAM)hIconFile, 0);
CheckDlgButton(hwndDlg, IDC_CHK_MESSAGEREAD, Options.MessageRead?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_MESSAGESEND, Options.MessageSend?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_URLREAD, Options.UrlRead?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_URLSEND, Options.UrlSend?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_FILEREAD, Options.FileRead?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_FILESEND, Options.FileSend?BST_CHECKED:BST_UNCHECKED);
switch(Options.ChangeTo) {
case ID_STATUS_OFFLINE : CheckDlgButton(hwndDlg, IDC_RAD_OFFLINE, BST_CHECKED); break;
case ID_STATUS_ONLINE : CheckDlgButton(hwndDlg, IDC_RAD_ONLINE, BST_CHECKED); break;
case ID_STATUS_AWAY : CheckDlgButton(hwndDlg, IDC_RAD_AWAY, BST_CHECKED); break;
case ID_STATUS_DND : CheckDlgButton(hwndDlg, IDC_RAD_DND, BST_CHECKED); break;
case ID_STATUS_NA : CheckDlgButton(hwndDlg, IDC_RAD_NA, BST_CHECKED); break;
case ID_STATUS_OCCUPIED : CheckDlgButton(hwndDlg, IDC_RAD_OCCUPIED, BST_CHECKED); break;
case ID_STATUS_FREECHAT : CheckDlgButton(hwndDlg, IDC_RAD_FREECHAT, BST_CHECKED); break;
case ID_STATUS_INVISIBLE : CheckDlgButton(hwndDlg, IDC_RAD_INVISIBLE, BST_CHECKED); break;
case ID_STATUS_ONTHEPHONE : CheckDlgButton(hwndDlg, IDC_RAD_ONTHEPHONE, BST_CHECKED); break;
case ID_STATUS_OUTTOLUNCH : CheckDlgButton(hwndDlg, IDC_RAD_OUTTOLUNCH, BST_CHECKED); break;
break;
}
CheckDlgButton(hwndDlg, IDC_CHK_OFFLINE, Options.IfOffline?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_ONLINE, Options.IfOnline?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_AWAY, Options.IfAway?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_DND, Options.IfDND?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_NA, Options.IfNA?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_OCCUPIED, Options.IfOccupied?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_FREECHAT, Options.IfFreeforchat?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_INVISIBLE, Options.IfInvisible?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_ONTHEPHONE, Options.IfOnthephone?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_OUTTOLUNCH, Options.IfOuttolunch?BST_CHECKED:BST_UNCHECKED);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_CHK_MESSAGEREAD:
Options.MessageRead = !Options.MessageRead;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_MESSAGESEND:
Options.MessageSend = !Options.MessageSend;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_URLREAD:
Options.UrlRead = !Options.UrlRead;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_URLSEND:
Options.UrlSend = !Options.UrlSend;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_FILEREAD:
Options.FileRead = !Options.FileRead;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_FILESEND:
Options.FileSend = !Options.FileSend;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_RAD_OFFLINE:
Options.ChangeTo = ID_STATUS_OFFLINE;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_RAD_ONLINE:
Options.ChangeTo = ID_STATUS_ONLINE;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_RAD_AWAY:
Options.ChangeTo = ID_STATUS_AWAY;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_RAD_DND:
Options.ChangeTo = ID_STATUS_DND;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_RAD_NA:
Options.ChangeTo = ID_STATUS_NA;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_RAD_OCCUPIED:
Options.ChangeTo = ID_STATUS_OCCUPIED;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_RAD_FREECHAT:
Options.ChangeTo = ID_STATUS_FREECHAT;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_RAD_INVISIBLE:
Options.ChangeTo = ID_STATUS_INVISIBLE;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_RAD_ONTHEPHONE:
Options.ChangeTo = ID_STATUS_ONTHEPHONE;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_RAD_OUTTOLUNCH:
Options.ChangeTo = ID_STATUS_OUTTOLUNCH;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_OFFLINE:
Options.IfOffline = !Options.IfOffline;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_ONLINE:
Options.IfOnline = !Options.IfOnline;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_AWAY:
Options.IfAway = !Options.IfAway;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_DND:
Options.IfDND = !Options.IfDND;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_NA:
Options.IfNA = !Options.IfNA;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_OCCUPIED:
Options.IfOccupied = !Options.IfOccupied;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_FREECHAT:
Options.IfFreeforchat = !Options.IfFreeforchat;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_INVISIBLE:
Options.IfInvisible = !Options.IfInvisible;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_ONTHEPHONE:
Options.IfOnthephone = !Options.IfOnthephone;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_CHK_OUTTOLUNCH:
Options.IfOuttolunch = !Options.IfOuttolunch;
PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
break;
case WM_NOTIFY:
switch(((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_RESET:
LoadOptions();
return TRUE;
case PSN_APPLY:
db_set_b(NULL, PLUGINNAME, "MessageRead", (BYTE)Options.MessageRead);
db_set_b(NULL, PLUGINNAME, "MessageSend", (BYTE)Options.MessageSend);
db_set_b(NULL, PLUGINNAME, "UrlRead", (BYTE)Options.UrlRead);
db_set_b(NULL, PLUGINNAME, "UrlSend", (BYTE)Options.UrlSend);
db_set_b(NULL, PLUGINNAME, "FileRead", (BYTE)Options.FileRead);
db_set_b(NULL, PLUGINNAME, "FileSend", (BYTE)Options.FileSend);
db_set_dw(NULL, PLUGINNAME, "ChangeTo", (DWORD)Options.ChangeTo);
db_set_b(NULL, PLUGINNAME, "IfOffline", (BYTE)Options.IfOffline);
db_set_b(NULL, PLUGINNAME, "IfOnline", (BYTE)Options.IfOnline);
db_set_b(NULL, PLUGINNAME, "IfAway", (BYTE)Options.IfAway);
db_set_b(NULL, PLUGINNAME, "IfNA", (BYTE)Options.IfNA);
db_set_b(NULL, PLUGINNAME, "IfDND", (BYTE)Options.IfDND);
db_set_b(NULL, PLUGINNAME, "IfOccupied", (BYTE)Options.IfOccupied);
db_set_b(NULL, PLUGINNAME, "IfFreeforchat", (BYTE)Options.IfFreeforchat);
db_set_b(NULL, PLUGINNAME, "IfInvisible", (BYTE)Options.IfInvisible);
db_set_b(NULL, PLUGINNAME, "IfOnthephone", (BYTE)Options.IfOnthephone);
db_set_b(NULL, PLUGINNAME, "IfOuttolunch", (BYTE)Options.IfOuttolunch);
return TRUE;
break;
}
break;
break;
}
break;
case WM_DESTROY:
DestroyIcon(hIconMsg);
DestroyIcon(hIconUrl);
DestroyIcon(hIconFile);
break;
}
return FALSE;
}
int StatusChangeOptInit(WPARAM wParam, LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = {0};
odp.cbSize = sizeof(odp);
odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.ptszTitle = LPGENT("Status Change");
odp.ptszGroup = LPGENT("Status");
odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
odp.pfnDlgProc = DlgProcStatusChangeOpts;
Options_AddPage(wParam, &odp);
return 0;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hInst = hinstDLL;
return TRUE;
}
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
{
return &pluginInfo;
}
extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfo);
HookEvent(ME_OPT_INITIALISE, StatusChangeOptInit);
HookEvent(ME_DB_EVENT_ADDED, StatusChangeGetMessage);
LoadOptions();
return 0;
}
extern "C" __declspec(dllexport) int Unload(void)
{
return 0;
}
|