Add support for udevil to mount/unmount removable drives

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/1/head
Slávek Banko 9 years ago
parent c10124c965
commit ece75495e1

@ -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 )

@ -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( )

@ -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);

Loading…
Cancel
Save