summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-06-05 13:49:26 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-06-05 13:49:26 (GMT)
commit21e358a55e6eee1036fe95993c5715382d08c0c8 (patch)
treec512cb0b6640c1fee942cf55fa76954a8100568c /Swift/QtUI/Whiteboard
parentdfeab948530982d10a7754a93a37cd8422888378 (diff)
downloadswift-contrib-21e358a55e6eee1036fe95993c5715382d08c0c8.zip
swift-contrib-21e358a55e6eee1036fe95993c5715382d08c0c8.tar.bz2
Moved whiteboard handling to WhiteboardManager
Diffstat (limited to 'Swift/QtUI/Whiteboard')
-rw-r--r--Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp27
-rw-r--r--Swift/QtUI/Whiteboard/QtWhiteboardWindow.h10
2 files changed, 33 insertions, 4 deletions
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
index 19d64ae..b991e52 100644
--- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
+++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp
@@ -6,12 +6,17 @@
#include "QtWhiteboardWindow.h"
-#include<iostream>
+#include <iostream>
+
+#include <boost/bind.hpp>
+
+#include <Swiften/Client/StanzaChannel.h>
+#include <Swiften/Elements/WhiteboardPayload.h>
using namespace std;
namespace Swift {
- QtWhiteboardWindow::QtWhiteboardWindow() : QWidget() {
+ QtWhiteboardWindow::QtWhiteboardWindow(StanzaChannel* stanzaChannel, const JID& jid) : QWidget(), stanzaChannel_(stanzaChannel), jid_(jid) {
layout = new QVBoxLayout(this);
hLayout = new QHBoxLayout;
sidebarLayout = new QVBoxLayout;
@@ -115,6 +120,15 @@ namespace Swift {
hLayout->addLayout(sidebarLayout);
layout->addLayout(hLayout);
this->setLayout(layout);
+
+ stanzaChannel_->onMessageReceived.connect(boost::bind(&QtWhiteboardWindow::handleIncommingMessage, this, _1));
+ }
+
+ void QtWhiteboardWindow::handleIncommingMessage(boost::shared_ptr<Message> message) {
+ boost::shared_ptr<WhiteboardPayload> wb = message->getPayload<WhiteboardPayload>();
+ if(wb) {
+ addItem(wb->getData());
+ }
}
void QtWhiteboardWindow::addItem(const std::string& item) {
@@ -245,7 +259,14 @@ namespace Swift {
}
if (!serialized.empty()) {
cout << "serialized: " << serialized << endl;
- onItemAdd(serialized);
+ boost::shared_ptr<Message> mes(new Message());
+ mes->setTo(jid_);
+ boost::shared_ptr<WhiteboardPayload> wbPayload(new WhiteboardPayload);
+ wbPayload->setData(serialized);
+// mes->setType(Swift::Message::Chat);
+ mes->addPayload(wbPayload);
+ stanzaChannel_->sendMessage(mes);
}
+
}
}
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h
index f472629..9ced322 100644
--- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h
+++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h
@@ -7,6 +7,8 @@
#pragma once
#include <Swift/Controllers/UIInterfaces/WhiteboardWindow.h>
+#include <Swiften/Elements/Message.h>
+#include "Swiften/JID/JID.h"
#include <QWidget>
#include <QGraphicsView>
@@ -23,11 +25,14 @@
#include "GView.h"
namespace Swift {
+ class StanzaChannel;
+
class QtWhiteboardWindow : public QWidget, public WhiteboardWindow
{
Q_OBJECT;
public:
- QtWhiteboardWindow();
+ QtWhiteboardWindow(StanzaChannel *stanzaChannel, const JID& jid);
+ void handleIncommingMessage(boost::shared_ptr<Message> message);
void addItem(const std::string& item);
void show();
@@ -67,5 +72,8 @@ namespace Swift {
QToolButton* textButton;
QToolButton* polygonButton;
QToolButton* selectButton;
+
+ StanzaChannel* stanzaChannel_;
+ JID jid_;
};
}