summaryrefslogtreecommitdiff
path: root/MySpace/notifications.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'MySpace/notifications.cpp')
-rw-r--r--MySpace/notifications.cpp141
1 files changed, 129 insertions, 12 deletions
diff --git a/MySpace/notifications.cpp b/MySpace/notifications.cpp
index d29db18..e7574e7 100644
--- a/MySpace/notifications.cpp
+++ b/MySpace/notifications.cpp
@@ -1,15 +1,22 @@
#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"
-bool bWndMailPopup = false, bWndBlogPopup = false, bWndProfilePopup = false, bWndFriendPopup = false;
+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;
typedef struct {
char *url;
bool *bWnd;
@@ -220,34 +227,143 @@ void NotifyFriendRequest() {
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
+
+ PopupData *pd = new PopupData;
+ char url[1024];
+ mir_snprintf(url, 1024, URL_PICTURE, DBGetContactSettingDword(0, MODULE, "UID", 0));
+ pd->url = strdup(url);
+ pd->bWnd = &bWndPicPopup;
+
+ if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
+ POPUPDATACLASS d = {sizeof(d), popup_class_name};
+ d.ptszTitle = wproto;
+ d.ptszText = TranslateT("You have unread picture comments");
+ d.PluginData = (void *)pd;
+ CallService(MS_POPUP_ADDPOPUPCLASS, 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 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)&pre;
+ 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 temp_sec[512], temp[512];
- mir_snprintf(temp_sec, 512, "%s Notifications", MODULE);
- sd.pszSection = temp_sec;
+ char sec[512], name[512], zap_desc[512];
+ mir_snprintf(sec, 512, "%s Notifications", MODULE);
+ sd.pszSection = sec;
- mir_snprintf(temp, 512, "%s/Mail", MODULE);
- sd.pszName = temp;
+ mir_snprintf(name, 512, "%s/Mail", MODULE);
+ sd.pszName = name;
sd.pszDescription = "Mail";
CallService(MS_SKIN_ADDNEWSOUND, 0, (LPARAM)&sd);
- mir_snprintf(temp, 512, "%s/BlogComment", MODULE);
- sd.pszName = temp;
+ mir_snprintf(name, 512, "%s/BlogComment", MODULE);
+ sd.pszName = name;
sd.pszDescription = "New blog comment";
CallService(MS_SKIN_ADDNEWSOUND, 0, (LPARAM)&sd);
- mir_snprintf(temp, 512, "%s/ProfileComment", MODULE);
- sd.pszName = temp;
+ mir_snprintf(name, 512, "%s/ProfileComment", MODULE);
+ sd.pszName = name;
sd.pszDescription = "New profile comment";
CallService(MS_SKIN_ADDNEWSOUND, 0, (LPARAM)&sd);
- mir_snprintf(temp, 512, "%s/FriendRequest", MODULE);
- sd.pszName = temp;
+ 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);
+
+ 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_POPUP_ADDPOPUPCLASS)) {
TCHAR tmod[128];
@@ -275,3 +391,4 @@ void DeinitNotifications() {
DestroyIcon(hProtoIcon);
}
+