Cleanup signals and slots in SftpPlugin

This commit is contained in:
Albert Vaca Cintora 2023-08-24 18:14:59 +02:00
parent 1ef9d7e2a0
commit 45615f8acf
4 changed files with 11 additions and 18 deletions

View file

@ -24,8 +24,6 @@ Mounter::Mounter(SftpPlugin *sftp)
, m_mountPoint(sftp->mountPoint()) , m_mountPoint(sftp->mountPoint())
, m_started(false) , m_started(false)
{ {
connect(m_sftp, &SftpPlugin::packetReceived, this, &Mounter::onPackageReceived);
connect(&m_connectTimer, &QTimer::timeout, this, &Mounter::onMountTimeout); connect(&m_connectTimer, &QTimer::timeout, this, &Mounter::onMountTimeout);
connect(this, &Mounter::mounted, &m_connectTimer, &QTimer::stop); connect(this, &Mounter::mounted, &m_connectTimer, &QTimer::stop);
@ -58,7 +56,7 @@ bool Mounter::wait()
return loop.exec(); return loop.exec();
} }
void Mounter::onPackageReceived(const NetworkPacket &np) void Mounter::onPacketReceived(const NetworkPacket &np)
{ {
if (np.get<bool>(QStringLiteral("stop"), false)) { if (np.get<bool>(QStringLiteral("stop"), false)) {
qCDebug(KDECONNECT_PLUGIN_SFTP) << "SFTP server stopped"; qCDebug(KDECONNECT_PLUGIN_SFTP) << "SFTP server stopped";

View file

@ -25,6 +25,7 @@ public:
{ {
return m_started; return m_started;
} }
void onPacketReceived(const NetworkPacket &np);
Q_SIGNALS: Q_SIGNALS:
void mounted(); void mounted();
@ -32,7 +33,6 @@ Q_SIGNALS:
void failed(const QString &message); void failed(const QString &message);
private Q_SLOTS: private Q_SLOTS:
void onPackageReceived(const NetworkPacket &np);
void onStarted(); void onStarted();
void onError(QProcess::ProcessError error); void onError(QProcess::ProcessError error);
void onFinished(int exitCode, QProcess::ExitStatus exitStatus); void onFinished(int exitCode, QProcess::ExitStatus exitStatus);

View file

@ -130,7 +130,7 @@ void SftpPlugin::receivePacket(const NetworkPacket &np)
return; return;
} }
Q_EMIT packetReceived(np); d->m_mounter->onPacketReceived(np);
remoteDirectories.clear(); remoteDirectories.clear();
if (np.has(QStringLiteral("multiPaths"))) { if (np.has(QStringLiteral("multiPaths"))) {

View file

@ -26,32 +26,24 @@ public:
return QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/sftp"); return QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/sftp");
} }
Q_SIGNALS: Q_SCRIPTABLE bool startBrowsing();
void packetReceived(const NetworkPacket &np);
Q_SCRIPTABLE void mounted();
Q_SCRIPTABLE void unmounted();
public Q_SLOTS:
Q_SCRIPTABLE void mount(); Q_SCRIPTABLE void mount();
Q_SCRIPTABLE void unmount(); Q_SCRIPTABLE void unmount();
Q_SCRIPTABLE bool mountAndWait(); Q_SCRIPTABLE bool mountAndWait();
Q_SCRIPTABLE bool isMounted() const; Q_SCRIPTABLE bool isMounted() const;
Q_SCRIPTABLE QString getMountError(); Q_SCRIPTABLE QString getMountError();
Q_SCRIPTABLE bool startBrowsing();
Q_SCRIPTABLE QString mountPoint(); Q_SCRIPTABLE QString mountPoint();
Q_SCRIPTABLE QVariantMap getDirectories(); // Actually a QMap<String, String>, but QDBus prefers this Q_SCRIPTABLE QVariantMap getDirectories(); // Actually a QMap<String, String>, but QDBus prefers this
Q_SIGNALS:
Q_SCRIPTABLE void mounted();
Q_SCRIPTABLE void unmounted();
private Q_SLOTS: private Q_SLOTS:
void onMounted(); void onMounted();
void onUnmounted(); void onUnmounted();
void onFailed(const QString &message); void onFailed(const QString &message);
private:
void knotify(int type, const QString &text, const QPixmap &icon) const;
void addToDolphin();
void removeFromDolphin();
private: private:
struct Pimpl; struct Pimpl;
QScopedPointer<Pimpl> d; QScopedPointer<Pimpl> d;
@ -59,4 +51,7 @@ private:
QVariantMap remoteDirectories; // Actually a QMap<String, String>, but QDBus prefers this QVariantMap remoteDirectories; // Actually a QMap<String, String>, but QDBus prefers this
QString mountError; QString mountError;
void addToDolphin();
void removeFromDolphin();
}; };