From d39c407bf49fab58fa53c20bb3d301ee6e709c32 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 21 Nov 2020 17:49:23 +0800 Subject: 1) tdehwdevicetray: added support for unmount/unlock/lock operations. 2) minor changes and improvements to user messages. Signed-off-by: Michele Calgaro --- kcontrol/hwmanager/devicepropsdlg.cpp | 38 +++++++++++++++-------------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'kcontrol/hwmanager/devicepropsdlg.cpp') diff --git a/kcontrol/hwmanager/devicepropsdlg.cpp b/kcontrol/hwmanager/devicepropsdlg.cpp index bb37695bd..bc50f11ac 100644 --- a/kcontrol/hwmanager/devicepropsdlg.cpp +++ b/kcontrol/hwmanager/devicepropsdlg.cpp @@ -940,7 +940,7 @@ void DevicePropertiesDialog::unmountDisk() { TQStringVariantMap unmountResult = sdevice->unmountDevice(); if (unmountResult["result"].toBool() == false) { // Unmount failed! - qerror = "" + i18n("Unfortunately, the device could not be unmounted."); + qerror = "" + i18n("The device could not be unmounted."); TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null; if (!errStr.isEmpty()) { qerror.append(i18n("

Technical details:
").append(errStr)); @@ -958,9 +958,11 @@ void DevicePropertiesDialog::unlockDisk() { if (!m_passDlg) { - m_passDlg = new PasswordDlg(sdevice->deviceNode(), "drive-harddisk-locked"); + m_passDlg = new PasswordDlg(); connect(m_passDlg, TQT_SIGNAL(user1Clicked()), this, TQT_SLOT(doUnlockDisk())); } + m_passDlg->setDevice(sdevice->deviceNode()); + m_passDlg->clearPassword(); m_passDlg->show(); } @@ -969,28 +971,27 @@ void DevicePropertiesDialog::doUnlockDisk() { // Use DCOP call to unlock the disk to make sure the status and mime type of the underlying medium // is correctly updated throughout TDE - TQString qerror; DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call("unlockByNode", sdevice->deviceNode(), m_passDlg->getPassword()); TQStringVariantMap unlockResult; if (reply.isValid()) { reply.get(unlockResult); } - if (!unlockResult.contains("result") || !unlockResult["result"].toBool()) { - qerror = i18n("Unable to unlock this device.

Potential reasons include:
Wrong password and/or user privilege level.
Corrupt data on storage device."); - TQString errStr = unlockResult.contains("errStr") ? unlockResult["errStr"].toString() : i18n("Unknown unlock error."); - if (!errStr.isEmpty()) { - qerror.append(i18n("

Technical details:
").append(errStr)); + if (!unlockResult.contains("result") || !unlockResult["result"].toBool()) + { + TQString errStr = unlockResult.contains("errStr") ? unlockResult["errStr"].toString() : TQString::null; + if (errStr.isEmpty()) + { + errStr = i18n("Unable to unlock this device.

Potential reasons include:
Wrong password " + "and/or user privilege level.
Corrupt data on storage device."); } - qerror.append(""); + KMessageBox::error(this, errStr, i18n("Unlock Failed")); + m_passDlg->clearPassword(); } else { m_passDlg->hide(); - qerror = ""; } - if (qerror != "") KMessageBox::error(this, qerror, i18n("Unlock Failed")); - populateDeviceInformation(); } @@ -999,25 +1000,18 @@ void DevicePropertiesDialog::lockDisk() { // Use DCOP call to lock the disk to make sure the status and mime type of the underlying medium // is correctly updated throughout TDE - TQString qerror; DCOPRef mediamanager("kded", "mediamanager"); DCOPReply reply = mediamanager.call("lockByNode", sdevice->deviceNode()); TQStringVariantMap lockResult; if (reply.isValid()) { reply.get(lockResult); } - if (lockResult["result"].toBool() == false) { + if (!lockResult.contains("result") || lockResult["result"].toBool() == false) { // Lock failed! - qerror = "" + i18n("Unfortunately, the device could not be locked."); - TQString errStr = lockResult.contains("errStr") ? lockResult["errStr"].toString() : TQString::null; - if (!errStr.isEmpty()) { - qerror.append(i18n("

Technical details:
").append(errStr)); - } - qerror.append(""); + TQString errStr = lockResult.contains("errStr") ? lockResult["errStr"].toString() : i18n("Unable to lock the device."); + KMessageBox::error(this, "" + errStr + "", i18n("Lock Failed")); } - if (qerror != "") KMessageBox::error(this, qerror, i18n("Lock Failed")); - populateDeviceInformation(); } -- cgit v1.2.3