From 08cfaa06859238449d6848df4e170ffb6dc605d3 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Mon, 18 Jul 2011 20:36:39 +0100 Subject: Issue activate() on MUCs joined through Join dialog. Resolves: #936 diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index 05017e7..8b8b993 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -304,13 +304,12 @@ void ChatsManager::handleUIEvent(boost::shared_ptr event) { mucBookmarkManager_->replaceBookmark(editMUCBookmarkEvent->getOldBookmark(), editMUCBookmarkEvent->getNewBookmark()); } else if (JoinMUCUIEvent::ref joinEvent = boost::dynamic_pointer_cast(event)) { - handleJoinMUCRequest(joinEvent->getJID(), joinEvent->getNick(), false); + handleJoinMUCRequest(joinEvent->getJID(), joinEvent->getNick(), joinEvent->getShouldJoinAutomatically()); mucControllers_[joinEvent->getJID()]->activateChatWindow(); } else if (boost::shared_ptr joinEvent = boost::dynamic_pointer_cast(event)) { if (!joinMUCWindow_) { - joinMUCWindow_ = joinMUCWindowFactory_->createJoinMUCWindow(); - joinMUCWindow_->onJoinMUC.connect(boost::bind(&ChatsManager::handleJoinMUCRequest, this, _1, _2, _3)); + joinMUCWindow_ = joinMUCWindowFactory_->createJoinMUCWindow(uiEventStream_); joinMUCWindow_->onSearchMUC.connect(boost::bind(&ChatsManager::handleSearchMUCRequest, this)); } joinMUCWindow_->setMUC(joinEvent->getRoom()); diff --git a/Swift/Controllers/UIEvents/JoinMUCUIEvent.h b/Swift/Controllers/UIEvents/JoinMUCUIEvent.h index 505a0e8..dea3ead 100644 --- a/Swift/Controllers/UIEvents/JoinMUCUIEvent.h +++ b/Swift/Controllers/UIEvents/JoinMUCUIEvent.h @@ -18,11 +18,13 @@ namespace Swift { class JoinMUCUIEvent : public UIEvent { public: typedef boost::shared_ptr ref; - JoinMUCUIEvent(const JID& jid, const boost::optional& nick = boost::optional()) : jid_(jid), nick_(nick) {}; + JoinMUCUIEvent(const JID& jid, const boost::optional& nick = boost::optional(), bool joinAutomaticallyInFuture = false) : jid_(jid), nick_(nick), joinAutomatically_(joinAutomaticallyInFuture){}; boost::optional getNick() {return nick_;}; JID getJID() {return jid_;}; + bool getShouldJoinAutomatically() {return joinAutomatically_;} private: JID jid_; boost::optional nick_; + bool joinAutomatically_; }; } diff --git a/Swift/Controllers/UIInterfaces/JoinMUCWindow.h b/Swift/Controllers/UIInterfaces/JoinMUCWindow.h index 2e3d43c..4873c9b 100644 --- a/Swift/Controllers/UIInterfaces/JoinMUCWindow.h +++ b/Swift/Controllers/UIInterfaces/JoinMUCWindow.h @@ -21,7 +21,6 @@ namespace Swift { virtual void setMUC(const std::string& nick) = 0; virtual void show() = 0; - boost::signal onJoinMUC; boost::signal onSearchMUC; }; } diff --git a/Swift/Controllers/UIInterfaces/JoinMUCWindowFactory.h b/Swift/Controllers/UIInterfaces/JoinMUCWindowFactory.h index 9c8bd77..cd8021b 100644 --- a/Swift/Controllers/UIInterfaces/JoinMUCWindowFactory.h +++ b/Swift/Controllers/UIInterfaces/JoinMUCWindowFactory.h @@ -9,10 +9,11 @@ #include namespace Swift { + class UIEventStream; class JoinMUCWindowFactory { public: virtual ~JoinMUCWindowFactory() {}; - virtual JoinMUCWindow* createJoinMUCWindow() = 0; + virtual JoinMUCWindow* createJoinMUCWindow(UIEventStream* uiEventStream) = 0; }; } diff --git a/Swift/QtUI/QtJoinMUCWindow.cpp b/Swift/QtUI/QtJoinMUCWindow.cpp index 7980a17..a44cdaf 100644 --- a/Swift/QtUI/QtJoinMUCWindow.cpp +++ b/Swift/QtUI/QtJoinMUCWindow.cpp @@ -6,10 +6,13 @@ #include "QtJoinMUCWindow.h" #include "QtSwiftUtil.h" +#include +#include +#include namespace Swift { -QtJoinMUCWindow::QtJoinMUCWindow() { +QtJoinMUCWindow::QtJoinMUCWindow(UIEventStream* uiEventStream) : uiEventStream(uiEventStream) { ui.setupUi(this); #if QT_VERSION >= 0x040700 ui.room->setPlaceholderText(tr("someroom@rooms.example.com")); @@ -35,7 +38,7 @@ void QtJoinMUCWindow::handleJoin() { lastSetNick = Q2PSTRING(ui.nickName->text()); JID room(Q2PSTRING(ui.room->text())); - onJoinMUC(room, lastSetNick, ui.joinAutomatically->isChecked()); + uiEventStream->send(boost::make_shared(room, lastSetNick, ui.joinAutomatically->isChecked())); hide(); } diff --git a/Swift/QtUI/QtJoinMUCWindow.h b/Swift/QtUI/QtJoinMUCWindow.h index 6e8e846..90b4f3f 100644 --- a/Swift/QtUI/QtJoinMUCWindow.h +++ b/Swift/QtUI/QtJoinMUCWindow.h @@ -11,10 +11,11 @@ #include namespace Swift { + class UIEventStream; class QtJoinMUCWindow : public QWidget, public JoinMUCWindow { Q_OBJECT public: - QtJoinMUCWindow(); + QtJoinMUCWindow(UIEventStream* uiEventStream); virtual void setNick(const std::string& nick); virtual void setMUC(const std::string& nick); @@ -28,5 +29,6 @@ namespace Swift { private: Ui::QtJoinMUCWindow ui; std::string lastSetNick; + UIEventStream* uiEventStream; }; } diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp index 40ce95e..bd936d4 100644 --- a/Swift/QtUI/QtUIFactory.cpp +++ b/Swift/QtUI/QtUIFactory.cpp @@ -112,8 +112,8 @@ UserSearchWindow* QtUIFactory::createUserSearchWindow(UserSearchWindow::Type typ return new QtUserSearchWindow(eventStream, type, groups); }; -JoinMUCWindow* QtUIFactory::createJoinMUCWindow() { - return new QtJoinMUCWindow(); +JoinMUCWindow* QtUIFactory::createJoinMUCWindow(UIEventStream* uiEventStream) { + return new QtJoinMUCWindow(uiEventStream); } ProfileWindow* QtUIFactory::createProfileWindow() { diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h index a576ded..e7ea6c6 100644 --- a/Swift/QtUI/QtUIFactory.h +++ b/Swift/QtUI/QtUIFactory.h @@ -36,7 +36,7 @@ namespace Swift { virtual MUCSearchWindow* createMUCSearchWindow(); virtual ChatWindow* createChatWindow(const JID &contact, UIEventStream* eventStream); virtual UserSearchWindow* createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream, const std::set& groups); - virtual JoinMUCWindow* createJoinMUCWindow(); + virtual JoinMUCWindow* createJoinMUCWindow(UIEventStream* uiEventStream); virtual ProfileWindow* createProfileWindow(); virtual ContactEditWindow* createContactEditWindow(); virtual void createAdHocCommandWindow(boost::shared_ptr command); -- cgit v0.10.2-6-g49f6