From e40a3421da567a02a69249e2486420bec3c4cc44 Mon Sep 17 00:00:00 2001 From: sje Date: Wed, 11 Jul 2007 03:29:01 +0000 Subject: added sounds for zaps added 'PictureComment' notification removed known notification types from mail message debug info git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@272 4f64403b-2f21-0410-a795-97e2b3489a10 --- MySpace/notifications.cpp | 141 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 129 insertions(+), 12 deletions(-) (limited to 'MySpace/notifications.cpp') 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 +#include #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)⪯ + 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); } + -- cgit v1.2.3