From b248e37b81b01563fdf3d6aa34db74b58fee7d43 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sat, 9 Mar 2019 03:40:59 +0100 Subject: [PATCH] [sftp] Give better error messages for common errors --- kio/kiokdeconnect.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/kio/kiokdeconnect.cpp b/kio/kiokdeconnect.cpp index 97224fb7f..d002ba9ab 100644 --- a/kio/kiokdeconnect.cpp +++ b/kio/kiokdeconnect.cpp @@ -138,6 +138,36 @@ void KioKdeconnect::listDevice(const QString& device) QDBusReply mountreply = interface.mountAndWait(); + if (mountreply.error().type() == QDBusError::UnknownObject) { + + DaemonDbusInterface daemon; + + auto devsRepl = daemon.devices(false, false); + devsRepl.waitForFinished(); + + if (!devsRepl.value().contains(device)) { + error(KIO::ERR_SLAVE_DEFINED, i18n("No such device: %0").arg(device)); + return; + } + + DeviceDbusInterface dev(device); + + if (!dev.isTrusted()) { + error(KIO::ERR_SLAVE_DEFINED, i18n("%0 is not paired").arg(dev.name())); + return; + } + + if (!dev.isReachable()) { + error(KIO::ERR_SLAVE_DEFINED, i18n("%0 is not connected").arg(dev.name())); + return; + } + + if (!dev.hasPlugin(QStringLiteral("kdeconnect_sftp"))) { + error(KIO::ERR_SLAVE_DEFINED, i18n("%0 has no SFTP plugin").arg(dev.name())); + return; + } + } + if (handleDBusError(mountreply, this)) { return; }