diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2019-07-07 22:21:21 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2019-07-07 22:40:46 +0900 |
commit | 7214a7b6b590d62aac622dbf2de31b1ca1ba78d5 (patch) | |
tree | e63d5e40e1a2d4d4a8efb0990ebff10dcf163617 /tdecore/tdehw/tdestoragedevice.cpp | |
parent | c76553c4fb3ee8f839c17b4dc3c3beb3c4338eb3 (diff) | |
download | tdelibs-7214a7b6b590d62aac622dbf2de31b1ca1ba78d5.tar.gz tdelibs-7214a7b6b590d62aac622dbf2de31b1ca1ba78d5.zip |
tdehw: code restructuring for tdestoragedevice.
1. added disk helper source files
2. removed WITH_UDISKS2, WITH_UDISK, WITH_UDEVIL defines. The respective code is always included
3. order of execution for mount/umount activities: udisks2, udisk, udevil, pmount.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdecore/tdehw/tdestoragedevice.cpp')
-rw-r--r-- | tdecore/tdehw/tdestoragedevice.cpp | 563 |
1 files changed, 100 insertions, 463 deletions
diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp index 71f852e0b..bf2ca2fd4 100644 --- a/tdecore/tdehw/tdestoragedevice.cpp +++ b/tdecore/tdehw/tdestoragedevice.cpp @@ -35,8 +35,8 @@ #include "kiconloader.h" #include "tdetempfile.h" #include "kstandarddirs.h" - #include "tdehardwaredevices.h" +#include "disksHelper.h" #include "config.h" @@ -55,21 +55,6 @@ #endif #endif -// uDisks2 integration -#if defined(WITH_UDISKS) || defined(WITH_UDISKS2) - #include <tqdbusdata.h> - #include <tqdbusmessage.h> - #include <tqdbusproxy.h> - #include <tqdbusvariant.h> - #include <tqdbusconnection.h> - #include <tqdbuserror.h> - #include <tqdbusdatamap.h> - #include <tqdbusobjectpath.h> -#endif // defined(WITH_UDISKS) || defined(WITH_UDISKS2) -#if defined(WITH_UDISKS) - #include "tqdbusdatalist.h" -#endif // ddefined(WITH_UDISKS) - TDEStorageDevice::TDEStorageDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn), m_mediaInserted(true), m_cryptDevice(NULL) { m_diskType = TDEDiskDeviceType::Null; m_diskStatus = TDEDiskDeviceStatus::Null; @@ -322,282 +307,7 @@ bool TDEStorageDevice::lockDriveMedia(bool lock) { } } -bool ejectDriveUDisks(TDEStorageDevice* sdevice) { -#ifdef WITH_UDISKS - TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); - if (dbusConn.isConnected()) { - TQString blockDeviceString = sdevice->deviceNode(); - blockDeviceString.replace("/dev/", ""); - blockDeviceString.replace("-", "_2d"); - blockDeviceString = "/org/freedesktop/UDisks/devices/" + blockDeviceString; - - // Eject the drive! - TQT_DBusError error; - TQT_DBusProxy driveControl("org.freedesktop.UDisks", blockDeviceString, "org.freedesktop.UDisks.Device", dbusConn); - if (driveControl.canSend()) { - TQValueList<TQT_DBusData> params; - TQT_DBusDataList options; - params << TQT_DBusData::fromList(options); - TQT_DBusMessage reply = driveControl.sendWithReply("DriveEject", params, &error); - if (error.isValid()) { - // Error! - printf("[ERROR][tdehwlib] ejectDriveUDisks: %s\n", error.name().ascii()); fflush(stdout); - return false; - } - else { - return true; - } - } - } -#endif // WITH_UDISKS - return false; -} - -bool ejectDriveUDisks2(TDEStorageDevice* sdevice) { -#ifdef WITH_UDISKS2 - TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); - if (dbusConn.isConnected()) { - TQString blockDeviceString = sdevice->deviceNode(); - blockDeviceString.replace("/dev/", ""); - blockDeviceString.replace("-", "_2d"); - blockDeviceString = "/org/freedesktop/UDisks2/block_devices/" + blockDeviceString; - TQT_DBusProxy hardwareControl("org.freedesktop.UDisks2", blockDeviceString, "org.freedesktop.DBus.Properties", dbusConn); - if (hardwareControl.canSend()) { - // get associated udisks2 drive path - TQT_DBusError error; - TQValueList<TQT_DBusData> params; - params << TQT_DBusData::fromString("org.freedesktop.UDisks2.Block") << TQT_DBusData::fromString("Drive"); - TQT_DBusMessage reply = hardwareControl.sendWithReply("Get", params, &error); - if (error.isValid()) { - // Error! - printf("[ERROR][tdehwlib] ejectDriveUDisks2: %s\n", error.name().ascii()); fflush(stdout); - return false; - } - else { - if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) { - TQT_DBusObjectPath driveObjectPath = reply[0].toVariant().value.toObjectPath(); - if (!driveObjectPath.isValid()) { - return false; - } - - error = TQT_DBusError(); - TQT_DBusProxy driveInformation("org.freedesktop.UDisks2", driveObjectPath, "org.freedesktop.DBus.Properties", dbusConn); - // can eject? - TQValueList<TQT_DBusData> params; - params << TQT_DBusData::fromString("org.freedesktop.UDisks2.Drive") << TQT_DBusData::fromString("Ejectable"); - TQT_DBusMessage reply = driveInformation.sendWithReply("Get", params, &error); - if (error.isValid()) { - // Error! - printf("[ERROR][tdehwlib] ejectDriveUDisks2: %s\n", error.name().ascii()); fflush(stdout); - return false; - } - if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) { - bool ejectable = reply[0].toVariant().value.toBool(); - if (!ejectable) { - return false; - } - - // Eject the drive! - TQT_DBusProxy driveControl("org.freedesktop.UDisks2", driveObjectPath, "org.freedesktop.UDisks2.Drive", dbusConn); - TQValueList<TQT_DBusData> params; - TQT_DBusDataMap<TQString> options(TQT_DBusData::Variant); - params << TQT_DBusData::fromStringKeyMap(options); - TQT_DBusMessage reply = driveControl.sendWithReply("Eject", params, &error); - if (error.isValid()) { - // Error! - printf("[ERROR][tdehwlib] ejectDriveUDisks2: %s\n", error.name().ascii()); fflush(stdout); - return false; - } - else { - return true; - } - } - } - } - } - } -#endif // WITH_UDISKS2 - return false; -} - -int mountDriveUDisks(TQString deviceNode, TQString fileSystemType, TQStringList mountOptions, TQString* errStr = NULL) { -#ifdef WITH_UDISKS - TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); - if (dbusConn.isConnected()) { - TQString blockDeviceString = deviceNode; - blockDeviceString.replace("/dev/", ""); - blockDeviceString.replace("-", "_2d"); - blockDeviceString = "/org/freedesktop/UDisks/devices/" + blockDeviceString; - - // Mount the drive! - TQT_DBusError error; - TQT_DBusProxy driveControl("org.freedesktop.UDisks", blockDeviceString, "org.freedesktop.UDisks.Device", dbusConn); - if (driveControl.canSend()) { - TQValueList<TQT_DBusData> params; - params << TQT_DBusData::fromString(fileSystemType); - params << TQT_DBusData::fromList(TQT_DBusDataList(mountOptions)); - TQT_DBusMessage reply = driveControl.sendWithReply("FilesystemMount", params, &error); - if (error.isValid()) { - // Error! - if (error.name() == "org.freedesktop.DBus.Error.ServiceUnknown") { - // Service not installed or unavailable - return -2; - } - if (errStr) { - *errStr = error.name() + ": " + error.message(); - } - else { - printf("[ERROR][tdehwlib] mountDriveUDisks: %s\n", error.name().ascii()); fflush(stdout); - } - return -1; - } - else { - return 0; - } - } - else { - return -2; - } - } -#endif // WITH_UDISKS - return -2; -} - -int mountDriveUDisks2(TQString deviceNode, TQString fileSystemType, TQString mountOptions, TQString* errStr = NULL) { -#ifdef WITH_UDISKS2 - TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); - if (dbusConn.isConnected()) { - TQString blockDeviceString = deviceNode; - blockDeviceString.replace("/dev/", ""); - blockDeviceString.replace("-", "_2d"); - blockDeviceString = "/org/freedesktop/UDisks2/block_devices/" + blockDeviceString; - - // Mount the drive! - TQT_DBusError error; - TQT_DBusProxy driveControl("org.freedesktop.UDisks2", blockDeviceString, "org.freedesktop.UDisks2.Filesystem", dbusConn); - if (driveControl.canSend()) { - TQValueList<TQT_DBusData> params; - TQMap<TQString, TQT_DBusData> optionsMap; - if (fileSystemType != "") { - optionsMap["fstype"] = (TQT_DBusData::fromString(fileSystemType)).getAsVariantData(); - } - optionsMap["options"] = (TQT_DBusData::fromString(mountOptions)).getAsVariantData(); - params << TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(optionsMap)); - TQT_DBusMessage reply = driveControl.sendWithReply("Mount", params, &error); - if (error.isValid()) { - // Error! - if (error.name() == "org.freedesktop.DBus.Error.ServiceUnknown") { - // Service not installed or unavailable - return -2; - } - if (errStr) { - *errStr = error.name() + ": " + error.message(); - } - else { - printf("[ERROR][tdehwlib] mountDriveUDisks2: %s\n", error.name().ascii()); fflush(stdout); - } - return -1; - } - else { - return 0; - } - } - else { - return -2; - } - } -#endif // WITH_UDISKS2 - return -2; -} - -int unMountDriveUDisks(TQString deviceNode, TQStringList unMountOptions, TQString* errStr = NULL) { -#ifdef WITH_UDISKS - TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); - if (dbusConn.isConnected()) { - TQString blockDeviceString = deviceNode; - blockDeviceString.replace("/dev/", ""); - blockDeviceString.replace("-", "_2d"); - blockDeviceString = "/org/freedesktop/UDisks/devices/" + blockDeviceString; - - // Mount the drive! - TQT_DBusError error; - TQT_DBusProxy driveControl("org.freedesktop.UDisks", blockDeviceString, "org.freedesktop.UDisks.Device", dbusConn); - if (driveControl.canSend()) { - TQValueList<TQT_DBusData> params; - params << TQT_DBusData::fromList(TQT_DBusDataList(unMountOptions)); - TQT_DBusMessage reply = driveControl.sendWithReply("FilesystemUnmount", params, &error); - if (error.isValid()) { - // Error! - if (error.name() == "org.freedesktop.DBus.Error.ServiceUnknown") { - // Service not installed or unavailable - return -2; - } - if (errStr) { - *errStr = error.name() + ": " + error.message(); - } - else { - printf("[ERROR][tdehwlib] unMountDriveUDisks: %s\n", error.name().ascii()); fflush(stdout); - } - return -1; - } - else { - return 0; - } - } - else { - return -2; - } - } -#endif // WITH_UDISKS - return -2; -} - -int unMountDriveUDisks2(TQString deviceNode, TQString unMountOptions, TQString* errStr = NULL) { -#ifdef WITH_UDISKS2 - TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); - if (dbusConn.isConnected()) { - TQString blockDeviceString = deviceNode; - blockDeviceString.replace("/dev/", ""); - blockDeviceString.replace("-", "_2d"); - blockDeviceString = "/org/freedesktop/UDisks2/block_devices/" + blockDeviceString; - - // Mount the drive! - TQT_DBusError error; - TQT_DBusProxy driveControl("org.freedesktop.UDisks2", blockDeviceString, "org.freedesktop.UDisks2.Filesystem", dbusConn); - if (driveControl.canSend()) { - TQValueList<TQT_DBusData> params; - TQMap<TQString, TQT_DBusData> optionsMap; - optionsMap["options"] = (TQT_DBusData::fromString(unMountOptions)).getAsVariantData(); - params << TQT_DBusData::fromStringKeyMap(TQT_DBusDataMap<TQString>(optionsMap)); - TQT_DBusMessage reply = driveControl.sendWithReply("Unmount", params, &error); - if (error.isValid()) { - // Error! - if (error.name() == "org.freedesktop.DBus.Error.ServiceUnknown") { - // Service not installed or unavailable - return -2; - } - if (errStr) { - *errStr = error.name() + ": " + error.message(); - } - else { - printf("[ERROR][tdehwlib] unMountDriveUDisks2: %s\n", error.name().ascii()); fflush(stdout); - } - return -1; - } - else { - return 0; - } - } - else { - return -2; - } - } -#endif // WITH_UDISKS2 - return -2; -} - bool TDEStorageDevice::ejectDrive() { -#ifdef WITH_UDISKS2 if (!(TDEGlobal::dirs()->findExe("udisksctl").isEmpty())) { if (ejectDriveUDisks2(this)) { return true; @@ -607,9 +317,6 @@ bool TDEStorageDevice::ejectDrive() { fflush(stdout); } } -#endif // WITH_UDISKS2 - -#ifdef WITH_UDISKS if (!(TDEGlobal::dirs()->findExe("udisks").isEmpty())) { if (ejectDriveUDisks(this)) { return true; @@ -619,7 +326,6 @@ bool TDEStorageDevice::ejectDrive() { fflush(stdout); } } -#endif // WITH_UDISKS if (!(TDEGlobal::dirs()->findExe("eject").isEmpty())) { TQString command = TQString("eject -v '%1' 2>&1").arg(deviceNode()); @@ -994,24 +700,20 @@ TQString TDEStorageDevice::mountPath() { } TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOptions mountOptions, TQString* errRet, int* retcode) { + // Device is already mounted + if (!mountPath().isNull()) { + return mountPath(); + } + int internal_retcode; if (!retcode) { retcode = &internal_retcode; } - TQString ret = mountPath(); - - // Device is already mounted - if (!ret.isNull()) { - return ret; - } - - TQString command; TQString devNode = deviceNode(); devNode.replace("'", "'\\''"); mediaName.replace("'", "'\\''"); -#if defined(WITH_UDEVIL) || defined(WITH_UDISKS2) || defined(WITH_UDISKS) // Prepare filesystem options for mount TQStringList udisksOptions; TQString optionString; @@ -1068,109 +770,70 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption if (!optionString.isEmpty()) { optionString.remove(0, 1); } -#endif // defined(WITH_UDEVIL) || defined(WITH_UDISKS2) || defined(WITH_UDISKS) - -#ifdef WITH_UDEVIL - if(command.isEmpty()) { - // Use 'udevil' command, if available - TQString udevilProg = TDEGlobal::dirs()->findExe("udevil"); - if (!udevilProg.isEmpty()) { - - TQString fileSystemType; - if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) { - fileSystemType = TQString("-t %1").arg(mountOptions["filesystem"]); - } - TQString mountpoint; - if (mountOptions.contains("mountpoint") - && !mountOptions["mountpoint"].isEmpty() - && (mountOptions["mountpoint"] != "/media/")) { - mountpoint = mountOptions["mountpoint"]; - mountpoint.replace("'", "'\\''"); - } - else { - mountpoint = TQString("/media/%1").arg(mediaName); - } + // Try to use UDISKS v2 via DBUS, if available + TQString errorString; + TQString fileSystemType; - command = TQString("udevil mount %1 -o '%2' '%3' '%4' 2>&1").arg(fileSystemType).arg(optionString).arg(devNode).arg(mountpoint); - } + if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) { + fileSystemType = mountOptions["filesystem"]; } -#endif // WITH_UDEVIL - -#ifdef WITH_UDISKS2 - if(command.isEmpty()) { - // Try to use UDISKS v2 via DBUS, if available - TQString errorString; - TQString fileSystemType; - if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) { - fileSystemType = mountOptions["filesystem"]; - } - - int uDisks2Ret = mountDriveUDisks2(devNode, fileSystemType, optionString, &errorString); - if (uDisks2Ret == 0) { - // Update internal mount data - TDEGlobal::hardwareDevices()->processModifiedMounts(); - - ret = mountPath(); - return ret; + int uDisks2Ret = mountDriveUDisks2(devNode, fileSystemType, optionString, &errorString); + if (uDisks2Ret == 0) { + // Update internal mount data + TDEGlobal::hardwareDevices()->processModifiedMounts(); + return mountPath(); + } + else if (uDisks2Ret == -1) { + if (errRet) { + *errRet = errorString; } - else if (uDisks2Ret == -1) { - if (errRet) { - *errRet = errorString; - } - - // Update internal mount data - TDEGlobal::hardwareDevices()->processModifiedMounts(); + // Update internal mount data + TDEGlobal::hardwareDevices()->processModifiedMounts(); + return mountPath(); + } - ret = mountPath(); - return ret; - } - else { - // The UDISKS v2 DBUS service was either not available or was unusable; try another method... - command = TQString::null; + // The UDISKS v2 DBUS service was either not available or was unusable + // Try to use UDISKS v1 via DBUS, if available + int uDisksRet = mountDriveUDisks(devNode, fileSystemType, udisksOptions, &errorString); + if (uDisksRet == 0) { + // Update internal mount data + TDEGlobal::hardwareDevices()->processModifiedMounts(); + return mountPath(); + } + else if (uDisksRet == -1) { + if (errRet) { + *errRet = errorString; } + // Update internal mount data + TDEGlobal::hardwareDevices()->processModifiedMounts(); + return mountPath(); } -#endif // WITH_UDISKS2 - -#ifdef WITH_UDISKS - if(command.isEmpty()) { - // Try to use UDISKS v1 via DBUS, if available - TQString errorString; - TQString fileSystemType; + // The UDISKS v1 DBUS service was either not available or was unusable + // Use 'udevil' command, if available + TQString command = TQString::null; + TQString udevilProg = TDEGlobal::dirs()->findExe("udevil"); + if (!udevilProg.isEmpty()) { if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) { - fileSystemType = mountOptions["filesystem"]; + fileSystemType = TQString("-t %1").arg(mountOptions["filesystem"]); } - - int uDisksRet = mountDriveUDisks(devNode, fileSystemType, udisksOptions, &errorString); - if (uDisksRet == 0) { - // Update internal mount data - TDEGlobal::hardwareDevices()->processModifiedMounts(); - - ret = mountPath(); - return ret; - } - else if (uDisksRet == -1) { - if (errRet) { - *errRet = errorString; - } - - // Update internal mount data - TDEGlobal::hardwareDevices()->processModifiedMounts(); - - ret = mountPath(); - return ret; + TQString mountpoint; + if (mountOptions.contains("mountpoint") && !mountOptions["mountpoint"].isEmpty() && + (mountOptions["mountpoint"] != "/media/")) { + mountpoint = mountOptions["mountpoint"]; + mountpoint.replace("'", "'\\''"); } else { - // The UDISKS v1 DBUS service was either not available or was unusable; try another method... - command = TQString::null; + mountpoint = TQString("/media/%1").arg(mediaName); } + command = TQString("udevil mount %1 -o '%2' '%3' '%4' 2>&1") + .arg(fileSystemType).arg(optionString).arg(devNode).arg(mountpoint); } -#endif // WITH_UDISKS + // If 'udevil' was not found, use 'pmount' command if available if(command.isEmpty()) { - // Use 'pmount' command, if available TQString pmountProg = TDEGlobal::dirs()->findExe("pmount"); if (!pmountProg.isEmpty()) { // Create dummy password file @@ -1203,9 +866,8 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption } TQString mountpoint; - if (mountOptions.contains("mountpoint") - && !mountOptions["mountpoint"].isEmpty() - && (mountOptions["mountpoint"] != "/media/")) { + if (mountOptions.contains("mountpoint") && !mountOptions["mountpoint"].isEmpty() && + (mountOptions["mountpoint"] != "/media/")) { mountpoint = mountOptions["mountpoint"]; mountpoint.replace("'", "'\\''"); } @@ -1216,7 +878,8 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption TQString passFileName = passwordFile.name(); passFileName.replace("'", "'\\''"); - command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mountpoint); + command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1") + .arg(passFileName).arg(optionString).arg(devNode).arg(mountpoint); } } @@ -1224,7 +887,7 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption if (errRet) { *errRet = i18n("No supported mounting methods were detected on your system"); } - return ret; + return mountPath(); } FILE *exepipe = popen(command.local8Bit(), "r"); @@ -1241,10 +904,7 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption // Update internal mount data TDEGlobal::hardwareDevices()->processModifiedMounts(); - - ret = mountPath(); - - return ret; + return mountPath(); } TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString mediaName, TDEStorageMountOptions mountOptions, TQString* errRet, int* retcode) { @@ -1274,15 +934,15 @@ TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString me 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"); } @@ -1323,6 +983,10 @@ TQString TDEStorageDevice::mountEncryptedDevice(TQString passphrase, TQString me } bool TDEStorageDevice::unmountDevice(TQString* errRet, int* retcode) { + if (mountPath().isNull()) { + return true; + } + int internal_retcode; if (!retcode) { retcode = &internal_retcode; @@ -1331,77 +995,50 @@ bool TDEStorageDevice::unmountDevice(TQString* errRet, int* retcode) { TQString mountpoint = mountPath(); TQString devNode = deviceNode(); - if (mountpoint.isNull()) { - return true; - } - mountpoint.replace("'", "'\\''"); - TQString command; - -#ifdef WITH_UDEVIL - if(command.isEmpty() && - !(TDEGlobal::dirs()->findExe("udevil").isEmpty())) { - command = TQString("udevil umount '%1' 2>&1").arg(mountpoint); + // Try to use UDISKS v2 via DBUS, if available + TQString errorString; + int unMountUDisks2Ret = unMountDriveUDisks2(devNode, TQString::null, &errorString); + if (unMountUDisks2Ret == 0) { + // Update internal mount data + TDEGlobal::hardwareDevices()->processModifiedMounts(); + return true; } -#endif // WITH_UDEVIL - -#ifdef WITH_UDISKS2 - if(command.isEmpty()) { - // Try to use UDISKS v2 via DBUS, if available - TQString errorString; - int unMountUDisks2Ret = unMountDriveUDisks2(devNode, TQString::null, &errorString); - if (unMountUDisks2Ret == 0) { - // Update internal mount data - TDEGlobal::hardwareDevices()->processModifiedMounts(); - - return true; - } - else if (unMountUDisks2Ret == -1) { - if (errRet) { - *errRet = errorString; - } - - // Update internal mount data - TDEGlobal::hardwareDevices()->processModifiedMounts(); - - return false; - } - else { - // The UDISKS v2 DBUS service was either not available or was unusable; try another method... - command = TQString::null; + else if (unMountUDisks2Ret == -1) { + if (errRet) { + *errRet = errorString; } + // Update internal mount data + TDEGlobal::hardwareDevices()->processModifiedMounts(); + return false; } -#endif // WITH_UDISKS2 - -#ifdef WITH_UDISKS - if(command.isEmpty()) { - // Try to use UDISKS v1 via DBUS, if available - TQString errorString; - int unMountUDisksRet = unMountDriveUDisks(devNode, TQStringList(), &errorString); - if (unMountUDisksRet == 0) { - // Update internal mount data - TDEGlobal::hardwareDevices()->processModifiedMounts(); - return true; + // The UDISKS v2 DBUS service was either not available or was unusable + // Try to use UDISKS v1 via DBUS, if available + int unMountUDisksRet = unMountDriveUDisks(devNode, TQStringList(), &errorString); + if (unMountUDisksRet == 0) { + // Update internal mount data + TDEGlobal::hardwareDevices()->processModifiedMounts(); + return true; + } + else if (unMountUDisksRet == -1) { + if (errRet) { + *errRet = errorString; } - else if (unMountUDisksRet == -1) { - if (errRet) { - *errRet = errorString; - } - - // Update internal mount data - TDEGlobal::hardwareDevices()->processModifiedMounts(); + // Update internal mount data + TDEGlobal::hardwareDevices()->processModifiedMounts(); + return false; + } - return false; - } - else { - // The UDISKS v1 DBUS service was either not available or was unusable; try another method... - command = TQString::null; - } + // The UDISKS v1 DBUS service was either not available or was unusable + // Try to use udevil, if available + TQString command; + if(!(TDEGlobal::dirs()->findExe("udevil").isEmpty())) { + command = TQString("udevil umount '%1' 2>&1").arg(mountpoint); } -#endif // WITH_UDISKS + // If 'udevil' was not found, use 'pmount' command if available if(command.isEmpty() && !(TDEGlobal::dirs()->findExe("pumount").isEmpty())) { command = TQString("pumount '%1' 2>&1").arg(mountpoint); |