summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MySpace/notifications.cpp141
-rw-r--r--MySpace/notifications.h6
-rw-r--r--MySpace/server_con.cpp39
-rw-r--r--MySpace/server_con.h2
-rw-r--r--MySpace/version.h2
5 files changed, 152 insertions, 38 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);
}
+
diff --git a/MySpace/notifications.h b/MySpace/notifications.h
index 9b14d72..3340046 100644
--- a/MySpace/notifications.h
+++ b/MySpace/notifications.h
@@ -5,9 +5,15 @@ void NotifyMail();
void NotifyBlogComment();
void NotifyProfileComment();
void NotifyFriendRequest();
+void NotifyPictureComment();
void InitNotifications();
void DeinitNotifications();
+extern char *zap_array[];
+
+void NotifyZapRecv(HANDLE hContact, int zap_num);
+void NotifyZapSend(HANDLE hContact, int zap_num);
+
#endif
diff --git a/MySpace/server_con.cpp b/MySpace/server_con.cpp
index c79ecd3..3d7319f 100644
--- a/MySpace/server_con.cpp
+++ b/MySpace/server_con.cpp
@@ -36,10 +36,6 @@ int signon_status = ID_STATUS_ONLINE;
char signon_status_msg[512] = {0};
CRITICAL_SECTION write_cs;
-char *zap_array[11] = {
- "zap", "whack", "torch", "smooch", "hug", "bslap", "goose", "hi-five", "punk'd", "raspberry", 0
-};
-
bool WriteData(char *fn, int fn_size, char *data, int data_size) {
char szTempPath[MAX_PATH], szTempFileName[MAX_PATH];
@@ -508,23 +504,8 @@ void __cdecl ServerThreadFunc(void*) {
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, (LPARAM)0);
} else if(strncmp(smsg, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_", 28) == 0) {
// recvd a zap
- int zapnum = smsg[28] - '0';
- char rmsg[512];
- mir_snprintf(rmsg, 512, Translate("You received a ZAP: %s"), Translate(zap_array[zapnum]));
-
- 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);
-
+ int zap_num = smsg[28] - '0';
+ NotifyZapRecv(hContact, zap_num);
}
}
}
@@ -732,12 +713,24 @@ void __cdecl ServerThreadFunc(void*) {
if(body.get_string("FriendRequest", b, 10)) {
NotifyFriendRequest();
}
+ if(body.get_string("PictureComment", b, 10)) {
+ NotifyPictureComment();
+ }
if(DBGetContactSettingByte(0, MODULE, "DebugMail", 0)) {
char pmsg[512];
for(LinkedList<KeyValue>::Iterator i = body.start(); i.has_val(); i.next()) {
KeyValue &kv = i.val();
- mir_snprintf(pmsg, 512, "%s = %s", kv.first.text, kv.second.text);
- PUShowMessage(pmsg, SM_NOTIFY);
+ if(
+ strcmp(kv.first.text, "BlogComment") != 0
+ && strcmp(kv.first.text, "Mail") != 0
+ && strcmp(kv.first.text, "ProfileComment") != 0
+ && strcmp(kv.first.text, "FriendRequest") != 0
+ && strcmp(kv.first.text, "PictureComment") != 0
+ && strcmp(kv.first.text, "€") != 0)
+ {
+ mir_snprintf(pmsg, 512, "%s = %s", kv.first.text, kv.second.text);
+ PUShowMessage(pmsg, SM_NOTIFY);
+ }
}
}
}
diff --git a/MySpace/server_con.h b/MySpace/server_con.h
index 4064744..c81ce07 100644
--- a/MySpace/server_con.h
+++ b/MySpace/server_con.h
@@ -25,6 +25,4 @@ typedef struct {
int uid;
} MYPROTOSEARCHRESULT;
-extern char *zap_array[];
-
#endif
diff --git a/MySpace/version.h b/MySpace/version.h
index 72f6e84..d9791f1 100644
--- a/MySpace/version.h
+++ b/MySpace/version.h
@@ -5,7 +5,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 0
#define __RELEASE_NUM 4
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM