diff options
author | Michele Calgaro <[email protected]> | 2019-08-25 20:27:06 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2020-10-17 10:48:29 +0800 |
commit | 1a089178fa6b7d19326a1b37d554f2e56c30f6f7 (patch) | |
tree | e250f4902a53aa7db802447eff28ff8d2f224663 /tdeioslave/media/mediamanager/halbackend.cpp | |
parent | 7c6e00a43ce3626e0450954ab1234c78048fcb58 (diff) | |
download | tdebase-1a089178fa6b7d19326a1b37d554f2e56c30f6f7.tar.gz tdebase-1a089178fa6b7d19326a1b37d554f2e56c30f6f7.zip |
tdeioslave media: mount/unmount/unlock/lock are only allowed on devices
for which those operations make sense.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'tdeioslave/media/mediamanager/halbackend.cpp')
-rw-r--r-- | tdeioslave/media/mediamanager/halbackend.cpp | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/tdeioslave/media/mediamanager/halbackend.cpp b/tdeioslave/media/mediamanager/halbackend.cpp index 190dda774..3c6f38af1 100644 --- a/tdeioslave/media/mediamanager/halbackend.cpp +++ b/tdeioslave/media/mediamanager/halbackend.cpp @@ -1488,8 +1488,14 @@ TQString HALBackend::isInFstab(const Medium *medium) TQStringVariantMap HALBackend::mount(const Medium *medium) { TQStringVariantMap result; - if (medium->isMounted()) { - result["result"] = true; + if (!medium->isMountable()) { + result["errStr"] = i18n("%1 is not a mountable media.").arg(medium->deviceNode()); + result["result"] = false; + return result; + } + else if (medium->isMounted()) { + result["errStr"] = i18n("%1 is already mounted to %2.").arg(medium->deviceNode()).arg(medium->mountPoint()); + result["result"] = false; return result; } @@ -1666,14 +1672,19 @@ TQStringVariantMap HALBackend::unmount(const TQString &id) result["result"] = false; return result; } - - if (!medium->isMounted()) { - result["result"] = true; + else if (!medium->isMountable()) { + result["errStr"] = i18n("%1 is not a mountable media.").arg(medium->deviceNode()); + result["result"] = false; + return result; + } + else if (!medium->isMounted()) { + result["errStr"] = i18n("%1 is already unmounted.").arg(medium->deviceNode()); + result["result"] = false; return result; } TQString mountPoint = isInFstab(medium); - if (!mountPoint.isNull()) + if (!mountPoint.isEmpty()) { struct mount_job_data data; data.completed = false; @@ -1848,9 +1859,14 @@ TQStringVariantMap HALBackend::unlock(const TQString &id, const TQString &passwo result["result"] = false; return result; } - - if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull()) { - result["result"] = true; + else if (!medium->isEncrypted()) { + result["errStr"] = i18n("%1 is not an encrypted media.").arg(medium->deviceNode()); + result["result"] = false; + return result; + } + else if (!medium->needUnlocking()) { + result["errStr"] = i18n("%1 is already unlocked.").arg(medium->deviceNode()); + result["result"] = false; return result; } @@ -1917,9 +1933,14 @@ TQStringVariantMap HALBackend::lock(const TQString &id) result["result"] = false; return result; } - - if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull()) { - result["result"] = true; + else if (!medium->isEncrypted()) { + result["errStr"] = i18n("%1 is not an encrypted media.").arg(medium->deviceNode()); + result["result"] = false; + return result; + } + else if (medium->needUnlocking()) { + result["errStr"] = i18n("%1 is already locked.").arg(medium->deviceNode()); + result["result"] = false; return result; } |