diff options
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/MainController.cpp | 16 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/XMLConsoleWidget.h | 5 | ||||
-rw-r--r-- | Swift/Controllers/XMLConsoleController.cpp | 12 | ||||
-rw-r--r-- | Swift/Controllers/XMLConsoleController.h | 6 |
4 files changed, 27 insertions, 12 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 2e640e0..8800da0 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -45,16 +45,6 @@ #include "Swiften/StringCodecs/SHA1.h" #include "Swiften/StringCodecs/Hexify.h" -namespace { - void printIncomingData(const Swift::String& data) { - std::cout << "<- " << data << std::endl; - } - - void printOutgoingData(const Swift::String& data) { - std::cout << "-> " << data << std::endl; - } -} - namespace Swift { static const String CLIENT_NAME = "Swift"; @@ -273,8 +263,10 @@ void MainController::performLoginFromCachedCredentials() { if (!client_) { client_ = new Swift::Client(jid_, password_); presenceSender_ = new PresenceSender(client_); - //client_->onDataRead.connect(&printIncomingData); - //client_->onDataWritten.connect(&printOutgoingData); + client_->onDataRead.connect(boost::bind( + &XMLConsoleController::handleDataRead, xmlConsoleController_, _1)); + client_->onDataWritten.connect(boost::bind( + &XMLConsoleController::handleDataWritten, xmlConsoleController_, _1)); if (!certificateFile_.isEmpty()) { client_->setCertificate(certificateFile_); } diff --git a/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h b/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h index e333d97..eab29a8 100644 --- a/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h +++ b/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h @@ -1,10 +1,15 @@ #pragma once namespace Swift { + class String; + class XMLConsoleWidget { public: virtual ~XMLConsoleWidget(); + virtual void handleDataRead(const String& data) = 0; + virtual void handleDataWritten(const String& data) = 0; + virtual void show() = 0; virtual void activate() = 0; }; diff --git a/Swift/Controllers/XMLConsoleController.cpp b/Swift/Controllers/XMLConsoleController.cpp index 4629573..7de5b94 100644 --- a/Swift/Controllers/XMLConsoleController.cpp +++ b/Swift/Controllers/XMLConsoleController.cpp @@ -24,4 +24,16 @@ void XMLConsoleController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) { } } +void XMLConsoleController::handleDataRead(const String& data) { + if (xmlConsoleWidget) { + xmlConsoleWidget->handleDataRead(data); + } +} + +void XMLConsoleController::handleDataWritten(const String& data) { + if (xmlConsoleWidget) { + xmlConsoleWidget->handleDataWritten(data); + } +} + } diff --git a/Swift/Controllers/XMLConsoleController.h b/Swift/Controllers/XMLConsoleController.h index 52a8269..134bf0d 100644 --- a/Swift/Controllers/XMLConsoleController.h +++ b/Swift/Controllers/XMLConsoleController.h @@ -7,13 +7,19 @@ #include "Swift/Controllers/UIEvents/UIEventStream.h" namespace Swift { + class String; class XMLConsoleWidgetFactory; class XMLConsoleWidget; + class XMLConsoleController { public: XMLConsoleController(UIEventStream* uiEventStream, XMLConsoleWidgetFactory* xmlConsoleWidgetFactory); ~XMLConsoleController(); + public: + void handleDataRead(const String& data); + void handleDataWritten(const String& data); + private: void handleUIEvent(boost::shared_ptr<UIEvent> event); |