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
|
#include "common.h"
#include "notifications.h"
#include "resource.h"
#include "server_con.h"
#include <malloc.h>
#include <ctime>
#define URL_MAIL "http://messaging.myspace.com/index.cfm?fuseaction=mail.inbox"
#define URL_BLOG "http://blog.myspace.com/index.cfm?fuseaction=blog"
#define URL_PROFILE "http://comment.myspace.com/index.cfm?fuseaction=user.viewComments&friendID=%d"
#define URL_FRIEND "http://messaging.myspace.com/index.cfm?fuseaction=mail.friendRequests"
#define URL_PICTURE "http://viewmorepics.myspace.com/index.cfm?fuseaction=user.viewPictureComments&friendID=%d"
#define URL_BLOGSUB "http://blog.myspace.com/index.cfm?fuseaction=blog.controlcenter"
#define URL_HOME "http://home.myspace.com/index.cfm?fuseaction=user"
char *zap_array[11] = {
"zap", "whack", "torch", "smooch", "hug", "bslap", "goose", "hi-five", "punk'd", "raspberry", 0
};
bool bWndMailPopup = false, bWndBlogPopup = false, bWndProfilePopup = false, bWndFriendPopup = false, bWndPicPopup = false,
bWndBlogSubPopup = false, bWndUnknownPopup = false;
typedef struct {
char *url;
bool *bWnd;
} PopupProcData;
char popup_class_name[128];
LRESULT CALLBACK NotifyPopupWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message ) {
case UM_INITPOPUP:
{
PopupProcData *pd = (PopupProcData *)PUGetPluginData(hWnd);
if(pd) *pd->bWnd = true;
}
break;
case WM_COMMAND:
{
PopupProcData *pd = (PopupProcData *)PUGetPluginData(hWnd);
if(pd) {
CallService(MS_UTILS_OPENURL, (WPARAM)TRUE, (LPARAM)pd->url); //"http://messaging.myspace.com/index.cfm?fuseaction=mail.inbox"
*pd->bWnd = false;
}
}
PUDeletePopUp( hWnd );
return TRUE;
case WM_CONTEXTMENU:
{
PopupProcData *pd = (PopupProcData *)PUGetPluginData(hWnd);
if(pd) *pd->bWnd = false;
}
PUDeletePopUp( hWnd );
return TRUE;
case UM_FREEPLUGINDATA:
{
PopupProcData *pd = (PopupProcData *)PUGetPluginData(hWnd);
if(pd) {
free(pd->url);
delete pd;
}
}
return TRUE;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
void NotifyMail() {
if (!ServiceExists( MS_POPUP_ADDPOPUPT)) return;
if(bWndMailPopup) return;
POPUPDATAT ppd = {0};
TCHAR wproto[256];
#ifndef _UNICODE
strncpy(wproto, MODULE, 256);
#else
MultiByteToWideChar(code_page, 0, MODULE, -1, wproto, 256);
#endif
PopupProcData *pd = new PopupProcData;
pd->url = strdup(URL_MAIL);
pd->bWnd = &bWndMailPopup;
if(ServiceExists(MS_YAPP_CLASSINSTANCE)) {
PopupClassInstance d = {sizeof(d), popup_class_name};
d.ptszTitle = wproto;
d.ptszText = TranslateT("You have unread mail");
d.opaque = (void *)pd;
CallService(MS_YAPP_CLASSINSTANCE, 0, (LPARAM)&d);
} else {
_tcsncpy(ppd.lptzContactName, wproto, 256);
_tcscpy(ppd.lptzText, TranslateT("You have unread mail"));
ppd.lchIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MYSPACE), IMAGE_ICON, SM_CXSMICON, SM_CYSMICON, 0);
ppd.PluginWindowProc = ( WNDPROC )NotifyPopupWindowProc;
ppd.PluginData = (void *)pd;
ppd.iSeconds = -1;
PUAddPopUpT(&ppd);
}
char temp[512];
mir_snprintf(temp, 512, "%s/Mail", MODULE);
SkinPlaySound(temp);
}
void NotifyBlogComment() {
if (!ServiceExists( MS_POPUP_ADDPOPUPT)) return;
if(bWndBlogPopup) return;
POPUPDATAT ppd = {0};
TCHAR wproto[256];
#ifndef _UNICODE
strncpy(wproto, MODULE, 256);
#else
MultiByteToWideChar(code_page, 0, MODULE, -1, wproto, 256);
#endif
PopupProcData *pd = new PopupProcData;
pd->url = strdup(URL_BLOG);
pd->bWnd = &bWndBlogPopup;
if(ServiceExists(MS_YAPP_CLASSINSTANCE)) {
PopupClassInstance d = {sizeof(d), popup_class_name};
d.ptszTitle = wproto;
d.ptszText = TranslateT("You have unread blog comments");
d.opaque = (void *)pd;
CallService(MS_YAPP_CLASSINSTANCE, 0, (LPARAM)&d);
} else {
_tcsncpy(ppd.lptzContactName, wproto, 256);
_tcscpy(ppd.lptzText, TranslateT("You have unread blog comments"));
ppd.lchIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MYSPACE), IMAGE_ICON, SM_CXSMICON, SM_CYSMICON, 0);
ppd.PluginWindowProc = ( WNDPROC )NotifyPopupWindowProc;
ppd.PluginData = (void *)pd;
ppd.iSeconds = -1;
PUAddPopUpT(&ppd);
}
char temp[512];
mir_snprintf(temp, 512, "%s/BlogComment", MODULE);
SkinPlaySound(temp);
}
void NotifyProfileComment() {
if (!ServiceExists( MS_POPUP_ADDPOPUPT)) return;
if(bWndProfilePopup) return;
POPUPDATAT ppd = {0};
TCHAR wproto[256];
#ifndef _UNICODE
strncpy(wproto, MODULE, 256);
#else
MultiByteToWideChar(code_page, 0, MODULE, -1, wproto, 256);
#endif
PopupProcData *pd = new PopupProcData;
char url[1024];
mir_snprintf(url, 1024, URL_PROFILE, DBGetContactSettingDword(0, MODULE, "UID", 0));
pd->url = strdup(url);
pd->bWnd = &bWndProfilePopup;
if(ServiceExists(MS_YAPP_CLASSINSTANCE)) {
PopupClassInstance d = {sizeof(d), popup_class_name};
d.ptszTitle = wproto;
d.ptszText = TranslateT("You have unread profile comments");
d.opaque = (void *)pd;
CallService(MS_YAPP_CLASSINSTANCE, 0, (LPARAM)&d);
} else {
_tcsncpy(ppd.lptzContactName, wproto, 256);
_tcscpy(ppd.lptzText, TranslateT("You have unread profile comments"));
ppd.lchIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MYSPACE), IMAGE_ICON, SM_CXSMICON, SM_CYSMICON, 0);
ppd.PluginWindowProc = ( WNDPROC )NotifyPopupWindowProc;
ppd.PluginData = (void *)pd;
ppd.iSeconds = -1;
PUAddPopUpT(&ppd);
}
char temp[512];
mir_snprintf(temp, 512, "%s/ProfileComment", MODULE);
SkinPlaySound(temp);
}
void NotifyFriendRequest() {
if (!ServiceExists( MS_POPUP_ADDPOPUPT)) return;
if(bWndFriendPopup) return;
POPUPDATAT ppd = {0};
TCHAR wproto[256];
#ifndef _UNICODE
strncpy(wproto, MODULE, 256);
#else
MultiByteToWideChar(code_page, 0, MODULE, -1, wproto, 256);
#endif
PopupProcData *pd = new PopupProcData;
pd->url = strdup(URL_FRIEND);
pd->bWnd = &bWndFriendPopup;
if(ServiceExists(MS_YAPP_CLASSINSTANCE)) {
PopupClassInstance d = {sizeof(d), popup_class_name};
d.ptszTitle = wproto;
d.ptszText = TranslateT("You have new friend requests");
d.opaque = (void *)pd;
CallService(MS_YAPP_CLASSINSTANCE, 0, (LPARAM)&d);
} else {
_tcsncpy(ppd.lptzContactName, wproto, 256);
_tcscpy(ppd.lptzText, TranslateT("You have new friend requests"));
ppd.lchIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MYSPACE), IMAGE_ICON, SM_CXSMICON, SM_CYSMICON, 0);
ppd.PluginWindowProc = ( WNDPROC )NotifyPopupWindowProc;
ppd.PluginData = (void *)pd;
ppd.iSeconds = -1;
PUAddPopUpT(&ppd);
}
char temp[512];
mir_snprintf(temp, 512, "%s/FriendRequest", MODULE);
SkinPlaySound(temp);
}
void NotifyPictureComment() {
if (!ServiceExists( MS_POPUP_ADDPOPUPT)) return;
if(bWndPicPopup) return;
POPUPDATAT ppd = {0};
TCHAR wproto[256];
#ifndef _UNICODE
strncpy(wproto, MODULE, 256);
#else
MultiByteToWideChar(code_page, 0, MODULE, -1, wproto, 256);
#endif
PopupProcData *pd = new PopupProcData;
char url[1024];
mir_snprintf(url, 1024, URL_PICTURE, DBGetContactSettingDword(0, MODULE, "UID", 0));
pd->url = strdup(url);
pd->bWnd = &bWndPicPopup;
if(ServiceExists(MS_YAPP_CLASSINSTANCE)) {
PopupClassInstance d = {sizeof(d), popup_class_name};
d.ptszTitle = wproto;
d.ptszText = TranslateT("You have unread picture comments");
d.opaque = (void *)pd;
CallService(MS_YAPP_CLASSINSTANCE, 0, (LPARAM)&d);
} else {
_tcsncpy(ppd.lptzContactName, wproto, 256);
_tcscpy(ppd.lptzText, TranslateT("You have unread picture comments"));
ppd.lchIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MYSPACE), IMAGE_ICON, SM_CXSMICON, SM_CYSMICON, 0);
ppd.PluginWindowProc = ( WNDPROC )NotifyPopupWindowProc;
ppd.PluginData = (void *)pd;
ppd.iSeconds = -1;
PUAddPopUpT(&ppd);
}
char temp[512];
mir_snprintf(temp, 512, "%s/PictureComment", MODULE);
SkinPlaySound(temp);
}
void NotifyBlogSubscriptPost() {
if (!ServiceExists( MS_POPUP_ADDPOPUPT)) return;
if(bWndBlogSubPopup) return;
POPUPDATAT ppd = {0};
TCHAR wproto[256];
#ifndef _UNICODE
strncpy(wproto, MODULE, 256);
#else
MultiByteToWideChar(code_page, 0, MODULE, -1, wproto, 256);
#endif
PopupProcData *pd = new PopupProcData;
pd->url = strdup(URL_BLOGSUB);
pd->bWnd = &bWndBlogSubPopup;
if(ServiceExists(MS_YAPP_CLASSINSTANCE)) {
PopupClassInstance d = {sizeof(d), popup_class_name};
d.ptszTitle = wproto;
d.ptszText = TranslateT("You have unread blog subscription posts");
d.opaque = (void *)pd;
CallService(MS_YAPP_CLASSINSTANCE, 0, (LPARAM)&d);
} else {
_tcsncpy(ppd.lptzContactName, wproto, 256);
_tcscpy(ppd.lptzText, TranslateT("You have unread log subscription posts"));
ppd.lchIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MYSPACE), IMAGE_ICON, SM_CXSMICON, SM_CYSMICON, 0);
ppd.PluginWindowProc = ( WNDPROC )NotifyPopupWindowProc;
ppd.PluginData = (void *)pd;
ppd.iSeconds = -1;
PUAddPopUpT(&ppd);
}
char temp[512];
mir_snprintf(temp, 512, "%s/BlogSubscriptionPost", MODULE);
SkinPlaySound(temp);
}
void NotifyUnknown(char *name) {
if (!ServiceExists( MS_POPUP_ADDPOPUPT)) return;
if(bWndUnknownPopup) return;
POPUPDATAT ppd = {0};
TCHAR wproto[256];
#ifndef _UNICODE
strncpy(wproto, MODULE, 256);
#else
MultiByteToWideChar(code_page, 0, MODULE, -1, wproto, 256);
#endif
PopupProcData *pd = new PopupProcData;
pd->url = strdup(URL_HOME);
pd->bWnd = &bWndUnknownPopup;
TCHAR tname[256];
#ifdef _UNICODE
MultiByteToWideChar(CP_UTF8, 0, name, -1, tname, 256);
#else
strncpy(tname, name, 256);
#endif
TCHAR text[512];
mir_sntprintf(text, 512, TranslateT("Unknown event: %s\n\nClick here to go to your homepage"), tname);
if(ServiceExists(MS_YAPP_CLASSINSTANCE)) {
PopupClassInstance d = {sizeof(d), popup_class_name};
d.ptszTitle = wproto;
d.ptszText = text;
d.opaque = (void *)pd;
CallService(MS_YAPP_CLASSINSTANCE, 0, (LPARAM)&d);
} else {
_tcsncpy(ppd.lptzContactName, wproto, 256);
_tcscpy(ppd.lptzText, text);
ppd.lchIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MYSPACE), IMAGE_ICON, SM_CXSMICON, SM_CYSMICON, 0);
ppd.PluginWindowProc = ( WNDPROC )NotifyPopupWindowProc;
ppd.PluginData = (void *)pd;
ppd.iSeconds = -1;
PUAddPopUpT(&ppd);
}
}
void NotifyZapRecv(HANDLE hContact, int zap_num) {
char rmsg[512];
mir_snprintf(rmsg, 512, Translate("You received a ZAP: %s"), Translate(zap_array[zap_num]));
PROTORECVEVENT pre = {0};
pre.flags = PREF_UTF;
pre.szMessage = rmsg;
pre.timestamp = (DWORD)time(0);
pre.lParam = EVENTTYPE_ZAP;
CCSDATA css = {0};
css.hContact = hContact;
css.lParam = (LPARAM)⪯
css.szProtoService = PSR_MESSAGE;
CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&css);
char zap_sound_name[512];
mir_snprintf(zap_sound_name, 512, "%s/Zap/%s", MODULE, zap_array[zap_num]);
SkinPlaySound(zap_sound_name);
}
void NotifyZapSend(HANDLE hContact, int zap_num) {
char rmsg[512];
mir_snprintf(rmsg, 512, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", zap_num);
ClientNetMessage msg;
msg.add_int("bm", 121);
msg.add_int("sesskey", sesskey);
msg.add_int("t", DBGetContactSettingDword(hContact, MODULE, "UID", 0));
msg.add_int("f", my_uid);
msg.add_int("cv", CLIENT_VER);
msg.add_string("msg", rmsg);
SendMessage(msg);
mir_snprintf(rmsg, 512, "You sent a ZAP: %s", zap_array[zap_num]);
DBEVENTINFO dbe;
dbe.cbSize = sizeof(dbe);
dbe.szModule = MODULE;
dbe.timestamp = (DWORD)time(0);
dbe.flags = DBEF_SENT;
dbe.eventType = EVENTTYPE_ZAP;
dbe.pBlob = (BYTE*)rmsg;
dbe.cbBlob = strlen(rmsg) + 1;
CallService(MS_DB_EVENT_ADD,(WPARAM)hContact,(LPARAM)&dbe);
HANDLE hMeta;
if(ServiceExists(MS_MC_GETMETACONTACT) && (hMeta = (HANDLE)CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0)) != 0) // add to metacontact too
CallService(MS_DB_EVENT_ADD,(WPARAM)hMeta,(LPARAM)&dbe);
char zap_sound_name[512];
mir_snprintf(zap_sound_name, 512, "%s/Zap/%s", MODULE, zap_array[zap_num]);
SkinPlaySound(zap_sound_name);
}
HICON hProtoIcon;
void InitNotifications() {
SKINSOUNDDESCEX sd = {0};
sd.cbSize = sizeof(sd);
char sec[512], name[512], zap_desc[512];
mir_snprintf(sec, 512, "%s Notifications", MODULE);
sd.pszSection = sec;
mir_snprintf(name, 512, "%s/Mail", MODULE);
sd.pszName = name;
sd.pszDescription = "Mail";
CallService(MS_SKIN_ADDNEWSOUND, 0, (LPARAM)&sd);
mir_snprintf(name, 512, "%s/BlogComment", MODULE);
sd.pszName = name;
sd.pszDescription = "New blog comment";
CallService(MS_SKIN_ADDNEWSOUND, 0, (LPARAM)&sd);
mir_snprintf(name, 512, "%s/ProfileComment", MODULE);
sd.pszName = name;
sd.pszDescription = "New profile comment";
CallService(MS_SKIN_ADDNEWSOUND, 0, (LPARAM)&sd);
mir_snprintf(name, 512, "%s/FriendRequest", MODULE);
sd.pszName = name;
sd.pszDescription = "New friend request";
CallService(MS_SKIN_ADDNEWSOUND, 0, (LPARAM)&sd);
mir_snprintf(name, 512, "%s/PictureComment", MODULE);
sd.pszName = name;
sd.pszDescription = "New picture comment";
CallService(MS_SKIN_ADDNEWSOUND, 0, (LPARAM)&sd);
mir_snprintf(name, 512, "%s/BlogSubscriptionPost", MODULE);
sd.pszName = name;
sd.pszDescription = "New blog subscription post";
CallService(MS_SKIN_ADDNEWSOUND, 0, (LPARAM)&sd);
for(int i = 0; zap_array[i]; i++) {
mir_snprintf(name, 512, "%s/Zap/%s", MODULE, zap_array[i]);
sd.pszName = name;
mir_snprintf(zap_desc, 512, "Zap: %s", zap_array[i]);
sd.pszDescription = zap_desc;
CallService(MS_SKIN_ADDNEWSOUND, 0, (LPARAM)&sd);
}
hProtoIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MYSPACE), IMAGE_ICON, SM_CXSMICON, SM_CYSMICON, 0);
if(ServiceExists(MS_YAPP_REGISTERCLASS)) {
TCHAR tmod[128];
#ifdef _UNICODE
MultiByteToWideChar(code_page, 0, MODULE, -1, tmod, 128);
#else
strncpy(tmod, MODULE, 128);
#endif
mir_snprintf(popup_class_name, 128, "%s/Notify", MODULE);
PopupClass test = {0};
test.cbSize = sizeof(test);
test.flags = PCF_TCHAR;
test.hIcon = hProtoIcon;
test.timeout = -1;
test.ptszDescription = tmod;
test.pszName = popup_class_name;
test.windowProc = NotifyPopupWindowProc;
CallService(MS_YAPP_REGISTERCLASS, 0, (WPARAM)&test);
}
}
void DeinitNotifications() {
DestroyIcon(hProtoIcon);
}
|