summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/chat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/FacebookRM/src/chat.cpp')
-rw-r--r--protocols/FacebookRM/src/chat.cpp39
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;
+}