diff options
Diffstat (limited to 'Swiften/FileTransfer/IncomingFileTransferManager.cpp')
-rw-r--r-- | Swiften/FileTransfer/IncomingFileTransferManager.cpp | 46 |
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; + } +} + + +} |