summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r--protocols/FacebookRM/facebook_10.vcxproj1
-rw-r--r--protocols/FacebookRM/facebook_10.vcxproj.filters3
-rw-r--r--protocols/FacebookRM/facebook_11.vcxproj1
-rw-r--r--protocols/FacebookRM/facebook_11.vcxproj.filters3
-rw-r--r--protocols/FacebookRM/src/avatars.h32
-rw-r--r--protocols/FacebookRM/src/client.h17
-rw-r--r--protocols/FacebookRM/src/common.h1
-rw-r--r--protocols/FacebookRM/src/communication.cpp316
-rw-r--r--protocols/FacebookRM/src/constants.h96
-rw-r--r--protocols/FacebookRM/src/contacts.cpp20
-rw-r--r--protocols/FacebookRM/src/json.cpp2
-rw-r--r--protocols/FacebookRM/src/messages.cpp10
-rw-r--r--protocols/FacebookRM/src/process.cpp40
-rw-r--r--protocols/FacebookRM/src/proto.cpp6
-rw-r--r--protocols/FacebookRM/src/proto.h4
-rw-r--r--protocols/FacebookRM/src/theme.cpp8
16 files changed, 261 insertions, 299 deletions
diff --git a/protocols/FacebookRM/facebook_10.vcxproj b/protocols/FacebookRM/facebook_10.vcxproj
index 932d50f1da..3d9900b8ea 100644
--- a/protocols/FacebookRM/facebook_10.vcxproj
+++ b/protocols/FacebookRM/facebook_10.vcxproj
@@ -198,7 +198,6 @@
<ClInclude Include="src\JSON_CAJUN\reader.h" />
<ClInclude Include="src\JSON_CAJUN\visitor.h" />
<ClInclude Include="src\JSON_CAJUN\writer.h" />
- <ClInclude Include="src\avatars.h" />
<ClInclude Include="src\client.h" />
<ClInclude Include="src\common.h" />
<ClInclude Include="src\constants.h" />
diff --git a/protocols/FacebookRM/facebook_10.vcxproj.filters b/protocols/FacebookRM/facebook_10.vcxproj.filters
index 58933f59b0..0723d8bb3d 100644
--- a/protocols/FacebookRM/facebook_10.vcxproj.filters
+++ b/protocols/FacebookRM/facebook_10.vcxproj.filters
@@ -83,9 +83,6 @@
<ClInclude Include="src\JSON_CAJUN\writer.h">
<Filter>Source Files\JSON_CAJUN</Filter>
</ClInclude>
- <ClInclude Include="src\avatars.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\client.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/protocols/FacebookRM/facebook_11.vcxproj b/protocols/FacebookRM/facebook_11.vcxproj
index 9501800047..8db31e285c 100644
--- a/protocols/FacebookRM/facebook_11.vcxproj
+++ b/protocols/FacebookRM/facebook_11.vcxproj
@@ -201,7 +201,6 @@
<ClInclude Include="src\JSON_CAJUN\reader.h" />
<ClInclude Include="src\JSON_CAJUN\visitor.h" />
<ClInclude Include="src\JSON_CAJUN\writer.h" />
- <ClInclude Include="src\avatars.h" />
<ClInclude Include="src\client.h" />
<ClInclude Include="src\common.h" />
<ClInclude Include="src\constants.h" />
diff --git a/protocols/FacebookRM/facebook_11.vcxproj.filters b/protocols/FacebookRM/facebook_11.vcxproj.filters
index 58933f59b0..0723d8bb3d 100644
--- a/protocols/FacebookRM/facebook_11.vcxproj.filters
+++ b/protocols/FacebookRM/facebook_11.vcxproj.filters
@@ -83,9 +83,6 @@
<ClInclude Include="src\JSON_CAJUN\writer.h">
<Filter>Source Files\JSON_CAJUN</Filter>
</ClInclude>
- <ClInclude Include="src\avatars.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\client.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/protocols/FacebookRM/src/avatars.h b/protocols/FacebookRM/src/avatars.h
deleted file mode 100644
index eb43844ce3..0000000000
--- a/protocols/FacebookRM/src/avatars.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2009-11 Michal Zelinka, 2011-13 Robert Pösel
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-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/>.
-
-*/
-
-#pragma once
-
-struct update_avatar
-{
- update_avatar(HANDLE hContact,const std::string &url,const std::string &file)
- : hContact(hContact),url(url),file(file) {}
-
- HANDLE hContact;
- std::string url, file;
-};
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index 024ba16b26..652c20fc23 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "constants.h"
+
#pragma once
#define FORCE_DISCONNECT 1
@@ -153,7 +155,7 @@ public:
std::map<std::string, bool> messages_ignore;
bool channel();
- bool send_message(std::string message_recipient, std::string message_text, std::string *error_text, int method);
+ bool send_message(std::string message_recipient, std::string message_text, std::string *error_text, MessageMethod method);
////////////////////////////////////////////////////////////
// Status handling
@@ -164,15 +166,14 @@ public:
// HTTP communication
- http::response flap(const int request_type, std::string* request_data = NULL, std::string* request_get_data = NULL, int method = 0);
+ http::response flap(RequestType request_type, std::string* request_data = NULL, std::string* request_get_data = NULL, int method = 0);
bool save_url(const std::string &url,const std::tstring &filename, HANDLE &nlc);
- DWORD choose_security_level(int);
- int choose_method(int);
- std::string choose_proto(int);
- std::string choose_server(int, std::string* data = NULL, std::string* get_data = NULL);
- std::string choose_action(int, std::string* data = NULL, std::string* get_data = NULL);
- std::string choose_request_url(int, std::string* data = NULL, std::string* get_data = NULL);
+ DWORD choose_security_level(RequestType);
+ int choose_method(RequestType);
+ std::string choose_proto(RequestType);
+ std::string choose_server(RequestType, std::string* data = NULL, std::string* get_data = NULL);
+ std::string choose_action(RequestType, std::string* data = NULL, std::string* get_data = NULL);
NETLIBHTTPHEADER* get_request_headers(int request_type, int* headers_count);
diff --git a/protocols/FacebookRM/src/common.h b/protocols/FacebookRM/src/common.h
index e1f198cb29..e3074eb5c5 100644
--- a/protocols/FacebookRM/src/common.h
+++ b/protocols/FacebookRM/src/common.h
@@ -65,7 +65,6 @@ class FacebookProto;
#include "definitions.h"
#include "entities.h"
-#include "avatars.h"
#include "http.h"
#include "list.hpp"
#include "utils.h"
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index c356c948df..619f082a45 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -27,18 +27,22 @@ void facebook_client::client_notify(TCHAR* message)
parent->NotifyEvent(parent->m_tszUserName, message, NULL, FACEBOOK_EVENT_CLIENT);
}
-http::response facebook_client::flap(const int request_type, std::string* request_data, std::string* request_get_data, int method)
+http::response facebook_client::flap(RequestType request_type, std::string* request_data, std::string* request_get_data, int method)
{
NETLIBHTTPREQUEST nlhr = {sizeof(NETLIBHTTPREQUEST)};
nlhr.requestType = !method ? choose_method(request_type) : method;
- std::string url = choose_request_url(request_type, request_data, request_get_data);
+
+ std::string url = choose_proto(request_type);
+ url.append(choose_server(request_type, request_data, request_get_data));
+ url.append(choose_action(request_type, request_data, request_get_data));
+
nlhr.szUrl = (char*)url.c_str();
nlhr.flags = NLHRF_HTTP11 | NLHRF_NODUMP | choose_security_level(request_type);
nlhr.headers = get_request_headers(nlhr.requestType, &nlhr.headersCount);
switch (request_type)
{
- case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
+ case REQUEST_MESSAGES_RECEIVE:
nlhr.timeout = 1000 * 65; break;
default:
nlhr.timeout = 1000 * 20; break;
@@ -54,11 +58,11 @@ http::response facebook_client::flap(const int request_type, std::string* reques
switch (request_type)
{
- case FACEBOOK_REQUEST_LOGIN:
+ case REQUEST_LOGIN:
nlhr.nlc = NULL;
break;
- case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
+ case REQUEST_MESSAGES_RECEIVE:
nlhr.nlc = hMsgCon;
nlhr.flags |= NLHRF_PERSISTENT;
break;
@@ -79,11 +83,11 @@ http::response facebook_client::flap(const int request_type, std::string* reques
switch (request_type)
{
- case FACEBOOK_REQUEST_LOGIN:
- case FACEBOOK_REQUEST_SETUP_MACHINE:
+ case REQUEST_LOGIN:
+ case REQUEST_SETUP_MACHINE:
break;
- case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
+ case REQUEST_MESSAGES_RECEIVE:
hMsgCon = pnlhr ? pnlhr->nlc : NULL;
break;
@@ -205,94 +209,94 @@ bool facebook_client::handle_error(std::string method, int action)
//////////////////////////////////////////////////////////////////////////////
-DWORD facebook_client::choose_security_level(int request_type)
+DWORD facebook_client::choose_security_level(RequestType request_type)
{
if (this->https_)
{
- if (request_type != FACEBOOK_REQUEST_MESSAGES_RECEIVE
+ if (request_type != REQUEST_MESSAGES_RECEIVE
|| db_get_b(NULL, parent->m_szModuleName, FACEBOOK_KEY_FORCE_HTTPS_CHANNEL, DEFAULT_FORCE_HTTPS_CHANNEL))
return NLHRF_SSL;
}
switch (request_type)
{
- case FACEBOOK_REQUEST_LOGIN:
- case FACEBOOK_REQUEST_SETUP_MACHINE:
+ case REQUEST_LOGIN:
+ case REQUEST_SETUP_MACHINE:
return NLHRF_SSL;
-// case FACEBOOK_REQUEST_LOGOUT:
-// case FACEBOOK_REQUEST_HOME:
-// case FACEBOOK_REQUEST_DTSG:
-// case FACEBOOK_REQUEST_BUDDY_LIST:
-// case FACEBOOK_REQUEST_LOAD_FRIENDS:
-// case FACEBOOK_REQUEST_LOAD_REQUESTS:
-// case FACEBOOK_REQUEST_SEARCH:
-// case FACEBOOK_REQUEST_DELETE_FRIEND:
-// case FACEBOOK_REQUEST_REQUEST_FRIEND:
-// case FACEBOOK_REQUEST_APPROVE_FRIEND:
-// case FACEBOOK_REQUEST_CANCEL_REQUEST:
-// case FACEBOOK_REQUEST_FEEDS:
-// case FACEBOOK_REQUEST_NOTIFICATIONS:
-// case FACEBOOK_REQUEST_RECONNECT:
-// case FACEBOOK_REQUEST_STATUS_SET:
-// case FACEBOOK_REQUEST_MESSAGE_SEND:
-// case FACEBOOK_REQUEST_MESSAGE_SEND2:
-// case FACEBOOK_REQUEST_THREAD_INFO:
-// case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
-// case FACEBOOK_REQUEST_VISIBILITY:
-// case FACEBOOK_REQUEST_POKE:
-// case FACEBOOK_REQUEST_ASYNC:
-// case FACEBOOK_REQUEST_MARK_READ:
-// case FACEBOOK_REQUEST_NOTIFICATIONS_READ:
-// case FACEBOOK_REQUEST_UNREAD_THREADS:
-// case FACEBOOK_REQUEST_UNREAD_MESSAGES:
-// case FACEBOOK_REQUEST_TYPING_SEND:
+// case REQUEST_LOGOUT:
+// case REQUEST_HOME:
+// case REQUEST_DTSG:
+// case REQUEST_BUDDY_LIST:
+// case REQUEST_LOAD_FRIENDS:
+// case REQUEST_LOAD_REQUESTS:
+// case REQUEST_SEARCH:
+// case REQUEST_DELETE_FRIEND:
+// case REQUEST_REQUEST_FRIEND:
+// case REQUEST_APPROVE_FRIEND:
+// case REQUEST_CANCEL_REQUEST:
+// case REQUEST_FEEDS:
+// case REQUEST_NOTIFICATIONS:
+// case REQUEST_RECONNECT:
+// case REQUEST_STATUS_SET:
+// case REQUEST_MESSAGE_SEND:
+// case REQUEST_MESSAGE_SEND2:
+// case REQUEST_THREAD_INFO:
+// case REQUEST_MESSAGES_RECEIVE:
+// case REQUEST_VISIBILITY:
+// case REQUEST_POKE:
+// case REQUEST_ASYNC:
+// case REQUEST_MARK_READ:
+// case REQUEST_NOTIFICATIONS_READ:
+// case REQUEST_UNREAD_THREADS:
+// case REQUEST_UNREAD_MESSAGES:
+// case REQUEST_TYPING_SEND:
default:
return (DWORD)0;
}
}
-int facebook_client::choose_method(int request_type)
+int facebook_client::choose_method(RequestType request_type)
{
switch (request_type)
{
- case FACEBOOK_REQUEST_LOGIN:
- case FACEBOOK_REQUEST_SETUP_MACHINE:
- case FACEBOOK_REQUEST_BUDDY_LIST:
- case FACEBOOK_REQUEST_STATUS_SET:
- case FACEBOOK_REQUEST_MESSAGE_SEND:
- case FACEBOOK_REQUEST_MESSAGE_SEND2:
- case FACEBOOK_REQUEST_THREAD_INFO:
- case FACEBOOK_REQUEST_VISIBILITY:
- case FACEBOOK_REQUEST_POKE:
- case FACEBOOK_REQUEST_ASYNC:
- case FACEBOOK_REQUEST_MARK_READ:
- case FACEBOOK_REQUEST_NOTIFICATIONS_READ:
- case FACEBOOK_REQUEST_TYPING_SEND:
- case FACEBOOK_REQUEST_LOGOUT:
- case FACEBOOK_REQUEST_DELETE_FRIEND:
- case FACEBOOK_REQUEST_REQUEST_FRIEND:
- case FACEBOOK_REQUEST_APPROVE_FRIEND:
- case FACEBOOK_REQUEST_CANCEL_REQUEST:
+ case REQUEST_LOGIN:
+ case REQUEST_SETUP_MACHINE:
+ case REQUEST_BUDDY_LIST:
+ case REQUEST_STATUS_SET:
+ case REQUEST_MESSAGE_SEND:
+ case REQUEST_MESSAGE_SEND2:
+ case REQUEST_THREAD_INFO:
+ case REQUEST_VISIBILITY:
+ case REQUEST_POKE:
+ case REQUEST_ASYNC:
+ case REQUEST_MARK_READ:
+ case REQUEST_NOTIFICATIONS_READ:
+ case REQUEST_TYPING_SEND:
+ case REQUEST_LOGOUT:
+ case REQUEST_DELETE_FRIEND:
+ case REQUEST_REQUEST_FRIEND:
+ case REQUEST_APPROVE_FRIEND:
+ case REQUEST_CANCEL_REQUEST:
return REQUEST_POST;
-// case FACEBOOK_REQUEST_HOME:
-// case FACEBOOK_REQUEST_DTSG:
-// case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
-// case FACEBOOK_REQUEST_FEEDS:
-// case FACEBOOK_REQUEST_NOTIFICATIONS:
-// case FACEBOOK_REQUEST_RECONNECT:
-// case FACEBOOK_REQUEST_LOAD_FRIENDS:
-// case FACEBOOK_REQUEST_LOAD_REQUESTS:
-// case FACEBOOK_REQUEST_SEARCH:
-// case FACEBOOK_REQUEST_UNREAD_THREADS:
-// case FACEBOOK_REQUEST_UNREAD_MESSAGES:
+// case REQUEST_HOME:
+// case REQUEST_DTSG:
+// case REQUEST_MESSAGES_RECEIVE:
+// case REQUEST_FEEDS:
+// case REQUEST_NOTIFICATIONS:
+// case REQUEST_RECONNECT:
+// case REQUEST_LOAD_FRIENDS:
+// case REQUEST_LOAD_REQUESTS:
+// case REQUEST_SEARCH:
+// case REQUEST_UNREAD_THREADS:
+// case REQUEST_UNREAD_MESSAGES:
default:
return REQUEST_GET;
}
}
-std::string facebook_client::choose_proto(int request_type)
+std::string facebook_client::choose_proto(RequestType request_type)
{
if (choose_security_level(request_type) == NLHRF_SSL)
return HTTP_PROTO_SECURE;
@@ -300,14 +304,14 @@ std::string facebook_client::choose_proto(int request_type)
return HTTP_PROTO_REGULAR;
}
-std::string facebook_client::choose_server(int request_type, std::string* data, std::string* get_data)
+std::string facebook_client::choose_server(RequestType request_type, std::string* data, std::string* get_data)
{
switch (request_type)
{
- case FACEBOOK_REQUEST_LOGIN:
+ case REQUEST_LOGIN:
return FACEBOOK_SERVER_LOGIN;
- case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
+ case REQUEST_MESSAGES_RECEIVE:
{
std::string server = FACEBOOK_SERVER_CHAT;
utils::text::replace_first(&server, "%s", "0");
@@ -315,75 +319,75 @@ std::string facebook_client::choose_server(int request_type, std::string* data,
return server;
}
- case FACEBOOK_REQUEST_HOME:
- case FACEBOOK_REQUEST_DTSG:
- case FACEBOOK_REQUEST_APPROVE_FRIEND:
- case FACEBOOK_REQUEST_LOAD_REQUESTS:
- case FACEBOOK_REQUEST_SEARCH:
- case FACEBOOK_REQUEST_UNREAD_THREADS:
- case FACEBOOK_REQUEST_UNREAD_MESSAGES:
+ case REQUEST_HOME:
+ case REQUEST_DTSG:
+ case REQUEST_APPROVE_FRIEND:
+ case REQUEST_LOAD_REQUESTS:
+ case REQUEST_SEARCH:
+ case REQUEST_UNREAD_THREADS:
+ case REQUEST_UNREAD_MESSAGES:
return FACEBOOK_SERVER_MOBILE;
-// case FACEBOOK_REQUEST_LOGOUT:
-// case FACEBOOK_REQUEST_BUDDY_LIST:
-// case FACEBOOK_REQUEST_LOAD_FRIENDS:
-// case FACEBOOK_REQUEST_FEEDS:
-// case FACEBOOK_REQUEST_NOTIFICATIONS:
-// case FACEBOOK_REQUEST_RECONNECT:
-// case FACEBOOK_REQUEST_STATUS_SET:
-// case FACEBOOK_REQUEST_MESSAGE_SEND:
-// case FACEBOOK_REQUEST_MESSAGE_SEND2:
-// case FACEBOOK_REQUEST_THREAD_INFO:
-// case FACEBOOK_REQUEST_VISIBILITY:
-// case FACEBOOK_REQUEST_POKE:
-// case FACEBOOK_REQUEST_ASYNC:
-// case FACEBOOK_REQUEST_MARK_READ:
-// case FACEBOOK_REQUEST_NOTIFICATIONS_READ:
-// case FACEBOOK_REQUEST_TYPING_SEND:
-// case FACEBOOK_REQUEST_SETUP_MACHINE:
-// case FACEBOOK_REQUEST_DELETE_FRIEND:
-// case FACEBOOK_REQUEST_REQUEST_FRIEND:
-// case FACEBOOK_REQUEST_CANCEL_REQUEST:
+// case REQUEST_LOGOUT:
+// case REQUEST_BUDDY_LIST:
+// case REQUEST_LOAD_FRIENDS:
+// case REQUEST_FEEDS:
+// case REQUEST_NOTIFICATIONS:
+// case REQUEST_RECONNECT:
+// case REQUEST_STATUS_SET:
+// case REQUEST_MESSAGE_SEND:
+// case REQUEST_MESSAGE_SEND2:
+// case REQUEST_THREAD_INFO:
+// case REQUEST_VISIBILITY:
+// case REQUEST_POKE:
+// case REQUEST_ASYNC:
+// case REQUEST_MARK_READ:
+// case REQUEST_NOTIFICATIONS_READ:
+// case REQUEST_TYPING_SEND:
+// case REQUEST_SETUP_MACHINE:
+// case REQUEST_DELETE_FRIEND:
+// case REQUEST_REQUEST_FRIEND:
+// case REQUEST_CANCEL_REQUEST:
default:
return FACEBOOK_SERVER_REGULAR;
}
}
-std::string facebook_client::choose_action(int request_type, std::string* data, std::string* get_data)
+std::string facebook_client::choose_action(RequestType request_type, std::string* data, std::string* get_data)
{
switch (request_type)
{
- case FACEBOOK_REQUEST_LOGIN:
+ case REQUEST_LOGIN:
return "/login.php?login_attempt=1";
- case FACEBOOK_REQUEST_SETUP_MACHINE:
+ case REQUEST_SETUP_MACHINE:
return "/checkpoint/";
- case FACEBOOK_REQUEST_LOGOUT:
+ case REQUEST_LOGOUT:
return "/logout.php";
- case FACEBOOK_REQUEST_HOME:
+ case REQUEST_HOME:
return "/profile.php?v=edit";
- case FACEBOOK_REQUEST_DTSG:
+ case REQUEST_DTSG:
return "/editprofile.php?edit=current_city&type=basic";
- case FACEBOOK_REQUEST_BUDDY_LIST:
+ case REQUEST_BUDDY_LIST:
return "/ajax/chat/buddy_list.php?__a=1";
- case FACEBOOK_REQUEST_LOAD_FRIENDS:
+ case REQUEST_LOAD_FRIENDS:
{
std::string action = "/ajax/chat/user_info_all.php?__a=1&viewer=%s&__user=%s";
utils::text::replace_all(&action, "%s", self_.user_id);
return action;
}
- case FACEBOOK_REQUEST_LOAD_REQUESTS:
+ case REQUEST_LOAD_REQUESTS:
{
return "/friends/";
}
- case FACEBOOK_REQUEST_SEARCH:
+ case REQUEST_SEARCH:
{
std::string action = "/search/?search=people&query=";
if (get_data != NULL) {
@@ -392,7 +396,7 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
return action;
}
- case FACEBOOK_REQUEST_UNREAD_THREADS:
+ case REQUEST_UNREAD_THREADS:
{
std::string action = "/messages/?folder=unread";
if (get_data != NULL) {
@@ -401,7 +405,7 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
return action;
}
- case FACEBOOK_REQUEST_UNREAD_MESSAGES:
+ case REQUEST_UNREAD_MESSAGES:
{
std::string action = "/messages/read/?";
if (get_data != NULL) {
@@ -410,7 +414,7 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
return action;
}
- case FACEBOOK_REQUEST_DELETE_FRIEND:
+ case REQUEST_DELETE_FRIEND:
{
std::string action = "/ajax/profile/removefriendconfirm.php?__a=1";
if (get_data != NULL) {
@@ -419,12 +423,12 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
return action;
}
- case FACEBOOK_REQUEST_REQUEST_FRIEND:
+ case REQUEST_REQUEST_FRIEND:
{
return "/ajax/add_friend/action.php?__a=1";
}
- case FACEBOOK_REQUEST_APPROVE_FRIEND:
+ case REQUEST_APPROVE_FRIEND:
{
std::string action = "/a/notifications.php?__a=1";
if (get_data != NULL) {
@@ -433,12 +437,12 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
return action;
}
- case FACEBOOK_REQUEST_CANCEL_REQUEST:
+ case REQUEST_CANCEL_REQUEST:
{
return "/ajax/friends/requests/cancel.php?__a=1";
}
- case FACEBOOK_REQUEST_FEEDS:
+ case REQUEST_FEEDS:
{
std::string action = "/ajax/intent.php?filter=";
action += get_newsfeed_type();
@@ -449,14 +453,14 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
return action;
}
- case FACEBOOK_REQUEST_NOTIFICATIONS:
+ case REQUEST_NOTIFICATIONS:
{
std::string action = "/ajax/notifications/get.php?__a=1&user=%s&time=0&version=2&__user=%s";
utils::text::replace_all(&action, "%s", self_.user_id);
return action;
}
- case FACEBOOK_REQUEST_RECONNECT:
+ case REQUEST_RECONNECT:
{
std::string action = "/ajax/presence/reconnect.php?__a=1&reason=%s&fb_dtsg=%s&__user=%s";
@@ -469,19 +473,19 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
return action;
}
- case FACEBOOK_REQUEST_STATUS_SET:
+ case REQUEST_STATUS_SET:
return "/ajax/updatestatus.php?__a=1";
- case FACEBOOK_REQUEST_MESSAGE_SEND:
+ case REQUEST_MESSAGE_SEND:
return "/ajax/mercury/send_messages.php?__a=1";
- case FACEBOOK_REQUEST_MESSAGE_SEND2:
+ case REQUEST_MESSAGE_SEND2:
return "/ajax/messaging/send.php";
- case FACEBOOK_REQUEST_THREAD_INFO:
+ case REQUEST_THREAD_INFO:
return "/ajax/mercury/thread_info.php?__a=1";
- case FACEBOOK_REQUEST_MESSAGES_RECEIVE:
+ case REQUEST_MESSAGES_RECEIVE:
{
std::string action = "/pull?channel=" + (this->chat_channel_.empty() ? "p_" + self_.user_id : this->chat_channel_);
action += "&seq=" + (this->chat_sequence_num_.empty() ? "0" : this->chat_sequence_num_);
@@ -490,13 +494,13 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
return action;
}
- case FACEBOOK_REQUEST_VISIBILITY:
+ case REQUEST_VISIBILITY:
return "/ajax/chat/privacy/visibility.php?__a=1";
- case FACEBOOK_REQUEST_POKE:
+ case REQUEST_POKE:
return "/ajax/poke_dialog.php?__a=1";
- case FACEBOOK_REQUEST_ASYNC:
+ case REQUEST_ASYNC:
{
std::string action = "/ajax/messaging/async.php?__a=1";
if (get_data != NULL) {
@@ -505,10 +509,10 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
return action;
}
- case FACEBOOK_REQUEST_MARK_READ:
+ case REQUEST_MARK_READ:
return "/ajax/mercury/change_read_status.php?__a=1";
- case FACEBOOK_REQUEST_NOTIFICATIONS_READ:
+ case REQUEST_NOTIFICATIONS_READ:
{
std::string action = "/ajax/notifications/mark_read.php?__a=1";
if (get_data != NULL) {
@@ -517,7 +521,7 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
return action;
}
- case FACEBOOK_REQUEST_TYPING_SEND:
+ case REQUEST_TYPING_SEND:
return "/ajax/messaging/typ.php?__a=1";
default:
@@ -525,14 +529,6 @@ std::string facebook_client::choose_action(int request_type, std::string* data,
}
}
-std::string facebook_client::choose_request_url(int request_type, std::string* data, std::string* get_data)
-{
- std::string url = choose_proto(request_type);
- url.append(choose_server(request_type, data, get_data));
- url.append(choose_action(request_type, data, get_data));
- return url;
-}
-
NETLIBHTTPHEADER* facebook_client::get_request_headers(int request_type, int* headers_count)
{
if (request_type == REQUEST_POST)
@@ -663,7 +659,7 @@ bool facebook_client::login(const std::string &username,const std::string &passw
password_ = password;
// Get initial cookies
- flap(FACEBOOK_REQUEST_LOGIN);
+ flap(REQUEST_LOGIN);
// Prepare login data
std::string data = "charset_test=%e2%82%ac%2c%c2%b4%2c%e2%82%ac%2c%c2%b4%2c%e6%b0%b4%2c%d0%94%2c%d0%84&pass_placeHolder=Password&login=Login&persistent=1";
@@ -675,7 +671,7 @@ bool facebook_client::login(const std::string &username,const std::string &passw
data += "&locale=" + std::string(locale);
// Send validation
- http::response resp = flap(FACEBOOK_REQUEST_LOGIN, &data);
+ http::response resp = flap(REQUEST_LOGIN, &data);
// Process result data
validate_response(&resp);
@@ -712,7 +708,7 @@ bool facebook_client::login(const std::string &username,const std::string &passw
// Check whether setting Machine name is required
if (resp.headers["Location"].find("/checkpoint/") != std::string::npos)
{
- resp = flap(FACEBOOK_REQUEST_SETUP_MACHINE, NULL, NULL, REQUEST_GET);
+ resp = flap(REQUEST_SETUP_MACHINE, NULL, NULL, REQUEST_GET);
if (resp.data.find("login_approvals_no_phones") != std::string::npos) {
// Code approval - but no phones in account
@@ -727,21 +723,21 @@ bool facebook_client::login(const std::string &username,const std::string &passw
inner_data = "submit[Continue]=Continue";
inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"");
inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"");
- resp = flap(FACEBOOK_REQUEST_SETUP_MACHINE, &inner_data);
+ resp = flap(REQUEST_SETUP_MACHINE, &inner_data);
// 2) Approve last unknown login
// inner_data = "submit[I%20don't%20recognize]=I%20don't%20recognize"; // Don't recognize - this will force to change account password
inner_data = "submit[This%20is%20Okay]=This%20is%20Okay"; // Recognize
inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"");
inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"");
- resp = flap(FACEBOOK_REQUEST_SETUP_MACHINE, &inner_data);
+ resp = flap(REQUEST_SETUP_MACHINE, &inner_data);
// 3) Save device
inner_data = "submit[Continue]=Continue";
inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"");
inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"");
inner_data += "&name_action_selected=save_device"; // Save device - or "dont_save"
- resp = flap(FACEBOOK_REQUEST_SETUP_MACHINE, &inner_data);
+ resp = flap(REQUEST_SETUP_MACHINE, &inner_data);
}
// Save actual machine name
@@ -751,7 +747,7 @@ bool facebook_client::login(const std::string &username,const std::string &passw
inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"");
inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"");
- resp = flap(FACEBOOK_REQUEST_SETUP_MACHINE, &inner_data);
+ resp = flap(REQUEST_SETUP_MACHINE, &inner_data);
validate_response(&resp);
}
}
@@ -809,7 +805,7 @@ bool facebook_client::logout()
std::string data = "fb_dtsg=" + (this->dtsg_.length() ? this->dtsg_ : "0");
data += "&ref=mb&h=" + this->logout_hash_;
- http::response resp = flap(FACEBOOK_REQUEST_LOGOUT, &data);
+ http::response resp = flap(REQUEST_LOGOUT, &data);
if (hFcbCon)
Netlib_CloseHandle(hFcbCon);
@@ -834,7 +830,7 @@ bool facebook_client::home()
handle_entry("home");
// get fb_dtsg
- http::response resp = flap(FACEBOOK_REQUEST_DTSG);
+ http::response resp = flap(REQUEST_DTSG);
this->dtsg_ = utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"");
parent->Log(" Got self dtsg: %s", this->dtsg_.c_str());
@@ -842,7 +838,7 @@ bool facebook_client::home()
if (this->dtsg_.empty())
return false;
- resp = flap(FACEBOOK_REQUEST_HOME);
+ resp = flap(REQUEST_HOME);
// Process result data
validate_response(&resp);
@@ -891,7 +887,7 @@ bool facebook_client::chat_state(bool online)
data += "&window_id=0";
data += "&fb_dtsg=" + (dtsg_.length() ? dtsg_ : "0");
data += "&phstamp=0&__user=" + self_.user_id;
- http::response resp = flap(FACEBOOK_REQUEST_VISIBILITY, &data);
+ http::response resp = flap(REQUEST_VISIBILITY, &data);
return handle_success("chat_state");
}
@@ -901,7 +897,7 @@ bool facebook_client::reconnect()
handle_entry("reconnect");
// Request reconnect
- http::response resp = flap(FACEBOOK_REQUEST_RECONNECT);
+ http::response resp = flap(REQUEST_RECONNECT);
// Process result data
validate_response(&resp);
@@ -949,7 +945,7 @@ bool facebook_client::buddy_list()
}
// Get buddy list
- http::response resp = flap(FACEBOOK_REQUEST_BUDDY_LIST, &data);
+ http::response resp = flap(REQUEST_BUDDY_LIST, &data);
// Process result data
validate_response(&resp);
@@ -975,7 +971,7 @@ bool facebook_client::load_friends()
handle_entry("load_friends");
// Get buddy list
- http::response resp = flap(FACEBOOK_REQUEST_LOAD_FRIENDS);
+ http::response resp = flap(REQUEST_LOAD_FRIENDS);
// Process result data
validate_response(&resp);
@@ -1000,7 +996,7 @@ bool facebook_client::feeds()
handle_entry("feeds");
// Get feeds
- http::response resp = flap(FACEBOOK_REQUEST_FEEDS);
+ http::response resp = flap(REQUEST_FEEDS);
// Process result data
validate_response(&resp);
@@ -1026,7 +1022,7 @@ bool facebook_client::channel()
handle_entry("channel");
// Get update
- http::response resp = flap(FACEBOOK_REQUEST_MESSAGES_RECEIVE);
+ http::response resp = flap(REQUEST_MESSAGES_RECEIVE);
// Process result data
validate_response(&resp);
@@ -1086,7 +1082,7 @@ bool facebook_client::channel()
}
}
-bool facebook_client::send_message(std::string message_recipient, std::string message_text, std::string *error_text, int method)
+bool facebook_client::send_message(std::string message_recipient, std::string message_text, std::string *error_text, MessageMethod method)
{
handle_entry("send_message");
@@ -1104,7 +1100,7 @@ bool facebook_client::send_message(std::string message_recipient, std::string me
data += "&fb_dtsg=" + (dtsg_.length() ? dtsg_ : "0");
data += "&phstamp=0";
- resp = flap(FACEBOOK_REQUEST_MESSAGE_SEND2, &data);
+ resp = flap(REQUEST_MESSAGE_SEND2, &data);
break;
}
case MESSAGE_MERCURY:
@@ -1138,7 +1134,7 @@ bool facebook_client::send_message(std::string message_recipient, std::string me
data += "&__a=1";
data += "&phstamp=0";
- resp = flap(FACEBOOK_REQUEST_MESSAGE_SEND, &data);
+ resp = flap(REQUEST_MESSAGE_SEND, &data);
break;
}
case MESSAGE_TID:
@@ -1162,7 +1158,7 @@ bool facebook_client::send_message(std::string message_recipient, std::string me
data += "&__user=" + this->self_.user_id;
data += "&phstamp=0";
- resp = flap(FACEBOOK_REQUEST_MESSAGE_SEND, &data);
+ resp = flap(REQUEST_MESSAGE_SEND, &data);
break;
}
case MESSAGE_ASYNC:
@@ -1174,7 +1170,7 @@ bool facebook_client::send_message(std::string message_recipient, std::string me
data += "&lsd=";
data += "&fb_dtsg=" + (dtsg_.length() ? dtsg_ : "0");
- resp = flap(FACEBOOK_REQUEST_ASYNC, &data);
+ resp = flap(REQUEST_ASYNC, &data);
break;
}
}
@@ -1247,7 +1243,7 @@ bool facebook_client::set_status(const std::string &status_text)
data += "&composertags_place_name=";
data += ptrA(mir_urlEncode(place));
- http::response resp = flap(FACEBOOK_REQUEST_STATUS_SET, &data);
+ http::response resp = flap(REQUEST_STATUS_SET, &data);
validate_response(&resp);
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index c0711edd66..764dadcda2 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -80,52 +80,56 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_EVENT_OTHER 0x80000000 // Facebook other event - friend requests/new messages
// Facebook request types // TODO: Provide MS_ and release in FB plugin API?
-#define FACEBOOK_REQUEST_LOGIN 100 // connecting physically
-#define FACEBOOK_REQUEST_LOGOUT 101 // disconnecting physically
-#define FACEBOOK_REQUEST_SETUP_MACHINE 102 // setting machine name
-#define FACEBOOK_REQUEST_HOME 103 // getting own name, avatar, ...
-#define FACEBOOK_REQUEST_DTSG 104 // getting __fb_dtsg__
-#define FACEBOOK_REQUEST_RECONNECT 105 // getting __sequence_num__ and __channel_id__
-#define FACEBOOK_REQUEST_VISIBILITY 305 // setting chat visibility
-
-#define FACEBOOK_REQUEST_FEEDS 120 // getting feeds
-#define FACEBOOK_REQUEST_NOTIFICATIONS 121 // getting notifications
-#define FACEBOOK_REQUEST_LOAD_REQUESTS 122 // getting friend requests
-
-#define FACEBOOK_REQUEST_STATUS_SET 130 // setting my "What's on my mind?"
-#define FACEBOOK_REQUEST_SEARCH 140 // searching
-#define FACEBOOK_REQUEST_POKE 150 // sending pokes
-#define FACEBOOK_REQUEST_NOTIFICATIONS_READ 151 // marking notifications read
-
-#define FACEBOOK_REQUEST_BUDDY_LIST 200 // getting regular updates (friends online, ...)
-#define FACEBOOK_REQUEST_LOAD_FRIENDS 201 // getting list of all friends
-#define FACEBOOK_REQUEST_REQUEST_FRIEND 210 // requesting friends
-#define FACEBOOK_REQUEST_APPROVE_FRIEND 211 // approving friends
-#define FACEBOOK_REQUEST_DELETE_FRIEND 212 // deleting friends
-#define FACEBOOK_REQUEST_CANCEL_REQUEST 213 // canceling friends request
-
-#define FACEBOOK_REQUEST_MESSAGE_SEND 300 // sending message
-#define FACEBOOK_REQUEST_MESSAGE_SEND2 301 // sending message through inbox
-#define FACEBOOK_REQUEST_MESSAGES_RECEIVE 302 // receiving messages
-#define FACEBOOK_REQUEST_TYPING_SEND 303 // sending typing notification
-
-#define FACEBOOK_REQUEST_THREAD_INFO 400 // getting thread info
-#define FACEBOOK_REQUEST_UNREAD_THREADS 401 // getting unread threads
-#define FACEBOOK_REQUEST_UNREAD_MESSAGES 402 // getting unread messages
-#define FACEBOOK_REQUEST_ASYNC 403 // marking messages read and getting other things
-#define FACEBOOK_REQUEST_MARK_READ 404 // marking messages read (new)
-
-// Send message types
-#define MESSAGE_INBOX 0
-#define MESSAGE_MERCURY 1
-#define MESSAGE_TID 2
-#define MESSAGE_ASYNC 3
-
-// Contact types
-#define FACEBOOK_CONTACT_FRIEND 1 // contact that IS on our server list
-#define FACEBOOK_CONTACT_NONE 2 // contact that ISN'T on our server list
-#define FACEBOOK_CONTACT_REQUEST 3 // contact that we asked for friendship
-#define FACEBOOK_CONTACT_APPROVE 4 // contact that is asking us for approval of friendship
+enum RequestType {
+ REQUEST_LOGIN, // connecting physically
+ REQUEST_LOGOUT, // disconnecting physically
+ REQUEST_SETUP_MACHINE, // setting machine name
+ REQUEST_HOME, // getting own name, avatar, ...
+ REQUEST_DTSG, // getting __fb_dtsg__
+ REQUEST_RECONNECT, // getting __sequence_num__ and __channel_id__
+ REQUEST_VISIBILITY, // setting chat visibility
+
+ REQUEST_FEEDS, // getting feeds
+ REQUEST_NOTIFICATIONS, // getting notifications
+ REQUEST_LOAD_REQUESTS, // getting friend requests
+
+ REQUEST_STATUS_SET, // setting my "What's on my mind?"
+ REQUEST_SEARCH, // searching
+ REQUEST_POKE, // sending pokes
+ REQUEST_NOTIFICATIONS_READ, // marking notifications read
+
+ REQUEST_BUDDY_LIST, // getting regular updates (friends online, ...)
+ REQUEST_LOAD_FRIENDS, // getting list of all friends
+ REQUEST_REQUEST_FRIEND, // requesting friends
+ REQUEST_APPROVE_FRIEND, // approving friends
+ REQUEST_DELETE_FRIEND, // deleting friends
+ REQUEST_CANCEL_REQUEST, // canceling friends request
+
+ REQUEST_MESSAGE_SEND, // sending message
+ REQUEST_MESSAGE_SEND2, // sending message through inbox
+ REQUEST_MESSAGES_RECEIVE, // receiving messages
+ REQUEST_TYPING_SEND, // sending typing notification
+
+ REQUEST_THREAD_INFO, // getting thread info
+ REQUEST_UNREAD_THREADS, // getting unread threads
+ REQUEST_UNREAD_MESSAGES, // getting unread messages
+ REQUEST_ASYNC, // marking messages read and getting other things
+ REQUEST_MARK_READ, // marking messages read (new)
+};
+
+enum MessageMethod {
+ MESSAGE_INBOX,
+ MESSAGE_MERCURY,
+ MESSAGE_TID,
+ MESSAGE_ASYNC
+};
+
+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
+};
typedef struct {
const char *name;
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index a93fac5f64..58c9237aa4 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -62,7 +62,7 @@ HANDLE FacebookProto::ContactIDToHContact(std::string user_id)
return 0;
}
-HANDLE FacebookProto::AddToContactList(facebook_user* fbu, BYTE type, bool dont_check)
+HANDLE FacebookProto::AddToContactList(facebook_user* fbu, ContactType type, bool dont_check)
{
HANDLE hContact;
@@ -164,7 +164,7 @@ void FacebookProto::DeleteContactFromServer(void *data)
std::string get_query = "norefresh=true&unref=button_dropdown&uid=" + id;
// Get unread inbox threads
- http::response resp = facy.flap(FACEBOOK_REQUEST_DELETE_FRIEND, &query, &get_query);
+ http::response resp = facy.flap(REQUEST_DELETE_FRIEND, &query, &get_query);
// Process result data
facy.validate_response(&resp);
@@ -180,7 +180,7 @@ void FacebookProto::DeleteContactFromServer(void *data)
// If contact wasn't deleted from database
if (hContact != NULL) {
db_set_w(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE);
- db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_NONE);
+ db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE);
db_set_dw(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, ::time(NULL));
}
@@ -209,7 +209,7 @@ void FacebookProto::AddContactToServer(void *data)
query += "&__user=" + facy.self_.user_id;
// Get unread inbox threads
- http::response resp = facy.flap(FACEBOOK_REQUEST_REQUEST_FRIEND, &query);
+ http::response resp = facy.flap(REQUEST_REQUEST_FRIEND, &query);
// Process result data
facy.validate_response(&resp);
@@ -219,7 +219,7 @@ void FacebookProto::AddContactToServer(void *data)
// If contact wasn't deleted from database
if (hContact != NULL)
- db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_REQUEST);
+ db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_REQUEST);
NotifyEvent(m_tszUserName, TranslateT("Request for friendship was sent."), NULL, FACEBOOK_EVENT_OTHER);
} else {
@@ -249,12 +249,12 @@ void FacebookProto::ApproveContactToServer(void *data)
ptrA id = db_get_sa(hContact, m_szModuleName, FACEBOOK_KEY_ID);
get_data += id;
- http::response resp = facy.flap(FACEBOOK_REQUEST_APPROVE_FRIEND, &post_data, &get_data);
+ http::response resp = facy.flap(REQUEST_APPROVE_FRIEND, &post_data, &get_data);
// Process result data
facy.validate_response(&resp);
- db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_FRIEND);
+ db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_FRIEND);
}
void FacebookProto::CancelFriendsRequest(void *data)
@@ -275,14 +275,14 @@ void FacebookProto::CancelFriendsRequest(void *data)
query += "&friend=" + std::string(id);
// Get unread inbox threads
- http::response resp = facy.flap(FACEBOOK_REQUEST_CANCEL_REQUEST, &query);
+ http::response resp = facy.flap(REQUEST_CANCEL_REQUEST, &query);
// Process result data
facy.validate_response(&resp);
if (resp.data.find("\"payload\":null", 0) != std::string::npos)
{
- db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_NONE);
+ db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE);
NotifyEvent(m_tszUserName, TranslateT("Request for friendship was canceled."), NULL, FACEBOOK_EVENT_OTHER);
} else {
facy.client_notify(TranslateT("Error occured when canceling friendship request."));
@@ -308,7 +308,7 @@ void FacebookProto::SendPokeWorker(void *p)
data += "&__user=" + facy.self_.user_id;
// Send poke
- http::response resp = facy.flap(FACEBOOK_REQUEST_POKE, &data);
+ http::response resp = facy.flap(REQUEST_POKE, &data);
// Process result data
facy.validate_response(&resp);
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 08556d77be..426e867475 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -508,7 +508,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
facebook_user fbu;
fbu.user_id = user_id;
- HANDLE hContact = proto->AddToContactList(&fbu, FACEBOOK_CONTACT_FRIEND);
+ HANDLE hContact = proto->AddToContactList(&fbu, CONTACT_FRIEND);
if (db_get_w(hContact, proto->m_szModuleName, "Status", 0) == ID_STATUS_OFFLINE)
db_set_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_ONLINE);
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp
index f7eff1c61a..1c31312263 100644
--- a/protocols/FacebookRM/src/messages.cpp
+++ b/protocols/FacebookRM/src/messages.cpp
@@ -90,7 +90,7 @@ void FacebookProto::SendChatMsgWorker(void *p)
post_data += "&__user=" + facy.self_.user_id;
post_data += "&phstamp=0";
- http::response resp = facy.flap(FACEBOOK_REQUEST_THREAD_INFO, &post_data);
+ http::response resp = facy.flap(REQUEST_THREAD_INFO, &post_data);
facy.validate_response(&resp);
tid = utils::text::source_get_value(&resp.data, 2, "\"thread_id\":\"", "\"");
@@ -133,7 +133,7 @@ void FacebookProto::SendTypingWorker(void *p)
// Dont send typing notifications to contacts, that are offline or not friends
if (db_get_w(typing->hContact,m_szModuleName,"Status", 0) == ID_STATUS_OFFLINE
- || db_get_b(typing->hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) != FACEBOOK_CONTACT_FRIEND)
+ || db_get_b(typing->hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) != CONTACT_FRIEND)
return;
// TODO RM: maybe better send typing optimalization
@@ -155,7 +155,7 @@ void FacebookProto::SendTypingWorker(void *p)
data += "&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0");
data += "&lsd=&phstamp=0&__user=" + facy.self_.user_id;
- http::response resp = facy.flap(FACEBOOK_REQUEST_TYPING_SEND, &data);
+ http::response resp = facy.flap(REQUEST_TYPING_SEND, &data);
db_free(&dbv);
}
@@ -180,7 +180,7 @@ void FacebookProto::ReadMessageWorker(void *p)
data += "&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0");
data += "&lsd=&__user=" + facy.self_.user_id;
- facy.flap(FACEBOOK_REQUEST_ASYNC, &data);
+ facy.flap(REQUEST_ASYNC, &data);
} else {
// new variant - with seen info
ptrA mid( db_get_sa(hContact, m_szModuleName, FACEBOOK_KEY_MESSAGE_ID));
@@ -191,7 +191,7 @@ void FacebookProto::ReadMessageWorker(void *p)
data += "&__user=" + facy.self_.user_id;
data += "&__a=1&__dyn=&__req=j&phstamp=0";
- facy.flap(FACEBOOK_REQUEST_MARK_READ, &data);
+ facy.flap(REQUEST_MARK_READ, &data);
}
}
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index 9ec6aec3b0..ab77ddb50d 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -69,7 +69,7 @@ void FacebookProto::ProcessBuddyList(void* data)
{
HANDLE hContact = fbu->handle;
if (!hContact)
- hContact = AddToContactList(fbu, FACEBOOK_CONTACT_FRIEND);
+ hContact = AddToContactList(fbu, CONTACT_FRIEND);
DBVARIANT dbv;
TCHAR* client = on_mobile ? _T(FACEBOOK_MOBILE) : _T(FACEBOOK_NAME);
@@ -94,7 +94,7 @@ void FacebookProto::ProcessBuddyList(void* data)
i = i->next;
if (!fbu->handle) // just been added
- fbu->handle = AddToContactList(fbu, FACEBOOK_CONTACT_FRIEND);
+ fbu->handle = AddToContactList(fbu, CONTACT_FRIEND);
if (db_get_w(fbu->handle, m_szModuleName, "Status", 0) != fbu->status_id)
db_set_w(fbu->handle, m_szModuleName, "Status", fbu->status_id);
@@ -106,8 +106,8 @@ void FacebookProto::ProcessBuddyList(void* data)
db_unset(fbu->handle, m_szModuleName, "LastActiveTS");
}
- if (db_get_b(fbu->handle, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) != FACEBOOK_CONTACT_FRIEND) {
- db_set_b(fbu->handle, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_FRIEND);
+ if (db_get_b(fbu->handle, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) != CONTACT_FRIEND) {
+ db_set_b(fbu->handle, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_FRIEND);
// TODO: remove that popup and use "Contact added you" event?
}
@@ -195,8 +195,8 @@ void FacebookProto::ProcessFriendList(void* data)
db_set_utf(hContact, m_szModuleName, FACEBOOK_KEY_NICK, fbu->real_name.c_str());
}
- if (db_get_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) != FACEBOOK_CONTACT_FRIEND) {
- db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_FRIEND);
+ if (db_get_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) != CONTACT_FRIEND) {
+ db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_FRIEND);
// TODO: remove that popup and use "Contact added you" event?
}
@@ -221,11 +221,11 @@ void FacebookProto::ProcessFriendList(void* data)
// Wasnt we already been notified about this contact? And was this real friend?
if (!db_get_dw(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, 0)
- && db_get_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) == FACEBOOK_CONTACT_FRIEND)
+ && db_get_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) == CONTACT_FRIEND)
{
db_set_dw(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, ::time(NULL));
- db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_NONE);
+ db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE);
std::string contactname = id;
if (!db_get_utf(hContact, m_szModuleName, FACEBOOK_KEY_NAME, &dbv)) {
@@ -247,7 +247,7 @@ void FacebookProto::ProcessFriendList(void* data)
for (std::map< std::string, facebook_user* >::iterator iter = friends.begin(); iter != friends.end(); ++iter) {
facebook_user *fbu = iter->second;
- HANDLE hContact = AddToContactList(fbu, FACEBOOK_CONTACT_FRIEND, true); // This contact is surely new ...are you sure?
+ HANDLE hContact = AddToContactList(fbu, CONTACT_FRIEND, true); // This contact is surely new ...are you sure?
// db_set_w(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE);
}
@@ -273,7 +273,7 @@ void FacebookProto::ProcessUnreadMessages(void*)
{
std::string get_data = "&page=" + page;
- http::response resp = facy.flap(FACEBOOK_REQUEST_UNREAD_THREADS, NULL, &get_data);
+ http::response resp = facy.flap(REQUEST_UNREAD_THREADS, NULL, &get_data);
// Process result data
facy.validate_response(&resp);
@@ -315,7 +315,7 @@ void FacebookProto::ProcessUnreadMessage(void *tid_data)
std::string get_data = "tid=" + *(std::string*)tid_data;
delete (std::string*)tid_data;
- http::response resp = facy.flap(FACEBOOK_REQUEST_UNREAD_MESSAGES, NULL, &get_data);
+ http::response resp = facy.flap(REQUEST_UNREAD_MESSAGES, NULL, &get_data);
facy.validate_response(&resp);
if (resp.code != HTTP_CODE_OK) {
@@ -331,9 +331,9 @@ void FacebookProto::ProcessUnreadMessage(void *tid_data)
std::string messageslist = utils::text::source_get_value(&resp.data, 2, "id=\"messageGroup\">", "</form>");
facebook_user fbu;
- HANDLE hContact;
+ HANDLE hContact = NULL;
- std::string::size_type pos, pos2 = 0;
+ std::string::size_type pos = 0, pos2 = 0;
while ((pos2 = messageslist.find("class=\"acw apl abt", pos2)) != std::string::npos) {
pos2 += 19;
std::string group = messageslist.substr(pos2, messageslist.find("class=\"actions ", pos2) - pos2);
@@ -356,7 +356,7 @@ void FacebookProto::ProcessUnreadMessage(void *tid_data)
if (hContact == NULL) {
fbu.user_id = author;
fbu.real_name = utils::text::slashu_to_utf8(utils::text::source_get_value(&group, 2, "name&quot;:&quot;", "&quot;"));
- hContact = AddToContactList(&fbu, FACEBOOK_CONTACT_NONE);
+ hContact = AddToContactList(&fbu, CONTACT_NONE);
// TODO: if contact is newly added, get his user info
// TODO: maybe create new "receiveMsg" function and use it for offline and channel messages?
}
@@ -423,7 +423,7 @@ void FacebookProto::ProcessMessages(void* data)
fbu.user_id = messages[i]->user_id;
fbu.real_name = messages[i]->sender_name;
- HANDLE hContact = AddToContactList(&fbu, FACEBOOK_CONTACT_NONE);
+ HANDLE hContact = AddToContactList(&fbu, CONTACT_NONE);
db_set_s(hContact, m_szModuleName, FACEBOOK_KEY_MESSAGE_ID, messages[i]->message_id.c_str());
// TODO: if contact is newly added, get his user info
@@ -477,7 +477,7 @@ void FacebookProto::ProcessNotifications(void*)
facy.handle_entry("notifications");
// Get notifications
- http::response resp = facy.flap(FACEBOOK_REQUEST_NOTIFICATIONS);
+ http::response resp = facy.flap(REQUEST_NOTIFICATIONS);
// Process result data
facy.validate_response(&resp);
@@ -526,7 +526,7 @@ void FacebookProto::ProcessFriendRequests(void*)
facy.handle_entry("friendRequests");
// Get notifications
- http::response resp = facy.flap(FACEBOOK_REQUEST_LOAD_REQUESTS);
+ http::response resp = facy.flap(REQUEST_LOAD_REQUESTS);
// Process result data
facy.validate_response(&resp);
@@ -562,8 +562,8 @@ void FacebookProto::ProcessFriendRequests(void*)
if (fbu->user_id.length() && fbu->real_name.length())
{
- HANDLE hContact = AddToContactList(fbu, FACEBOOK_CONTACT_APPROVE);
- db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_APPROVE);
+ HANDLE hContact = AddToContactList(fbu, CONTACT_APPROVE);
+ db_set_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_APPROVE);
bool seen = false;
@@ -735,7 +735,7 @@ void FacebookProto::SearchAckThread(void *targ)
if (!ssid.empty())
get_data += "&ssid=" + ssid;
- http::response resp = facy.flap(FACEBOOK_REQUEST_SEARCH, NULL, &get_data);
+ http::response resp = facy.flap(REQUEST_SEARCH, NULL, &get_data);
// Process result data
facy.validate_response(&resp);
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 9f37b2a8b8..ab0f3a6e3d 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -247,7 +247,7 @@ HANDLE FacebookProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
fbu.real_name += " ";
fbu.real_name += surname;
- HANDLE hContact = AddToContactList(&fbu, FACEBOOK_CONTACT_NONE);
+ HANDLE hContact = AddToContactList(&fbu, CONTACT_NONE);
if (hContact) {
if (flags & PALF_TEMPORARY) {
db_set_b(hContact, "Clist", "Hidden", 1);
@@ -544,7 +544,7 @@ int FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam)
// Ignore groupchats and, if deleting, also not-friends
if (db_get_b(hContact, m_szModuleName, "ChatRoom", 0)
- || (deleting && db_get_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) != FACEBOOK_CONTACT_FRIEND))
+ || (deleting && db_get_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0) != CONTACT_FRIEND))
return 0;
ptrT tname = db_get_tsa(hContact, m_szModuleName, FACEBOOK_KEY_NAME);
@@ -668,7 +668,7 @@ void FacebookProto::ReadNotificationWorker(void *p)
data += "&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0");
data += "&__user=" + facy.self_.user_id;
- facy.flap(FACEBOOK_REQUEST_NOTIFICATIONS_READ, NULL, &data);
+ facy.flap(REQUEST_NOTIFICATIONS_READ, NULL, &data);
delete p;
} \ No newline at end of file
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index 640ccad168..1fe140a966 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "constants.h"
+
#pragma once
class FacebookProto : public PROTO_INTERFACE
@@ -168,7 +170,7 @@ public:
bool IsMyContact(HANDLE, bool include_chat = false);
HANDLE ContactIDToHContact(std::string);
HANDLE ChatIDToHContact(std::string);
- HANDLE AddToContactList(facebook_user*, BYTE type, bool dont_check = false);
+ HANDLE AddToContactList(facebook_user*, ContactType type, bool dont_check = false);
void SetAllContactStatuses(int status, bool reset_client = false);
HANDLE HContactFromAuthEvent(HANDLE hEvent);
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp
index 698e3e5fd8..f01dcd616e 100644
--- a/protocols/FacebookRM/src/theme.cpp
+++ b/protocols/FacebookRM/src/theme.cpp
@@ -156,10 +156,10 @@ int FacebookProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
BYTE type = db_get_b(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0);
- Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_ASK], ctrlPressed || type == FACEBOOK_CONTACT_NONE || !type);
- Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_GRANT], ctrlPressed || type == FACEBOOK_CONTACT_APPROVE);
- Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || type == FACEBOOK_CONTACT_FRIEND);
- Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_CANCEL], ctrlPressed || type == FACEBOOK_CONTACT_REQUEST);
+ Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_ASK], ctrlPressed || type == CONTACT_NONE || !type);
+ Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_GRANT], ctrlPressed || type == CONTACT_APPROVE);
+ Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || type == CONTACT_FRIEND);
+ Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_CANCEL], ctrlPressed || type == CONTACT_REQUEST);
Menu_ShowItem(g_hContactMenuItems[CMI_POKE], true);
}