summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/process.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/FacebookRM/src/process.cpp')
-rw-r--r--protocols/FacebookRM/src/process.cpp96
1 files changed, 87 insertions, 9 deletions
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index 7cdec9f7fa..f03a8906eb 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -543,7 +543,7 @@ void parseFeeds(const std::string &text, std::vector<facebook_newsfeed *> &news,
DWORD new_time = last_post_time;
- while ((pos = text.find("<div class=\"userContentWrapper", pos)) != std::string::npos && limit <= 25)
+ while ((pos = text.find("<div class=\"fbUserContent", pos)) != std::string::npos && limit <= 25)
{
std::string post = text.substr(pos, text.find("</form>", pos) - pos);
pos += 5;
@@ -551,6 +551,9 @@ void parseFeeds(const std::string &text, std::vector<facebook_newsfeed *> &news,
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=\"", "\"");
+ if (post_link == "#") {
+ post_link = utils::text::source_get_value(&post, 5, "</h5>", "<a", "<a", "href=\"", "\"");
+ }
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=\"", "\"");
@@ -597,10 +600,26 @@ void parseFeeds(const std::string &text, std::vector<facebook_newsfeed *> &news,
utils::text::remove_html(
post_header.substr(pos2, post_header.length() - pos2))));
- // Strip "Translate" link
- pos2 = post_message.find("role=\"button\">");
+ // Strip "Translate" and other buttons
+ do {
+ pos2 = post_message.find("role=\"button\"");
+ if (pos2 != std::string::npos) {
+ pos2 = post_message.find(">", pos2);
+ if (pos2 != std::string::npos) {
+ std::string::size_type pos3 = post_message.find("</a>", pos2);
+ std::string tmp = post_message.substr(0, pos2);
+ if (pos3 != std::string::npos) {
+ tmp += post_message.substr(pos3, post_message.length() - pos3);
+ }
+ post_message = tmp;
+ }
+ }
+ } while (pos2 != std::string::npos);
+
+ // Strip "See more" link
+ pos2 = post_message.find("<span class=\"see_more_link_inner\">");
if (pos2 != std::string::npos) {
- post_message = post_message.substr(0, pos2 + 14);
+ post_message = post_message.substr(0, pos2);
}
// Process attachment (if present)
@@ -676,17 +695,24 @@ void parseFeeds(const std::string &text, std::vector<facebook_newsfeed *> &news,
last_post_time = new_time;
}
-void FacebookProto::ProcessMemories(void*)
+void FacebookProto::ProcessMemories(void *p)
{
if (isOffline())
return;
+ bool manuallyTriggered = (p == MANUALLY_TRIGGERED);
+ if (manuallyTriggered) {
+ facy.info_notify(TranslateT("Loading memories..."));
+ }
+
+ int numMemories = 0;
+
facy.handle_entry(__FUNCTION__);
HttpRequest *request = new MemoriesRequest(&facy);
http::response resp = facy.sendRequest(request);
- if (resp.code != HTTP_CODE_OK) {
+ if (resp.code != HTTP_CODE_OK || resp.data.empty()) {
facy.handle_error(__FUNCTION__);
return;
}
@@ -706,6 +732,8 @@ void FacebookProto::ProcessMemories(void*)
SkinPlaySound("Memories");
}
+ numMemories = news.size();
+
for (std::vector<facebook_newsfeed*>::size_type i = 0; i < news.size(); i++)
{
ptrW tszTitle(mir_utf8decodeW(news[i]->title.c_str()));
@@ -718,6 +746,11 @@ void FacebookProto::ProcessMemories(void*)
}
}
+ if (manuallyTriggered) {
+ CMStringW text(FORMAT, TranslateT("Found %d memories."), numMemories);
+ facy.info_notify(text.GetBuffer());
+ }
+
facy.handle_success(__FUNCTION__);
}
@@ -1009,11 +1042,16 @@ void FacebookProto::ShowNotifications() {
}
}
-void FacebookProto::ProcessNotifications(void*)
+void FacebookProto::ProcessNotifications(void *p)
{
if (isOffline())
return;
+ bool manuallyTriggered = (p == MANUALLY_TRIGGERED);
+ if (manuallyTriggered) {
+ facy.info_notify(TranslateT("Loading notifications..."));
+ }
+
facy.handle_entry("notifications");
// Get notifications
@@ -1029,10 +1067,18 @@ void FacebookProto::ProcessNotifications(void*)
debugLogA("*** Starting processing notifications");
try {
+ int numNotifications = facy.notifications.size();
+
facebook_json_parser* p = new facebook_json_parser(this);
p->parse_notifications(&(resp.data), &facy.notifications);
delete p;
+ if (manuallyTriggered) {
+ numNotifications = facy.notifications.size() - numNotifications;
+ CMStringW text(FORMAT, TranslateT("Found %d notifications."), numNotifications);
+ facy.info_notify(text.GetBuffer());
+ }
+
ShowNotifications();
debugLogA("*** Notifications processed");
@@ -1042,11 +1088,16 @@ void FacebookProto::ProcessNotifications(void*)
}
}
-void FacebookProto::ProcessFriendRequests(void*)
+void FacebookProto::ProcessFriendRequests(void *p)
{
if (isOffline())
return;
+ bool manuallyTriggered = (p == MANUALLY_TRIGGERED);
+ if (manuallyTriggered) {
+ facy.info_notify(TranslateT("Loading friendship requests..."));
+ }
+
facy.handle_entry("friendRequests");
// Get load friendships
@@ -1064,6 +1115,9 @@ void FacebookProto::ProcessFriendRequests(void*)
return;
}
+ int numRequestsNew = 0;
+ int numRequestsOld = 0;
+
// Parse it
std::string reqs = utils::text::source_get_value(&resp.data, 3, "id=\"friends_center_main\"", "</h3>", "/friends/center/suggestions/");
@@ -1113,18 +1167,37 @@ void FacebookProto::ProcessFriendRequests(void*)
db_event_add(0, &dbei);
}
debugLogA(" < (%s) Friendship request [%s]", (isNew ? "New" : "Old"), time.c_str());
+
+ if (isNew)
+ numRequestsNew++;
+ else
+ numRequestsOld++;
}
else debugLogA("!!! Wrong friendship request:\n%s", req.c_str());
}
+ if (manuallyTriggered) {
+ CMStringW text;
+ if (numRequestsOld > 0)
+ text.AppendFormat(TranslateT("Found %d friendship requests (%d seen)."), numRequestsNew, numRequestsOld);
+ else
+ text.AppendFormat(TranslateT("Found %d friendship requests."), numRequestsNew);
+ facy.info_notify(text.GetBuffer());
+ }
+
facy.handle_success("friendRequests");
}
-void FacebookProto::ProcessFeeds(void*)
+void FacebookProto::ProcessFeeds(void *p)
{
if (!isOnline())
return;
+ bool manuallyTriggered = (p == MANUALLY_TRIGGERED);
+ if (manuallyTriggered) {
+ facy.info_notify(TranslateT("Loading wall posts..."));
+ }
+
facy.handle_entry("feeds");
// Get feeds
@@ -1146,6 +1219,11 @@ void FacebookProto::ProcessFeeds(void*)
SkinPlaySound("NewsFeed");
}
+ if (manuallyTriggered) {
+ CMStringW text(FORMAT, TranslateT("Found %d wall posts."), news.size());
+ facy.info_notify(text.GetBuffer());
+ }
+
for (std::vector<facebook_newsfeed*>::size_type i = 0; i < news.size(); i++)
{
ptrW tszTitle(mir_utf8decodeW(news[i]->title.c_str()));