summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw/tdestoragedevice.cpp
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2016-01-23 04:46:16 +0100
committerSlávek Banko <slavek.banko@axis.cz>2016-01-23 04:46:16 +0100
commitece75495e126871b52b2fca5ba1974cf77030153 (patch)
treee52595987d6f046a22b17b9062f4a1a3e9e6ec28 /tdecore/tdehw/tdestoragedevice.cpp
parentc10124c96557042d5a9c0170dd2883557997be3e (diff)
downloadtdelibs-ece75495e126871b52b2fca5ba1974cf77030153.tar.gz
tdelibs-ece75495e126871b52b2fca5ba1974cf77030153.zip
Add support for udevil to mount/unmount removable drives
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'tdecore/tdehw/tdestoragedevice.cpp')
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp40
1 files changed, 38 insertions, 2 deletions
diff --git a/tdecore/tdehw/tdestoragedevice.cpp b/tdecore/tdehw/tdestoragedevice.cpp
index 38907df79..1f3e046be 100644
--- a/tdecore/tdehw/tdestoragedevice.cpp
+++ b/tdecore/tdehw/tdestoragedevice.cpp
@@ -1026,7 +1026,7 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption
devNode.replace("'", "'\\''");
mediaName.replace("'", "'\\''");
-#if defined(WITH_UDISKS2) || defined(WITH_UDISKS)
+#if defined(WITH_UDEVIL) || defined(WITH_UDISKS2) || defined(WITH_UDISKS)
// Prepare filesystem options for mount
TQStringList udisksOptions;
TQString optionString;
@@ -1083,7 +1083,34 @@ TQString TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageMountOption
if (!optionString.isEmpty()) {
optionString.remove(0, 1);
}
-#endif // defined(WITH_UDISKS2) || defined(WITH_UDISKS)
+#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);
+ }
+
+ command = TQString("udevil mount %1 -o '%2' '%3' '%4' 2>&1").arg(fileSystemType).arg(optionString).arg(devNode).arg(mountpoint);
+ }
+ }
+#endif // WITH_UDEVIL
#ifdef WITH_UDISKS2
if(command.isEmpty()) {
@@ -1327,6 +1354,13 @@ bool TDEStorageDevice::unmountDevice(TQString* errRet, int* retcode) {
TQString command;
+#ifdef WITH_UDEVIL
+ if(command.isEmpty() &&
+ !(TDEGlobal::dirs()->findExe("udevil").isEmpty())) {
+ command = TQString("udevil umount '%1' 2>&1").arg(mountpoint);
+ }
+#endif // WITH_UDEVIL
+
#ifdef WITH_UDISKS2
if(command.isEmpty()) {
// Try to use UDISKS v2 via DBUS, if available
@@ -1354,6 +1388,7 @@ bool TDEStorageDevice::unmountDevice(TQString* errRet, int* retcode) {
}
}
#endif // WITH_UDISKS2
+
#ifdef WITH_UDISKS
if(command.isEmpty()) {
// Try to use UDISKS v1 via DBUS, if available
@@ -1381,6 +1416,7 @@ bool TDEStorageDevice::unmountDevice(TQString* errRet, int* retcode) {
}
}
#endif // WITH_UDISKS
+
if(command.isEmpty() &&
!(TDEGlobal::dirs()->findExe("pumount").isEmpty())) {
command = TQString("pumount '%1' 2>&1").arg(mountpoint);