diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-03-28 13:25:13 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-03-28 13:25:35 (GMT) |
commit | a59af6c6daa72dd491189335cf2d255a788eb0f6 (patch) | |
tree | a09c9b67e6ba5ea0ac87ab06a0b9836d61571a3e /Swift/Controllers/Chat | |
parent | 625d6a9f18c2377cdc3180e74b773ce3cbb2dcba (diff) | |
download | swift-contrib-a59af6c6daa72dd491189335cf2d255a788eb0f6.zip swift-contrib-a59af6c6daa72dd491189335cf2d255a788eb0f6.tar.bz2 |
Chat list in the gui (mostly non-functional).
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 26 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.h | 9 |
2 files changed, 23 insertions, 12 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 104df22..d83c42e 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -8,6 +8,7 @@ #include "Swift/Controllers/EventController.h" #include "Swift/Controllers/Chat/MUCController.h" #include "Swift/Controllers/UIEvents/RequestChatUIEvent.h" +#include "Swift/Controllers/UIInterfaces/ChatListWindowFactory.h" #include "Swiften/Presence/PresenceSender.h" #include "Swiften/Elements/ChatState.h" #include "Swiften/MUC/MUCBookmarkManager.h" @@ -17,7 +18,7 @@ namespace Swift { typedef std::pair<JID, ChatController*> JIDChatControllerPair; typedef std::pair<JID, MUCController*> JIDMUCControllerPair; -ChatsManager::ChatsManager(JID jid, StanzaChannel* stanzaChannel, IQRouter* iqRouter, EventController* eventController, ChatWindowFactory* chatWindowFactory, TreeWidgetFactory* treeWidgetFactory, NickResolver* nickResolver, PresenceOracle* presenceOracle, boost::shared_ptr<DiscoInfo> serverDiscoInfo, PresenceSender* presenceSender, UIEventStream* uiEventStream) : jid_(jid) { +ChatsManager::ChatsManager(JID jid, StanzaChannel* stanzaChannel, IQRouter* iqRouter, EventController* eventController, ChatWindowFactory* chatWindowFactory, TreeWidgetFactory* treeWidgetFactory, NickResolver* nickResolver, PresenceOracle* presenceOracle, boost::shared_ptr<DiscoInfo> serverDiscoInfo, PresenceSender* presenceSender, UIEventStream* uiEventStream, ChatListWindowFactory* chatListWindowFactory) : jid_(jid) { eventController_ = eventController; stanzaChannel_ = stanzaChannel; iqRouter_ = iqRouter; @@ -30,9 +31,11 @@ ChatsManager::ChatsManager(JID jid, StanzaChannel* stanzaChannel, IQRouter* iqRo presenceSender_ = presenceSender; uiEventStream_ = uiEventStream; mucBookmarkManager_ = new MUCBookmarkManager(iqRouter); - mucBookmarkManager_->onBookmarksChanged.connect(boost::bind(&ChatsManager::handleMUCBookmarksChanged, this)); + mucBookmarkManager_->onBookmarkAdded.connect(boost::bind(&ChatsManager::handleMUCBookmarkAdded, this, _1)); + mucBookmarkManager_->onBookmarkRemoved.connect(boost::bind(&ChatsManager::handleMUCBookmarkRemoved, this, _1)); presenceOracle_->onPresenceChange.connect(boost::bind(&ChatsManager::handlePresenceChange, this, _1, _2)); uiEventStream_->onUIEvent.connect(boost::bind(&ChatsManager::handleUIEvent, this, _1)); + chatListWindow_ = chatListWindowFactory->createWindow(uiEventStream_); } ChatsManager::~ChatsManager() { @@ -45,15 +48,18 @@ ChatsManager::~ChatsManager() { delete mucBookmarkManager_; } -void ChatsManager::handleMUCBookmarksChanged() { - foreach (boost::shared_ptr<MUCBookmark> bookmark, mucBookmarkManager_->getBookmarks()) { - std::map<JID, MUCController*>::iterator it = mucControllers_.find(bookmark->getRoom()); - if (it == mucControllers_.end()) { - //FIXME: need vcard stuff here to get a nick - String nick = bookmark->getNick() ? bookmark->getNick().get() : "Swift user"; - handleJoinMUCRequest(bookmark->getRoom(), nick); - } +void ChatsManager::handleMUCBookmarkAdded(boost::shared_ptr<MUCBookmark> bookmark) { + std::map<JID, MUCController*>::iterator it = mucControllers_.find(bookmark->getRoom()); + if (it == mucControllers_.end()) { + //FIXME: need vcard stuff here to get a nick + String nick = bookmark->getNick() ? bookmark->getNick().get() : "Swift user"; + handleJoinMUCRequest(bookmark->getRoom(), nick); } + chatListWindow_->addMUCBookmark(bookmark); +} + +void ChatsManager::handleMUCBookmarkRemoved(boost::shared_ptr<MUCBookmark> bookmark) { + chatListWindow_->removeMUCBookmark(bookmark); } void ChatsManager::handleUserLeftMUC(MUCController* mucController) { diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h index a1614f8..575be5f 100644 --- a/Swift/Controllers/Chat/ChatsManager.h +++ b/Swift/Controllers/Chat/ChatsManager.h @@ -11,6 +11,7 @@ #include "Swiften/JID/JID.h" #include "Swiften/MUC/MUCRegistry.h" #include "Swift/Controllers/UIEvents/UIEventStream.h" +#include "Swiften/MUC/MUCBookmark.h" namespace Swift { class EventController; @@ -25,10 +26,12 @@ namespace Swift { class IQRouter; class PresenceSender; class MUCBookmarkManager; + class ChatListWindow; + class ChatListWindowFactory; class ChatsManager : public MUCRegistry { public: - ChatsManager(JID jid, StanzaChannel* stanzaChannel, IQRouter* iqRouter, EventController* eventController, ChatWindowFactory* chatWindowFactory, TreeWidgetFactory* treeWidgetFactory, NickResolver* nickResolver, PresenceOracle* presenceOracle, boost::shared_ptr<DiscoInfo> serverDiscoInfo, PresenceSender* presenceSender, UIEventStream* uiEventStream); + ChatsManager(JID jid, StanzaChannel* stanzaChannel, IQRouter* iqRouter, EventController* eventController, ChatWindowFactory* chatWindowFactory, TreeWidgetFactory* treeWidgetFactory, NickResolver* nickResolver, PresenceOracle* presenceOracle, boost::shared_ptr<DiscoInfo> serverDiscoInfo, PresenceSender* presenceSender, UIEventStream* uiEventStream, ChatListWindowFactory* chatListWindowFactory); ~ChatsManager(); void setAvatarManager(AvatarManager* avatarManager); void setEnabled(bool enabled); @@ -40,7 +43,8 @@ namespace Swift { void rebindControllerJID(const JID& from, const JID& to); void handlePresenceChange(boost::shared_ptr<Presence> newPresence, boost::shared_ptr<Presence> lastPresence); void handleUIEvent(boost::shared_ptr<UIEvent> event); - void handleMUCBookmarksChanged(); + void handleMUCBookmarkAdded(boost::shared_ptr<MUCBookmark> bookmark); + void handleMUCBookmarkRemoved(boost::shared_ptr<MUCBookmark> bookmark); void handleUserLeftMUC(MUCController* mucController); ChatController* getChatController(const JID &contact); virtual bool isMUC(const JID& muc) const; @@ -60,5 +64,6 @@ namespace Swift { UIEventStream* uiEventStream_; MUCBookmarkManager* mucBookmarkManager_; boost::shared_ptr<DiscoInfo> serverDiscoInfo_; + ChatListWindow* chatListWindow_; }; } |