diff options
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 5 | ||||
-rw-r--r-- | Swift/Controllers/UIEvents/JoinMUCUIEvent.h | 4 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/JoinMUCWindow.h | 1 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/JoinMUCWindowFactory.h | 3 | ||||
-rw-r--r-- | Swift/QtUI/QtJoinMUCWindow.cpp | 7 | ||||
-rw-r--r-- | Swift/QtUI/QtJoinMUCWindow.h | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtUIFactory.cpp | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtUIFactory.h | 2 |
8 files changed, 18 insertions, 12 deletions
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 @@ -298,25 +298,24 @@ void ChatsManager::handleUIEvent(boost::shared_ptr<UIEvent> event) { mucBookmarkManager_->addBookmark(addMUCBookmarkEvent->getBookmark()); return; } boost::shared_ptr<EditMUCBookmarkUIEvent> editMUCBookmarkEvent = boost::dynamic_pointer_cast<EditMUCBookmarkUIEvent>(event); if (editMUCBookmarkEvent) { mucBookmarkManager_->replaceBookmark(editMUCBookmarkEvent->getOldBookmark(), editMUCBookmarkEvent->getNewBookmark()); } else if (JoinMUCUIEvent::ref joinEvent = boost::dynamic_pointer_cast<JoinMUCUIEvent>(event)) { - handleJoinMUCRequest(joinEvent->getJID(), joinEvent->getNick(), false); + handleJoinMUCRequest(joinEvent->getJID(), joinEvent->getNick(), joinEvent->getShouldJoinAutomatically()); mucControllers_[joinEvent->getJID()]->activateChatWindow(); } else if (boost::shared_ptr<RequestJoinMUCUIEvent> joinEvent = boost::dynamic_pointer_cast<RequestJoinMUCUIEvent>(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()); joinMUCWindow_->setNick(nickResolver_->jidToNick(jid_)); joinMUCWindow_->show(); } } /** 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 @@ -12,17 +12,19 @@ #include <Swiften/JID/JID.h> #include "Swift/Controllers/UIEvents/UIEvent.h" namespace Swift { class JoinMUCUIEvent : public UIEvent { public: typedef boost::shared_ptr<JoinMUCUIEvent> ref; - JoinMUCUIEvent(const JID& jid, const boost::optional<std::string>& nick = boost::optional<std::string>()) : jid_(jid), nick_(nick) {}; + JoinMUCUIEvent(const JID& jid, const boost::optional<std::string>& nick = boost::optional<std::string>(), bool joinAutomaticallyInFuture = false) : jid_(jid), nick_(nick), joinAutomatically_(joinAutomaticallyInFuture){}; boost::optional<std::string> getNick() {return nick_;}; JID getJID() {return jid_;}; + bool getShouldJoinAutomatically() {return joinAutomatically_;} private: JID jid_; boost::optional<std::string> 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 @@ -15,13 +15,12 @@ namespace Swift { class JoinMUCWindow { public: virtual ~JoinMUCWindow() {}; virtual void setNick(const std::string& nick) = 0; virtual void setMUC(const std::string& nick) = 0; virtual void show() = 0; - boost::signal<void (const JID& /* muc */, const std::string& /* nick */, bool /* autoJoin */)> onJoinMUC; boost::signal<void ()> 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 @@ -3,16 +3,17 @@ * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include <Swift/Controllers/UIInterfaces/JoinMUCWindow.h> 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 @@ -1,21 +1,24 @@ /* * Copyright (c) 2010 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include "QtJoinMUCWindow.h" #include "QtSwiftUtil.h" +#include <boost/smart_ptr/make_shared.hpp> +#include <Swift/Controllers/UIEvents/UIEventStream.h> +#include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h> 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")); #endif connect(ui.room, SIGNAL(returnPressed()), this, SLOT(handleJoin())); connect(ui.searchButton, SIGNAL(clicked()), this, SLOT(handleSearch())); connect(ui.joinButton, SIGNAL(clicked()), this, SLOT(handleJoin())); // FIXME: Temporarily set focus on the nickName field first, so that the // placeholder for the room is visible. This is just because Qt hides @@ -29,19 +32,19 @@ void QtJoinMUCWindow::handleJoin() { return; } if (ui.nickName->text().isEmpty()) { // TODO: Error return; } lastSetNick = Q2PSTRING(ui.nickName->text()); JID room(Q2PSTRING(ui.room->text())); - onJoinMUC(room, lastSetNick, ui.joinAutomatically->isChecked()); + uiEventStream->send(boost::make_shared<JoinMUCUIEvent>(room, lastSetNick, ui.joinAutomatically->isChecked())); hide(); } void QtJoinMUCWindow::handleSearch() { onSearchMUC(); } void QtJoinMUCWindow::setNick(const std::string& nick) { ui.nickName->setText(P2QSTRING(nick)); 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 @@ -5,28 +5,30 @@ */ #pragma once #include <string> #include <Swift/Controllers/UIInterfaces/JoinMUCWindow.h> #include <Swift/QtUI/ui_QtJoinMUCWindow.h> 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); virtual void show(); private slots: void handleJoin(); void handleSearch(); 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 @@ -106,20 +106,20 @@ ChatWindow* QtUIFactory::createChatWindow(const JID& contact, UIEventStream* eve void QtUIFactory::handleChatWindowFontResized(int size) { chatFontSize = size; settings->storeInt(CHATWINDOW_FONT_SIZE, size); } UserSearchWindow* QtUIFactory::createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream, const std::set<std::string>& groups) { return new QtUserSearchWindow(eventStream, type, groups); }; -JoinMUCWindow* QtUIFactory::createJoinMUCWindow() { - return new QtJoinMUCWindow(); +JoinMUCWindow* QtUIFactory::createJoinMUCWindow(UIEventStream* uiEventStream) { + return new QtJoinMUCWindow(uiEventStream); } ProfileWindow* QtUIFactory::createProfileWindow() { return new QtProfileWindow(); } ContactEditWindow* QtUIFactory::createContactEditWindow() { return new QtContactEditWindow(); } 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 @@ -30,19 +30,19 @@ namespace Swift { virtual XMLConsoleWidget* createXMLConsoleWidget(); virtual MainWindow* createMainWindow(UIEventStream* eventStream); virtual LoginWindow* createLoginWindow(UIEventStream* eventStream); virtual EventWindow* createEventWindow(); virtual ChatListWindow* createChatListWindow(UIEventStream*); virtual MUCSearchWindow* createMUCSearchWindow(); virtual ChatWindow* createChatWindow(const JID &contact, UIEventStream* eventStream); virtual UserSearchWindow* createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream, const std::set<std::string>& groups); - virtual JoinMUCWindow* createJoinMUCWindow(); + virtual JoinMUCWindow* createJoinMUCWindow(UIEventStream* uiEventStream); virtual ProfileWindow* createProfileWindow(); virtual ContactEditWindow* createContactEditWindow(); virtual void createAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocCommandSession> command); private slots: void handleLoginWindowGeometryChanged(); void handleChatWindowFontResized(int); private: |