summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-09-01 21:44:45 +0000
committerRobert Pösel <robyer@seznam.cz>2016-09-01 21:44:45 +0000
commit756ce057cf3aecb1220daebadb3f728f51ef5b5e (patch)
treeecf3dab8ccdc71bbfed18452077ed2769f6a7098 /protocols/FacebookRM
parent6c13e88bbfd39fe43ac732dde41672aead181819 (diff)
Facebook: Rework event notify type from defines and flags to enum
git-svn-id: http://svn.miranda-ng.org/main/trunk@17240 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r--protocols/FacebookRM/src/communication.cpp6
-rw-r--r--protocols/FacebookRM/src/constants.h19
-rw-r--r--protocols/FacebookRM/src/contacts.cpp12
-rw-r--r--protocols/FacebookRM/src/events.cpp36
-rw-r--r--protocols/FacebookRM/src/json.cpp6
-rw-r--r--protocols/FacebookRM/src/process.cpp10
-rw-r--r--protocols/FacebookRM/src/proto.cpp8
-rw-r--r--protocols/FacebookRM/src/proto.h2
8 files changed, 45 insertions, 54 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index f4fd7cf13d..a7002d41e1 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void facebook_client::client_notify(wchar_t* message)
{
- parent->NotifyEvent(parent->m_tszUserName, message, NULL, FACEBOOK_EVENT_CLIENT);
+ parent->NotifyEvent(parent->m_tszUserName, message, NULL, EVENT_CLIENT);
}
http::response facebook_client::flap(RequestType request_type, std::string *post_data, std::string *get_data)
@@ -1645,7 +1645,7 @@ bool facebook_client::post_status(status_data *status)
}
if (resp.isValid()) {
- parent->NotifyEvent(parent->m_tszUserName, TranslateT("Status update was successful."), NULL, FACEBOOK_EVENT_OTHER);
+ parent->NotifyEvent(parent->m_tszUserName, TranslateT("Status update was successful."), NULL, EVENT_OTHER);
return handle_success("post_status");
}
@@ -1716,6 +1716,6 @@ bool facebook_client::sms_code(const char *fb_dtsg)
return false;
}
- parent->NotifyEvent(parent->m_tszUserName, TranslateT("Verification SMS code was sent to your mobile phone."), NULL, FACEBOOK_EVENT_OTHER);
+ parent->NotifyEvent(parent->m_tszUserName, TranslateT("Verification SMS code was sent to your mobile phone."), NULL, EVENT_OTHER);
return true;
} \ No newline at end of file
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index dd389df257..058d0defec 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -105,15 +105,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEFAULT_EVENT_TICKER_ENABLE 0
#define DEFAULT_EVENT_ON_THIS_DAY_ENABLE 0
-// Event flags
-#define FACEBOOK_EVENT_CLIENT 0x10000000 // Facebook client errors
-#define FACEBOOK_EVENT_NEWSFEED 0x20000000 // Facebook newsfeed (wall) message
-#define FACEBOOK_EVENT_NOTIFICATION 0x40000000 // Facebook new notification
-#define FACEBOOK_EVENT_OTHER 0x80000000 // Facebook other event (poke sent, status update, ...)
-#define FACEBOOK_EVENT_FRIENDSHIP 0x01000000 // Facebook friendship event
-#define FACEBOOK_EVENT_TICKER 0x02000000 // Facebook ticker message
-#define FACEBOOK_EVENT_ON_THIS_DAY 0x04000000 // Facebook on this day posts
-
// Send message return values
#define SEND_MESSAGE_OK 0
#define SEND_MESSAGE_ERROR 1
@@ -197,6 +188,16 @@ enum MessageType {
THREAD_IMAGE = 8,
};
+enum EventType {
+ EVENT_CLIENT = 1, // Client error
+ EVENT_NEWSFEED = 2, // Newsfeed (wall) message
+ EVENT_NOTIFICATION = 3, // New notification
+ EVENT_OTHER = 4, // Other event (poke sent, status update, ...)
+ EVENT_FRIENDSHIP = 5, // Friendship event
+ EVENT_TICKER = 6, // Ticker message
+ EVENT_ON_THIS_DAY = 7, // On this day post (memories)
+};
+
enum ParticipantRole {
ROLE_ME = 0,
ROLE_FRIEND = 1,
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index cb67ff7a0f..771198c361 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -532,7 +532,7 @@ void FacebookProto::DeleteContactFromServer(void *data)
setDword(hContact, FACEBOOK_KEY_DELETED, ::time(NULL));
}
- NotifyEvent(m_tszUserName, TranslateT("Contact was removed from your server list."), NULL, FACEBOOK_EVENT_FRIENDSHIP);
+ NotifyEvent(m_tszUserName, TranslateT("Contact was removed from your server list."), NULL, EVENT_FRIENDSHIP);
}
else {
facy.client_notify(TranslateT("Error occurred when removing contact from server."));
@@ -570,7 +570,7 @@ void FacebookProto::AddContactToServer(void *data)
if (hContact != NULL)
setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_REQUEST);
- NotifyEvent(m_tszUserName, TranslateT("Request for friendship was sent."), NULL, FACEBOOK_EVENT_FRIENDSHIP);
+ NotifyEvent(m_tszUserName, TranslateT("Request for friendship was sent."), NULL, EVENT_FRIENDSHIP);
}
else facy.client_notify(TranslateT("Error occurred when requesting friendship."));
@@ -606,7 +606,7 @@ void FacebookProto::ApproveContactToServer(void *data)
if (resp.data.find("\"success\":true") != std::string::npos)
{
setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_FRIEND);
- NotifyEvent(m_tszUserName, TranslateT("Request for friendship was accepted."), NULL, FACEBOOK_EVENT_FRIENDSHIP);
+ NotifyEvent(m_tszUserName, TranslateT("Request for friendship was accepted."), NULL, EVENT_FRIENDSHIP);
}
else facy.client_notify(TranslateT("Error occurred when accepting friendship request."));
@@ -642,7 +642,7 @@ void FacebookProto::CancelFriendsRequest(void *data)
if (resp.data.find("\"payload\":null", 0) != std::string::npos)
{
setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE);
- NotifyEvent(m_tszUserName, TranslateT("Request for friendship was canceled."), NULL, FACEBOOK_EVENT_FRIENDSHIP);
+ NotifyEvent(m_tszUserName, TranslateT("Request for friendship was canceled."), NULL, EVENT_FRIENDSHIP);
}
else facy.client_notify(TranslateT("Error occurred when canceling friendship request."));
@@ -678,7 +678,7 @@ void FacebookProto::IgnoreFriendshipRequest(void *data)
if (resp.data.find("\"success\":true") != std::string::npos)
{
setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE);
- NotifyEvent(m_tszUserName, TranslateT("Request for friendship was ignored."), NULL, FACEBOOK_EVENT_FRIENDSHIP);
+ NotifyEvent(m_tszUserName, TranslateT("Request for friendship was ignored."), NULL, EVENT_FRIENDSHIP);
// Delete this contact, if he's temporary
if (db_get_b(hContact, "CList", "NotOnList", 0))
@@ -726,7 +726,7 @@ void FacebookProto::SendPokeWorker(void *p)
utils::text::remove_html(message));
ptrW tmessage(mir_utf8decodeW(message.c_str()));
- NotifyEvent(m_tszUserName, tmessage, NULL, FACEBOOK_EVENT_OTHER);
+ NotifyEvent(m_tszUserName, tmessage, NULL, EVENT_OTHER);
}
facy.handle_success("SendPokeWorker");
diff --git a/protocols/FacebookRM/src/events.cpp b/protocols/FacebookRM/src/events.cpp
index be0306148f..069baa3806 100644
--- a/protocols/FacebookRM/src/events.cpp
+++ b/protocols/FacebookRM/src/events.cpp
@@ -3,7 +3,7 @@
Facebook plugin for Miranda Instant Messenger
_____________________________________________
-Copyright © 2009-11 Michal Zelinka, 2011-16 Robert Pösel
+Copyright � 2009-11 Michal Zelinka, 2011-16 Robert P�sel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,52 +22,45 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-HWND FacebookProto::NotifyEvent(wchar_t* title, wchar_t* info, MCONTACT contact, DWORD flags, std::string *url, std::string *notification_id, const char *icon)
+HWND FacebookProto::NotifyEvent(wchar_t* title, wchar_t* info, MCONTACT contact, EventType type, std::string *url, std::string *notification_id, const char *icon)
{
if (title == NULL || info == NULL)
return NULL;
char name[256];
- switch (flags)
+ switch (type)
{
- case FACEBOOK_EVENT_CLIENT:
+ case EVENT_CLIENT:
mir_snprintf(name, "%s_%s", m_szModuleName, "Client");
- flags |= NIIF_WARNING;
break;
- case FACEBOOK_EVENT_NEWSFEED:
+ case EVENT_NEWSFEED:
mir_snprintf(name, "%s_%s", m_szModuleName, "Newsfeed");
- flags |= NIIF_INFO;
break;
- case FACEBOOK_EVENT_NOTIFICATION:
+ case EVENT_NOTIFICATION:
mir_snprintf(name, "%s_%s", m_szModuleName, "Notification");
SkinPlaySound("Notification");
- flags |= NIIF_INFO;
break;
- case FACEBOOK_EVENT_OTHER:
+ case EVENT_OTHER:
mir_snprintf(name, "%s_%s", m_szModuleName, "Other");
SkinPlaySound("OtherEvent");
- flags |= NIIF_INFO;
break;
- case FACEBOOK_EVENT_FRIENDSHIP:
+ case EVENT_FRIENDSHIP:
mir_snprintf(name, "%s_%s", m_szModuleName, "Friendship");
SkinPlaySound("Friendship");
- flags |= NIIF_INFO;
break;
- case FACEBOOK_EVENT_TICKER:
+ case EVENT_TICKER:
mir_snprintf(name, "%s_%s", m_szModuleName, "Ticker");
SkinPlaySound("Ticker");
- flags |= NIIF_INFO;
break;
- case FACEBOOK_EVENT_ON_THIS_DAY:
+ case EVENT_ON_THIS_DAY:
mir_snprintf(name, "%s_%s", m_szModuleName, "Memories");
- flags |= NIIF_INFO;
break;
}
@@ -107,22 +100,19 @@ HWND FacebookProto::NotifyEvent(wchar_t* title, wchar_t* info, MCONTACT contact,
if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY))
{
MIRANDASYSTRAYNOTIFY err;
- int niif_flags = flags;
-
- niif_flags = niif_flags & ~(FACEBOOK_EVENT_CLIENT | FACEBOOK_EVENT_NEWSFEED | FACEBOOK_EVENT_NOTIFICATION | FACEBOOK_EVENT_OTHER | FACEBOOK_EVENT_FRIENDSHIP);
-
err.szProto = m_szModuleName;
err.cbSize = sizeof(err);
- err.dwInfoFlags = NIIF_INTERN_UNICODE | niif_flags;
+ err.dwInfoFlags = NIIF_INTERN_UNICODE | (type == EVENT_CLIENT ? NIIF_WARNING : NIIF_INFO);
err.tszInfoTitle = title;
err.tszInfo = info;
err.uTimeout = 10000;
+
if (CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&err) == 0)
return NULL;
}
}
- if ((flags & FACEBOOK_EVENT_CLIENT) == FACEBOOK_EVENT_CLIENT)
+ if (type == EVENT_CLIENT)
MessageBox(NULL, info, title, MB_OK | MB_ICONERROR);
return NULL;
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index c79ad14716..493569346f 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -656,7 +656,7 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
// Notify it, if user wants to be notified
if (proto->getByte(FACEBOOK_KEY_EVENT_FRIENDSHIP_ENABLE, DEFAULT_EVENT_FRIENDSHIP_ENABLE)) {
- proto->NotifyEvent(proto->m_tszUserName, ptrW(mir_utf8decodeW(text.c_str())), NULL, FACEBOOK_EVENT_FRIENDSHIP, &url, alert_id.empty() ? NULL : &alert_id);
+ proto->NotifyEvent(proto->m_tszUserName, ptrW(mir_utf8decodeW(text.c_str())), NULL, EVENT_FRIENDSHIP, &url, alert_id.empty() ? NULL : &alert_id);
}
}
}
@@ -855,7 +855,7 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
std::string contactname = getContactName(this, fbu->handle, !fbu->real_name.empty() ? fbu->real_name.c_str() : fbu->user_id.c_str());
ptrW szTitle(mir_utf8decodeW(contactname.c_str()));
- NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), fbu->handle, FACEBOOK_EVENT_FRIENDSHIP, &url);
+ NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), fbu->handle, EVENT_FRIENDSHIP, &url);
} */
@@ -963,7 +963,7 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
proto->debugLogA("+++ Got ticker type='%s' class='%s'", story_type.c_str(), story_class.c_str());
if (!text.empty())
- proto->NotifyEvent(proto->m_tszUserName, ptrW(mir_utf8decodeW(text.c_str())), hContact, FACEBOOK_EVENT_TICKER, &url);
+ proto->NotifyEvent(proto->m_tszUserName, ptrW(mir_utf8decodeW(text.c_str())), hContact, EVENT_TICKER, &url);
}
else if (t == "mercury") {
// rename multi user chat, video call, ...
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index b6c4f1b709..4f1423a65e 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -134,7 +134,7 @@ void FacebookProto::ProcessFriendList(void*)
std::string contactname = getContactName(this, hContact, !fbu->real_name.empty() ? fbu->real_name.c_str() : fbu->user_id.c_str());
ptrW szTitle(mir_utf8decodeW(contactname.c_str()));
- NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), hContact, FACEBOOK_EVENT_FRIENDSHIP, &url);
+ NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), hContact, EVENT_FRIENDSHIP, &url);
}
}
@@ -158,7 +158,7 @@ void FacebookProto::ProcessFriendList(void*)
std::string contactname = getContactName(this, hContact, id);
ptrW szTitle(mir_utf8decodeW(contactname.c_str()));
- NotifyEvent(szTitle, TranslateT("Contact is no longer on server-list."), hContact, FACEBOOK_EVENT_FRIENDSHIP, &url);
+ NotifyEvent(szTitle, TranslateT("Contact is no longer on server-list."), hContact, EVENT_FRIENDSHIP, &url);
}
}
}
@@ -844,7 +844,7 @@ void FacebookProto::ProcessMemories(void*)
ptrW tszTitle(mir_utf8decodeW(news[i]->title.c_str()));
ptrW tszText(mir_utf8decodeW(news[i]->text.c_str()));
- NotifyEvent(TranslateT("On this day"), tszText, NULL, FACEBOOK_EVENT_ON_THIS_DAY, &news[i]->link);
+ NotifyEvent(TranslateT("On this day"), tszText, NULL, EVENT_ON_THIS_DAY, &news[i]->link);
delete news[i];
}
news.clear();
@@ -1133,7 +1133,7 @@ void FacebookProto::ShowNotifications() {
debugLogA(" Showing popup for notification ID: %s", notification->id.c_str());
ptrW szText(mir_utf8decodeW(notification->text.c_str()));
MCONTACT hContact = (notification->user_id.empty() ? NULL : ContactIDToHContact(notification->user_id));
- notification->hWndPopup = NotifyEvent(m_tszUserName, szText, hContact, FACEBOOK_EVENT_NOTIFICATION, &notification->link, &notification->id, notification->icon);
+ notification->hWndPopup = NotifyEvent(m_tszUserName, szText, hContact, EVENT_NOTIFICATION, &notification->link, &notification->id, notification->icon);
notification->seen = true;
}
}
@@ -1304,7 +1304,7 @@ void FacebookProto::ProcessFeeds(void*)
ptrW tszText(mir_utf8decodeW(news[i]->text.c_str()));
MCONTACT hContact = ContactIDToHContact(news[i]->user_id);
- NotifyEvent(tszTitle, tszText, hContact, FACEBOOK_EVENT_NEWSFEED, &news[i]->link);
+ NotifyEvent(tszTitle, tszText, hContact, EVENT_NEWSFEED, &news[i]->link);
delete news[i];
}
news.clear();
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index ea84b7033a..5cb8089e0c 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -643,7 +643,7 @@ INT_PTR FacebookProto::CheckNewsfeeds(WPARAM, LPARAM)
if (ctrlPressed) {
facy.last_feeds_update_ = 0;
}
- NotifyEvent(m_tszUserName, TranslateT("Loading wall posts..."), NULL, FACEBOOK_EVENT_OTHER);
+ NotifyEvent(m_tszUserName, TranslateT("Loading wall posts..."), NULL, EVENT_OTHER);
ForkThread(&FacebookProto::ProcessFeeds, NULL);
}
return 0;
@@ -652,7 +652,7 @@ INT_PTR FacebookProto::CheckNewsfeeds(WPARAM, LPARAM)
INT_PTR FacebookProto::CheckFriendRequests(WPARAM, LPARAM)
{
if (!isOffline()) {
- NotifyEvent(m_tszUserName, TranslateT("Loading friendship requests..."), NULL, FACEBOOK_EVENT_OTHER);
+ NotifyEvent(m_tszUserName, TranslateT("Loading friendship requests..."), NULL, EVENT_OTHER);
ForkThread(&FacebookProto::ProcessFriendRequests, NULL);
}
return 0;
@@ -661,7 +661,7 @@ INT_PTR FacebookProto::CheckFriendRequests(WPARAM, LPARAM)
INT_PTR FacebookProto::CheckNotifications(WPARAM, LPARAM)
{
if (!isOffline()) {
- NotifyEvent(m_tszUserName, TranslateT("Loading notifications..."), NULL, FACEBOOK_EVENT_OTHER);
+ NotifyEvent(m_tszUserName, TranslateT("Loading notifications..."), NULL, EVENT_OTHER);
ForkThread(&FacebookProto::ProcessNotifications, NULL);
}
return 0;
@@ -670,7 +670,7 @@ INT_PTR FacebookProto::CheckNotifications(WPARAM, LPARAM)
INT_PTR FacebookProto::CheckMemories(WPARAM, LPARAM)
{
if (!isOffline()) {
- NotifyEvent(m_tszUserName, TranslateT("Loading memories..."), NULL, FACEBOOK_EVENT_OTHER);
+ NotifyEvent(m_tszUserName, TranslateT("Loading memories..."), NULL, EVENT_OTHER);
ForkThread(&FacebookProto::ProcessMemories, NULL);
}
return 0;
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index 585b3e93d4..823a516ae4 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -261,6 +261,6 @@ public:
static void CALLBACK APC_callback(ULONG_PTR p);
// Information providing
- HWND NotifyEvent(wchar_t* title, wchar_t* info, MCONTACT contact, DWORD flags, std::string *url = NULL, std::string *notification_id = NULL, const char *icon = NULL);
+ HWND NotifyEvent(wchar_t* title, wchar_t* info, MCONTACT contact, EventType type, std::string *url = NULL, std::string *notification_id = NULL, const char *icon = NULL);
void ShowNotifications();
};