diff options
author | Kevin Smith <git@kismith.co.uk> | 2009-11-26 17:31:53 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2009-11-26 17:46:21 (GMT) |
commit | eebdef9a7724ff7fa86a5d1cca37759d37bbb336 (patch) | |
tree | 7dd76b8e5d364eb1b019b2511a839a9eac8397e4 /Swift/Controllers | |
parent | 39e58e4593f54a65f810e73728fe2490958fcba2 (diff) | |
download | swift-contrib-eebdef9a7724ff7fa86a5d1cca37759d37bbb336.zip swift-contrib-eebdef9a7724ff7fa86a5d1cca37759d37bbb336.tar.bz2 |
Plumbing to show a dummy XMLConsoleWidget in the chat tabs.
This should all work now, and the XMLConsoleController needs to talk to the QtXMLConsoleWidget through the XMLConsoleWidget interface.
Resolves: #256
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/MainController.cpp | 16 | ||||
-rw-r--r-- | Swift/Controllers/MainController.h | 7 | ||||
-rw-r--r-- | Swift/Controllers/SConscript | 4 | ||||
-rw-r--r-- | Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h | 9 | ||||
-rw-r--r-- | Swift/Controllers/UIEvents/UIEvent.cpp | 7 | ||||
-rw-r--r-- | Swift/Controllers/UIEvents/UIEvent.h | 8 | ||||
-rw-r--r-- | Swift/Controllers/UIEvents/UIEventStream.h | 15 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/LoginWindow.h (renamed from Swift/Controllers/LoginWindow.h) | 0 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/LoginWindowFactory.h (renamed from Swift/Controllers/LoginWindowFactory.h) | 5 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/XMLConsoleWidget.h | 7 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/XMLConsoleWidgetFactory.h | 12 | ||||
-rw-r--r-- | Swift/Controllers/XMLConsoleController.cpp | 21 | ||||
-rw-r--r-- | Swift/Controllers/XMLConsoleController.h | 21 |
13 files changed, 124 insertions, 8 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index e030a31..0705eb4 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -10,8 +10,8 @@ #include "Swift/Controllers/ChatController.h" #include "Swift/Controllers/ChatWindowFactory.h" #include "Swift/Controllers/EventController.h" -#include "Swift/Controllers/LoginWindow.h" -#include "Swift/Controllers/LoginWindowFactory.h" +#include "Swift/Controllers/UIInterfaces/LoginWindow.h" +#include "Swift/Controllers/UIInterfaces/LoginWindowFactory.h" #include "Swift/Controllers/MainWindow.h" #include "Swift/Controllers/MainWindowFactory.h" #include "Swift/Controllers/MUCController.h" @@ -22,7 +22,10 @@ #include "Swift/Controllers/SoundPlayer.h" #include "Swift/Controllers/SystemTray.h" #include "Swift/Controllers/SystemTrayController.h" +#include "Swift/Controllers/XMLConsoleController.h" #include "Swift/Controllers/XMPPRosterController.h" +#include "Swift/Controllers/UIInterfaces/XMLConsoleWidgetFactory.h" +#include "Swift/Controllers/UIEvents/UIEventStream.h" #include "Swiften/Base/foreach.h" #include "Swiften/Base/String.h" #include "Swiften/Client/Client.h" @@ -60,11 +63,12 @@ static const String CLIENT_NODE = "http://swift.im"; typedef std::pair<JID, ChatController*> JIDChatControllerPair; typedef std::pair<JID, MUCController*> JIDMUCControllerPair; -MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory *treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer) +MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory *treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer, XMLConsoleWidgetFactory* xmlConsoleWidgetFactory) : timerFactory_(&boostIOServiceThread_.getIOService()), idleDetector_(&idleQuerier_, &timerFactory_, 100), client_(NULL), presenceSender_(NULL), chatWindowFactory_(chatWindowFactory), mainWindowFactory_(mainWindowFactory), loginWindowFactory_(loginWindowFactory), treeWidgetFactory_(treeWidgetFactory), settings_(settings), xmppRosterController_(NULL), rosterController_(NULL), loginWindow_(NULL), clientVersionResponder_(NULL), nickResolver_(NULL), discoResponder_(NULL) { application_ = application; presenceOracle_ = NULL; avatarManager_ = NULL; + uiEventStream_ = new UIEventStream(); avatarStorage_ = new AvatarFileStorage(application_->getAvatarDir()); @@ -72,7 +76,7 @@ MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowF eventController_->onEventQueueLengthChange.connect(boost::bind(&MainController::handleEventQueueLengthChange, this, _1)); systemTrayController_ = new SystemTrayController(eventController_, systemTray); soundEventController_ = new SoundEventController(eventController_, soundPlayer, settings->getBoolSetting("playSounds", true)); - loginWindow_ = loginWindowFactory_->createLoginWindow(); + loginWindow_ = loginWindowFactory_->createLoginWindow(uiEventStream_); foreach (String profile, settings->getAvailableProfiles()) { ProfileSettingsProvider* profileSettings = new ProfileSettingsProvider(profile, settings); loginWindow_->addAvailableAccount(profileSettings->getStringSetting("jid"), profileSettings->getStringSetting("pass"), profileSettings->getStringSetting("certificate")); @@ -83,6 +87,8 @@ MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowF idleDetector_.setIdleTimeSeconds(600); idleDetector_.onIdleChanged.connect(boost::bind(&MainController::handleInputIdleChanged, this, _1)); + + xmlConsoleController_ = new XMLConsoleController(uiEventStream_, xmlConsoleWidgetFactory); } MainController::~MainController() { @@ -95,6 +101,8 @@ MainController::~MainController() { delete systemTrayController_; delete soundEventController_; delete avatarStorage_; + delete xmlConsoleController_; + delete uiEventStream_; resetClient(); } diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 78e49a2..c260f33 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -47,10 +47,13 @@ namespace Swift { class SystemTrayController; class SoundEventController; class SoundPlayer; + class XMLConsoleController; + class UIEventStream; + class XMLConsoleWidgetFactory; class MainController : public MUCRegistry { public: - MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory* treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer); + MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory* treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer, XMLConsoleWidgetFactory* xmlConsoleWidgetFactory); ~MainController(); @@ -103,6 +106,8 @@ namespace Swift { SoftwareVersionResponder* clientVersionResponder_; NickResolver* nickResolver_; DiscoInfoResponder* discoResponder_; + UIEventStream* uiEventStream_; + XMLConsoleController* xmlConsoleController_; boost::shared_ptr<CapsInfo> capsInfo_; std::map<JID, MUCController*> mucControllers_; std::map<JID, ChatController*> chatControllers_; diff --git a/Swift/Controllers/SConscript b/Swift/Controllers/SConscript index dfcf878..6c9b049 100644 --- a/Swift/Controllers/SConscript +++ b/Swift/Controllers/SConscript @@ -17,7 +17,9 @@ myenv.StaticLibrary("SwiftControllers", [ "MUCController.cpp", "EventController.cpp", "SoundEventController.cpp", - "SystemTrayController.cpp" + "SystemTrayController.cpp", + "XMLConsoleController.cpp", + "UIEvents/UIEvent.cpp" ]) env.Append(UNITTEST_SOURCES = [ diff --git a/Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h b/Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h new file mode 100644 index 0000000..63492b3 --- /dev/null +++ b/Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h @@ -0,0 +1,9 @@ +#pragma once + +#include "Swift/Controllers/UIEvents/UIEvent.h" + +namespace Swift { + class RequestXMLConsoleUIEvent : public UIEvent { + + }; +} diff --git a/Swift/Controllers/UIEvents/UIEvent.cpp b/Swift/Controllers/UIEvents/UIEvent.cpp new file mode 100644 index 0000000..7d29a19 --- /dev/null +++ b/Swift/Controllers/UIEvents/UIEvent.cpp @@ -0,0 +1,7 @@ +#include "Swift/Controllers/UIEvents/UIEvent.h" + +namespace Swift { +UIEvent::~UIEvent() { + +} +} diff --git a/Swift/Controllers/UIEvents/UIEvent.h b/Swift/Controllers/UIEvents/UIEvent.h new file mode 100644 index 0000000..7e06255 --- /dev/null +++ b/Swift/Controllers/UIEvents/UIEvent.h @@ -0,0 +1,8 @@ +#pragma once + +namespace Swift { + class UIEvent { + public: + virtual ~UIEvent(); + }; +} diff --git a/Swift/Controllers/UIEvents/UIEventStream.h b/Swift/Controllers/UIEvents/UIEventStream.h new file mode 100644 index 0000000..a20c578 --- /dev/null +++ b/Swift/Controllers/UIEvents/UIEventStream.h @@ -0,0 +1,15 @@ +#pragma once + +#include <boost/signals.hpp> +#include <boost/shared_ptr.hpp> + + +#include "Swift/Controllers/UIEvents/UIEvent.h" + +namespace Swift { + class UIEventStream { + public: + boost::signal<void (boost::shared_ptr<UIEvent>)> onUIEvent; + void send(boost::shared_ptr<UIEvent> event) {onUIEvent(event);}; + }; +} diff --git a/Swift/Controllers/LoginWindow.h b/Swift/Controllers/UIInterfaces/LoginWindow.h index cfa20c7..cfa20c7 100644 --- a/Swift/Controllers/LoginWindow.h +++ b/Swift/Controllers/UIInterfaces/LoginWindow.h diff --git a/Swift/Controllers/LoginWindowFactory.h b/Swift/Controllers/UIInterfaces/LoginWindowFactory.h index 79ad5c0..d2dc31b 100644 --- a/Swift/Controllers/LoginWindowFactory.h +++ b/Swift/Controllers/UIInterfaces/LoginWindowFactory.h @@ -5,7 +5,8 @@ namespace Swift { class LoginWindow; - class String; + class String; + class UIEventStream; class LoginWindowFactory { public: @@ -14,7 +15,7 @@ namespace Swift { /** * Transfers ownership of result. */ - virtual LoginWindow* createLoginWindow() = 0; + virtual LoginWindow* createLoginWindow(UIEventStream* uiEventStream) = 0; }; } diff --git a/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h b/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h new file mode 100644 index 0000000..69628df --- /dev/null +++ b/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h @@ -0,0 +1,7 @@ +#pragma once + +namespace Swift { + class XMLConsoleWidget { + + }; +} diff --git a/Swift/Controllers/UIInterfaces/XMLConsoleWidgetFactory.h b/Swift/Controllers/UIInterfaces/XMLConsoleWidgetFactory.h new file mode 100644 index 0000000..fa7707a --- /dev/null +++ b/Swift/Controllers/UIInterfaces/XMLConsoleWidgetFactory.h @@ -0,0 +1,12 @@ +#pragma once + +#include "Swift/Controllers/UIInterfaces/XMLConsoleWidget.h" + +namespace Swift { + class UIEventStream; + class XMLConsoleWidgetFactory { + public: + virtual XMLConsoleWidget* createXMLConsoleWidget() = 0; + virtual ~XMLConsoleWidgetFactory() {}; + }; +} diff --git a/Swift/Controllers/XMLConsoleController.cpp b/Swift/Controllers/XMLConsoleController.cpp new file mode 100644 index 0000000..8bd79ed --- /dev/null +++ b/Swift/Controllers/XMLConsoleController.cpp @@ -0,0 +1,21 @@ +#include "Swift/Controllers/XMLConsoleController.h" + +#include "Swift/Controllers/UIInterfaces/XMLConsoleWidgetFactory.h" + +#include "Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h" + +namespace Swift { +XMLConsoleController::XMLConsoleController(UIEventStream* uiEventStream, XMLConsoleWidgetFactory* xmlConsoleWidgetFactory) { + uiEventStream_ = uiEventStream; + xmlConsoleWidgetFactory_ = xmlConsoleWidgetFactory; + uiEventStream_->onUIEvent.connect(boost::bind(&XMLConsoleController::handleUIEvent, this, _1)); +} + +void XMLConsoleController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) { + boost::shared_ptr<RequestXMLConsoleUIEvent> event = boost::dynamic_pointer_cast<RequestXMLConsoleUIEvent>(rawEvent); + if (event != NULL) { + xmlConsoleWidget_ = xmlConsoleWidgetFactory_->createXMLConsoleWidget(); + } +} + +} diff --git a/Swift/Controllers/XMLConsoleController.h b/Swift/Controllers/XMLConsoleController.h new file mode 100644 index 0000000..f97e6c1 --- /dev/null +++ b/Swift/Controllers/XMLConsoleController.h @@ -0,0 +1,21 @@ +#pragma once + +#include <boost/signals.hpp> +#include <boost/bind.hpp> +#include <boost/shared_ptr.hpp> + +#include "Swift/Controllers/UIEvents/UIEventStream.h" + +namespace Swift { + class XMLConsoleWidgetFactory; + class XMLConsoleWidget; + class XMLConsoleController { + public: + XMLConsoleController(UIEventStream* uiEventStream, XMLConsoleWidgetFactory* xmlConsoleWidgetFactory); + private: + void handleUIEvent(boost::shared_ptr<UIEvent> event); + UIEventStream* uiEventStream_; + XMLConsoleWidgetFactory* xmlConsoleWidgetFactory_; + XMLConsoleWidget* xmlConsoleWidget_; + }; +} |