diff options
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r-- | protocols/FacebookRM/src/entities.h | 19 | ||||
-rw-r--r-- | protocols/FacebookRM/src/events.cpp | 5 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 4 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.h | 2 |
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, ¬ification->link, ¬ification->id); + notification->hWndPopup = NotifyEvent(m_tszUserName, szText, hContact, FACEBOOK_EVENT_NOTIFICATION, ¬ification->link, ¬ification->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(); }; |