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)
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)

View file

@ -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)

View file

@ -21,12 +21,15 @@
#include "compositeuploadjob.h"
#include <core_debug.h>
#include <KLocalizedString>
#include <kio/global.h>
#include <KJobTrackerInterface>
#include "lanlinkprovider.h"
#include <daemon.h>
#include "plugins/share/shareplugin.h"
#ifdef HAVE_KIO
#include <kio/global.h>
#endif
CompositeUploadJob::CompositeUploadJob(const QString& deviceId, bool displayNotification)
: KCompositeJob()
, m_server(new Server(this))
@ -46,7 +49,7 @@ CompositeUploadJob::CompositeUploadJob(const QString& deviceId, bool displayNoti
setCapabilities(Killable);
if (displayNotification) {
KIO::getJobTracker()->registerJob(this);
Daemon::instance()->jobTracker()->registerJob(this);
}
}

View file

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

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -24,12 +24,22 @@
#include <core/daemon.h>
#include <core/backends/pairinghandler.h>
#include <QCoreApplication>
#include <KJobTrackerInterface>
#ifdef HAVE_KIO
#include <KIO/AccessManager>
#else
#include <QNetworkAccessManager>
#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