summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-15 21:16:37 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-15 21:19:29 (GMT)
commit1cf2023bc496a4abe5a98138401295b45a0b899a (patch)
tree8516e0132e9aaf197635ef9eb515b2e93256614c /Swift/Controllers
parentbd8af5feb9b61f42c15cab77b19a58dfd93afa06 (diff)
downloadswift-1cf2023bc496a4abe5a98138401295b45a0b899a.zip
swift-1cf2023bc496a4abe5a98138401295b45a0b899a.tar.bz2
Normalise muc joining, allow it from bookmark list.
Resolves: #320
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/Chat/ChatsManager.cpp13
-rw-r--r--Swift/Controllers/Chat/ChatsManager.h2
-rw-r--r--Swift/Controllers/MainController.cpp5
-rw-r--r--Swift/Controllers/RosterController.cpp9
-rw-r--r--Swift/Controllers/RosterController.h3
-rw-r--r--Swift/Controllers/UIEvents/JoinMUCUIEvent.h9
-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.h2
-rw-r--r--Swift/Controllers/UnitTest/MockMainWindowFactory.h2
-rw-r--r--Swift/Controllers/XMPPRosterController.cpp2
11 files changed, 20 insertions, 28 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"