From efa644f0a4fb86f50e333f187f0ad5606ba39f84 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sat, 9 Mar 2019 14:52:29 +0000 Subject: [PATCH] [sftp] Get device ID from URL --- kio/kiokdeconnect.cpp | 32 +++++++------------------------- kio/kiokdeconnect.h | 9 +-------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/kio/kiokdeconnect.cpp b/kio/kiokdeconnect.cpp index 37127da45..042736889 100644 --- a/kio/kiokdeconnect.cpp +++ b/kio/kiokdeconnect.cpp @@ -128,13 +128,13 @@ void KioKdeconnect::listAllDevices() finished(); } -void KioKdeconnect::listDevice() +void KioKdeconnect::listDevice(const QString& device) { infoMessage(i18n("Accessing device...")); - qCDebug(KDECONNECT_KIO) << "ListDevice" << m_currentDevice; + qCDebug(KDECONNECT_KIO) << "ListDevice" << device; - SftpDbusInterface interface(m_currentDevice); + SftpDbusInterface interface(device); QDBusReply mountreply = interface.mountAndWait(); @@ -191,20 +191,18 @@ void KioKdeconnect::listDir(const QUrl& url) { qCDebug(KDECONNECT_KIO) << "Listing..." << url; - /// Url is not used here because all we could care about the url is the host, and that's already - /// handled in @p setHost - Q_UNUSED(url); - if (!m_dbusInterface->isValid()) { infoMessage(i18n("Could not contact background service.")); finished(); return; } - if (m_currentDevice.isEmpty()) { + QString currentDevice = url.host(); + + if (currentDevice.isEmpty()) { listAllDevices(); } else { - listDevice(); + listDevice(currentDevice); } } @@ -226,21 +224,5 @@ void KioKdeconnect::get(const QUrl& url) finished(); } -void KioKdeconnect::setHost(const QString& hostName, quint16 port, const QString& user, const QString& pass) -{ - - //This is called before everything else to set the file we want to show - - qCDebug(KDECONNECT_KIO) << "Setting host: " << hostName; - - // In this kio only the hostname is used - Q_UNUSED(port) - Q_UNUSED(user) - Q_UNUSED(pass) - - m_currentDevice = hostName; - -} - //needed for JSON file embedding #include "kiokdeconnect.moc" diff --git a/kio/kiokdeconnect.h b/kio/kiokdeconnect.h index 1f5bf4dde..e5e5cbf9a 100644 --- a/kio/kiokdeconnect.h +++ b/kio/kiokdeconnect.h @@ -41,19 +41,12 @@ public: void listDir(const QUrl& url) override; void stat(const QUrl& url) override; - void setHost(const QString& constHostname, quint16 port, const QString& user, const QString& pass) override; - void listAllDevices(); //List all devices exported by m_dbusInterface - void listDevice(); //List m_currentDevice + void listDevice(const QString& device); //List m_currentDevice private: - /** - * Contains the ID of the current device or is empty when no device is set. - */ - QString m_currentDevice; - /** * KDED DBus interface, used to communicate to the daemon since we need some status (like connected) */