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 | |
parent | bd8af5feb9b61f42c15cab77b19a58dfd93afa06 (diff) | |
download | swift-1cf2023bc496a4abe5a98138401295b45a0b899a.zip swift-1cf2023bc496a4abe5a98138401295b45a0b899a.tar.bz2 |
Normalise muc joining, allow it from bookmark list.
Resolves: #320
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 13 | ||||
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.h | 2 | ||||
-rw-r--r-- | Swift/Controllers/MainController.cpp | 5 | ||||
-rw-r--r-- | Swift/Controllers/RosterController.cpp | 9 | ||||
-rw-r--r-- | Swift/Controllers/RosterController.h | 3 | ||||
-rw-r--r-- | Swift/Controllers/UIEvents/JoinMUCUIEvent.h | 9 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/MainWindow.h (renamed from Swift/Controllers/MainWindow.h) | 1 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/MainWindowFactory.h (renamed from Swift/Controllers/MainWindowFactory.h) | 0 | ||||
-rw-r--r-- | Swift/Controllers/UnitTest/MockMainWindow.h | 2 | ||||
-rw-r--r-- | Swift/Controllers/UnitTest/MockMainWindowFactory.h | 2 | ||||
-rw-r--r-- | Swift/Controllers/XMPPRosterController.cpp | 2 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/ChatListModel.cpp | 7 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/ChatListModel.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/ChatList/QtChatListWindow.cpp | 11 | ||||
-rw-r--r-- | Swift/QtUI/QtLoginWindow.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtMainWindow.cpp | 7 | ||||
-rw-r--r-- | Swift/QtUI/QtMainWindow.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtMainWindowFactory.h | 2 |
18 files changed, 45 insertions, 35 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); diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index e8c6c94..341fc09 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -21,8 +21,8 @@ #include "Swift/Controllers/UIInterfaces/LoginWindow.h" #include "Swift/Controllers/UIInterfaces/LoginWindowFactory.h" #include "Swift/Controllers/UIInterfaces/EventWindowFactory.h" -#include "Swift/Controllers/MainWindow.h" -#include "Swift/Controllers/MainWindowFactory.h" +#include "Swift/Controllers/UIInterfaces/MainWindow.h" +#include "Swift/Controllers/UIInterfaces/MainWindowFactory.h" #include "Swift/Controllers/Chat/MUCController.h" #include "Swift/Controllers/NickResolver.h" #include "Swift/Controllers/ProfileSettingsProvider.h" @@ -185,7 +185,6 @@ void MainController::handleConnected() { client_->onMessageReceived.connect(boost::bind(&ChatsManager::handleIncomingMessage, chatsManager_, _1)); chatsManager_->setAvatarManager(avatarManager_); rosterController_->onStartChatRequest.connect(boost::bind(&ChatsManager::handleChatRequest, chatsManager_, _1)); - rosterController_->onJoinMUCRequest.connect(boost::bind(&ChatsManager::handleJoinMUCRequest, chatsManager_, _1, _2)); avatarManager_->setMUCRegistry(chatsManager_); diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp index 17fd2e9..3bbc9f8 100644 --- a/Swift/Controllers/RosterController.cpp +++ b/Swift/Controllers/RosterController.cpp @@ -9,8 +9,8 @@ #include <boost/bind.hpp> #include "Swiften/Base/foreach.h" -#include "Swift/Controllers/MainWindow.h" -#include "Swift/Controllers/MainWindowFactory.h" +#include "Swift/Controllers/UIInterfaces/MainWindow.h" +#include "Swift/Controllers/UIInterfaces/MainWindowFactory.h" #include "Swift/Controllers/NickResolver.h" #include "Swiften/Queries/Requests/GetRosterRequest.h" #include "Swiften/Queries/Requests/SetRosterRequest.h" @@ -44,7 +44,6 @@ RosterController::RosterController(const JID& jid, boost::shared_ptr<XMPPRoster> eventController_ = eventController; roster_->addFilter(offlineFilter_); - joinMUCConnection_ = mainWindow_->onJoinMUCRequest.connect(boost::bind(&RosterController::handleJoinMUCRequest, this, _1, _2)); changeStatusConnection_ = mainWindow_->onChangeStatusRequest.connect(boost::bind(&RosterController::handleChangeStatusRequest, this, _1, _2)); showOfflineConnection_ = mainWindow_->onShowOfflineToggled.connect(boost::bind(&RosterController::handleShowOfflineToggled, this, _1)); signOutConnection_ = mainWindow_->onSignOutRequest.connect(boost::bind(boost::ref(onSignOutRequest))); @@ -233,8 +232,4 @@ void RosterController::handleAvatarChanged(const JID& jid, const String&) { } } -void RosterController::handleJoinMUCRequest(const JID &muc, const String &nick) { - onJoinMUCRequest(JID(muc), nick); -} - } diff --git a/Swift/Controllers/RosterController.h b/Swift/Controllers/RosterController.h index d5a97a9..e9561bb 100644 --- a/Swift/Controllers/RosterController.h +++ b/Swift/Controllers/RosterController.h @@ -42,7 +42,6 @@ namespace Swift { void setAvatarManager(AvatarManager* avatarManager); void setNickResolver(NickResolver* nickResolver); boost::signal<void (const JID&)> onStartChatRequest; - boost::signal<void (const JID&, const String&)> onJoinMUCRequest; boost::signal<void (StatusShow::Type, const String&)> onChangeStatusRequest; boost::signal<void ()> onSignOutRequest; void handleAvatarChanged(const JID& jid, const String& hash); @@ -52,7 +51,6 @@ namespace Swift { void handleOnJIDRemoved(const JID &jid); void handleOnJIDUpdated(const JID &jid, const String& oldName, const std::vector<String> oldGroups); void handleStartChatRequest(const JID& contact); - void handleJoinMUCRequest(const JID &muc, const String &nick); void handleUserAction(boost::shared_ptr<UserRosterAction> action); void handleChangeStatusRequest(StatusShow::Type show, const String &statusText); void handleShowOfflineToggled(bool state); @@ -74,7 +72,6 @@ namespace Swift { PresenceOracle* presenceOracle_; EventController* eventController_; IQRouter* iqRouter_; - boost::bsignals::scoped_connection joinMUCConnection_; boost::bsignals::scoped_connection changeStatusConnection_; boost::bsignals::scoped_connection showOfflineConnection_; boost::bsignals::scoped_connection signOutConnection_; diff --git a/Swift/Controllers/UIEvents/JoinMUCUIEvent.h b/Swift/Controllers/UIEvents/JoinMUCUIEvent.h index 0bdfef1..4ebf1f1 100644 --- a/Swift/Controllers/UIEvents/JoinMUCUIEvent.h +++ b/Swift/Controllers/UIEvents/JoinMUCUIEvent.h @@ -4,10 +4,9 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -//Not used yet. - #pragma once +#include <boost/optional.hpp> #include "Swiften/Base/String.h" #include "Swift/Controllers/UIEvents/UIEvent.h" @@ -15,11 +14,11 @@ namespace Swift { class JoinMUCUIEvent : public UIEvent { public: - JoinMUCUIEvent(const JID& jid, const String& contact) : jid_(jid), contact_(contact) {}; - String getContact() {return contact_;}; + JoinMUCUIEvent(const JID& jid, const boost::optional<String>& nick) : jid_(jid), nick_(nick) {}; + boost::optional<String> getNick() {return nick_;}; JID getJID() {return jid_;}; private: - String contact_; JID jid_; + boost::optional<String> nick_; }; } diff --git a/Swift/Controllers/MainWindow.h b/Swift/Controllers/UIInterfaces/MainWindow.h index 0f68af5..ce8b877 100644 --- a/Swift/Controllers/MainWindow.h +++ b/Swift/Controllers/UIInterfaces/MainWindow.h @@ -27,7 +27,6 @@ namespace Swift { virtual void setMyStatusType(StatusShow::Type type) = 0; boost::signal<void (const JID&)> onStartChatRequest; - boost::signal<void (const JID&, const String&)> onJoinMUCRequest; boost::signal<void (StatusShow::Type, const String&)> onChangeStatusRequest; boost::signal<void (bool)> onShowOfflineToggled; boost::signal<void ()> onSignOutRequest; diff --git a/Swift/Controllers/MainWindowFactory.h b/Swift/Controllers/UIInterfaces/MainWindowFactory.h index c5cdfef..c5cdfef 100644 --- a/Swift/Controllers/MainWindowFactory.h +++ b/Swift/Controllers/UIInterfaces/MainWindowFactory.h diff --git a/Swift/Controllers/UnitTest/MockMainWindow.h b/Swift/Controllers/UnitTest/MockMainWindow.h index f20c088..f6134da 100644 --- a/Swift/Controllers/UnitTest/MockMainWindow.h +++ b/Swift/Controllers/UnitTest/MockMainWindow.h @@ -6,7 +6,7 @@ #pragma once -#include "Swift/Controllers/MainWindow.h" +#include "Swift/Controllers/UIInterfaces/MainWindow.h" #include "Swiften/Roster/TreeWidget.h" namespace Swift { diff --git a/Swift/Controllers/UnitTest/MockMainWindowFactory.h b/Swift/Controllers/UnitTest/MockMainWindowFactory.h index 3cee5ca..2f0559b 100644 --- a/Swift/Controllers/UnitTest/MockMainWindowFactory.h +++ b/Swift/Controllers/UnitTest/MockMainWindowFactory.h @@ -6,7 +6,7 @@ #pragma once -#include "Swift/Controllers/MainWindowFactory.h" +#include "Swift/Controllers/UIInterfaces/MainWindowFactory.h" #include "Swiften/Roster/TreeWidgetFactory.h" #include "Swift/Controllers/UnitTest/MockMainWindow.h" diff --git a/Swift/Controllers/XMPPRosterController.cpp b/Swift/Controllers/XMPPRosterController.cpp index e5cf0a3..a7e634a 100644 --- a/Swift/Controllers/XMPPRosterController.cpp +++ b/Swift/Controllers/XMPPRosterController.cpp @@ -9,8 +9,6 @@ #include <boost/bind.hpp> #include "Swiften/Base/foreach.h" -#include "Swift/Controllers/MainWindow.h" -#include "Swift/Controllers/MainWindowFactory.h" #include "Swiften/Elements/RosterItemPayload.h" #include "Swiften/Queries/IQRouter.h" #include "Swiften/Queries/Requests/GetRosterRequest.h" diff --git a/Swift/QtUI/ChatList/ChatListModel.cpp b/Swift/QtUI/ChatList/ChatListModel.cpp index 1b01c64..40ed1b7 100644 --- a/Swift/QtUI/ChatList/ChatListModel.cpp +++ b/Swift/QtUI/ChatList/ChatListModel.cpp @@ -41,8 +41,13 @@ int ChatListModel::columnCount(const QModelIndex& /*parent*/) const { return 1; } +ChatListItem* ChatListModel::getItemForIndex(const QModelIndex& index) const { + return index.isValid() ? static_cast<ChatListItem*>(index.internalPointer()) : NULL; +} + QVariant ChatListModel::data(const QModelIndex& index, int role) const { - return index.isValid() ? static_cast<ChatListItem*>(index.internalPointer())->data(role) : QVariant(); + ChatListItem* item = getItemForIndex(index); + return item ? item->data(role) : QVariant(); } QModelIndex ChatListModel::index(int row, int column, const QModelIndex & parent) const { diff --git a/Swift/QtUI/ChatList/ChatListModel.h b/Swift/QtUI/ChatList/ChatListModel.h index f7cd137..71849cc 100644 --- a/Swift/QtUI/ChatList/ChatListModel.h +++ b/Swift/QtUI/ChatList/ChatListModel.h @@ -27,6 +27,7 @@ namespace Swift { QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; QModelIndex parent(const QModelIndex& index) const; int rowCount(const QModelIndex& parent = QModelIndex()) const; + ChatListItem* getItemForIndex(const QModelIndex& index) const; private: ChatListGroupItem* mucBookmarks_; ChatListGroupItem* root_; diff --git a/Swift/QtUI/ChatList/QtChatListWindow.cpp b/Swift/QtUI/ChatList/QtChatListWindow.cpp index c6c8e64..793d89a 100644 --- a/Swift/QtUI/ChatList/QtChatListWindow.cpp +++ b/Swift/QtUI/ChatList/QtChatListWindow.cpp @@ -5,6 +5,8 @@ */ #include "Swift/QtUI/ChatList/QtChatListWindow.h" +#include "Swift/QtUI/ChatList/ChatListMUCItem.h" +#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h" namespace Swift { @@ -29,8 +31,13 @@ QtChatListWindow::~QtChatListWindow() { delete delegate_; } -void QtChatListWindow::handleItemActivated(const QModelIndex& item) { - +void QtChatListWindow::handleItemActivated(const QModelIndex& index) { + ChatListItem* item = model_->getItemForIndex(index); + ChatListMUCItem* mucItem = dynamic_cast<ChatListMUCItem*>(item); + if (mucItem) { + boost::shared_ptr<UIEvent> event(new JoinMUCUIEvent(mucItem->getBookmark()->getRoom(), mucItem->getBookmark()->getNick())); + eventStream_->send(event); + } } void QtChatListWindow::addMUCBookmark(boost::shared_ptr<MUCBookmark> bookmark) { diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h index 654498d..c7b35c7 100644 --- a/Swift/QtUI/QtLoginWindow.h +++ b/Swift/QtUI/QtLoginWindow.h @@ -17,7 +17,7 @@ #include "Swift/Controllers/UIInterfaces/LoginWindow.h" #include "Swift/Controllers/UIEvents/UIEventStream.h" -#include "Swift/Controllers/MainWindow.h" +#include "Swift/Controllers/UIInterfaces/MainWindow.h" #include "QtAboutWidget.h" class QLabel; diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index 116f52e..c947ae7 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -6,6 +6,8 @@ #include "QtMainWindow.h" +#include <boost/optional.hpp> + #include <QBoxLayout> #include <QComboBox> #include <QLineEdit> @@ -24,6 +26,7 @@ #include "Roster/QtTreeWidgetFactory.h" #include "Roster/QtTreeWidget.h" #include "Swift/Controllers/UIEvents/AddContactUIEvent.h" +#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h" namespace Swift { @@ -137,7 +140,9 @@ void QtMainWindow::handleJoinMUCAction() { } void QtMainWindow::handleJoinMUCDialogComplete(const JID& muc, const QString& nick) { - onJoinMUCRequest(muc, Q2PSTRING(nick)); + boost::optional<String> maybeNick(Q2PSTRING(nick)); + boost::shared_ptr<UIEvent> event(new JoinMUCUIEvent(muc, maybeNick)); + uiEventStream_->send(event); } void QtMainWindow::handleStatusChanged(StatusShow::Type showType, const QString &statusMessage) { diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h index f846e27..45dbda6 100644 --- a/Swift/QtUI/QtMainWindow.h +++ b/Swift/QtUI/QtMainWindow.h @@ -9,7 +9,7 @@ #include <QWidget> #include <QMenu> -#include "Swift/Controllers/MainWindow.h" +#include "Swift/Controllers/UIInterfaces/MainWindow.h" #include "Swift/QtUI/QtRosterHeader.h" #include "Swift/QtUI/EventViewer/QtEventWindow.h" #include "Swift/QtUI/ChatList/QtChatListWindow.h" diff --git a/Swift/QtUI/QtMainWindowFactory.h b/Swift/QtUI/QtMainWindowFactory.h index 11414bb..c16d229 100644 --- a/Swift/QtUI/QtMainWindowFactory.h +++ b/Swift/QtUI/QtMainWindowFactory.h @@ -7,7 +7,7 @@ #ifndef SWIFT_QtMainWindowFactory_H #define SWIFT_QtMainWindowFactory_H -#include "Swift/Controllers/MainWindowFactory.h" +#include "Swift/Controllers/UIInterfaces/MainWindowFactory.h" namespace Swift { class QtTreeWidgetFactory; |