diff options
| author | Richard Maudsley <richard.maudsley@isode.com> | 2014-05-19 18:12:23 (GMT) |
|---|---|---|
| committer | Swift Review <review@swift.im> | 2014-05-29 18:31:43 (GMT) |
| commit | 6ce9e6bfa735ebeb577a308a1dd51a3424f5f0fe (patch) | |
| tree | e8a5918f40fd3862da79546a1ee3d4cbd32217d4 | |
| parent | b70a50f11da1ea57a0e89ff14882eed03944eb2a (diff) | |
| download | swift-contrib-6ce9e6bfa735ebeb577a308a1dd51a3424f5f0fe.zip swift-contrib-6ce9e6bfa735ebeb577a308a1dd51a3424f5f0fe.tar.bz2 | |
Check if contact supports file transfer before sending
Change-Id: Iadb580ad8b3f258d49b7c1b8713f0f92009e022e
| -rw-r--r-- | Swift/Controllers/Chat/ChatController.cpp | 20 | ||||
| -rw-r--r-- | Swift/Controllers/Roster/RosterController.cpp | 2 | ||||
| -rw-r--r-- | Swift/Controllers/UIInterfaces/ChatWindow.h | 1 | ||||
| -rw-r--r-- | Swift/Controllers/UnitTest/MockChatWindow.h | 1 | ||||
| -rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 7 | ||||
| -rw-r--r-- | Swift/QtUI/QtChatWindow.h | 2 | ||||
| -rw-r--r-- | Swiften/FileTransfer/FileTransferManager.cpp | 9 | ||||
| -rw-r--r-- | Swiften/FileTransfer/FileTransferManager.h | 3 | ||||
| -rw-r--r-- | Swiften/FileTransfer/FileTransferManagerImpl.cpp | 3 |
9 files changed, 37 insertions, 11 deletions
diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 10cf54b..65d65a6 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -12,12 +12,14 @@ -#include <Swiften/Base/format.h> -#include <Swiften/Base/Algorithm.h> #include <Swiften/Avatars/AvatarManager.h> +#include <Swiften/Base/Algorithm.h> +#include <Swiften/Base/DateTime.h> +#include <Swiften/Base/foreach.h> +#include <Swiften/Base/format.h> +#include <Swiften/Base/Log.h> #include <Swiften/Chat/ChatStateNotifier.h> #include <Swiften/Chat/ChatStateTracker.h> -#include <Swiften/Client/StanzaChannel.h> +#include <Swiften/Client/ClientBlockListManager.h> #include <Swiften/Client/NickResolver.h> +#include <Swiften/Client/StanzaChannel.h> #include <Swiften/Disco/EntityCapsProvider.h> -#include <Swiften/Base/foreach.h> -#include <Swiften/Base/DateTime.h> #include <Swiften/Elements/DeliveryReceipt.h> @@ -25,4 +27,3 @@ #include <Swiften/Elements/Idle.h> -#include <Swiften/Base/Log.h> -#include <Swiften/Client/ClientBlockListManager.h> +#include <Swiften/FileTransfer/FileTransferManager.h> @@ -137,2 +138,7 @@ void ChatController::handleBareJIDCapsChanged(const JID& /*jid*/) { } + if (FileTransferManager::isSupportedBy(disco)) { + chatWindow_->setFileTransferEnabled(ChatWindow::Yes); + } else { + chatWindow_->setFileTransferEnabled(ChatWindow::No); + } } else { diff --git a/Swift/Controllers/Roster/RosterController.cpp b/Swift/Controllers/Roster/RosterController.cpp index 4016f81..d2d024c 100644 --- a/Swift/Controllers/Roster/RosterController.cpp +++ b/Swift/Controllers/Roster/RosterController.cpp @@ -358,3 +358,3 @@ void RosterController::handleOnCapsChanged(const JID& jid) { std::set<ContactRosterItem::Feature> features; - if (info->hasFeature(DiscoInfo::JingleFeature) && info->hasFeature(DiscoInfo::JingleFTFeature) && info->hasFeature(DiscoInfo::JingleTransportsIBBFeature)) { + if (FileTransferManager::isSupportedBy(info)) { features.insert(ContactRosterItem::FileTransferFeature); diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h index 096a59a..ba4b397 100644 --- a/Swift/Controllers/UIInterfaces/ChatWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatWindow.h @@ -135,2 +135,3 @@ namespace Swift { virtual void setCorrectionEnabled(Tristate enabled) = 0; + virtual void setFileTransferEnabled(Tristate enabled) = 0; virtual void setUnreadMessageCount(int count) = 0; diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h index c2e2c9f..e4c2548 100644 --- a/Swift/Controllers/UnitTest/MockChatWindow.h +++ b/Swift/Controllers/UnitTest/MockChatWindow.h @@ -60,2 +60,3 @@ namespace Swift { virtual void setCorrectionEnabled(Tristate /*enabled*/) {} + virtual void setFileTransferEnabled(Tristate /*enabled*/) {} void setAvailableOccupantActions(const std::vector<OccupantAction>&/* actions*/) {} diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index f58c11b..f0d2038 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -69,2 +69,3 @@ QtChatWindow::QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventSt correctionEnabled_ = Maybe; + fileTransferEnabled_ = Maybe; updateTitleWithUnreadCount(); @@ -388,2 +389,6 @@ void QtChatWindow::setCorrectionEnabled(Tristate enabled) { +void QtChatWindow::setFileTransferEnabled(Tristate enabled) { + fileTransferEnabled_ = enabled; +} + SecurityLabelsCatalog::Item QtChatWindow::getSelectedSecurityLabel() { @@ -552,3 +557,3 @@ void QtChatWindow::dragEnterEvent(QDragEnterEvent *event) { void QtChatWindow::dropEvent(QDropEvent *event) { - if (event->mimeData()->hasUrls()) { + if (fileTransferEnabled_ == ChatWindow::Yes && event->mimeData()->hasUrls()) { if (event->mimeData()->urls().size() == 1) { diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index de7e45e..95edcd0 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -138,2 +138,3 @@ namespace Swift { void setCorrectionEnabled(Tristate enabled); + void setFileTransferEnabled(Tristate enabled); @@ -205,2 +206,3 @@ namespace Swift { Tristate correctionEnabled_; + Tristate fileTransferEnabled_; QString alertStyleSheet_; 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 @@ -13,2 +13,11 @@ 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 @@ -20,2 +20,3 @@ #include <Swiften/Base/boost_bsignals.h> +#include <Swiften/Elements/DiscoInfo.h> #include <Swiften/JID/JID.h> @@ -47,2 +48,4 @@ namespace Swift { + 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 @@ -113,4 +113,3 @@ boost::optional<JID> FileTransferManagerImpl::highestPriorityJIDSupportingFileTr 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(); |
Swift