summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2015-06-05 07:37:27 +0000
committerRobert Pösel <robyer@seznam.cz>2015-06-05 07:37:27 +0000
commit7cdb740b6e7599cb626deb2161aa3ab07b252e51 (patch)
treeaeaf154b2c91e0070d3bf8465dec0673ffd7edb2 /protocols
parent894d04d09e39156eb2264fb49f2b24035bb16d09 (diff)
Facebook: New feature to notify "On this day" posts at login; version bump
Right now it notify at every login, max. last 20 posts. In future I'll probably add more options to limit number of posts and do it only one per day, etc. git-svn-id: http://svn.miranda-ng.org/main/trunk@14006 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/FacebookRM/res/facebook.rc28
-rw-r--r--protocols/FacebookRM/src/communication.cpp10
-rw-r--r--protocols/FacebookRM/src/connection.cpp6
-rw-r--r--protocols/FacebookRM/src/constants.h3
-rw-r--r--protocols/FacebookRM/src/db.h13
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp3
-rw-r--r--protocols/FacebookRM/src/events.cpp8
-rw-r--r--protocols/FacebookRM/src/process.cpp320
-rw-r--r--protocols/FacebookRM/src/proto.cpp19
-rw-r--r--protocols/FacebookRM/src/proto.h1
-rw-r--r--protocols/FacebookRM/src/resource.h153
-rw-r--r--protocols/FacebookRM/src/version.h28
12 files changed, 341 insertions, 251 deletions
diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc
index 6941a33008..5a7875fe32 100644
--- a/protocols/FacebookRM/res/facebook.rc
+++ b/protocols/FacebookRM/res/facebook.rc
@@ -126,23 +126,25 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Event notifications",IDC_STATIC,6,7,292,126
+ GROUPBOX "Event notifications",IDC_STATIC,6,7,292,137
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
- RTEXT "News feed types to notify:",IDC_STATIC,26,49,117,8
- COMBOBOX IDC_FEED_TYPE,150,47,138,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- CONTROL "Don't show advertising posts",IDC_FILTER_ADS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,150,65,138,8
- 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
- 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
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,36,272,8
+ RTEXT "News feed types to notify:",IDC_STATIC,26,48,117,8
+ COMBOBOX IDC_FEED_TYPE,150,46,138,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ CONTROL "Don't show advertising posts",IDC_FILTER_ADS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,150,63,138,8
+ CONTROL "Other events",IDC_OTHER_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,72,272,8
+ CONTROL "Client notifications",IDC_CLIENT_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,85,272,8
+ CONTROL "Friendship notifications",IDC_FRIENDSHIP_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,99,272,8
+ CONTROL "Ticker feeds",IDC_TICKER_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,113,272,8
+ CONTROL "Show ""On this day"" posts at login",IDC_ON_THIS_DAY_ENABLE,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,128,272,8
+ RTEXT "Use this server for opening links:",IDC_STATIC,13,154,139,8
+ COMBOBOX IDC_URL_SERVER,156,151,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,167,272,8
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,170,272,8
CONTROL "Use logging notifications into special chatroom",IDC_NOTIFICATIONS_CHATROOM,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,181,272,8
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,184,272,8
PUSHBUTTON "Preview",IDC_PREVIEW,116,199,68,14
END
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 1bc95ff696..fde25c036f 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -261,6 +261,7 @@ std::string facebook_client::choose_server(RequestType request_type)
// case REQUEST_CANCEL_FRIENDSHIP:
// case REQUEST_FRIENDSHIP:
// case REQUEST_UNREAD_THREADS:
+ // case REQUEST_ON_THIS_DAY:
default:
return FACEBOOK_SERVER_REGULAR;
}
@@ -488,6 +489,15 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
case REQUEST_TYPING_SEND:
return "/ajax/messaging/typ.php?__a=1";
+ case REQUEST_ON_THIS_DAY:
+ {
+ std::string action = "/onthisday/story/query/?__a=1";
+ if (get_data != NULL) {
+ action += "&" + (*get_data);
+ }
+ return action;
+ }
+
default:
return "/?_fb_noscript=1";
}
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp
index 57070cd827..ec68c4c4ad 100644
--- a/protocols/FacebookRM/src/connection.cpp
+++ b/protocols/FacebookRM/src/connection.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
@@ -124,6 +124,10 @@ void FacebookProto::ChangeStatus(void*)
// Load pages for post status dialog
ForkThread(&FacebookProto::ProcessPages, NULL);
+ // Load on this day posts
+ if (getByte(FACEBOOK_KEY_EVENT_ON_THIS_DAY_ENABLE, DEFAULT_EVENT_ON_THIS_DAY_ENABLE))
+ ForkThread(&FacebookProto::ProcessOnThisDay, NULL);
+
setDword(FACEBOOK_KEY_LOGON_TS, (DWORD)time(NULL));
ForkThread(&FacebookProto::UpdateLoop, NULL);
ForkThread(&FacebookProto::MessageLoop, NULL);
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index ebb3e995df..b353049c24 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -96,6 +96,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEFAULT_EVENT_CLIENT_ENABLE 1
#define DEFAULT_EVENT_FRIENDSHIP_ENABLE 1
#define DEFAULT_EVENT_TICKER_ENABLE 0
+#define DEFAULT_EVENT_ON_THIS_DAY_ENABLE 0
// Event flags
#define FACEBOOK_EVENT_CLIENT 0x10000000 // Facebook error or info message
@@ -104,6 +105,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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
@@ -129,6 +131,7 @@ enum RequestType {
REQUEST_NOTIFICATIONS, // getting notifications
REQUEST_LOAD_FRIENDSHIPS, // getting friendship requests
REQUEST_PAGES, // getting pages list
+ REQUEST_ON_THIS_DAY, // getting on this day posts
REQUEST_POST_STATUS, // posting status to our or friends's wall
REQUEST_LINK_SCRAPER, // getting data for some url link
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h
index dde49edca6..c261ecbbf5 100644
--- a/protocols/FacebookRM/src/db.h
+++ b/protocols/FacebookRM/src/db.h
@@ -70,12 +70,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Account DB keys - notifications
#define FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE "EventNotificationsEnable"
-#define FACEBOOK_KEY_EVENT_FEEDS_ENABLE "EventFeedsEnable"
-#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"
+#define FACEBOOK_KEY_EVENT_FEEDS_ENABLE "EventFeedsEnable"
+#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_EVENT_ON_THIS_DAY_ENABLE "EventOnThisDayEnable"
+#define FACEBOOK_KEY_FEED_TYPE "EventFeedsType"
// Hidden account DB keys (can't be changed through GUI)
#define FACEBOOK_KEY_POLL_RATE "PollRate" // [HIDDEN] - (byte)
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index 771adf60bd..210a449644 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -513,6 +513,7 @@ INT_PTR CALLBACK FBOptionsEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPA
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_ON_THIS_DAY_ENABLE, FACEBOOK_KEY_EVENT_ON_THIS_DAY_ENABLE, DEFAULT_EVENT_ON_THIS_DAY_ENABLE);
LoadDBCheckState(proto, hwnd, IDC_FILTER_ADS, FACEBOOK_KEY_FILTER_ADS, DEFAULT_FILTER_ADS);
} return TRUE;
@@ -527,6 +528,7 @@ INT_PTR CALLBACK FBOptionsEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPA
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);
+ proto->NotifyEvent(proto->m_tszUserName, TranslateT("Sample on this day"), NULL, FACEBOOK_EVENT_ON_THIS_DAY);
break;
case IDC_FEED_TYPE:
case IDC_URL_SERVER:
@@ -554,6 +556,7 @@ INT_PTR CALLBACK FBOptionsEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPA
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_ON_THIS_DAY_ENABLE, FACEBOOK_KEY_EVENT_ON_THIS_DAY_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 624a9e9a84..f9ac580a23 100644
--- a/protocols/FacebookRM/src/events.cpp
+++ b/protocols/FacebookRM/src/events.cpp
@@ -77,6 +77,14 @@ HWND FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, MCONTACT contact, DWO
SkinPlaySound("Ticker");
flags |= NIIF_INFO;
break;
+
+ case FACEBOOK_EVENT_ON_THIS_DAY:
+ if (!getByte(FACEBOOK_KEY_EVENT_ON_THIS_DAY_ENABLE, DEFAULT_EVENT_ON_THIS_DAY_ENABLE))
+ return NULL;
+ mir_snprintf(name, "%s_%s", m_szModuleName, "OnThisDay");
+ SkinPlaySound("OnThisDay");
+ flags |= NIIF_INFO;
+ break;
}
if (!getByte(FACEBOOK_KEY_SYSTRAY_NOTIFY, DEFAULT_SYSTRAY_NOTIFY))
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index e798d007d2..b3a700e230 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.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
@@ -620,6 +620,184 @@ void FacebookProto::SyncThreads(void*)
facy.handle_success("SyncThreads");
}
+void parseFeeds(const std::string &text, std::vector<facebook_newsfeed *> &news, DWORD &last_post_time, bool filterAds = true) {
+ std::string::size_type pos = 0;
+ UINT limit = 0;
+
+ DWORD new_time = last_post_time;
+
+ while ((pos = text.find("<div class=\"userContentWrapper", pos)) != std::string::npos && limit <= 25)
+ {
+ /*std::string::size_type pos2 = text.find("<div class=\"userContentWrapper", pos+5);
+ if (pos2 == std::string::npos)
+ pos2 = text.length();
+
+ std::string post = text.substr(pos, pos2 - pos);*/
+ std::string post = text.substr(pos, text.find("</form>", pos) - pos);
+ pos += 5;
+
+ std::string post_header = utils::text::source_get_value(&post, 3, "<h5", ">", "</h5>");
+ std::string post_message = utils::text::source_get_value(&post, 3, " userContent\"", ">", "<form");
+ std::string post_link = utils::text::source_get_value(&post, 4, "</h5>", "<a", "href=\"", "\"");
+ //std::string post_attach = utils::text::source_get_value(&post, 4, "<div class=", "uiStreamAttachments", ">", "<form");
+
+ std::string post_time = utils::text::source_get_value(&post, 3, "</h5>", "<abbr", "</a>");
+
+ std::string time = utils::text::source_get_value(&post_time, 2, "data-utime=\"", "\"");
+ std::string time_text = utils::text::source_get_value(&post_time, 2, ">", "</abbr>");
+
+ if (time.empty()) {
+ // alternative parsing (probably page like or advertisement)
+ time = utils::text::source_get_value(&post, 2, "content_timestamp&quot;:&quot;", "&quot;");
+ }
+
+ DWORD ttime;
+ if (!utils::conversion::from_string<DWORD>(ttime, time, std::dec)) {
+ //debugLogA("!!! - Newsfeed with wrong/empty time (probably wrong parsing)\n%s", post.c_str());
+ continue;
+ }
+
+ if (ttime > new_time) {
+ new_time = ttime; // remember newest time from all these posts
+ //debugLogA(" - Newsfeed time: %d (new)", ttime);
+ }
+ else if (ttime <= last_post_time) {
+ //debugLogA(" - Newsfeed time: %d (ignored)", ttime);
+ continue; // ignore posts older than newest post of previous check
+ }
+ else {
+ //debugLogA(" - Newsfeed time: %d (normal)", ttime);
+ }
+
+ std::string post_place = utils::text::source_get_value(&post, 4, "</abbr>", "<a", ">", "</a>");
+
+ std::string premsg = "\n" + time_text;
+
+ post_place = utils::text::trim(
+ utils::text::remove_html(post_place));
+ if (!post_place.empty()) {
+ premsg += " - " + post_place;
+ }
+ premsg += "\n";
+
+ // in title keep only name, end of events like "X shared link" put into message
+ std::string::size_type pos2 = post_header.find("?");
+
+ if (pos2 != std::string::npos) {
+ utils::text::replace_first(&post_header, "?", " � ");
+ }
+ else {
+ pos2 = post_header.find("</a></");
+ if (pos2 != std::string::npos) {
+ pos2 += 4;
+ std::string a = utils::text::trim(utils::text::remove_html(post_header.substr(pos2, post_header.length() - pos2)));
+ if (a.length() > 2)
+ premsg += a;
+ post_header = post_header.substr(0, pos2);
+ }
+ }
+
+ // Strip "Translate" link
+ pos2 = post_message.find("role=\"button\">");
+ if (pos2 != std::string::npos) {
+ post_message = post_message.substr(0, pos2 + 14);
+ }
+
+ post_message = premsg + post_message;
+
+ // append attachement to message (if any)
+ //post_message += utils::text::trim(post_attach);
+
+ facebook_newsfeed* nf = new facebook_newsfeed;
+
+ nf->title = utils::text::trim(
+ utils::text::html_entities_decode(
+ utils::text::remove_html(post_header)));
+
+ nf->user_id = utils::text::source_get_value(&post_header, 2, "user.php?id=", "&amp;");
+
+ nf->link = utils::text::html_entities_decode(post_link);
+
+ // Check if we don't want to show ads posts
+ bool filtered = filterAds && (nf->link.find("/about/ads") != std::string::npos
+ || post.find("class=\"uiStreamSponsoredLink\"") != std::string::npos
+ || post.find("href=\"/about/ads\"") != std::string::npos);
+
+ nf->text = utils::text::trim(
+ utils::text::html_entities_decode(
+ utils::text::remove_html(
+ utils::text::edit_html(post_message))));
+
+ if (filtered || nf->title.empty() || nf->text.empty()) {
+ //debugLogA(" \\ Newsfeed (time: %d) is filtered: %s", ttime, filtered ? "advertisement" : (nf->title.empty() ? "title empty" : "text empty"));
+ delete nf;
+ continue;
+ }
+ else {
+ //debugLogA(" Got newsfeed (time: %d)", ttime);
+ }
+
+ news.push_back(nf);
+ pos++;
+ limit++;
+ }
+
+ last_post_time = new_time;
+}
+
+void FacebookProto::ProcessOnThisDay(void*)
+{
+ if (isOffline() || !getBool(FACEBOOK_KEY_EVENT_ON_THIS_DAY_ENABLE, DEFAULT_EVENT_ON_THIS_DAY_ENABLE))
+ return;
+
+ facy.handle_entry(__FUNCTION__);
+
+ time_t timestamp = ::time(NULL);
+
+ std::string get_data = "&start_index=0&num_stories=20&last_section_header=0";
+ get_data += "&timestamp=" + utils::conversion::to_string((void*)&timestamp, UTILS_CONV_TIME_T);
+ get_data += "&__dyn=&__req=&__rev=&__user=" + facy.self_.user_id;
+
+ http::response resp = facy.flap(REQUEST_ON_THIS_DAY, NULL, &get_data);
+
+ if (resp.code != HTTP_CODE_OK) {
+ facy.handle_error(__FUNCTION__);
+ return;
+ }
+
+ std::string jsonData = resp.data.substr(9);
+ JSONNode root = JSONNode::parse(jsonData.c_str());
+ if (root) {
+ const JSONNode &html_ = root["domops"].at((json_index_t)0).at((json_index_t)3).at("__html");
+ if (html_) {
+ std::string html = utils::text::html_entities_decode(utils::text::slashu_to_utf8(html_.as_string()));
+
+ std::vector<facebook_newsfeed *> news;
+ DWORD new_time = 0;
+
+ parseFeeds(html, news, new_time, true);
+
+ debugLogA(" Last feeds update (new): %d", new_time);
+
+ for (std::vector<facebook_newsfeed*>::size_type i = 0; i < news.size(); i++)
+ {
+ // Truncate text of newsfeed when it's too long
+ std::tstring text = ptrT(mir_utf8decodeT(news[i]->text.c_str()));
+ if (text.length() > MAX_NEWSFEED_LEN)
+ text = text.substr(0, MAX_NEWSFEED_LEN) + _T("...");
+
+ ptrT tszTitle(mir_utf8decodeT(news[i]->title.c_str()));
+ ptrT tszText(mir_tstrdup(text.c_str()));
+
+ NotifyEvent(TranslateT("On this day"), tszText, NULL, FACEBOOK_EVENT_ON_THIS_DAY, &news[i]->link);
+ delete news[i];
+ }
+ news.clear();
+ }
+ }
+
+ facy.handle_success(__FUNCTION__);
+}
void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, bool check_duplicates)
{
@@ -1022,137 +1200,11 @@ void FacebookProto::ProcessFeeds(void*)
return;
}
- CODE_BLOCK_TRY
-
- debugLogA("*** Starting processing feeds");
-
- std::vector< facebook_newsfeed* > news;
-
- std::string::size_type pos = 0;
- UINT limit = 0;
-
+ std::vector<facebook_newsfeed *> news;
DWORD new_time = facy.last_feeds_update_;
bool filterAds = getBool(FACEBOOK_KEY_FILTER_ADS, DEFAULT_FILTER_ADS);
- debugLogA(" Last feeds update (old): %d", facy.last_feeds_update_);
-
- while ((pos = resp.data.find("<div class=\"userContentWrapper", pos)) != std::string::npos && limit <= 25)
- {
- /*std::string::size_type pos2 = resp.data.find("<div class=\"userContentWrapper", pos+5);
- if (pos2 == std::string::npos)
- pos2 = resp.data.length();
-
- std::string post = resp.data.substr(pos, pos2 - pos);*/
- std::string post = resp.data.substr(pos, resp.data.find("</form>", pos) - pos);
- pos += 5;
-
- std::string post_header = utils::text::source_get_value(&post, 3, "<h5", ">", "</h5>");
- std::string post_message = utils::text::source_get_value(&post, 3, " userContent\"", ">", "<form");
- std::string post_link = utils::text::source_get_value(&post, 4, "</h5>", "<a", "href=\"", "\"");
- //std::string post_attach = utils::text::source_get_value(&post, 4, "<div class=", "uiStreamAttachments", ">", "<form");
-
- std::string post_time = utils::text::source_get_value(&post, 3, "</h5>", "<abbr", "</a>");
-
- std::string time = utils::text::source_get_value(&post_time, 2, "data-utime=\"", "\"");
- std::string time_text = utils::text::source_get_value(&post_time, 2, ">", "</abbr>");
-
- if (time.empty()) {
- // alternative parsing (probably page like or advertisement)
- time = utils::text::source_get_value(&post, 2, "content_timestamp&quot;:&quot;", "&quot;");
- }
-
- DWORD ttime;
- if (!utils::conversion::from_string<DWORD>(ttime, time, std::dec)) {
- debugLogA("!!! - Newsfeed with wrong/empty time (probably wrong parsing)\n%s", post.c_str());
- continue;
- }
-
- if (ttime > new_time) {
- new_time = ttime; // remember newest time from all these posts
- debugLogA(" - Newsfeed time: %d (new)", ttime);
- }
- else if (ttime <= facy.last_feeds_update_) {
- debugLogA(" - Newsfeed time: %d (ignored)", ttime);
- continue; // ignore posts older than newest post of previous check
- }
- else {
- debugLogA(" - Newsfeed time: %d (normal)", ttime);
- }
-
- std::string post_place = utils::text::source_get_value(&post, 4, "</abbr>", "<a", ">", "</a>");
-
- std::string premsg = "\n" + time_text;
-
- post_place = utils::text::trim(
- utils::text::remove_html(post_place));
- if (!post_place.empty()) {
- premsg += " - " + post_place;
- }
- premsg += "\n";
-
- // in title keep only name, end of events like "X shared link" put into message
- std::string::size_type pos2 = post_header.find("?");
-
- if (pos2 != std::string::npos) {
- utils::text::replace_first(&post_header, "?", " › ");
- }
- else {
- pos2 = post_header.find("</a></");
- if (pos2 != std::string::npos) {
- pos2 += 4;
- std::string a = utils::text::trim(utils::text::remove_html(post_header.substr(pos2, post_header.length() - pos2)));
- if (a.length() > 2)
- premsg += a;
- post_header = post_header.substr(0, pos2);
- }
- }
-
- // Strip "Translate" link
- pos2 = post_message.find("role=\"button\">");
- if (pos2 != std::string::npos) {
- post_message = post_message.substr(0, pos2 + 14);
- }
-
- post_message = premsg + post_message;
-
- // append attachement to message (if any)
- //post_message += utils::text::trim(post_attach);
-
- facebook_newsfeed* nf = new facebook_newsfeed;
-
- nf->title = utils::text::trim(
- utils::text::html_entities_decode(
- utils::text::remove_html(post_header)));
-
- nf->user_id = utils::text::source_get_value(&post_header, 2, "user.php?id=", "&amp;");
-
- nf->link = utils::text::html_entities_decode(post_link);
-
- // Check if we don't want to show ads posts
- bool filtered = filterAds && (nf->link.find("/about/ads") != std::string::npos
- || post.find("class=\"uiStreamSponsoredLink\"") != std::string::npos
- || post.find("href=\"/about/ads\"") != std::string::npos);
-
- nf->text = utils::text::trim(
- utils::text::html_entities_decode(
- utils::text::remove_html(
- utils::text::edit_html(post_message))));
-
- if (filtered || nf->title.empty() || nf->text.empty()) {
- debugLogA(" \\ Newsfeed (time: %d) is filtered: %s", ttime, filtered ? "advertisement" : (nf->title.empty() ? "title empty" : "text empty"));
- delete nf;
- continue;
- }
- else {
- debugLogA(" Got newsfeed (time: %d)", ttime);
- }
-
- news.push_back(nf);
- pos++;
- limit++;
- }
-
- debugLogA(" Last feeds update (new): %d", new_time);
+ parseFeeds(resp.data, news, new_time, filterAds);
for (std::vector<facebook_newsfeed*>::size_type i = 0; i < news.size(); i++)
{
@@ -1172,15 +1224,7 @@ void FacebookProto::ProcessFeeds(void*)
// Set time of last update to time of newest post
this->facy.last_feeds_update_ = new_time;
- debugLogA("*** Feeds processed");
-
- CODE_BLOCK_CATCH
-
- debugLogA("*** Error processing feeds: %s", e.what());
-
- CODE_BLOCK_END
-
- facy.handle_success("feeds");
+ facy.handle_success("feeds");
}
void FacebookProto::ProcessPages(void*)
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 4910eba167..a7184d4ff0 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -1055,6 +1055,17 @@ void FacebookProto::InitPopups()
ppc.colorText = RGB(0, 0, 0); // black
ppc.iSeconds = 0;
popupClasses.push_back(Popup_RegisterClass(&ppc));
+
+ // On this day
+ mir_sntprintf(desc, _T("%s/%s"), m_tszUserName, TranslateT("On this day posts"));
+ mir_snprintf(name, "%s_%s", m_szModuleName, "OnThisDay");
+ 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));
}
/**
@@ -1092,9 +1103,11 @@ void FacebookProto::InitHotkeys()
void FacebookProto::InitSounds()
{
SkinAddNewSoundExT("Notification", m_tszUserName, LPGENT("Notification"));
- SkinAddNewSoundExT("NewsFeed", m_tszUserName, LPGENT("News Feed"));
- SkinAddNewSoundExT("OtherEvent", m_tszUserName, LPGENT("Other Event"));
- SkinAddNewSoundExT("Friendship", m_tszUserName, LPGENT("Friendship Event"));
+ SkinAddNewSoundExT("NewsFeed", m_tszUserName, LPGENT("Newsfeed event"));
+ SkinAddNewSoundExT("OtherEvent", m_tszUserName, LPGENT("Other event"));
+ SkinAddNewSoundExT("Friendship", m_tszUserName, LPGENT("Friendship event"));
+ SkinAddNewSoundExT("Ticker", m_tszUserName, LPGENT("Ticker event"));
+ SkinAddNewSoundExT("OnThisDay", m_tszUserName, LPGENT("On this day event"));
}
/**
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index e8b0c8c3c5..a43953e728 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -169,6 +169,7 @@ public:
void __cdecl ProcessPages(void*);
void __cdecl LoadLastMessages(void*);
void __cdecl SyncThreads(void*);
+ void __cdecl ProcessOnThisDay(void*);
// Worker threads
void __cdecl SignOn(void*);
diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h
index 030806e8d2..82083e2954 100644
--- a/protocols/FacebookRM/src/resource.h
+++ b/protocols/FacebookRM/src/resource.h
@@ -1,76 +1,77 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by ..\res\facebook.rc
-//
-#define IDC_EXPAND 3
-#define IDI_FACEBOOK 101
-#define IDI_MIND 102
-#define IDD_FACEBOOKACCOUNT 111
-#define IDD_MIND 112
-#define IDD_OPTIONS 113
-#define IDD_OPTIONS_EVENTS 114
-#define IDD_OPTIONS_STATUSES 115
-#define IDD_CAPTCHAFORM 116
-#define IDD_OPTIONS_MESSAGING 117
-#define IDI_POKE 127
-#define IDI_NOTIFICATION 128
-#define IDI_NEWSFEED 129
-#define IDI_FRIENDS 130
-#define IDI_CONVERSATION 131
-#define IDI_READ 132
-#define IDI_KEYS 133
-#define IDC_UN 1001
-#define IDC_PW 1002
-#define IDC_NEWACCOUNTLINK 1003
-#define IDC_MINDMSG 1012
-#define IDC_GROUP 1021
-#define IDC_SET_IGNORE_STATUS 1025
-#define IDC_DISCONNECT_CHAT 1028
-#define IDC_BIGGER_AVATARS 1030
-#define IDC_MAP_STATUSES 1032
-#define IDC_CUSTOM_SMILEYS 1034
-#define IDC_LOAD_PAGES 1036
-#define IDC_KEEP_UNREAD 1037
-#define IDC_INBOX_ONLY 1038
-#define IDC_MESSAGES_ON_OPEN 1039
-#define IDC_HIDE_CHATS 1040
-#define IDC_NOTIFICATIONS_ENABLE 1041
-#define IDC_FEEDS_ENABLE 1042
-#define IDC_OTHER_ENABLE 1043
-#define IDC_CLIENT_ENABLE 1044
-#define IDC_FILTER_ADS 1045
-#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
-#define IDC_SET_STATUS 1126
-#define IDC_FEED_TYPE 1201
-#define IDC_URL_SERVER 1202
-#define IDC_PLACE 1203
-#define IDC_PRIVACY 1204
-#define IDC_WALL 1205
-#define IDC_URL 1206
-#define IDC_CCLIST 1207
-#define IDC_CCLIST_LABEL 1208
-#define IDC_MESSAGES_COUNT 1209
-#define IDC_MESSAGES_COUNT_SPIN 1210
-#define IDC_VALUE 1211
-#define IDC_WHITERECT 1212
-#define IDC_TITLE 1213
-#define IDC_INSTRUCTION 1214
-#define IDC_FRAME1 1215
-#define IDC_FRAME2 1216
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 134
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1218
-#define _APS_NEXT_SYMED_VALUE 134
-#endif
-#endif
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by ..\res\facebook.rc
+//
+#define IDC_EXPAND 3
+#define IDI_FACEBOOK 101
+#define IDI_MIND 102
+#define IDD_FACEBOOKACCOUNT 111
+#define IDD_MIND 112
+#define IDD_OPTIONS 113
+#define IDD_OPTIONS_EVENTS 114
+#define IDD_OPTIONS_STATUSES 115
+#define IDD_CAPTCHAFORM 116
+#define IDD_OPTIONS_MESSAGING 117
+#define IDI_POKE 127
+#define IDI_NOTIFICATION 128
+#define IDI_NEWSFEED 129
+#define IDI_FRIENDS 130
+#define IDI_CONVERSATION 131
+#define IDI_READ 132
+#define IDI_KEYS 133
+#define IDC_UN 1001
+#define IDC_PW 1002
+#define IDC_NEWACCOUNTLINK 1003
+#define IDC_MINDMSG 1012
+#define IDC_GROUP 1021
+#define IDC_SET_IGNORE_STATUS 1025
+#define IDC_DISCONNECT_CHAT 1028
+#define IDC_BIGGER_AVATARS 1030
+#define IDC_MAP_STATUSES 1032
+#define IDC_CUSTOM_SMILEYS 1034
+#define IDC_LOAD_PAGES 1036
+#define IDC_KEEP_UNREAD 1037
+#define IDC_INBOX_ONLY 1038
+#define IDC_MESSAGES_ON_OPEN 1039
+#define IDC_HIDE_CHATS 1040
+#define IDC_NOTIFICATIONS_ENABLE 1041
+#define IDC_FEEDS_ENABLE 1042
+#define IDC_OTHER_ENABLE 1043
+#define IDC_CLIENT_ENABLE 1044
+#define IDC_FILTER_ADS 1045
+#define IDC_LOGIN_SYNC 1046
+#define IDC_ENABLE_CHATS 1047
+#define IDC_FRIENDSHIP_ENABLE 1048
+#define IDC_TICKER_ENABLE 1049
+#define IDC_ON_THIS_DAY_ENABLE 1050
+#define IDC_SYSTRAY_NOTIFY 1098
+#define IDC_PREVIEW 1099
+#define IDC_NOTIFICATIONS_CHATROOM 1100
+#define IDC_SET_STATUS 1126
+#define IDC_FEED_TYPE 1201
+#define IDC_URL_SERVER 1202
+#define IDC_PLACE 1203
+#define IDC_PRIVACY 1204
+#define IDC_WALL 1205
+#define IDC_URL 1206
+#define IDC_CCLIST 1207
+#define IDC_CCLIST_LABEL 1208
+#define IDC_MESSAGES_COUNT 1209
+#define IDC_MESSAGES_COUNT_SPIN 1210
+#define IDC_VALUE 1211
+#define IDC_WHITERECT 1212
+#define IDC_TITLE 1213
+#define IDC_INSTRUCTION 1214
+#define IDC_FRAME1 1215
+#define IDC_FRAME2 1216
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 134
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1218
+#define _APS_NEXT_SYMED_VALUE 134
+#endif
+#endif
diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h
index ba5c6c2040..6a7908fe51 100644
--- a/protocols/FacebookRM/src/version.h
+++ b/protocols/FacebookRM/src/version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 2
-#define __RELEASE_NUM 11
-#define __BUILD_NUM 2
-
-#include <stdver.h>
-
-#define __PLUGIN_NAME "Facebook RM"
-#define __FILENAME "Facebook.dll"
-#define __DESCRIPTION "Facebook protocol support for Miranda NG."
-#define __AUTHOR "Michal Zelinka, Robert P\xf6" "sel"
-#define __AUTHOREMAIL "robyer@seznam.cz"
-#define __AUTHORWEB "http://miranda-ng.org/p/Facebook/"
-#define __COPYRIGHT "© 2009-11 Michal Zelinka, 2011-15 Robert P\xf6" "sel"
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 2
+#define __RELEASE_NUM 11
+#define __BUILD_NUM 3
+
+#include <stdver.h>
+
+#define __PLUGIN_NAME "Facebook RM"
+#define __FILENAME "Facebook.dll"
+#define __DESCRIPTION "Facebook protocol support for Miranda NG."
+#define __AUTHOR "Michal Zelinka, Robert P\xf6" "sel"
+#define __AUTHOREMAIL "robyer@seznam.cz"
+#define __AUTHORWEB "http://miranda-ng.org/p/Facebook/"
+#define __COPYRIGHT "© 2009-11 Michal Zelinka, 2011-15 Robert P\xf6" "sel"