diff options
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 35 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 5 |
2 files changed, 26 insertions, 14 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 976f8263a6..2c84a18b5b 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -36,23 +36,17 @@ http::response facebook_client::flap(RequestType request_type, std::string *post return resp; } + // Prepare the request NETLIBHTTPREQUEST nlhr = { sizeof(NETLIBHTTPREQUEST) }; + // Set request URL std::string url = HTTP_PROTO_SECURE + choose_server(request_type) + choose_action(request_type, get_data); - if (!parent->m_locale.empty()) url += "&locale=" + parent->m_locale; - + nlhr.szUrl = (char*)url.c_str(); - nlhr.flags = NLHRF_HTTP11 | NLHRF_SSL; - nlhr.headers = get_request_headers(nlhr.requestType, &nlhr.headersCount); - -#ifdef _DEBUG - nlhr.flags |= NLHRF_DUMPASTEXT; -#else - nlhr.flags |= NLHRF_NODUMP; -#endif + // Set timeout (bigger for channel request) switch (request_type) { case REQUEST_MESSAGES_RECEIVE: nlhr.timeout = 1000 * 65; @@ -63,6 +57,7 @@ http::response facebook_client::flap(RequestType request_type, std::string *post break; } + // Set request type (GET/POST) and eventually also POST data if (post_data != NULL) { nlhr.requestType = REQUEST_POST; nlhr.pData = (char*)(*post_data).c_str(); @@ -71,8 +66,19 @@ http::response facebook_client::flap(RequestType request_type, std::string *post nlhr.requestType = REQUEST_GET; } - parent->debugLogA("@@@ Sending request to '%s'", nlhr.szUrl); + // Set headers - it depends on requestType so it must be after setting that + nlhr.headers = get_request_headers(nlhr.requestType, &nlhr.headersCount); + // Set flags + nlhr.flags = NLHRF_HTTP11 | NLHRF_SSL; + +#ifdef _DEBUG + nlhr.flags |= NLHRF_DUMPASTEXT; +#else + nlhr.flags |= NLHRF_NODUMP; +#endif + + // Set persistent connection (or not) switch (request_type) { case REQUEST_LOGIN: nlhr.nlc = NULL; @@ -90,11 +96,15 @@ http::response facebook_client::flap(RequestType request_type, std::string *post break; } - NETLIBHTTPREQUEST* pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)handle_, (LPARAM)&nlhr); + parent->debugLogA("@@@ Sending request to '%s'", nlhr.szUrl); + + // Send the request + NETLIBHTTPREQUEST *pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)handle_, (LPARAM)&nlhr); mir_free(nlhr.headers[3].szValue); mir_free(nlhr.headers); + // Remember the persistent connection handle (or not) switch (request_type) { case REQUEST_LOGIN: case REQUEST_SETUP_MACHINE: @@ -110,6 +120,7 @@ http::response facebook_client::flap(RequestType request_type, std::string *post break; } + // Check and copy response data if (pnlhr != NULL) { parent->debugLogA("@@@ Got response with code %d", pnlhr->resultCode); store_headers(&resp, pnlhr->headers, pnlhr->headersCount); diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index b28a465de1..1e69fd0689 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.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 @@ -921,9 +921,10 @@ void FacebookProto::ReadNotificationWorker(void *p) return; } - std::string data = "seen=0&asyncSignal=&__dyn=&__req=a&alert_ids%5B0%5D=" + utils::url::encode(*id); + std::string data = "seen=true&asyncSignal=&__dyn=&__rev=&__req=&alert_ids%5B0%5D=" + utils::url::encode(*id); data += "&fb_dtsg=" + facy.dtsg_; data += "&__user=" + facy.self_.user_id; + data += "&ttstamp=" + facy.ttstamp(); facy.flap(REQUEST_NOTIFICATIONS_READ, NULL, &data); |