summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-05-28 14:27:38 +0000
committerRobert Pösel <robyer@seznam.cz>2014-05-28 14:27:38 +0000
commit4d556a607649ff90b846f0c6e1b033d365d3b744 (patch)
treeb7d5510363e89d3a2f545907ff7580a9e68f96fc /protocols/FacebookRM/src
parent2bc466a8af4b4ed77f20cab4b61886124db259e5 (diff)
Facebook: Added option to not show advertising posts from news feeds
git-svn-id: http://svn.miranda-ng.org/main/trunk@9335 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r--protocols/FacebookRM/src/constants.h1
-rw-r--r--protocols/FacebookRM/src/db.h1
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp2
-rw-r--r--protocols/FacebookRM/src/process.cpp13
-rw-r--r--protocols/FacebookRM/src/resource.h1
5 files changed, 11 insertions, 7 deletions
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index bfa54d2ec7..29fa13751e 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -75,6 +75,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEFAULT_LOAD_PAGES 0
#define DEFAULT_KEEP_UNREAD 0
#define DEFAULT_INBOX_ONLY 0
+#define DEFAULT_FILTER_ADS 0
#define DEFAULT_EVENT_NOTIFICATIONS_ENABLE 1
#define DEFAULT_EVENT_FEEDS_ENABLE 1
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h
index 536462d9e7..be6f42c41e 100644
--- a/protocols/FacebookRM/src/db.h
+++ b/protocols/FacebookRM/src/db.h
@@ -54,6 +54,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_KEY_LOAD_PAGES "LoadPages"
#define FACEBOOK_KEY_KEEP_UNREAD "KeepUnread" // (byte) 1 = don't mark messages as read on server (works globally or per contact)
#define FACEBOOK_KEY_INBOX_ONLY "InboxOnly"
+#define FACEBOOK_KEY_FILTER_ADS "FilterAds"
#define FACEBOOK_KEY_POLL_RATE "PollRate" // [HIDDEN]
#define FACEBOOK_KEY_TIMEOUTS_LIMIT "TimeoutsLimit" // [HIDDEN]
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index 76b7f1a100..d9ed46a869 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -535,6 +535,7 @@ INT_PTR CALLBACK FBEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpa
LoadDBCheckState(proto, hwnd, IDC_FEEDS_ENABLE, FACEBOOK_KEY_EVENT_FEEDS_ENABLE, DEFAULT_EVENT_FEEDS_ENABLE);
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_FILTER_ADS, FACEBOOK_KEY_FILTER_ADS, DEFAULT_FILTER_ADS);
} return TRUE;
@@ -569,6 +570,7 @@ INT_PTR CALLBACK FBEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpa
StoreDBCheckState(proto, hwnd, IDC_FEEDS_ENABLE, FACEBOOK_KEY_EVENT_FEEDS_ENABLE);
StoreDBCheckState(proto, hwnd, IDC_OTHER_ENABLE, FACEBOOK_KEY_EVENT_OTHER_ENABLE);
StoreDBCheckState(proto, hwnd, IDC_CLIENT_ENABLE, FACEBOOK_KEY_EVENT_CLIENT_ENABLE);
+ StoreDBCheckState(proto, hwnd, IDC_FILTER_ADS, FACEBOOK_KEY_FILTER_ADS);
}
} return TRUE;
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index 03c99f246f..3fc432943e 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -744,14 +744,11 @@ void FacebookProto::ProcessFeeds(void* data)
// Get feeds
http::response resp = facy.flap(REQUEST_FEEDS);
- if (resp.code != HTTP_CODE_OK) {
+ if (resp.code != HTTP_CODE_OK || resp.data.empty()) {
facy.handle_error("feeds");
return;
}
- if (resp.data.empty() /*|| resp.data.find("\"num_stories\":0") != std::string::npos*/)
- return;
-
CODE_BLOCK_TRY
debugLogA("***** Starting processing feeds");
@@ -762,6 +759,7 @@ void FacebookProto::ProcessFeeds(void* data)
UINT limit = 0;
DWORD new_time = facy.last_feeds_update_;
+ bool filterAds = getBool(FACEBOOK_KEY_FILTER_ADS, DEFAULT_FILTER_ADS);
while ((pos = resp.data.find("<div class=\"userContentWrapper", pos)) != std::string::npos && limit <= 25)
{
@@ -836,15 +834,16 @@ void FacebookProto::ProcessFeeds(void* data)
nf->user_id = utils::text::source_get_value(&post_header, 2, "user.php?id=", "&amp;");
nf->link = utils::text::special_expressions_decode(post_link);
- //utils::text::source_get_value(&post_link, 2, "href=\\\"", "\\\">"));
+
+ // Check if we don't want to show ads posts
+ bool filtered = filterAds && nf->link.find("/about/ads") != std::string::npos;
nf->text = utils::text::trim(
utils::text::special_expressions_decode(
utils::text::remove_html(
utils::text::edit_html(post_message))));
- if (!nf->title.length() || !nf->text.length())
- {
+ if (filtered || !nf->title.length() || !nf->text.length()) {
delete nf;
continue;
}
diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h
index 4c706e58e5..19958fceb4 100644
--- a/protocols/FacebookRM/src/resource.h
+++ b/protocols/FacebookRM/src/resource.h
@@ -36,6 +36,7 @@
#define IDC_FEEDS_ENABLE 1042
#define IDC_OTHER_ENABLE 1043
#define IDC_CLIENT_ENABLE 1044
+#define IDC_FILTER_ADS 1045
#define IDC_SYSTRAY_NOTIFY 1098
#define IDC_PREVIEW 1099
#define IDC_SET_STATUS 1126