diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-04-05 19:15:02 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-04-05 19:15:02 (GMT) |
commit | 90eab2990dc087ebe2b91181f14ca452e5b31697 (patch) | |
tree | 7e264a796dad34bb55a79de81bed9e0bb4768573 /Swift/Controllers/Chat/MUCController.cpp | |
parent | c88b7c5da8dde6c4f7bdd85743378ec46f3a30fc (diff) | |
download | swift-contrib-90eab2990dc087ebe2b91181f14ca452e5b31697.zip swift-contrib-90eab2990dc087ebe2b91181f14ca452e5b31697.tar.bz2 |
Allow opening chats to MUC occupants.
Resolves: #275
Diffstat (limited to 'Swift/Controllers/Chat/MUCController.cpp')
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 0ec8c28..a1ca9cc 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -5,10 +5,13 @@ #include "Swiften/Base/foreach.h" #include "Swift/Controllers/UIInterfaces/ChatWindow.h" #include "Swift/Controllers/UIInterfaces/ChatWindowFactory.h" +#include "Swift/Controllers/UIEvents/UIEventStream.h" +#include "Swift/Controllers/UIEvents/RequestChatUIEvent.h" #include "Swiften/Avatars/AvatarManager.h" #include "Swiften/MUC/MUC.h" #include "Swiften/Client/StanzaChannel.h" #include "Swiften/Roster/Roster.h" +#include "Swiften/Roster/OpenChatRosterAction.h" #include "Swiften/Roster/SetAvatar.h" #include "Swiften/Roster/SetPresence.h" #include "Swiften/Roster/TreeWidgetFactory.h" @@ -28,13 +31,16 @@ MUCController::MUCController ( ChatWindowFactory* chatWindowFactory, TreeWidgetFactory *treeWidgetFactory, PresenceOracle* presenceOracle, - AvatarManager* avatarManager) : + AvatarManager* avatarManager, + UIEventStream* uiEventStream) : ChatControllerBase(self, stanzaChannel, iqRouter, chatWindowFactory, muc, presenceOracle, avatarManager), muc_(new MUC(stanzaChannel, presenceSender, muc)), nick_(nick), treeWidgetFactory_(treeWidgetFactory) { parting_ = false; + events_ = uiEventStream; roster_ = new Roster(chatWindow_->getTreeWidget(), treeWidgetFactory_); + roster_->onUserAction.connect(boost::bind(&MUCController::handleUserAction, this, _1)); chatWindow_->onClosed.connect(boost::bind(&MUCController::handleWindowClosed, this)); muc_->joinAs(nick); muc_->onOccupantJoined.connect(boost::bind(&MUCController::handleOccupantJoined, this, _1)); @@ -52,6 +58,16 @@ MUCController::~MUCController() { delete roster_; } +void MUCController::handleUserAction(boost::shared_ptr<UserRosterAction> action) { + boost::shared_ptr<OpenChatRosterAction> chatAction = boost::dynamic_pointer_cast<OpenChatRosterAction>(action); + if (chatAction.get() != NULL) { + ContactRosterItem *contactItem = dynamic_cast<ContactRosterItem*>(chatAction->getRosterItem()); + assert(contactItem); + events_->send(boost::shared_ptr<RequestChatUIEvent>(new RequestChatUIEvent(contactItem->getJID()))); + return; + } +} + void MUCController::handleAvatarChanged(const JID& jid, const String&) { if (parting_) { return; |