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,13 +21,16 @@
#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"
CompositeUploadJob::CompositeUploadJob(const QString& deviceId, bool displayNotification)
#ifdef HAVE_KIO
#include <kio/global.h>
#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<QString, QString> 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
);
}

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