summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtUIFactory.cpp5
-rw-r--r--Swift/QtUI/QtUIFactory.h3
-rw-r--r--Swift/QtUI/Roster/QtRosterWidget.cpp5
-rw-r--r--Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp27
-rw-r--r--Swift/QtUI/Whiteboard/QtWhiteboardWindow.h10
5 files changed, 43 insertions, 7 deletions
diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp
index 28c8c7c..d127791 100644
--- a/Swift/QtUI/QtUIFactory.cpp
+++ b/Swift/QtUI/QtUIFactory.cpp
@@ -28,6 +28,7 @@
#include "Whiteboard/QtWhiteboardWindow.h"
#include <Swift/Controllers/Settings/SettingsProviderHierachy.h>
#include <Swift/QtUI/QtUISettingConstants.h>
+#include <Swiften/Client/StanzaChannel.h>
namespace Swift {
@@ -135,8 +136,8 @@ ContactEditWindow* QtUIFactory::createContactEditWindow() {
return new QtContactEditWindow();
}
-WhiteboardWindow* QtUIFactory::createWhiteboardWindow() {
- return new QtWhiteboardWindow();
+WhiteboardWindow* QtUIFactory::createWhiteboardWindow(StanzaChannel* stanzaChannel, const JID& jid) {
+ return new QtWhiteboardWindow(stanzaChannel, jid);
}
void QtUIFactory::createAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocCommandSession> command) {
diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h
index e52c663..0c337f4 100644
--- a/Swift/QtUI/QtUIFactory.h
+++ b/Swift/QtUI/QtUIFactory.h
@@ -24,6 +24,7 @@ namespace Swift {
class QtChatWindowFactory;
class QtChatWindow;
class TimerFactory;
+ class StanzaChannel;
class QtUIFactory : public QObject, public UIFactory {
Q_OBJECT
@@ -42,7 +43,7 @@ namespace Swift {
virtual ProfileWindow* createProfileWindow();
virtual ContactEditWindow* createContactEditWindow();
virtual FileTransferListWidget* createFileTransferListWidget();
- virtual WhiteboardWindow* createWhiteboardWindow();
+ virtual WhiteboardWindow* createWhiteboardWindow(StanzaChannel* stanzaChannel, const JID& jid);
virtual void createAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocCommandSession> command);
private slots:
diff --git a/Swift/QtUI/Roster/QtRosterWidget.cpp b/Swift/QtUI/Roster/QtRosterWidget.cpp
index 2fe7f33..a7767fe 100644
--- a/Swift/QtUI/Roster/QtRosterWidget.cpp
+++ b/Swift/QtUI/Roster/QtRosterWidget.cpp
@@ -15,6 +15,7 @@
#include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h"
#include "Swift/Controllers/UIEvents/RenameGroupUIEvent.h"
#include "Swift/Controllers/UIEvents/SendFileUIEvent.h"
+#include "Swift/Controllers/UIEvents/RequestWhiteboardUIEvent.h"
#include "QtContactEditWindow.h"
#include "Swift/Controllers/Roster/ContactRosterItem.h"
#include "Swift/Controllers/Roster/GroupRosterItem.h"
@@ -62,6 +63,7 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) {
sendFile = contextMenu.addAction(tr("Send File"));
}
#endif
+ QAction* startWhiteboardChat = contextMenu.addAction(tr("Start Whiteboard Chat"));
QAction* result = contextMenu.exec(event->globalPos());
if (result == editContact) {
eventStream_->send(boost::make_shared<RequestContactEditorUIEvent>(contact->getJID()));
@@ -79,6 +81,9 @@ void QtRosterWidget::contextMenuEvent(QContextMenuEvent* event) {
}
}
#endif
+ else if (result == startWhiteboardChat) {
+ eventStream_->send(boost::make_shared<RequestWhiteboardUIEvent>(contact->getJID()));
+ }
}
else if (GroupRosterItem* group = dynamic_cast<GroupRosterItem*>(item)) {
QAction* renameGroupAction = contextMenu.addAction(tr("Rename"));
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_;
};
}