Differential D17822 Diff 48257 plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp
Changeset View
Changeset View
Standalone View
Standalone View
plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
52 | #include <QJsonDocument> | 52 | #include <QJsonDocument> | ||
53 | #include <QMenu> | 53 | #include <QMenu> | ||
54 | #include <QProcess> | 54 | #include <QProcess> | ||
55 | #include <QStandardPaths> | 55 | #include <QStandardPaths> | ||
56 | #include <QTemporaryFile> | 56 | #include <QTemporaryFile> | ||
57 | #include <QUrlQuery> | 57 | #include <QUrlQuery> | ||
58 | #include <QDBusPendingReply> | 58 | #include <QDBusPendingReply> | ||
59 | #include <QDBusReply> | 59 | #include <QDBusReply> | ||
60 | #include <QVersionNumber> | ||||
60 | 61 | | |||
61 | #include <memory> | 62 | #include <memory> | ||
62 | #include <type_traits> | 63 | #include <type_traits> | ||
63 | 64 | | |||
64 | using namespace KItinerary; | 65 | using namespace KItinerary; | ||
65 | 66 | | |||
66 | SemanticUrlHandler::SemanticUrlHandler() | 67 | SemanticUrlHandler::SemanticUrlHandler() | ||
67 | { | 68 | { | ||
▲ Show 20 Lines • Show All 401 Lines • ▼ Show 20 Line(s) | 459 | { | |||
469 | for (const auto &d : m->data()) { | 470 | for (const auto &d : m->data()) { | ||
470 | data += d.reservations; | 471 | data += d.reservations; | ||
471 | } | 472 | } | ||
472 | f.write(QJsonDocument(JsonLdDocument::toJson(data)).toJson()); | 473 | f.write(QJsonDocument(JsonLdDocument::toJson(data)).toJson()); | ||
473 | f.close(); | 474 | f.close(); | ||
474 | part->nodeHelper()->addTempFile(f.fileName()); | 475 | part->nodeHelper()->addTempFile(f.fileName()); | ||
475 | f.setAutoRemove(false); | 476 | f.setAutoRemove(false); | ||
476 | 477 | | |||
477 | QDBusMessage msg | 478 | | ||
478 | = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/share"), QStringLiteral( | 479 | QDBusInterface remoteApp(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/MainApplication"), QStringLiteral("org.qtproject.Qt.QCoreApplication")); | ||
479 | "org.kde.kdeconnect.device.share"), QStringLiteral("openFile")); | 480 | QVersionNumber kdeconnectVersion = QVersionNumber::fromString(remoteApp.property("applicationVersion").toString()); | ||
481 | | ||||
482 | QString method; | ||||
483 | if(kdeconnectVersion >= QVersionNumber(1, 4, 0)) { | ||||
484 | method = QStringLiteral("openFile"); | ||||
485 | } else { | ||||
486 | method = QStringLiteral("shareUrl"); | ||||
487 | } | ||||
488 | | ||||
489 | QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/share"), QStringLiteral( | ||||
490 | "org.kde.kdeconnect.device.share"), method); | ||||
480 | msg.setArguments({QUrl::fromLocalFile(f.fileName()).toString()}); | 491 | msg.setArguments({QUrl::fromLocalFile(f.fileName()).toString()}); | ||
481 | 492 | | |||
482 | QDBusConnection::sessionBus().send(msg); | 493 | QDBusConnection::sessionBus().send(msg); | ||
483 | 494 | | |||
484 | // add pkpass attachments | 495 | // add pkpass attachments | ||
485 | for (const auto &elem : data) { | 496 | for (const auto &elem : data) { | ||
486 | if (!JsonLd::canConvert<Reservation>(elem)) { | 497 | if (!JsonLd::canConvert<Reservation>(elem)) { | ||
487 | continue; | 498 | continue; | ||
Show All 21 Lines |