Added back build options for UDISKS2, UDISKS and UDEVIL as requested by

some users.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/73/head
Michele Calgaro 5 years ago
parent 94515be234
commit b6953843f5
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -92,6 +92,9 @@ OPTION( WITH_HAL "Enable HAL support" OFF )
OPTION( WITH_DEVKITPOWER "Enable DeviceKit Power support" OFF ) OPTION( WITH_DEVKITPOWER "Enable DeviceKit Power support" OFF )
OPTION( WITH_LOGINDPOWER "Enable Logind/Systemd Power support" OFF ) OPTION( WITH_LOGINDPOWER "Enable Logind/Systemd Power support" OFF )
OPTION( WITH_UPOWER "Enable uPower support" ${WITH_ALL_OPTIONS} ) 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_CONSOLEKIT "Enable ConsoleKit support" ${WITH_ALL_OPTIONS} )
OPTION( WITH_NETWORK_MANAGER_BACKEND "Enable network-manager support" OFF ) 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 ) OPTION( WITH_SUDO_TDESU_BACKEND "Use sudo as backend for tdesu (default is su)" OFF )

@ -17,6 +17,13 @@ if( NOT DBUS_SYSTEM_BUS )
set( DBUS_SYSTEM_BUS "unix:path=/var/run/dbus/system_bus_socket" CACHE INTERNAL "" FORCE ) set( DBUS_SYSTEM_BUS "unix:path=/var/run/dbus/system_bus_socket" CACHE INTERNAL "" FORCE )
endif() endif()
if( WITH_TDEHWLIB_DAEMONS OR WITH_HAL OR WITH_DEVKITPOWER OR WITH_UPOWER OR WITH_UDISKS OR WITH_UDISKS2 OR
WITH_NETWORK_MANAGER_BACKEND OR WITH_CONSOLEKIT )
list( APPEND TDEHW_CUSTOM_INCLUDE_DIRS ${DBUS_TQT_INCLUDE_DIRS} )
list( APPEND TDEHW_CUSTOM_LIBRARY_DIRS ${DBUS_TQT_LIBRARY_DIRS} )
list( APPEND TDEHW_CUSTOM_LIBRARIES ${DBUS_TQT_LIBRARIES} )
endif( )
if( WITH_TDEHWLIB_DAEMONS ) if( WITH_TDEHWLIB_DAEMONS )
add_definitions( -DWITH_TDEHWLIB_DAEMONS ) add_definitions( -DWITH_TDEHWLIB_DAEMONS )
endif( ) endif( )
@ -37,6 +44,18 @@ if( WITH_UPOWER )
add_definitions( -DWITH_UPOWER ) add_definitions( -DWITH_UPOWER )
endif( ) endif( )
if( WITH_UDISKS )
add_definitions( -DWITH_UDISKS )
endif( )
if( WITH_UDISKS2 )
add_definitions( -DWITH_UDISKS2 )
endif( )
if( WITH_UDEVIL )
add_definitions( -DWITH_UDEVIL )
endif( )
if( WITH_CONSOLEKIT ) if( WITH_CONSOLEKIT )
add_definitions( -DWITH_CONSOLEKIT ) add_definitions( -DWITH_CONSOLEKIT )
endif( ) endif( )
@ -73,13 +92,11 @@ include_directories(
${CMAKE_SOURCE_DIR}/tdecore ${CMAKE_SOURCE_DIR}/tdecore
${CMAKE_SOURCE_DIR}/dcop ${CMAKE_SOURCE_DIR}/dcop
${CMAKE_BINARY_DIR}/tdeio/kssl ${CMAKE_BINARY_DIR}/tdeio/kssl
${DBUS_TQT_INCLUDE_DIRS}
${TDEHW_CUSTOM_INCLUDE_DIRS} ${TDEHW_CUSTOM_INCLUDE_DIRS}
) )
link_directories( link_directories(
${TQT_LIBRARY_DIRS} ${TQT_LIBRARY_DIRS}
${DBUS_TQT_LIBRARY_DIRS}
${TDEHW_CUSTOM_LIBRARY_DIRS} ${TDEHW_CUSTOM_LIBRARY_DIRS}
) )
@ -109,6 +126,5 @@ set( ${target}_SRCS
tde_add_library( ${target} STATIC_PIC AUTOMOC tde_add_library( ${target} STATIC_PIC AUTOMOC
SOURCES ${${target}_SRCS} SOURCES ${${target}_SRCS}
LINK udev ${TDENM_LIBRARIES} ${TDEUPOWER_LIBRARIES} ${DBUS_TQT_LIBRARIES} LINK udev ${TDENM_LIBRARIES} ${TDEUPOWER_LIBRARIES} ${TDEHW_CUSTOM_LIBRARIES}
${TDEHW_CUSTOM_LIBRARIES}
) )

@ -20,16 +20,21 @@
#include "disksHelper.h" #include "disksHelper.h"
#include "tdelocale.h" #include "tdelocale.h"
#include "tdestoragedevice.h" #include "tdestoragedevice.h"
#include <tqdbusdata.h>
#include <tqdbusmessage.h>
#include <tqdbusproxy.h>
#include <tqdbusvariant.h>
#include <tqdbusconnection.h>
#include <tqdbuserror.h>
#include <tqdbusdatamap.h>
#include <tqdbusobjectpath.h>
#include "tqdbusdatalist.h"
#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>
#include "tqdbusdatalist.h"
#endif
#ifdef WITH_UDISKS
//------------------------------- //-------------------------------
// UDisks // UDisks
//------------------------------- //-------------------------------
@ -148,7 +153,10 @@ TQStringVariantMap UDisksUnmountDrive(TQString deviceNode, TQStringList unmountO
} }
return result; return result;
} }
#endif
#ifdef WITH_UDISKS2
//------------------------------- //-------------------------------
// UDisks2 // UDisks2
//------------------------------- //-------------------------------
@ -310,5 +318,4 @@ TQStringVariantMap UDisks2UnmountDrive(TQString deviceNode, TQString unmountOpti
} }
return result; return result;
} }
#endif

@ -308,6 +308,7 @@ bool TDEStorageDevice::lockDriveMedia(bool lock) {
} }
bool TDEStorageDevice::ejectDrive() { bool TDEStorageDevice::ejectDrive() {
#ifdef WITH_UDISKS2
if (!(TDEGlobal::dirs()->findExe("udisksctl").isEmpty())) { if (!(TDEGlobal::dirs()->findExe("udisksctl").isEmpty())) {
TQStringVariantMap ejectResult = UDisks2EjectDrive(this); TQStringVariantMap ejectResult = UDisks2EjectDrive(this);
if (ejectResult["result"].toBool()) { if (ejectResult["result"].toBool()) {
@ -318,6 +319,8 @@ bool TDEStorageDevice::ejectDrive() {
fflush(stdout); fflush(stdout);
} }
} }
#endif
#ifdef WITH_UDISKS
if (!(TDEGlobal::dirs()->findExe("udisks").isEmpty())) { if (!(TDEGlobal::dirs()->findExe("udisks").isEmpty())) {
TQStringVariantMap ejectResult = UDisksEjectDrive(this); TQStringVariantMap ejectResult = UDisksEjectDrive(this);
if (ejectResult["result"].toBool()) { if (ejectResult["result"].toBool()) {
@ -328,6 +331,7 @@ bool TDEStorageDevice::ejectDrive() {
fflush(stdout); fflush(stdout);
} }
} }
#endif
if (!(TDEGlobal::dirs()->findExe("eject").isEmpty())) { if (!(TDEGlobal::dirs()->findExe("eject").isEmpty())) {
TQString command = TQString("eject -v '%1' 2>&1").arg(deviceNode()); TQString command = TQString("eject -v '%1' 2>&1").arg(deviceNode());
@ -718,7 +722,9 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
TQString devNode = deviceNode(); TQString devNode = deviceNode();
devNode.replace("'", "'\\''"); devNode.replace("'", "'\\''");
mediaName.replace("'", "'\\''"); mediaName.replace("'", "'\\''");
TQString command = TQString::null;
#if defined(WITH_UDISKS2) || defined(WITH_UDISKS) || defined(WITH_UDEVIL)
// Prepare filesystem options for mount // Prepare filesystem options for mount
TQStringList udisksOptions; TQStringList udisksOptions;
if (mountOptions["ro"] == "true") { if (mountOptions["ro"] == "true") {
@ -770,13 +776,17 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
optionString.remove(0, 1); optionString.remove(0, 1);
} }
// Try to use UDISKS v2 via DBUS, if available
TQString fileSystemType; TQString fileSystemType;
if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) { if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
fileSystemType = mountOptions["filesystem"]; fileSystemType = mountOptions["filesystem"];
} }
TQStringVariantMap mountResult = UDisks2MountDrive(devNode, fileSystemType, optionString); TQStringVariantMap mountResult;
#endif
#if defined(WITH_UDISKS2)
// Try to use UDISKS v2 via DBUS, if available
mountResult = UDisks2MountDrive(devNode, fileSystemType, optionString);
if (mountResult["result"].toBool()) { if (mountResult["result"].toBool()) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
@ -791,7 +801,9 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
result["result"] = false; result["result"] = false;
return result; return result;
} }
#endif
#if defined(WITH_UDISKS)
// The UDISKS v2 DBUS service was either not available or was unusable // The UDISKS v2 DBUS service was either not available or was unusable
// Try to use UDISKS v1 via DBUS, if available // Try to use UDISKS v1 via DBUS, if available
mountResult = UDisksMountDrive(devNode, fileSystemType, udisksOptions); mountResult = UDisksMountDrive(devNode, fileSystemType, udisksOptions);
@ -809,10 +821,11 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
result["result"] = false; result["result"] = false;
return result; return result;
} }
#endif
#if defined(WITH_UDEVIL)
// The UDISKS v1 DBUS service was either not available or was unusable // The UDISKS v1 DBUS service was either not available or was unusable
// Use 'udevil' command, if available // Use 'udevil' command, if available
TQString command = TQString::null;
if (!TDEGlobal::dirs()->findExe("udevil").isEmpty()) { if (!TDEGlobal::dirs()->findExe("udevil").isEmpty()) {
if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) { if (mountOptions.contains("filesystem") && !mountOptions["filesystem"].isEmpty()) {
fileSystemType = TQString("-t %1").arg(mountOptions["filesystem"]); fileSystemType = TQString("-t %1").arg(mountOptions["filesystem"]);
@ -829,8 +842,9 @@ TQStringVariantMap TDEStorageDevice::mountDevice(TQString mediaName, TDEStorageM
command = TQString("udevil mount %1 -o '%2' '%3' '%4' 2>&1") command = TQString("udevil mount %1 -o '%2' '%3' '%4' 2>&1")
.arg(fileSystemType).arg(optionString).arg(devNode).arg(mountpoint); .arg(fileSystemType).arg(optionString).arg(devNode).arg(mountpoint);
} }
#endif
// If 'udevil' was not found, use 'pmount' command if available // If no other method was found, use 'pmount' command if available
if(command.isEmpty()) { if(command.isEmpty()) {
if (!TDEGlobal::dirs()->findExe("pmount").isEmpty()) { if (!TDEGlobal::dirs()->findExe("pmount").isEmpty()) {
// Create dummy password file // Create dummy password file
@ -990,9 +1004,12 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
mountpoint.replace("'", "'\\''"); mountpoint.replace("'", "'\\''");
TQString devNode = deviceNode(); TQString devNode = deviceNode();
TQString command = TQString::null;
TQStringVariantMap unmountResult;
#if defined(WITH_UDISKS2)
// Try to use UDISKS v2 via DBUS, if available // Try to use UDISKS v2 via DBUS, if available
TQStringVariantMap unmountResult = UDisks2UnmountDrive(devNode, TQString::null); unmountResult = UDisks2UnmountDrive(devNode, TQString::null);
if (unmountResult["result"].toBool()) { if (unmountResult["result"].toBool()) {
// Update internal mount data // Update internal mount data
TDEGlobal::hardwareDevices()->processModifiedMounts(); TDEGlobal::hardwareDevices()->processModifiedMounts();
@ -1006,7 +1023,9 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
result["result"] = false; result["result"] = false;
return result; return result;
} }
#endif
#if defined(WITH_UDISKS)
// The UDISKS v2 DBUS service was either not available or was unusable // The UDISKS v2 DBUS service was either not available or was unusable
// Try to use UDISKS v1 via DBUS, if available // Try to use UDISKS v1 via DBUS, if available
unmountResult = UDisksUnmountDrive(devNode, TQStringList()); unmountResult = UDisksUnmountDrive(devNode, TQStringList());
@ -1023,15 +1042,17 @@ TQStringVariantMap TDEStorageDevice::unmountDevice() {
result["result"] = false; result["result"] = false;
return result; return result;
} }
#endif
#if defined(WITH_UDEVIL)
// The UDISKS v1 DBUS service was either not available or was unusable // The UDISKS v1 DBUS service was either not available or was unusable
// Use 'udevil' command, if available // Use 'udevil' command, if available
TQString command = TQString::null;
if (!TDEGlobal::dirs()->findExe("udevil").isEmpty()) { if (!TDEGlobal::dirs()->findExe("udevil").isEmpty()) {
command = TQString("udevil umount '%1' 2>&1").arg(mountpoint); command = TQString("udevil umount '%1' 2>&1").arg(mountpoint);
} }
#endif
// If 'udevil' was not found, use 'pmount' command if available // If no other method was found, use 'pmount' command if available
if(command.isEmpty() && !TDEGlobal::dirs()->findExe("pumount").isEmpty()) { if(command.isEmpty() && !TDEGlobal::dirs()->findExe("pumount").isEmpty()) {
command = TQString("pumount '%1' 2>&1").arg(mountpoint); command = TQString("pumount '%1' 2>&1").arg(mountpoint);
} }

@ -1670,16 +1670,19 @@ void FileProtocol::unmount( const TQString& _point )
bool FileProtocol::pmount(const TQString &dev) bool FileProtocol::pmount(const TQString &dev)
{ {
TQString mountProg; TQString mountProg = TQString::null;
TQCString buffer; TQCString buffer;
#ifdef WITH_UDISKS2
// Use 'udisksctl' (UDISKS2) if available // Use 'udisksctl' (UDISKS2) if available
mountProg = TDEGlobal::dirs()->findExe("udisksctl"); mountProg = TDEGlobal::dirs()->findExe("udisksctl");
if (!mountProg.isEmpty()) { if (!mountProg.isEmpty()) {
buffer.sprintf( "%s mount -b %s", TQFile::encodeName(mountProg).data(), buffer.sprintf( "%s mount -b %s", TQFile::encodeName(mountProg).data(),
TQFile::encodeName(TDEProcess::quote(dev)).data() ); TQFile::encodeName(TDEProcess::quote(dev)).data() );
} }
#endif
#ifdef WITH_UDISKS
// Use 'udisks' (UDISKS1) if available // Use 'udisks' (UDISKS1) if available
if (mountProg.isEmpty()) { if (mountProg.isEmpty()) {
mountProg = TDEGlobal::dirs()->findExe("udisks"); mountProg = TDEGlobal::dirs()->findExe("udisks");
@ -1688,6 +1691,7 @@ bool FileProtocol::pmount(const TQString &dev)
TQFile::encodeName(TDEProcess::quote(dev)).data() ); TQFile::encodeName(TDEProcess::quote(dev)).data() );
} }
} }
#endif
// Use 'pmount', if available // Use 'pmount', if available
if (mountProg.isEmpty()) { if (mountProg.isEmpty()) {
@ -1731,16 +1735,19 @@ bool FileProtocol::pumount(const TQString &point)
if (dev.isEmpty()) return false; if (dev.isEmpty()) return false;
if (dev.endsWith("/")) dev.truncate(dev.length()-1); if (dev.endsWith("/")) dev.truncate(dev.length()-1);
TQString umountProg; TQString umountProg = TQString::null;
TQCString buffer; TQCString buffer;
#ifdef WITH_UDISKS2
// Use 'udisksctl' (UDISKS2), if available // Use 'udisksctl' (UDISKS2), if available
umountProg = TDEGlobal::dirs()->findExe("udisksctl"); umountProg = TDEGlobal::dirs()->findExe("udisksctl");
if (!umountProg.isEmpty()) { if (!umountProg.isEmpty()) {
buffer.sprintf( "%s unmount -b %s", TQFile::encodeName(umountProg).data(), buffer.sprintf( "%s unmount -b %s", TQFile::encodeName(umountProg).data(),
TQFile::encodeName(TDEProcess::quote(dev)).data() ); TQFile::encodeName(TDEProcess::quote(dev)).data() );
} }
#endif
#ifdef WITH_UDISKS
// Use 'udisks' (UDISKS1), if available // Use 'udisks' (UDISKS1), if available
if (umountProg.isEmpty()) { if (umountProg.isEmpty()) {
umountProg = TDEGlobal::dirs()->findExe("udisks"); umountProg = TDEGlobal::dirs()->findExe("udisks");
@ -1749,6 +1756,7 @@ bool FileProtocol::pumount(const TQString &point)
TQFile::encodeName(TDEProcess::quote(dev)).data() ); TQFile::encodeName(TDEProcess::quote(dev)).data() );
} }
} }
#endif
// Use 'pumount', if available // Use 'pumount', if available
if (umountProg.isEmpty()) { if (umountProg.isEmpty()) {

Loading…
Cancel
Save