summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordknn <yoann.blein@free.fr>2012-07-08 20:27:27 (GMT)
committerdknn <yoann.blein@free.fr>2012-09-22 09:00:01 (GMT)
commit1b2d23c160b4c120a364ff9e86b54e2d8caeaaa4 (patch)
tree94c9884d7746786568d0da2d6e122dd0f0b5ca9c /Swiften/ScreenSharing/IncomingScreenSharing.cpp
parent4e0236b08d3914d24af32f45bc99663a73c6d83a (diff)
downloadswift-contrib-1b2d23c160b4c120a364ff9e86b54e2d8caeaaa4.zip
swift-contrib-1b2d23c160b4c120a364ff9e86b54e2d8caeaaa4.tar.bz2
Screen sharing managing
Diffstat (limited to 'Swiften/ScreenSharing/IncomingScreenSharing.cpp')
-rw-r--r--Swiften/ScreenSharing/IncomingScreenSharing.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/Swiften/ScreenSharing/IncomingScreenSharing.cpp b/Swiften/ScreenSharing/IncomingScreenSharing.cpp
new file mode 100644
index 0000000..d5ee56e
--- /dev/null
+++ b/Swiften/ScreenSharing/IncomingScreenSharing.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2012 Yoann Blein
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swiften/ScreenSharing/IncomingScreenSharing.h>
+
+#include <Swiften/Jingle/JingleSession.h>
+#include <Swiften/Elements/JingleRawUDPTransportPayload.h>
+#include <Swiften/Network/UDPSocketFactory.h>
+#include <Swiften/Network/UDPSocket.h>
+
+namespace Swift {
+
+IncomingScreenSharing::IncomingScreenSharing(boost::shared_ptr<JingleSession> session, UDPSocketFactory* udpSocketFactory,
+ boost::shared_ptr<JingleContentPayload> content)
+ : ScreenSharing(session, udpSocketFactory),
+ initialContent(content)
+{
+ onStateChange(ScreenSharing::WaitingForAccept);
+}
+
+IncomingScreenSharing::~IncomingScreenSharing()
+{
+}
+
+void IncomingScreenSharing::cancel()
+{
+ session->sendTerminate(JinglePayload::Reason::Cancel);
+ clientSocket->close();
+ onStateChange(ScreenSharing::Canceled);
+}
+
+void IncomingScreenSharing::accept()
+{
+ JingleRawUDPTransportPayload::ref transport = boost::make_shared<JingleRawUDPTransportPayload>();
+ addBestCandidate(transport);
+ // TODO: create a valid description instead of copying the initator's one
+ session->sendAccept(getContentID(), initialContent->getDescriptions().front(), transport);
+
+ JingleRawUDPTransportPayload::ref initialTransport = initialContent->getTransport<JingleRawUDPTransportPayload>();
+ clientSocket = udpSocketFactory->createUDPSocket();
+ clientSocket->connect(initialTransport->getCandidates().front().hostAddressPort);
+ // Send a empty packet to let the server know about us
+ SafeByteArray data(1, 0);
+ clientSocket->send(data);
+
+ onStateChange(ScreenSharing::Connecting);
+}
+
+JingleContentID IncomingScreenSharing::getContentID() const
+{
+ return JingleContentID(initialContent->getName(), initialContent->getCreator());
+}
+
+}