summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-06-02 16:23:59 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-06-02 16:23:59 (GMT)
commit7520c7fed383d4f7631f5572ef40379022126264 (patch)
treeee87b26bb923d0289a670defce96e2012f3623e3 /Swift/Controllers/WhiteboardController.cpp
parente8ab1af885ff61715ab0350c3cb22ed6988a082a (diff)
downloadswift-contrib-7520c7fed383d4f7631f5572ef40379022126264.zip
swift-contrib-7520c7fed383d4f7631f5572ef40379022126264.tar.bz2
Added whiteboard controller with simple sharing
Whiteboard controller is handled in ChatController only for testing purposes.
Diffstat (limited to 'Swift/Controllers/WhiteboardController.cpp')
-rw-r--r--Swift/Controllers/WhiteboardController.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/Swift/Controllers/WhiteboardController.cpp b/Swift/Controllers/WhiteboardController.cpp
new file mode 100644
index 0000000..9228901
--- /dev/null
+++ b/Swift/Controllers/WhiteboardController.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012 Mateusz Piękos
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <boost/bind.hpp>
+
+#include "Swift/Controllers/WhiteboardController.h"
+
+#include <Swift/Controllers/UIInterfaces/WhiteboardWindowFactory.h>
+#include <Swift/Controllers/UIInterfaces/WhiteboardWindow.h>
+
+#include <Swiften/Elements/WhiteboardPayload.h>
+
+#include <iostream>
+
+namespace Swift {
+ WhiteboardController::WhiteboardController(StanzaChannel* stanzaChannel, const JID& toJID, WhiteboardWindowFactory* whiteboardWindowFactory) : stanzaChannel_(stanzaChannel), toJID_(toJID) {
+ whiteboardWindow_ = whiteboardWindowFactory->createWhiteboardWindow();
+ whiteboardWindow_->show();
+ whiteboardWindow_->onItemAdd.connect(boost::bind(&WhiteboardController::handleItemChange, this, _1));
+ }
+
+ WhiteboardController::~WhiteboardController() {
+ delete whiteboardWindow_;
+ }
+
+ void WhiteboardController::handleIncomingMessage(boost::shared_ptr<MessageEvent> message) {
+ boost::shared_ptr<WhiteboardPayload> wb = message->getStanza()->getPayload<WhiteboardPayload>();
+ if(wb) {
+ whiteboardWindow_->addItem(wb->getData());
+ }
+ }
+
+ void WhiteboardController::handleItemChange(std::string item) {
+ boost::shared_ptr<Message> mes(new Message());
+ mes->setTo(toJID_);
+ boost::shared_ptr<WhiteboardPayload> wbPayload(new WhiteboardPayload);
+ wbPayload->setData(item);
+// mes->setType(Swift::Message::Chat);
+ mes->addPayload(wbPayload);
+ stanzaChannel_->sendMessage(mes);
+ }
+}