summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer')
-rw-r--r--Swiften/FileTransfer/IncomingFileTransfer.cpp10
-rw-r--r--Swiften/FileTransfer/IncomingFileTransfer.h4
-rw-r--r--Swiften/FileTransfer/IncomingFileTransferManager.cpp46
-rw-r--r--Swiften/FileTransfer/IncomingFileTransferManager.h19
-rw-r--r--Swiften/FileTransfer/IncomingJingleFileTransfer.cpp19
-rw-r--r--Swiften/FileTransfer/IncomingJingleFileTransfer.h27
-rw-r--r--Swiften/FileTransfer/OutgoingFileTransfer.cpp2
-rw-r--r--Swiften/FileTransfer/SConscript2
8 files changed, 124 insertions, 5 deletions
diff --git a/Swiften/FileTransfer/IncomingFileTransfer.cpp b/Swiften/FileTransfer/IncomingFileTransfer.cpp
index 1962724..238ccce 100644
--- a/Swiften/FileTransfer/IncomingFileTransfer.cpp
+++ b/Swiften/FileTransfer/IncomingFileTransfer.cpp
@@ -8,8 +8,16 @@
namespace Swift {
-void IncomingFileTransfer::accept(WriteBytestream::ref) {
+IncomingFileTransfer::~IncomingFileTransfer() {
}
+/*void IncomingFileTransfer::accept(WriteBytestream::ref) {
+
+}
+
+void IncomingFileTransfer::stop() {
+
+}*/
+
}
diff --git a/Swiften/FileTransfer/IncomingFileTransfer.h b/Swiften/FileTransfer/IncomingFileTransfer.h
index d5e7a2f..4286ef0 100644
--- a/Swiften/FileTransfer/IncomingFileTransfer.h
+++ b/Swiften/FileTransfer/IncomingFileTransfer.h
@@ -16,6 +16,8 @@ namespace Swift {
public:
typedef boost::shared_ptr<IncomingFileTransfer> ref;
- void accept(WriteBytestream::ref);
+ virtual ~IncomingFileTransfer();
+
+ virtual void accept(WriteBytestream::ref) = 0;
};
}
diff --git a/Swiften/FileTransfer/IncomingFileTransferManager.cpp b/Swiften/FileTransfer/IncomingFileTransferManager.cpp
new file mode 100644
index 0000000..5535840
--- /dev/null
+++ b/Swiften/FileTransfer/IncomingFileTransferManager.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/FileTransfer/IncomingFileTransferManager.h>
+
+#include <boost/smart_ptr/make_shared.hpp>
+
+#include <Swiften/Elements/JingleDescription.h>
+#include <Swiften/Elements/JingleFileTransferDescription.h>
+#include <Swiften/Elements/JingleIBBTransport.h>
+#include <Swiften/Jingle/JingleSessionManager.h>
+#include <Swiften/FileTransfer/IncomingJingleFileTransfer.h>
+
+namespace Swift {
+
+IncomingFileTransferManager::IncomingFileTransferManager(JingleSessionManager* jingleSessionManager, IQRouter* router) : jingleSessionManager(jingleSessionManager), router(router) {
+ jingleSessionManager->addIncomingSessionHandler(this);
+}
+
+IncomingFileTransferManager::~IncomingFileTransferManager() {
+ jingleSessionManager->removeIncomingSessionHandler(this);
+}
+
+bool IncomingFileTransferManager::handleIncomingJingleSession(IncomingJingleSession::ref session) {
+ JingleContent::ref content = session->getContentWithDescription<JingleFileTransferDescription>();
+ if (content) {
+ // Check for supported transports
+ if (content->getTransport<JingleIBBTransport>()) {
+ IncomingJingleFileTransfer::ref transfer = boost::make_shared<IncomingJingleFileTransfer>(session);
+ onIncomingFileTransfer(transfer);
+ }
+ else {
+ session->terminate(JinglePayload::Reason::UnsupportedTransports);
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+
+}
diff --git a/Swiften/FileTransfer/IncomingFileTransferManager.h b/Swiften/FileTransfer/IncomingFileTransferManager.h
index 41499e5..a54b5cd 100644
--- a/Swiften/FileTransfer/IncomingFileTransferManager.h
+++ b/Swiften/FileTransfer/IncomingFileTransferManager.h
@@ -8,11 +8,26 @@
#include <boost/shared_ptr.hpp>
-#include "Swiften/Base/boost_bsignals.h"
+#include <Swiften/Base/boost_bsignals.h>
+#include <Swiften/FileTransfer/IncomingFileTransfer.h>
+#include <Swiften/Jingle/IncomingJingleSessionHandler.h>
namespace Swift {
- class IncomingFileTransferManager {
+ class IQRouter;
+ class JingleSessionManager;
+
+ class IncomingFileTransferManager : public IncomingJingleSessionHandler {
public:
+ IncomingFileTransferManager(JingleSessionManager* jingleSessionManager, IQRouter* router);
+ ~IncomingFileTransferManager();
+
boost::signal<void (IncomingFileTransfer::ref)> onIncomingFileTransfer;
+
+ private:
+ bool handleIncomingJingleSession(IncomingJingleSession::ref session);
+
+ private:
+ JingleSessionManager* jingleSessionManager;
+ IQRouter* router;
};
}
diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp
new file mode 100644
index 0000000..cb2f65c
--- /dev/null
+++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.cpp
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2011 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/FileTransfer/IncomingJingleFileTransfer.h>
+
+namespace Swift {
+
+IncomingJingleFileTransfer::IncomingJingleFileTransfer(IncomingJingleSession::ref session) : session(session) {
+
+}
+
+void IncomingJingleFileTransfer::accept(WriteBytestream::ref stream) {
+ this->stream = stream;
+}
+
+}
diff --git a/Swiften/FileTransfer/IncomingJingleFileTransfer.h b/Swiften/FileTransfer/IncomingJingleFileTransfer.h
new file mode 100644
index 0000000..d69449e
--- /dev/null
+++ b/Swiften/FileTransfer/IncomingJingleFileTransfer.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <boost/shared_ptr.hpp>
+
+#include <Swiften/Jingle/IncomingJingleSession.h>
+#include <Swiften/FileTransfer/IncomingFileTransfer.h>
+
+namespace Swift {
+ class IncomingJingleFileTransfer : public IncomingFileTransfer {
+ public:
+ typedef boost::shared_ptr<IncomingJingleFileTransfer> ref;
+
+ IncomingJingleFileTransfer(IncomingJingleSession::ref session);
+
+ virtual void accept(WriteBytestream::ref);
+
+ private:
+ IncomingJingleSession::ref session;
+ WriteBytestream::ref stream;
+ };
+}
diff --git a/Swiften/FileTransfer/OutgoingFileTransfer.cpp b/Swiften/FileTransfer/OutgoingFileTransfer.cpp
index 4fa8d94..8e6f839 100644
--- a/Swiften/FileTransfer/OutgoingFileTransfer.cpp
+++ b/Swiften/FileTransfer/OutgoingFileTransfer.cpp
@@ -21,7 +21,7 @@ OutgoingFileTransfer::OutgoingFileTransfer(const String& id, const JID& from, co
void OutgoingFileTransfer::start() {
StreamInitiation::ref streamInitiation(new StreamInitiation());
streamInitiation->setID(id);
- streamInitiation->setFileInfo(StreamInitiation::FileInfo(name, description, size));
+ streamInitiation->setFileInfo(StreamInitiationFileInfo(name, description, size));
//streamInitiation->addProvidedMethod("http://jabber.org/protocol/bytestreams");
streamInitiation->addProvidedMethod("http://jabber.org/protocol/ibb");
StreamInitiationRequest::ref request = StreamInitiationRequest::create(to, streamInitiation, iqRouter);
diff --git a/Swiften/FileTransfer/SConscript b/Swiften/FileTransfer/SConscript
index d36e029..9f3234f 100644
--- a/Swiften/FileTransfer/SConscript
+++ b/Swiften/FileTransfer/SConscript
@@ -3,6 +3,8 @@ Import("swiften_env")
sources = [
"OutgoingFileTransfer.cpp",
"IncomingFileTransfer.cpp",
+ "IncomingJingleFileTransfer.cpp",
+ "IncomingFileTransferManager.cpp",
"ReadBytestream.cpp",
"WriteBytestream.cpp",
"FileReadBytestream.cpp",