summaryrefslogtreecommitdiffstats
path: root/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2022-02-19 16:13:03 +0900
committerMichele Calgaro <[email protected]>2022-02-19 16:13:03 +0900
commit8d0f49aeb4a37176e25c7393ad6a31b8b9e8fcf4 (patch)
treea0cb97849a1dea54c91bed8bca9bfb800bdf5019 /tdeioslave/media/mediamanager/tdehardwarebackend.cpp
parentcc236553afa96e1f2bd2dba35b9d93080e273f8c (diff)
downloadtdebase-8d0f49aeb4a37176e25c7393ad6a31b8b9e8fcf4.tar.gz
tdebase-8d0f49aeb4a37176e25c7393ad6a31b8b9e8fcf4.zip
Added 'eject' and 'ejectByNode' to mediamanager DCOP interface.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'tdeioslave/media/mediamanager/tdehardwarebackend.cpp')
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
index 1da7634d0..ba99b8c0c 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
@@ -1474,7 +1474,6 @@ TQStringVariantMap TDEBackend::unlock(const TQString &id, const TQString &passwo
}
ResetProperties(sdevice, false, true);
- result["result"] = unlockResult["unlockedDevice"];
result["result"] = true;
return result;
}
@@ -1526,6 +1525,47 @@ TQStringVariantMap TDEBackend::lock(const TQString &id)
return result;
}
+TQStringVariantMap TDEBackend::eject(const TQString &id)
+{
+ kdDebug(1219) << "TDEBackend::eject for id " << id << endl;
+
+ TQStringVariantMap result;
+
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium)
+ {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+
+ TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
+ if (!sdevice)
+ {
+ result["errStr"] = i18n("Internal error. Couldn't find medium id %1.").arg(medium->id());
+ result["result"] = false;
+ return result;
+ }
+
+ TQStringVariantMap ejectResult = sdevice->ejectDrive();
+ if (ejectResult["result"].toBool() == false)
+ {
+ TQString qerror = i18n("<b>Unable to eject the device.</b>");
+ TQString errStr = ejectResult.contains("errStr") ? ejectResult["errStr"].toString() : TQString::null;
+ if (!errStr.isEmpty())
+ {
+ qerror.append(i18n("<p>Technical details:<br>").append(errStr));
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
+ }
+ }
+
+ result["result"] = true;
+ return result;
+}
+
void TDEBackend::slotResult(TDEIO::Job *job)
{
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();