|
|
@ -308,6 +308,7 @@ bool TDEStorageDevice::lockDriveMedia(bool lock) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TDEStorageDevice::ejectDrive() {
|
|
|
|
bool TDEStorageDevice::ejectDrive() {
|
|
|
|
|
|
|
|
#ifdef WITH_UDISKS2
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("udisksctl").isEmpty())) {
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("udisksctl").isEmpty())) {
|
|
|
|
TQStringVariantMap ejectResult = UDisks2EjectDrive(this);
|
|
|
|
TQStringVariantMap ejectResult = UDisks2EjectDrive(this);
|
|
|
|
if (ejectResult["result"].toBool()) {
|
|
|
|
if (ejectResult["result"].toBool()) {
|
|
|
@ -318,6 +319,8 @@ bool TDEStorageDevice::ejectDrive() {
|
|
|
|
fflush(stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WITH_UDISKS
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("udisks").isEmpty())) {
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("udisks").isEmpty())) {
|
|
|
|
TQStringVariantMap ejectResult = UDisksEjectDrive(this);
|
|
|
|
TQStringVariantMap ejectResult = UDisksEjectDrive(this);
|
|
|
|
if (ejectResult["result"].toBool()) {
|
|
|
|
if (ejectResult["result"].toBool()) {
|
|
|
@ -328,6 +331,7 @@ bool TDEStorageDevice::ejectDrive() {
|
|
|
|
fflush(stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("eject").isEmpty())) {
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("eject").isEmpty())) {
|
|
|
|
TQString command = TQString("eject -v '%1' 2>&1").arg(deviceNode());
|
|
|
|
TQString command = TQString("eject -v '%1' 2>&1").arg(deviceNode());
|
|
|
@ -718,7 +722,9 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
|
|
|
|
TQString devNode = deviceNode();
|
|
|
|
TQString devNode = deviceNode();
|
|
|
|
devNode.replace("'", "'\\''");
|
|
|
|
devNode.replace("'", "'\\''");
|
|
|
|
mediaName.replace("'", "'\\''");
|
|
|
|
mediaName.replace("'", "'\\''");
|
|
|
|
|
|
|
|
TQString command = TQString::null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_UDISKS2) || defined(WITH_UDISKS) || defined(WITH_UDEVIL)
|
|
|
|
// Prepare filesystem options for mount
|
|
|
|
// Prepare filesystem options for mount
|
|
|
|
TQStringList udisksOptions;
|
|
|
|
TQStringList udisksOptions;
|
|
|
|
if (mountOptions["ro"] == "true") {
|
|
|
|
if (mountOptions["ro"] == "true") {
|
|
|
@ -770,13 +776,17 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
|
|
|
|
optionString.remove(0, 1);
|
|
|
|
optionString.remove(0, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
|
|
|
|
TQString fileSystemType;
|
|
|
|
TQString fileSystemType;
|
|
|
|
if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
|
|
|
|
if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
|
|
|
|
fileSystemType = mountOptions["filesystem"];
|
|
|
|
fileSystemType = mountOptions["filesystem"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQStringVariantMap mountResult = UDisks2MountDrive(devNode, fileSystemType, optionString);
|
|
|
|
TQStringVariantMap mountResult;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_UDISKS2)
|
|
|
|
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
|
|
|
|
mountResult = UDisks2MountDrive(devNode, fileSystemType, optionString);
|
|
|
|
if (mountResult["result"].toBool()) {
|
|
|
|
if (mountResult["result"].toBool()) {
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
@ -791,7 +801,9 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
|
|
|
|
result["result"] = false;
|
|
|
|
result["result"] = false;
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_UDISKS)
|
|
|
|
// The UDISKS v2 DBUS service was either not available or was unusable
|
|
|
|
// The UDISKS v2 DBUS service was either not available or was unusable
|
|
|
|
// Try to use UDISKS v1 via DBUS, if available
|
|
|
|
// Try to use UDISKS v1 via DBUS, if available
|
|
|
|
mountResult = UDisksMountDrive(devNode, fileSystemType, udisksOptions);
|
|
|
|
mountResult = UDisksMountDrive(devNode, fileSystemType, udisksOptions);
|
|
|
@ -809,10 +821,11 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
|
|
|
|
result["result"] = false;
|
|
|
|
result["result"] = false;
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_UDEVIL)
|
|
|
|
// The UDISKS v1 DBUS service was either not available or was unusable
|
|
|
|
// The UDISKS v1 DBUS service was either not available or was unusable
|
|
|
|
// Use 'udevil' command, if available
|
|
|
|
// Use 'udevil' command, if available
|
|
|
|
TQString command = TQString::null;
|
|
|
|
|
|
|
|
if (!TDEGlobal::dirs()->findExe("udevil").isEmpty()) {
|
|
|
|
if (!TDEGlobal::dirs()->findExe("udevil").isEmpty()) {
|
|
|
|
if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
|
|
|
|
if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
|
|
|
|
fileSystemType = TQString("-t %1").arg(mountOptions["filesystem"]);
|
|
|
|
fileSystemType = TQString("-t %1").arg(mountOptions["filesystem"]);
|
|
|
@ -829,8 +842,9 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
|
|
|
|
command = TQString("udevil mount %1 -o '%2' '%3' '%4' 2>&1")
|
|
|
|
command = TQString("udevil mount %1 -o '%2' '%3' '%4' 2>&1")
|
|
|
|
.arg(fileSystemType).arg(optionString).arg(devNode).arg(mountpoint);
|
|
|
|
.arg(fileSystemType).arg(optionString).arg(devNode).arg(mountpoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// If 'udevil' was not found, use 'pmount' command if available
|
|
|
|
// If no other method was found, use 'pmount' command if available
|
|
|
|
if(command.isEmpty()) {
|
|
|
|
if(command.isEmpty()) {
|
|
|
|
if (!TDEGlobal::dirs()->findExe("pmount").isEmpty()) {
|
|
|
|
if (!TDEGlobal::dirs()->findExe("pmount").isEmpty()) {
|
|
|
|
// Create dummy password file
|
|
|
|
// Create dummy password file
|
|
|
@ -990,9 +1004,12 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
|
|
|
|
|
|
|
|
|
|
|
|
mountpoint.replace("'", "'\\''");
|
|
|
|
mountpoint.replace("'", "'\\''");
|
|
|
|
TQString devNode = deviceNode();
|
|
|
|
TQString devNode = deviceNode();
|
|
|
|
|
|
|
|
TQString command = TQString::null;
|
|
|
|
|
|
|
|
TQStringVariantMap unmountResult;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_UDISKS2)
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
TQStringVariantMap unmountResult = UDisks2UnmountDrive(devNode, TQString::null);
|
|
|
|
unmountResult = UDisks2UnmountDrive(devNode, TQString::null);
|
|
|
|
if (unmountResult["result"].toBool()) {
|
|
|
|
if (unmountResult["result"].toBool()) {
|
|
|
|
// Update internal mount data
|
|
|
|
// Update internal mount data
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
@ -1006,7 +1023,9 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
|
|
|
|
result["result"] = false;
|
|
|
|
result["result"] = false;
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_UDISKS)
|
|
|
|
// The UDISKS v2 DBUS service was either not available or was unusable
|
|
|
|
// The UDISKS v2 DBUS service was either not available or was unusable
|
|
|
|
// Try to use UDISKS v1 via DBUS, if available
|
|
|
|
// Try to use UDISKS v1 via DBUS, if available
|
|
|
|
unmountResult = UDisksUnmountDrive(devNode, TQStringList());
|
|
|
|
unmountResult = UDisksUnmountDrive(devNode, TQStringList());
|
|
|
@ -1023,15 +1042,17 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
|
|
|
|
result["result"] = false;
|
|
|
|
result["result"] = false;
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_UDEVIL)
|
|
|
|
// The UDISKS v1 DBUS service was either not available or was unusable
|
|
|
|
// The UDISKS v1 DBUS service was either not available or was unusable
|
|
|
|
// Use 'udevil' command, if available
|
|
|
|
// Use 'udevil' command, if available
|
|
|
|
TQString command = TQString::null;
|
|
|
|
|
|
|
|
if (!TDEGlobal::dirs()->findExe("udevil").isEmpty()) {
|
|
|
|
if (!TDEGlobal::dirs()->findExe("udevil").isEmpty()) {
|
|
|
|
command = TQString("udevil umount '%1' 2>&1").arg(mountpoint);
|
|
|
|
command = TQString("udevil umount '%1' 2>&1").arg(mountpoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// If 'udevil' was not found, use 'pmount' command if available
|
|
|
|
// If no other method was found, use 'pmount' command if available
|
|
|
|
if(command.isEmpty() && !TDEGlobal::dirs()->findExe("pumount").isEmpty()) {
|
|
|
|
if(command.isEmpty() && !TDEGlobal::dirs()->findExe("pumount").isEmpty()) {
|
|
|
|
command = TQString("pumount '%1' 2>&1").arg(mountpoint);
|
|
|
|
command = TQString("pumount '%1' 2>&1").arg(mountpoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|