|
|
|
@ -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;
|
|
|
|
|