summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers/ScreenSharing')
-rw-r--r--Swift/Controllers/ScreenSharing/ScreenSharingController.cpp114
-rw-r--r--Swift/Controllers/ScreenSharing/ScreenSharingController.h41
-rw-r--r--Swift/Controllers/ScreenSharing/ScreenSharingOverview.cpp43
-rw-r--r--Swift/Controllers/ScreenSharing/ScreenSharingOverview.h45
4 files changed, 187 insertions, 56 deletions
diff --git a/Swift/Controllers/ScreenSharing/ScreenSharingController.cpp b/Swift/Controllers/ScreenSharing/ScreenSharingController.cpp
index fd3357d..b932765 100644
--- a/Swift/Controllers/ScreenSharing/ScreenSharingController.cpp
+++ b/Swift/Controllers/ScreenSharing/ScreenSharingController.cpp
@@ -12,82 +12,118 @@
#include <Swiften/ScreenSharing/Image.h>
#include <Swiften/Network/TimerFactory.h>
#include <Swiften/Network/Timer.h>
-#include "Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.h"
+#include "Swift/Controllers/ScreenSharing/DesktopScreenGrabber.h"
#include "Swift/Controllers/UIInterfaces/RemoteScreenWindowFactory.h"
#include "Swift/Controllers/UIInterfaces/RemoteScreenWindow.h"
+#include "Swift/Controllers/UIInterfaces/ChatWindow.h"
+#include "Swift/Controllers/Intl.h"
#include <boost/bind.hpp>
namespace Swift {
-ScreenSharingController::ScreenSharingController(ScreenSharingManager *screenSharingManager, RemoteScreenWindowFactory* remoteScreenViewerFactory, TimerFactory* timerFactory)
- : screenSharingManager(screenSharingManager), remoteScreenWindowFactory(remoteScreenViewerFactory), remoteScreenWindow(0),
- grabTimer(timerFactory->createTimer(500)), screenGrabber(new QtDesktopScreenGrabber)
+ScreenSharingController::ScreenSharingController(ScreenSharingManager* screenSharingManager, TimerFactory* timerFactory, DesktopScreenGrabber* desktopScreenGrabber, const JID& to)
+ : screenGrabber(desktopScreenGrabber), grabTimer(timerFactory->createTimer(500)), remoteScreenWindowFactory(0),
+ remoteScreenWindow(0), otherParty(to), incoming(false), chatWindow(0)
{
- screenSharingManager->onIncomingScreenSharing.connect(boost::bind(&ScreenSharingController::handleIncomingScreenSharing, this, _1));
- grabTimer->onTick.connect(boost::bind(&ScreenSharingController::handleGrabTimerTick, this));
+ OutgoingScreenSharing::ref oss = screenSharingManager->createOutgoingScreenSharing(to);
+ if (oss) {
+ oss->onReady.connect(boost::bind(&ScreenSharingController::handleReady, this));
+ oss->onFinished.connect(boost::bind(&ScreenSharingController::handleFinished, this));
+ oss->onStateChange.connect(boost::bind(&ScreenSharingController::handleStateChange, this, _1));
+ const Image& image = screenGrabber->grab();
+ oss->start(image.width, image.height);
+ screenSharing = oss;
+ } else {
+ std::cerr << "Screen sharing not supported!" << std::endl;
+ }
+}
+
+ScreenSharingController::ScreenSharingController(boost::shared_ptr<IncomingScreenSharing> screenSharing, RemoteScreenWindowFactory* remoteScreenWindowFactory)
+ : screenGrabber(0), remoteScreenWindowFactory(remoteScreenWindowFactory), remoteScreenWindow(0),
+ screenSharing(screenSharing), otherParty(screenSharing->getSender()), incoming(true), chatWindow(0)
+{
+ screenSharing->onFinished.connect(boost::bind(&ScreenSharingController::handleFinished, this));
+ screenSharing->onStateChange.connect(boost::bind(&ScreenSharingController::handleStateChange, this, _1));
}
ScreenSharingController::~ScreenSharingController()
{
- grabTimer->onTick.disconnect(boost::bind(&ScreenSharingController::handleGrabTimerTick, this));
+ screenSharing->onStateChange.disconnect(boost::bind(&ScreenSharingController::handleStateChange, this, _1));
delete remoteScreenWindow;
}
-boost::shared_ptr<OutgoingScreenSharing> ScreenSharingController::createOugoingScreenSharing(const JID& to)
+const JID& ScreenSharingController::getOtherParty() const
{
- if (!oss) {
- oss = screenSharingManager->createOutgoingScreenSharing(to);
- if (oss) {
- oss->onReady.connect(boost::bind(&ScreenSharingController::handleOssReady, this));
- oss->onFinished.connect(boost::bind(&ScreenSharingController::handleOutgoingFinished, this));
- const Image& image = screenGrabber->grab();
- oss->start(image.width, image.height);
+ return otherParty;
+}
+
+std::string ScreenSharingController::setChatWindow(ChatWindow* wnd, std::string nickname) {
+ chatWindow = wnd;
+ uiID = wnd->addScreenSharing((incoming ? nickname : QT_TRANSLATE_NOOP("", "me")), incoming);
+ return uiID;
+}
+
+void ScreenSharingController::accept()
+{
+ if (incoming) {
+ if (IncomingScreenSharing::ref iss = boost::dynamic_pointer_cast<IncomingScreenSharing>(screenSharing)) {
+ iss->accept();
+ remoteScreenWindow = remoteScreenWindowFactory->createRemoteScreenViewer(iss);
+ remoteScreenWindow->onStopRequest.connect(boost::bind(&ScreenSharingController::handleWindowStopRequest, this));
}
- return oss;
}
- return boost::shared_ptr<OutgoingScreenSharing>();
}
-void ScreenSharingController::handleIncomingScreenSharing(boost::shared_ptr<IncomingScreenSharing> incomingScreenSharing)
+void ScreenSharingController::cancel()
{
- if (iss) {
- incomingScreenSharing->cancel();
- } else {
- iss = incomingScreenSharing;
- iss->accept();
- iss->onFinished.connect(boost::bind(&ScreenSharingController::handleIncomingFinished, this));
- remoteScreenWindow = remoteScreenWindowFactory->createRemoteScreenViewer(iss);
-// onNewIncomingScreenSharing(iss);
- }
+ screenSharing->cancel();
+}
+
+void ScreenSharingController::stop()
+{
+ screenSharing->stop();
}
void ScreenSharingController::handleGrabTimerTick()
{
- if (oss) {
- grabTimer->start();
- oss->addImage(screenGrabber->grab());
+ if (screenSharing) {
+ if (OutgoingScreenSharing::ref oss = boost::dynamic_pointer_cast<OutgoingScreenSharing>(screenSharing)) {
+ grabTimer->start();
+ oss->addImage(screenGrabber->grab());
+ }
+ } else {
+ grabTimer->onTick.disconnect(boost::bind(&ScreenSharingController::handleGrabTimerTick, this));
}
}
-void ScreenSharingController::handleOssReady()
+void ScreenSharingController::handleReady()
{
- handleGrabTimerTick();
+ if (OutgoingScreenSharing::ref oss = boost::dynamic_pointer_cast<OutgoingScreenSharing>(screenSharing)) {
+ oss->onReady.disconnect(boost::bind(&ScreenSharingController::handleReady, this));
+ grabTimer->onTick.connect(boost::bind(&ScreenSharingController::handleGrabTimerTick, this));
+ handleGrabTimerTick();
+ }
}
-void ScreenSharingController::handleIncomingFinished()
+void ScreenSharingController::handleFinished()
{
- iss->onFinished.disconnect(boost::bind(&ScreenSharingController::handleIncomingFinished, this));
- iss.reset();
+ screenSharing->onFinished.disconnect(boost::bind(&ScreenSharingController::handleFinished, this));
+ screenSharing.reset();
delete remoteScreenWindow;
remoteScreenWindow = 0;
}
-void ScreenSharingController::handleOutgoingFinished()
+void ScreenSharingController::handleStateChange(ScreenSharing::SCState state)
+{
+ if (chatWindow)
+ chatWindow->setScreenSharingStatus(uiID, state);
+}
+
+void ScreenSharingController::handleWindowStopRequest()
{
- oss->onReady.disconnect(boost::bind(&ScreenSharingController::handleOssReady, this));
- oss->onFinished.disconnect(boost::bind(&ScreenSharingController::handleOutgoingFinished, this));
- oss.reset();
+ remoteScreenWindow->onStopRequest.disconnect(boost::bind(&ScreenSharingController::handleWindowStopRequest, this));
+ screenSharing->stop();
}
}
diff --git a/Swift/Controllers/ScreenSharing/ScreenSharingController.h b/Swift/Controllers/ScreenSharing/ScreenSharingController.h
index 6bae132..11b4504 100644
--- a/Swift/Controllers/ScreenSharing/ScreenSharingController.h
+++ b/Swift/Controllers/ScreenSharing/ScreenSharingController.h
@@ -6,46 +6,53 @@
#pragma once
-#include <Swiften/Base/boost_bsignals.h>
+#include <Swiften/JID/JID.h>
+#include <Swiften/ScreenSharing/ScreenSharing.h>
#include <boost/shared_ptr.hpp>
namespace Swift {
+ class ScreenSharing;
class ScreenSharingManager;
class IncomingScreenSharing;
- class OutgoingScreenSharing;
class Timer;
class TimerFactory;
class DesktopScreenGrabber;
class RemoteScreenWindowFactory;
class RemoteScreenWindow;
- class JID;
+ class ChatWindow;
class ScreenSharingController {
public:
- ScreenSharingController(ScreenSharingManager* screenSharingManager, RemoteScreenWindowFactory* remoteScreenWindowFactory, TimerFactory* timerFactory);
+ ScreenSharingController(ScreenSharingManager* screenSharingManager, TimerFactory* timerFactory, DesktopScreenGrabber* desktopScreenGrabber, const JID& to);
+ ScreenSharingController(boost::shared_ptr<IncomingScreenSharing> screenSharing, RemoteScreenWindowFactory* remoteScreenWindowFactory);
~ScreenSharingController();
- boost::shared_ptr<OutgoingScreenSharing> createOugoingScreenSharing(const JID& to);
+ const JID& getOtherParty() const;
- public:
- boost::signal<void (boost::shared_ptr<IncomingScreenSharing>)> onNewIncomingScreenSharing;
+ std::string setChatWindow(ChatWindow *wnd, std::string nickname);
+
+ void accept();
+ void cancel();
+ void stop();
private:
- void handleIncomingScreenSharing(boost::shared_ptr<IncomingScreenSharing> incomingScreenSharing);
void handleGrabTimerTick();
- void handleOssReady();
- void handleIncomingFinished();
- void handleOutgoingFinished();
+ void handleReady();
+ void handleFinished();
+ void handleStateChange(ScreenSharing::SCState state);
+ void handleWindowStopRequest();
private:
- ScreenSharingManager* screenSharingManager;
+ DesktopScreenGrabber* screenGrabber;
+ boost::shared_ptr<Timer> grabTimer;
RemoteScreenWindowFactory* remoteScreenWindowFactory;
-
RemoteScreenWindow* remoteScreenWindow;
- boost::shared_ptr<Timer> grabTimer;
- DesktopScreenGrabber* screenGrabber;
- boost::shared_ptr<IncomingScreenSharing> iss;
- boost::shared_ptr<OutgoingScreenSharing> oss;
+
+ boost::shared_ptr<ScreenSharing> screenSharing;
+ JID otherParty;
+ bool incoming;
+ std::string uiID;
+ ChatWindow* chatWindow;
};
}
diff --git a/Swift/Controllers/ScreenSharing/ScreenSharingOverview.cpp b/Swift/Controllers/ScreenSharing/ScreenSharingOverview.cpp
new file mode 100644
index 0000000..91f75b9
--- /dev/null
+++ b/Swift/Controllers/ScreenSharing/ScreenSharingOverview.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012 Yoann Blein
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include "ScreenSharingOverview.h"
+
+#include "Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.h"
+#include "Swift/Controllers/ScreenSharing/ScreenSharingController.h"
+#include <Swiften/ScreenSharing/ScreenSharingManager.h>
+
+#include <boost/bind.hpp>
+
+namespace Swift {
+
+ScreenSharingOverview::ScreenSharingOverview(ScreenSharingManager *screenSharingManager, RemoteScreenWindowFactory* remoteScreenViewerFactory, TimerFactory* timerFactory)
+ : screenSharingManager(screenSharingManager), remoteScreenWindowFactory(remoteScreenViewerFactory), timerFactory(timerFactory),
+ screenGrabber(new QtDesktopScreenGrabber)
+{
+ screenSharingManager->onIncomingScreenSharing.connect(boost::bind(&ScreenSharingOverview::handleIncomingScreenSharing, this, _1));
+}
+
+ScreenSharingOverview::~ScreenSharingOverview()
+{
+ screenSharingManager->onIncomingScreenSharing.disconnect(boost::bind(&ScreenSharingOverview::handleIncomingScreenSharing, this, _1));
+}
+
+void ScreenSharingOverview::createOugoingScreenSharing(const JID& to)
+{
+ ScreenSharingController* ssc = new ScreenSharingController(screenSharingManager, timerFactory, screenGrabber, to);
+ controllers.push_back(ssc);
+ onNewScreenSharingController(ssc);
+}
+
+void ScreenSharingOverview::handleIncomingScreenSharing(boost::shared_ptr<IncomingScreenSharing> incomingScreenSharing)
+{
+ ScreenSharingController* ssc = new ScreenSharingController(incomingScreenSharing, remoteScreenWindowFactory);
+ controllers.push_back(ssc);
+ onNewScreenSharingController(ssc);
+}
+
+}
diff --git a/Swift/Controllers/ScreenSharing/ScreenSharingOverview.h b/Swift/Controllers/ScreenSharing/ScreenSharingOverview.h
new file mode 100644
index 0000000..b43a665
--- /dev/null
+++ b/Swift/Controllers/ScreenSharing/ScreenSharingOverview.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012 Yoann Blein
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/boost_bsignals.h>
+
+#include <boost/shared_ptr.hpp>
+
+#include <vector>
+
+namespace Swift {
+ class ScreenSharingManager;
+ class ScreenSharingController;
+ class IncomingScreenSharing;
+ class TimerFactory;
+ class DesktopScreenGrabber;
+ class RemoteScreenWindowFactory;
+ class JID;
+
+ class ScreenSharingOverview {
+ public:
+ ScreenSharingOverview(ScreenSharingManager* screenSharingManager, RemoteScreenWindowFactory* remoteScreenWindowFactory, TimerFactory* timerFactory);
+ ~ScreenSharingOverview();
+
+ void createOugoingScreenSharing(const JID& to);
+
+ public:
+ boost::signal<void (ScreenSharingController*)> onNewScreenSharingController;
+
+ private:
+ void handleIncomingScreenSharing(boost::shared_ptr<IncomingScreenSharing> incomingScreenSharing);
+
+ private:
+ ScreenSharingManager* screenSharingManager;
+ RemoteScreenWindowFactory* remoteScreenWindowFactory;
+ TimerFactory* timerFactory;
+
+ DesktopScreenGrabber* screenGrabber;
+ std::vector<ScreenSharingController*> controllers;
+ };
+}