summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-07-05 17:58:47 +0000
committerRobert Pösel <robyer@seznam.cz>2016-07-05 17:58:47 +0000
commitec473b50196a5d04bd0fbcf67f465b5703b5138a (patch)
treea0032b99de071f70fb2ba225f9275365de2c10a3
parent21811cedec44836942fc07977634c868d9045cf5 (diff)
Facebook: Prepare for showing reaction icons for notifications (needs support in Popup+ and YAPP)
git-svn-id: http://svn.miranda-ng.org/main/trunk@17061 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/FacebookRM/src/entities.h19
-rw-r--r--protocols/FacebookRM/src/events.cpp5
-rw-r--r--protocols/FacebookRM/src/json.cpp4
-rw-r--r--protocols/FacebookRM/src/process.cpp2
-rw-r--r--protocols/FacebookRM/src/proto.h2
5 files changed, 29 insertions, 3 deletions
diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h
index 8cd50f590b..a12404de74 100644
--- a/protocols/FacebookRM/src/entities.h
+++ b/protocols/FacebookRM/src/entities.h
@@ -110,6 +110,7 @@ struct facebook_notification
std::string text;
std::string link;
std::string id;
+ const char *icon;
time_t time;
bool seen;
HWND hWndPopup;
@@ -120,6 +121,24 @@ struct facebook_notification
this->seen = false;
this->hWndPopup = NULL;
}
+
+ void setIcon(std::string iconUrl)
+ {
+ if (iconUrl == "https://www.facebook.com/rsrc.php/v2/yj/r/6WffvhOaXGY.png")
+ icon = "like";
+ else if (iconUrl == "https://www.facebook.com/rsrc.php/v2/y1/r/RvGKklgAefT.png")
+ icon = "love";
+ else if (iconUrl == "https://www.facebook.com/rsrc.php/v2/yV/r/McJA2ZjdJmf.png")
+ icon = "haha";
+ else if (iconUrl == "https://www.facebook.com/rsrc.php/v2/yL/r/IfsimazVjj4.png")
+ icon = "wow";
+ else if (iconUrl == "https://www.facebook.com/rsrc.php/v2/yH/r/jOeSrGlcPLG.png")
+ icon = "sad";
+ else if (iconUrl == "https://www.facebook.com/rsrc.php/v2/yL/r/IfsimazVjj4.png")
+ icon = "angry";
+ else
+ icon = NULL;
+ }
};
struct facebook_newsfeed
diff --git a/protocols/FacebookRM/src/events.cpp b/protocols/FacebookRM/src/events.cpp
index 0dc5ad458a..f52385f30b 100644
--- a/protocols/FacebookRM/src/events.cpp
+++ b/protocols/FacebookRM/src/events.cpp
@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-HWND FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, MCONTACT contact, DWORD flags, std::string *url, std::string *notification_id)
+HWND FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, MCONTACT contact, DWORD flags, std::string *url, std::string *notification_id, const char *icon)
{
if (title == NULL || info == NULL)
return NULL;
@@ -103,6 +103,9 @@ HWND FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, MCONTACT contact, DWO
pd.ptszText = info;
pd.pszClassName = name;
pd.hContact = contact;
+ if (icon != NULL) {
+ // pd.hIcon = IcoLib_GetIconByHandle(GetIconHandle(icon)); // FIXME: Uncomment when implemented in Popup+ and YAPP correctly
+ }
if (url != NULL || notification_id != NULL) {
popup_data *data = new popup_data(this);
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 376e5da431..c0c3e02845 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -135,6 +135,7 @@ int facebook_json_parser::parse_notifications(std::string *data, std::map< std::
const JSONNode &time_ = (*it)["timestamp"]["time"];
const JSONNode &text_ = (*it)["title"]["text"];
const JSONNode &url_ = (*it)["url"];
+ const JSONNode &icon_ = (*it)["icon"]["uri"];
// Ignore empty and old notifications
if (!text_ || !state_ || state_.as_string() == "SEEN_AND_READ" || !time_)
@@ -152,6 +153,7 @@ int facebook_json_parser::parse_notifications(std::string *data, std::map< std::
notification->link = url_.as_string();
notification->text = utils::text::html_entities_decode(utils::text::slashu_to_utf8(text_.as_string()));
notification->time = utils::time::from_string(time_.as_string());
+ notification->setIcon(icon_.as_string());
// Write notification to chatroom
proto->UpdateNotificationsChatRoom(notification);
@@ -522,6 +524,7 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
const JSONNode &text = text_["text"];
const JSONNode &url = (*itNodes)["url"];
const JSONNode &alert_id = (*itNodes)["alert_id"];
+ const JSONNode &icon_ = (*itNodes)["icon"]["uri"];
const JSONNode &time_ = (*itNodes)["timestamp"];
if (!time_)
@@ -540,6 +543,7 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
notification->link = url.as_string();
notification->id = alert_id.as_string();
notification->time = timestamp;
+ notification->setIcon(icon_.as_string());
// Fix notification ID
std::string::size_type pos = notification->id.find(":");
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index 313c365dc8..2a4cf0597a 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -928,7 +928,7 @@ void FacebookProto::ShowNotifications() {
debugLogA(" Showing popup for notification ID: %s", notification->id.c_str());
ptrT szText(mir_utf8decodeT(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->hWndPopup = NotifyEvent(m_tszUserName, szText, hContact, FACEBOOK_EVENT_NOTIFICATION, &notification->link, &notification->id, notification->icon);
notification->seen = true;
}
}
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index e7e3fa851c..06e0dae590 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -256,6 +256,6 @@ public:
static void CALLBACK APC_callback(ULONG_PTR p);
// Information providing
- HWND NotifyEvent(TCHAR* title, TCHAR* info, MCONTACT contact, DWORD flags, std::string *url = NULL, std::string *notification_id = NULL);
+ HWND NotifyEvent(TCHAR* title, TCHAR* info, MCONTACT contact, DWORD flags, std::string *url = NULL, std::string *notification_id = NULL, const char *icon = NULL);
void ShowNotifications();
};