Handle errorMessage in kdeconnect.sftp packet
This commit is contained in:
parent
74ba660cad
commit
273c9bb6e4
4 changed files with 23 additions and 2 deletions
|
@ -143,7 +143,7 @@ void KioKdeconnect::listDevice()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mountreply.value()) {
|
if (!mountreply.value()) {
|
||||||
error(KIO::ERR_COULD_NOT_MOUNT, i18n("Could not mount device filesystem"));
|
error(KIO::ERR_COULD_NOT_MOUNT, interface.getMountError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,11 @@ void Mounter::onPackageReceived(const NetworkPacket& np)
|
||||||
unmount(false);
|
unmount(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (np.has("errorMessage")) {
|
||||||
|
Q_EMIT failed(np.get<QString>("errorMessage", ""));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//This is the previous code, to access sftp server using KIO. Now we are
|
//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.
|
//using the external binary sshfs, and accessing it as a local filesystem.
|
||||||
|
|
|
@ -117,6 +117,16 @@ bool SftpPlugin::isMounted() const
|
||||||
return d->m_mounter && d->m_mounter->isMounted();
|
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()
|
bool SftpPlugin::startBrowsing()
|
||||||
{
|
{
|
||||||
if (mountAndWait()) {
|
if (mountAndWait()) {
|
||||||
|
@ -128,7 +138,7 @@ bool SftpPlugin::startBrowsing()
|
||||||
|
|
||||||
bool SftpPlugin::receivePacket(const NetworkPacket& np)
|
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
|
// packet is invalid
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -147,6 +157,10 @@ bool SftpPlugin::receivePacket(const NetworkPacket& np)
|
||||||
remoteDirectories.insert(mountPoint(), i18n("All files"));
|
remoteDirectories.insert(mountPoint(), i18n("All files"));
|
||||||
remoteDirectories.insert(mountPoint() + "/DCIM/Camera", i18n("Camera pictures"));
|
remoteDirectories.insert(mountPoint() + "/DCIM/Camera", i18n("Camera pictures"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (np.has("errorMessage")) {
|
||||||
|
mountError = np.get<QString>("errorMessage");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public Q_SLOTS:
|
||||||
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 bool startBrowsing();
|
Q_SCRIPTABLE bool startBrowsing();
|
||||||
Q_SCRIPTABLE QString mountPoint();
|
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
|
QString deviceId; //Storing it to avoid accessing device() from the destructor which could cause a crash
|
||||||
|
|
||||||
QVariantMap remoteDirectories; //Actually a QMap<String, String>, but QDBus prefers this
|
QVariantMap remoteDirectories; //Actually a QMap<String, String>, but QDBus prefers this
|
||||||
|
QString mountError;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue