Add an initial support for UDisks2 solid backend.

Currently, UDisks2 support can only be enabled at compile time.
BUG:311408

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1358151
This commit is contained in:
Andrius Štikonas 2013-06-23 09:44:38 +00:00
parent 42302a11cc
commit 6573cfd4ea
3 changed files with 35 additions and 21 deletions

View File

@ -45,6 +45,11 @@ add_definitions(${KDE4_ENABLE_EXCEPTIONS})
include(KDE4Defaults)
include(MacroLibrary)
option(ENABLE_UDISKS2 "Use UDisks2 backend." OFF)
if (ENABLE_UDISKS2)
add_definitions(-DENABLE_UDISKS2)
endif (ENABLE_UDISKS2)
include_directories(${KDE4_INCLUDES} ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} ${UUID_INCLUDE_DIRS} ${BLKID_INCLUDE_DIRS} lib/ src/)
add_subdirectory(lib)

View File

@ -447,6 +447,8 @@ static quint32 countDevices(const QList<Solid::Device>& driveList)
foreach(const Solid::Device& solidDevice, driveList)
{
(void) solidDevice; // Silence compiler warning.
#ifndef ENABLE_UDISKS2
const Solid::StorageDrive* solidDrive = solidDevice.as<Solid::StorageDrive>();
if (solidDrive->driveType() == Solid::StorageDrive::HardDisk ||
solidDrive->driveType() == Solid::StorageDrive::CompactFlash ||
@ -454,9 +456,9 @@ static quint32 countDevices(const QList<Solid::Device>& driveList)
solidDrive->driveType() == Solid::StorageDrive::SmartMedia ||
solidDrive->driveType() == Solid::StorageDrive::SdMmc ||
solidDrive->driveType() == Solid::StorageDrive::Xd)
#endif
rval++;
}
return rval;
}
@ -471,6 +473,7 @@ QList<Device*> LibPartedBackend::scanDevices()
foreach(const Solid::Device& solidDevice, driveList)
{
#ifndef ENABLE_UDISKS2
const Solid::StorageDrive* solidDrive = solidDevice.as<Solid::StorageDrive>();
if (solidDrive->driveType() != Solid::StorageDrive::HardDisk &&
@ -480,6 +483,7 @@ QList<Device*> LibPartedBackend::scanDevices()
solidDrive->driveType() != Solid::StorageDrive::SdMmc &&
solidDrive->driveType() != Solid::StorageDrive::Xd)
continue;
#endif
const Solid::Block* solidBlock = solidDevice.as<Solid::Block>();

View File

@ -232,9 +232,14 @@ bool checkAccessibleDevices()
QList<Solid::Device> getSolidDeviceList()
{
QString predicate = "[ [ [ StorageDrive.driveType == 'HardDisk' OR StorageDrive.driveType == 'CompactFlash'] OR "
"[ StorageDrive.driveType == 'MemoryStick' OR StorageDrive.driveType == 'SmartMedia'] ] OR "
"[ StorageDrive.driveType == 'SdMmc' OR StorageDrive.driveType == 'Xd'] ]";
#ifdef ENABLE_UDISKS2
QString predicate = "StorageVolume.usage == 'PartitionTable'";
#else
QString predicate = "[ [ [ StorageDrive.driveType == 'HardDisk' OR StorageDrive.driveType == 'CompactFlash'] OR "
"[ StorageDrive.driveType == 'MemoryStick' OR StorageDrive.driveType == 'SmartMedia'] ] OR "
"[ StorageDrive.driveType == 'SdMmc' OR StorageDrive.driveType == 'Xd'] ]";
#endif
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
if (args->count() > 0)