Don't use KIO in core when building for Sailfish

This commit is contained in:
Nicolas Fella 2019-10-27 19:35:18 +00:00
parent 1c6d45654c
commit 724a5a14a8
8 changed files with 49 additions and 11 deletions

View file

@ -66,7 +66,7 @@ else()
if(NOT WIN32 AND NOT APPLE) if(NOT WIN32 AND NOT APPLE)
find_package(KF5PulseAudioQt) find_package(KF5PulseAudioQt)
endif() 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() endif()
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Quick Network) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Quick Network)

View file

@ -49,7 +49,6 @@ target_link_libraries(kdeconnectcore
PUBLIC PUBLIC
Qt5::Network Qt5::Network
KF5::CoreAddons KF5::CoreAddons
KF5::KIOCore
qca-qt5 qca-qt5
PRIVATE PRIVATE
Qt5::DBus Qt5::DBus
@ -57,6 +56,10 @@ PRIVATE
KF5::ConfigCore KF5::ConfigCore
) )
if(${KF5KIO_FOUND})
target_link_libraries(kdeconnectcore PUBLIC KF5::KIOCore)
endif()
if (BLUETOOTH_ENABLED) if (BLUETOOTH_ENABLED)
target_compile_definitions(kdeconnectcore PRIVATE -DKDECONNECT_BLUETOOTH) target_compile_definitions(kdeconnectcore PRIVATE -DKDECONNECT_BLUETOOTH)
target_link_libraries(kdeconnectcore PRIVATE Qt5::Bluetooth) target_link_libraries(kdeconnectcore PRIVATE Qt5::Bluetooth)

View file

@ -21,13 +21,16 @@
#include "compositeuploadjob.h" #include "compositeuploadjob.h"
#include <core_debug.h> #include <core_debug.h>
#include <KLocalizedString> #include <KLocalizedString>
#include <kio/global.h>
#include <KJobTrackerInterface> #include <KJobTrackerInterface>
#include "lanlinkprovider.h" #include "lanlinkprovider.h"
#include <daemon.h> #include <daemon.h>
#include "plugins/share/shareplugin.h" #include "plugins/share/shareplugin.h"
CompositeUploadJob::CompositeUploadJob(const QString& deviceId, bool displayNotification) #ifdef HAVE_KIO
#include <kio/global.h>
#endif
CompositeUploadJob::CompositeUploadJob(const QString& deviceId, bool displayNotification)
: KCompositeJob() : KCompositeJob()
, m_server(new Server(this)) , m_server(new Server(this))
, m_socket(nullptr) , m_socket(nullptr)
@ -44,9 +47,9 @@ CompositeUploadJob::CompositeUploadJob(const QString& deviceId, bool displayNoti
, m_updatePacketPending(false) , m_updatePacketPending(false)
{ {
setCapabilities(Killable); setCapabilities(Killable);
if (displayNotification) { 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) { void CompositeUploadJob::emitDescription(const QString& currentFileName) {
QPair<QString, QString> field2; QPair<QString, QString> field2;
if (m_totalJobs > 1) { if (m_totalJobs > 1) {
field2.first = i18n("Progress"); field2.first = i18n("Progress");
field2.second = i18n("Sending file %1 of %2", m_currentJobNum, m_totalJobs); 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 { i18n("File"), currentFileName }, field2
); );
} }

View file

@ -21,7 +21,6 @@
#include "compositefiletransferjob.h" #include "compositefiletransferjob.h"
#include <core_debug.h> #include <core_debug.h>
#include <KLocalizedString> #include <KLocalizedString>
#include <kio/global.h>
#include <KJobTrackerInterface> #include <KJobTrackerInterface>
#include <daemon.h> #include <daemon.h>
#include "filetransferjob.h" #include "filetransferjob.h"

View file

@ -32,6 +32,7 @@ class NetworkPacket;
class DeviceLink; class DeviceLink;
class Device; class Device;
class QNetworkAccessManager; class QNetworkAccessManager;
class KJobTrackerInterface;
class KDECONNECTCORE_EXPORT Daemon class KDECONNECTCORE_EXPORT Daemon
: public QObject : public QObject
@ -53,6 +54,7 @@ public:
virtual void reportError(const QString& title, const QString& description) = 0; virtual void reportError(const QString& title, const QString& description) = 0;
virtual void quit() = 0; virtual void quit() = 0;
virtual QNetworkAccessManager* networkAccessManager(); virtual QNetworkAccessManager* networkAccessManager();
virtual KJobTrackerInterface* jobTracker() = 0;
Device* getDevice(const QString& deviceId); Device* getDevice(const QString& deviceId);

View file

@ -85,6 +85,11 @@ public:
return m_nam; 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 Q_SCRIPTABLE void sendSimpleNotification(const QString &eventId, const QString &title, const QString &text, const QString &iconName) override
{ {
KNotification* notification = new KNotification(eventId); //KNotification::Persistent KNotification* notification = new KNotification(eventId); //KNotification::Persistent

View file

@ -11,13 +11,16 @@ include_directories(
set(kdeconnect_libraries set(kdeconnect_libraries
kdeconnectcore kdeconnectcore
KF5::I18n KF5::I18n
KF5::KIOWidgets
Qt5::DBus Qt5::DBus
Qt5::Network Qt5::Network
Qt5::Test Qt5::Test
qca-qt5 qca-qt5
) )
if(${KF5KIO_FOUND})
list(APPEND kdeconnect_libraries KF5::KIOWidgets)
endif()
set(kdeconnect_sms_libraries set(kdeconnect_sms_libraries
kdeconnectsmshelper kdeconnectsmshelper
Qt5::Test Qt5::Test

View file

@ -24,12 +24,22 @@
#include <core/daemon.h> #include <core/daemon.h>
#include <core/backends/pairinghandler.h> #include <core/backends/pairinghandler.h>
#include <QCoreApplication>
#include <KJobTrackerInterface>
#ifdef HAVE_KIO
#include <KIO/AccessManager>
#else
#include <QNetworkAccessManager>
#endif
class TestDaemon : public Daemon class TestDaemon : public Daemon
{ {
public: public:
TestDaemon(QObject* parent = nullptr) TestDaemon(QObject* parent = nullptr)
: Daemon(parent, true) : Daemon(parent, true)
, m_nam(nullptr) , m_nam(nullptr)
, m_jobTrackerInterface(nullptr)
{ {
// Necessary to force the event loop to run because the test harness seems to behave differently // 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 // and we need the QTimer::SingleShot in Daemon's constructor to fire
@ -52,7 +62,11 @@ public:
QNetworkAccessManager* networkAccessManager() override QNetworkAccessManager* networkAccessManager() override
{ {
if (!m_nam) { if (!m_nam) {
#ifdef HAVE_KIO
m_nam = new KIO::AccessManager(this); m_nam = new KIO::AccessManager(this);
#else
m_nam = new QNetworkAccessManager(this);
#endif
} }
return m_nam; return m_nam;
} }
@ -66,8 +80,17 @@ public:
qDebug() << "quit was called"; qDebug() << "quit was called";
} }
KJobTrackerInterface* jobTracker() override
{
if (!m_jobTrackerInterface) {
m_jobTrackerInterface = new KJobTrackerInterface();
}
return m_jobTrackerInterface;
}
private: private:
QNetworkAccessManager* m_nam; QNetworkAccessManager* m_nam;
KJobTrackerInterface* m_jobTrackerInterface;
}; };
#endif #endif