From 45615f8acfbedad36b23cbd11c9c07042cdaa015 Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Thu, 24 Aug 2023 18:14:59 +0200 Subject: [PATCH] Cleanup signals and slots in SftpPlugin --- plugins/sftp/mounter.cpp | 4 +--- plugins/sftp/mounter.h | 2 +- plugins/sftp/sftpplugin.cpp | 2 +- plugins/sftp/sftpplugin.h | 21 ++++++++------------- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/plugins/sftp/mounter.cpp b/plugins/sftp/mounter.cpp index 5d9a230a9..d466ed3de 100644 --- a/plugins/sftp/mounter.cpp +++ b/plugins/sftp/mounter.cpp @@ -24,8 +24,6 @@ Mounter::Mounter(SftpPlugin *sftp) , m_mountPoint(sftp->mountPoint()) , m_started(false) { - connect(m_sftp, &SftpPlugin::packetReceived, this, &Mounter::onPackageReceived); - connect(&m_connectTimer, &QTimer::timeout, this, &Mounter::onMountTimeout); connect(this, &Mounter::mounted, &m_connectTimer, &QTimer::stop); @@ -58,7 +56,7 @@ bool Mounter::wait() return loop.exec(); } -void Mounter::onPackageReceived(const NetworkPacket &np) +void Mounter::onPacketReceived(const NetworkPacket &np) { if (np.get(QStringLiteral("stop"), false)) { qCDebug(KDECONNECT_PLUGIN_SFTP) << "SFTP server stopped"; diff --git a/plugins/sftp/mounter.h b/plugins/sftp/mounter.h index a476870a4..4ce2ec51c 100644 --- a/plugins/sftp/mounter.h +++ b/plugins/sftp/mounter.h @@ -25,6 +25,7 @@ public: { return m_started; } + void onPacketReceived(const NetworkPacket &np); Q_SIGNALS: void mounted(); @@ -32,7 +33,6 @@ Q_SIGNALS: void failed(const QString &message); private Q_SLOTS: - void onPackageReceived(const NetworkPacket &np); void onStarted(); void onError(QProcess::ProcessError error); void onFinished(int exitCode, QProcess::ExitStatus exitStatus); diff --git a/plugins/sftp/sftpplugin.cpp b/plugins/sftp/sftpplugin.cpp index 9e8b3d2e4..650fb7450 100644 --- a/plugins/sftp/sftpplugin.cpp +++ b/plugins/sftp/sftpplugin.cpp @@ -130,7 +130,7 @@ void SftpPlugin::receivePacket(const NetworkPacket &np) return; } - Q_EMIT packetReceived(np); + d->m_mounter->onPacketReceived(np); remoteDirectories.clear(); if (np.has(QStringLiteral("multiPaths"))) { diff --git a/plugins/sftp/sftpplugin.h b/plugins/sftp/sftpplugin.h index 9efe511e4..b47338ba4 100644 --- a/plugins/sftp/sftpplugin.h +++ b/plugins/sftp/sftpplugin.h @@ -26,32 +26,24 @@ public: return QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/sftp"); } -Q_SIGNALS: - void packetReceived(const NetworkPacket &np); - Q_SCRIPTABLE void mounted(); - Q_SCRIPTABLE void unmounted(); - -public Q_SLOTS: + Q_SCRIPTABLE bool startBrowsing(); Q_SCRIPTABLE void mount(); Q_SCRIPTABLE void unmount(); Q_SCRIPTABLE bool mountAndWait(); Q_SCRIPTABLE bool isMounted() const; Q_SCRIPTABLE QString getMountError(); - - Q_SCRIPTABLE bool startBrowsing(); Q_SCRIPTABLE QString mountPoint(); Q_SCRIPTABLE QVariantMap getDirectories(); // Actually a QMap, but QDBus prefers this +Q_SIGNALS: + Q_SCRIPTABLE void mounted(); + Q_SCRIPTABLE void unmounted(); + private Q_SLOTS: void onMounted(); void onUnmounted(); void onFailed(const QString &message); -private: - void knotify(int type, const QString &text, const QPixmap &icon) const; - void addToDolphin(); - void removeFromDolphin(); - private: struct Pimpl; QScopedPointer d; @@ -59,4 +51,7 @@ private: QVariantMap remoteDirectories; // Actually a QMap, but QDBus prefers this QString mountError; + + void addToDolphin(); + void removeFromDolphin(); };