diff options
author | Robert Pösel <robyer@seznam.cz> | 2017-03-05 15:05:51 +0100 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2017-03-05 15:06:02 +0100 |
commit | da611f505c0e9a8d8476de272967891efba48872 (patch) | |
tree | 9c3b2ea1ca752b9a3628748fafa6cd78dbb0b101 /protocols/FacebookRM/src/chat.cpp | |
parent | 5417b1e4a79c86ac64cb3f84cde17eec2e0d0c87 (diff) |
Facebook: Fix reseting chat name
When user changed thread name from website and set it to "", in Miranda it previously stay "". Now it correctly generates new name from participant names.
Diffstat (limited to 'protocols/FacebookRM/src/chat.cpp')
-rw-r--r-- | protocols/FacebookRM/src/chat.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index d271b544f9..126976137f 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -3,7 +3,7 @@ Facebook plugin for Miranda Instant Messenger _____________________________________________ -Copyright � 2011-17 Robert P�sel +Copyright © 2011-17 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 @@ -432,4 +432,39 @@ void FacebookProto::UpdateNotificationsChatRoom(facebook_notification *notificat gce.ptszUID = idT; Chat_Event(&gce); -}
\ No newline at end of file +} + +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; + + // 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) + continue; + + if (namesUsed > 0) + name += ", "; + + name += utils::text::prepare_name(participant, false); + + if (++namesUsed >= FACEBOOK_CHATROOM_NAMES_COUNT) + break; + } + + // Participants.size()-1 because we ignore self contact + if (fbc->participants.size() - 1 > namesUsed) { + wchar_t more[200]; + mir_snwprintf(more, TranslateT("%s and more (%d)"), fbc->chat_name.c_str(), fbc->participants.size() - 1 - namesUsed); // -1 because we ignore self contact + fbc->chat_name = more; + } + + // If there are no participants to create a name from, use just thread_id + if (name.empty()) + name = fbc->thread_id.c_str(); + + return name; +} |