diff options
author | Robert Pösel <robyer@seznam.cz> | 2016-09-13 20:55:43 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2016-09-13 20:55:43 +0000 |
commit | 50ab5fccce7607a788ab26c77f43dd3198c1d7c6 (patch) | |
tree | aab55b6ff389d1dfeb70bbbf2e944c6559b468a6 /protocols/FacebookRM/src | |
parent | a6b06e8fee136a38231c3c15a438fe5043ed82eb (diff) |
Facebook: Fix errors from Coverity
git-svn-id: http://svn.miranda-ng.org/main/trunk@17294 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 38 | ||||
-rw-r--r-- | protocols/FacebookRM/src/entities.h | 11 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 6 |
3 files changed, 32 insertions, 23 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 5ebc58549c..2e59510c22 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -116,9 +116,6 @@ http::response facebook_client::sendRequest(HttpRequest *request) // Better to have something set explicitely as this value is compaired in all communication requests } - // Delete the request object - delete request; - // Get Facebook's error message if (resp.code == HTTP_CODE_OK) { std::string::size_type pos = resp.data.find("\"error\":"); @@ -165,6 +162,9 @@ http::response facebook_client::sendRequest(HttpRequest *request) } } + // Delete the request object + delete request; + return resp; } @@ -490,10 +490,10 @@ bool facebook_client::login(const char *username, const char *password) while (resp.data.find("id=\"approvals_code\"") != std::string::npos) { parent->debugLogA(" Login info: Approval code required."); - const char *fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")).c_str(); - const char *nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"").c_str(); + std::string fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); + std::string nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); - CFacebookGuardDialog guardDialog(parent, fb_dtsg); + CFacebookGuardDialog guardDialog(parent, fb_dtsg.c_str()); if (guardDialog.DoModal() != DIALOG_RESULT_OK) { parent->SetStatus(ID_STATUS_OFFLINE); return false; @@ -502,7 +502,7 @@ bool facebook_client::login(const char *username, const char *password) // We need verification code from user (he can get it via Facebook application on phone or by requesting code via SMS) const char *givenCode = guardDialog.GetCode(); - request = new SetupMachineRequest(fb_dtsg, nh, "Continue"); + request = new SetupMachineRequest(fb_dtsg.c_str(), nh.c_str(), "Continue"); request->Body << CHAR_VALUE("approvals_code", givenCode); resp = sendRequest(request); @@ -527,10 +527,10 @@ bool facebook_client::login(const char *username, const char *password) // 1) Continue (it might have been sent with approval code above already) if (resp.data.find("name=\"submit[Continue]\"") != std::string::npos) { - const char *fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")).c_str(); - const char *nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"").c_str(); + std::string fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); + std::string nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); - request = new SetupMachineRequest(fb_dtsg, nh, "Continue"); + request = new SetupMachineRequest(fb_dtsg.c_str(), nh.c_str(), "Continue"); resp = sendRequest(request); } @@ -560,27 +560,27 @@ bool facebook_client::login(const char *username, const char *password) return handle_error("login", FORCE_QUIT); } - const char *fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")).c_str(); - const char *nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"").c_str(); + std::string fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); + std::string nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); - request = new SetupMachineRequest(fb_dtsg, nh, "This was me"); // Recognize device (or "This wasn't me" - this will force to change account password) + request = new SetupMachineRequest(fb_dtsg.c_str(), nh.c_str(), "This was me"); // Recognize device (or "This wasn't me" - this will force to change account password) resp = sendRequest(request); // 3) Save last device - fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")).c_str(); - nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"").c_str(); + fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); + nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); - request = new SetupMachineRequest(fb_dtsg, nh, "Continue"); + request = new SetupMachineRequest(fb_dtsg.c_str(), nh.c_str(), "Continue"); request->Body << "&name_action_selected=save_device"; // Save device - or "dont_save" resp = sendRequest(request); } // Save this actual device if (resp.data.find("name=\"submit[Continue]\"") != std::string::npos) { - const char *fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")).c_str(); - const char *nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"").c_str(); + std::string fb_dtsg = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); + std::string nh = utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\""); - request = new SetupMachineRequest(fb_dtsg, nh, "Continue"); + request = new SetupMachineRequest(fb_dtsg.c_str(), nh.c_str(), "Continue"); request->Body << "&name_action_selected=save_device"; // Save device - or "dont_save" resp = sendRequest(request); } diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h index 2b98b5a393..5274d9d2b2 100644 --- a/protocols/FacebookRM/src/entities.h +++ b/protocols/FacebookRM/src/entities.h @@ -94,7 +94,12 @@ struct facebook_chatroom bool is_subscribed; bool read_only; - facebook_chatroom(std::string thread_id) : thread_id(thread_id) {} + facebook_chatroom(std::string thread_id) : thread_id(thread_id) { + this->can_reply = true; + this->is_archived = false; + this->is_subscribed = true; + this->read_only = false; + } }; struct facebook_message @@ -115,7 +120,8 @@ struct facebook_message facebook_message() { this->time = 0; - this->isUnread = this->isIncoming = true; + this->isUnread = true; + this->isIncoming = true; this->isChat = false; this->type = MESSAGE; this->flag_ = 0; @@ -138,6 +144,7 @@ struct facebook_notification this->time = 0; this->seen = false; this->hWndPopup = NULL; + this->icon = NULL; } void setIcon(const std::string &iconUrl) diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 19597bf2bd..bf1ed05a38 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -714,8 +714,10 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo auto participant = participants.find(from_id); if (participant == participants.end()) { // TODO: load name of this participant - participant->second.user_id = from_id; - proto->AddChatContact(tid.c_str(), participant->second, true); + chatroom_participant new_participant; + new_participant.user_id = from_id; + new_participant.nick = from_id; + proto->AddChatContact(tid.c_str(), new_participant, true); } participant = participants.find(from_id); |