diff options
Diffstat (limited to 'Swift/Controllers/Chat')
| -rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 8 | ||||
| -rw-r--r-- | Swift/Controllers/Chat/ChatsManager.h | 4 | ||||
| -rw-r--r-- | Swift/Controllers/Chat/UserSearchController.cpp | 22 | ||||
| -rw-r--r-- | Swift/Controllers/Chat/UserSearchController.h | 15 |
4 files changed, 25 insertions, 24 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 919a3d6..654f735 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -1,11 +1,11 @@ /* - * Copyright (c) 2010-2013 Kevin Smith + * Copyright (c) 2010-2014 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include <Swift/Controllers/Chat/ChatsManager.h> #include <boost/bind.hpp> #include <boost/algorithm/string.hpp> #include <boost/smart_ptr/make_shared.hpp> @@ -923,23 +923,23 @@ void ChatsManager::handleLocalServiceFound(const JID& service, boost::shared_ptr void ChatsManager::handleLocalServiceWalkFinished() { onImpromptuMUCServiceDiscovered(!localMUCServiceJID_.toString().empty()); } std::vector<ChatListWindow::Chat> ChatsManager::getRecentChats() const { return std::vector<ChatListWindow::Chat>(recentChats_.begin(), recentChats_.end()); } -std::vector<Contact> Swift::ChatsManager::getContacts() { - std::vector<Contact> result; +std::vector<Contact::ref> Swift::ChatsManager::getContacts() { + std::vector<Contact::ref> result; foreach (ChatListWindow::Chat chat, recentChats_) { if (!chat.isMUC) { - result.push_back(Contact(chat.chatName.empty() ? chat.jid.toString() : chat.chatName, chat.jid, chat.statusType, chat.avatarPath)); + result.push_back(boost::make_shared<Contact>(chat.chatName.empty() ? chat.jid.toString() : chat.chatName, chat.jid, chat.statusType, chat.avatarPath)); } } return result; } ChatsManager::SingleChatWindowFactoryAdapter::SingleChatWindowFactoryAdapter(ChatWindow* chatWindow) : chatWindow_(chatWindow) {} ChatsManager::SingleChatWindowFactoryAdapter::~SingleChatWindowFactoryAdapter() {} ChatWindow* ChatsManager::SingleChatWindowFactoryAdapter::createChatWindow(const JID &, UIEventStream*) { return chatWindow_; diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h index 979d52a..88a0986 100644 --- a/Swift/Controllers/Chat/ChatsManager.h +++ b/Swift/Controllers/Chat/ChatsManager.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2010-2013 Kevin Smith + * Copyright (c) 2010-2014 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include <map> #include <string> @@ -67,19 +67,19 @@ namespace Swift { class ChatsManager : public ContactProvider { public: ChatsManager(JID jid, StanzaChannel* stanzaChannel, IQRouter* iqRouter, EventController* eventController, ChatWindowFactory* chatWindowFactory, JoinMUCWindowFactory* joinMUCWindowFactory, NickResolver* nickResolver, PresenceOracle* presenceOracle, PresenceSender* presenceSender, UIEventStream* uiEventStream, ChatListWindowFactory* chatListWindowFactory, bool useDelayForLatency, TimerFactory* timerFactory, MUCRegistry* mucRegistry, EntityCapsProvider* entityCapsProvider, MUCManager* mucManager, MUCSearchWindowFactory* mucSearchWindowFactory, ProfileSettingsProvider* profileSettings, FileTransferOverview* ftOverview, XMPPRoster* roster, bool eagleMode, SettingsProvider* settings, HistoryController* historyController_, WhiteboardManager* whiteboardManager, HighlightManager* highlightManager, ClientBlockListManager* clientBlockListManager, const std::map<std::string, std::string>& emoticons, UserSearchController* inviteUserSearchController, VCardManager* vcardManager); virtual ~ChatsManager(); void setAvatarManager(AvatarManager* avatarManager); void setOnline(bool enabled); void setServerDiscoInfo(boost::shared_ptr<DiscoInfo> info); void handleIncomingMessage(boost::shared_ptr<Message> message); std::vector<ChatListWindow::Chat> getRecentChats() const; - virtual std::vector<Contact> getContacts(); + virtual std::vector<Contact::ref> getContacts(); boost::signal<void (bool supportsImpromptu)> onImpromptuMUCServiceDiscovered; private: class SingleChatWindowFactoryAdapter : public ChatWindowFactory { public: SingleChatWindowFactoryAdapter(ChatWindow* chatWindow); virtual ~SingleChatWindowFactoryAdapter(); virtual ChatWindow* createChatWindow(const JID &, UIEventStream*); diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp index 7844c1b..8503609 100644 --- a/Swift/Controllers/Chat/UserSearchController.cpp +++ b/Swift/Controllers/Chat/UserSearchController.cpp @@ -209,61 +209,61 @@ void UserSearchController::handleAvatarChanged(const JID& jid) { handleJIDUpdateRequested(std::vector<JID>(1, jid)); } void UserSearchController::handlePresenceChanged(Presence::ref presence) { handleJIDUpdateRequested(std::vector<JID>(1, presence->getFrom().toBare())); } void UserSearchController::handleJIDUpdateRequested(const std::vector<JID>& jids) { if (window_) { - std::vector<Contact> updates; + std::vector<Contact::ref> updates; foreach(const JID& jid, jids) { updates.push_back(convertJIDtoContact(jid)); } window_->updateContacts(updates); } } void UserSearchController::handleJIDAddRequested(const std::vector<JID>& jids) { - std::vector<Contact> contacts; + std::vector<Contact::ref> contacts; foreach(const JID& jid, jids) { contacts.push_back(convertJIDtoContact(jid)); } window_->addContacts(contacts); } -Contact UserSearchController::convertJIDtoContact(const JID& jid) { - Contact contact; - contact.jid = jid; +Contact::ref UserSearchController::convertJIDtoContact(const JID& jid) { + Contact::ref contact = boost::make_shared<Contact>(); + contact->jid = jid; // name lookup boost::optional<XMPPRosterItem> rosterItem = rosterController_->getItem(jid); if (rosterItem && !rosterItem->getName().empty()) { - contact.name = rosterItem->getName(); + contact->name = rosterItem->getName(); } else { VCard::ref vcard = vcardManager_->getVCard(jid); if (vcard && !vcard->getFullName().empty()) { - contact.name = vcard->getFullName(); + contact->name = vcard->getFullName(); } else { - contact.name = jid.toString(); + contact->name = jid.toString(); } } // presence lookup Presence::ref presence = presenceOracle_->getHighestPriorityPresence(jid); if (presence) { - contact.statusType = presence->getShow(); + contact->statusType = presence->getShow(); } else { - contact.statusType = StatusShow::None; + contact->statusType = StatusShow::None; } // avatar lookup - contact.avatarPath = avatarManager_->getAvatarPath(jid); + contact->avatarPath = avatarManager_->getAvatarPath(jid); return contact; } void UserSearchController::handleDiscoWalkFinished() { window_->setServerSupportsSearch(false); endDiscoWalker(); } void UserSearchController::initializeUserWindow() { diff --git a/Swift/Controllers/Chat/UserSearchController.h b/Swift/Controllers/Chat/UserSearchController.h index fc4c8e9..d630580 100644 --- a/Swift/Controllers/Chat/UserSearchController.h +++ b/Swift/Controllers/Chat/UserSearchController.h @@ -1,44 +1,45 @@ /* * Copyright (c) 2010-2014 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include <boost/shared_ptr.hpp> + #include <map> #include <vector> -#include <Swiften/Base/boost_bsignals.h> - -#include <Swiften/Elements/SearchPayload.h> #include <string> -#include <Swiften/JID/JID.h> + +#include <Swift/Controllers/Contact.h> +#include <Swiften/Base/boost_bsignals.h> #include <Swiften/Elements/DiscoInfo.h> #include <Swiften/Elements/DiscoItems.h> #include <Swiften/Elements/ErrorPayload.h> -#include <Swiften/Elements/VCard.h> #include <Swiften/Elements/Presence.h> +#include <Swiften/Elements/SearchPayload.h> +#include <Swiften/Elements/VCard.h> +#include <Swiften/JID/JID.h> namespace Swift { class UIEventStream; class UIEvent; class UserSearchWindow; class UserSearchWindowFactory; class IQRouter; class DiscoServiceWalker; class RosterController; class VCardManager; class ContactSuggester; class AvatarManager; class PresenceOracle; - class Contact; class UserSearchResult { public: UserSearchResult(const JID& jid, const std::map<std::string, std::string>& fields) : jid_(jid), fields_(fields) {} const JID& getJID() const {return jid_;} const std::map<std::string, std::string>& getFields() const {return fields_;} private: JID jid_; std::map<std::string, std::string> fields_; @@ -62,19 +63,19 @@ namespace Swift { void handleSearch(boost::shared_ptr<SearchPayload> fields, const JID& jid); void handleSearchResponse(boost::shared_ptr<SearchPayload> results, ErrorPayload::ref error); void handleNameSuggestionRequest(const JID& jid); void handleContactSuggestionsRequested(std::string text); void handleVCardChanged(const JID& jid, VCard::ref vcard); void handleAvatarChanged(const JID& jid); void handlePresenceChanged(Presence::ref presence); void handleJIDUpdateRequested(const std::vector<JID>& jids); void handleJIDAddRequested(const std::vector<JID>& jids); - Contact convertJIDtoContact(const JID& jid); + Contact::ref convertJIDtoContact(const JID& jid); void endDiscoWalker(); void initializeUserWindow(); private: Type type_; JID jid_; JID suggestionsJID_; UIEventStream* uiEventStream_; VCardManager* vcardManager_; |
Swift