summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/FacebookRM/src/chat.cpp10
-rw-r--r--protocols/FacebookRM/src/client.h11
-rw-r--r--protocols/FacebookRM/src/communication.cpp31
-rw-r--r--protocols/FacebookRM/src/contacts.cpp21
-rw-r--r--protocols/FacebookRM/src/entities.h2
-rw-r--r--protocols/FacebookRM/src/json.cpp319
-rw-r--r--protocols/FacebookRM/src/list.hpp185
-rw-r--r--protocols/FacebookRM/src/messages.cpp4
-rw-r--r--protocols/FacebookRM/src/process.cpp19
-rw-r--r--protocols/FacebookRM/src/proto.cpp16
-rw-r--r--protocols/FacebookRM/src/stdafx.h1
11 files changed, 185 insertions, 434 deletions
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp
index 335b9e281a..7b5a0d7935 100644
--- a/protocols/FacebookRM/src/chat.cpp
+++ b/protocols/FacebookRM/src/chat.cpp
@@ -260,8 +260,8 @@ INT_PTR FacebookProto::OnJoinChat(WPARAM hContact, LPARAM)
AddChat(fbc->thread_id.c_str(), fbc->chat_name.c_str());
// Add chat contacts
- for (std::map<std::string, chatroom_participant>::iterator jt = fbc->participants.begin(); jt != fbc->participants.end(); ++jt)
- AddChatContact(fbc->thread_id.c_str(), jt->second, false);
+ for (auto &jt : fbc->participants)
+ AddChatContact(fbc->thread_id.c_str(), jt.second, false);
// Load last messages
delSetting(hContact, FACEBOOK_KEY_MESSAGE_ID); // We're creating new chatroom so we want load all recent messages
@@ -393,11 +393,11 @@ std::string FacebookProto::GenerateChatName(facebook_chatroom *fbc)
std::string name = "";
unsigned int namesUsed = 0;
- for (auto it = fbc->participants.begin(); it != fbc->participants.end(); ++it) {
- std::string participant = it->second.nick;
+ for (auto &it : fbc->participants) {
+ std::string participant = it.second.nick;
// Ignore self contact, empty and numeric only participant names
- if (it->second.role == ROLE_ME || participant.empty() || participant.find_first_not_of("0123456789") == std::string::npos)
+ if (it.second.role == ROLE_ME || participant.empty() || participant.find_first_not_of("0123456789") == std::string::npos)
continue;
if (namesUsed > 0)
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index c97a43be55..129a2ae8c1 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -92,14 +92,12 @@ public:
bool mbasicWorks;
////////////////////////////////////////////////////////////
-
// Client vs protocol communication
void client_notify(wchar_t* message);
void info_notify(wchar_t* message);
////////////////////////////////////////////////////////////
-
// Cookies, Data storage
HANDLE cookies_lock_;
@@ -165,7 +163,6 @@ public:
}
////////////////////////////////////////////////////////////
-
// Login handling
bool login(const char *username, const char *password);
@@ -175,7 +172,6 @@ public:
const std::string & get_username() const;
////////////////////////////////////////////////////////////
-
// Session handling
bool home();
@@ -183,15 +179,12 @@ public:
bool chat_state(bool online = true);
////////////////////////////////////////////////////////////
-
// Updates handling
- List::List<facebook_user> buddies;
HANDLE send_message_lock_;
HANDLE notifications_lock_;
////////////////////////////////////////////////////////////
-
// Messages handling
std::map<std::string, int> messages_ignore;
@@ -205,13 +198,11 @@ public:
int send_message(int seqid, MCONTACT, const std::string &message_text, std::string *error_text, const std::string &captchaPersistData = "", const std::string &captcha = "");
////////////////////////////////////////////////////////////
-
// Status handling
- bool post_status(status_data *data);
+ bool post_status(status_data *data);
////////////////////////////////////////////////////////////
-
// HTTP communication
http::response sendRequest(HttpRequest *request);
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 562f46b3a8..f07674b258 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -220,10 +220,10 @@ char* facebook_client::load_cookies()
std::string cookieString;
if (!cookies.empty())
- for (std::map< std::string, std::string >::iterator iter = cookies.begin(); iter != cookies.end(); ++iter) {
- cookieString.append(iter->first);
+ for (auto &iter : cookies) {
+ cookieString.append(iter.first);
cookieString.append(1, '=');
- cookieString.append(iter->second);
+ cookieString.append(iter.second);
cookieString.append(1, ';');
}
@@ -264,12 +264,11 @@ void facebook_client::clear_notifications()
{
ScopedLock s(notifications_lock_);
- for (auto it = notifications.begin(); it != notifications.end();) {
- if (it->second->hWndPopup != nullptr)
- PUDeletePopup(it->second->hWndPopup); // close popup
+ for (auto &it : notifications) {
+ if (it.second->hWndPopup != nullptr)
+ PUDeletePopup(it.second->hWndPopup); // close popup
- delete it->second;
- it = notifications.erase(it);
+ delete it.second;
}
notifications.clear();
@@ -277,10 +276,9 @@ void facebook_client::clear_notifications()
void facebook_client::clear_chatrooms()
{
- for (auto it = chat_rooms.begin(); it != chat_rooms.end();) {
- delete it->second;
- it = chat_rooms.erase(it);
- }
+ for (auto &it : chat_rooms)
+ delete it.second;
+
chat_rooms.clear();
}
@@ -289,12 +287,11 @@ void facebook_client::clear_chatrooms()
*/
void facebook_client::clear_readers()
{
- for (std::map<MCONTACT, time_t>::iterator it = readers.begin(); it != readers.end();) {
- if (parent->isChatRoom(it->first))
- parent->delSetting(it->first, FACEBOOK_KEY_MESSAGE_READERS);
+ for (auto &it : readers) {
+ if (parent->isChatRoom(it.first))
+ parent->delSetting(it.first, FACEBOOK_KEY_MESSAGE_READERS);
- parent->delSetting(it->first, FACEBOOK_KEY_MESSAGE_READ);
- it = readers.erase(it);
+ parent->delSetting(it.first, FACEBOOK_KEY_MESSAGE_READ);
}
readers.clear();
}
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index b66628b733..6352300348 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -222,9 +222,9 @@ void FacebookProto::LoadParticipantsNames(facebook_chatroom *fbc)
std::vector<std::string> namelessIds;
// TODO: We could load all names from server at once by skipping this for cycle and using namelessIds as all in participants list, but we would lost our local names of our contacts. But maybe that's not a problem?
- for (auto it = fbc->participants.begin(); it != fbc->participants.end(); ++it) {
- const char *id = it->first.c_str();
- chatroom_participant &user = it->second;
+ for (auto &it : fbc->participants) {
+ const char *id = it.first.c_str();
+ chatroom_participant &user = it.second;
if (!user.loaded) {
if (!mir_strcmp(id, facy.self_.user_id.c_str())) {
@@ -260,9 +260,8 @@ void FacebookProto::LoadParticipantsNames(facebook_chatroom *fbc)
// we have some contacts without name, let's load them all from the server
LIST<char> userIds(1);
- for (std::string::size_type i = 0; i < namelessIds.size(); i++) {
+ for (std::string::size_type i = 0; i < namelessIds.size(); i++)
userIds.insert(mir_strdup(namelessIds.at(i).c_str()));
- }
HttpRequest *request = new UserInfoRequest(&facy, userIds);
http::response resp = facy.sendRequest(request);
@@ -411,14 +410,8 @@ void FacebookProto::DeleteContactFromServer(void *data)
http::response resp = facy.sendRequest(request);
if (resp.data.find("\"payload\":null", 0) != std::string::npos) {
- // FIXME: Remember that we deleted this contact, so we won't accidentally add him at status change
- /* facebook_user* fbu = facy.buddies.find(id);
- if (fbu != nullptr)
- fbu->deleted = true; */
-
- MCONTACT hContact = ContactIDToHContact(id);
-
// If contact wasn't deleted from database
+ MCONTACT hContact = ContactIDToHContact(id);
if (hContact != 0) {
setWord(hContact, "Status", ID_STATUS_OFFLINE);
setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE);
@@ -427,9 +420,7 @@ void FacebookProto::DeleteContactFromServer(void *data)
NotifyEvent(m_tszUserName, TranslateT("Contact was removed from your server list."), 0, EVENT_FRIENDSHIP);
}
- else {
- facy.client_notify(TranslateT("Error occurred when removing contact from server."));
- }
+ else facy.client_notify(TranslateT("Error occurred when removing contact from server."));
if (resp.code != HTTP_CODE_OK)
facy.handle_error("DeleteContactFromServer");
diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h
index 3a88dc8acc..5b10bd53ee 100644
--- a/protocols/FacebookRM/src/entities.h
+++ b/protocols/FacebookRM/src/entities.h
@@ -147,7 +147,7 @@ struct facebook_notification
this->icon = nullptr;
}
- void setIcon(const std::string &iconUrl)
+ void setIcon(const std::string& /*iconUrl*/)
{
icon = nullptr;
}
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 586189784f..5ce92f5441 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -93,8 +93,8 @@ void FacebookProto::ParseMessageType(facebook_message &message, const JSONNode &
message.type = SUBSCRIBE;
const JSONNode &fbids_ = log_data_["added_participants"];
- for (auto it2 = fbids_.begin(); it2 != fbids_.end(); ++it2) {
- std::string id = (*it2).as_string().substr(5); // strip "fbid:" prefix
+ for (auto &it2 : fbids_) {
+ std::string id = it2.as_string().substr(5); // strip "fbid:" prefix
if (!message.data.empty())
message.data += ";";
message.data += id;
@@ -104,8 +104,8 @@ void FacebookProto::ParseMessageType(facebook_message &message, const JSONNode &
message.type = UNSUBSCRIBE;
const JSONNode &fbids_ = log_data_["removed_participants"];
- for (auto it2 = fbids_.begin(); it2 != fbids_.end(); ++it2) {
- std::string id = (*it2).as_string().substr(5); // strip "fbid:" prefix
+ for (auto &it2 : fbids_) {
+ std::string id = it2.as_string().substr(5); // strip "fbid:" prefix
if (!message.data.empty())
message.data += ";";
message.data += id;
@@ -135,10 +135,10 @@ int FacebookProto::ParseChatParticipants(std::string *data, std::map<std::string
if (!profiles)
return EXIT_FAILURE;
- for (auto it = profiles.begin(); it != profiles.end(); ++it) {
- std::string userId = (*it).name();
- std::string userName = (*it)["name"].as_string();
- std::string type = (*it)["type"].as_string();
+ for (auto &it : profiles) {
+ std::string userId = it.name();
+ std::string userName = it["name"].as_string();
+ std::string type = it["type"].as_string();
if (userId.empty() || userName.empty())
continue;
@@ -177,9 +177,9 @@ int FacebookProto::ParseFriends(std::string *data, std::map< std::string, facebo
if (!payload)
return EXIT_FAILURE;
- for (auto it = payload.begin(); it != payload.end(); ++it) {
+ for (auto &it : payload) {
facebook_user *fbu = new facebook_user();
- parseUser(*it, fbu);
+ parseUser(it, fbu);
// Facebook now sends also other types of contacts, which we do not want here
if (!loadAllContacts && fbu->type != CONTACT_FRIEND) {
@@ -193,7 +193,6 @@ int FacebookProto::ParseFriends(std::string *data, std::map< std::string, facebo
return EXIT_SUCCESS;
}
-
int FacebookProto::ParseNotifications(std::string *data, std::map< std::string, facebook_notification* > *notifications)
{
std::string jsonData = data->substr(9);
@@ -209,13 +208,13 @@ int FacebookProto::ParseNotifications(std::string *data, std::map< std::string,
// Create notifications chatroom (if it doesn't exists), because we will be writing to it new notifications here
PrepareNotificationsChatRoom();
- for (auto it = list.begin(); it != list.end(); ++it) {
- const JSONNode &id_ = (*it)["alert_id"];
- const JSONNode &state_ = (*it)["seen_state"];
- const JSONNode &time_ = (*it)["timestamp"]["time"];
- const JSONNode &text_ = (*it)["title"]["text"];
- const JSONNode &url_ = (*it)["url"];
- const JSONNode &icon_ = (*it)["icon"]["uri"];
+ for (auto &it : list) {
+ const JSONNode &id_ = it["alert_id"];
+ const JSONNode &state_ = it["seen_state"];
+ const JSONNode &time_ = it["timestamp"]["time"];
+ const JSONNode &text_ = it["title"]["text"];
+ const JSONNode &url_ = it["url"];
+ const JSONNode &icon_ = it["icon"]["uri"];
// Ignore empty and old notifications
if (!text_ || !state_ || state_.as_string() == "SEEN_AND_READ" || !time_)
@@ -281,9 +280,8 @@ void FacebookProto::ParseAttachments(std::string &message_text, const JSONNode &
if (!attachments_ || attachments_.empty())
return;
- for (auto itAttachment = attachments_.begin(); itAttachment != attachments_.end(); ++itAttachment) {
- const JSONNode &attach_ = legacy ? (*itAttachment) : (*itAttachment)["mercury"];
-
+ for (auto &itAttachment : attachments_) {
+ const JSONNode &attach_ = legacy ? itAttachment : itAttachment["mercury"];
if (const JSONNode sticker_ = attach_["sticker_attachment"]) {
newText = TranslateT("a sticker");
attachments_text += "\n";
@@ -433,10 +431,9 @@ bool FacebookProto::ProcessSpecialMessage(std::vector<facebook_message>* message
int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_message>* messages, std::map< std::string, facebook_notification* >* notifications)
{
// remove old received messages from map
- for (std::map<std::string, int>::iterator it = facy.messages_ignore.begin(); it != facy.messages_ignore.end();) {
- if (it->second > FACEBOOK_IGNORE_COUNTER_LIMIT) {
+ for (auto it = facy.messages_ignore.begin(); it != facy.messages_ignore.end();) {
+ if (it->second > FACEBOOK_IGNORE_COUNTER_LIMIT)
it = facy.messages_ignore.erase(it);
- }
else {
it->second++; // increase counter on each request
++it;
@@ -451,8 +448,8 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
if (!ms)
return EXIT_FAILURE;
- for (auto it = ms.begin(); it != ms.end(); ++it) {
- const JSONNode &type = (*it)["type"];
+ for (auto &it : ms) {
+ const JSONNode &type = it["type"];
if (!type)
continue;
@@ -460,7 +457,7 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
if (t == "delta") {
// new messaging stuff
- const JSONNode &delta_ = (*it)["delta"];
+ const JSONNode &delta_ = it["delta"];
if (!delta_)
continue;
@@ -631,11 +628,8 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
std::string data = "";
const JSONNode &addedParticipants_ = delta_["addedParticipants"]; // array of added participants
- for (auto it2 = addedParticipants_.begin(); it2 != addedParticipants_.end(); ++it2) {
- //const JSONNode &firstName_ = (*it2)["firstName"];
- //const JSONNode &fullName_ = (*it2)["fullName"];
- //const JSONNode &isMessengerUser_ = (*it2)["isMessengerUser"]; // boolean
- const JSONNode &userFbId_ = (*it2)["userFbId"]; // userid
+ for (auto &it2 : addedParticipants_) {
+ const JSONNode &userFbId_ = it2["userFbId"]; // userid
// TODO: Take advantage of given fullName so we don't need to load it manually afterwards
if (userFbId_) {
@@ -654,22 +648,22 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
}
else if (t == "notification_json") {
// event notification
- const JSONNode &nodes = (*it)["nodes"];
+ const JSONNode &nodes = it["nodes"];
// Create notifications chatroom (if it doesn't exists), because we will be writing to it new notifications here
PrepareNotificationsChatRoom();
- for (auto itNodes = nodes.begin(); itNodes != nodes.end(); ++itNodes) {
- const JSONNode &text_ = (*itNodes)["unaggregatedTitle"]; // notifications one by one, not grouped
+ for (auto &itNodes : nodes) {
+ const JSONNode &text_ = itNodes["unaggregatedTitle"]; // notifications one by one, not grouped
if (!text_)
continue;
const JSONNode &text = text_["text"];
- const JSONNode &url = (*itNodes)["url"];
- const JSONNode &alert_id = (*itNodes)["alert_id"];
- const JSONNode &icon_ = (*itNodes)["icon"]["uri"];
+ const JSONNode &url = itNodes["url"];
+ const JSONNode &alert_id = itNodes["alert_id"];
+ const JSONNode &icon_ = itNodes["icon"]["uri"];
- const JSONNode &time_ = (*itNodes)["timestamp"];
+ const JSONNode &time_ = itNodes["timestamp"];
if (!time_)
continue;
const JSONNode &time = time_["time"];
@@ -705,7 +699,7 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
}
}
else if (t == "m_notification") {
- const JSONNode &data = (*it)["data"];
+ const JSONNode &data = it["data"];
if (!data)
continue;
@@ -752,11 +746,11 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
}
else if (t == "typ") { // revised 5.3.2017
// chat typing notification
- const JSONNode &from_ = (*it)["from"]; // user fbid
- const JSONNode &to_ = (*it)["to"]; // user fbid (should be our own, but could be from our page too)
- //const JSONNode &realtime_viewer_fbid_ = (*it)["realtime_viewer_fbid"]; // our user fbid
- //const JSONNode &from_mobile_ = (*it)["from_mobile"]; // boolean // TODO: perhaps we should update user client based on this?
- const JSONNode &st_ = (*it)["st"]; // typing status - 1 = started typing, 0 = stopped typing
+ const JSONNode &from_ = it["from"]; // user fbid
+ const JSONNode &to_ = it["to"]; // user fbid (should be our own, but could be from our page too)
+ //const JSONNode &realtime_viewer_fbid_ = it["realtime_viewer_fbid"]; // our user fbid
+ //const JSONNode &from_mobile_ = it["from_mobile"]; // boolean // TODO: perhaps we should update user client based on this?
+ const JSONNode &st_ = it["st"]; // typing status - 1 = started typing, 0 = stopped typing
// Ignore wrong (without "from") typing notifications or that are not meant for us (but e.g. for our page)
if (!from_ || to_.as_string() != facy.self_.user_id)
@@ -777,9 +771,9 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
if (!m_enableChat)
continue;
- const JSONNode &from_ = (*it)["from"];
- const JSONNode &thread_ = (*it)["thread"];
- const JSONNode &st_ = (*it)["st"];
+ const JSONNode &from_ = it["from"];
+ const JSONNode &thread_ = it["thread"];
+ const JSONNode &st_ = it["st"];
if (!from_ || !thread_ || !st_)
continue;
@@ -817,8 +811,8 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
else if (t == "privacy_changed") {
// settings changed
- const JSONNode &event_type = (*it)["event"];
- const JSONNode &event_data = (*it)["data"];
+ const JSONNode &event_type = it["event"];
+ const JSONNode &event_data = it["data"];
if (!event_type || !event_data)
continue;
@@ -836,25 +830,23 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
}
}
else if (t == "chatproxy-presence") {
- const JSONNode &buddyList = (*it)["buddyList"];
+ const JSONNode &buddyList = it["buddyList"];
if (!buddyList)
continue;
time_t offlineThreshold = time(nullptr) - 15 * 60; // contacts last active more than 15 minutes will be marked offline
- for (auto itNodes = buddyList.begin(); itNodes != buddyList.end(); ++itNodes) {
- std::string id = (*itNodes).name();
-
+ for (auto &itNodes : buddyList) {
// Facebook now sends info also about some nonfriends, so we just ignore status change of contacts we don't have in list
- MCONTACT hContact = ContactIDToHContact(id);
+ MCONTACT hContact = ContactIDToHContact(itNodes.name());
if (!hContact)
continue;
// TODO: Check for friends existence/inexistence? Here we should get all friends (but we're already doing friendslist request, so we should have fresh data already)
- const JSONNode &p_ = (*itNodes)["p"]; // possible values: 0, 2 (something more?) (might not be present)
- const JSONNode &lat_ = (*itNodes)["lat"]; // timestamp of last activity (could be 0) (is always present)
- const JSONNode &vc_ = (*itNodes)["vc"]; // possible values: 0, 8, 10 (something more?) (might not be present)
+ const JSONNode &p_ = itNodes["p"]; // possible values: 0, 2 (something more?) (might not be present)
+ const JSONNode &lat_ = itNodes["lat"]; // timestamp of last activity (could be 0) (is always present)
+ const JSONNode &vc_ = itNodes["vc"]; // possible values: 0, 8, 10 (something more?) (might not be present)
int status = ID_STATUS_DND; // DND to easily spot some problem, as we expect it will always be p==0 or p==2 below
@@ -900,16 +892,14 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
else if (t == "buddylist_overlay") {
// TODO: This is now supported also via /ajax/mercury/tabs_presence.php request (probably)
// additional info about user status (status, used client)
- const JSONNode &overlay_ = (*it)["overlay"];
+ const JSONNode &overlay_ = it["overlay"];
if (!overlay_)
continue;
time_t offlineThreshold = time(nullptr) - 15 * 60; // contacts last active more than 15 minutes will be marked offline
- for (auto itNodes = overlay_.begin(); itNodes != overlay_.end(); ++itNodes) {
- std::string id = (*itNodes).name();
-
- MCONTACT hContact = ContactIDToHContact(id);
+ for (auto &itNodes : overlay_) {
+ MCONTACT hContact = ContactIDToHContact(itNodes.name());
if (!hContact) {
// Facebook now sends info also about some nonfriends, so we just ignore status change of contacts we don't have in list
continue;
@@ -920,14 +910,14 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
setWString(fbu->handle, "MirVer", fbu->getMirVer());
*/
- const JSONNode &a_ = (*itNodes)["a"]; // possible values: 0, 2 (something more?)
- const JSONNode &la_ = (*itNodes)["la"]; // timestamp of last activity (could be 0)
- const JSONNode &s_ = (*itNodes)["s"]; // possible values: push (something more?)
- const JSONNode &vc_ = (*itNodes)["vc"]; // possible values: 0, 8, 10 (something more?)
+ const JSONNode &a_ = itNodes["a"]; // possible values: 0, 2 (something more?)
+ const JSONNode &la_ = itNodes["la"]; // timestamp of last activity (could be 0)
+ const JSONNode &s_ = itNodes["s"]; // possible values: push (something more?)
+ const JSONNode &vc_ = itNodes["vc"]; // possible values: 0, 8, 10 (something more?)
// Friller account has also these:
- // const JSONNode &ol_ = (*itNodes)["ol"]; // possible values: -1 (when goes to offline), 0 (when goes back online) (something more?)
- // const JSONNode &p_ = (*itNodes)["p"]; // class with fbAppStatus, messengerStatus, otherStatus, status, webStatus
+ // const JSONNode &ol_ = itNodes["ol"]; // possible values: -1 (when goes to offline), 0 (when goes back online) (something more?)
+ // const JSONNode &p_ = itNodes["p"]; // class with fbAppStatus, messengerStatus, otherStatus, status, webStatus
int status = ID_STATUS_FREECHAT; // FREECHAT to easily spot some problem, as we expect it will always be p==0 or p==2 below
@@ -946,27 +936,11 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
if (la_ /*&& status != ID_STATUS_ONLINE*/) {
time_t last_active = utils::time::from_string(la_.as_string());
- // we should set IdleTS only when contact is IDLE, or OFFLINE
- //if (getDword(hContact, "IdleTS", 0) != last_active) {
- // if (/*(fbu->idle || status == ID_STATUS_OFFLINE) &&*/ last_active > 0)
- // setDword(hContact, "IdleTS", last_active);
- // else
- // delSetting(hContact, "IdleTS");
- //}
-
- /*if (last_active > 0)
- setDword(hContact, "LastActiveTS", last_active);
- else
- delSetting(hContact, "LastActiveTS");
- */
-
// Set users inactive for too long as offline
if (last_active > 0 && last_active < offlineThreshold)
status = ID_STATUS_OFFLINE;
}
- else {
- delSetting(hContact, "IdleTS");
- }
+ else delSetting(hContact, "IdleTS");
setWord(hContact, "Status", status);
@@ -1000,8 +974,8 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
if (!getByte(FACEBOOK_KEY_EVENT_TICKER_ENABLE, DEFAULT_EVENT_TICKER_ENABLE))
continue;
- const JSONNode &actor_ = (*it)["actor"];
- const JSONNode &story_ = (*it)["story_xhp"];
+ const JSONNode &actor_ = it["actor"];
+ const JSONNode &story_ = it["story_xhp"];
std::string text = story_.as_string();
text = utils::text::html_entities_decode(utils::text::slashu_to_utf8(text));
@@ -1024,12 +998,9 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
else if (t == "notifications_read" || t == "notifications_seen") { // revised 5.3.2017
ScopedLock s(facy.notifications_lock_);
- const JSONNode &alerts = (*it)["alert_ids"];
-
- for (auto itAlerts = alerts.begin(); itAlerts != alerts.end(); ++itAlerts) {
- std::string id = (*itAlerts).as_string();
-
- auto itAlert = notifications->find(id);
+ const JSONNode &alerts = it["alert_ids"];
+ for (auto &itAlerts : alerts) {
+ auto itAlert = notifications->find(itAlerts.as_string());
if (itAlert != notifications->end()) {
if (itAlert->second->hWndPopup != nullptr)
PUDeletePopup(itAlert->second->hWndPopup); // close popup
@@ -1041,35 +1012,35 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag
}
/*else if (t == "mobile_requests_count") { // revised 5.3.2017
// Notifies about remaining friendship requests (happens e.g. after approving friendship)
- const JSONNode &num_friend_confirmed_unseen_ = (*it)["num_friend_confirmed_unseen"]; // number, e.g. "0"
- const JSONNode &num_unread_ = (*it)["num_unread"]; // number, e.g. "0"
- const JSONNode &num_unseen_ = (*it)["num_unseen"]; // number, e.g. "0"
- const JSONNode &realtime_viewer_fbid_ = (*it)["realtime_viewer_fbid"]; // our user fbid
+ const JSONNode &num_friend_confirmed_unseen_ = it["num_friend_confirmed_unseen"]; // number, e.g. "0"
+ const JSONNode &num_unread_ = it["num_unread"]; // number, e.g. "0"
+ const JSONNode &num_unseen_ = it["num_unseen"]; // number, e.g. "0"
+ const JSONNode &realtime_viewer_fbid_ = it["realtime_viewer_fbid"]; // our user fbid
}
else if (t == "friending_state_change") { // revised 5.3.2017
- const JSONNode &userid_ = (*it)["userid"]; // fbid of user this event is about
- const JSONNode &realtime_viewer_fbid_ = (*it)["realtime_viewer_fbid"]; // our user fbid
- const JSONNode &action_ = (*it)["action"]; // "confirm" = when we approved friendship
+ const JSONNode &userid_ = it["userid"]; // fbid of user this event is about
+ const JSONNode &realtime_viewer_fbid_ = it["realtime_viewer_fbid"]; // our user fbid
+ const JSONNode &action_ = it["action"]; // "confirm" = when we approved friendship
if (action_.as_string() == "confirm") {
// ...
}
}
else if (t == "inbox") { // revised 5.3.2017
- const JSONNode &realtime_viewer_fbid_ = (*it)["realtime_viewer_fbid"]; // our user fbid
- const JSONNode &recent_unread_ = (*it)["recent_unread"]; // number
- const JSONNode &seen_timestamp_ = (*it)["seen_timestamp"]; // number
- const JSONNode &unread_ = (*it)["unread"]; // number
- const JSONNode &unseen_ = (*it)["unseen"]; // number
+ const JSONNode &realtime_viewer_fbid_ = it["realtime_viewer_fbid"]; // our user fbid
+ const JSONNode &recent_unread_ = it["recent_unread"]; // number
+ const JSONNode &seen_timestamp_ = it["seen_timestamp"]; // number
+ const JSONNode &unread_ = it["unread"]; // number
+ const JSONNode &unseen_ = it["unseen"]; // number
}
else if (t == "webrtc") { // revised 5.3.2017
- const JSONNode &realtime_viewer_fbid_ = (*it)["realtime_viewer_fbid"]; // our user fbid
- const JSONNode &source_ = (*it)["source"]; // e.g. "www"
- const JSONNode &msg_type_ = (*it)["msg_type"]; // e.g. "hang_up", "other_dismiss", "ice_candidate", "offer", "offer_ack", ...?
- const JSONNode &id_ = (*it)["id"]; // some numeric id
- const JSONNode &call_id_ = (*it)["call_id"]; // some numeric id
- const JSONNode &from_ = (*it)["from"]; // user fbid that started this event
- const JSONNode &payload_ = (*it)["payload"]; // string with some metadata (usually same as above)
+ const JSONNode &realtime_viewer_fbid_ = it["realtime_viewer_fbid"]; // our user fbid
+ const JSONNode &source_ = it["source"]; // e.g. "www"
+ const JSONNode &msg_type_ = it["msg_type"]; // e.g. "hang_up", "other_dismiss", "ice_candidate", "offer", "offer_ack", ...?
+ const JSONNode &id_ = it["id"]; // some numeric id
+ const JSONNode &call_id_ = it["call_id"]; // some numeric id
+ const JSONNode &from_ = it["from"]; // user fbid that started this event
+ const JSONNode &payload_ = it["payload"]; // string with some metadata (usually same as above)
}*/
else
continue;
@@ -1090,16 +1061,16 @@ int FacebookProto::ParseUnreadThreads(std::string *data, std::vector< std::strin
if (!unread_threads)
return EXIT_FAILURE;
- for (auto it = unread_threads.begin(); it != unread_threads.end(); ++it) {
+ for (auto &it : unread_threads) {
// For multi user chats
- const JSONNode &thread_fbids = (*it)["thread_fbids"];
- for (auto jt = thread_fbids.begin(); jt != thread_fbids.end(); ++jt)
- threads->push_back((*jt).as_string());
+ const JSONNode &thread_fbids = it["thread_fbids"];
+ for (auto &jt : thread_fbids)
+ threads->push_back(jt.as_string());
// For classic conversations
- const JSONNode &other_user_fbids = (*it)["other_user_fbids"];
- for (auto jt = other_user_fbids.begin(); jt != other_user_fbids.end(); ++jt)
- threads->push_back((*jt).as_string());
+ const JSONNode &other_user_fbids = it["other_user_fbids"];
+ for (auto &jt : other_user_fbids)
+ threads->push_back(jt.as_string());
}
return EXIT_SUCCESS;
@@ -1122,21 +1093,21 @@ int FacebookProto::ParseThreadMessages(std::string *data, std::vector< facebook_
if (!actions || !threads)
return EXIT_FAILURE;
- for (auto it = actions.begin(); it != actions.end(); ++it) {
- const JSONNode &author_ = (*it)["author"];
- const JSONNode &other_user_fbid_ = (*it)["other_user_fbid"];
- const JSONNode &body_ = (*it)["body"];
- const JSONNode &thread_id_ = (*it)["thread_id"];
- const JSONNode &thread_fbid_ = (*it)["thread_fbid"];
- const JSONNode &mid_ = (*it)["message_id"];
- const JSONNode &timestamp_ = (*it)["timestamp"];
- const JSONNode &filtered_ = (*it)["is_filtered_content"];
- const JSONNode &is_unread_ = (*it)["is_unread"];
+ for (auto &it : actions) {
+ const JSONNode &author_ = it["author"];
+ const JSONNode &other_user_fbid_ = it["other_user_fbid"];
+ const JSONNode &body_ = it["body"];
+ const JSONNode &thread_id_ = it["thread_id"];
+ const JSONNode &thread_fbid_ = it["thread_fbid"];
+ const JSONNode &mid_ = it["message_id"];
+ const JSONNode &timestamp_ = it["timestamp"];
+ const JSONNode &filtered_ = it["is_filtered_content"];
+ const JSONNode &is_unread_ = it["is_unread"];
// Either there is "body" (for classic messages), or "log_message_type" and "log_message_body" (for log messages)
- const JSONNode &log_type_ = (*it)["log_message_type"];
- const JSONNode &log_body_ = (*it)["log_message_body"];
- const JSONNode &log_data_ = (*it)["log_message_data"]; // additional data for this log message
+ const JSONNode &log_type_ = it["log_message_type"];
+ const JSONNode &log_body_ = it["log_message_body"];
+ const JSONNode &log_data_ = it["log_message_data"]; // additional data for this log message
if (!author_ || (!body_ && !log_body_) || !mid_ || (!thread_fbid_ && !thread_id_) || !timestamp_) {
debugLogA("ParseThreadMessages: ignoring message (%s) - missing attribute", mid_.as_string().c_str());
@@ -1154,7 +1125,7 @@ int FacebookProto::ParseThreadMessages(std::string *data, std::vector< facebook_
author_id = author_id.substr(pos + 1);
// Process attachements and stickers
- ParseAttachments(message_text, *it, other_user_fbid, true);
+ ParseAttachments(message_text, it, other_user_fbid, true);
if (filtered_.as_bool() && message_text.empty())
message_text = Translate("This message is no longer available, because it was marked as abusive or spam.");
@@ -1214,20 +1185,20 @@ int FacebookProto::ParseHistory(std::string *data, std::vector< facebook_message
bool first = true;
- for (auto it = actions.begin(); it != actions.end(); ++it) {
- const JSONNode &author = (*it)["author"];
- const JSONNode &other_user_fbid = (*it)["other_user_fbid"];
- const JSONNode &body = (*it)["body"];
- const JSONNode &tid = (*it)["thread_id"];
- const JSONNode &mid = (*it)["message_id"];
- const JSONNode &timestamp = (*it)["timestamp"];
- const JSONNode &filtered = (*it)["is_filtered_content"];
- const JSONNode &is_unread = (*it)["is_unread"];
+ for (auto &it : actions) {
+ const JSONNode &author = it["author"];
+ const JSONNode &other_user_fbid = it["other_user_fbid"];
+ const JSONNode &body = it["body"];
+ const JSONNode &tid = it["thread_id"];
+ const JSONNode &mid = it["message_id"];
+ const JSONNode &timestamp = it["timestamp"];
+ const JSONNode &filtered = it["is_filtered_content"];
+ const JSONNode &is_unread = it["is_unread"];
// Either there is "body" (for classic messages), or "log_message_type" and "log_message_body" (for log messages)
- const JSONNode &log_type_ = (*it)["log_message_type"];
- const JSONNode &log_body_ = (*it)["log_message_body"];
- const JSONNode &log_data_ = (*it)["log_message_data"];
+ const JSONNode &log_type_ = it["log_message_type"];
+ const JSONNode &log_body_ = it["log_message_body"];
+ const JSONNode &log_data_ = it["log_message_data"];
if (!author || (!body && !log_body_) || !mid || !tid || !timestamp) {
debugLogA("ParseHistory: ignoring message (%s) - missing attribute", mid.as_string().c_str());
@@ -1249,7 +1220,7 @@ int FacebookProto::ParseHistory(std::string *data, std::vector< facebook_message
author_id = author_id.substr(pos + 1);
// Process attachements and stickers
- ParseAttachments(message_text, *it, other_user_id, true);
+ ParseAttachments(message_text, it, other_user_id, true);
if (filtered.as_bool() && message_text.empty())
message_text = Translate("This message is no longer available, because it was marked as abusive or spam.");
@@ -1291,10 +1262,10 @@ int FacebookProto::ParseThreadInfo(std::string *data, std::string* user_id)
return EXIT_FAILURE;
//std::map<std::string, std::string> thread_ids;
- for (auto it = threads.begin(); it != threads.end(); ++it) {
- const JSONNode &canonical = (*it)["canonical_fbid"];
- const JSONNode &thread_id = (*it)["thread_id"];
- //const JSONNode &message_count = (*it)["message_count"); // TODO: this could be useful for loading history from server
+ for (auto &it : threads) {
+ const JSONNode &canonical = it["canonical_fbid"];
+ const JSONNode &thread_id = it["thread_id"];
+ //const JSONNode &message_count = it["message_count"); // TODO: this could be useful for loading history from server
if (!canonical || !thread_id)
continue;
@@ -1322,12 +1293,12 @@ int FacebookProto::ParseUserInfo(std::string *data, facebook_user* fbu)
return EXIT_FAILURE;
//std::map<std::string, std::string> user_ids;
- for (auto it = profiles.begin(); it != profiles.end(); ++it) {
+ for (auto &it : profiles) {
// TODO: allow more users to parse at once
- std::string id = (*it).name();
+ std::string id = it.name();
if (fbu->user_id == id) {
- parseUser(*it, fbu);
+ parseUser(it, fbu);
break;
}
}
@@ -1347,12 +1318,12 @@ int FacebookProto::ParseChatInfo(std::string *data, facebook_chatroom* fbc)
if (!threads)
return EXIT_FAILURE;
- for (auto it = threads.begin(); it != threads.end(); ++it) {
- const JSONNode &is_canonical_user_ = (*it)["is_canonical_user"];
- const JSONNode &thread_fbid_ = (*it)["thread_fbid"];
- const JSONNode &name_ = (*it)["name"];
- //const JSONNode &message_count_ = (*it)["message_count");
- //const JSONNode &unread_count_ = (*it)["unread_count"); // TODO: use it to check against number of loaded messages... but how?
+ for (auto &it : threads) {
+ const JSONNode &is_canonical_user_ = it["is_canonical_user"];
+ const JSONNode &thread_fbid_ = it["thread_fbid"];
+ const JSONNode &name_ = it["name"];
+ //const JSONNode &message_count_ = it["message_count");
+ //const JSONNode &unread_count_ = it["unread_count"); // TODO: use it to check against number of loaded messages... but how?
if (!thread_fbid_ || !is_canonical_user_ || is_canonical_user_.as_bool())
continue;
@@ -1366,27 +1337,27 @@ int FacebookProto::ParseChatInfo(std::string *data, facebook_chatroom* fbc)
chatroom_participant user;
user.is_former = true;
- const JSONNode &former_participants = (*it)["former_participants"];
- for (auto jt = former_participants.begin(); jt != former_participants.end(); ++jt) {
- user.role = (*jt)["is_friend"].as_bool() ? ROLE_FRIEND : ROLE_NONE;
- user.user_id = (*jt)["id"].as_string().substr(5); // strip "fbid:" prefix
+ const JSONNode &former_participants = it["former_participants"];
+ for (auto &jt : former_participants) {
+ user.role = jt["is_friend"].as_bool() ? ROLE_FRIEND : ROLE_NONE;
+ user.user_id = jt["id"].as_string().substr(5); // strip "fbid:" prefix
fbc->participants.insert(std::make_pair(user.user_id, user));
}
user.is_former = false;
user.role = ROLE_NONE;
- const JSONNode &participants = (*it)["participants"];
- for (auto jt = participants.begin(); jt != participants.end(); ++jt) {
- user.user_id = (*jt).as_string().substr(5); // strip "fbid:" prefix
+ const JSONNode &participants = it["participants"];
+ for (auto &jt : participants) {
+ user.user_id = jt.as_string().substr(5); // strip "fbid:" prefix
fbc->participants.insert(std::make_pair(user.user_id, user));
}
// TODO: don't automatically join unsubscribed or archived chatrooms
- fbc->can_reply = (*it)["can_reply"].as_bool();
- fbc->is_archived = (*it)["is_archived"].as_bool();
- fbc->is_subscribed = (*it)["is_subscribed"].as_bool();
- fbc->read_only = (*it)["read_only"].as_bool();
+ fbc->can_reply = it["can_reply"].as_bool();
+ fbc->is_archived = it["is_archived"].as_bool();
+ fbc->is_subscribed = it["is_subscribed"].as_bool();
+ fbc->read_only = it["read_only"].as_bool();
fbc->chat_name = std::wstring(ptrW(mir_utf8decodeW(name_.as_string().c_str())));
}
@@ -1405,9 +1376,9 @@ int FacebookProto::ParseMessagesCount(std::string *data, int *messagesCount, int
if (!threads)
return EXIT_FAILURE;
- for (auto it = threads.begin(); it != threads.end(); ++it) {
- const JSONNode &message_count_ = (*it)["message_count"];
- const JSONNode &unread_count_ = (*it)["unread_count"];
+ for (auto &it : threads) {
+ const JSONNode &message_count_ = it["message_count"];
+ const JSONNode &unread_count_ = it["unread_count"];
if (!message_count_ || !unread_count_)
return EXIT_FAILURE;
diff --git a/protocols/FacebookRM/src/list.hpp b/protocols/FacebookRM/src/list.hpp
deleted file mode 100644
index 7e3038fd20..0000000000
--- a/protocols/FacebookRM/src/list.hpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
-
-Facebook plugin for Miranda Instant Messenger
-_____________________________________________
-
-Copyright © 2009-11 Michal Zelinka, 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/>.
-
-*/
-
-#pragma once
-
-namespace List
-{
- template< typename T > class Item
- {
- public:
- std::string key;
- T* data;
- Item< T >* prev;
- Item< T >* next;
-
- Item()
- {
- this->data = nullptr;
- this->prev = nullptr;
- this->next = nullptr;
- }
-
- ~Item()
- {
- delete this->data;
- }
- };
-
- template< typename T > class List
- {
- private:
- Item< T >* first;
- Item< T >* last;
- unsigned int count;
-
- public:
- List()
- {
- this->first = this->last = nullptr;
- this->count = 0;
- }
-
- ~List()
- {
- this->clear();
- }
-
- Item< T >* begin()
- {
- return first;
- }
-
- Item< T >* end()
- {
- return last;
- }
-
- unsigned int size()
- {
- return count;
- }
-
- bool empty()
- {
- return (this->first == nullptr);
- }
-
- void insert(Item< T >* item)
- {
- if (this->empty()) {
- this->first = this->last = item;
- this->count = 1;
- }
- else { // TODO: key sorting/comparation
- item->next = this->first;
- this->first->prev = item;
- this->first = item;
- this->count++;
- }
- }
-
- void insert(std::pair< std::string, T* > item)
- {
- Item<T>* ins = new Item<T>;
- ins->key = item.first;
- ins->data = item.second;
- this->insert(ins);
- }
- void erase(std::string key)
- {
- Item< T >* help = this->first;
- while (help != nullptr) {
- if (help->key.compare(key) != 0)
- help = help->next;
- else {
- if (help == this->first) {
- this->first = help->next;
- if (this->first != nullptr)
- this->first->prev = nullptr;
- else
- this->last = nullptr;
- }
- else if (help == this->last) {
- this->last = help->prev;
- if (this->last != nullptr)
- this->last->next = nullptr;
- else
- this->first = nullptr;
- }
- else {
- help->prev->next = help->next;
- help->next->prev = help->prev;
- }
- this->count--;
- delete help;
- break;
- }
- }
- }
-
- void erase(Item< T >* item)
- {
- if (item != nullptr)
- erase(item->key);
- }
-
- T* find(std::string key)
- {
- Item< T >* help = this->begin();
- while (help != nullptr) {
- if (help->key.compare(key) != 0)
- help = help->next;
- else
- return help->data;
- }
- return nullptr;
- }
-
- T* at(const unsigned int item)
- {
- if (item >= this->count)
- return nullptr;
- Item< T >* help = this->begin();
- for (unsigned int i = 0; i < item; i++)
- help = help->next;
- return help->item;
- }
-
- T* operator[](const unsigned int item)
- {
- return at(item);
- }
-
- void clear()
- {
- Item< T >* help;
- while (this->first != nullptr) {
- help = this->first;
- this->first = this->first->next;
- delete help;
- }
- this->last = nullptr;
- this->count = 0;
- }
- };
-};
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp
index 4bf30fc915..e634473c6d 100644
--- a/protocols/FacebookRM/src/messages.cpp
+++ b/protocols/FacebookRM/src/messages.cpp
@@ -168,9 +168,7 @@ void FacebookProto::ReadMessageWorker(void *p)
}
LIST<char> ids(1);
- for (std::set<MCONTACT>::iterator it = hContacts->begin(); it != hContacts->end(); ++it) {
- MCONTACT hContact = *it;
-
+ for (auto &hContact : *hContacts) {
if (getBool(hContact, FACEBOOK_KEY_KEEP_UNREAD, 0))
continue;
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index fc8f1ea67e..cfbcdeec99 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -157,12 +157,11 @@ void FacebookProto::ProcessFriendList(void*)
}
// Check remaining contacts in map and add them to contact list
- for (std::map< std::string, facebook_user* >::iterator it = friends.begin(); it != friends.end();) {
- if (!it->second->deleted)
- AddToContactList(it->second, true); // we know this contact doesn't exists, so we force add it
+ for (auto &it : friends) {
+ if (!it.second->deleted)
+ AddToContactList(it.second, true); // we know this contact doesn't exists, so we force add it
- delete it->second;
- it = friends.erase(it);
+ delete it.second;
}
friends.clear();
@@ -714,7 +713,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message> &messages, boo
}
// 2. remove all marked messages from list
- for (std::vector<facebook_message>::iterator it = messages.begin(); it != messages.end();) {
+ for (auto it = messages.begin(); it != messages.end();) {
if ((*it).flag_ == 1)
it = messages.erase(it);
else
@@ -760,8 +759,8 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message> &messages, boo
// Set thread id (TID) for later
setString(hChatContact, FACEBOOK_KEY_TID, fbc->thread_id.c_str());
- for (auto jt = fbc->participants.begin(); jt != fbc->participants.end(); ++jt)
- AddChatContact(fbc->thread_id.c_str(), jt->second, false);
+ for (auto &jt : fbc->participants)
+ AddChatContact(fbc->thread_id.c_str(), jt.second, false);
}
if (!hChatContact)
@@ -955,8 +954,8 @@ void FacebookProto::ShowNotifications()
ScopedLock s(facy.notifications_lock_);
// Show popups for unseen notifications and/or write them to chatroom
- for (std::map<std::string, facebook_notification*>::iterator it = facy.notifications.begin(); it != facy.notifications.end(); ++it) {
- facebook_notification *notification = it->second;
+ for (auto &it : facy.notifications) {
+ facebook_notification *notification = it.second;
if (notification != nullptr && !notification->seen) {
debugLogA(" Showing popup for notification ID: %s", notification->id.c_str());
ptrW szText(mir_utf8decodeW(notification->text.c_str()));
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 6533f754ee..f46b558c63 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -534,11 +534,9 @@ INT_PTR FacebookProto::OnMind(WPARAM wParam, LPARAM)
post_status_data *data = new post_status_data(this, wall);
- if (wall->user_id == facy.self_.user_id) {
- for (std::map<std::string, std::string>::iterator iter = facy.pages.begin(); iter != facy.pages.end(); ++iter) {
- data->walls.push_back(new wall_data(iter->first, mir_utf8decodeW(iter->second.c_str()), true));
- }
- }
+ if (wall->user_id == facy.self_.user_id)
+ for (auto &iter : facy.pages)
+ data->walls.push_back(new wall_data(iter.first, mir_utf8decodeW(iter.second.c_str()), true));
HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MIND), (HWND)nullptr, FBMindProc, reinterpret_cast<LPARAM>(data));
ShowWindow(hDlg, SW_SHOW);
@@ -789,14 +787,6 @@ INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam)
return 1;
std::string *val = new std::string(id);
-
- // FIXME: Remember that we deleted this contact, so we won't accidentally add him at status change
- /*if (deleting) {
- facebook_user *fbu = facy.buddies.find(*val);
- if (fbu != nullptr)
- fbu->handle = nullptr;
- }*/
-
ForkThread(&FacebookProto::DeleteContactFromServer, val);
}
diff --git a/protocols/FacebookRM/src/stdafx.h b/protocols/FacebookRM/src/stdafx.h
index fe8d50eb58..6bf092d283 100644
--- a/protocols/FacebookRM/src/stdafx.h
+++ b/protocols/FacebookRM/src/stdafx.h
@@ -71,7 +71,6 @@ class FacebookProto;
#include "entities.h"
#include "http.h"
#include "http_request.h"
-#include "list.hpp"
#include "client.h"
#include "proto.h"
#include "db.h"