summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r--protocols/FacebookRM/src/constants.h2
-rw-r--r--protocols/FacebookRM/src/db.h1
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp3
-rw-r--r--protocols/FacebookRM/src/events.cpp8
-rw-r--r--protocols/FacebookRM/src/json.cpp26
-rw-r--r--protocols/FacebookRM/src/proto.cpp11
-rw-r--r--protocols/FacebookRM/src/resource.h1
-rw-r--r--protocols/FacebookRM/src/version.h2
8 files changed, 43 insertions, 11 deletions
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index f57d665e09..89576afe3d 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -93,6 +93,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEFAULT_EVENT_OTHER_ENABLE 1
#define DEFAULT_EVENT_CLIENT_ENABLE 1
#define DEFAULT_EVENT_FRIENDSHIP_ENABLE 1
+#define DEFAULT_EVENT_TICKER_ENABLE 0
// Event flags
#define FACEBOOK_EVENT_CLIENT 0x10000000 // Facebook error or info message
@@ -100,6 +101,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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
// Send message return values
#define SEND_MESSAGE_OK 0
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h
index d1c565e6a1..f5c4c22f14 100644
--- a/protocols/FacebookRM/src/db.h
+++ b/protocols/FacebookRM/src/db.h
@@ -73,6 +73,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_KEY_EVENT_OTHER_ENABLE "EventOtherEnable"
#define FACEBOOK_KEY_EVENT_CLIENT_ENABLE "EventClientEnable"
#define FACEBOOK_KEY_EVENT_FRIENDSHIP_ENABLE "EventFriendshipEnable"
+#define FACEBOOK_KEY_EVENT_TICKER_ENABLE "EventTickerEnable"
#define FACEBOOK_KEY_FEED_TYPE "EventFeedsType"
// Hidden account DB keys (can't be changed through GUI)
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index bda685b08a..bdd9995d3a 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -512,6 +512,7 @@ INT_PTR CALLBACK FBOptionsEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPA
LoadDBCheckState(proto, hwnd, IDC_CLIENT_ENABLE, FACEBOOK_KEY_EVENT_CLIENT_ENABLE, DEFAULT_EVENT_CLIENT_ENABLE);
LoadDBCheckState(proto, hwnd, IDC_OTHER_ENABLE, FACEBOOK_KEY_EVENT_OTHER_ENABLE, DEFAULT_EVENT_OTHER_ENABLE);
LoadDBCheckState(proto, hwnd, IDC_FRIENDSHIP_ENABLE, FACEBOOK_KEY_EVENT_FRIENDSHIP_ENABLE, DEFAULT_EVENT_FRIENDSHIP_ENABLE);
+ LoadDBCheckState(proto, hwnd, IDC_TICKER_ENABLE, FACEBOOK_KEY_EVENT_TICKER_ENABLE, DEFAULT_EVENT_TICKER_ENABLE);
LoadDBCheckState(proto, hwnd, IDC_FILTER_ADS, FACEBOOK_KEY_FILTER_ADS, DEFAULT_FILTER_ADS);
} return TRUE;
@@ -525,6 +526,7 @@ INT_PTR CALLBACK FBOptionsEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPA
proto->NotifyEvent(proto->m_tszUserName, TranslateT("Sample newsfeed"), NULL, FACEBOOK_EVENT_NEWSFEED);
proto->NotifyEvent(proto->m_tszUserName, TranslateT("Sample notification"), NULL, FACEBOOK_EVENT_NOTIFICATION);
proto->NotifyEvent(proto->m_tszUserName, TranslateT("Sample friendship"), NULL, FACEBOOK_EVENT_FRIENDSHIP);
+ proto->NotifyEvent(proto->m_tszUserName, TranslateT("Sample ticker"), NULL, FACEBOOK_EVENT_TICKER);
break;
case IDC_FEED_TYPE:
case IDC_URL_SERVER:
@@ -551,6 +553,7 @@ INT_PTR CALLBACK FBOptionsEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPA
StoreDBCheckState(proto, hwnd, IDC_OTHER_ENABLE, FACEBOOK_KEY_EVENT_OTHER_ENABLE);
StoreDBCheckState(proto, hwnd, IDC_FRIENDSHIP_ENABLE, FACEBOOK_KEY_EVENT_FRIENDSHIP_ENABLE);
StoreDBCheckState(proto, hwnd, IDC_CLIENT_ENABLE, FACEBOOK_KEY_EVENT_CLIENT_ENABLE);
+ StoreDBCheckState(proto, hwnd, IDC_TICKER_ENABLE, FACEBOOK_KEY_EVENT_TICKER_ENABLE);
StoreDBCheckState(proto, hwnd, IDC_FILTER_ADS, FACEBOOK_KEY_FILTER_ADS);
}
} return TRUE;
diff --git a/protocols/FacebookRM/src/events.cpp b/protocols/FacebookRM/src/events.cpp
index db5f0fef22..5a2abf822f 100644
--- a/protocols/FacebookRM/src/events.cpp
+++ b/protocols/FacebookRM/src/events.cpp
@@ -69,6 +69,14 @@ HWND FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, MCONTACT contact, DWO
SkinPlaySound("Friendship");
flags |= NIIF_INFO;
break;
+
+ case FACEBOOK_EVENT_TICKER:
+ if (!getByte(FACEBOOK_KEY_EVENT_TICKER_ENABLE, DEFAULT_EVENT_TICKER_ENABLE))
+ return NULL;
+ mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Ticker");
+ SkinPlaySound("Ticker");
+ flags |= NIIF_INFO;
+ break;
}
if (!getByte(FACEBOOK_KEY_SYSTRAY_NOTIFY, DEFAULT_SYSTRAY_NOTIFY))
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index cd954ed1af..2ab50f0590 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -3,7 +3,7 @@
Facebook plugin for Miranda Instant Messenger
_____________________________________________
-Copyright © 2009-11 Michal Zelinka, 2011-15 Robert Pösel
+Copyright � 2009-11 Michal Zelinka, 2011-15 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
@@ -731,20 +731,26 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo
continue;
} else if (t == "ticker_update:home") {
JSONNODE *actor_ = json_get(it, "actor");
- JSONNODE *time_ = json_get(it, "time");
+ JSONNODE *time_ = json_get(it, "story_time");
JSONNODE *story_ = json_get(it, "story_xhp");
std::string text = json_as_pstring(story_);
- text = utils::text::slashu_to_utf8(text);
+ text = utils::text::html_entities_decode(utils::text::slashu_to_utf8(text));
- text = utils::text::trim(
- utils::text::html_entities_decode(
- utils::text::source_get_value(&text, 3, "<h5", ">", "</h5>")));
+ std::string url = utils::text::source_get_value(&text, 3, "\"tickerStoryLink\"", "href=\"", "\"");
+ std::string story_type = utils::text::source_get_value2(&text, "\"type\":\"", "\"");
+ std::string story_class = utils::text::source_get_value2(&text, "\"entstory_class\":\"", "\"");
- // TODO: notify ticker updates
- /* if (!text.empty()) {
- proto->NotifyEvent()
- }*/
+ text = utils::text::trim(utils::text::remove_html(text));
+
+ std::string userId = (actor_ != NULL ? json_as_pstring(actor_) : "");
+
+ MCONTACT hContact = proto->ContactIDToHContact(userId);
+
+ proto->debugLogA("+++ Got ticker type='%s' class='%s'", story_type.c_str(), story_class.c_str());
+
+ if (!text.empty())
+ proto->NotifyEvent(proto->m_tszUserName, ptrT(mir_utf8decodeT(text.c_str())), hContact, FACEBOOK_EVENT_TICKER, &url);
}
else if (t == "mercury") {
// rename multi user chat, video call, ...
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 3c010869fd..c8244b87e7 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -1036,6 +1036,17 @@ void FacebookProto::InitPopups()
ppc.colorText = RGB(255, 255, 255); // white
ppc.iSeconds = 0;
popupClasses.push_back(Popup_RegisterClass(&ppc));
+
+ // Ticker
+ mir_sntprintf(desc, SIZEOF(desc), _T("%s/%s"), m_tszUserName, TranslateT("Ticker feeds"));
+ mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Ticker");
+ ppc.ptszDescription = desc;
+ ppc.pszName = name;
+ ppc.hIcon = Skin_GetIconByHandle(GetIconHandle("newsfeed"));
+ ppc.colorBack = RGB(255, 255, 255); // white
+ ppc.colorText = RGB(0, 0, 0); // black
+ ppc.iSeconds = 0;
+ popupClasses.push_back(Popup_RegisterClass(&ppc));
}
/**
diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h
index bb897960a2..030806e8d2 100644
--- a/protocols/FacebookRM/src/resource.h
+++ b/protocols/FacebookRM/src/resource.h
@@ -42,6 +42,7 @@
#define IDC_LOGIN_SYNC 1046
#define IDC_ENABLE_CHATS 1047
#define IDC_FRIENDSHIP_ENABLE 1048
+#define IDC_TICKER_ENABLE 1049
#define IDC_SYSTRAY_NOTIFY 1098
#define IDC_PREVIEW 1099
#define IDC_NOTIFICATIONS_CHATROOM 1100
diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h
index 29f93c408a..2735e7c90f 100644
--- a/protocols/FacebookRM/src/version.h
+++ b/protocols/FacebookRM/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 2
#define __RELEASE_NUM 10
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>