summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-01-29 17:48:13 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-01-29 18:45:34 (GMT)
commit869c52b244c2d03313e9eda83fac05bf0fc3a619 (patch)
tree63f0518e15d0c23ece6eb55733c2ef44f710bf01 /Swiften/FileTransfer/IncomingFileTransferManager.cpp
parent11a7f5c48ea9c90e9adaaa06a96e0a9116234bff (diff)
downloadswift-contrib-869c52b244c2d03313e9eda83fac05bf0fc3a619.zip
swift-contrib-869c52b244c2d03313e9eda83fac05bf0fc3a619.tar.bz2
Added some experimental Jingle classes.
Diffstat (limited to 'Swiften/FileTransfer/IncomingFileTransferManager.cpp')
-rw-r--r--Swiften/FileTransfer/IncomingFileTransferManager.cpp46
1 files changed, 46 insertions, 0 deletions
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;
+ }
+}
+
+
+}