Adjusted to new TDEStorageOpResult-based tdelibs api.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/39/head
Michele Calgaro 6 years ago
parent e408b99187
commit df9e4e43b0
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -879,21 +879,19 @@ void DevicePropertiesDialog::setHibernationMethod(int value) {
void DevicePropertiesDialog::mountDisk() { void DevicePropertiesDialog::mountDisk() {
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
// FIXME
// This can only mount normal volumes
TQString qerror; TQString qerror;
TQString diskLabel = sdevice->diskLabel(); TQString diskLabel = sdevice->diskLabel();
if (diskLabel.isNull()) { if (diskLabel.isNull()) {
diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize()); diskLabel = i18n("%1 Removable Device").arg(sdevice->deviceFriendlySize());
} }
TDEStorageMountOptions mountOptions; TDEStorageMountOptions mountOptions;
TQString mountMessages; TDEStorageOpResult mountResult = sdevice->mountDevice(diskLabel, mountOptions);
TQString mountedPath = sdevice->mountDevice(diskLabel, mountOptions, &mountMessages); TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
if (mountedPath.isNull()) { 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"); 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");
if (!mountMessages.isNull()) { TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
qerror.append(i18n("<p>Technical details:<br>").append(mountMessages)); if (!errStr.isEmpty()) {
qerror.append(i18n("<p>Technical details:<br>").append(errStr));
} }
qerror.append("</qt>"); qerror.append("</qt>");
} }
@ -910,13 +908,13 @@ void DevicePropertiesDialog::unmountDisk() {
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device); TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(m_device);
TQString qerror; TQString qerror;
TQString unmountMessages; TDEStorageOpResult unmountResult = sdevice->unmountDevice();
int unmountRetcode = 0; if (unmountResult["result"].toBool() == false) {
if (!sdevice->unmountDevice(&unmountMessages, &unmountRetcode)) {
// Unmount failed! // Unmount failed!
qerror = "<qt>" + i18n("Unfortunately, the device could not be unmounted."); qerror = "<qt>" + i18n("Unfortunately, the device could not be unmounted.");
if (!unmountMessages.isNull()) { TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
qerror.append(i18n("<p>Technical details:<br>").append(unmountMessages)); if (!errStr.isEmpty()) {
qerror.append(i18n("<p>Technical details:<br>").append(errStr));
} }
qerror.append("</qt>"); qerror.append("</qt>");
} }

@ -300,11 +300,12 @@ void HwDeviceSystemTray::slotUnmountDevice(int parameter)
for (hwdevice = diskDeviceList.first(); hwdevice; hwdevice = diskDeviceList.next()) { for (hwdevice = diskDeviceList.first(); hwdevice; hwdevice = diskDeviceList.next()) {
TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice); TDEStorageDevice* sdevice = static_cast<TDEStorageDevice*>(hwdevice);
if ((sdevice->diskUUID() == uuid) || (sdevice->systemPath() == uuid)) { if ((sdevice->diskUUID() == uuid) || (sdevice->systemPath() == uuid)) {
if (sdevice->mountPath() != TQString::null) { if (!sdevice->mountPath().isEmpty()) {
int retcode; TDEStorageOpResult unmountResult = sdevice->unmountDevice();
TQString errstr; if (unmountResult["result"].toBool() == false) {
if (!sdevice->unmountDevice(&errstr, &retcode)) { TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
KMessageBox::error(0, i18n("<qt><b>Unable to eject device</b><p>Detailed error information:<br>%1 (code %2)</qt>").arg(errstr).arg(retcode), i18n("Eject Failed")); TQString retcodeStr = unmountResult.contains("retCode") ? unmountResult["retCode"].asString() : "not available";
KMessageBox::error(0, i18n("<qt><b>Unable to eject device</b><p>Detailed error information:<br>%1 (error code %2)</qt>").arg(errStr).arg(retcodeStr), i18n("Eject Failed"));
} }
return; return;
} }

@ -1233,12 +1233,13 @@ TQString TDEBackend::mount(const Medium *medium)
if (!medium->isEncrypted()) { if (!medium->isEncrypted()) {
// normal volume // normal volume
TQString mountMessages; TDEStorageOpResult mountResult = sdevice->mountDevice(diskLabel, valids);
TQString mountedPath = sdevice->mountDevice(diskLabel, valids, &mountMessages); TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
if (mountedPath.isNull()) { 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"); 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");
if (!mountMessages.isNull()) { TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
qerror.append(i18n("<p>Technical details:<br>").append(mountMessages)); if (!errStr.isEmpty()) {
qerror.append(i18n("<p>Technical details:<br>").append(errStr));
} }
qerror.append("</qt>"); qerror.append("</qt>");
} }
@ -1285,17 +1286,16 @@ TQString TDEBackend::mount(const Medium *medium)
} }
// mount encrypted volume with password // mount encrypted volume with password
int mountRetcode; TDEStorageOpResult mountResult = sdevice->mountEncryptedDevice(m_decryptionPassword, diskLabel, valids);
TQString mountMessages; TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
TQString mountedPath = sdevice->mountEncryptedDevice(m_decryptionPassword, diskLabel, valids, &mountMessages, &mountRetcode); if (mountedPath.isEmpty()) {
if (mountedPath.isNull()) { if (mountResult.contains("retCode") && mountResult["retCode"].toInt() == 0) {
if (mountRetcode == 0) {
// Mounting was successful // Mounting was successful
// Because the TDE hardware backend is event driven it might take a little while for the new unencrypted mapped device to show up // Because the TDE hardware backend is event driven it might take a little while for the new unencrypted mapped device to show up
// Wait up to 30 seconds for it to appear... // Wait up to 30 seconds for it to appear...
for (int i=0;i<300;i++) { for (int i=0;i<300;i++) {
mountedPath = sdevice->mountPath(); mountedPath = sdevice->mountPath();
if (!mountedPath.isNull()) { if (!mountedPath.isEmpty()) {
break; break;
} }
tqApp->processEvents(50); tqApp->processEvents(50);
@ -1303,8 +1303,8 @@ TQString TDEBackend::mount(const Medium *medium)
} }
} }
} }
if (mountedPath.isNull()) { if (mountedPath.isEmpty()) {
if (mountRetcode == 25600) { if (mountResult.contains("retCode") && mountResult["retCode"].toInt() == 25600) {
// Probable LUKS failure // Probable LUKS failure
// Retry // Retry
m_decryptDialog->setEnabled(true); m_decryptDialog->setEnabled(true);
@ -1312,8 +1312,9 @@ TQString TDEBackend::mount(const Medium *medium)
} }
else { else {
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<br>Incorrect encryption password"); 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<br>Incorrect encryption password");
if (!mountMessages.isNull()) { TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
qerror.append(i18n("<p>Technical details:<br>").append(mountMessages)); if (!errStr.isEmpty()) {
qerror.append(i18n("<p>Technical details:<br>").append(errStr));
} }
qerror.append("</qt>"); qerror.append("</qt>");
continue_trying_to_decrypt = false; continue_trying_to_decrypt = false;
@ -1399,13 +1400,13 @@ TQString TDEBackend::unmount(const TQString &_udi)
TQString uid = sdevice->uniqueID(); TQString uid = sdevice->uniqueID();
TQString node = sdevice->deviceNode(); TQString node = sdevice->deviceNode();
TQString unmountMessages; TDEStorageOpResult unmountResult = sdevice->unmountDevice();
int unmountRetcode = 0; if (unmountResult["result"].toBool() == false) {
if (!sdevice->unmountDevice(&unmountMessages, &unmountRetcode)) {
// Unmount failed! // Unmount failed!
qerror = "<qt>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at <b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(), medium->prettyLabel(), medium->prettyBaseURL().pathOrURL()); qerror = "<qt>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at <b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(), medium->prettyLabel(), medium->prettyBaseURL().pathOrURL());
if (!unmountMessages.isNull()) { TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
qerror.append(i18n("<p>Technical details:<br>").append(unmountMessages)); if (!errStr.isEmpty()) {
qerror.append(i18n("<p>Technical details:<br>").append(errStr));
} }
qerror.append("</qt>"); qerror.append("</qt>");
} }
@ -1413,17 +1414,19 @@ TQString TDEBackend::unmount(const TQString &_udi)
qerror = ""; qerror = "";
} }
if (unmountRetcode == 1280) { if (unmountResult.contains("retCode") && unmountResult["retCode"].toInt() == 1280) {
// Failed as BUSY // Failed as BUSY
TQString processesUsingDev = listUsingProcesses(medium); TQString processesUsingDev = listUsingProcesses(medium);
if (!processesUsingDev.isNull()) { if (!processesUsingDev.isNull()) {
if (KMessageBox::warningYesNo(0, i18n("<qt>The device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at <b>%4</b> can not be unmounted at this time.<p>%5<p><b>Would you like to forcibly terminate these processes?</b><br><i>All unsaved data would be lost</i>").arg("system:/media/" + medium->name()).arg(medium->deviceNode()).arg(medium->prettyLabel()).arg(medium->prettyBaseURL().pathOrURL()).arg(processesUsingDev)) == KMessageBox::Yes) { if (KMessageBox::warningYesNo(0, i18n("<qt>The device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at <b>%4</b> can not be unmounted at this time.<p>%5<p><b>Would you like to forcibly terminate these processes?</b><br><i>All unsaved data would be lost</i>").arg("system:/media/" + medium->name()).arg(medium->deviceNode()).arg(medium->prettyLabel()).arg(medium->prettyBaseURL().pathOrURL()).arg(processesUsingDev)) == KMessageBox::Yes) {
killUsingProcesses(medium); killUsingProcesses(medium);
if (!sdevice->unmountDevice(&unmountMessages, &unmountRetcode)) { unmountResult = sdevice->unmountDevice();
if (unmountResult["result"].toBool() == false) {
// Unmount failed! // Unmount failed!
qerror = "<qt>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at <b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(), medium->prettyLabel(), medium->prettyBaseURL().pathOrURL()); qerror = "<qt>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at <b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(), medium->prettyLabel(), medium->prettyBaseURL().pathOrURL());
if (!unmountMessages.isNull()) { TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
qerror.append(i18n("<p>Technical details:<br>").append(unmountMessages)); if (!errStr.isEmpty()) {
qerror.append(i18n("<p>Technical details:<br>").append(errStr));
} }
qerror.append("</qt>"); qerror.append("</qt>");
} }

Loading…
Cancel
Save