summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Fella <[email protected]>2018-12-27 17:41:28 +0100
committerNicolas Fella <[email protected]>2019-01-05 19:00:10 +0100
commit787dbfe2ba5e64089b68544e82195bad89145bcf (patch)
tree8262cff998d4f39eb49b4b4e6d6d91ec8fa96e33
parent44f47c5fe75fc16d525dfd995f8b0000d39df244 (diff)
Fix send to KDE Connect for older KDE Connect version
Summary: When I wrote the code I assumed that by the time it is released the corresponding KDE Connect changes would be released, too. History proved me wrong. The openFile method will only be available with KDE Connect 1.4 whose release is not yet scheduled. For older versions of KDE Connect shareUrl is used now. That transfers the file but does not open it. Test Plan: Tested with KDE Connect 1.3.3 and master (with version bumped to 1.4). Reviewers: vkrause, #kde_pim_kmail Reviewed By: vkrause Subscribers: kde-pim Tags: #kde_pim, #kde_pim_kmail, #kde_itinerary Differential Revision: https://phabricator.kde.org/D17822
-rw-r--r--plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp b/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp
index b879161..8f4bd75 100644
--- a/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp
+++ b/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp
@@ -58,6 +58,7 @@
#include <QUrlQuery>
#include <QDBusPendingReply>
#include <QDBusReply>
+#include <QVersionNumber>
#include <memory>
#include <type_traits>
@@ -484,9 +485,19 @@ void SemanticUrlHandler::openWithKDEConnect(MimeTreeParser::Interface::BodyPart
part->nodeHelper()->addTempFile(f.fileName());
f.setAutoRemove(false);
- QDBusMessage msg
- = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/share"), QStringLiteral(
- "org.kde.kdeconnect.device.share"), QStringLiteral("openFile"));
+
+ QDBusInterface remoteApp(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/MainApplication"), QStringLiteral("org.qtproject.Qt.QCoreApplication"));
+ QVersionNumber kdeconnectVersion = QVersionNumber::fromString(remoteApp.property("applicationVersion").toString());
+
+ QString method;
+ if(kdeconnectVersion >= QVersionNumber(1, 4, 0)) {
+ method = QStringLiteral("openFile");
+ } else {
+ method = QStringLiteral("shareUrl");
+ }
+
+ QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/share"), QStringLiteral(
+ "org.kde.kdeconnect.device.share"), method);
msg.setArguments({QUrl::fromLocalFile(f.fileName()).toString()});
QDBusConnection::sessionBus().send(msg);