summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--CMakeLists.txt1
-rw-r--r--tdecore/tdehw/CMakeLists.txt4
-rw-r--r--tdecore/tdehw/tdestoragedevice.cpp40
3 files changed, 43 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f16fce036..8758ddea4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -93,6 +93,7 @@ OPTION( WITH_LOGINDPOWER "Enable Logind/Systemd Power support" OFF )
OPTION( WITH_UPOWER "Enable uPower support" ${WITH_ALL_OPTIONS} )
OPTION( WITH_UDISKS "Enable uDisks support" ${WITH_ALL_OPTIONS} )
OPTION( WITH_UDISKS2 "Enable uDisks2 support" ${WITH_ALL_OPTIONS} )
+OPTION( WITH_UDEVIL "Enable udevil support" ${WITH_ALL_OPTIONS} )
OPTION( WITH_CONSOLEKIT "Enable ConsoleKit support" ${WITH_ALL_OPTIONS} )
OPTION( WITH_NETWORK_MANAGER_BACKEND "Enable network-manager support" OFF )
OPTION( WITH_SUDO_TDESU_BACKEND "Use sudo as backend for tdesu (default is su)" OFF )
diff --git a/tdecore/tdehw/CMakeLists.txt b/tdecore/tdehw/CMakeLists.txt
index e21cfdeb0..02b775931 100644
--- a/tdecore/tdehw/CMakeLists.txt
+++ b/tdecore/tdehw/CMakeLists.txt
@@ -52,6 +52,10 @@ if( WITH_UDISKS2 )
add_definitions( -DWITH_UDISKS2 )
endif( )
+if( WITH_UDEVIL )
+ add_definitions( -DWITH_UDEVIL )
+endif( )
+
if( WITH_CONSOLEKIT )
add_definitions( -DWITH_CONSOLEKIT )
endif( )
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);