diff options
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/docs/facebook - readme.txt | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/client.h | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 111 | ||||
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 15 | ||||
-rw-r--r-- | protocols/FacebookRM/src/db.h | 9 | ||||
-rw-r--r-- | protocols/FacebookRM/src/entities.h | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/http.h | 82 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 10 | ||||
-rw-r--r-- | protocols/FacebookRM/src/messages.cpp | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 47 |
10 files changed, 109 insertions, 175 deletions
diff --git a/protocols/FacebookRM/docs/facebook - readme.txt b/protocols/FacebookRM/docs/facebook - readme.txt index a094c6b995..eef2b87168 100644 --- a/protocols/FacebookRM/docs/facebook - readme.txt +++ b/protocols/FacebookRM/docs/facebook - readme.txt @@ -28,7 +28,6 @@ Info: "DisableLogout" (Byte) - 1 = Disable logout procedure, 0 = default
"PollRate" (Byte) - Waiting time between buddy list and newsfeed parsing.
"Locale" (String) - Get facebook errors in specific language, "en_US", "cs_CZ", etc.
-"ValidateResponse" (Byte) - Set how otfen it should validate facebook responses and thus handle/show errors; 0 = default, 1 = always, 2 = never
"UseLocalTimestampUnread" (Byte) - 1 = Use local timestamp for offline (unread) messages
--------------------------------
@@ -38,7 +37,7 @@ Info: 0.2.1.0 - 1.10.2013
+ Save name into first, second and last name fields separately
+ First experimental implementation of multi user chats (thanks to nobodyreal for patch)
- * Notify more facebook errors in validate_reseponse
+ * Notify more facebook errors
* Don't use local_timestamp for unread messages (even if enabled in options) by default (use hidden setting to enable it)
! Duplicit contacts fixes (and hopefully it won't create duplicit contacts anymore)
! Fixed Poke
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index 41a8b6a1d0..57a503d748 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -111,8 +111,6 @@ public: unsigned int error_count_;
- bool validate_response(http::response *resp, bool notify = true);
-
bool handle_entry(std::string method);
bool handle_success(std::string method);
bool handle_error(std::string method, int force_disconnect = 0);
@@ -174,6 +172,7 @@ public: DWORD choose_security_level(RequestType);
int choose_method(RequestType);
+ bool notify_errors(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);
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index f7c56feb70..6e908c5505 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -108,82 +108,48 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ } else {
parent->Log("!!!!! No response from server (time-out)");
resp.code = HTTP_CODE_FAKE_DISCONNECTED;
- // Better to have something set explicitely as this value
- // is compaired in all communication requests
+ // Better to have something set explicitely as this value is compaired in all communication requests
}
- if (parent->getByte(FACEBOOK_KEY_VALIDATE_RESPONSE, 0) == 1)
- validate_response(&resp);
-
- return resp;
-}
-
-bool facebook_client::validate_response(http::response* resp, bool notify)
-{
- if (resp->code == HTTP_CODE_FAKE_DISCONNECTED)
- {
- parent->Log(" ! ! Request has timed out, connection or server error");
- return false;
- }
-
- if (parent->getByte(FACEBOOK_KEY_VALIDATE_RESPONSE, 0) == 2) {
- return true;
- }
-
-/*
- // TODO: Is this from jarvis? Or me? Add it?
- std::string cookie = utils::text::source_get_value(&resp->data, 2, "setCookie(\\\"", ");");
- if (!cookie.empty()) {
- std::string cookie_name = utils::text::source_get_value(&cookie, 1, "\\\"");
- std::string cookie_value = utils::text::source_get_value(&cookie, 3, "\\\"", "\\\"", "\\\"");
-
- parent->Log(" New cookie from response '%s': %s", cookie_name.c_str(), cookie_value.c_str());
- this->cookies[cookie_name] = cookie_value;
- }
-*/
- std::string::size_type pos = resp->data.find("\"error\":");
- if (pos != std::string::npos) {
- try
- {
+ // Get Facebook's error message
+ if (resp.code == HTTP_CODE_OK) {
+ std::string::size_type pos = resp.data.find("\"error\":");
+ if (pos != std::string::npos) {
pos += 8;
- int error_num = atoi(resp->data.substr(pos, resp->data.find(",", pos) - pos).c_str());
+ int error_num = atoi(resp.data.substr(pos, resp.data.find(",", pos) - pos).c_str());
if (error_num != 0) {
std::string error = "";
- pos = resp->data.find("\"errorDescription\":\"", pos);
+
+ pos = resp.data.find("\"errorDescription\":\"", pos);
if (pos != std::string::npos) {
pos += 20;
- error = resp->data.substr(pos, resp->data.find("\"", pos) - pos);
+ error = resp.data.substr(pos, resp.data.find("\"", pos) - pos);
error = utils::text::trim(utils::text::special_expressions_decode(utils::text::slashu_to_utf8(error)));
error = ptrA( mir_utf8decodeA(error.c_str()));
}
std::string title = "";
- pos = resp->data.find("\"errorSummary\":\"", pos);
+ pos = resp.data.find("\"errorSummary\":\"", pos);
if (pos != std::string::npos) {
pos += 16;
- title = resp->data.substr(pos, resp->data.find("\"", pos) - pos);
+ title = resp.data.substr(pos, resp.data.find("\"", pos) - pos);
title = utils::text::trim(utils::text::special_expressions_decode(utils::text::slashu_to_utf8(title)));
title = ptrA( mir_utf8decodeA(title.c_str()));
}
- resp->error_number = error_num;
- resp->error_text = error;
- resp->error_title = title;
- resp->code = HTTP_CODE_FAKE_ERROR;
+ resp.error_number = error_num;
+ resp.error_text = error;
+ resp.error_title = title;
+ resp.code = HTTP_CODE_FAKE_ERROR;
parent->Log(" ! ! Received Facebook error: %d -- %s", error_num, error.c_str());
- if (notify)
+ if (notify_errors(request_type))
client_notify(_A2T(error.c_str()));
-
- return false;
}
- } catch (const std::exception &e) {
- parent->Log(" @ @ validate_response: Exception: %s",e.what());
- return false;
}
}
- return true;
+ return resp;
}
bool facebook_client::handle_entry(std::string method)
@@ -564,6 +530,21 @@ std::string facebook_client::choose_action(RequestType request_type, std::string }
}
+bool facebook_client::notify_errors(RequestType request_type)
+{
+ switch (request_type)
+ {
+ case REQUEST_BUDDY_LIST:
+ case REQUEST_MESSAGE_SEND2:
+ case REQUEST_MESSAGE_SEND:
+ case REQUEST_ASYNC:
+ return false;
+
+ default:
+ return true;
+ }
+}
+
NETLIBHTTPHEADER* facebook_client::get_request_headers(int request_type, int* headers_count)
{
if (request_type == REQUEST_POST)
@@ -715,9 +696,6 @@ bool facebook_client::login(const char *username, const char *password) // Send validation
http::response resp = flap(REQUEST_LOGIN, &data);
- // Process result data
- validate_response(&resp);
-
// Save Device ID
if (cookies["datr"].length())
parent->setString(FACEBOOK_KEY_DEVICE_ID, cookies["datr"].c_str());
@@ -782,7 +760,6 @@ bool facebook_client::login(const char *username, const char *password) inner_data += "&fb_dtsg=" + utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"");
resp = flap(REQUEST_SETUP_MACHINE, &inner_data);
- validate_response(&resp);
}
}
@@ -884,9 +861,6 @@ bool facebook_client::home() resp = flap(REQUEST_HOME);
- // Process result data
- validate_response(&resp);
-
switch (resp.code)
{
case HTTP_CODE_OK:
@@ -942,9 +916,6 @@ bool facebook_client::reconnect() // Request reconnect
http::response resp = flap(REQUEST_RECONNECT);
- // Process result data
- validate_response(&resp);
-
switch (resp.code)
{
case HTTP_CODE_OK:
@@ -990,9 +961,6 @@ bool facebook_client::buddy_list() // Get buddy list
http::response resp = flap(REQUEST_BUDDY_LIST, &data);
- // Process result data
- validate_response(&resp);
-
switch (resp.code) {
case HTTP_CODE_OK:
parent->ForkThread(&FacebookProto::ProcessBuddyList, new std::string(resp.data));
@@ -1012,9 +980,6 @@ bool facebook_client::load_friends() // Get buddy list
http::response resp = flap(REQUEST_LOAD_FRIENDS);
- // Process result data
- validate_response(&resp);
-
switch (resp.code) {
case HTTP_CODE_OK:
parent->ForkThread(&FacebookProto::ProcessFriendList, new std::string(resp.data));
@@ -1034,9 +999,6 @@ bool facebook_client::feeds() // Get feeds
http::response resp = flap(REQUEST_FEEDS);
- // Process result data
- validate_response(&resp);
-
switch (resp.code) {
case HTTP_CODE_OK:
if (resp.data.find("\"num_stories\":0") == std::string::npos)
@@ -1061,9 +1023,6 @@ bool facebook_client::load_pages() // Get feeds
http::response resp = flap(REQUEST_PAGES);
- // Process result data
- validate_response(&resp);
-
switch (resp.code) {
case HTTP_CODE_OK:
{
@@ -1112,9 +1071,6 @@ bool facebook_client::channel() // Get update
http::response resp = flap(REQUEST_MESSAGES_RECEIVE);
- // Process result data
- validate_response(&resp);
-
if (resp.code != HTTP_CODE_OK)
{
// Something went wrong
@@ -1263,7 +1219,6 @@ bool facebook_client::send_message(std::string message_recipient, std::string me }
}
- validate_response(&resp, false);
*error_text = resp.error_text;
switch (resp.error_number)
@@ -1380,7 +1335,7 @@ bool facebook_client::post_status(status_data *status) flap(REQUEST_IDENTITY_SWITCH, &data);
}
- if (validate_response(&resp) && resp.code == HTTP_CODE_OK) {
+ if (resp.isValid()) {
parent->NotifyEvent(parent->m_tszUserName, TranslateT("Status update was successful."), NULL, FACEBOOK_EVENT_OTHER);
return handle_success("post_status");
}
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 28b2b25d79..0ba4986f1a 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -197,9 +197,6 @@ void FacebookProto::DeleteContactFromServer(void *data) // Get unread inbox threads
http::response resp = facy.flap(REQUEST_DELETE_FRIEND, &query, &get_query);
- // Process result data
- facy.validate_response(&resp);
-
if (resp.data.find("\"payload\":null", 0) != std::string::npos)
{
facebook_user* fbu = facy.buddies.find(id);
@@ -242,9 +239,6 @@ void FacebookProto::AddContactToServer(void *data) // Get unread inbox threads
http::response resp = facy.flap(REQUEST_REQUEST_FRIEND, &query);
- // Process result data
- facy.validate_response(&resp);
-
if (resp.data.find("\"success\":true", 0) != std::string::npos) {
HANDLE hContact = ContactIDToHContact(id);
@@ -281,9 +275,6 @@ void FacebookProto::ApproveContactToServer(void *data) http::response resp = facy.flap(REQUEST_APPROVE_FRIEND, &post_data, &get_data);
- // Process result data
- facy.validate_response(&resp);
-
setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_FRIEND);
}
@@ -307,9 +298,6 @@ void FacebookProto::CancelFriendsRequest(void *data) // Get unread inbox threads
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)
{
setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE);
@@ -339,9 +327,6 @@ void FacebookProto::SendPokeWorker(void *p) // Send poke
http::response resp = facy.flap(REQUEST_POKE, &data);
- // Process result data
- facy.validate_response(&resp);
-
if (resp.data.find("\"payload\":null", 0) != std::string::npos) {
std::string message = utils::text::source_get_value(&resp.data, 3, "__html\":\"", "\\/button>", "\"}");
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h index d009139627..65538d2f16 100644 --- a/protocols/FacebookRM/src/db.h +++ b/protocols/FacebookRM/src/db.h @@ -55,11 +55,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FACEBOOK_KEY_LAST_WALL "LastWall"
#define FACEBOOK_KEY_LOAD_PAGES "LoadPages"
-#define FACEBOOK_KEY_POLL_RATE "PollRate" // [HIDDEN]
-#define FACEBOOK_KEY_TIMEOUTS_LIMIT "TimeoutsLimit" // [HIDDEN]
-#define FACEBOOK_KEY_DISABLE_LOGOUT "DisableLogout" // [HIDDEN]
-#define FACEBOOK_KEY_VALIDATE_RESPONSE "ValidateResponse" // [HIDDEN] - 0 = standard, 1 = always, 2 = never
-#define FACEBOOK_KEY_LOCALE "Locale" // [HIDDEN] - en_US, cs_CZ, etc.
+#define FACEBOOK_KEY_POLL_RATE "PollRate" // [HIDDEN]
+#define FACEBOOK_KEY_TIMEOUTS_LIMIT "TimeoutsLimit" // [HIDDEN]
+#define FACEBOOK_KEY_DISABLE_LOGOUT "DisableLogout" // [HIDDEN]
+#define FACEBOOK_KEY_LOCALE "Locale" // [HIDDEN] - en_US, cs_CZ, etc.
#define FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD "UseLocalTimestampUnread" // [HIDDEN] - 1 = use local timestamp for offline messages
#define FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE "EventNotificationsEnable"
diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h index 4ad4612985..d18a939e7b 100644 --- a/protocols/FacebookRM/src/entities.h +++ b/protocols/FacebookRM/src/entities.h @@ -80,12 +80,14 @@ struct facebook_message DWORD time;
bool isIncoming;
bool isUnread;
+ bool isChat;
facebook_message()
{
this->user_id = this->message_text = this->sender_name = this->message_id = "";
this->time = 0;
this->isUnread = this->isIncoming = true;
+ this->isChat = false;
}
facebook_message(const facebook_message& msg)
@@ -97,6 +99,7 @@ struct facebook_message this->time = msg.time;
this->isIncoming = msg.isIncoming;
this->isUnread = msg.isUnread;
+ this->isChat = msg.isChat;
}
};
diff --git a/protocols/FacebookRM/src/http.h b/protocols/FacebookRM/src/http.h index 69dc4dc9c7..507658bff9 100644 --- a/protocols/FacebookRM/src/http.h +++ b/protocols/FacebookRM/src/http.h @@ -25,37 +25,37 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define HTTP_PROTO_REGULAR "http://"
#define HTTP_PROTO_SECURE "https://"
-#define HTTP_CODE_CONTINUE 100
+#define HTTP_CODE_CONTINUE 100
#define HTTP_CODE_SWITCHING_PROTOCOLS 101
-#define HTTP_CODE_PROCESSING 102
-#define HTTP_CODE_OK 200
-#define HTTP_CODE_CREATED 201
-#define HTTP_CODE_ACCEPTED 202
+#define HTTP_CODE_PROCESSING 102
+#define HTTP_CODE_OK 200
+#define HTTP_CODE_CREATED 201
+#define HTTP_CODE_ACCEPTED 202
#define HTTP_CODE_NON_AUTHORITATIVE_INFORMATION 203
-#define HTTP_CODE_NO_CONTENT 204
-#define HTTP_CODE_RESET_CONTENT 205
-#define HTTP_CODE_PARTIAL_CONTENT 206
-#define HTTP_CODE_MULTI_STATUS 207
-#define HTTP_CODE_MULTIPLE_CHOICES 300
-#define HTTP_CODE_MOVED_PERMANENTLY 301
-#define HTTP_CODE_FOUND 302
-#define HTTP_CODE_SEE_OTHER 303
-#define HTTP_CODE_NOT_MODIFIED 304
-#define HTTP_CODE_USE_PROXY 305
-#define HTTP_CODE_SWITCH_PROXY 306
+#define HTTP_CODE_NO_CONTENT 204
+#define HTTP_CODE_RESET_CONTENT 205
+#define HTTP_CODE_PARTIAL_CONTENT 206
+#define HTTP_CODE_MULTI_STATUS 207
+#define HTTP_CODE_MULTIPLE_CHOICES 300
+#define HTTP_CODE_MOVED_PERMANENTLY 301
+#define HTTP_CODE_FOUND 302
+#define HTTP_CODE_SEE_OTHER 303
+#define HTTP_CODE_NOT_MODIFIED 304
+#define HTTP_CODE_USE_PROXY 305
+#define HTTP_CODE_SWITCH_PROXY 306
#define HTTP_CODE_TEMPORARY_REDIRECT 307
-#define HTTP_CODE_BAD_REQUEST 400
-#define HTTP_CODE_UNAUTHORIZED 401
-#define HTTP_CODE_PAYMENT_REQUIRED 402
-#define HTTP_CODE_FORBIDDEN 403
-#define HTTP_CODE_NOT_FOUND 404
+#define HTTP_CODE_BAD_REQUEST 400
+#define HTTP_CODE_UNAUTHORIZED 401
+#define HTTP_CODE_PAYMENT_REQUIRED 402
+#define HTTP_CODE_FORBIDDEN 403
+#define HTTP_CODE_NOT_FOUND 404
#define HTTP_CODE_METHOD_NOT_ALLOWED 405
-#define HTTP_CODE_NOT_ACCEPTABLE 406
+#define HTTP_CODE_NOT_ACCEPTABLE 406
#define HTTP_CODE_PROXY_AUTHENTICATION_REQUIRED 407
-#define HTTP_CODE_REQUEST_TIMEOUT 408
-#define HTTP_CODE_CONFLICT 409
-#define HTTP_CODE_GONE 410
-#define HTTP_CODE_LENGTH_REQUIRED 411
+#define HTTP_CODE_REQUEST_TIMEOUT 408
+#define HTTP_CODE_CONFLICT 409
+#define HTTP_CODE_GONE 410
+#define HTTP_CODE_LENGTH_REQUIRED 411
#define HTTP_CODE_PRECONDITION_REQUIRED 412
#define HTTP_CODE_REQUEST_ENTITY_TOO_LARGE 413
#define HTTP_CODE_REQUEST_URI_TOO_LONG 414
@@ -63,24 +63,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define HTTP_CODE_REQUESTED_RANGE_NOT_SATISFIABLE 416
#define HTTP_CODE_EXPECTATION_FAILED 417
#define HTTP_CODE_UNPROCESSABLE_ENTITY 422
-#define HTTP_CODE_LOCKED 423
-#define HTTP_CODE_FAILED_DEPENDENCY 424
+#define HTTP_CODE_LOCKED 423
+#define HTTP_CODE_FAILED_DEPENDENCY 424
#define HTTP_CODE_UNORDERED_COLLECTION 425
-#define HTTP_CODE_UPGRADE_REQUIRED 426
-#define HTTP_CODE_RETRY_WITH 449
+#define HTTP_CODE_UPGRADE_REQUIRED 426
+#define HTTP_CODE_RETRY_WITH 449
#define HTTP_CODE_INTERNAL_SERVER_ERROR 500
-#define HTTP_CODE_NOT_IMPLEMENTED 501
-#define HTTP_CODE_BAD_GATEWAY 502
+#define HTTP_CODE_NOT_IMPLEMENTED 501
+#define HTTP_CODE_BAD_GATEWAY 502
#define HTTP_CODE_SERVICE_UNAVAILABLE 503
-#define HTTP_CODE_GATEWAY_TIMEOUT 504
+#define HTTP_CODE_GATEWAY_TIMEOUT 504
#define HTTP_CODE_HTTP_VERSION_NOT_SUPPORTED 505
#define HTTP_CODE_VARIANT_ALSO_NEGOTIATES 506
#define HTTP_CODE_INSUFFICIENT_STORAGE 507
#define HTTP_CODE_BANDWIDTH_LIMIT_EXCEEDED 509
-#define HTTP_CODE_NOT_EXTENDED 510
+#define HTTP_CODE_NOT_EXTENDED 510
-#define HTTP_CODE_FAKE_DISCONNECTED 0
-#define HTTP_CODE_FAKE_ERROR 1
+#define HTTP_CODE_FAKE_DISCONNECTED 0
+#define HTTP_CODE_FAKE_ERROR 1
namespace http
{
@@ -94,10 +94,16 @@ namespace http {
response() : code(0), error_number(0) {}
int code;
+ std::map< std::string, std::string > headers;
+ std::string data;
+
+ // Facebook's error data
unsigned int error_number;
std::string error_text;
std::string error_title;
- std::map< std::string, std::string > headers;
- std::string data;
+
+ bool isValid() {
+ return (code == HTTP_CODE_OK && error_number == 0);
+ }
};
}
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 529dd8abd1..df43cf9466 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -84,7 +84,7 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user }
}
- // Find now awailable contacts
+ // Find now available contacts
JSONNODE *nowAvailable = json_get(list, "nowAvailableList");
if (nowAvailable != NULL) {
for (unsigned int i = 0; i < json_size(nowAvailable); i++) {
@@ -295,7 +295,7 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, JSONNODE if (!message_text->empty())
*message_text += "\n\n";
- // we can use this as offline messages doesn't have it
+ // we can't use this as offline messages doesn't have it
/* JSONNODE *admin_snippet = json_get(it, "admin_snippet");
if (admin_snippet != NULL) {
*message_text += json_as_pstring(admin_snippet);
@@ -435,8 +435,6 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa resp = proto->facy.flap(REQUEST_USER_INFO, NULL, &search);
}
- proto->facy.validate_response(&resp);
-
if (resp.code == HTTP_CODE_OK) {
std::string about = utils::text::source_get_value(&resp.data, 2, "<div class=\"timeline", "<div id=\"footer");
@@ -542,8 +540,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa }
std::string senderName = json_as_string(sender_name);
- std::string::size_type pos;
- /*if ((pos = senderName.find(" ")) != std::string::npos) {
+ /*std::string::size_type pos;
+ if ((pos = senderName.find(" ")) != std::string::npos) {
senderName = senderName.substr(0, pos);
}*/
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index 5a7dc086ae..8ca7a8c2c1 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -90,7 +90,6 @@ void FacebookProto::SendChatMsgWorker(void *p) post_data += "&phstamp=0";
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\":\"", "\"");
setString(hContact, FACEBOOK_KEY_TID, tid.c_str());
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index 74180a8358..af9726db2f 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -278,7 +278,6 @@ void FacebookProto::ProcessUnreadMessages(void*) data += "&__a=1&__dyn=&__req=&ttstamp=0";
http::response resp = facy.flap(REQUEST_UNREAD_THREADS, &data);
- facy.validate_response(&resp);
if (resp.code == HTTP_CODE_OK) {
@@ -343,7 +342,6 @@ void FacebookProto::ProcessUnreadMessage(void *p) }
resp = facy.flap(REQUEST_THREAD_INFO, &data);
- facy.validate_response(&resp);
if (resp.code == HTTP_CODE_OK) {
@@ -371,22 +369,26 @@ void FacebookProto::ProcessUnreadMessage(void *p) ParseSmileys(messages[i]->message_text, hContact);
- if (messages[i]->isIncoming) {
- PROTORECVEVENT recv = {0};
- recv.flags = PREF_UTF;
- recv.szMessage = const_cast<char*>(messages[i]->message_text.c_str());
- recv.timestamp = local_timestamp || !messages[i]->time ? ::time(NULL) : messages[i]->time;
- ProtoChainRecvMsg(hContact, &recv);
+ if (messages[i]->isChat) {
+
} else {
- DBEVENTINFO dbei = {0};
- dbei.cbSize = sizeof(dbei);
- dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | DBEF_UTF;
- dbei.szModule = m_szModuleName;
- dbei.timestamp = local_timestamp || !messages[i]->time ? ::time(NULL) : messages[i]->time;
- dbei.cbBlob = (DWORD)messages[i]->message_text.length() + 1;
- dbei.pBlob = (PBYTE)messages[i]->message_text.c_str();
- db_event_add(hContact, &dbei);
+ if (messages[i]->isIncoming) {
+ PROTORECVEVENT recv = {0};
+ recv.flags = PREF_UTF;
+ recv.szMessage = const_cast<char*>(messages[i]->message_text.c_str());
+ recv.timestamp = local_timestamp || !messages[i]->time ? ::time(NULL) : messages[i]->time;
+ ProtoChainRecvMsg(hContact, &recv);
+ } else {
+ DBEVENTINFO dbei = {0};
+ dbei.cbSize = sizeof(dbei);
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.flags = DBEF_SENT | DBEF_UTF;
+ dbei.szModule = m_szModuleName;
+ dbei.timestamp = local_timestamp || !messages[i]->time ? ::time(NULL) : messages[i]->time;
+ dbei.cbBlob = (DWORD)messages[i]->message_text.length() + 1;
+ dbei.pBlob = (PBYTE)messages[i]->message_text.c_str();
+ db_event_add(hContact, &dbei);
+ }
}
}
delete messages[i];
@@ -510,9 +512,6 @@ void FacebookProto::ProcessNotifications(void*) // Get notifications
http::response resp = facy.flap(REQUEST_NOTIFICATIONS);
- // Process result data
- facy.validate_response(&resp);
-
if (resp.code != HTTP_CODE_OK) {
facy.handle_error("notifications");
return;
@@ -556,9 +555,6 @@ void FacebookProto::ProcessFriendRequests(void*) // Get notifications
http::response resp = facy.flap(REQUEST_LOAD_REQUESTS);
- // Process result data
- facy.validate_response(&resp);
-
if (resp.code != HTTP_CODE_OK) {
facy.handle_error("friendRequests");
return;
@@ -763,9 +759,6 @@ void FacebookProto::SearchAckThread(void *targ) http::response resp = facy.flap(REQUEST_SEARCH, NULL, &get_data);
- // Process result data
- facy.validate_response(&resp);
-
if (resp.code == HTTP_CODE_OK)
{
std::string items = utils::text::source_get_value(&resp.data, 2, "<body", "</body>");
@@ -848,8 +841,6 @@ void FacebookProto::SearchIdAckThread(void *targ) resp = facy.flap(REQUEST_USER_INFO, NULL, &search);
}
- facy.validate_response(&resp);
-
if (resp.code == HTTP_CODE_OK)
{
std::string about = utils::text::source_get_value(&resp.data, 2, "<div class=\"timeline", "<div id=\"footer");
|