summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw/tdestoragedevice.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-10-10 14:31:22 +0800
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-10-10 14:31:24 +0800
commit33794c4ec3572327ac077e272523234aac464aa2 (patch)
tree0a6d84fcd46310059cc8cebfda669efcd7085abe /tdecore/tdehw/tdestoragedevice.cpp
parentfe08361f7e4227def5699ee7c911a61b84f5a77b (diff)
downloadtdelibs-33794c4ec3572327ac077e272523234aac464aa2.tar.gz
tdelibs-33794c4ec3572327ac077e272523234aac464aa2.zip
Fixed displaying of encrypted disks.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdecore/tdehw/tdestoragedevice.cpp')
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp90
1 files changed, 15 insertions, 75 deletions
diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp
index a995e49fa..862e7b10e 100644
--- a/tdecore/tdehw/tdestoragedevice.cpp
+++ b/tdecore/tdehw/tdestoragedevice.cpp
@@ -789,6 +789,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
mountResult = udisks2MountDrive(devNode, fileSystemType, optionString);
if (mountResult["result"].toBool()) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["mountPath"] = mountPath();
result["result"] = true;
@@ -796,6 +797,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
}
else if (mountResult["retcode"].toInt() == -1) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = mountResult["errStr"];
result["result"] = false;
@@ -809,6 +811,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
mountResult = udisksMountDrive(devNode, fileSystemType, udisksOptions);
if (mountResult["result"].toBool()) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["mountPath"] = mountPath();
result["result"] = true;
@@ -816,6 +819,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
}
else if (mountResult["retcode"].toInt() == -1) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = mountResult["errStr"];
result["result"] = false;
@@ -911,81 +915,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
}
// Update internal mount data
- TDEGlobal::hardwareDevices()->processModifiedMounts();
- result["mountPath"] = mountPath();
- result["result"] = !mountPath().isEmpty();
- return result;
-}
-
-TQStringVariantMap TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString mediaName,
- TDEStorageMountOptions mountOptions) {
- TQStringVariantMap result;
-
- // Check if device is already mounted
- TQString mountpath = mountPath();
- if (!mountpath.isEmpty()) {
- result["mountPath"] = mountpath;
- result["result"] = true;
- return result;
- }
-
- // Create dummy password file
- KTempFile passwordFile(TQString::null, "tmp", 0600);
- passwordFile.setAutoDelete(true);
- TQFile* pwFile = passwordFile.file();
- if (!pwFile) {
- result["errStr"] = i18n("Cannot create temporary password file");
- result["result"] = false;
- return result;
- }
-
- pwFile->writeBlock(passphrase.ascii(), passphrase.length());
- pwFile->flush();
-
- TQString optionString;
- if (mountOptions["ro"] == "true") {
- optionString.append(" -r");
- }
-
- if (mountOptions["atime"] != "true") {
- optionString.append(" -A");
- }
-
- if (mountOptions["utf8"] == "true") {
- optionString.append(" -c utf8");
- }
-
- if (mountOptions["sync"] == "true") {
- optionString.append(" -s");
- }
-
- if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
- optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"]));
- }
-
- if (mountOptions.contains("locale")) {
- optionString.append(TQString(" -c %1").arg(mountOptions["locale"]));
- }
-
- TQString passFileName = passwordFile.name();
- TQString devNode = deviceNode();
- passFileName.replace("'", "'\\''");
- devNode.replace("'", "'\\''");
- mediaName.replace("'", "'\\''");
- TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1")
- .arg(passFileName).arg(optionString).arg(devNode).arg(mediaName);
-
- FILE *exepipe = popen(command.local8Bit(), "r");
- if (exepipe) {
- TQTextStream* ts = new TQTextStream(exepipe, IO_ReadOnly);
- TQString mount_output = ts->read();
- delete ts;
- int retcode = pclose(exepipe);
- result["errStr"] = mount_output;
- result["retCode"] = retcode;
- }
-
- // Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["mountPath"] = mountPath();
result["result"] = !mountPath().isEmpty();
@@ -1012,12 +942,14 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
unmountResult = udisks2UnmountDrive(devNode, TQString::null);
if (unmountResult["result"].toBool()) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
return result;
}
else if (unmountResult["retcode"].toInt() == -1) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = unmountResult["errStr"];
result["result"] = false;
@@ -1031,12 +963,14 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
unmountResult = udisksUnmountDrive(devNode, TQStringList());
if (unmountResult["result"].toBool()) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
return result;
}
else if (unmountResult["retcode"].toInt() == -1) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = unmountResult["errStr"];
result["result"] = false;
@@ -1071,6 +1005,7 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
int retcode = pclose(exepipe);
if (retcode == 0) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
return result;
@@ -1082,6 +1017,7 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
}
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = false;
return result;
@@ -1109,6 +1045,7 @@ TQStringVariantMap TDEStorageDevice::unlockDevice(const TQString &passphrase)
unlockResult = udisks2UnlockDrive(devNode, passphrase);
if (unlockResult["result"].toBool()) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["unlockedDevice"] = unlockResult["unlockedDevice"];
result["result"] = true;
@@ -1116,6 +1053,7 @@ TQStringVariantMap TDEStorageDevice::unlockDevice(const TQString &passphrase)
}
else if (unlockResult["retcode"].toInt() == -1) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = unlockResult["errStr"];
result["result"] = false;
@@ -1151,12 +1089,14 @@ TQStringVariantMap TDEStorageDevice::lockDevice()
lockResult = udisks2LockDrive(devNode);
if (lockResult["result"].toBool()) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["result"] = true;
return result;
}
else if (lockResult["retcode"].toInt() == -1) {
// Update internal mount data
+ TDEGlobal::hardwareDevices()->rescanDeviceInformation(this);
TDEGlobal::hardwareDevices()->processModifiedMounts();
result["errStr"] = lockResult["errStr"];
result["result"] = false;