Compare commits

...

3 commits

Author SHA1 Message Date
Albert Vaca Cintora
0044f09b12 Follow-up to my previous commit (fixes build) 2023-04-10 10:52:02 +02:00
Albert Vaca Cintora
d05ef54b2a Further KIO::AccessManager cleanup 2023-04-10 10:29:08 +02:00
Nicolas Fella
7b8003fe2c Don't use KIO::AccessManager
The main thing it provides over QNetworkAccessManager is integration
with the CookieJar and using kio-http, but since we jsut exchange bytes
from another local device that's not interesting for us
2023-04-10 10:28:33 +02:00
8 changed files with 4 additions and 39 deletions

View file

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

View file

@ -39,7 +39,7 @@ public:
virtual void askPairingConfirmation(Device *device) = 0; virtual void askPairingConfirmation(Device *device) = 0;
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(); QNetworkAccessManager *networkAccessManager();
virtual KJobTrackerInterface *jobTracker() = 0; virtual KJobTrackerInterface *jobTracker() = 0;
Device *getDevice(const QString &deviceId); Device *getDevice(const QString &deviceId);

View file

@ -12,6 +12,7 @@
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <qalgorithms.h> #include <qalgorithms.h>
#include <QNetworkAccessManager>
#include <KLocalizedString> #include <KLocalizedString>

View file

@ -9,7 +9,6 @@
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QDBusMessage> #include <QDBusMessage>
#include <QIcon> #include <QIcon>
#include <QNetworkAccessManager>
#include <QProcess> #include <QProcess>
#include <QSessionManager> #include <QSessionManager>
#include <QStandardPaths> #include <QStandardPaths>
@ -17,10 +16,10 @@
#include <KAboutData> #include <KAboutData>
#include <KDBusService> #include <KDBusService>
#include <KIO/AccessManager>
#include <KLocalizedString> #include <KLocalizedString>
#include <KNotification> #include <KNotification>
#include <KWindowSystem> #include <KWindowSystem>
#include <KIO/Global>
#include <dbushelper.h> #include <dbushelper.h>
@ -38,7 +37,6 @@ class DesktopDaemon : public Daemon
public: public:
DesktopDaemon(QObject *parent = nullptr) DesktopDaemon(QObject *parent = nullptr)
: Daemon(parent) : Daemon(parent)
, m_nam(nullptr)
{ {
qApp->setWindowIcon(QIcon(QStringLiteral(":/icons/kdeconnect/kdeconnect.svg"))); qApp->setWindowIcon(QIcon(QStringLiteral(":/icons/kdeconnect/kdeconnect.svg")));
} }
@ -73,14 +71,6 @@ public:
KNotification::event(KNotification::Error, title, description); KNotification::event(KNotification::Error, title, description);
} }
QNetworkAccessManager *networkAccessManager() override
{
if (!m_nam) {
m_nam = new KIO::Integration::AccessManager(this);
}
return m_nam;
}
KJobTrackerInterface *jobTracker() override KJobTrackerInterface *jobTracker() override
{ {
return KIO::getJobTracker(); return KIO::getJobTracker();
@ -100,9 +90,6 @@ public:
{ {
QApplication::quit(); QApplication::quit();
} }
private:
QNetworkAccessManager *m_nam;
}; };
// Copied from plasma-workspace/libkworkspace/kworkspace.cpp // Copied from plasma-workspace/libkworkspace/kworkspace.cpp

View file

@ -128,7 +128,7 @@ bool SharePlugin::receivePacket(const NetworkPacket &np)
m_compositeJob = new CompositeFileTransferJob(device()->id()); m_compositeJob = new CompositeFileTransferJob(device()->id());
m_compositeJob->setProperty("destUrl", destinationDir().toString()); m_compositeJob->setProperty("destUrl", destinationDir().toString());
m_compositeJob->setProperty("immediateProgressReporting", true); m_compositeJob->setProperty("immediateProgressReporting", true);
KIO::getJobTracker()->registerJob(m_compositeJob); Daemon::instance()->jobTracker()->registerJob(m_compositeJob);
} }
FileTransferJob *job = np.createPayloadTransferJob(destination); FileTransferJob *job = np.createPayloadTransferJob(destination);

View file

@ -5,7 +5,6 @@
*/ */
#include <QCoreApplication> #include <QCoreApplication>
#include <QNetworkAccessManager>
#include <QSignalSpy> #include <QSignalSpy>
#include <QSocketNotifier> #include <QSocketNotifier>
#include <QStandardPaths> #include <QStandardPaths>

View file

@ -5,7 +5,6 @@
*/ */
#include <QCoreApplication> #include <QCoreApplication>
#include <QNetworkAccessManager>
#include <QSignalSpy> #include <QSignalSpy>
#include <QSocketNotifier> #include <QSocketNotifier>
#include <QStandardPaths> #include <QStandardPaths>

View file

@ -13,18 +13,11 @@
#include <KJobTrackerInterface> #include <KJobTrackerInterface>
#include <QCoreApplication> #include <QCoreApplication>
#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_jobTrackerInterface(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
@ -47,18 +40,6 @@ public:
d->acceptPairing(); d->acceptPairing();
} }
QNetworkAccessManager *networkAccessManager() override
{
if (!m_nam) {
#ifdef HAVE_KIO
m_nam = new KIO::Integration::AccessManager(this);
#else
m_nam = new QNetworkAccessManager(this);
#endif
}
return m_nam;
}
Q_SCRIPTABLE virtual void sendSimpleNotification(const QString &eventId, const QString &title, const QString &text, const QString &iconName) override Q_SCRIPTABLE virtual void sendSimpleNotification(const QString &eventId, const QString &title, const QString &text, const QString &iconName) override
{ {
qDebug() << eventId << title << text << iconName; qDebug() << eventId << title << text << iconName;
@ -78,7 +59,6 @@ public:
} }
private: private:
QNetworkAccessManager *m_nam;
KJobTrackerInterface *m_jobTrackerInterface; KJobTrackerInterface *m_jobTrackerInterface;
}; };