diff options
author | Michele Calgaro <[email protected]> | 2022-03-07 16:03:45 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2022-03-07 16:03:45 +0900 |
commit | 449305f1909fa8cec59834bb42d35237495b28ce (patch) | |
tree | 44828802ed7a0ffb79e2cb38fdc23b8570835099 /kcontrol/hwmanager/devicepropsdlg.cpp | |
parent | b173191cf8edf14c7c1abc859c2bbde3b4bf3c82 (diff) | |
download | tdebase-449305f1909fa8cec59834bb42d35237495b28ce.tar.gz tdebase-449305f1909fa8cec59834bb42d35237495b28ce.zip |
tdehwdevicetray: use DCOP calls instead of direct tdehw calls to mount/unmount/unlock/lock/eject devices. This is for consistency of behavior and error messages.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'kcontrol/hwmanager/devicepropsdlg.cpp')
-rw-r--r-- | kcontrol/hwmanager/devicepropsdlg.cpp | 63 |
1 files changed, 26 insertions, 37 deletions
diff --git a/kcontrol/hwmanager/devicepropsdlg.cpp b/kcontrol/hwmanager/devicepropsdlg.cpp index ffb19da1a..9256110d2 100644 --- a/kcontrol/hwmanager/devicepropsdlg.cpp +++ b/kcontrol/hwmanager/devicepropsdlg.cpp @@ -908,48 +908,39 @@ void DevicePropertiesDialog::setHibernationMethod(int value) { void DevicePropertiesDialog::mountDisk() { TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); - TQString qerror; - TQString diskLabel = sdevice->diskLabel(); - if (diskLabel.isNull()) { - diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize()); - } - TDEStorageMountOptions mountOptions; - TQStringVariantMap mountResult = sdevice->mountDevice(diskLabel, mountOptions); - TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null; - if (mountedPath.isEmpty()) { - qerror = i18n("<qt>Unable to mount this device.<p>Potential reasons include:<br>Improper device and/or user privilege level<br>Corrupt data on storage device"); - TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null; - if (!errStr.isEmpty()) { - qerror.append(i18n("<p>Technical details:<br>").append(errStr)); - } - qerror.append("</qt>"); + + // Use DCOP call instead of a tdehw call for consistent behavior across TDE + DCOPRef mediamanager("kded", "mediamanager"); + DCOPReply reply = mediamanager.call("mountByNode", sdevice->deviceNode()); + TQStringVariantMap mountResult; + if (reply.isValid()) { + reply.get(mountResult); } - else { - qerror = ""; + if (!mountResult.contains("result") || mountResult["result"].toBool() == false) { + // Mount failed! + TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : i18n("Unable to mount the device."); + KMessageBox::error(this, "<qt>" + errStr + "</qt>", i18n("Mount failed")); } - if (qerror != "") KMessageBox::error(this, qerror, i18n("Mount Failed")); - populateDeviceInformation(); } void DevicePropertiesDialog::unmountDisk() { TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); - TQString qerror; - TQStringVariantMap unmountResult = sdevice->unmountDevice(); - if (unmountResult["result"].toBool() == false) { + // Use DCOP call instead of a tdehw call for consistent behavior across TDE + DCOPRef mediamanager("kded", "mediamanager"); + DCOPReply reply = mediamanager.call("unmountByNode", sdevice->deviceNode()); + TQStringVariantMap unmountResult; + if (reply.isValid()) { + reply.get(unmountResult); + } + if (!unmountResult.contains("result") || unmountResult["result"].toBool() == false) { // Unmount failed! - qerror = "<qt>" + i18n("<b>The device could not be unmounted.</b>"); - TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null; - if (!errStr.isEmpty()) { - qerror.append(i18n("<p>Technical details:<br>").append(errStr)); - } - qerror.append("</qt>"); + TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : i18n("Unable to unmount the device."); + KMessageBox::error(this, "<qt>" + errStr + "</qt>", i18n("Unmount failed")); } - if (qerror != "") KMessageBox::error(this, qerror, i18n("Unmount Failed")); - populateDeviceInformation(); } @@ -969,8 +960,7 @@ void DevicePropertiesDialog::unlockDisk() { void DevicePropertiesDialog::doUnlockDisk() { TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); - // Use DCOP call to unlock the disk to make sure the status and mime type of the underlying medium - // is correctly updated throughout TDE + // Use DCOP call instead of a tdehw call for consistent behavior across TDE DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call("unlockByNode", sdevice->deviceNode(), m_passDlg->getPassword()); TQStringVariantMap unlockResult; @@ -982,10 +972,10 @@ void DevicePropertiesDialog::doUnlockDisk() { TQString errStr = unlockResult.contains("errStr") ? unlockResult["errStr"].toString() : TQString::null; if (errStr.isEmpty()) { - errStr = i18n("<qt>Unable to unlock this device.<p>Potential reasons include:<br>Wrong password " + errStr = i18n("<qt>Unable to unlock the device.<p>Potential reasons include:<br>Wrong password " "and/or user privilege level.<br>Corrupt data on storage device.</qt>"); } - KMessageBox::error(this, errStr, i18n("Unlock Failed")); + KMessageBox::error(this, errStr, i18n("Unlock failed")); m_passDlg->clearPassword(); } else { @@ -998,8 +988,7 @@ void DevicePropertiesDialog::doUnlockDisk() { void DevicePropertiesDialog::lockDisk() { TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); - // Use DCOP call to lock the disk to make sure the status and mime type of the underlying medium - // is correctly updated throughout TDE + // Use DCOP call instead of a tdehw call for consistent behavior across TDE DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call("lockByNode", sdevice->deviceNode()); TQStringVariantMap lockResult; @@ -1009,7 +998,7 @@ void DevicePropertiesDialog::lockDisk() { if (!lockResult.contains("result") || lockResult["result"].toBool() == false) { // Lock failed! TQString errStr = lockResult.contains("errStr") ? lockResult["errStr"].toString() : i18n("Unable to lock the device."); - KMessageBox::error(this, "<qt>" + errStr + "</qt>", i18n("Lock Failed")); + KMessageBox::error(this, "<qt>" + errStr + "</qt>", i18n("Lock failed")); } populateDeviceInformation(); |