diff options
Diffstat (limited to 'Swift/Controllers')
| -rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 4 | ||||
| -rw-r--r-- | Swift/Controllers/Chat/ChatController.h | 1 | ||||
| -rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 14 | ||||
| -rw-r--r-- | Swift/Controllers/Chat/ChatsManager.h | 5 | ||||
| -rw-r--r-- | Swift/Controllers/MainController.cpp | 2 | ||||
| -rw-r--r-- | Swift/Controllers/UIEvents/AcceptWhiteboardSessionUIEvent.h | 24 | ||||
| -rw-r--r-- | Swift/Controllers/UIEvents/CancelWhiteboardSessionUIEvent.h | 24 | ||||
| -rw-r--r-- | Swift/Controllers/UIInterfaces/ChatWindow.h | 2 | ||||
| -rw-r--r-- | Swift/Controllers/WhiteboardManager.cpp | 48 | ||||
| -rw-r--r-- | Swift/Controllers/WhiteboardManager.h | 6 | 
10 files changed, 113 insertions, 17 deletions
| diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 2fa4559..12d3814 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -255,6 +255,10 @@ void ChatController::handleNewFileTransferController(FileTransferController* ftc  	ftControllers[ftID] = ftc;  } +void ChatController::handleIncomingWhiteboardSession() { +	chatWindow_->addWhiteboardRequest(toJID_); +} +  void ChatController::handleFileTransferCancel(std::string id) {  	SWIFT_LOG(debug) << "handleFileTransferCancel(" << id << ")" << std::endl;  	if (ftControllers.find(id) != ftControllers.end()) { diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h index 7043231..561bbf4 100644 --- a/Swift/Controllers/Chat/ChatController.h +++ b/Swift/Controllers/Chat/ChatController.h @@ -29,6 +29,7 @@ namespace Swift {  			virtual void setToJID(const JID& jid);  			virtual void setOnline(bool online);  			virtual void handleNewFileTransferController(FileTransferController* ftc); +			virtual void handleIncomingWhiteboardSession();  			virtual void setContactIsReceivingPresence(bool /*isReceivingPresence*/);  		protected: diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index da96603..380b3ae 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -42,6 +42,7 @@  #include <Swift/Controllers/Settings/SettingsProvider.h>  #include <Swift/Controllers/SettingConstants.h>  #include <Swiften/Client/StanzaChannel.h> +#include <Swiften/Whiteboard/WhiteboardSessionManager.h>  namespace Swift { @@ -71,7 +72,8 @@ ChatsManager::ChatsManager(  		FileTransferOverview* ftOverview,  		XMPPRoster* roster,  		bool eagleMode, -		SettingsProvider* settings) : +		SettingsProvider* settings, +		WhiteboardSessionManager* whiteboardSessionManager) :  			jid_(jid),   			joinMUCWindowFactory_(joinMUCWindowFactory),   			useDelayForLatency_(useDelayForLatency),  @@ -81,7 +83,8 @@ ChatsManager::ChatsManager(  			ftOverview_(ftOverview),  			roster_(roster),  			eagleMode_(eagleMode), -			settings_(settings) { +			settings_(settings), +			whiteboardSessionManager_(whiteboardSessionManager) {  	timerFactory_ = timerFactory;  	eventController_ = eventController;  	stanzaChannel_ = stanzaChannel; @@ -107,6 +110,7 @@ ChatsManager::ChatsManager(  	mucSearchController_ = new MUCSearchController(jid_, mucSearchWindowFactory, iqRouter, profileSettings_);  	mucSearchController_->onMUCSelected.connect(boost::bind(&ChatsManager::handleMUCSelectedAfterSearch, this, _1));  	ftOverview_->onNewFileTransferController.connect(boost::bind(&ChatsManager::handleNewFileTransferController, this, _1)); +	whiteboardSessionManager_->onRequestReceived.connect(boost::bind(&ChatsManager::handleIncomingWhiteboardSession, this, _1));  	roster_->onJIDAdded.connect(boost::bind(&ChatsManager::handleJIDAddedToRoster, this, _1));  	roster_->onJIDRemoved.connect(boost::bind(&ChatsManager::handleJIDRemovedFromRoster, this, _1));  	roster_->onJIDUpdated.connect(boost::bind(&ChatsManager::handleJIDUpdatedInRoster, this, _1)); @@ -655,6 +659,12 @@ void ChatsManager::handleNewFileTransferController(FileTransferController* ftc)  	chatController->activateChatWindow();  } +void ChatsManager::handleIncomingWhiteboardSession(const JID& from) { +	ChatController* chatController = getChatControllerOrCreate(from); +	chatController->handleIncomingWhiteboardSession(); +	chatController->activateChatWindow(); +} +  void ChatsManager::handleRecentActivated(const ChatListWindow::Chat& chat) {  	if (chat.isMUC) {  		/* FIXME: This means that recents requiring passwords will just flat-out not work */ diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h index a8c69c4..3fcd3fb 100644 --- a/Swift/Controllers/Chat/ChatsManager.h +++ b/Swift/Controllers/Chat/ChatsManager.h @@ -47,10 +47,11 @@ namespace Swift {  	class FileTransferController;  	class XMPPRoster;  	class SettingsProvider; +	class WhiteboardSessionManager;  	class ChatsManager {  		public: -			ChatsManager(JID jid, StanzaChannel* stanzaChannel, IQRouter* iqRouter, EventController* eventController, ChatWindowFactory* chatWindowFactory, JoinMUCWindowFactory* joinMUCWindowFactory, NickResolver* nickResolver, PresenceOracle* presenceOracle, PresenceSender* presenceSender, UIEventStream* uiEventStream, ChatListWindowFactory* chatListWindowFactory, bool useDelayForLatency, TimerFactory* timerFactory, MUCRegistry* mucRegistry, EntityCapsProvider* entityCapsProvider, MUCManager* mucManager, MUCSearchWindowFactory* mucSearchWindowFactory, ProfileSettingsProvider* profileSettings, FileTransferOverview* ftOverview, XMPPRoster* roster, bool eagleMode, SettingsProvider* settings); +			ChatsManager(JID jid, StanzaChannel* stanzaChannel, IQRouter* iqRouter, EventController* eventController, ChatWindowFactory* chatWindowFactory, JoinMUCWindowFactory* joinMUCWindowFactory, NickResolver* nickResolver, PresenceOracle* presenceOracle, PresenceSender* presenceSender, UIEventStream* uiEventStream, ChatListWindowFactory* chatListWindowFactory, bool useDelayForLatency, TimerFactory* timerFactory, MUCRegistry* mucRegistry, EntityCapsProvider* entityCapsProvider, MUCManager* mucManager, MUCSearchWindowFactory* mucSearchWindowFactory, ProfileSettingsProvider* profileSettings, FileTransferOverview* ftOverview, XMPPRoster* roster, bool eagleMode, SettingsProvider* settings, WhiteboardSessionManager* whiteboardSessionManager);  			virtual ~ChatsManager();  			void setAvatarManager(AvatarManager* avatarManager);  			void setOnline(bool enabled); @@ -72,6 +73,7 @@ namespace Swift {  			void handleBookmarksReady();  			void handleChatActivity(const JID& jid, const std::string& activity, bool isMUC);  			void handleNewFileTransferController(FileTransferController*); +			void handleIncomingWhiteboardSession(const JID& from);  			void appendRecent(const ChatListWindow::Chat& chat);  			void prependRecent(const ChatListWindow::Chat& chat);  			void setupBookmarks(); @@ -129,5 +131,6 @@ namespace Swift {  			bool eagleMode_;  			bool userWantsReceipts_;  			SettingsProvider* settings_; +			WhiteboardSessionManager* whiteboardSessionManager_;  	};  } diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index bcced6d..e866102 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -293,7 +293,7 @@ void MainController::handleConnected() {  		contactEditController_ = new ContactEditController(rosterController_, client_->getVCardManager(), uiFactory_, uiEventStream_); -		chatsManager_ = new ChatsManager(jid_, client_->getStanzaChannel(), client_->getIQRouter(), eventController_, uiFactory_, uiFactory_, client_->getNickResolver(), client_->getPresenceOracle(), client_->getPresenceSender(), uiEventStream_, uiFactory_, useDelayForLatency_, networkFactories_->getTimerFactory(), client_->getMUCRegistry(), client_->getEntityCapsProvider(), client_->getMUCManager(), uiFactory_, profileSettings_, ftOverview_, client_->getRoster(), !settings_->getSetting(SettingConstants::REMEMBER_RECENT_CHATS), settings_); +		chatsManager_ = new ChatsManager(jid_, client_->getStanzaChannel(), client_->getIQRouter(), eventController_, uiFactory_, uiFactory_, client_->getNickResolver(), client_->getPresenceOracle(), client_->getPresenceSender(), uiEventStream_, uiFactory_, useDelayForLatency_, networkFactories_->getTimerFactory(), client_->getMUCRegistry(), client_->getEntityCapsProvider(), client_->getMUCManager(), uiFactory_, profileSettings_, ftOverview_, client_->getRoster(), !settings_->getSetting(SettingConstants::REMEMBER_RECENT_CHATS), settings_, client_->getWhiteboardSessionManager());  		client_->onMessageReceived.connect(boost::bind(&ChatsManager::handleIncomingMessage, chatsManager_, _1));  		chatsManager_->setAvatarManager(client_->getAvatarManager()); diff --git a/Swift/Controllers/UIEvents/AcceptWhiteboardSessionUIEvent.h b/Swift/Controllers/UIEvents/AcceptWhiteboardSessionUIEvent.h new file mode 100644 index 0000000..93cad03 --- /dev/null +++ b/Swift/Controllers/UIEvents/AcceptWhiteboardSessionUIEvent.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <boost/shared_ptr.hpp> + +#include <Swiften/JID/JID.h> + +#include <Swift/Controllers/UIEvents/UIEvent.h> + +namespace Swift { +	class AcceptWhiteboardSessionUIEvent : public UIEvent { +		typedef boost::shared_ptr<AcceptWhiteboardSessionUIEvent> ref; +	public: +		AcceptWhiteboardSessionUIEvent(const JID& jid) : jid_(jid) {} +		const JID& getContact() const {return jid_;} +	private: +		JID jid_; +	}; +} diff --git a/Swift/Controllers/UIEvents/CancelWhiteboardSessionUIEvent.h b/Swift/Controllers/UIEvents/CancelWhiteboardSessionUIEvent.h new file mode 100644 index 0000000..f5c3b0e --- /dev/null +++ b/Swift/Controllers/UIEvents/CancelWhiteboardSessionUIEvent.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <boost/shared_ptr.hpp> + +#include <Swiften/JID/JID.h> + +#include <Swift/Controllers/UIEvents/UIEvent.h> + +namespace Swift { +	class CancelWhiteboardSessionUIEvent : public UIEvent { +		typedef boost::shared_ptr<CancelWhiteboardSessionUIEvent> ref; +	public: +		CancelWhiteboardSessionUIEvent(const JID& jid) : jid_(jid) {} +		const JID& getContact() const {return jid_;} +	private: +		JID jid_; +	}; +} diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h index b5b1604..66cc8c3 100644 --- a/Swift/Controllers/UIInterfaces/ChatWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatWindow.h @@ -59,6 +59,8 @@ namespace Swift {  			virtual void setFileTransferStatus(std::string, const FileTransferState state, const std::string& msg = "") = 0;  			virtual void addMUCInvitation(const std::string& senderName, const JID& jid, const std::string& reason, const std::string& password, bool direct = true) = 0; +			virtual void addWhiteboardRequest(const JID& from) = 0; +  			// message receipts  			virtual void setMessageReceiptState(const std::string& id, ChatWindow::ReceiptState state) = 0; diff --git a/Swift/Controllers/WhiteboardManager.cpp b/Swift/Controllers/WhiteboardManager.cpp index 25a661c..37c3263 100644 --- a/Swift/Controllers/WhiteboardManager.cpp +++ b/Swift/Controllers/WhiteboardManager.cpp @@ -10,6 +10,8 @@  #include <Swiften/Base/foreach.h>  #include <Swift/Controllers/UIEvents/RequestWhiteboardUIEvent.h> +#include <Swift/Controllers/UIEvents/AcceptWhiteboardSessionUIEvent.h> +#include <Swift/Controllers/UIEvents/CancelWhiteboardSessionUIEvent.h>  #include <Swiften/Client/StanzaChannel.h>  #include <Swiften/Whiteboard/WhiteboardSessionManager.h> @@ -18,6 +20,7 @@ namespace Swift {  	WhiteboardManager::WhiteboardManager(WhiteboardWindowFactory* whiteboardWindowFactory, UIEventStream* uiEventStream, WhiteboardSessionManager* whiteboardSessionManager) : whiteboardWindowFactory_(whiteboardWindowFactory), uiEventStream_(uiEventStream), whiteboardSessionManager_(whiteboardSessionManager) {  		uiEventConnection_ = uiEventStream_->onUIEvent.connect(boost::bind(&WhiteboardManager::handleUIEvent, this, _1)); +		whiteboardSessionManager_->onRequestAccepted.connect(boost::bind(&WhiteboardManager::handleAcceptedRequest, this, _1, _2));  	}  	WhiteboardManager::~WhiteboardManager() { @@ -26,25 +29,48 @@ namespace Swift {  		}  	} -	WhiteboardWindow* WhiteboardManager::getWhiteboardWindowOrCreate(const JID& contact) { -		if (whiteboardWindows_.find(contact) == whiteboardWindows_.end()) { -			return createNewWhiteboardWindow(contact); -		} -		return whiteboardWindows_[contact]; -	} - -	WhiteboardWindow* WhiteboardManager::createNewWhiteboardWindow(const JID& contact) { -		WhiteboardSession* session = whiteboardSessionManager_->createSession(contact); +	WhiteboardWindow* WhiteboardManager::createNewWhiteboardWindow(const JID& contact, WhiteboardSession* session) {  		WhiteboardWindow *window = whiteboardWindowFactory_->createWhiteboardWindow(session);  		whiteboardWindows_[contact] = window;  		return window;  	} +	WhiteboardWindow* WhiteboardManager::findWhiteboardWindow(const JID& contact) { +		if (whiteboardWindows_.find(contact) == whiteboardWindows_.end()) { +			return NULL; +		} +		return whiteboardWindows_[contact]; +	} +  	void WhiteboardManager::handleUIEvent(boost::shared_ptr<UIEvent> event) {  		boost::shared_ptr<RequestWhiteboardUIEvent> whiteboardEvent = boost::dynamic_pointer_cast<RequestWhiteboardUIEvent>(event);  		if (whiteboardEvent) { -			WhiteboardWindow* window = getWhiteboardWindowOrCreate(whiteboardEvent->getContact()); -			window->show(); +			whiteboardSessionManager_->requestSession(whiteboardEvent->getContact()); +		} +		boost::shared_ptr<AcceptWhiteboardSessionUIEvent> sessionAcceptEvent = boost::dynamic_pointer_cast<AcceptWhiteboardSessionUIEvent>(event); +		if (sessionAcceptEvent) { +			acceptSession(sessionAcceptEvent->getContact()); +		} +		boost::shared_ptr<CancelWhiteboardSessionUIEvent> sessionCancelEvent = boost::dynamic_pointer_cast<CancelWhiteboardSessionUIEvent>(event); +		if (sessionCancelEvent) { +			whiteboardSessionManager_->cancelSession(sessionCancelEvent->getContact()); +		} +	} + +	void WhiteboardManager::acceptSession(const JID& from) { +		WhiteboardSession* session = whiteboardSessionManager_->acceptSession(from); +		WhiteboardWindow* window = findWhiteboardWindow(from); +		if (window == NULL) { +			window = createNewWhiteboardWindow(from, session); +		} +		window->show(); +	} + +	void WhiteboardManager::handleAcceptedRequest(const JID& from, WhiteboardSession* session) { +		WhiteboardWindow* window = findWhiteboardWindow(from); +		if (window == NULL) { +			window = createNewWhiteboardWindow(from, session);  		} +		window->show();  	}  } diff --git a/Swift/Controllers/WhiteboardManager.h b/Swift/Controllers/WhiteboardManager.h index 8257f73..2690f36 100644 --- a/Swift/Controllers/WhiteboardManager.h +++ b/Swift/Controllers/WhiteboardManager.h @@ -25,11 +25,13 @@ namespace Swift {  		WhiteboardManager(WhiteboardWindowFactory* whiteboardWindowFactory, UIEventStream* uiEventStream, WhiteboardSessionManager* whiteboardSessionManager);  		~WhiteboardManager(); -		WhiteboardWindow* getWhiteboardWindowOrCreate(const JID& contact); -		WhiteboardWindow* createNewWhiteboardWindow(const JID& contact); +		WhiteboardWindow* createNewWhiteboardWindow(const JID& contact, WhiteboardSession* session);  	private:  		void handleUIEvent(boost::shared_ptr<UIEvent> event); +		void acceptSession(const JID& from); +		void handleAcceptedRequest(const JID& from, WhiteboardSession* session); +		WhiteboardWindow* findWhiteboardWindow(const JID& contact);  	private:  		std::map<JID, WhiteboardWindow*> whiteboardWindows_; | 
 Swift
 Swift