From 808957a884ac8195484c2a7a662b99cc7a163b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Sat, 21 Feb 2015 23:49:11 +0000 Subject: Facebook: Add support for notifying ticker feeds updates; version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@12237 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/res/facebook.rc | 20 +++++++++++--------- protocols/FacebookRM/src/constants.h | 2 ++ protocols/FacebookRM/src/db.h | 1 + protocols/FacebookRM/src/dialogs.cpp | 3 +++ protocols/FacebookRM/src/events.cpp | 8 ++++++++ protocols/FacebookRM/src/json.cpp | 26 ++++++++++++++++---------- protocols/FacebookRM/src/proto.cpp | 11 +++++++++++ protocols/FacebookRM/src/resource.h | 1 + protocols/FacebookRM/src/version.h | 2 +- 9 files changed, 54 insertions(+), 20 deletions(-) (limited to 'protocols/FacebookRM') diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc index fc382dd072..1e0b5ec143 100644 --- a/protocols/FacebookRM/res/facebook.rc +++ b/protocols/FacebookRM/res/facebook.rc @@ -121,12 +121,12 @@ BEGIN CONTROL "Use bigger avatars",IDC_BIGGER_AVATARS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,120,271,10 END -IDD_OPTIONS_EVENTS DIALOGEX 0, 0, 305, 208 +IDD_OPTIONS_EVENTS DIALOGEX 0, 0, 305, 227 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - GROUPBOX "Event notifications",IDC_STATIC,6,7,292,113 + GROUPBOX "Event notifications",IDC_STATIC,6,7,292,126 CONTROL "Notifications",IDC_NOTIFICATIONS_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,23,272,8 CONTROL "News feeds (WARNING: Causes excessive network traffic!)",IDC_FEEDS_ENABLE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,37,272,8 @@ -136,13 +136,14 @@ BEGIN CONTROL "Other events",IDC_OTHER_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,75,272,8 CONTROL "Client notifications",IDC_CLIENT_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,89,272,8 CONTROL "Friendship notifications",IDC_FRIENDSHIP_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,104,272,8 - RTEXT "Use this server for opening links:",IDC_STATIC,13,131,139,8 - COMBOBOX IDC_URL_SERVER,156,128,138,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Ticker feeds",IDC_TICKER_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,119,272,8 + RTEXT "Use this server for opening links:",IDC_STATIC,13,148,139,8 + COMBOBOX IDC_URL_SERVER,156,145,138,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Use balloon notifications in system tray instead of popups",IDC_SYSTRAY_NOTIFY, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,150,272,8 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,167,272,8 CONTROL "Use logging notifications into special chatroom",IDC_NOTIFICATIONS_CHATROOM, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,164,272,8 - PUSHBUTTON "Preview",IDC_PREVIEW,116,182,68,14 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,181,272,8 + PUSHBUTTON "Preview",IDC_PREVIEW,116,199,68,14 END IDD_OPTIONS_STATUSES DIALOGEX 0, 0, 308, 226 @@ -262,7 +263,7 @@ BEGIN VERTGUIDE, 150 VERTGUIDE, 288 TOPMARGIN, 7 - BOTTOMMARGIN, 200 + BOTTOMMARGIN, 219 END IDD_OPTIONS_STATUSES, DIALOG @@ -303,7 +304,8 @@ END // // Generated from the TEXTINCLUDE 3 resource. // - + + ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED 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 . #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 . #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 . #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, "", ""))); + 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 -- cgit v1.2.3