Skip to content

Commit

Permalink
[systemsettings] Updated udisks2 defines and add it to devel package.…
Browse files Browse the repository at this point in the history
… Contributes to JB#42530
  • Loading branch information
rainemak committed Aug 30, 2018
1 parent 43908cd commit 8ee508e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/src.pro
Expand Up @@ -57,6 +57,7 @@ PUBLIC_HEADERS = \
connmanvpnconnectionproxy.h \
developermodesettings.h \
batterystatus.h \
udisks2defines.h \
diskusage.h \
partition.h \
partitionmanager.h \
Expand All @@ -77,7 +78,6 @@ HEADERS += \
partition_p.h \
partitionmanager_p.h \
udisks2block_p.h \
udisks2defines.h \
udisks2job_p.h \
udisks2monitor_p.h

Expand Down
2 changes: 1 addition & 1 deletion src/udisks2block.cpp
Expand Up @@ -7,7 +7,7 @@
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>

UDisks2::Block::Block(const QString &path, const InterfacePropertyMap &interfacePropertyMap, QObject *parent)
UDisks2::Block::Block(const QString &path, const UDisks2::InterfacePropertyMap &interfacePropertyMap, QObject *parent)
: QObject(parent)
, m_path(path)
, m_interfacePropertyMap(interfacePropertyMap)
Expand Down
8 changes: 3 additions & 5 deletions src/udisks2block_p.h
Expand Up @@ -36,9 +36,7 @@
#include <QVariantMap>
#include <QDBusConnection>

typedef QMap<QString, QVariantMap> InterfacePropertyMap;

Q_DECLARE_METATYPE(InterfacePropertyMap)
#include "udisks2defines.h"

class QDBusPendingCallWatcher;

Expand All @@ -49,7 +47,7 @@ class Block : public QObject
Q_OBJECT

public:
Block(const QString &path, const InterfacePropertyMap &interfacePropertyMap, QObject *parent = nullptr);
Block(const QString &path, const UDisks2::InterfacePropertyMap &interfacePropertyMap, QObject *parent = nullptr);
Block& operator=(const Block& other);

~Block();
Expand Down Expand Up @@ -112,7 +110,7 @@ private slots:
void getEncryptedInterface();

QString m_path;
InterfacePropertyMap m_interfacePropertyMap;
UDisks2::InterfacePropertyMap m_interfacePropertyMap;
QVariantMap m_data;
QDBusConnection m_connection;
QString m_mountPath;
Expand Down
10 changes: 9 additions & 1 deletion src/udisks2defines.h
Expand Up @@ -32,11 +32,18 @@
#ifndef UDISKS2_DEFINES
#define UDISKS2_DEFINES

#include <QVariantMap>

namespace UDisks2 {
static const auto propertiesChangedSignal = QStringLiteral("PropertiesChanged");
static const auto cryptoBackingDeviceKey = QStringLiteral("CryptoBackingDevice");
static const auto interfacesAddedSignal = QStringLiteral("InterfacesAdded");
static const auto interfacesRemovedSignal = QStringLiteral("InterfacesRemoved");
static const auto cryptoBackingDeviceKey = QStringLiteral("CryptoBackingDevice");

typedef QMap<QString, QVariantMap> InterfacePropertyMap;
}

Q_DECLARE_METATYPE(UDisks2::InterfacePropertyMap)

#define DBUS_OBJECT_MANAGER_INTERFACE QLatin1String("org.freedesktop.DBus.ObjectManager")
#define DBUS_OBJECT_PROPERTIES_INTERFACE QLatin1String("org.freedesktop.DBus.Properties")
Expand All @@ -49,6 +56,7 @@ namespace UDisks2 {
// Interfaces
#define UDISKS2_MANAGER_INTERFACE QLatin1String("org.freedesktop.UDisks2.Manager")
#define UDISKS2_ENCRYPTED_INTERFACE QLatin1String("org.freedesktop.UDisks2.Encrypted")
#define UDISKS2_DRIVE_INTERFACE QLatin1String("org.freedesktop.UDisks2.Drive")
#define UDISKS2_BLOCK_INTERFACE QLatin1String("org.freedesktop.UDisks2.Block")
#define UDISKS2_FILESYSTEM_INTERFACE QLatin1String("org.freedesktop.UDisks2.Filesystem")
#define UDISKS2_PARTITION_INTERFACE QLatin1String("org.freedesktop.UDisks2.Partition")
Expand Down
14 changes: 7 additions & 7 deletions src/udisks2monitor.cpp
Expand Up @@ -85,7 +85,7 @@ UDisks2::Monitor::Monitor(PartitionManagerPrivate *manager, QObject *parent)
Q_ASSERT(!sharedInstance);
sharedInstance = this;

qDBusRegisterMetaType<InterfacePropertyMap>();
qDBusRegisterMetaType<UDisks2::InterfacePropertyMap>();
QDBusConnection systemBus = QDBusConnection::systemBus();

connect(systemBus.interface(), &QDBusConnectionInterface::callWithCallbackFailed, this, [this](const QDBusError &error, const QDBusMessage &call) {
Expand All @@ -104,17 +104,17 @@ UDisks2::Monitor::Monitor(PartitionManagerPrivate *manager, QObject *parent)
UDISKS2_SERVICE,
UDISKS2_PATH,
DBUS_OBJECT_MANAGER_INTERFACE,
QStringLiteral("InterfacesAdded"),
interfacesAddedSignal,
this,
SLOT(interfacesAdded(QDBusObjectPath, InterfacePropertyMap)))) {
SLOT(interfacesAdded(QDBusObjectPath, UDisks2::InterfacePropertyMap)))) {
qCWarning(lcMemoryCardLog) << "Failed to connect to interfaces added signal:" << qPrintable(systemBus.lastError().message());
}

if (!systemBus.connect(
UDISKS2_SERVICE,
UDISKS2_PATH,
DBUS_OBJECT_MANAGER_INTERFACE,
QStringLiteral("InterfacesRemoved"),
interfacesRemovedSignal,
this,
SLOT(interfacesRemoved(QDBusObjectPath, QStringList)))) {
qCWarning(lcMemoryCardLog) << "Failed to connect to interfaces removed signal:" << qPrintable(systemBus.lastError().message());
Expand Down Expand Up @@ -202,7 +202,7 @@ void UDisks2::Monitor::format(const QString &deviceName, const QString &type, co
doFormat(deviceName, objectPath, type, arguments);
}

void UDisks2::Monitor::interfacesAdded(const QDBusObjectPath &objectPath, const InterfacePropertyMap &interfaces)
void UDisks2::Monitor::interfacesAdded(const QDBusObjectPath &objectPath, const UDisks2::InterfacePropertyMap &interfaces)
{
QString path = objectPath.path();
qCInfo(lcMemoryCardLog) << "UDisks interface added:" << path << interfaces << externalBlockDevice(path);
Expand Down Expand Up @@ -561,7 +561,7 @@ void UDisks2::Monitor::createPartition(const UDisks2::Block *block)
m_manager->add(addedPartitions);
}

void UDisks2::Monitor::createBlockDevice(const QString &path, const InterfacePropertyMap &interfacePropertyMap)
void UDisks2::Monitor::createBlockDevice(const QString &path, const UDisks2::InterfacePropertyMap &interfacePropertyMap)
{
if (m_blockDevices.contains(path)) {
return;
Expand Down Expand Up @@ -698,7 +698,7 @@ void UDisks2::Monitor::getBlockDevices()
for (const QDBusObjectPath &dbusObjectPath : blockDevicePaths) {
QString path = dbusObjectPath.path();
if (externalBlockDevice(path)) {
createBlockDevice(path, InterfacePropertyMap());
createBlockDevice(path, UDisks2::InterfacePropertyMap());
}
}
} else if (watcher->isError()) {
Expand Down
6 changes: 3 additions & 3 deletions src/udisks2monitor_p.h
Expand Up @@ -41,7 +41,7 @@

#include "partitionmodel.h"
#include "partitionmanager_p.h"
#include "udisks2block_p.h"
#include "udisks2defines.h"

class PartitionManagerPrivate;

Expand Down Expand Up @@ -96,7 +96,7 @@ class Monitor : public QObject
void formatError(Partition::Error error);

private slots:
void interfacesAdded(const QDBusObjectPath &objectPath, const InterfacePropertyMap &interfaces);
void interfacesAdded(const QDBusObjectPath &objectPath, const UDisks2::InterfacePropertyMap &interfaces);
void interfacesRemoved(const QDBusObjectPath &objectPath, const QStringList &interfaces);

private:
Expand All @@ -110,7 +110,7 @@ private slots:
void lookupPartitions(PartitionManagerPrivate::Partitions &affectedPartitions, const QStringList &objects);

void createPartition(const Block *block);
void createBlockDevice(const QString &path, const InterfacePropertyMap &interfacePropertyMap);
void createBlockDevice(const QString &path, const UDisks2::InterfacePropertyMap &interfacePropertyMap);

void doFormat(const QString &deviceName, const QString &dbusObjectPath, const QString &type, const QVariantHash &arguments);
void getBlockDevices();
Expand Down

0 comments on commit 8ee508e

Please sign in to comment.