diff options
Diffstat (limited to 'Swift/QtUI/Whiteboard')
-rw-r--r-- | Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp | 27 | ||||
-rw-r--r-- | Swift/QtUI/Whiteboard/QtWhiteboardWindow.h | 10 |
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_; }; } |