diff --git a/kio/kiokdeconnect.cpp b/kio/kiokdeconnect.cpp index 7e9f6c99a..37127da45 100644 --- a/kio/kiokdeconnect.cpp +++ b/kio/kiokdeconnect.cpp @@ -143,7 +143,7 @@ void KioKdeconnect::listDevice() } if (!mountreply.value()) { - error(KIO::ERR_COULD_NOT_MOUNT, i18n("Could not mount device filesystem")); + error(KIO::ERR_COULD_NOT_MOUNT, interface.getMountError()); return; } diff --git a/plugins/sftp/mounter.cpp b/plugins/sftp/mounter.cpp index 3d3526ed8..5480f4caf 100644 --- a/plugins/sftp/mounter.cpp +++ b/plugins/sftp/mounter.cpp @@ -82,6 +82,11 @@ void Mounter::onPackageReceived(const NetworkPacket& np) unmount(false); return; } + + if (np.has("errorMessage")) { + Q_EMIT failed(np.get("errorMessage", "")); + return; + } //This is the previous code, to access sftp server using KIO. Now we are //using the external binary sshfs, and accessing it as a local filesystem. diff --git a/plugins/sftp/sftpplugin.cpp b/plugins/sftp/sftpplugin.cpp index 7ab6e5ea1..608253628 100644 --- a/plugins/sftp/sftpplugin.cpp +++ b/plugins/sftp/sftpplugin.cpp @@ -117,6 +117,16 @@ bool SftpPlugin::isMounted() const return d->m_mounter && d->m_mounter->isMounted(); } +QString SftpPlugin::getMountError() +{ + if (!mountError.isEmpty()) { + return mountError; + } else { + return i18n("Could not mount device filesystem"); + } +} + + bool SftpPlugin::startBrowsing() { if (mountAndWait()) { @@ -128,7 +138,7 @@ bool SftpPlugin::startBrowsing() bool SftpPlugin::receivePacket(const NetworkPacket& np) { - if (!(fields_c - np.body().keys().toSet()).isEmpty()) { + if (!(fields_c - np.body().keys().toSet()).isEmpty() && !np.has("errorMessage")) { // packet is invalid return false; } @@ -147,6 +157,10 @@ bool SftpPlugin::receivePacket(const NetworkPacket& np) remoteDirectories.insert(mountPoint(), i18n("All files")); remoteDirectories.insert(mountPoint() + "/DCIM/Camera", i18n("Camera pictures")); } + + if (np.has("errorMessage")) { + mountError = np.get("errorMessage"); + } return true; } diff --git a/plugins/sftp/sftpplugin.h b/plugins/sftp/sftpplugin.h index 32ca85be3..c0881c68e 100644 --- a/plugins/sftp/sftpplugin.h +++ b/plugins/sftp/sftpplugin.h @@ -50,6 +50,7 @@ public Q_SLOTS: 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(); @@ -71,6 +72,7 @@ private: QString deviceId; //Storing it to avoid accessing device() from the destructor which could cause a crash QVariantMap remoteDirectories; //Actually a QMap, but QDBus prefers this + QString mountError; };