diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-04-15 21:16:37 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-04-15 21:19:29 (GMT) |
commit | 1cf2023bc496a4abe5a98138401295b45a0b899a (patch) | |
tree | 8516e0132e9aaf197635ef9eb515b2e93256614c /Swift/Controllers/Chat | |
parent | bd8af5feb9b61f42c15cab77b19a58dfd93afa06 (diff) | |
download | swift-contrib-1cf2023bc496a4abe5a98138401295b45a0b899a.zip swift-contrib-1cf2023bc496a4abe5a98138401295b45a0b899a.tar.bz2 |
Normalise muc joining, allow it from bookmark list.
Resolves: #320
Diffstat (limited to 'Swift/Controllers/Chat')
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 13 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.h | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index e3d3e64..a490a3f 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -14,6 +14,7 @@ #include "Swift/Controllers/EventController.h" #include "Swift/Controllers/Chat/MUCController.h" #include "Swift/Controllers/UIEvents/RequestChatUIEvent.h" +#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h" #include "Swift/Controllers/UIInterfaces/ChatListWindowFactory.h" #include "Swiften/Presence/PresenceSender.h" #include "Swiften/Elements/ChatState.h" @@ -58,8 +59,7 @@ void ChatsManager::handleMUCBookmarkAdded(boost::shared_ptr<MUCBookmark> bookmar std::map<JID, MUCController*>::iterator it = mucControllers_.find(bookmark->getRoom()); if (it == mucControllers_.end() && bookmark->getAutojoin()) { //FIXME: need vcard stuff here to get a nick - String nick = bookmark->getNick() ? bookmark->getNick().get() : "Swift user"; - handleJoinMUCRequest(bookmark->getRoom(), nick); + handleJoinMUCRequest(bookmark->getRoom(), bookmark->getNick()); } chatListWindow_->addMUCBookmark(bookmark); } @@ -84,6 +84,10 @@ void ChatsManager::handleUIEvent(boost::shared_ptr<UIEvent> event) { if (chatEvent) { handleChatRequest(chatEvent->getContact()); } + boost::shared_ptr<JoinMUCUIEvent> joinMUCEvent = boost::dynamic_pointer_cast<JoinMUCUIEvent>(event); + if (joinMUCEvent) { + handleJoinMUCRequest(joinMUCEvent->getJID(), joinMUCEvent->getNick()); + } } /** @@ -115,7 +119,7 @@ void ChatsManager::setAvatarManager(AvatarManager* avatarManager) { // { // boost::shared_ptr<JoinMUCUIEvent> event = boost::dynamic_pointer_cast<JoinMUCUIEvent>(rawEvent); // if (event != NULL) { -// handleJoinMUCRequest(event->getRoom(), event->getNick()); +// handleJoinMUCRequest(); // } // } // } @@ -191,11 +195,12 @@ void ChatsManager::rebindControllerJID(const JID& from, const JID& to) { chatControllers_[to]->setToJID(to); } -void ChatsManager::handleJoinMUCRequest(const JID &muc, const String &nick) { +void ChatsManager::handleJoinMUCRequest(const JID &muc, const boost::optional<String>& nickMaybe) { std::map<JID, MUCController*>::iterator it = mucControllers_.find(muc); if (it != mucControllers_.end()) { //FIXME: What's correct behaviour here? } else { + String nick = nickMaybe ? nickMaybe.get() : "Swift user"; MUCController* controller = new MUCController(jid_, muc, nick, stanzaChannel_, presenceSender_, iqRouter_, chatWindowFactory_, treeWidgetFactory_, presenceOracle_, avatarManager_, uiEventStream_); mucControllers_[muc] = controller; controller->setAvailableServerFeatures(serverDiscoInfo_); diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h index 6dc598e..df49b0a 100644 --- a/Swift/Controllers/Chat/ChatsManager.h +++ b/Swift/Controllers/Chat/ChatsManager.h @@ -44,8 +44,8 @@ namespace Swift { void setServerDiscoInfo(boost::shared_ptr<DiscoInfo> info); void handleIncomingMessage(boost::shared_ptr<Message> message); void handleChatRequest(const String& contact); - void handleJoinMUCRequest(const JID& muc, const String& nick); private: + void handleJoinMUCRequest(const JID& muc, const boost::optional<String>& nick); 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); |