From 724a5a14a87f2ab6d90417cc094de736522377f8 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sun, 27 Oct 2019 19:35:18 +0000 Subject: [PATCH] Don't use KIO in core when building for Sailfish --- CMakeLists.txt | 2 +- core/CMakeLists.txt | 5 ++++- core/backends/lan/compositeuploadjob.cpp | 17 ++++++++++------- core/compositefiletransferjob.cpp | 1 - core/daemon.h | 2 ++ daemon/kdeconnectd.cpp | 5 +++++ tests/CMakeLists.txt | 5 ++++- tests/testdaemon.h | 23 +++++++++++++++++++++++ 8 files changed, 49 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29c3097a7..4e77b7328 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ else() if(NOT WIN32 AND NOT APPLE) find_package(KF5PulseAudioQt) endif() - add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_NO_KEYWORDS -DQT_NO_CAST_FROM_ASCII) + add_definitions(-DQT_NO_URL_CAST_FROM_STRING -DQT_NO_KEYWORDS -DQT_NO_CAST_FROM_ASCII -DHAVE_KIO) endif() find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Quick Network) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index b5ccbde81..b5e08601b 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -49,7 +49,6 @@ target_link_libraries(kdeconnectcore PUBLIC Qt5::Network KF5::CoreAddons - KF5::KIOCore qca-qt5 PRIVATE Qt5::DBus @@ -57,6 +56,10 @@ PRIVATE KF5::ConfigCore ) +if(${KF5KIO_FOUND}) + target_link_libraries(kdeconnectcore PUBLIC KF5::KIOCore) +endif() + if (BLUETOOTH_ENABLED) target_compile_definitions(kdeconnectcore PRIVATE -DKDECONNECT_BLUETOOTH) target_link_libraries(kdeconnectcore PRIVATE Qt5::Bluetooth) diff --git a/core/backends/lan/compositeuploadjob.cpp b/core/backends/lan/compositeuploadjob.cpp index 29dfc5f8c..fc93812ea 100644 --- a/core/backends/lan/compositeuploadjob.cpp +++ b/core/backends/lan/compositeuploadjob.cpp @@ -21,13 +21,16 @@ #include "compositeuploadjob.h" #include #include -#include #include #include "lanlinkprovider.h" #include #include "plugins/share/shareplugin.h" -CompositeUploadJob::CompositeUploadJob(const QString& deviceId, bool displayNotification) +#ifdef HAVE_KIO +#include +#endif + +CompositeUploadJob::CompositeUploadJob(const QString& deviceId, bool displayNotification) : KCompositeJob() , m_server(new Server(this)) , m_socket(nullptr) @@ -44,9 +47,9 @@ CompositeUploadJob::CompositeUploadJob(const QString& deviceId, bool displayNoti , m_updatePacketPending(false) { setCapabilities(Killable); - + if (displayNotification) { - KIO::getJobTracker()->registerJob(this); + Daemon::instance()->jobTracker()->registerJob(this); } } @@ -283,13 +286,13 @@ void CompositeUploadJob::slotResult(KJob *job) { void CompositeUploadJob::emitDescription(const QString& currentFileName) { QPair field2; - + if (m_totalJobs > 1) { field2.first = i18n("Progress"); field2.second = i18n("Sending file %1 of %2", m_currentJobNum, m_totalJobs); } - - Q_EMIT description(this, i18n("Sending to %1", Daemon::instance()->getDevice(this->m_deviceId)->name()), + + Q_EMIT description(this, i18n("Sending to %1", Daemon::instance()->getDevice(this->m_deviceId)->name()), { i18n("File"), currentFileName }, field2 ); } diff --git a/core/compositefiletransferjob.cpp b/core/compositefiletransferjob.cpp index e5b810b7e..6ed9dac8e 100644 --- a/core/compositefiletransferjob.cpp +++ b/core/compositefiletransferjob.cpp @@ -21,7 +21,6 @@ #include "compositefiletransferjob.h" #include #include -#include #include #include #include "filetransferjob.h" diff --git a/core/daemon.h b/core/daemon.h index 83b3fa5db..9840e678a 100644 --- a/core/daemon.h +++ b/core/daemon.h @@ -32,6 +32,7 @@ class NetworkPacket; class DeviceLink; class Device; class QNetworkAccessManager; +class KJobTrackerInterface; class KDECONNECTCORE_EXPORT Daemon : public QObject @@ -53,6 +54,7 @@ public: virtual void reportError(const QString& title, const QString& description) = 0; virtual void quit() = 0; virtual QNetworkAccessManager* networkAccessManager(); + virtual KJobTrackerInterface* jobTracker() = 0; Device* getDevice(const QString& deviceId); diff --git a/daemon/kdeconnectd.cpp b/daemon/kdeconnectd.cpp index 8e38dd822..1e9bd49d9 100644 --- a/daemon/kdeconnectd.cpp +++ b/daemon/kdeconnectd.cpp @@ -85,6 +85,11 @@ public: return m_nam; } + KJobTrackerInterface* jobTracker() override + { + return KIO::getJobTracker(); + } + Q_SCRIPTABLE void sendSimpleNotification(const QString &eventId, const QString &title, const QString &text, const QString &iconName) override { KNotification* notification = new KNotification(eventId); //KNotification::Persistent diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1c5d01de7..a879f6182 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,13 +11,16 @@ include_directories( set(kdeconnect_libraries kdeconnectcore KF5::I18n - KF5::KIOWidgets Qt5::DBus Qt5::Network Qt5::Test qca-qt5 ) +if(${KF5KIO_FOUND}) + list(APPEND kdeconnect_libraries KF5::KIOWidgets) +endif() + set(kdeconnect_sms_libraries kdeconnectsmshelper Qt5::Test diff --git a/tests/testdaemon.h b/tests/testdaemon.h index dd64d1058..c42604429 100644 --- a/tests/testdaemon.h +++ b/tests/testdaemon.h @@ -24,12 +24,22 @@ #include #include +#include +#include + +#ifdef HAVE_KIO +#include +#else +#include +#endif + class TestDaemon : public Daemon { public: TestDaemon(QObject* parent = nullptr) : Daemon(parent, true) , m_nam(nullptr) + , m_jobTrackerInterface(nullptr) { // Necessary to force the event loop to run because the test harness seems to behave differently // and we need the QTimer::SingleShot in Daemon's constructor to fire @@ -52,7 +62,11 @@ public: QNetworkAccessManager* networkAccessManager() override { if (!m_nam) { +#ifdef HAVE_KIO m_nam = new KIO::AccessManager(this); +#else + m_nam = new QNetworkAccessManager(this); +#endif } return m_nam; } @@ -66,8 +80,17 @@ public: qDebug() << "quit was called"; } + KJobTrackerInterface* jobTracker() override + { + if (!m_jobTrackerInterface) { + m_jobTrackerInterface = new KJobTrackerInterface(); + } + return m_jobTrackerInterface; + } + private: QNetworkAccessManager* m_nam; + KJobTrackerInterface* m_jobTrackerInterface; }; #endif