summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-01-04 20:45:00 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-01-04 20:45:00 +0300
commit5b32a855e518f67589fd49837795a605a19badce (patch)
tree58e6664efc8c826a35e72e4d1a54e8e957b75c42 /protocols/FacebookRM/src
parent823e3839b108658811f689f959f51058effd82ac (diff)
code reordering, not to reassemble the whole project on each change in headers
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r--protocols/FacebookRM/src/channel.cpp77
-rw-r--r--protocols/FacebookRM/src/client.h2
-rw-r--r--protocols/FacebookRM/src/constants.h254
-rw-r--r--protocols/FacebookRM/src/contacts.cpp112
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp26
-rw-r--r--protocols/FacebookRM/src/feeds.cpp56
-rw-r--r--protocols/FacebookRM/src/history.cpp115
-rw-r--r--protocols/FacebookRM/src/http_request.h230
-rw-r--r--protocols/FacebookRM/src/login.cpp102
-rw-r--r--protocols/FacebookRM/src/messages.cpp120
-rw-r--r--protocols/FacebookRM/src/notifications.cpp64
-rw-r--r--protocols/FacebookRM/src/profile.cpp75
-rw-r--r--protocols/FacebookRM/src/requests/channel.h84
-rw-r--r--protocols/FacebookRM/src/requests/contacts.h182
-rw-r--r--protocols/FacebookRM/src/requests/feeds.h68
-rw-r--r--protocols/FacebookRM/src/requests/history.h134
-rw-r--r--protocols/FacebookRM/src/requests/login.h113
-rw-r--r--protocols/FacebookRM/src/requests/messages.h163
-rw-r--r--protocols/FacebookRM/src/requests/notifications.h73
-rw-r--r--protocols/FacebookRM/src/requests/profile.h88
-rw-r--r--protocols/FacebookRM/src/requests/status.h72
-rw-r--r--protocols/FacebookRM/src/requests/utils.h182
-rw-r--r--protocols/FacebookRM/src/search.cpp (renamed from protocols/FacebookRM/src/requests/search.h)34
-rw-r--r--protocols/FacebookRM/src/status.cpp63
-rw-r--r--protocols/FacebookRM/src/stdafx.h14
-rw-r--r--protocols/FacebookRM/src/utils.cpp157
26 files changed, 1329 insertions, 1331 deletions
diff --git a/protocols/FacebookRM/src/channel.cpp b/protocols/FacebookRM/src/channel.cpp
new file mode 100644
index 0000000000..9498209ff2
--- /dev/null
+++ b/protocols/FacebookRM/src/channel.cpp
@@ -0,0 +1,77 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
+
+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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "stdafx.h"
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// receiving updates, sending activity ping
+
+ChannelRequest::ChannelRequest(facebook_client *fc, Type type) :
+ HttpRequest(REQUEST_POST, FORMAT,
+ type == PULL ? FACEBOOK_SERVER_CHAT "/pull" : FACEBOOK_SERVER_CHAT "/active_ping",
+ fc->chat_conn_num_.empty() ? "0" : fc->chat_conn_num_.c_str(),
+ fc->chat_channel_host_.c_str())
+{
+ if (type == PULL) {
+ timeout = 65 * 1000;
+ Persistent = CHANNEL;
+ }
+
+ bool isPing = (type == PING);
+
+ Url << CHAR_PARAM("channel", fc->chat_channel_.empty() ? ("p_" + fc->self_.user_id).c_str() : fc->chat_channel_.c_str());
+ if (!isPing)
+ Url << CHAR_PARAM("seq", fc->chat_sequence_num_.empty() ? "0" : fc->chat_sequence_num_.c_str());
+
+ Url
+ << 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_PARAM("idle", idleSeconds); // Browser is sending "idle" always, even if it's "0"
+
+ if (!isPing) {
+ 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 << 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_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_PARAM("traceid", fc->chat_traceid_.c_str());
+
+ if (fc->parent->isInvisible())
+ Url << CHAR_PARAM("state", "offline");
+ else if (isPing || idleSeconds < 60)
+ Url << CHAR_PARAM("state", "active");
+}
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index 129a2ae8c1..3ece37c27e 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -205,7 +205,7 @@ public:
////////////////////////////////////////////////////////////
// HTTP communication
- http::response sendRequest(HttpRequest *request);
+ http::response sendRequest(class HttpRequest *request);
bool save_url(const std::string &url, const std::wstring &filename, HNETLIBCONN &nlc);
////////////////////////////////////////////////////////////
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index 70470a3ba2..764e213286 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -23,175 +23,155 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
// Product management
-#define FACEBOOK_NAME "Facebook"
-#define FACEBOOK_URL_HOMEPAGE "https://www.facebook.com"
-#define FACEBOOK_URL_REQUESTS "https://www.facebook.com/n/?reqs.php"
-#define FACEBOOK_URL_MESSAGES "https://www.facebook.com/n/?inbox"
-#define FACEBOOK_URL_NOTIFICATIONS "https://www.facebook.com/n/?notifications"
-#define FACEBOOK_URL_PROFILE "https://www.facebook.com/profile.php?id="
-#define FACEBOOK_URL_GROUP "https://www.facebook.com/n/?home.php&sk=group_"
-#define FACEBOOK_URL_PICTURE "https://graph.facebook.com/%s/picture"
-#define FACEBOOK_URL_CONVERSATION "https://www.facebook.com/messages/t/"
-//#define FACEBOOK_URL_STICKER "https://www.facebook.com/stickers/asset/?sticker_id=%s&image_type=BestEffortImage"
+#define FACEBOOK_NAME "Facebook"
+#define FACEBOOK_URL_HOMEPAGE "https://www.facebook.com"
+#define FACEBOOK_URL_REQUESTS "https://www.facebook.com/n/?reqs.php"
+#define FACEBOOK_URL_MESSAGES "https://www.facebook.com/n/?inbox"
+#define FACEBOOK_URL_NOTIFICATIONS "https://www.facebook.com/n/?notifications"
+#define FACEBOOK_URL_PROFILE "https://www.facebook.com/profile.php?id="
+#define FACEBOOK_URL_GROUP "https://www.facebook.com/n/?home.php&sk=group_"
+#define FACEBOOK_URL_PICTURE "https://graph.facebook.com/%s/picture"
+#define FACEBOOK_URL_CONVERSATION "https://www.facebook.com/messages/t/"
// Connection
-#define FACEBOOK_SERVER_REGULAR "www.facebook.com"
-#define FACEBOOK_SERVER_MBASIC "mbasic.facebook.com"
-#define FACEBOOK_SERVER_MOBILE "m.facebook.com"
-#define FACEBOOK_SERVER_CHAT "%s-%s.facebook.com"
-#define FACEBOOK_SERVER_LOGIN "www.facebook.com"
-#define FACEBOOK_SERVER_APPS "apps.facebook.com"
-#define FACEBOOK_SERVER_DOMAIN "facebook.com"
+#define FACEBOOK_SERVER_REGULAR "www.facebook.com"
+#define FACEBOOK_SERVER_MBASIC "mbasic.facebook.com"
+#define FACEBOOK_SERVER_MOBILE "m.facebook.com"
+#define FACEBOOK_SERVER_CHAT "%s-%s.facebook.com"
+#define FACEBOOK_SERVER_LOGIN "www.facebook.com"
+#define FACEBOOK_SERVER_APPS "apps.facebook.com"
+#define FACEBOOK_SERVER_DOMAIN "facebook.com"
// Facebook clients
-#define FACEBOOK_CLIENT_WEB L"Facebook (website)"
-#define FACEBOOK_CLIENT_MOBILE L"Facebook (mobile)"
-#define FACEBOOK_CLIENT_OTHER L"Facebook (other)"
-#define FACEBOOK_CLIENT_APP L"Facebook App"
-#define FACEBOOK_CLIENT_MESSENGER L"Facebook Messenger"
+#define FACEBOOK_CLIENT_WEB L"Facebook (website)"
+#define FACEBOOK_CLIENT_MOBILE L"Facebook (mobile)"
+#define FACEBOOK_CLIENT_OTHER L"Facebook (other)"
+#define FACEBOOK_CLIENT_APP L"Facebook App"
+#define FACEBOOK_CLIENT_MESSENGER L"Facebook Messenger"
// Various constants
-#define FACEBOOK_NOTIFICATIONS_CHATROOM "_notifications"
-#define FACEBOOK_CHATROOM_NAMES_COUNT 3 // number of participant names to use for chatrooms without specific name (on website it's 2)
-#define FACEBOOK_NOTIFICATIONS_LOAD_COUNT 20 // number of last notifications to load on login to notify
-#define MANUALLY_TRIGGERED (void*)1 // to use as thread parameter to notify this action was activated by user, so we should show info popups
+#define FACEBOOK_NOTIFICATIONS_CHATROOM "_notifications"
+#define FACEBOOK_CHATROOM_NAMES_COUNT 3 // number of participant names to use for chatrooms without specific name (on website it's 2)
+#define FACEBOOK_NOTIFICATIONS_LOAD_COUNT 20 // number of last notifications to load on login to notify
+#define MANUALLY_TRIGGERED (void*)1 // to use as thread parameter to notify this action was activated by user, so we should show info popups
// Limits
-#define FACEBOOK_MESSAGE_LIMIT 200000 // this is guessed limit, in reality it is bigger
-#define FACEBOOK_MESSAGE_LIMIT_TEXT "200000"
-#define FACEBOOK_MIND_LIMIT 63206 // this should be correct maximal limit
-#define FACEBOOK_MIND_LIMIT_TEXT "63206"
-#define FACEBOOK_TIMEOUTS_LIMIT 3
-#define FACEBOOK_GROUP_NAME_LIMIT 100
-#define FACEBOOK_MESSAGES_ON_OPEN_LIMIT 99
-#define FACEBOOK_TYPING_TIME 60
-#define FACEBOOK_IGNORE_COUNTER_LIMIT 100 // how many consequent requests it should keep info about duplicit message ids
-#define FACEBOOK_PING_TIME 90 // every 90 seconds send activity_ping (it's guessed value, but it's similar how often website does it)
-
-#define MAX_NEWSFEED_LEN 500
-#define MAX_LINK_DESCRIPTION_LEN 200
-
-#define TEXT_ELLIPSIS "\xE2\x80\xA6" // unicode ellipsis
-#define TEXT_EMOJI_LINK "\xF0\x9F\x94\x97" // emoji :link:
-#define TEXT_EMOJI_CLOCK "\xF0\x9F\x95\x92" // emoji :clock3:
-#define TEXT_EMOJI_PAGE "\xF0\x9F\x93\x84" // emoji :page_facing_up:
+#define FACEBOOK_MESSAGE_LIMIT 200000 // this is guessed limit, in reality it is bigger
+#define FACEBOOK_MESSAGE_LIMIT_TEXT "200000"
+#define FACEBOOK_MIND_LIMIT 63206 // this should be correct maximal limit
+#define FACEBOOK_MIND_LIMIT_TEXT "63206"
+#define FACEBOOK_TIMEOUTS_LIMIT 3
+#define FACEBOOK_GROUP_NAME_LIMIT 100
+#define FACEBOOK_MESSAGES_ON_OPEN_LIMIT 99
+#define FACEBOOK_TYPING_TIME 60
+#define FACEBOOK_IGNORE_COUNTER_LIMIT 100 // how many consequent requests it should keep info about duplicit message ids
+#define FACEBOOK_PING_TIME 90 // every 90 seconds send activity_ping (it's guessed value, but it's similar how often website does it)
+
+#define MAX_NEWSFEED_LEN 500
+#define MAX_LINK_DESCRIPTION_LEN 200
+
+#define TEXT_ELLIPSIS "\xE2\x80\xA6" // unicode ellipsis
+#define TEXT_EMOJI_LINK "\xF0\x9F\x94\x97" // emoji :link:
+#define TEXT_EMOJI_CLOCK "\xF0\x9F\x95\x92" // emoji :clock3:
+#define TEXT_EMOJI_PAGE "\xF0\x9F\x93\x84" // emoji :page_facing_up:
// Defaults
-#define FACEBOOK_MINIMAL_POLL_RATE 10
-#define FACEBOOK_DEFAULT_POLL_RATE 24 // in seconds
-#define FACEBOOK_MAXIMAL_POLL_RATE 60
-
-#define DEFAULT_SET_MIRANDA_STATUS 0
-#define DEFAULT_LOGGING_ENABLE 0
-#define DEFAULT_SYSTRAY_NOTIFY 0
-#define DEFAULT_DISABLE_STATUS_NOTIFY 0
-#define DEFAULT_BIG_AVATARS 0
-#define DEFAULT_DISCONNECT_CHAT 0
-#define DEFAULT_MAP_STATUSES 0
-#define DEFAULT_CUSTOM_SMILEYS 0
-#define DEFAULT_LOAD_PAGES 0
-#define DEFAULT_KEEP_UNREAD 0
-#define DEFAULT_FILTER_ADS 0
-#define DEFAULT_MESSAGES_ON_OPEN 0
-#define DEFAULT_MESSAGES_ON_OPEN_COUNT 10
-#define DEFAULT_HIDE_CHATS 0
-#define DEFAULT_ENABLE_CHATS 1
-#define DEFAULT_JOIN_EXISTING_CHATS 1
-#define DEFAULT_NOTIFICATIONS_CHATROOM 0
-#define DEFAULT_NAME_AS_NICK 1
-#define DEFAULT_LOAD_ALL_CONTACTS 0
-#define DEFAULT_PAGES_ALWAYS_ONLINE 1
-#define DEFAULT_TYPING_WHEN_INVISIBLE 1
-
-#define DEFAULT_EVENT_NOTIFICATIONS_ENABLE 1
-#define DEFAULT_EVENT_FEEDS_ENABLE 0
-#define DEFAULT_EVENT_FRIENDSHIP_ENABLE 1
-#define DEFAULT_EVENT_TICKER_ENABLE 0
-#define DEFAULT_EVENT_ON_THIS_DAY_ENABLE 0
+#define FACEBOOK_MINIMAL_POLL_RATE 10
+#define FACEBOOK_DEFAULT_POLL_RATE 24 // in seconds
+#define FACEBOOK_MAXIMAL_POLL_RATE 60
+
+#define DEFAULT_SET_MIRANDA_STATUS 0
+#define DEFAULT_LOGGING_ENABLE 0
+#define DEFAULT_SYSTRAY_NOTIFY 0
+#define DEFAULT_DISABLE_STATUS_NOTIFY 0
+#define DEFAULT_BIG_AVATARS 0
+#define DEFAULT_DISCONNECT_CHAT 0
+#define DEFAULT_MAP_STATUSES 0
+#define DEFAULT_CUSTOM_SMILEYS 0
+#define DEFAULT_LOAD_PAGES 0
+#define DEFAULT_KEEP_UNREAD 0
+#define DEFAULT_FILTER_ADS 0
+#define DEFAULT_MESSAGES_ON_OPEN 0
+#define DEFAULT_MESSAGES_ON_OPEN_COUNT 10
+#define DEFAULT_HIDE_CHATS 0
+#define DEFAULT_ENABLE_CHATS 1
+#define DEFAULT_JOIN_EXISTING_CHATS 1
+#define DEFAULT_NOTIFICATIONS_CHATROOM 0
+#define DEFAULT_NAME_AS_NICK 1
+#define DEFAULT_LOAD_ALL_CONTACTS 0
+#define DEFAULT_PAGES_ALWAYS_ONLINE 1
+#define DEFAULT_TYPING_WHEN_INVISIBLE 1
+
+#define DEFAULT_EVENT_NOTIFICATIONS_ENABLE 1
+#define DEFAULT_EVENT_FEEDS_ENABLE 0
+#define DEFAULT_EVENT_FRIENDSHIP_ENABLE 1
+#define DEFAULT_EVENT_TICKER_ENABLE 0
+#define DEFAULT_EVENT_ON_THIS_DAY_ENABLE 0
// Send message return values
-#define SEND_MESSAGE_OK 0
-#define SEND_MESSAGE_ERROR 1
-#define SEND_MESSAGE_CANCEL -1
+#define SEND_MESSAGE_OK 0
+#define SEND_MESSAGE_ERROR 1
+#define SEND_MESSAGE_CANCEL -1
// Event types
-#define FACEBOOK_EVENTTYPE_CALL 10010
-
-enum ContactType {
- CONTACT_FRIEND = 1, // contact that IS on our server list
- CONTACT_NONE = 2, // contact that ISN'T on our server list
- CONTACT_REQUEST = 3, // contact that we asked for friendship
- CONTACT_APPROVE = 4, // contact that is asking us for approval of friendship
- CONTACT_PAGE = 5 // contact is Facebook page
+#define FACEBOOK_EVENTTYPE_CALL 10010
+
+enum ContactType
+{
+ CONTACT_FRIEND = 1, // contact that IS on our server list
+ CONTACT_NONE = 2, // contact that ISN'T on our server list
+ CONTACT_REQUEST = 3, // contact that we asked for friendship
+ CONTACT_APPROVE = 4, // contact that is asking us for approval of friendship
+ CONTACT_PAGE = 5 // contact is Facebook page
};
-enum ClientType {
- CLIENT_WEB = 1, // Facebook website
- CLIENT_APP = 2, // Facebook mobile application
+enum ClientType
+{
+ CLIENT_WEB = 1, // Facebook website
+ CLIENT_APP = 2, // Facebook mobile application
CLIENT_MESSENGER = 3, // Facebook Messenger application
- CLIENT_OTHER = 4, // Facebook over XMPP
- CLIENT_MOBILE = 5 // Facebook on unknown mobile client (can't be determined for offline contacts)
+ CLIENT_OTHER = 4, // Facebook over XMPP
+ CLIENT_MOBILE = 5 // Facebook on unknown mobile client (can't be determined for offline contacts)
};
// TODO: Rework to "Events" and add also typing, seen, contact status, chat switch, etc. then have JSON parser only for parsing and a single place for processing updates
// Each type then could have also separate class representing it. And when giving it in some list, make it map of arrays with key=thread_id to group it by contact/chat, to have it more effective
// Use also for Poke and such events...
-enum MessageType {
- MESSAGE = 1,
- PHONE_CALL = 2,
- VIDEO_CALL = 3,
- ADMIN_TEXT = 4,
- SUBSCRIBE = 5,
- UNSUBSCRIBE = 6,
- THREAD_NAME = 7,
- THREAD_IMAGE = 8,
+
+enum MessageType
+{
+ MESSAGE = 1,
+ PHONE_CALL = 2,
+ VIDEO_CALL = 3,
+ ADMIN_TEXT = 4,
+ SUBSCRIBE = 5,
+ UNSUBSCRIBE = 6,
+ THREAD_NAME = 7,
+ THREAD_IMAGE = 8,
};
-enum EventType {
- EVENT_CLIENT = 1, // Client error
- EVENT_NEWSFEED = 2, // Newsfeed (wall) message
- EVENT_NOTIFICATION = 3, // New notification
- EVENT_OTHER = 4, // Other event (poke sent, status update, ...)
- EVENT_FRIENDSHIP = 5, // Friendship event
- EVENT_TICKER = 6, // Ticker message
- EVENT_ON_THIS_DAY = 7, // On this day post (memories)
+enum EventType
+{
+ EVENT_CLIENT = 1, // Client error
+ EVENT_NEWSFEED = 2, // Newsfeed (wall) message
+ EVENT_NOTIFICATION = 3, // New notification
+ EVENT_OTHER = 4, // Other event (poke sent, status update, ...)
+ EVENT_FRIENDSHIP = 5, // Friendship event
+ EVENT_TICKER = 6, // Ticker message
+ EVENT_ON_THIS_DAY = 7, // On this day post (memories)
};
-enum ParticipantRole {
+enum ParticipantRole
+{
ROLE_ME = 0,
ROLE_FRIEND = 1,
ROLE_NONE = 2
};
-typedef struct {
+struct ttype
+{
const char *name;
const char *id;
-} ttype;
-
-// News Feed types
-static const ttype feed_types[] = {
- { LPGEN("Top News"), "h_nor" },
- { LPGEN("Most Recent"), "h_chr" },
- { LPGEN("Pages"), "pages" },
- //{ LPGEN("Apps and Games"), "FEED_FILTER_KEY_APPS_AND_GAMES" },
-
- //{ LPGEN("Wall Posts"), "app_2915120374" },
- //{ LPGEN("Photos"), "app_2305272732_2392950137" },
- //{ LPGEN("Links"), "app_2309869772" },
-};
-
-// Server types
-static const ttype server_types[] = {
- { LPGEN("Classic website"), "www.facebook.com" },
- { LPGEN("Mobile website"), "m.facebook.com" },
- { LPGEN("Smartphone website"), "touch.facebook.com" },
};
-// Status privacy types
-static const ttype privacy_types[] = {
- { LPGEN("Public"), "80" },
- { LPGEN("Friends of friends"), "111&audience[0][custom_value]=50" },
- { LPGEN("Friends"), "40" },
- { LPGEN("Friends except acquaintances"), "127" },
- { LPGEN("Only me"), "10" },
-}; \ No newline at end of file
+extern const ttype feed_types[3], server_types[3], privacy_types[5];
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index 6352300348..6ae8fb0604 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -721,3 +721,115 @@ void FacebookProto::StopTyping(MCONTACT hContact)
CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
facy.typers.erase(hContact);
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+UserInfoRequest::UserInfoRequest(facebook_client *fc, const LIST<char> &userIds) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/chat/user_info/")
+{
+ Url << INT_PARAM("dpr", 1);
+
+ for (int i = 0; i < userIds.getCount(); i++) {
+ CMStringA id(::FORMAT, "ids[%i]", i);
+ Body << CHAR_PARAM(id, ptrA(mir_urlEncode(userIds[i])));
+ }
+
+ Body
+ << 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");
+}
+
+UserInfoAllRequest::UserInfoAllRequest(facebook_client *fc) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/chat/user_info_all/")
+{
+ Url
+ << INT_PARAM("dpr", 1)
+ << CHAR_PARAM("viewer", fc->self_.user_id.c_str());
+
+ Body
+ << 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);
+}
+
+AddFriendRequest::AddFriendRequest(facebook_client *fc, const char *userId) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/add_friend/action.php")
+{
+ Url << INT_PARAM("__a", 1);
+
+ Body
+ << 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");
+}
+
+DeleteFriendRequest::DeleteFriendRequest(facebook_client *fc, const char *userId) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/profile/removefriendconfirm.php")
+{
+ Url
+ << INT_PARAM("__a", 1)
+ << BOOL_PARAM("norefresh", true)
+ << CHAR_PARAM("unref", "button_dropdown")
+ << CHAR_PARAM("uid", userId);
+
+ Body
+ << 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);
+}
+
+CancelFriendshipRequest::CancelFriendshipRequest(facebook_client *fc, const char *userId) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/friends/requests/cancel.php")
+{
+ Url << INT_PARAM("__a", 1);
+
+ Body
+ << 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());
+}
+
+AnswerFriendshipRequest::AnswerFriendshipRequest(facebook_client *fc, const char *userId, Answer answer) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/requests/friends/ajax/")
+{
+ Url << INT_PARAM("__a", 1);
+
+ const char *action = "";
+ switch (answer) {
+ case CONFIRM:
+ action = "confirm";
+ break;
+ case REJECT:
+ action = "reject";
+ break;
+ }
+
+ Body
+ << 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/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index e3988b3907..b5c1c6645f 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -22,6 +22,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
+// News Feed types
+const ttype feed_types[3] =
+{
+ { LPGEN("Top News"), "h_nor" },
+ { LPGEN("Most Recent"), "h_chr" },
+ { LPGEN("Pages"), "pages" },
+};
+
+// Server types
+const ttype server_types[3] =
+{
+ { LPGEN("Classic website"), "www.facebook.com" },
+ { LPGEN("Mobile website"), "m.facebook.com" },
+ { LPGEN("Smartphone website"), "touch.facebook.com" },
+};
+
+// Status privacy types
+const ttype privacy_types[5] =
+{
+ { LPGEN("Public"), "80" },
+ { LPGEN("Friends of friends"), "111&audience[0][custom_value]=50" },
+ { LPGEN("Friends"), "40" },
+ { LPGEN("Friends except acquaintances"), "127" },
+ { LPGEN("Only me"), "10" },
+};
+
static BOOL LoadDBCheckState(FacebookProto* ppro, HWND hwnd, int idCtrl, const char* szSetting, BYTE bDef)
{
BOOL state = ppro->getByte(szSetting, bDef);
diff --git a/protocols/FacebookRM/src/feeds.cpp b/protocols/FacebookRM/src/feeds.cpp
new file mode 100644
index 0000000000..9e94c57f6e
--- /dev/null
+++ b/protocols/FacebookRM/src/feeds.cpp
@@ -0,0 +1,56 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
+
+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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "stdafx.h"
+
+// getting newsfeed posts
+NewsfeedRequest::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
+ << 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);
+}
+
+MemoriesRequest::MemoriesRequest(facebook_client *fc) :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/onthisday/story/query/")
+{
+ Url
+ << 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(nullptr))
+ << 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/history.cpp b/protocols/FacebookRM/src/history.cpp
new file mode 100644
index 0000000000..e1abb1dbeb
--- /dev/null
+++ b/protocols/FacebookRM/src/history.cpp
@@ -0,0 +1,115 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
+
+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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "stdafx.h"
+
+ThreadInfoRequest::ThreadInfoRequest(facebook_client *fc, bool isChat, const char *id, const char* timestamp, int limit) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/")
+{
+ setCommonBody(fc);
+
+ // FIXME: FB removed /ajax/mercury/thread_info requests and now all messaging stuff does through /api/graphqlbatch/ - all loading of threads, (unread) messages, list of contacts in groupchat, etc.
+ // All these request must be rewritten to the new request. Preparation is below but unfinished.
+
+ //const char *type = isChat ? "thread_fbids" : "user_ids";
+ std::string id_ = id; // FIXME: Rewrite this without std::string...
+ if (isChat) {
+ // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
+ if (id_.substr(0, 3) == "id.")
+ id_ = id_.substr(3);
+ }
+ ptrA idEncoded(mir_urlEncode(id_.c_str()));
+
+ JSONNode root, o0, query_params;
+ query_params
+ << CHAR_PARAM("id", idEncoded)
+ << INT_PARAM("message_limit", (limit == -1) ? 50 : limit)
+ << INT_PARAM("load_messages", 0)
+ << BOOL_PARAM("load_read_receipts", false);
+
+ if (timestamp != nullptr)
+ query_params << CHAR_PARAM("before", timestamp);
+ else
+ query_params << NULL_PARAM("before");
+
+ o0 << CHAR_PARAM("doc_id", "1549485615075443") << JSON_PARAM("query_params", query_params);
+ root << JSON_PARAM("o0", o0);
+
+ Body << CHAR_PARAM("queries", utils::url::encode(root.write()).c_str());
+}
+
+// Request both thread info and messages for more threads
+ThreadInfoRequest::ThreadInfoRequest(facebook_client *fc, const LIST<char> &ids, int offset, int limit) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/")
+{
+ setCommonBody(fc);
+
+ for (int i = 0; i < ids.getCount(); i++) {
+ // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
+ std::string id_ = ids[i]; // FIXME: Rewrite this without std::string...
+ if (id_.substr(0, 3) == "id.")
+ id_ = id_.substr(3);
+ ptrA idEncoded(mir_urlEncode(id_.c_str()));
+
+ // Load messages
+ CMStringA begin(::FORMAT, "messages[%s][%s]", "thread_fbids", idEncoded);
+ Body
+ << 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);
+ }
+}
+
+void ThreadInfoRequest::setCommonBody(facebook_client *fc)
+{
+ Body
+ << CHAR_PARAM("batch_name", "MessengerGraphQLThreadFetcherRe")
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << INT_PARAM("__a", 1)
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << INT_PARAM("__be", 1)
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << CHAR_PARAM("__rev", fc->__rev())
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("jazoest", "265816910476541027556899745586581711208287100122699749108");
+}
+
+UnreadThreadsRequest::UnreadThreadsRequest(facebook_client *fc) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/unread_threads.php")
+{
+ Url << INT_PARAM("dpr", 1);
+
+ Body
+ << 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/http_request.h b/protocols/FacebookRM/src/http_request.h
index 7c03adec46..523d7d6af8 100644
--- a/protocols/FacebookRM/src/http_request.h
+++ b/protocols/FacebookRM/src/http_request.h
@@ -246,4 +246,234 @@ public:
}
};
+/////////////////////////////////////////////////////////////////////////////////////////
+// channel.cpp
+
+struct ChannelRequest : public HttpRequest
+{
+ enum Type { PULL, PING };
+
+ ChannelRequest(facebook_client *fc, Type type);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// contact.cpp
+
+// getting frienship requests (using mobile website)
+struct GetFriendshipsRequest : public HttpRequest
+{
+ GetFriendshipsRequest(bool mobileBasicWorks) :
+ HttpRequest(REQUEST_GET, FORMAT, "%s/friends/center/requests/", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE)
+ {
+ flags |= NLHRF_REDIRECT;
+ }
+};
+
+// getting info about particular friend
+struct UserInfoRequest : public HttpRequest
+{ UserInfoRequest(facebook_client *fc, const LIST<char> &userIds);
+};
+
+// getting info about all friends
+struct UserInfoAllRequest : public HttpRequest
+{ UserInfoAllRequest(facebook_client *fc);
+};
+
+// requesting friendships
+struct AddFriendRequest : public HttpRequest
+{ AddFriendRequest(facebook_client *fc, const char *userId);
+};
+
+// deleting friendships
+struct DeleteFriendRequest : public HttpRequest
+{ DeleteFriendRequest(facebook_client *fc, const char *userId);
+};
+
+// canceling (our) friendship request
+struct CancelFriendshipRequest : public HttpRequest
+{ CancelFriendshipRequest(facebook_client *fc, const char *userId);
+};
+
+// approving or ignoring friendship requests
+struct AnswerFriendshipRequest : public HttpRequest
+{
+ enum Answer { CONFIRM, REJECT };
+
+ AnswerFriendshipRequest(facebook_client *fc, const char *userId, Answer answer);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// feeds.cpp
+
+// getting newsfeed posts
+struct NewsfeedRequest : public HttpRequest
+{ NewsfeedRequest(facebook_client *fc);
+};
+
+// getting memories ("on this day") posts
+struct MemoriesRequest : public HttpRequest
+{ MemoriesRequest(facebook_client *fc);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// history.cpp
+
+// getting thread info and messages
+class ThreadInfoRequest : public HttpRequest
+{
+ void setCommonBody(facebook_client *fc);
+
+public:
+ // Request only messages history
+ ThreadInfoRequest(facebook_client *fc, bool isChat, const char *id, const char* timestamp = nullptr, int limit = -1);
+ ThreadInfoRequest(facebook_client *fc, const LIST<char> &ids, int offset, int limit);
+};
+
+// getting unread threads
+struct UnreadThreadsRequest : public HttpRequest
+{ UnreadThreadsRequest(facebook_client *fc);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// login.cpp
+
+// connecting physically
+struct LoginRequest : public HttpRequest
+{
+ LoginRequest();
+ LoginRequest(const char *username, const char *password, const char *urlData, const char *bodyData);
+};
+
+// disconnecting physically
+struct LogoutRequest : public HttpRequest
+{ LogoutRequest(const char *dtsg, const char *logoutHash);
+};
+
+// request to receive login code via SMS
+struct LoginSmsRequest : public HttpRequest
+{ LoginSmsRequest(facebook_client *fc, const char *dtsg);
+};
+
+// setting machine name
+struct SetupMachineRequest : public HttpRequest
+{
+ SetupMachineRequest();
+ SetupMachineRequest(const char *dtsg, const char *nh, const char *submit);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// messages.cpp
+
+// sending messages
+struct SendMessageRequest : public HttpRequest
+{ SendMessageRequest(facebook_client *fc, const char *userId, const char *threadId, const char *messageId, const char *messageText, bool isChat, const char *captcha, const char *captchaPersistData);
+};
+
+// sending typing notification
+struct SendTypingRequest : public HttpRequest
+{ SendTypingRequest(facebook_client *fc, const char *userId, bool isChat, bool isTyping);
+};
+
+struct MarkMessageReadRequest : public HttpRequest
+{ MarkMessageReadRequest(facebook_client *fc, const LIST<char> &ids);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// notifications.cpp
+
+// getting notifications
+struct GetNotificationsRequest : public HttpRequest
+{ GetNotificationsRequest(facebook_client *fc, int count);
+};
+
+// marking notifications read
+struct MarkNotificationReadRequest : public HttpRequest
+{ MarkNotificationReadRequest(facebook_client *fc, const char *id);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// profile.cpp
+
+// getting own name, avatar, ...
+struct HomeRequest : public HttpRequest
+{ HomeRequest();
+};
+
+// getting fb_dtsg
+struct DtsgRequest : public HttpRequest
+{ DtsgRequest();
+};
+
+// request mobile page containing profile picture
+struct ProfilePictureRequest : public HttpRequest
+{ ProfilePictureRequest(bool mobileBasicWorks, const char *userId);
+};
+
+// request mobile page containing user profile
+struct ProfileRequest : public HttpRequest
+{ ProfileRequest(bool mobileBasicWorks, const char *data);
+};
+
+// request mobile page containing user profile by his id, and in english language (for parsing data)
+struct ProfileInfoRequest : public HttpRequest
+{ ProfileInfoRequest(bool mobileBasicWorks, const char *userId);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// search.cpp
+
+// searching
+struct SearchRequest : public HttpRequest
+{ SearchRequest(bool mobileBasicWorks, const char *query, int s, int pn, const char *ssid);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// status.cpp
+
+// getting info about channel and connecting to it
+struct ReconnectRequest : public HttpRequest
+{ ReconnectRequest(facebook_client *fc);
+};
+
+// setting chat visibility
+struct SetVisibilityRequest : public HttpRequest
+{ SetVisibilityRequest(facebook_client *fc, bool online);
+};
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// utils.cpp
+
+// getting data for given url (for sending/posting reasons)
+struct LinkScraperRequest : public HttpRequest
+{ LinkScraperRequest(facebook_client *fc, status_data *status);
+};
+
+// refreshing captcha dialog (changing captcha type)
+struct RefreshCaptchaRequest : public HttpRequest
+{ RefreshCaptchaRequest(facebook_client *fc, const char *captchaPersistData);
+};
+
+// getting owned/admined pages list
+struct GetPagesRequest : public HttpRequest
+{
+ GetPagesRequest() :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/bookmarks/pages")
+ {}
+};
+
+// changing identity to post status for pages
+struct SwitchIdentityRequest : public HttpRequest
+{ SwitchIdentityRequest(const char *dtsg, const char *userId);
+};
+
+// posting status to our or friends's wall
+struct SharePostRequest : public HttpRequest
+{ SharePostRequest(facebook_client *fc, status_data *status, const char *linkData);
+};
+
+// sending pokes
+struct SendPokeRequest : public HttpRequest
+{ SendPokeRequest(facebook_client *fc, const char *userId);
+};
+
#endif //_HTTP_REQUEST_H_ \ No newline at end of file
diff --git a/protocols/FacebookRM/src/login.cpp b/protocols/FacebookRM/src/login.cpp
new file mode 100644
index 0000000000..8547da48d2
--- /dev/null
+++ b/protocols/FacebookRM/src/login.cpp
@@ -0,0 +1,102 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
+
+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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "stdafx.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// connecting physically
+
+LoginRequest::LoginRequest() :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_LOGIN "/login.php")
+{
+ Url << INT_PARAM("login_attempt", 1);
+}
+
+LoginRequest::LoginRequest(const char *username, const char *password, const char *urlData, const char *bodyData) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_LOGIN "/login.php")
+{
+ Persistent = NONE;
+
+ Url
+ << INT_PARAM("login_attempt", 1)
+ << urlData; // additional data parsed from form
+
+ Body
+ << 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
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// request to receive login code via SMS
+
+LoginSmsRequest::LoginSmsRequest(facebook_client *fc, const char *dtsg) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/login/approvals/send_sms")
+{
+ Url << INT_PARAM("dpr", 1);
+
+ Body
+ << 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());
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// setting machine name
+
+SetupMachineRequest::SetupMachineRequest() :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/checkpoint/")
+{
+ Url << "next";
+}
+
+SetupMachineRequest::SetupMachineRequest(const char *dtsg, const char *nh, const char *submit) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/checkpoint/")
+{
+ Url << "next";
+
+ Body
+ << CHAR_PARAM(CMStringA(::FORMAT, "submit[%s]", submit), submit)
+ << CHAR_PARAM("nh", nh)
+ << CHAR_PARAM("fb_dtsg", dtsg);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// disconnecting physically
+
+LogoutRequest::LogoutRequest(const char *dtsg, const char *logoutHash) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/logout.php")
+{
+ Body
+ << CHAR_PARAM("fb_dtsg", dtsg)
+ << CHAR_PARAM("h", logoutHash);
+}
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp
index e634473c6d..d6284c43ea 100644
--- a/protocols/FacebookRM/src/messages.cpp
+++ b/protocols/FacebookRM/src/messages.cpp
@@ -220,3 +220,123 @@ void FacebookProto::StickerAsSmiley(std::string sticker, const std::string &url,
cont.path = dir;
CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, (LPARAM)&cont);
}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+
+SendMessageRequest::SendMessageRequest(
+ facebook_client *fc,
+ const char *userId,
+ const char *threadId,
+ const char *messageId,
+ const char *messageText,
+ bool isChat,
+ const char *captcha,
+ const char *captchaPersistData)
+ : HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/messaging/send/")
+{
+ // Don't notify errors for this request, because we're getting them inline in messaging window
+ NotifyErrors = false;
+
+ // Use own persistent connection for sending messages
+ Persistent = MESSAGES;
+
+ Url << INT_PARAM("dpr", 1);
+
+ if (mir_strlen(captcha) > 0)
+ Body << CHAR_PARAM("captcha_persist_data", captchaPersistData) << CHAR_PARAM("captcha_response", captcha);
+
+ Body << CHAR_PARAM("client", "mercury") << 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) == "]]")
+ // TODO: For sending GIF images instead of "sticker_id=" there is "image_ids[0]=", otherwise it's same
+ Body
+ << "body="
+ << CHAR_PARAM("sticker_id", ptrA(mir_urlEncode(message_text.substr(10, message_text.length() - 10 - 2).c_str())))
+ << BOOL_PARAM("has_attachment", true);
+ else
+ Body << CHAR_PARAM("body", ptrA(mir_urlEncode(messageText))) << BOOL_PARAM("has_attachment", false);
+
+ Body
+ << 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
+ std::string threadFbid = threadId; // FIXME: Rewrite this without std::string...
+ if (threadFbid.substr(0, 3) == "id.")
+ threadFbid = threadFbid.substr(3);
+
+ Body << CHAR_PARAM("thread_fbid", threadFbid.c_str());
+ }
+ else
+ Body
+ << 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"
+ << 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);
+}
+
+SendTypingRequest::SendTypingRequest(facebook_client *fc, const char *userId, bool isChat, bool isTyping) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/messaging/typ.php")
+{
+ Url << INT_PARAM("dpr", 1);
+
+ ptrA idEncoded(mir_urlEncode(userId));
+
+ Body
+ << 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);
+}
+
+MarkMessageReadRequest::MarkMessageReadRequest(facebook_client *fc, const LIST<char> &ids) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/change_read_status.php")
+{
+ Url << INT_PARAM("__a", 1);
+
+ for (int i = 0; i < ids.getCount(); i++) {
+ std::string id_ = ids[i];
+ // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
+ if (id_.substr(0, 3) == "id.")
+ id_ = id_.substr(3);
+
+ CMStringA id(::FORMAT, "ids[%s]", ptrA(mir_urlEncode(id_.c_str())));
+ Body << BOOL_PARAM(id, true);
+ }
+
+ Body
+ << 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/notifications.cpp b/protocols/FacebookRM/src/notifications.cpp
new file mode 100644
index 0000000000..eee2574fce
--- /dev/null
+++ b/protocols/FacebookRM/src/notifications.cpp
@@ -0,0 +1,64 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
+
+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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "stdafx.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// getting notifications
+
+GetNotificationsRequest::GetNotificationsRequest(facebook_client *fc, int count) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/notifications/client/get.php")
+{
+ Url << INT_PARAM("dpr", 1);
+
+ Body
+ << 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);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// marking notifications read
+
+MarkNotificationReadRequest::MarkNotificationReadRequest(facebook_client *fc, const char *id) :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/ajax/notifications/mark_read.php")
+{
+ Url
+ << 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/profile.cpp b/protocols/FacebookRM/src/profile.cpp
new file mode 100644
index 0000000000..6b0e8a4250
--- /dev/null
+++ b/protocols/FacebookRM/src/profile.cpp
@@ -0,0 +1,75 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
+
+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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "stdafx.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// getting own name, avatar, ...
+
+HomeRequest::HomeRequest() :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_MOBILE "/profile.php")
+{
+ flags |= NLHRF_REDIRECT;
+
+ Url << CHAR_PARAM("v", "info");
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// getting fb_dtsg
+
+DtsgRequest::DtsgRequest() :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_MOBILE "/profile/basic/intro/bio/")
+{
+ flags |= NLHRF_REDIRECT;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// request mobile page containing profile picture
+
+ProfilePictureRequest::ProfilePictureRequest(bool mobileBasicWorks, const char *userId) :
+ HttpRequest(REQUEST_GET, FORMAT, "%s/profile/picture/view/", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE)
+{
+ flags |= NLHRF_REDIRECT;
+
+ Url << CHAR_PARAM("profile_id", userId);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// request mobile page containing user profile
+
+ProfileRequest::ProfileRequest(bool mobileBasicWorks, const char *data) :
+ HttpRequest(REQUEST_GET, FORMAT, "%s/%s", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE, data)
+{
+ Url << CHAR_PARAM("v", "info");
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// request mobile page containing user profile by his id, and in english language (for parsing data)
+
+ProfileInfoRequest::ProfileInfoRequest(bool mobileBasicWorks, const char *userId) :
+ HttpRequest(REQUEST_GET, FORMAT, "%s/profile.php", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE)
+{
+ Url
+ << CHAR_PARAM("id", userId)
+ << CHAR_PARAM("v", "info")
+ << CHAR_PARAM("locale", "en_US");
+}
diff --git a/protocols/FacebookRM/src/requests/channel.h b/protocols/FacebookRM/src/requests/channel.h
deleted file mode 100644
index a1c1b649de..0000000000
--- a/protocols/FacebookRM/src/requests/channel.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
-
-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
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef _FACEBOOK_REQUEST_CHANNEL_H_
-#define _FACEBOOK_REQUEST_CHANNEL_H_
-
-// receiving updates, sending activity ping
-class ChannelRequest : public HttpRequest
-{
-public:
- enum Type { PULL, PING };
-
- ChannelRequest(facebook_client *fc, Type type) :
- HttpRequest(REQUEST_POST, FORMAT,
- type == PULL ? FACEBOOK_SERVER_CHAT "/pull" : FACEBOOK_SERVER_CHAT "/active_ping",
- fc->chat_conn_num_.empty() ? "0" : fc->chat_conn_num_.c_str(),
- fc->chat_channel_host_.c_str())
- {
- if (type == PULL) {
- timeout = 65 * 1000;
- Persistent = CHANNEL;
- }
-
- bool isPing = (type == PING);
-
- Url << CHAR_PARAM("channel", fc->chat_channel_.empty() ? ("p_" + fc->self_.user_id).c_str() : fc->chat_channel_.c_str());
- if (!isPing)
- Url << CHAR_PARAM("seq", fc->chat_sequence_num_.empty() ? "0" : fc->chat_sequence_num_.c_str());
-
- Url
- << 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_PARAM("idle", idleSeconds); // Browser is sending "idle" always, even if it's "0"
-
- if (!isPing) {
- 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 << 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_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_PARAM("traceid", fc->chat_traceid_.c_str());
-
- if (fc->parent->isInvisible())
- Url << CHAR_PARAM("state", "offline");
- else if (isPing || idleSeconds < 60)
- Url << CHAR_PARAM("state", "active");
- }
-};
-
-#endif //_FACEBOOK_REQUEST_CHANNEL_H_
diff --git a/protocols/FacebookRM/src/requests/contacts.h b/protocols/FacebookRM/src/requests/contacts.h
deleted file mode 100644
index 4b1122c808..0000000000
--- a/protocols/FacebookRM/src/requests/contacts.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
-
-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
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef _FACEBOOK_REQUEST_CONTACTS_H_
-#define _FACEBOOK_REQUEST_CONTACTS_H_
-
-// getting frienship requests (using mobile website)
-class GetFriendshipsRequest : public HttpRequest
-{
-public:
- GetFriendshipsRequest(bool mobileBasicWorks) :
- HttpRequest(REQUEST_GET, FORMAT, "%s/friends/center/requests/", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE)
- {
- flags |= NLHRF_REDIRECT;
- }
-};
-
-
-// getting info about particular friend
-// revised 3.12.2017
-class UserInfoRequest : public HttpRequest
-{
-public:
- UserInfoRequest(facebook_client *fc, const LIST<char> &userIds) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/chat/user_info/")
- {
- Url << INT_PARAM("dpr", 1);
-
- for (int i = 0; i < userIds.getCount(); i++) {
- CMStringA id(::FORMAT, "ids[%i]", i);
- Body << CHAR_PARAM(id, ptrA(mir_urlEncode(userIds[i])));
- }
-
- Body
- << 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");
- }
-};
-
-// getting info about all friends
-// revised 17.8.2016
-class UserInfoAllRequest : public HttpRequest
-{
-public:
- UserInfoAllRequest(facebook_client *fc) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/chat/user_info_all/")
- {
- Url
- << INT_PARAM("dpr", 1)
- << CHAR_PARAM("viewer", fc->self_.user_id.c_str());
-
- Body
- << 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);
- }
-};
-
-// requesting friendships
-class AddFriendRequest : public HttpRequest
-{
-public:
- AddFriendRequest(facebook_client *fc, const char *userId) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/add_friend/action.php")
- {
- Url << INT_PARAM("__a", 1);
-
- Body
- << 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");
- }
-};
-
-// deleting friendships
-class DeleteFriendRequest : public HttpRequest
-{
-public:
- DeleteFriendRequest(facebook_client *fc, const char *userId) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/profile/removefriendconfirm.php")
- {
- Url
- << INT_PARAM("__a", 1)
- << BOOL_PARAM("norefresh", true)
- << CHAR_PARAM("unref", "button_dropdown")
- << CHAR_PARAM("uid", userId);
-
- Body
- << 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);
- }
-};
-
-// canceling (our) friendship request
-class CancelFriendshipRequest : public HttpRequest
-{
-public:
- CancelFriendshipRequest(facebook_client *fc, const char *userId) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/friends/requests/cancel.php")
- {
- Url << INT_PARAM("__a", 1);
-
- Body
- << 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());
- }
-};
-
-// approving or ignoring friendship requests
-class AnswerFriendshipRequest : public HttpRequest
-{
-public:
- enum Answer { CONFIRM, REJECT };
-
- AnswerFriendshipRequest(facebook_client *fc, const char *userId, Answer answer) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/requests/friends/ajax/")
- {
- Url << INT_PARAM("__a", 1);
-
- const char *action = "";
- switch (answer) {
- case CONFIRM:
- action = "confirm";
- break;
- case REJECT:
- action = "reject";
- break;
- }
-
- Body
- << 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());
- }
-};
-
-#endif //_FACEBOOK_REQUEST_CONTACTS_H_
diff --git a/protocols/FacebookRM/src/requests/feeds.h b/protocols/FacebookRM/src/requests/feeds.h
deleted file mode 100644
index 7cc9fa0d3c..0000000000
--- a/protocols/FacebookRM/src/requests/feeds.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
-
-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
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef _FACEBOOK_REQUEST_FEEDS_H_
-#define _FACEBOOK_REQUEST_FEEDS_H_
-
-// getting newsfeed posts
-class NewsfeedRequest : public HttpRequest
-{
-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
- << 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);
- }
-};
-
-// getting memories ("on this day") posts
-class MemoriesRequest : public HttpRequest
-{
-public:
- MemoriesRequest(facebook_client *fc) :
- HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/onthisday/story/query/")
- {
- Url
- << 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(nullptr))
- << CHAR_PARAM("__dyn", fc->__dyn())
- << CHAR_PARAM("__req", fc->__req())
- << CHAR_PARAM("__rev", fc->__rev())
- << CHAR_PARAM("__user", fc->self_.user_id.c_str());
- }
-};
-
-#endif //_FACEBOOK_REQUEST_FEEDS_H_
diff --git a/protocols/FacebookRM/src/requests/history.h b/protocols/FacebookRM/src/requests/history.h
deleted file mode 100644
index 08def19920..0000000000
--- a/protocols/FacebookRM/src/requests/history.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
-
-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
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef _FACEBOOK_REQUEST_HISTORY_H_
-#define _FACEBOOK_REQUEST_HISTORY_H_
-
-// getting thread info and messages
-// revised 3.12.2017
-class ThreadInfoRequest : public HttpRequest
-{
- JSONNode data;
-
-public:
- // Request only messages history
- ThreadInfoRequest(facebook_client *fc, bool isChat, const char *id, const char* timestamp = nullptr, int limit = -1) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/")
- {
- setCommonBody(fc);
-
- // FIXME: FB removed /ajax/mercury/thread_info requests and now all messaging stuff does through /api/graphqlbatch/ - all loading of threads, (unread) messages, list of contacts in groupchat, etc.
- // All these request must be rewritten to the new request. Preparation is below but unfinished.
-
- //const char *type = isChat ? "thread_fbids" : "user_ids";
- std::string id_ = id; // FIXME: Rewrite this without std::string...
- if (isChat) {
- // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
- if (id_.substr(0, 3) == "id.")
- id_ = id_.substr(3);
- }
- ptrA idEncoded(mir_urlEncode(id_.c_str()));
-
- JSONNode root, o0, query_params;
- query_params
- << CHAR_PARAM("id", idEncoded)
- << INT_PARAM("message_limit", (limit == -1) ? 50 : limit)
- << INT_PARAM("load_messages", 0)
- << BOOL_PARAM("load_read_receipts", false);
-
- if (timestamp != nullptr)
- query_params << CHAR_PARAM("before", timestamp);
- else
- query_params << NULL_PARAM("before");
-
- o0 << CHAR_PARAM("doc_id", "1549485615075443") << JSON_PARAM("query_params", query_params);
- root << JSON_PARAM("o0", o0);
-
- Body << CHAR_PARAM("queries", utils::url::encode(root.write()).c_str());
- }
-
- // Request both thread info and messages for more threads
- ThreadInfoRequest(facebook_client *fc, const LIST<char> &ids, int offset, int limit) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/")
- {
- setCommonBody(fc);
-
- for (int i = 0; i < ids.getCount(); i++) {
- // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
- std::string id_ = ids[i]; // FIXME: Rewrite this without std::string...
- if (id_.substr(0, 3) == "id.")
- id_ = id_.substr(3);
- ptrA idEncoded(mir_urlEncode(id_.c_str()));
-
- // Load messages
- CMStringA begin(::FORMAT, "messages[%s][%s]", "thread_fbids", idEncoded);
- Body
- << 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);
- }
- }
-
-private:
- void setCommonBody(facebook_client *fc)
- {
- Body
- << CHAR_PARAM("batch_name", "MessengerGraphQLThreadFetcherRe")
- << CHAR_PARAM("__user", fc->self_.user_id.c_str())
- << INT_PARAM("__a", 1)
- << CHAR_PARAM("__dyn", fc->__dyn())
- << CHAR_PARAM("__req", fc->__req())
- << INT_PARAM("__be", 1)
- << CHAR_PARAM("__pc", "PHASED:DEFAULT")
- << CHAR_PARAM("__rev", fc->__rev())
- << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_PARAM("jazoest", "265816910476541027556899745586581711208287100122699749108");
- }
-};
-
-// getting unread threads
-// revised 17.8.2016
-class UnreadThreadsRequest : public HttpRequest
-{
-public:
- UnreadThreadsRequest(facebook_client *fc) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/unread_threads.php")
- {
- Url << INT_PARAM("dpr", 1);
-
- Body
- << 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);
- }
-};
-
-#endif //_FACEBOOK_REQUEST_HISTORY_H_
diff --git a/protocols/FacebookRM/src/requests/login.h b/protocols/FacebookRM/src/requests/login.h
deleted file mode 100644
index be6cb1f244..0000000000
--- a/protocols/FacebookRM/src/requests/login.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
-
-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
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef _FACEBOOK_REQUEST_LOGIN_H_
-#define _FACEBOOK_REQUEST_LOGIN_H_
-
-// connecting physically
-class LoginRequest : public HttpRequest
-{
-public:
- LoginRequest() :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_LOGIN "/login.php")
- {
- Url << INT_PARAM("login_attempt", 1);
- }
-
- LoginRequest(const char *username, const char *password, const char *urlData, const char *bodyData) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_LOGIN "/login.php")
- {
- Persistent = NONE;
-
- Url
- << INT_PARAM("login_attempt", 1)
- << urlData; // additional data parsed from form
-
- Body
- << 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
- }
-};
-
-// request to receive login code via SMS
-class LoginSmsRequest : public HttpRequest
-{
-public:
- LoginSmsRequest(facebook_client *fc, const char *dtsg) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/login/approvals/send_sms")
- {
- Url << INT_PARAM("dpr", 1);
-
- Body
- << 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());
- }
-};
-
-// setting machine name
-class SetupMachineRequest : public HttpRequest
-{
-public:
- SetupMachineRequest() :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/checkpoint/")
- {
- Url << "next";
- }
-
- SetupMachineRequest(const char *dtsg, const char *nh, const char *submit) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/checkpoint/")
- {
- Url << "next";
-
- Body
- << CHAR_PARAM(CMStringA(::FORMAT, "submit[%s]", submit), submit)
- << CHAR_PARAM("nh", nh)
- << CHAR_PARAM("fb_dtsg", dtsg);
- }
-};
-
-// disconnecting physically
-class LogoutRequest : public HttpRequest
-{
-public:
- LogoutRequest(const char *dtsg, const char *logoutHash) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/logout.php")
- {
- Body
- << CHAR_PARAM("fb_dtsg", dtsg)
- << CHAR_PARAM("h", logoutHash);
- }
-};
-
-#endif //_FACEBOOK_REQUEST_LOGIN_H_
diff --git a/protocols/FacebookRM/src/requests/messages.h b/protocols/FacebookRM/src/requests/messages.h
deleted file mode 100644
index a0d782612a..0000000000
--- a/protocols/FacebookRM/src/requests/messages.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
-
-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
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef _FACEBOOK_REQUEST_MESSAGES_H_
-#define _FACEBOOK_REQUEST_MESSAGES_H_
-
-// sending messages
-// revised 17.8.2016
-class SendMessageRequest : public HttpRequest
-{
-public:
- SendMessageRequest(facebook_client *fc, const char *userId, const char *threadId, const char *messageId, const char *messageText, bool isChat, const char *captcha, const char *captchaPersistData) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/messaging/send/")
- {
- // Don't notify errors for this request, because we're getting them inline in messaging window
- NotifyErrors = false;
-
- // Use own persistent connection for sending messages
- Persistent = MESSAGES;
-
- Url << INT_PARAM("dpr", 1);
-
- if (mir_strlen(captcha) > 0) {
- Body
- << CHAR_PARAM("captcha_persist_data", captchaPersistData)
- << CHAR_PARAM("captcha_response", captcha);
- }
-
- Body
- << 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_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_PARAM("body", ptrA(mir_urlEncode(messageText)))
- << BOOL_PARAM("has_attachment", false);
- }
-
- Body
- << 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
- std::string threadFbid = threadId; // FIXME: Rewrite this without std::string...
- if (threadFbid.substr(0, 3) == "id.")
- threadFbid = threadFbid.substr(3);
-
- Body << CHAR_PARAM("thread_fbid", threadFbid.c_str());
- }
- else {
- Body
- << 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"
- << 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);
- }
-};
-
-// sending typing notification
-// revised 17.8.2016
-class SendTypingRequest : public HttpRequest
-{
-public:
- SendTypingRequest(facebook_client *fc, const char *userId, bool isChat, bool isTyping) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/messaging/typ.php")
- {
- Url << INT_PARAM("dpr", 1);
-
- ptrA idEncoded(mir_urlEncode(userId));
-
- Body
- << 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);
- }
-};
-
-// marking messages read
-class MarkMessageReadRequest : public HttpRequest
-{
-public:
- MarkMessageReadRequest(facebook_client *fc, const LIST<char> &ids) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/change_read_status.php")
- {
- Url << INT_PARAM("__a", 1);
-
- for (int i = 0; i < ids.getCount(); i++) {
- std::string id_ = ids[i];
- // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
- if (id_.substr(0, 3) == "id.")
- id_ = id_.substr(3);
-
- CMStringA id(::FORMAT, "ids[%s]", ptrA(mir_urlEncode(id_.c_str())));
- Body << BOOL_PARAM(id, true);
- }
-
- Body
- << 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);
- }
-};
-
-#endif //_FACEBOOK_REQUEST_MESSAGES_H_
diff --git a/protocols/FacebookRM/src/requests/notifications.h b/protocols/FacebookRM/src/requests/notifications.h
deleted file mode 100644
index 801af7f642..0000000000
--- a/protocols/FacebookRM/src/requests/notifications.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
-
-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
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef _FACEBOOK_REQUEST_NOTIFICATIONS_H_
-#define _FACEBOOK_REQUEST_NOTIFICATIONS_H_
-
-// getting notifications
-// revised 17.8.2016
-class GetNotificationsRequest : public HttpRequest
-{
-public:
- GetNotificationsRequest(facebook_client *fc, int count) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/notifications/client/get.php")
- {
- Url << INT_PARAM("dpr", 1);
-
- Body
- << 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);
- }
-};
-
-// marking notifications read
-// request revised 11.2.2016 (we're not using the main website request, as it doesn't work, but still the old one with GET parameters)
-class MarkNotificationReadRequest : public HttpRequest
-{
-public:
- MarkNotificationReadRequest(facebook_client *fc, const char *id) :
- HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/ajax/notifications/mark_read.php")
- {
- Url
- << 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)));
- }
-};
-
-#endif //_FACEBOOK_REQUEST_NOTIFICATIONS_H_
diff --git a/protocols/FacebookRM/src/requests/profile.h b/protocols/FacebookRM/src/requests/profile.h
deleted file mode 100644
index ecd0c43b4c..0000000000
--- a/protocols/FacebookRM/src/requests/profile.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
-
-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
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef _FACEBOOK_REQUEST_PROFILE_H_
-#define _FACEBOOK_REQUEST_PROFILE_H_
-
-// getting own name, avatar, ...
-class HomeRequest : public HttpRequest
-{
-public:
- HomeRequest() :
- HttpRequest(REQUEST_GET, FACEBOOK_SERVER_MOBILE "/profile.php")
- {
- flags |= NLHRF_REDIRECT;
-
- Url << CHAR_PARAM("v", "info");
- }
-};
-
-// getting fb_dtsg
-class DtsgRequest : public HttpRequest
-{
-public:
- DtsgRequest() :
- HttpRequest(REQUEST_GET, FACEBOOK_SERVER_MOBILE "/profile/basic/intro/bio/")
- {
- flags |= NLHRF_REDIRECT;
- }
-};
-
-// request mobile page containing profile picture
-class ProfilePictureRequest : public HttpRequest
-{
-public:
- ProfilePictureRequest(bool mobileBasicWorks, const char *userId) :
- HttpRequest(REQUEST_GET, FORMAT, "%s/profile/picture/view/", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE)
- {
- flags |= NLHRF_REDIRECT;
-
- Url << CHAR_PARAM("profile_id", userId);
- }
-};
-
-// request mobile page containing user profile
-class ProfileRequest : public HttpRequest
-{
-public:
- ProfileRequest(bool mobileBasicWorks, const char *data) :
- HttpRequest(REQUEST_GET, FORMAT, "%s/%s", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE, data)
- {
- Url << CHAR_PARAM("v", "info");
- }
-};
-
-// request mobile page containing user profile by his id, and in english language (for parsing data)
-class ProfileInfoRequest : public HttpRequest
-{
-public:
- ProfileInfoRequest(bool mobileBasicWorks, const char *userId) :
- HttpRequest(REQUEST_GET, FORMAT, "%s/profile.php", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE)
- {
- Url
- << CHAR_PARAM("id", userId)
- << CHAR_PARAM("v", "info")
- << CHAR_PARAM("locale", "en_US");
- }
-};
-
-#endif //_FACEBOOK_REQUEST_PROFILE_H_
diff --git a/protocols/FacebookRM/src/requests/status.h b/protocols/FacebookRM/src/requests/status.h
deleted file mode 100644
index 4589604c18..0000000000
--- a/protocols/FacebookRM/src/requests/status.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
-
-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
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef _FACEBOOK_REQUEST_STATUS_H_
-#define _FACEBOOK_REQUEST_STATUS_H_
-
-// getting info about channel and connecting to it
-// revised 17.8.2016
-class ReconnectRequest : public HttpRequest
-{
-public:
- ReconnectRequest(facebook_client *fc) :
- HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/ajax/presence/reconnect.php")
- {
- Url
- << 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());
- }
-};
-
-// setting chat visibility
-// revised 17.8.2016
-class SetVisibilityRequest : public HttpRequest
-{
-public:
- SetVisibilityRequest(facebook_client *fc, bool online) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/chat/privacy/visibility.php")
- {
- Url << INT_PARAM("dpr", 1);
-
- Body
- << 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());
- }
-};
-
-#endif //_FACEBOOK_REQUEST_STATUS_H_
diff --git a/protocols/FacebookRM/src/requests/utils.h b/protocols/FacebookRM/src/requests/utils.h
deleted file mode 100644
index beef14842a..0000000000
--- a/protocols/FacebookRM/src/requests/utils.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
-
-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
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef _FACEBOOK_REQUEST_UTILS_H_
-#define _FACEBOOK_REQUEST_UTILS_H_
-
-// refreshing captcha dialog (changing captcha type)
-class RefreshCaptchaRequest : public HttpRequest
-{
-public:
- RefreshCaptchaRequest(facebook_client *fc, const char *captchaPersistData) :
- HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/captcha/refresh_ajax.php")
- {
- Url
- << 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());
- }
-};
-
-// getting data for given url (for sending/posting reasons)
-class LinkScraperRequest : public HttpRequest
-{
-public:
- LinkScraperRequest(facebook_client *fc, status_data *status) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/composerx/attachment/link/scraper/")
- {
- Url
- << INT_PARAM("__a", 1)
- << INT_PARAM("composerurihash", 2)
- << CHAR_PARAM("scrape_url", ptrA(mir_urlEncode(status->url.c_str())));
-
- Body
- << 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");
- }
-};
-
-// getting owned/admined pages list
-class GetPagesRequest : public HttpRequest
-{
-public:
- GetPagesRequest() :
- HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/bookmarks/pages")
- {}
-};
-
-// changing identity to post status for pages
-class SwitchIdentityRequest : public HttpRequest
-{
-public:
- SwitchIdentityRequest(const char *dtsg, const char *userId) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/identity_switch.php")
- {
- Url << INT_PARAM("__a", 1);
- Body << CHAR_PARAM("fb_dtsg", dtsg) << CHAR_PARAM("user_id", userId) << CHAR_PARAM("url", FACEBOOK_URL_HOMEPAGE);
- }
-};
-
-// posting status to our or friends's wall
-class SharePostRequest : public HttpRequest
-{
-public:
- SharePostRequest(facebook_client *fc, status_data *status, const char *linkData) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/updatestatus.php")
- {
- Url
- << INT_PARAM("__a", 1);
-
- ptrA text(mir_urlEncode(status->text.c_str()));
-
- Body
- << 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_PARAM("audience[0][value]", fc->get_privacy_type().c_str());
-
- if (!status->place.empty())
- 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++) {
- CMStringA withId(::FORMAT, "composertags_with[%i]", i);
- CMStringA withName(::FORMAT, "text_composertags_with[%i]", i);
-
- Body
- << 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
- if (mir_strlen(linkData) > 0) {
- Body << linkData;
- // << "no_picture=0" // for disabling link preview image
- }
- }
-};
-
-// sending pokes
-class SendPokeRequest : public HttpRequest
-{
-public:
- SendPokeRequest(facebook_client *fc, const char *userId) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/pokes/dialog/")
- {
- Url
- << INT_PARAM("__a", 1);
-
- Body
- << 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());
- }
-};
-
-#endif //_FACEBOOK_REQUEST_UTILS_H_
diff --git a/protocols/FacebookRM/src/requests/search.h b/protocols/FacebookRM/src/search.cpp
index f7d77d600d..f64f868339 100644
--- a/protocols/FacebookRM/src/requests/search.h
+++ b/protocols/FacebookRM/src/search.cpp
@@ -20,27 +20,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _FACEBOOK_REQUEST_SEARCH_H_
-#define _FACEBOOK_REQUEST_SEARCH_H_
+#include "stdafx.h"
// searching
-class SearchRequest : public HttpRequest
+SearchRequest::SearchRequest(bool mobileBasicWorks, const char *query, int s, int pn, const char *ssid) :
+ HttpRequest(REQUEST_GET, FORMAT, "%s/search/", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE)
{
-public:
- SearchRequest(bool mobileBasicWorks, const char *query, int s, int pn, const char *ssid) :
- HttpRequest(REQUEST_GET, FORMAT, "%s/search/", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE)
- {
- flags |= NLHRF_REDIRECT;
-
- Url
- << CHAR_PARAM("q", query)
- << INT_PARAM("s", s)
- << INT_PARAM("pn", pn);
-
- if (mir_strlen(ssid) > 0) {
- Url << CHAR_PARAM("ssid", ssid);
- }
- }
-};
-
-#endif //_FACEBOOK_REQUEST_SEARCH_H_
+ flags |= NLHRF_REDIRECT;
+
+ Url
+ << CHAR_PARAM("q", query)
+ << INT_PARAM("s", s)
+ << INT_PARAM("pn", pn);
+
+ if (mir_strlen(ssid) > 0)
+ Url << CHAR_PARAM("ssid", ssid);
+}
diff --git a/protocols/FacebookRM/src/status.cpp b/protocols/FacebookRM/src/status.cpp
new file mode 100644
index 0000000000..f6ba5e9963
--- /dev/null
+++ b/protocols/FacebookRM/src/status.cpp
@@ -0,0 +1,63 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
+
+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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "stdafx.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// getting info about channel and connecting to it
+
+ReconnectRequest::ReconnectRequest(facebook_client *fc) :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/ajax/presence/reconnect.php")
+{
+ Url
+ << 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());
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// setting chat visibility
+
+SetVisibilityRequest::SetVisibilityRequest(facebook_client *fc, bool online) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/chat/privacy/visibility.php")
+{
+ Url << INT_PARAM("dpr", 1);
+
+ Body
+ << 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/stdafx.h b/protocols/FacebookRM/src/stdafx.h
index 6bf092d283..83f39e24e6 100644
--- a/protocols/FacebookRM/src/stdafx.h
+++ b/protocols/FacebookRM/src/stdafx.h
@@ -70,8 +70,8 @@ class FacebookProto;
#include "constants.h"
#include "entities.h"
#include "http.h"
-#include "http_request.h"
#include "client.h"
+#include "http_request.h"
#include "proto.h"
#include "db.h"
#include "dialogs.h"
@@ -79,18 +79,6 @@ class FacebookProto;
#include "resource.h"
#include "version.h"
-#include "requests/contacts.h"
-#include "requests/feeds.h"
-#include "requests/history.h"
-#include "requests/channel.h"
-#include "requests/login.h"
-#include "requests/messages.h"
-#include "requests/notifications.h"
-#include "requests/profile.h"
-#include "requests/search.h"
-#include "requests/status.h"
-#include "requests/utils.h"
-
extern HINSTANCE g_hInstance;
extern std::string g_strUserAgent;
extern DWORD g_mirandaVersion;
diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp
new file mode 100644
index 0000000000..019ccddeea
--- /dev/null
+++ b/protocols/FacebookRM/src/utils.cpp
@@ -0,0 +1,157 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-17 Robert Pösel, 2017-18 Miranda NG team
+
+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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "stdafx.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// refreshing captcha dialog (changing captcha type)
+
+RefreshCaptchaRequest::RefreshCaptchaRequest(facebook_client *fc, const char *captchaPersistData) :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/captcha/refresh_ajax.php")
+{
+ Url
+ << 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());
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// getting data for given url (for sending/posting reasons)
+
+LinkScraperRequest::LinkScraperRequest(facebook_client *fc, status_data *status) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/composerx/attachment/link/scraper/")
+{
+ Url
+ << INT_PARAM("__a", 1)
+ << INT_PARAM("composerurihash", 2)
+ << CHAR_PARAM("scrape_url", ptrA(mir_urlEncode(status->url.c_str())));
+
+ Body
+ << 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");
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// changing identity to post status for pages
+
+SwitchIdentityRequest::SwitchIdentityRequest(const char *dtsg, const char *userId) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/identity_switch.php")
+{
+ Url << INT_PARAM("__a", 1);
+
+ Body << CHAR_PARAM("fb_dtsg", dtsg) << CHAR_PARAM("user_id", userId) << CHAR_PARAM("url", FACEBOOK_URL_HOMEPAGE);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// posting status to our or friends's wall
+
+SharePostRequest::SharePostRequest(facebook_client *fc, status_data *status, const char *linkData) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/updatestatus.php")
+{
+ Url << INT_PARAM("__a", 1);
+
+ ptrA text(mir_urlEncode(status->text.c_str()));
+
+ Body
+ << 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_PARAM("audience[0][value]", fc->get_privacy_type().c_str());
+
+ if (!status->place.empty())
+ 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++) {
+ CMStringA withId(::FORMAT, "composertags_with[%i]", i);
+ CMStringA withName(::FORMAT, "text_composertags_with[%i]", i);
+
+ Body
+ << 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
+ if (mir_strlen(linkData) > 0)
+ Body << linkData;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// sending pokes
+
+SendPokeRequest::SendPokeRequest(facebook_client *fc, const char *userId) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/pokes/dialog/")
+{
+ Url << INT_PARAM("__a", 1);
+
+ Body
+ << 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());
+}