summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw/tdestoragedevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdecore/tdehw/tdestoragedevice.cpp')
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp55
1 files changed, 42 insertions, 13 deletions
diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp
index ba88d6de..60ea5191 100644
--- a/tdecore/tdehw/tdestoragedevice.cpp
+++ b/tdecore/tdehw/tdestoragedevice.cpp
@@ -327,28 +327,47 @@ bool TDEStorageDevice::lockDriveMedia(bool lock) {
}
}
-bool TDEStorageDevice::ejectDrive() {
+TQStringVariantMap TDEStorageDevice::ejectDrive() {
+ TQStringVariantMap result;
+ TQStringVariantMap ejectResult;
+
#ifdef WITH_UDISKS2
if (!(TDEGlobal::dirs()->findExe("udisksctl").isEmpty())) {
- TQStringVariantMap ejectResult = udisks2EjectDrive(this);
+ ejectResult = udisks2EjectDrive(this);
if (ejectResult["result"].toBool()) {
- return true;
+ // Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
+ TDEGlobal::hardwareDevices()->processModifiedMounts();
+ result["result"] = true;
+ return result;
}
else {
- printf("[tdehwlib] Failed to eject drive '%s' via udisks2, falling back to alternate mechanism\n", deviceNode().ascii());
- fflush(stdout);
+ // Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
+ TDEGlobal::hardwareDevices()->processModifiedMounts();
+ result["errStr"] = ejectResult["errStr"];
+ result["result"] = false;
+ return result;
}
}
#endif
#ifdef WITH_UDISKS
if (!(TDEGlobal::dirs()->findExe("udisks").isEmpty())) {
- TQStringVariantMap ejectResult = udisksEjectDrive(this);
+ ejectResult = udisksEjectDrive(this);
if (ejectResult["result"].toBool()) {
- return true;
+ // Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
+ TDEGlobal::hardwareDevices()->processModifiedMounts();
+ result["result"] = true;
+ return result;
}
else {
- printf("[tdehwlib] Failed to eject drive '%s' via udisks, falling back to alternate mechanism\n", deviceNode().ascii());
- fflush(stdout);
+ // Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
+ TDEGlobal::hardwareDevices()->processModifiedMounts();
+ result["errStr"] = ejectResult["errStr"];
+ result["result"] = false;
+ return result;
}
}
#endif
@@ -363,14 +382,24 @@ bool TDEStorageDevice::ejectDrive() {
eject_output = ts.read();
int retcode = pclose(exepipe);
if (retcode == 0) {
- return true;
+ // Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
+ TDEGlobal::hardwareDevices()->processModifiedMounts();
+ result["result"] = true;
+ return result;
+ }
+ else {
+ result["errStr"] = eject_output;
+ result["retCode"] = retcode;
}
}
- printf("[tdehwlib] Failed to eject drive '%s' via 'eject' command\n", deviceNode().ascii());
- fflush(stdout);
}
- return false;
+ // Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
+ TDEGlobal::hardwareDevices()->processModifiedMounts();
+ result["result"] = false;
+ return result;
}
bool TDEStorageDevice::ejectDriveMedia() {