summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-07-23 08:00:01 (GMT)
committerSwift Review <review@swift.im>2014-10-03 07:21:38 (GMT)
commit3742d8fe17f558f9f6a5e26ac10e5ec3f0c3ae6c (patch)
tree0135a5e6aef5e1e9b5f389cdb8f14406765df029 /Swift/Controllers/Chat
parent4a4e72be24c9b7789426adf5cae078bfc4ca424e (diff)
downloadswift-3742d8fe17f558f9f6a5e26ac10e5ec3f0c3ae6c.zip
swift-3742d8fe17f558f9f6a5e26ac10e5ec3f0c3ae6c.tar.bz2
Suggest MUC occupants when typing in highlight editor JID box
Test-Information: Join several MUCs and confirm that MUC occupants are suggested along with recent contacts. Confirm that clicking or pressing return adds the selected contact to the edit field. Check that QtSuggestingJIDInput in Start Chat dialog still functions as before, and that MUC users are not suggested here. Change-Id: Ieadc95d55c764e1fa48c949cca4d5e0aa5f19615
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp17
-rw-r--r--Swift/Controllers/Chat/ChatsManager.h2
-rw-r--r--Swift/Controllers/Chat/UserSearchController.cpp3
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
@@ -971,13 +971,28 @@ std::vector<ChatListWindow::Chat> ChatsManager::getRecentChats() const {
return std::vector<ChatListWindow::Chat>(recentChats_.begin(), recentChats_.end());
}
-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_) {
if (!chat.isMUC) {
result.push_back(boost::make_shared<Contact>(chat.chatName.empty() ? chat.jid.toString() : chat.chatName, chat.jid, chat.statusType, chat.avatarPath));
}
}
+ 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
@@ -73,7 +73,7 @@ namespace Swift {
void setServerDiscoInfo(boost::shared_ptr<DiscoInfo> info);
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
@@ -196,7 +196,8 @@ 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()) {
bool found = false;