From df9e4e43b0e3e9945d9b32c1b0683314239d1476 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 30 May 2019 23:33:38 +0900 Subject: Adjusted to new TDEStorageOpResult-based tdelibs api. Signed-off-by: Michele Calgaro --- kcontrol/hwmanager/devicepropsdlg.cpp | 24 +++++++++++------------- kcontrol/hwmanager/hwdevicetray.cpp | 11 ++++++----- 2 files changed, 17 insertions(+), 18 deletions(-) (limited to 'kcontrol/hwmanager') diff --git a/kcontrol/hwmanager/devicepropsdlg.cpp b/kcontrol/hwmanager/devicepropsdlg.cpp index 885dc7a7a..c97c6dea2 100644 --- a/kcontrol/hwmanager/devicepropsdlg.cpp +++ b/kcontrol/hwmanager/devicepropsdlg.cpp @@ -879,21 +879,19 @@ void DevicePropertiesDialog::setHibernationMethod(int value) { void DevicePropertiesDialog::mountDisk() { TDEStorageDevice* sdevice = static_cast(m_device); - - // FIXME - // This can only mount normal volumes TQString qerror; TQString diskLabel = sdevice->diskLabel(); if (diskLabel.isNull()) { diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize()); } TDEStorageMountOptions mountOptions; - TQString mountMessages; - TQString mountedPath = sdevice->mountDevice(diskLabel, mountOptions, &mountMessages); - if (mountedPath.isNull()) { + TDEStorageOpResult mountResult = sdevice->mountDevice(diskLabel, mountOptions); + TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null; + if (mountedPath.isEmpty()) { qerror = i18n("Unable to mount this device.

Potential reasons include:
Improper device and/or user privilege level
Corrupt data on storage device"); - if (!mountMessages.isNull()) { - qerror.append(i18n("

Technical details:
").append(mountMessages)); + TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null; + if (!errStr.isEmpty()) { + qerror.append(i18n("

Technical details:
").append(errStr)); } qerror.append(""); } @@ -910,13 +908,13 @@ void DevicePropertiesDialog::unmountDisk() { TDEStorageDevice* sdevice = static_cast(m_device); TQString qerror; - TQString unmountMessages; - int unmountRetcode = 0; - if (!sdevice->unmountDevice(&unmountMessages, &unmountRetcode)) { + TDEStorageOpResult unmountResult = sdevice->unmountDevice(); + if (unmountResult["result"].toBool() == false) { // Unmount failed! qerror = "" + i18n("Unfortunately, the device could not be unmounted."); - if (!unmountMessages.isNull()) { - qerror.append(i18n("

Technical details:
").append(unmountMessages)); + TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null; + if (!errStr.isEmpty()) { + qerror.append(i18n("

Technical details:
").append(errStr)); } qerror.append(""); } diff --git a/kcontrol/hwmanager/hwdevicetray.cpp b/kcontrol/hwmanager/hwdevicetray.cpp index b6ef8a6ad..ae3a1db23 100644 --- a/kcontrol/hwmanager/hwdevicetray.cpp +++ b/kcontrol/hwmanager/hwdevicetray.cpp @@ -300,11 +300,12 @@ void HwDeviceSystemTray::slotUnmountDevice(int parameter) for (hwdevice = diskDeviceList.first(); hwdevice; hwdevice = diskDeviceList.next()) { TDEStorageDevice* sdevice = static_cast(hwdevice); if ((sdevice->diskUUID() == uuid) || (sdevice->systemPath() == uuid)) { - if (sdevice->mountPath() != TQString::null) { - int retcode; - TQString errstr; - if (!sdevice->unmountDevice(&errstr, &retcode)) { - KMessageBox::error(0, i18n("Unable to eject device

Detailed error information:
%1 (code %2)").arg(errstr).arg(retcode), i18n("Eject Failed")); + if (!sdevice->mountPath().isEmpty()) { + TDEStorageOpResult unmountResult = sdevice->unmountDevice(); + if (unmountResult["result"].toBool() == false) { + TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null; + TQString retcodeStr = unmountResult.contains("retCode") ? unmountResult["retCode"].asString() : "not available"; + KMessageBox::error(0, i18n("Unable to eject device

Detailed error information:
%1 (error code %2)").arg(errStr).arg(retcodeStr), i18n("Eject Failed")); } return; } -- cgit v1.2.1