summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-01-03 13:41:49 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-01-03 13:41:49 +0300
commitf524101c14374c2efd1318f9d9085b1216b69620 (patch)
tree1a556fda936976e854ce14a42cb801e21829dd67 /protocols
parentd5d5b3f352e0cc2601013950cd48d5aad5c73baa (diff)
Facebook:
- switch to the kernel parameter types; - strong parameters typization (also produces more compact code) - fixed timeline notifications - version bump
Diffstat (limited to 'protocols')
-rw-r--r--protocols/FacebookRM/src/client.h1
-rw-r--r--protocols/FacebookRM/src/communication.cpp27
-rw-r--r--protocols/FacebookRM/src/http_request.h102
-rw-r--r--protocols/FacebookRM/src/requests/channel.h49
-rw-r--r--protocols/FacebookRM/src/requests/contacts.h117
-rw-r--r--protocols/FacebookRM/src/requests/feeds.h36
-rw-r--r--protocols/FacebookRM/src/requests/history.h75
-rw-r--r--protocols/FacebookRM/src/requests/login.h55
-rw-r--r--protocols/FacebookRM/src/requests/messages.h112
-rw-r--r--protocols/FacebookRM/src/requests/notifications.h46
-rw-r--r--protocols/FacebookRM/src/requests/profile.h15
-rw-r--r--protocols/FacebookRM/src/requests/search.h8
-rw-r--r--protocols/FacebookRM/src/requests/status.h44
-rw-r--r--protocols/FacebookRM/src/requests/utils.h139
-rw-r--r--protocols/FacebookRM/src/version.h4
15 files changed, 354 insertions, 476 deletions
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index 9302752110..0d58d04114 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -114,7 +114,6 @@ public:
std::map<std::string, MCONTACT> chat_id_to_hcontact;
std::map<std::string, MCONTACT> user_id_to_hcontact;
- std::string get_newsfeed_type();
std::string get_server_type();
std::string get_privacy_type();
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 683fa486e3..acae64dcb1 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -43,16 +43,16 @@ http::response facebook_client::sendRequest(HttpRequest *request)
// Check and append user defined locale if request doesn't have it forced already
if (!parent->m_locale.empty() && strstr(request->szUrl, "&locale=") == nullptr)
- request->Url << CHAR_VALUE("locale", parent->m_locale.c_str());
+ request->Url << CHAR_PARAM("locale", parent->m_locale.c_str());
request->Headers
- << CHAR_VALUE("Accept-Language", "en,en-US;q=0.9")
- << CHAR_VALUE("Accept", "*/*")
- << CHAR_VALUE("User-Agent", g_strUserAgent.c_str())
- << CHAR_VALUE("Cookie", ptrA(load_cookies())); // FIXME: Rework load_cookies to not do strdup
+ << CHAR_PARAM("Accept-Language", "en,en-US;q=0.9")
+ << CHAR_PARAM("Accept", "*/*")
+ << CHAR_PARAM("User-Agent", g_strUserAgent.c_str())
+ << CHAR_PARAM("Cookie", ptrA(load_cookies())); // FIXME: Rework load_cookies to not do strdup
if (request->requestType == REQUEST_POST)
- request->Headers << CHAR_VALUE("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
+ request->Headers << CHAR_PARAM("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
// Set persistent connection (or not)
switch (request->Persistent) {
@@ -196,19 +196,6 @@ bool facebook_client::handle_error(const std::string &method, int action)
//////////////////////////////////////////////////////////////////////////////
-std::string facebook_client::get_newsfeed_type()
-{
- BYTE feed_type = parent->getByte(FACEBOOK_KEY_FEED_TYPE, 0);
- if (feed_type >= _countof(feed_types))
- feed_type = 0;
-
- std::string ret = "sk=";
- ret += feed_types[feed_type].id;
- ret += "&key=";
- ret += (feed_type < 2 ? "nf" : feed_types[feed_type].id);
- return ret;
-}
-
std::string facebook_client::get_server_type()
{
BYTE server_type = parent->getByte(FACEBOOK_KEY_SERVER_TYPE, 0);
@@ -491,7 +478,7 @@ bool facebook_client::login(const char *username, const char *password)
const char *givenCode = guardDialog.GetCode();
request = new SetupMachineRequest(fb_dtsg.c_str(), nh.c_str(), "Continue");
- request->Body << CHAR_VALUE("approvals_code", givenCode);
+ request->Body << CHAR_PARAM("approvals_code", givenCode);
resp = sendRequest(request);
if (resp.data.find("id=\"approvals_code\"") != std::string::npos) {
diff --git a/protocols/FacebookRM/src/http_request.h b/protocols/FacebookRM/src/http_request.h
index 93097d23dc..efabe21e3d 100644
--- a/protocols/FacebookRM/src/http_request.h
+++ b/protocols/FacebookRM/src/http_request.h
@@ -18,49 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _HTTP_REQUEST_H_
#define _HTTP_REQUEST_H_
-struct VALUE
-{
- LPCSTR szName;
- __forceinline VALUE(LPCSTR _name) : szName(_name) {}
-};
-
-struct INT_VALUE : public VALUE
-{
- int iValue;
- __forceinline INT_VALUE(LPCSTR _name, int _value)
- : VALUE(_name), iValue(_value)
- {}
-};
-
-struct LONG_VALUE : public VALUE
-{
- LONGLONG llValue;
- __forceinline LONG_VALUE(LPCSTR _name, LONGLONG _value)
- : VALUE(_name), llValue(_value)
- {}
-};
-
-struct CHAR_VALUE : public VALUE
-{
- LPCSTR szValue;
- __forceinline CHAR_VALUE(LPCSTR _name, LPCSTR _value)
- : VALUE(_name), szValue(_value)
- {}
-};
-
-struct FORMAT_VALUE : public VALUE
-{
- CMStringA szValue;
- FORMAT_VALUE(LPCSTR _name, LPCSTR _valueFormat, ...)
- : VALUE(_name)
- {
- va_list args;
- va_start(args, _valueFormat);
- szValue.FormatV(_valueFormat, args);
- va_end(args);
- }
-};
-
class HttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject
{
HttpRequest& operator=(const HttpRequest&); // to prevent copying;
@@ -93,31 +50,38 @@ protected:
HttpRequestUrl& operator=(const HttpRequestUrl&); // to prevent copying;
public:
- HttpRequestUrl & operator<<(const VALUE &param)
+ HttpRequestUrl& operator<<(const char *param)
{
- request.AddUrlParameter(param.szName);
+ if (param)
+ request.AddUrlParameter("%s", param);
return *this;
}
- HttpRequestUrl &operator<<(const INT_VALUE &param)
+ HttpRequestUrl& operator<<(const BOOL_PARAM &param)
+ {
+ request.AddUrlParameter("%s=%s", param.szName, param.bValue ? "true" : "false");
+ return *this;
+ }
+
+ HttpRequestUrl& operator<<(const INT_PARAM &param)
{
request.AddUrlParameter("%s=%i", param.szName, param.iValue);
return *this;
}
- HttpRequestUrl &operator<<(const LONG_VALUE &param)
+ HttpRequestUrl& operator<<(const INT64_PARAM &param)
{
- request.AddUrlParameter("%s=%lld", param.szName, param.llValue);
+ request.AddUrlParameter("%s=%lld", param.szName, param.iValue);
return *this;
}
- HttpRequestUrl &operator<<(const CHAR_VALUE &param)
+ HttpRequestUrl& operator<<(const CHAR_PARAM &param)
{
request.AddUrlParameter("%s=%s", param.szName, param.szValue);
return *this;
}
- char *ToString()
+ char* ToString()
{
return request.url.GetBuffer();
}
@@ -146,19 +110,7 @@ protected:
public:
HttpRequestHeaders(HttpRequest &request) : request(request) {}
- HttpRequestHeaders& operator<<(const VALUE &param)
- {
- Add(param.szName);
- return *this;
- }
-
- HttpRequestHeaders& operator<<(const CHAR_VALUE &param)
- {
- Add(param.szName, param.szValue);
- return *this;
- }
-
- HttpRequestHeaders& operator<<(const FORMAT_VALUE &param)
+ HttpRequestHeaders& operator<<(const CHAR_PARAM &param)
{
Add(param.szName, param.szValue);
return *this;
@@ -172,46 +124,46 @@ protected:
void AppendSeparator()
{
- if (!content.IsEmpty()) {
+ if (!content.IsEmpty())
content.AppendChar('&');
- }
}
public:
HttpRequestBody() {}
- HttpRequestBody & operator<<(const VALUE &param)
+ HttpRequestBody& operator<<(const char *str)
{
AppendSeparator();
- content.Append(param.szName);
+ if (str != nullptr)
+ content.Append(str);
return *this;
}
- HttpRequestBody & operator<<(const INT_VALUE &param)
+ HttpRequestBody& operator<<(const BOOL_PARAM &param)
{
AppendSeparator();
- content.AppendFormat("%s=%i", param.szName, param.iValue);
+ content.AppendFormat("%s=%s", param.szName, param.bValue ? "true" : "false");
return *this;
}
- HttpRequestBody & operator<<(const LONG_VALUE &param)
+ HttpRequestBody& operator<<(const INT_PARAM &param)
{
AppendSeparator();
- content.AppendFormat("%s=%lld", param.szName, param.llValue);
+ content.AppendFormat("%s=%i", param.szName, param.iValue);
return *this;
}
- HttpRequestBody & operator<<(const CHAR_VALUE &param)
+ HttpRequestBody& operator<<(const INT64_PARAM &param)
{
AppendSeparator();
- content.AppendFormat("%s=%s", param.szName, param.szValue);
+ content.AppendFormat("%s=%lld", param.szName, param.iValue);
return *this;
}
- HttpRequestBody & operator<<(const FORMAT_VALUE &param)
+ HttpRequestBody& operator<<(const CHAR_PARAM &param)
{
AppendSeparator();
- content.AppendFormat("%s=%s", param.szName, param.szValue.c_str());
+ content.AppendFormat("%s=%s", param.szName, param.szValue);
return *this;
}
diff --git a/protocols/FacebookRM/src/requests/channel.h b/protocols/FacebookRM/src/requests/channel.h
index e4d3ec84d5..a1c1b649de 100644
--- a/protocols/FacebookRM/src/requests/channel.h
+++ b/protocols/FacebookRM/src/requests/channel.h
@@ -42,59 +42,42 @@ public:
bool isPing = (type == PING);
- Url << CHAR_VALUE("channel", fc->chat_channel_.empty() ? ("p_" + fc->self_.user_id).c_str() : fc->chat_channel_.c_str());
+ Url << CHAR_PARAM("channel", fc->chat_channel_.empty() ? ("p_" + fc->self_.user_id).c_str() : fc->chat_channel_.c_str());
if (!isPing)
- Url << CHAR_VALUE("seq", fc->chat_sequence_num_.empty() ? "0" : fc->chat_sequence_num_.c_str());
+ Url << CHAR_PARAM("seq", fc->chat_sequence_num_.empty() ? "0" : fc->chat_sequence_num_.c_str());
Url
- << CHAR_VALUE("partition", fc->chat_channel_partition_.empty() ? "0" : fc->chat_channel_partition_.c_str())
- << CHAR_VALUE("clientid", fc->chat_clientid_.c_str())
- << CHAR_VALUE("cb", utils::text::rand_string(4, "0123456789abcdefghijklmnopqrstuvwxyz", &fc->random_).c_str());
-
- /*
- original cb = return (1048576 * Math.random() | 0).toString(36);
- char buffer[10];
- itoa(((int)(1048576 * (((double)rand()) / (RAND_MAX + 1))) | 0), buffer, 36);
- Url << CHAR_VALUE("cb", buffer);
- */
+ << CHAR_PARAM("partition", fc->chat_channel_partition_.empty() ? "0" : fc->chat_channel_partition_.c_str())
+ << CHAR_PARAM("clientid", fc->chat_clientid_.c_str())
+ << CHAR_PARAM("cb", utils::text::rand_string(4, "0123456789abcdefghijklmnopqrstuvwxyz", &fc->random_).c_str());
int idleSeconds = fc->parent->IdleSeconds();
- Url << INT_VALUE("idle", idleSeconds); // Browser is sending "idle" always, even if it's "0"
+ Url << INT_PARAM("idle", idleSeconds); // Browser is sending "idle" always, even if it's "0"
if (!isPing) {
- Url << "qp=y"; // TODO: what's this item?
- Url << "pws=fresh"; // TODO: what's this item?
- Url << "isq=487632"; // TODO: what's this item?
- Url << INT_VALUE("msgs_recv", fc->chat_msgs_recv_);
+ Url << CHAR_PARAM("qp", "y") << CHAR_PARAM("pws", "fresh") << INT_PARAM("isq", 487632);
+ Url << INT_PARAM("msgs_recv", fc->chat_msgs_recv_);
// TODO: sometimes there is &tur=1711 and &qpmade=<some actual timestamp> and &isq=487632
// Url << "request_batch=1"; // it somehow batches up more responses to one - then response has special "t=batched" type and "batches" array with the data
// Url << "msgr_region=LLA"; // it was here only for first pull, same as request_batch
}
- Url << "cap=8" // TODO: what's this item? Sometimes it's 0, sometimes 8
- << CHAR_VALUE("uid", fc->self_.user_id.c_str())
- << CHAR_VALUE("viewer_uid", fc->self_.user_id.c_str());
+ Url << INT_PARAM("cap", 8) // TODO: what's this item? Sometimes it's 0, sometimes 8
+ << CHAR_PARAM("uid", fc->self_.user_id.c_str())
+ << CHAR_PARAM("viewer_uid", fc->self_.user_id.c_str());
if (!fc->chat_sticky_num_.empty() && !fc->chat_sticky_pool_.empty()) {
- Url << CHAR_VALUE("sticky_token", fc->chat_sticky_num_.c_str());
- Url << CHAR_VALUE("sticky_pool", fc->chat_sticky_pool_.c_str());
+ Url << CHAR_PARAM("sticky_token", fc->chat_sticky_num_.c_str());
+ Url << CHAR_PARAM("sticky_pool", fc->chat_sticky_pool_.c_str());
}
if (!isPing && !fc->chat_traceid_.empty())
- Url << CHAR_VALUE("traceid", fc->chat_traceid_.c_str());
+ Url << CHAR_PARAM("traceid", fc->chat_traceid_.c_str());
if (fc->parent->isInvisible())
- Url << "state=offline";
+ Url << CHAR_PARAM("state", "offline");
else if (isPing || idleSeconds < 60)
- Url << "state=active";
-
- /*
- Body
- << "persistent=1"
- << CHAR_VALUE("email", ptrA(mir_urlEncode(username)))
- << CHAR_VALUE("pass", ptrA(mir_urlEncode(password)))
- << CHAR_VALUE("lgndim", "eyJ3IjoxOTIwLCJoIjoxMDgwLCJhdyI6MTgzNCwiYWgiOjEwODAsImMiOjMyfQ==") // means base64 encoded: {"w":1920,"h":1080,"aw":1834,"ah":1080,"c":32}
- << bodyData; // additional data parsed from form*/
+ Url << CHAR_PARAM("state", "active");
}
};
diff --git a/protocols/FacebookRM/src/requests/contacts.h b/protocols/FacebookRM/src/requests/contacts.h
index 6a92bf6b27..4b1122c808 100644
--- a/protocols/FacebookRM/src/requests/contacts.h
+++ b/protocols/FacebookRM/src/requests/contacts.h
@@ -43,28 +43,23 @@ public:
UserInfoRequest(facebook_client *fc, const LIST<char> &userIds) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/chat/user_info/")
{
- Url
- << "dpr=1";
+ Url << INT_PARAM("dpr", 1);
for (int i = 0; i < userIds.getCount(); i++) {
CMStringA id(::FORMAT, "ids[%i]", i);
- Body << CHAR_VALUE(id, ptrA(mir_urlEncode(userIds[i])));
+ Body << CHAR_PARAM(id, ptrA(mir_urlEncode(userIds[i])));
}
Body
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << "__a=1"
- << "__pc=PHASED:DEFAULT"
- << "__be=1"
- << "jazoest="
- << "__spin_r="
- << "__spin_b="
- << "__spin_t=";
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << INT_PARAM("__a", 1)
+ << INT_PARAM("__be", 1)
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT");
}
};
@@ -77,19 +72,19 @@ public:
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/chat/user_info_all/")
{
Url
- << "dpr=1"
- << CHAR_VALUE("viewer", fc->self_.user_id.c_str());
+ << INT_PARAM("dpr", 1)
+ << CHAR_PARAM("viewer", fc->self_.user_id.c_str());
Body
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << "__a=1"
- << "__pc=PHASED:DEFAULT"
- << "__be=-1";
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << INT_PARAM("__a", 1)
+ << INT_PARAM("__be", -1);
}
};
@@ -100,22 +95,16 @@ public:
AddFriendRequest(facebook_client *fc, const char *userId) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/add_friend/action.php")
{
- Url
- << "__a=1";
+ Url << INT_PARAM("__a", 1);
Body
- << CHAR_VALUE("to_friend", userId)
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << "action=add_friend"
- << "how_found=profile_button"
- << "ref_param=ts"
- << "outgoing_id="
- << "unwanted="
- << "logging_location="
- << "no_flyout_on_click=false"
- << "ego_log_data="
- << "lsd=";
+ << CHAR_PARAM("to_friend", userId)
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("action", "add_friend")
+ << CHAR_PARAM("how_found", "profile_button")
+ << CHAR_PARAM("ref_param", "ts")
+ << CHAR_PARAM("no_flyout_on_click", "false");
}
};
@@ -127,20 +116,20 @@ public:
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/profile/removefriendconfirm.php")
{
Url
- << "__a=1"
- << "norefresh=true"
- << "unref=button_dropdown"
- << CHAR_VALUE("uid", userId);
+ << INT_PARAM("__a", 1)
+ << BOOL_PARAM("norefresh", true)
+ << CHAR_PARAM("unref", "button_dropdown")
+ << CHAR_PARAM("uid", userId);
Body
- << CHAR_VALUE("uid", userId)
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << "norefresh=true"
- << "unref=button_dropdown"
- << "confirmed=1"
- << "__a=1";
+ << CHAR_PARAM("uid", userId)
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("norefresh", "true")
+ << CHAR_PARAM("unref", "button_dropdown")
+ << INT_PARAM("confirmed", 1)
+ << INT_PARAM("__a", 1);
}
};
@@ -151,14 +140,13 @@ public:
CancelFriendshipRequest(facebook_client *fc, const char *userId) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/friends/requests/cancel.php")
{
- Url
- << "__a=1";
+ Url << INT_PARAM("__a", 1);
Body
- << "confirmed=1"
- << CHAR_VALUE("friend", userId)
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str());
+ << INT_PARAM("confirmed", 1)
+ << CHAR_PARAM("friend", userId)
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str());
}
};
@@ -171,8 +159,7 @@ public:
AnswerFriendshipRequest(facebook_client *fc, const char *userId, Answer answer) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/requests/friends/ajax/")
{
- Url
- << "__a=1";
+ Url << INT_PARAM("__a", 1);
const char *action = "";
switch (answer) {
@@ -185,10 +172,10 @@ public:
}
Body
- << CHAR_VALUE("action", action)
- << CHAR_VALUE("id", userId)
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str());
+ << CHAR_PARAM("action", action)
+ << CHAR_PARAM("id", userId)
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str());
}
};
diff --git a/protocols/FacebookRM/src/requests/feeds.h b/protocols/FacebookRM/src/requests/feeds.h
index b1572696d4..0690998d2f 100644
--- a/protocols/FacebookRM/src/requests/feeds.h
+++ b/protocols/FacebookRM/src/requests/feeds.h
@@ -30,10 +30,15 @@ public:
NewsfeedRequest(facebook_client *fc) :
HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/ajax/home/generic.php")
{
+ BYTE feed_type = fc->parent->getByte(FACEBOOK_KEY_FEED_TYPE, 0);
+ if (feed_type >= _countof(feed_types))
+ feed_type = 0;
+
Url
- << fc->get_newsfeed_type().c_str()
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << "__a=1";
+ << CHAR_PARAM("sk", feed_types[feed_type].id)
+ << CHAR_PARAM("key", (feed_type < 2) ? "nf" : feed_types[feed_type].id)
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << INT_PARAM("__a", 1);
}
};
@@ -45,19 +50,18 @@ public:
HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/onthisday/story/query/")
{
Url
- << "__a=1"
- << "start_index=0"
- << "num_stories=20"
- << "last_section_header=0"
- << "last_section_key=regular_story"
- << "__af="
- << "__be=-1"
- << "__pc=PHASED:DEFAULT"
- << LONG_VALUE("timestamp", ::time(NULL))
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str());
+ << INT_PARAM("__a", 1)
+ << INT_PARAM("start_index", 0)
+ << INT_PARAM("num_stories", 20)
+ << INT_PARAM("last_section_header", 0)
+ << CHAR_PARAM("last_section_key", "regular_story")
+ << INT_PARAM("__be", -1)
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << INT64_PARAM("timestamp", ::time(NULL))
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str());
}
};
diff --git a/protocols/FacebookRM/src/requests/history.h b/protocols/FacebookRM/src/requests/history.h
index 2e22ca15dd..2b2184a1cf 100644
--- a/protocols/FacebookRM/src/requests/history.h
+++ b/protocols/FacebookRM/src/requests/history.h
@@ -46,7 +46,6 @@ public:
}
ptrA idEncoded(mir_urlEncode(id_.c_str()));
-
JSONNode root, o0, query_params;
int before = -1;
@@ -67,8 +66,8 @@ public:
root << JSON_PARAM("o0", o0);
Body
- << "batch_name=MessengerGraphQLThreadFetcherRe"
- << CHAR_VALUE("queries", root.write().c_str());
+ << CHAR_PARAM("batch_name", "MessengerGraphQLThreadFetcherRe")
+ << CHAR_PARAM("queries", root.write().c_str());
// example request data we need to send: { "o0":{"doc_id":"456789456123","query_params" : {"id":"123456789","message_limit" : 20,"load_messages" : 1,"load_read_receipts" : false,"before" : null}} }
@@ -106,7 +105,7 @@ public:
ptrA idEncoded(mir_urlEncode(id_.c_str()));
// Load only thread info
- Body << CMStringA(::FORMAT, "threads[%s][0]=%s", type, idEncoded).c_str();
+ Body << CHAR_PARAM(CMStringA(::FORMAT, "threads[%s][0]", type), idEncoded);
}
// Request both thread info and messages for single contact/chat
@@ -128,12 +127,12 @@ public:
CMStringA begin(::FORMAT, "messages[%s][%s]", type, idEncoded);
Body
- << CMStringA(::FORMAT, "%s[offset]=%i", begin.c_str(), 0).c_str()
- << CMStringA(::FORMAT, "%s[timestamp]=%s", begin.c_str(), "").c_str()
- << CMStringA(::FORMAT, "%s[limit]=%i", begin.c_str(), limit).c_str();
+ << INT_PARAM(CMStringA(::FORMAT, "%s[offset]", begin.c_str()), 0)
+ << CHAR_PARAM(CMStringA(::FORMAT, "%s[timestamp]", begin.c_str()), "")
+ << INT_PARAM(CMStringA(::FORMAT, "%s[limit]", begin.c_str()), limit);
// Load thread info
- Body << CMStringA(::FORMAT, "threads[%s][0]=%s", type, idEncoded).c_str();
+ Body << CHAR_PARAM(CMStringA(::FORMAT, "threads[%s][0]", type), idEncoded);
}
// Request both thread info and messages for more threads
@@ -152,12 +151,9 @@ public:
// Load messages
CMStringA begin(::FORMAT, "messages[%s][%s]", "thread_fbids", idEncoded);
Body
- << CMStringA(::FORMAT, "%s[offset]=%i", begin.c_str(), offset).c_str()
- //<< CMStringA(::FORMAT, "%s[timestamp]=%s", begin.c_str(), "").c_str()
- << CMStringA(::FORMAT, "%s[limit]=%i", begin.c_str(), limit).c_str();
-
- // Load thread info
- Body << CMStringA(::FORMAT, "threads[%s][%i]=%s", "thread_fbids", i, idEncoded).c_str();
+ << INT_PARAM(CMStringA(::FORMAT, "%s[offset]", begin.c_str()), offset)
+ << INT_PARAM(CMStringA(::FORMAT, "%s[limit]", begin.c_str()), limit)
+ << CHAR_PARAM(CMStringA(::FORMAT, "threads[%s][%i]", "thread_fbids", i), idEncoded);
}
}
@@ -165,19 +161,15 @@ private:
void setCommonBody(facebook_client *fc)
{
Body
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << "__a=1"
- << "__pc=PHASED:DEFAULT"
- << "__be=1"
- << "jazoest="
- << "__spin_r="
- << "__spin_b="
- << "__spin_t=";
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << INT_PARAM("__a", 1)
+ << INT_PARAM("__be", 1);
}
};
@@ -189,24 +181,21 @@ public:
UnreadThreadsRequest(facebook_client *fc) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/unread_threads.php")
{
- Url
- << "dpr=1";
+ Url << INT_PARAM("dpr", 1);
Body
- << "folders[0]=inbox"
- << "folders[1]=other" // TODO: "other" is probably unused, and there is now "pending" instead
- << "client=mercury"
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << "__a=1"
- << "__pc=PHASED:DEFAULT"
- << "__be=-1";
-
- //queries={"o0":{"doc_id":"2003371749678240","query_params":{"limit":99,"before":null,"tags":["PENDING","unread"],"includeDeliveryReceipts":true,"includeSeqID":false}}}
+ << CHAR_PARAM("folders[0]", "inbox")
+ << CHAR_PARAM("folders[1]", "other") // TODO: "other" is probably unused, and there is now "pending" instead
+ << CHAR_PARAM("client", "mercury")
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << INT_PARAM("__a", 1)
+ << INT_PARAM("__be", -1);
}
};
diff --git a/protocols/FacebookRM/src/requests/login.h b/protocols/FacebookRM/src/requests/login.h
index 08ee612403..be6cb1f244 100644
--- a/protocols/FacebookRM/src/requests/login.h
+++ b/protocols/FacebookRM/src/requests/login.h
@@ -30,8 +30,7 @@ public:
LoginRequest() :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_LOGIN "/login.php")
{
- Url
- << "login_attempt=1";
+ Url << INT_PARAM("login_attempt", 1);
}
LoginRequest(const char *username, const char *password, const char *urlData, const char *bodyData) :
@@ -40,14 +39,14 @@ public:
Persistent = NONE;
Url
- << "login_attempt=1"
+ << INT_PARAM("login_attempt", 1)
<< urlData; // additional data parsed from form
Body
- << "persistent=1"
- << CHAR_VALUE("email", ptrA(mir_urlEncode(username)))
- << CHAR_VALUE("pass", ptrA(mir_urlEncode(password)))
- << CHAR_VALUE("lgndim", "eyJ3IjoxOTIwLCJoIjoxMDgwLCJhdyI6MTgzNCwiYWgiOjEwODAsImMiOjMyfQ==") // means base64 encoded: {"w":1920,"h":1080,"aw":1834,"ah":1080,"c":32}
+ << INT_PARAM("persistent", 1)
+ << CHAR_PARAM("email", ptrA(mir_urlEncode(username)))
+ << CHAR_PARAM("pass", ptrA(mir_urlEncode(password)))
+ << CHAR_PARAM("lgndim", "eyJ3IjoxOTIwLCJoIjoxMDgwLCJhdyI6MTgzNCwiYWgiOjEwODAsImMiOjMyfQ==") // means base64 encoded: {"w":1920,"h":1080,"aw":1834,"ah":1080,"c":32}
<< bodyData; // additional data parsed from form
}
};
@@ -59,21 +58,20 @@ public:
LoginSmsRequest(facebook_client *fc, const char *dtsg) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/login/approvals/send_sms")
{
- Url
- << "dpr=1";
+ Url << INT_PARAM("dpr", 1);
Body
- << "method_requested=sms_requested"
- << "__a=1"
- << "__user=0"
- << "__be=0"
- << "__pc=EXP1:DEFAULT"
- << CHAR_VALUE("current_time", (utils::time::unix_timestamp() + ".000").c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("fb_dtsg", dtsg)
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << CHAR_VALUE("__rev", fc->__rev());
+ << CHAR_PARAM("method_requested", "sms_requested")
+ << INT_PARAM("__a", 1)
+ << INT_PARAM("__user", 0)
+ << INT_PARAM("__be", 0)
+ << CHAR_PARAM("__pc", "EXP1:DEFAULT")
+ << CHAR_PARAM("current_time", (utils::time::unix_timestamp() + ".000").c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("fb_dtsg", dtsg)
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__rev", fc->__rev());
}
};
@@ -84,20 +82,18 @@ public:
SetupMachineRequest() :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/checkpoint/")
{
- Url
- << "next";
+ Url << "next";
}
SetupMachineRequest(const char *dtsg, const char *nh, const char *submit) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/checkpoint/")
{
- Url
- << "next";
+ Url << "next";
Body
- << CMStringA(::FORMAT, "submit[%s]=%s", submit, submit).c_str()
- << CHAR_VALUE("nh", nh)
- << CHAR_VALUE("fb_dtsg", dtsg);
+ << CHAR_PARAM(CMStringA(::FORMAT, "submit[%s]", submit), submit)
+ << CHAR_PARAM("nh", nh)
+ << CHAR_PARAM("fb_dtsg", dtsg);
}
};
@@ -109,9 +105,8 @@ public:
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/logout.php")
{
Body
- << "ref="
- << CHAR_VALUE("fb_dtsg", dtsg)
- << CHAR_VALUE("h", logoutHash);
+ << CHAR_PARAM("fb_dtsg", dtsg)
+ << CHAR_PARAM("h", logoutHash);
}
};
diff --git a/protocols/FacebookRM/src/requests/messages.h b/protocols/FacebookRM/src/requests/messages.h
index 89765d6e34..a0d782612a 100644
--- a/protocols/FacebookRM/src/requests/messages.h
+++ b/protocols/FacebookRM/src/requests/messages.h
@@ -37,40 +37,37 @@ public:
// Use own persistent connection for sending messages
Persistent = MESSAGES;
- Url
- << "dpr=1";
+ Url << INT_PARAM("dpr", 1);
if (mir_strlen(captcha) > 0) {
Body
- << CHAR_VALUE("captcha_persist_data", captchaPersistData)
- << "recaptcha_challenge_field="
- << CHAR_VALUE("captcha_response", captcha);
+ << CHAR_PARAM("captcha_persist_data", captchaPersistData)
+ << CHAR_PARAM("captcha_response", captcha);
}
Body
- << "client=mercury" // or "web_messenger" (whole messages page)
- << "action_type=ma-type:user-generated-message";
+ << CHAR_PARAM("client", "mercury") // or "web_messenger" (whole messages page)
+ << CHAR_PARAM("action_type", "ma-type:user-generated-message");
// Experimental sticker sending support
std::string message_text = messageText; // FIXME: Rewrite this without std::string...
if (message_text.substr(0, 10) == "[[sticker:" && message_text.substr(message_text.length() - 2) == "]]") {
Body
<< "body="
- << CHAR_VALUE("sticker_id", ptrA(mir_urlEncode(message_text.substr(10, message_text.length() - 10 - 2).c_str())))
- << "has_attachment=true";
+ << CHAR_PARAM("sticker_id", ptrA(mir_urlEncode(message_text.substr(10, message_text.length() - 10 - 2).c_str())))
+ << BOOL_PARAM("has_attachment", true);
// TODO: For sending GIF images instead of "sticker_id=" there is "image_ids[0]=", otherwise it's same
}
else {
Body
- << CHAR_VALUE("body", ptrA(mir_urlEncode(messageText)))
- << "has_attachment=false";
+ << CHAR_PARAM("body", ptrA(mir_urlEncode(messageText)))
+ << BOOL_PARAM("has_attachment", false);
}
Body
- << "ephemeral_ttl_mode=0"
- // << "force_sms=true" // TODO: This is present always when sending via "web_messenger"
- << CHAR_VALUE("message_id", messageId)
- << CHAR_VALUE("offline_threading_id", messageId); // Same as message ID
+ << INT_PARAM("ephemeral_ttl_mode", 0)
+ << CHAR_PARAM("message_id", messageId)
+ << CHAR_PARAM("offline_threading_id", messageId); // Same as message ID
if (isChat) {
// NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
@@ -78,30 +75,29 @@ public:
if (threadFbid.substr(0, 3) == "id.")
threadFbid = threadFbid.substr(3);
- Body << CHAR_VALUE("thread_fbid", threadFbid.c_str());
+ Body << CHAR_PARAM("thread_fbid", threadFbid.c_str());
}
else {
Body
- << CHAR_VALUE("other_user_fbid", userId)
- << CHAR_VALUE("specific_to_list[0]", CMStringA(::FORMAT, "fbid:%s", userId))
- << CHAR_VALUE("specific_to_list[1]", CMStringA(::FORMAT, "fbid:%s", fc->self_.user_id.c_str()));
+ << CHAR_PARAM("other_user_fbid", userId)
+ << CHAR_PARAM("specific_to_list[0]", CMStringA(::FORMAT, "fbid:%s", userId))
+ << CHAR_PARAM("specific_to_list[1]", CMStringA(::FORMAT, "fbid:%s", fc->self_.user_id.c_str()));
}
Body
- << "signature_id=" // TODO: How to generate signature ID? It is present only when sending via "mercury"
- << "source=source:chat:web" // or "source:titan:web" for web_messenger
- << CHAR_VALUE("timestamp", utils::time::mili_timestamp().c_str())
- << "ui_push_phase=V3"
-
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << "__a=1"
- << "__pc=PHASED:DEFAULT"
- << "__be=-1";
+ // << "signature_id=" // TODO: How to generate signature ID? It is present only when sending via "mercury"
+ << CHAR_PARAM("source", "source:chat:web") // or "source:titan:web" for web_messenger
+ << CHAR_PARAM("timestamp", utils::time::mili_timestamp().c_str())
+ << CHAR_PARAM("ui_push_phase", "V3")
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << INT_PARAM("__a", 1)
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << INT_PARAM("__be", -1);
}
};
@@ -113,25 +109,24 @@ public:
SendTypingRequest(facebook_client *fc, const char *userId, bool isChat, bool isTyping) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/messaging/typ.php")
{
- Url
- << "dpr=1";
+ Url << INT_PARAM("dpr", 1);
ptrA idEncoded(mir_urlEncode(userId));
Body
- << (isTyping ? "typ=1" : "typ=0")
- << CHAR_VALUE("to", isChat ? "" : idEncoded)
- << CHAR_VALUE("thread", idEncoded)
- << "source=mercury-chat"
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << "__a=1"
- << "__pc=PHASED:DEFAULT"
- << "__be=-1";
+ << INT_PARAM("typ", isTyping ? 1 : 0)
+ << CHAR_PARAM("to", isChat ? "" : idEncoded)
+ << CHAR_PARAM("thread", idEncoded)
+ << CHAR_PARAM("source", "mercury-chat")
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << INT_PARAM("__a", 1)
+ << INT_PARAM("__be", -1);
}
};
@@ -142,8 +137,7 @@ public:
MarkMessageReadRequest(facebook_client *fc, const LIST<char> &ids) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/change_read_status.php")
{
- Url
- << "__a=1";
+ Url << INT_PARAM("__a", 1);
for (int i = 0; i < ids.getCount(); i++) {
std::string id_ = ids[i];
@@ -151,18 +145,18 @@ public:
if (id_.substr(0, 3) == "id.")
id_ = id_.substr(3);
- CMStringA id(::FORMAT, "ids[%s]=true", ptrA(mir_urlEncode(id_.c_str())));
- Body << id.c_str();
+ CMStringA id(::FORMAT, "ids[%s]", ptrA(mir_urlEncode(id_.c_str())));
+ Body << BOOL_PARAM(id, true);
}
Body
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << "__a=1";
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << INT_PARAM("__a", 1);
}
};
diff --git a/protocols/FacebookRM/src/requests/notifications.h b/protocols/FacebookRM/src/requests/notifications.h
index b5ea3bbe65..801af7f642 100644
--- a/protocols/FacebookRM/src/requests/notifications.h
+++ b/protocols/FacebookRM/src/requests/notifications.h
@@ -31,22 +31,21 @@ public:
GetNotificationsRequest(facebook_client *fc, int count) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/notifications/client/get.php")
{
- Url
- << "dpr=1";
+ Url << INT_PARAM("dpr", 1);
Body
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << "cursor=" // when loading more
- << INT_VALUE("length", count) // number of items to load
- << "businessID=" // probably for pages?
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << "__pc=PHASED:DEFAULT"
- << "__be=-1"
- << "__a=1";
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ // << "cursor=" // when loading more
+ << INT_PARAM("length", count) // number of items to load
+ // << "businessID=" // probably for pages?
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << INT_PARAM("__be", -1)
+ << INT_PARAM("__a", 1);
}
};
@@ -59,16 +58,15 @@ public:
HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/ajax/notifications/mark_read.php")
{
Url
- << "__a=1"
- << "seen=0"
- << "asyncSignal="
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << CHAR_VALUE("alert_ids%5B0%5D", ptrA(mir_urlEncode(id)));
+ << INT_PARAM("__a", 1)
+ << INT_PARAM("seen", 0)
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << CHAR_PARAM("alert_ids%5B0%5D", ptrA(mir_urlEncode(id)));
}
};
diff --git a/protocols/FacebookRM/src/requests/profile.h b/protocols/FacebookRM/src/requests/profile.h
index 1301262703..ecd0c43b4c 100644
--- a/protocols/FacebookRM/src/requests/profile.h
+++ b/protocols/FacebookRM/src/requests/profile.h
@@ -32,8 +32,7 @@ public:
{
flags |= NLHRF_REDIRECT;
- Url
- << "v=info";
+ Url << CHAR_PARAM("v", "info");
}
};
@@ -57,8 +56,7 @@ public:
{
flags |= NLHRF_REDIRECT;
- Url
- << CHAR_VALUE("profile_id", userId);
+ Url << CHAR_PARAM("profile_id", userId);
}
};
@@ -69,8 +67,7 @@ public:
ProfileRequest(bool mobileBasicWorks, const char *data) :
HttpRequest(REQUEST_GET, FORMAT, "%s/%s", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE, data)
{
- Url
- << "v=info";
+ Url << CHAR_PARAM("v", "info");
}
};
@@ -82,9 +79,9 @@ public:
HttpRequest(REQUEST_GET, FORMAT, "%s/profile.php", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE)
{
Url
- << CHAR_VALUE("id", userId)
- << "v=info"
- << "locale=en_US";
+ << CHAR_PARAM("id", userId)
+ << CHAR_PARAM("v", "info")
+ << CHAR_PARAM("locale", "en_US");
}
};
diff --git a/protocols/FacebookRM/src/requests/search.h b/protocols/FacebookRM/src/requests/search.h
index 9ca764ddf8..f7d77d600d 100644
--- a/protocols/FacebookRM/src/requests/search.h
+++ b/protocols/FacebookRM/src/requests/search.h
@@ -33,12 +33,12 @@ public:
flags |= NLHRF_REDIRECT;
Url
- << CHAR_VALUE("q", query)
- << INT_VALUE("s", s)
- << INT_VALUE("pn", pn);
+ << CHAR_PARAM("q", query)
+ << INT_PARAM("s", s)
+ << INT_PARAM("pn", pn);
if (mir_strlen(ssid) > 0) {
- Url << CHAR_VALUE("ssid", ssid);
+ Url << CHAR_PARAM("ssid", ssid);
}
}
};
diff --git a/protocols/FacebookRM/src/requests/status.h b/protocols/FacebookRM/src/requests/status.h
index 8275d28913..4589604c18 100644
--- a/protocols/FacebookRM/src/requests/status.h
+++ b/protocols/FacebookRM/src/requests/status.h
@@ -32,15 +32,15 @@ public:
HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/ajax/presence/reconnect.php")
{
Url
- << "__a=1"
- << "__pc=PHASED:DEFAULT"
- << "__be=-1"
- << CHAR_VALUE("reason", fc->chat_reconnect_reason_.empty() ? "6" : fc->chat_reconnect_reason_.c_str())
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev());
+ << INT_PARAM("__a", 1)
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << INT_PARAM("__be", -1)
+ << CHAR_PARAM("reason", fc->chat_reconnect_reason_.empty() ? "6" : fc->chat_reconnect_reason_.c_str())
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev());
}
};
@@ -52,22 +52,20 @@ public:
SetVisibilityRequest(facebook_client *fc, bool online) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/chat/privacy/visibility.php")
{
- Url
- << "dpr=1";
+ Url << INT_PARAM("dpr", 1);
Body
- << (online ? "visibility=1" : "visibility=0")
- << "window_id=0"
- << "__a=1"
- << "__pc=PHASED:DEFAULT"
- << "__be=-1"
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev());
- ;
+ << INT_PARAM("visibility", online ? 1 : 0)
+ << INT_PARAM("window_id", 0)
+ << INT_PARAM("__a", 1)
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << INT_PARAM("__be", -1)
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev());
}
};
diff --git a/protocols/FacebookRM/src/requests/utils.h b/protocols/FacebookRM/src/requests/utils.h
index 485cd09dd8..beef14842a 100644
--- a/protocols/FacebookRM/src/requests/utils.h
+++ b/protocols/FacebookRM/src/requests/utils.h
@@ -31,13 +31,13 @@ public:
HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/captcha/refresh_ajax.php")
{
Url
- << "__a=1"
- << "new_captcha_type=TFBCaptcha"
- << CHAR_VALUE("skipped_captcha_data", captchaPersistData)
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str());
+ << INT_PARAM("__a", 1)
+ << CHAR_PARAM("new_captcha_type", "TFBCaptcha")
+ << CHAR_PARAM("skipped_captcha_data", captchaPersistData)
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str());
}
};
@@ -49,41 +49,41 @@ public:
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/composerx/attachment/link/scraper/")
{
Url
- << "__a=1"
- << "composerurihash=2"
- << CHAR_VALUE("scrape_url", ptrA(mir_urlEncode(status->url.c_str())));
+ << INT_PARAM("__a", 1)
+ << INT_PARAM("composerurihash", 2)
+ << CHAR_PARAM("scrape_url", ptrA(mir_urlEncode(status->url.c_str())));
Body
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("targetid", status->user_id.empty() ? fc->self_.user_id.c_str() : status->user_id.c_str())
- << CHAR_VALUE("xhpc_targetid", status->user_id.empty() ? fc->self_.user_id.c_str() : status->user_id.c_str())
- << "istimeline=1"
- << "composercontext=composer"
- << "onecolumn=1"
- << "nctr[_mod]=pagelet_timeline_recent"
- << "__a=1"
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << CHAR_VALUE("__user", status->isPage && !status->user_id.empty() ? status->user_id.c_str() : fc->self_.user_id.c_str())
- << "loaded_components[0]=maininput"
- << "loaded_components[1]=backdateicon"
- << "loaded_components[2]=withtaggericon"
- << "loaded_components[3]=cameraicon"
- << "loaded_components[4]=placetaggericon"
- << "loaded_components[5]=mainprivacywidget"
- << "loaded_components[6]=withtaggericon"
- << "loaded_components[7]=backdateicon"
- << "loaded_components[8]=placetaggericon"
- << "loaded_components[9]=cameraicon"
- << "loaded_components[10]=mainprivacywidget"
- << "loaded_components[11]=maininput"
- << "loaded_components[12]=explicitplaceinput"
- << "loaded_components[13]=hiddenplaceinput"
- << "loaded_components[14]=placenameinput"
- << "loaded_components[15]=hiddensessionid"
- << "loaded_components[16]=withtagger"
- << "loaded_components[17]=backdatepicker"
- << "loaded_components[18]=placetagger"
- << "loaded_components[19]=citysharericon";
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("targetid", status->user_id.empty() ? fc->self_.user_id.c_str() : status->user_id.c_str())
+ << CHAR_PARAM("xhpc_targetid", status->user_id.empty() ? fc->self_.user_id.c_str() : status->user_id.c_str())
+ << INT_PARAM("istimeline", 1)
+ << CHAR_PARAM("composercontext", "composer")
+ << INT_PARAM("onecolumn", 1)
+ << CHAR_PARAM("nctr[_mod]", "pagelet_timeline_recent")
+ << INT_PARAM("__a", 1)
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__user", status->isPage && !status->user_id.empty() ? status->user_id.c_str() : fc->self_.user_id.c_str())
+ << CHAR_PARAM("loaded_components[0]", "maininput")
+ << CHAR_PARAM("loaded_components[1]", "backdateicon")
+ << CHAR_PARAM("loaded_components[2]", "withtaggericon")
+ << CHAR_PARAM("loaded_components[3]", "cameraicon")
+ << CHAR_PARAM("loaded_components[4]", "placetaggericon")
+ << CHAR_PARAM("loaded_components[5]", "mainprivacywidget")
+ << CHAR_PARAM("loaded_components[6]", "withtaggericon")
+ << CHAR_PARAM("loaded_components[7]", "backdateicon")
+ << CHAR_PARAM("loaded_components[8]", "placetaggericon")
+ << CHAR_PARAM("loaded_components[9]", "cameraicon")
+ << CHAR_PARAM("loaded_components[10]", "mainprivacywidget")
+ << CHAR_PARAM("loaded_components[11]", "maininput")
+ << CHAR_PARAM("loaded_components[12]", "explicitplaceinput")
+ << CHAR_PARAM("loaded_components[13]", "hiddenplaceinput")
+ << CHAR_PARAM("loaded_components[14]", "placenameinput")
+ << CHAR_PARAM("loaded_components[15]", "hiddensessionid")
+ << CHAR_PARAM("loaded_components[16]", "withtagger")
+ << CHAR_PARAM("loaded_components[17]", "backdatepicker")
+ << CHAR_PARAM("loaded_components[18]", "placetagger")
+ << CHAR_PARAM("loaded_components[19]", "citysharericon");
}
};
@@ -103,8 +103,8 @@ public:
SwitchIdentityRequest(const char *dtsg, const char *userId) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/identity_switch.php")
{
- Url << "__a=1";
- Body << CHAR_VALUE("fb_dtsg", dtsg) << CHAR_VALUE("user_id", userId) << CHAR_VALUE("url", FACEBOOK_URL_HOMEPAGE);
+ Url << INT_PARAM("__a", 1);
+ Body << CHAR_PARAM("fb_dtsg", dtsg) << CHAR_PARAM("user_id", userId) << CHAR_PARAM("url", FACEBOOK_URL_HOMEPAGE);
}
};
@@ -116,36 +116,31 @@ public:
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/updatestatus.php")
{
Url
- << "__a=1";
+ << INT_PARAM("__a", 1);
ptrA text(mir_urlEncode(status->text.c_str()));
Body
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << CHAR_VALUE("__user", status->isPage && !status->user_id.empty() ? status->user_id.c_str() : fc->self_.user_id.c_str())
- << CHAR_VALUE("xhpc_targetid", status->user_id.empty() ? fc->self_.user_id.c_str() : status->user_id.c_str())
- << CHAR_VALUE("xhpc_message", text)
- << CHAR_VALUE("xhpc_message_text", text)
- << "xhpc_context=profile"
- << "xhpc_ismeta=1"
- << "xhpc_timeline=1"
- << "xhpc_composerid=u_0_2y"
- << "is_explicit_place="
- << "composertags_place="
- << "composertags_city="
- << "composer_session_id="
- << "composer_predicted_city="
- << "disable_location_sharing=false"
- << "nctr[_mod]=pagelet_composer";
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__user", status->isPage && !status->user_id.empty() ? status->user_id.c_str() : fc->self_.user_id.c_str())
+ << CHAR_PARAM("xhpc_targetid", status->user_id.empty() ? fc->self_.user_id.c_str() : status->user_id.c_str())
+ << CHAR_PARAM("xhpc_message", text)
+ << CHAR_PARAM("xhpc_message_text", text)
+ << CHAR_PARAM("xhpc_context", "profile")
+ << INT_PARAM("xhpc_ismeta", 1)
+ << INT_PARAM("xhpc_timeline", 1)
+ << CHAR_PARAM("xhpc_composerid", "u_0_2y")
+ << BOOL_PARAM("disable_location_sharing", false)
+ << CHAR_PARAM("nctr[_mod]", "pagelet_composer");
if (!status->isPage)
- Body << CHAR_VALUE("audience[0][value]", fc->get_privacy_type().c_str());
+ Body << CHAR_PARAM("audience[0][value]", fc->get_privacy_type().c_str());
if (!status->place.empty())
- Body << CHAR_VALUE("composertags_place_name", ptrA(mir_urlEncode(status->place.c_str())));
+ Body << CHAR_PARAM("composertags_place_name", ptrA(mir_urlEncode(status->place.c_str())));
// Status with users
for (std::vector<facebook_user*>::size_type i = 0; i < status->users.size(); i++) {
@@ -153,8 +148,8 @@ public:
CMStringA withName(::FORMAT, "text_composertags_with[%i]", i);
Body
- << CHAR_VALUE(withId.c_str(), status->users[i]->user_id.c_str())
- << CHAR_VALUE(withName.c_str(), status->users[i]->real_name.c_str());
+ << CHAR_PARAM(withId.c_str(), status->users[i]->user_id.c_str())
+ << CHAR_PARAM(withName.c_str(), status->users[i]->real_name.c_str());
}
// Link attachment
@@ -173,14 +168,14 @@ public:
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/pokes/dialog/")
{
Url
- << "__a=1";
+ << INT_PARAM("__a", 1);
Body
- << "do_confirm=0"
- << CHAR_VALUE("poke_target", userId)
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str());
+ << INT_PARAM("do_confirm", 0)
+ << CHAR_PARAM("poke_target", userId)
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str());
}
};
diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h
index 037887a10e..b6de90ab7a 100644
--- a/protocols/FacebookRM/src/version.h
+++ b/protocols/FacebookRM/src/version.h
@@ -1,11 +1,11 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 4
#define __RELEASE_NUM 0
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
-#define __PLUGIN_NAME "Facebook RM"
+#define __PLUGIN_NAME "Facebook"
#define __FILENAME "Facebook.dll"
#define __DESCRIPTION "Facebook protocol support for Miranda NG."
#define __AUTHOR "Michal Zelinka, Robert Pösel"