diff options
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 17 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.h | 2 | ||||
-rw-r--r-- | Swift/Controllers/Chat/UserSearchController.cpp | 3 |
3 files changed, 19 insertions, 3 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 3db1327..c180024 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -972,5 +972,5 @@ std::vector<ChatListWindow::Chat> ChatsManager::getRecentChats() const { } -std::vector<Contact::ref> Swift::ChatsManager::getContacts() { +std::vector<Contact::ref> Swift::ChatsManager::getContacts(bool withMUCNicks) { std::vector<Contact::ref> result; foreach (ChatListWindow::Chat chat, recentChats_) { @@ -979,4 +979,19 @@ std::vector<Contact::ref> Swift::ChatsManager::getContacts() { } } + if (withMUCNicks) { + /* collect MUC nicks */ + typedef std::map<JID, MUCController*>::value_type Item; + foreach (const Item& item, mucControllers_) { + JID mucJID = item.second->getToJID(); + std::map<std::string, JID> participants = item.second->getParticipantJIDs(); + typedef std::map<std::string, JID>::value_type ParticipantType; + foreach (const ParticipantType& participant, participants) { + const JID nickJID = JID(mucJID.getNode(), mucJID.getDomain(), participant.first); + Presence::ref presence = presenceOracle_->getLastPresence(nickJID); + const boost::filesystem::path avatar = avatarManager_->getAvatarPath(nickJID); + result.push_back(boost::make_shared<Contact>(participant.first, JID(), presence->getShow(), avatar)); + } + } + } return result; } diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h index 179f536..575b3cb 100644 --- a/Swift/Controllers/Chat/ChatsManager.h +++ b/Swift/Controllers/Chat/ChatsManager.h @@ -74,5 +74,5 @@ namespace Swift { void handleIncomingMessage(boost::shared_ptr<Message> message); std::vector<ChatListWindow::Chat> getRecentChats() const; - virtual std::vector<Contact::ref> getContacts(); + virtual std::vector<Contact::ref> getContacts(bool withMUCNicks); boost::signal<void (bool supportsImpromptu)> onImpromptuMUCServiceDiscovered; diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp index f259a9a..f1849c9 100644 --- a/Swift/Controllers/Chat/UserSearchController.cpp +++ b/Swift/Controllers/Chat/UserSearchController.cpp @@ -197,5 +197,6 @@ void UserSearchController::handleNameSuggestionRequest(const JID &jid) { void UserSearchController::handleContactSuggestionsRequested(std::string text) { const std::vector<JID> existingJIDs = window_->getJIDs(); - std::vector<Contact::ref> suggestions = contactSuggester_->getSuggestions(text); + std::vector<Contact::ref> suggestions = contactSuggester_->getSuggestions(text, false); + /* do not suggest contacts that have already been added to the chat list */ std::vector<Contact::ref>::iterator i = suggestions.begin(); while (i != suggestions.end()) { |