|
|
|
@ -310,7 +310,7 @@ bool TDEStorageDevice::lockDriveMedia(bool lock) {
|
|
|
|
|
bool TDEStorageDevice::ejectDrive() {
|
|
|
|
|
#ifdef WITH_UDISKS2
|
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("udisksctl").isEmpty())) {
|
|
|
|
|
TQStringVariantMap ejectResult = UDisks2EjectDrive(this);
|
|
|
|
|
TQStringVariantMap ejectResult = udisks2EjectDrive(this);
|
|
|
|
|
if (ejectResult["result"].toBool()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -322,7 +322,7 @@ bool TDEStorageDevice::ejectDrive() {
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef WITH_UDISKS
|
|
|
|
|
if (!(TDEGlobal::dirs()->findExe("udisks").isEmpty())) {
|
|
|
|
|
TQStringVariantMap ejectResult = UDisksEjectDrive(this);
|
|
|
|
|
TQStringVariantMap ejectResult = udisksEjectDrive(this);
|
|
|
|
|
if (ejectResult["result"].toBool()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -786,7 +786,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_UDISKS2)
|
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
|
mountResult = UDisks2MountDrive(devNode, fileSystemType, optionString);
|
|
|
|
|
mountResult = udisks2MountDrive(devNode, fileSystemType, optionString);
|
|
|
|
|
if (mountResult["result"].toBool()) {
|
|
|
|
|
// Update internal mount data
|
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
@ -806,7 +806,7 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
|
|
|
|
|
#if defined(WITH_UDISKS)
|
|
|
|
|
// The UDISKS v2 DBUS service was either not available or was unusable
|
|
|
|
|
// Try to use UDISKS v1 via DBUS, if available
|
|
|
|
|
mountResult = UDisksMountDrive(devNode, fileSystemType, udisksOptions);
|
|
|
|
|
mountResult = udisksMountDrive(devNode, fileSystemType, udisksOptions);
|
|
|
|
|
if (mountResult["result"].toBool()) {
|
|
|
|
|
// Update internal mount data
|
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
@ -1009,7 +1009,7 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_UDISKS2)
|
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
|
unmountResult = UDisks2UnmountDrive(devNode, TQString::null);
|
|
|
|
|
unmountResult = udisks2UnmountDrive(devNode, TQString::null);
|
|
|
|
|
if (unmountResult["result"].toBool()) {
|
|
|
|
|
// Update internal mount data
|
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
@ -1028,7 +1028,7 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
|
|
|
|
|
#if defined(WITH_UDISKS)
|
|
|
|
|
// The UDISKS v2 DBUS service was either not available or was unusable
|
|
|
|
|
// Try to use UDISKS v1 via DBUS, if available
|
|
|
|
|
unmountResult = UDisksUnmountDrive(devNode, TQStringList());
|
|
|
|
|
unmountResult = udisksUnmountDrive(devNode, TQStringList());
|
|
|
|
|
if (unmountResult["result"].toBool()) {
|
|
|
|
|
// Update internal mount data
|
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
@ -1087,6 +1087,89 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQStringVariantMap TDEStorageDevice::unlockDevice(const TQString &passphrase)
|
|
|
|
|
{
|
|
|
|
|
TQStringVariantMap result;
|
|
|
|
|
|
|
|
|
|
// Check if device is already mounted
|
|
|
|
|
TQString mountpath = mountPath();
|
|
|
|
|
if (!mountpath.isEmpty()) {
|
|
|
|
|
result["unlockedDevice"] = mountpath;
|
|
|
|
|
result["result"] = true;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQString devNode = deviceNode();
|
|
|
|
|
devNode.replace("'", "'\\''");
|
|
|
|
|
|
|
|
|
|
TQStringVariantMap unlockResult;
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_UDISKS2)
|
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
|
unlockResult = udisks2UnlockDrive(devNode, passphrase);
|
|
|
|
|
if (unlockResult["result"].toBool()) {
|
|
|
|
|
// Update internal mount data
|
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
|
result["unlockedDevice"] = unlockResult["unlockedDevice"];
|
|
|
|
|
result["result"] = true;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else if (unlockResult["retcode"].toInt() == -1) {
|
|
|
|
|
// Update internal mount data
|
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
|
result["errStr"] = unlockResult["errStr"];
|
|
|
|
|
result["result"] = false;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// No supported methods found for unlocking the device
|
|
|
|
|
result["errStr"] = i18n("No supported unlocking methods were detected on your system.");
|
|
|
|
|
result["result"] = false;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQStringVariantMap TDEStorageDevice::lockDevice()
|
|
|
|
|
{
|
|
|
|
|
TQStringVariantMap result;
|
|
|
|
|
|
|
|
|
|
// Check if device is mounted
|
|
|
|
|
TQString mountpath = mountPath();
|
|
|
|
|
if (!mountpath.isEmpty()) {
|
|
|
|
|
result["errStr"] = i18n("The device is currently mounted and cannot be locked.");
|
|
|
|
|
result["result"] = false;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQString devNode = deviceNode();
|
|
|
|
|
devNode.replace("'", "'\\''");
|
|
|
|
|
|
|
|
|
|
TQStringVariantMap lockResult;
|
|
|
|
|
|
|
|
|
|
#if defined(WITH_UDISKS2)
|
|
|
|
|
// Try to use UDISKS v2 via DBUS, if available
|
|
|
|
|
lockResult = udisks2LockDrive(devNode);
|
|
|
|
|
if (lockResult["result"].toBool()) {
|
|
|
|
|
// Update internal mount data
|
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
|
result["result"] = true;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else if (lockResult["retcode"].toInt() == -1) {
|
|
|
|
|
// Update internal mount data
|
|
|
|
|
TDEGlobal::hardwareDevices()->processModifiedMounts();
|
|
|
|
|
result["errStr"] = lockResult["errStr"];
|
|
|
|
|
result["result"] = false;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// No supported methods found for locking the device
|
|
|
|
|
result["errStr"] = i18n("No supported locking methods were detected on your system.");
|
|
|
|
|
result["result"] = false;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQString TDEStorageDevice::determineFileSystemType(TQString path) {
|
|
|
|
|
TQStringList mountTable;
|
|
|
|
|
TQString prevPath = path;
|
|
|
|
|