summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-05-19 18:12:23 (GMT)
committerSwift Review <review@swift.im>2014-05-29 18:31:43 (GMT)
commit6ce9e6bfa735ebeb577a308a1dd51a3424f5f0fe (patch)
treee8a5918f40fd3862da79546a1ee3d4cbd32217d4 /Swiften/FileTransfer
parentb70a50f11da1ea57a0e89ff14882eed03944eb2a (diff)
downloadswift-6ce9e6bfa735ebeb577a308a1dd51a3424f5f0fe.zip
swift-6ce9e6bfa735ebeb577a308a1dd51a3424f5f0fe.tar.bz2
Check if contact supports file transfer before sending
Change-Id: Iadb580ad8b3f258d49b7c1b8713f0f92009e022e
Diffstat (limited to 'Swiften/FileTransfer')
-rw-r--r--Swiften/FileTransfer/FileTransferManager.cpp9
-rw-r--r--Swiften/FileTransfer/FileTransferManager.h3
-rw-r--r--Swiften/FileTransfer/FileTransferManagerImpl.cpp3
3 files changed, 13 insertions, 2 deletions
diff --git a/Swiften/FileTransfer/FileTransferManager.cpp b/Swiften/FileTransfer/FileTransferManager.cpp
index 69be852..0c7d894 100644
--- a/Swiften/FileTransfer/FileTransferManager.cpp
+++ b/Swiften/FileTransfer/FileTransferManager.cpp
@@ -11,4 +11,13 @@ namespace Swift {
FileTransferManager::~FileTransferManager() {
}
+bool FileTransferManager::isSupportedBy(const DiscoInfo::ref info) {
+ if (info) {
+ return info->hasFeature(DiscoInfo::JingleFeature)
+ && info->hasFeature(DiscoInfo::JingleFTFeature)
+ && (info->hasFeature(DiscoInfo::JingleTransportsIBBFeature) || info->hasFeature(DiscoInfo::JingleTransportsS5BFeature));
+ }
+ return false;
+}
+
}
diff --git a/Swiften/FileTransfer/FileTransferManager.h b/Swiften/FileTransfer/FileTransferManager.h
index 3b793c5..bc6530b 100644
--- a/Swiften/FileTransfer/FileTransferManager.h
+++ b/Swiften/FileTransfer/FileTransferManager.h
@@ -18,6 +18,7 @@
#include <Swiften/Base/API.h>
#include <Swiften/Base/boost_bsignals.h>
+#include <Swiften/Elements/DiscoInfo.h>
#include <Swiften/JID/JID.h>
#include <Swiften/FileTransfer/FileTransferOptions.h>
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
@@ -45,6 +46,8 @@ namespace Swift {
boost::shared_ptr<ReadBytestream> bytestream,
const FileTransferOptions& = FileTransferOptions()) = 0;
+ static bool isSupportedBy(const DiscoInfo::ref info);
+
boost::signal<void (IncomingFileTransfer::ref)> onIncomingFileTransfer;
};
}
diff --git a/Swiften/FileTransfer/FileTransferManagerImpl.cpp b/Swiften/FileTransfer/FileTransferManagerImpl.cpp
index b832d7e..04a2332 100644
--- a/Swiften/FileTransfer/FileTransferManagerImpl.cpp
+++ b/Swiften/FileTransfer/FileTransferManagerImpl.cpp
@@ -111,8 +111,7 @@ boost::optional<JID> FileTransferManagerImpl::highestPriorityJIDSupportingFileTr
if (pres->getPriority() > priority) {
// look up caps from the jid
DiscoInfo::ref info = capsProvider->getCaps(pres->getFrom());
- if (info && info->hasFeature(DiscoInfo::JingleFeature) && info->hasFeature(DiscoInfo::JingleFTFeature) && (info->hasFeature(DiscoInfo::JingleTransportsIBBFeature) || info->hasFeature(DiscoInfo::JingleTransportsS5BFeature))) {
-
+ if (isSupportedBy(info)) {
priority = pres->getPriority();
fullReceipientJID = pres->getFrom();
}