summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-09-19 17:19:57 +0000
committerRobert Pösel <robyer@seznam.cz>2014-09-19 17:19:57 +0000
commitb59603c66c0982effbe8faccd62f5088d0078c23 (patch)
treebdaf771ce5015086a2026f993ffe6278dd4ece28 /protocols/FacebookRM
parente546ee6ef368b6b7d1f21ccc30b0496b42e4f10c (diff)
Facebook: Fix for Facebook's image captcha; version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@10524 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r--protocols/FacebookRM/src/communication.cpp40
-rw-r--r--protocols/FacebookRM/src/constants.h1
-rw-r--r--protocols/FacebookRM/src/version.h2
3 files changed, 35 insertions, 8 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 2ad9e3cd96..fe8fdc3cfb 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -233,6 +233,7 @@ DWORD facebook_client::choose_security_level(RequestType request_type)
// case REQUEST_RECONNECT:
// case REQUEST_POST_STATUS:
// case REQUEST_IDENTITY_SWITCH:
+// case REQUEST_CAPTCHA_REFRESH:
// case REQUEST_LINK_SCRAPER:
// case REQUEST_MESSAGE_SEND_CHAT:
// case REQUEST_MESSAGE_SEND_INBOX:
@@ -289,6 +290,7 @@ int facebook_client::choose_method(RequestType request_type)
// case REQUEST_USER_INFO_MOBILE:
// case REQUEST_LOAD_FRIENDSHIPS:
// case REQUEST_SEARCH:
+// case REQUEST_CAPTCHA_REFRESH:
default:
return REQUEST_GET;
}
@@ -334,6 +336,7 @@ std::string facebook_client::choose_server(RequestType request_type, std::string
// case REQUEST_RECONNECT:
// case REQUEST_POST_STATUS:
// case REQUEST_IDENTITY_SWITCH:
+// case REQUEST_CAPTCHA_REFRESH:
// case REQUEST_LINK_SCRAPER:
// case REQUEST_MESSAGE_SEND_CHAT:
// case REQUEST_MESSAGE_SEND_INBOX:
@@ -490,6 +493,15 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
case REQUEST_IDENTITY_SWITCH:
return "/identity_switch.php?__a=1";
+ case REQUEST_CAPTCHA_REFRESH:
+ {
+ std::string action = "/captcha/refresh_ajax.php?__a=1";
+ if (get_data != NULL) {
+ action += "&" + (*get_data);
+ }
+ return action;
+ }
+
case REQUEST_LINK_SCRAPER:
{
std::string action = "/ajax/composerx/attachment/link/scraper/?__a=1&composerurihash=2&scrape_url=";
@@ -1315,17 +1327,31 @@ int facebook_client::send_message(MCONTACT hContact, std::string message_recipie
{
std::string imageUrl = utils::text::html_entities_decode(utils::text::slashu_to_utf8(utils::text::source_get_value(&resp.data, 3, "img class=\\\"img\\\"", "src=\\\"", "\\\"")));
std::string captchaPersistData = utils::text::source_get_value(&resp.data, 3, "\\\"captcha_persist_data\\\"", "value=\\\"", "\\\"");
+
+ parent->debugLogA("Got imageUrl (first): %s", imageUrl.c_str());
+ parent->debugLogA("Got captchaPersistData (first): %s", captchaPersistData.c_str());
+
+ std::string data = "new_captcha_type=TFBCaptcha&skipped_captcha_data=" + captchaPersistData;
+ data += "&__dyn=&__req=&__rev=&__user=" + this->self_.user_id;
+ http::response resp = flap(REQUEST_CAPTCHA_REFRESH, NULL, &data);
- parent->debugLogA("Got imageUrl: %s", imageUrl.c_str());
- parent->debugLogA("Got captchaPersistData: %s", captchaPersistData.c_str());
+ if (resp.code == HTTP_CODE_OK) {
+ imageUrl = utils::text::html_entities_decode(utils::text::slashu_to_utf8(utils::text::source_get_value(&resp.data, 3, "img class=\\\"img\\\"", "src=\\\"", "\\\"")));
+ captchaPersistData = utils::text::source_get_value(&resp.data, 3, "\\\"captcha_persist_data\\\"", "value=\\\"", "\\\"");
+
+ parent->debugLogA("Got imageUrl (second): %s", imageUrl.c_str());
+ parent->debugLogA("Got captchaPersistData (second): %s", captchaPersistData.c_str());
+
+ std::string result;
+ if (!parent->RunCaptchaForm(imageUrl, result)) {
+ *error_text = Translate("User cancel captcha challenge.");
+ return SEND_MESSAGE_CANCEL;
+ }
- std::string result;
- if (!parent->RunCaptchaForm(imageUrl, result)) {
- *error_text = Translate("User cancel captcha challenge.");
- return SEND_MESSAGE_CANCEL;
+ return send_message(hContact, message_recipient, message_text, error_text, method, captchaPersistData, result);
}
- return send_message(hContact, message_recipient, message_text, error_text, method, captchaPersistData, result);
+ return SEND_MESSAGE_CANCEL; // Cancel because we failed to load captcha image so we can't continue only with error
}
default: // Other error
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index d2fd847e69..d7211b2f1b 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -113,6 +113,7 @@ enum RequestType {
REQUEST_RECONNECT, // getting __sequence_num__ and __channel_id__
REQUEST_VISIBILITY, // setting chat visibility
REQUEST_IDENTITY_SWITCH, // changing identity to post status for pages
+ REQUEST_CAPTCHA_REFRESH, // refreshing captcha dialog (changing captcha type)
REQUEST_FEEDS, // getting feeds
REQUEST_NOTIFICATIONS, // getting notifications
diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h
index 1efaf598d8..234a5218ab 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 9
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#include <stdver.h>