diff options
author | George Hazan <george.hazan@gmail.com> | 2015-08-27 17:07:10 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-08-27 17:07:10 +0000 |
commit | 87fff9deac0941da4e87728f14c917700d5bbdec (patch) | |
tree | 99e0942bba2ab6b71390b5856a1cba3340ff73f4 /protocols/FacebookRM | |
parent | f12258520128cd7e4f758ba5840ffb4704cea7c8 (diff) |
name conflicts
git-svn-id: http://svn.miranda-ng.org/main/trunk@15046 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 62 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 21 |
2 files changed, 37 insertions, 46 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index ff11543ce7..3970cf44d8 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -401,7 +401,7 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, const JSO } } -int facebook_json_parser::parse_messages(std::string *data, std::vector< facebook_message* >* messages, std::map< std::string, facebook_notification* >* notifications, bool inboxOnly) +int facebook_json_parser::parse_messages(std::string *pData, std::vector< facebook_message* >* messages, std::map< std::string, facebook_notification* >* notifications, bool inboxOnly) { // remove old received messages from map for (std::map<std::string, int>::iterator it = proto->facy.messages_ignore.begin(); it != proto->facy.messages_ignore.end();) { @@ -414,9 +414,7 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo } } - std::string jsonData = data->substr(9); - - JSONNode root = JSONNode::parse(jsonData.c_str()); + JSONNode root = JSONNode::parse(pData->substr(9).c_str()); if (!root) return EXIT_FAILURE; @@ -433,12 +431,11 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo if (t == "messaging") { // various messaging stuff (received and sent messages, getting seen info) - const JSONNode &type = (*it)["event"]; - if (!type) + const JSONNode &ev = (*it)["event"]; + if (!ev) continue; - std::string t = type.as_string(); - if (t == "read_receipt") { + if (ev.as_string() == "read_receipt") { // user read message const JSONNode &reader_ = (*it)["reader"]; const JSONNode &time_ = (*it)["time"]; @@ -461,12 +458,12 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo std::string tid = threadid.as_string(); - std::map<std::string, facebook_chatroom*>::iterator it = proto->facy.chat_rooms.find(tid); - if (it != proto->facy.chat_rooms.end()) { - facebook_chatroom *chatroom = it->second; + auto itRoom = proto->facy.chat_rooms.find(tid); + if (itRoom != proto->facy.chat_rooms.end()) { + facebook_chatroom *chatroom = itRoom->second; std::map<std::string, std::string> participants = chatroom->participants; - std::map<std::string, std::string>::const_iterator participant = participants.find(readerId); + auto participant = participants.find(readerId); if (participant == participants.end()) { // TODO: load name of this participant std::string name = readerId; @@ -667,12 +664,12 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo std::string tid = thread_.as_string(); std::string from_id = from_.as_string(); - std::map<std::string, facebook_chatroom*>::iterator it = proto->facy.chat_rooms.find(thread_.as_string()); - if (it != proto->facy.chat_rooms.end()) { - facebook_chatroom *chatroom = it->second; + auto itRoom = proto->facy.chat_rooms.find(thread_.as_string()); + if (itRoom != proto->facy.chat_rooms.end()) { + facebook_chatroom *chatroom = itRoom->second; std::map<std::string, std::string> participants = chatroom->participants; - std::map<std::string, std::string>::const_iterator participant = participants.find(from_id); + auto participant = participants.find(from_id); if (participant == participants.end()) { // TODO: load name of this participant std::string name = from_id; @@ -692,9 +689,7 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact, (LPARAM)&st); } - else { - CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact); - } + else CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact); // TODO: support proper MS_PROTO_CONTACTISTYPING service for chatrooms (when it will be implemented) } @@ -708,8 +703,8 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo if (!event_type || !event_data) continue; - std::string t = event_type.as_string(); - if (t == "visibility_update") { + std::string et = event_type.as_string(); + if (et == "visibility_update") { // change of chat status const JSONNode &visibility = event_data["visibility"]; @@ -761,10 +756,10 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo continue; std::string thread_id = thread_id_.as_string(); - std::string type = log_type_.as_string(); + std::string logType = log_type_.as_string(); std::string message_text = log_body_.as_string(); - if (type == "log:video-call") { + if (logType == "log:video-call") { std::string id = action_["other_user_fbid"].as_string(); std::string message_id = action_["message_id"].as_string(); @@ -804,13 +799,13 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo for (auto itAlerts = alerts.begin(); itAlerts != alerts.end(); ++itAlerts) { std::string id = (*itAlerts).as_string(); - std::map<std::string, facebook_notification*>::iterator it = notifications->find(id); - if (it != notifications->end()) { - if (it->second->hWndPopup != NULL) - PUDeletePopup(it->second->hWndPopup); // close popup + auto itAlert = notifications->find(id); + if (itAlert != notifications->end()) { + if (itAlert->second->hWndPopup != NULL) + PUDeletePopup(itAlert->second->hWndPopup); // close popup - delete it->second; - notifications->erase(it); + delete itAlert->second; + notifications->erase(itAlert); } } } @@ -971,8 +966,7 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector< message->isIncoming = (author_id != proto->facy.self_.user_id); message->isUnread = isUnread; - std::map<std::string, facebook_chatroom*>::iterator iter = chatrooms->find(thread_id); - if (iter != chatrooms->end()) { + if (chatrooms->find(thread_id) != chatrooms->end()) { // this is chatroom message message->isChat = true; message->user_id = author_id; @@ -980,10 +974,10 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector< else { // this is standard message message->isChat = false; - std::map<std::string, std::string>::iterator iter = thread_ids.find(thread_id); - if (iter != thread_ids.end()) { + auto iter = thread_ids.find(thread_id); + if (iter != thread_ids.end()) message->user_id = iter->second; // TODO: Check if we have contact with this ID in friendlist and otherwise do something different? - } else { + else { delete message; continue; } diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index b3a700e230..97fd295899 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -331,12 +331,12 @@ void FacebookProto::ProcessUnreadMessages(void*) facy.handle_success("ProcessUnreadMessages"); } -void FacebookProto::ProcessUnreadMessage(void *data) +void FacebookProto::ProcessUnreadMessage(void *pParam) { - if (data == NULL) + if (pParam == NULL) return; - std::vector<std::string> *threads = (std::vector<std::string>*)data; + std::vector<std::string> *threads = (std::vector<std::string>*)pParam; if (isOffline()) { delete threads; @@ -440,21 +440,18 @@ void FacebookProto::ProcessUnreadMessage(void *data) delete threads; } -void FacebookProto::LoadLastMessages(void *p) +void FacebookProto::LoadLastMessages(void *pParam) { - if (p == NULL) + if (pParam == NULL) return; - if (isOffline()) { - delete (MCONTACT*)p; + MCONTACT hContact = *(MCONTACT*)pParam; + delete (MCONTACT*)pParam; + + if (isOffline()) return; - } facy.handle_entry("LoadLastMessages"); - - MCONTACT hContact = *(MCONTACT*)p; - delete (MCONTACT*)p; - if (!isOnline()) return; |