Commit bdedc51b authored by Raine Makelainen's avatar Raine Makelainen

[systemsettings] Expose format, unmount, and mount from partitionmodel. Contributes to JB#40936

parent 016a17bc
......@@ -33,3 +33,4 @@
Q_LOGGING_CATEGORY(lcVpnLog, "org.sailfishos.settings.vpn", QtWarningMsg)
Q_LOGGING_CATEGORY(lcDeveloperModeLog, "org.sailfishos.settings.developermode", QtWarningMsg)
Q_LOGGING_CATEGORY(lcMemoryCardLog, "org.sailfishos.settings.memorycard", QtWarningMsg)
......@@ -36,5 +36,6 @@
Q_DECLARE_LOGGING_CATEGORY(lcVpnLog)
Q_DECLARE_LOGGING_CATEGORY(lcDeveloperModeLog)
Q_DECLARE_LOGGING_CATEGORY(lcMemoryCardLog)
#endif
......@@ -101,6 +101,11 @@ QString Partition::deviceName() const
return d ? d->deviceName : QString();
}
QString Partition::deviceLabel() const
{
return d ? d->deviceLabel : QString();
}
QString Partition::mountPath() const
{
return d ? d->mountPath : QString();
......
......@@ -33,6 +33,7 @@
#define PARTITION_H
#include <QSharedData>
#include <QObject>
#include <systemsettingsglobal.h>
......@@ -59,11 +60,31 @@ public:
Unmounted,
Mounting,
Mounted,
Unmounting
Unmounting,
Formatting,
Formatted
};
Q_DECLARE_FLAGS(StorageTypes, StorageType)
enum Error {
ErrorFailed,
ErrorCancelled,
ErrorAlreadyCancelled,
ErrorNotAuthorized,
ErrorNotAuthorizedCanObtain,
ErrorNotAuthorizedDismissed,
ErrorAlreadyMounted,
ErrorNotMounted,
ErrorOptionNotPermitted,
ErrorMountedByOtherUser,
ErrorAlreadyUnmounting,
ErrorNotSupported,
ErrorTimedout,
ErrorWouldWakeup,
ErrorDeviceBusy
};
Partition();
Partition(const Partition &partition);
Partition &operator =(const Partition &partition);
......@@ -83,6 +104,7 @@ public:
QString devicePath() const;
QString deviceName() const;
QString deviceLabel() const;
QString mountPath() const;
QString filesystemType() const;
......
......@@ -50,6 +50,7 @@ public:
, canMount(false)
, mountFailed(false)
, deviceRoot(false)
, valid(false)
{
}
......@@ -62,6 +63,7 @@ public:
QString deviceName;
QString devicePath;
QString deviceLabel;
QString mountPath;
QString filesystemType;
QString activeState;
......@@ -74,6 +76,8 @@ public:
bool canMount;
bool mountFailed;
bool deviceRoot;
// If valid, only mount status and available bytes will be checked
bool valid;
};
#endif
......@@ -31,6 +31,7 @@
#include "partitionmanager_p.h"
#include "udisks2monitor_p.h"
#include "logging_p.h"
#include <QFile>
#include <QRegularExpression>
......@@ -43,6 +44,8 @@
static const auto userName = QString(qgetenv("USER"));
static const auto externalMountPath = QString("/run/media/%1/").arg(userName);
static const QRegularExpression externalMedia(QString("^%1$").arg(externalDevice));
PartitionManagerPrivate *PartitionManagerPrivate::sharedInstance = nullptr;
PartitionManagerPrivate::PartitionManagerPrivate()
......@@ -51,6 +54,11 @@ PartitionManagerPrivate::PartitionManagerPrivate()
sharedInstance = this;
m_udisksMonitor.reset(new UDisks2::Monitor(this));
connect(m_udisksMonitor.data(), &UDisks2::Monitor::status, this, &PartitionManagerPrivate::status);
connect(m_udisksMonitor.data(), &UDisks2::Monitor::errorMessage, this, &PartitionManagerPrivate::errorMessage);
connect(m_udisksMonitor.data(), &UDisks2::Monitor::mountError, this, &PartitionManagerPrivate::mountError);
connect(m_udisksMonitor.data(), &UDisks2::Monitor::unmountError, this, &PartitionManagerPrivate::unmountError);
connect(m_udisksMonitor.data(), &UDisks2::Monitor::formatError, this, &PartitionManagerPrivate::formatError);
QExplicitlySharedDataPointer<PartitionPrivate> root(new PartitionPrivate(this));
root->storageType = Partition::System;
......@@ -97,6 +105,8 @@ PartitionManagerPrivate::PartitionManagerPrivate()
if (root->status == Partition::Mounted) {
m_root = Partition(QExplicitlySharedDataPointer<PartitionPrivate>(root));
}
m_udisksMonitor->getBlockDevices();
}
PartitionManagerPrivate::~PartitionManagerPrivate()
......@@ -156,7 +166,6 @@ void PartitionManagerPrivate::refresh()
partitionFile.readLine();
static const QRegularExpression whitespace(QStringLiteral("\\s+"));
static const QRegularExpression externalMedia(QString("^%1$").arg(externalDevice));
static const QRegularExpression deviceRoot(QStringLiteral("^mmcblk\\d+$"));
while (!partitionFile.atEnd()) {
......@@ -234,14 +243,16 @@ void PartitionManagerPrivate::refresh(const Partitions &partitions, Partitions &
for (auto partition : partitions) {
// Reset properties to the unmounted defaults. If the partition is mounted these will be restored
// by the refresh.
partition->status = partition->activeState == QStringLiteral("activating")
? Partition::Mounting
: Partition::Unmounted;
partition->bytesFree = 0;
partition->bytesAvailable = 0;
partition->canMount = false;
partition->readOnly = true;
partition->filesystemType.clear();
if (!partition->valid) {
partition->status = partition->activeState == QStringLiteral("activating")
? Partition::Mounting
: Partition::Unmounted;
partition->canMount = false;
partition->readOnly = true;
partition->filesystemType.clear();
}
}
FILE *mtab = setmntent("/etc/mtab", "r");
......@@ -256,9 +267,11 @@ void PartitionManagerPrivate::refresh(const Partitions &partitions, Partitions &
const QString mountPath = QString::fromUtf8(mountEntry.mnt_dir);
const QString devicePath = QString::fromUtf8(mountEntry.mnt_fsname);
for (auto partition : partitions) {
if ((partition->status == Partition::Mounted || partition->status == Partition::Mounting)
&& (partition->storageType != Partition::External || partition->mountPath.startsWith(externalMountPath))) {
if (partition->valid || ((partition->status == Partition::Mounted || partition->status == Partition::Mounting) &&
(partition->storageType != Partition::External ||
partition->mountPath.startsWith(externalMountPath)))) {
continue;
}
......@@ -279,21 +292,6 @@ void PartitionManagerPrivate::refresh(const Partitions &partitions, Partitions &
}
endmntent(mtab);
blkid_cache cache = nullptr;
// Query filesystems supported by this device
// Note this will only find filesystems supported either directly by the
// kernel, or by modules already loaded.
QStringList supportedFs;
QFile filesystems(QStringLiteral("/proc/filesystems"));
if (filesystems.open(QIODevice::ReadOnly)) {
QString line = filesystems.readLine();
while (line.length() > 0) {
supportedFs << line.trimmed().split('\t').last();
line = filesystems.readLine();
}
}
for (auto partition : partitions) {
if (partition->status == Partition::Mounted) {
......@@ -312,33 +310,54 @@ void PartitionManagerPrivate::refresh(const Partitions &partitions, Partitions &
partition->bytesFree = bytesFree;
partition->bytesAvailable = bytesAvailable;
}
} else if (partition->storageType == Partition::External) {
// Presume the file system can be mounted, unless we can confirm otherwise.
partition->canMount = true;
}
}
}
// If an external partition is unmounted, query the uuid to get the prospective mount path.
if (!cache && blkid_get_cache(&cache, nullptr) < 0) {
qWarning("Failed to load blkid cache");
continue;
}
void PartitionManagerPrivate::mount(const Partition &partition)
{
qCInfo(lcMemoryCardLog) << "Can mount:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.deviceName();
if (externalMedia.match(partition.deviceName()).hasMatch()) {
m_udisksMonitor->mount(partition.deviceName());
}
}
// Directly probing the device would be better but requires root permissions.
if (char * const uuid = blkid_get_tag_value(
cache, "UUID", partition->devicePath.toUtf8().constData())) {
partition->mountPath = externalMountPath + QString::fromUtf8(uuid);
void PartitionManagerPrivate::unmount(const Partition &partition)
{
qCInfo(lcMemoryCardLog) << "Can unmount:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.deviceName();
if (externalMedia.match(partition.deviceName()).hasMatch()) {
m_udisksMonitor->instance()->unmount(partition.deviceName());
} else {
qCWarning(lcMemoryCardLog) << "Unmount allowed only for external memory cards," << partition.devicePath() << "is not allowed";
}
}
::free(uuid);
}
void PartitionManagerPrivate::format(const Partition &partition, const QString &type, const QString &label)
{
qCInfo(lcMemoryCardLog) << "Can format:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.deviceName();
if (char * const type = blkid_get_tag_value(
cache, "TYPE", partition->devicePath.toUtf8().constData())) {
partition->filesystemType = QString::fromUtf8(type);
partition->canMount = !partition->filesystemType.isEmpty() && supportedFs.contains(partition->filesystemType);
if (externalMedia.match(partition.deviceName()).hasMatch()) {
m_udisksMonitor->instance()->format(partition.deviceName(), type, label);
} else {
qCWarning(lcMemoryCardLog) << "Formatting allowed only for external memory cards," << partition.devicePath() << "is not allowed";
}
}
::free(type);
}
QStringList PartitionManagerPrivate::supportedFileSystems() const
{
// Query filesystems supported by this device
// Note this will only find filesystems supported either directly by the
// kernel, or by modules already loaded.
QStringList supportedFs;
QFile filesystems(QStringLiteral("/proc/filesystems"));
if (filesystems.open(QIODevice::ReadOnly)) {
QString line = filesystems.readLine();
while (line.length() > 0) {
supportedFs << line.trimmed().split('\t').last();
line = filesystems.readLine();
}
}
return supportedFs;
}
PartitionManager::PartitionManager(QObject *parent)
......
......@@ -63,11 +63,23 @@ public:
void refresh(PartitionPrivate *partition);
void refresh(const Partitions &partitions, Partitions &changedPartitions);
void mount(const Partition &partition);
void unmount(const Partition &partition);
void format(const Partition &partition, const QString &type, const QString &label);
QStringList supportedFileSystems() const;
signals:
void partitionChanged(const Partition &partition);
void partitionAdded(const Partition &partition);
void partitionRemoved(const Partition &partition);
void status(const QString &deviceName, Partition::Status);
void errorMessage(const QString &objectPath, const QString &errorName);
void mountError(Partition::Error error);
void unmountError(Partition::Error error);
void formatError(Partition::Error error);
private:
static PartitionManagerPrivate *sharedInstance;
......
......@@ -32,6 +32,12 @@
#include "partitionmodel.h"
#include "partitionmanager_p.h"
#include "udisks2monitor_p.h"
#include "logging_p.h"
#include <QDir>
#include <QFileInfo>
PartitionModel::PartitionModel(QObject *parent)
: QAbstractListModel(parent)
, m_manager(PartitionManagerPrivate::instance())
......@@ -42,6 +48,18 @@ PartitionModel::PartitionModel(QObject *parent)
connect(m_manager.data(), &PartitionManagerPrivate::partitionChanged, this, &PartitionModel::partitionChanged);
connect(m_manager.data(), &PartitionManagerPrivate::partitionAdded, this, &PartitionModel::partitionAdded);
connect(m_manager.data(), &PartitionManagerPrivate::partitionRemoved, this, &PartitionModel::partitionRemoved);
connect(m_manager.data(), &PartitionManagerPrivate::errorMessage, this, &PartitionModel::errorMessage);
connect(m_manager.data(), &PartitionManagerPrivate::mountError, this, [this](Partition::Error error) {
emit mountError(static_cast<PartitionModel::Error>(error));
});
connect(m_manager.data(), &PartitionManagerPrivate::unmountError, this, [this](Partition::Error error) {
emit unmountError(static_cast<PartitionModel::Error>(error));
});
connect(m_manager.data(), &PartitionManagerPrivate::formatError, this, [this](Partition::Error error) {
emit formatError(static_cast<PartitionModel::Error>(error));
});
}
PartitionModel::~PartitionModel()
......@@ -64,6 +82,24 @@ void PartitionModel::setStorageTypes(StorageTypes types)
}
}
QStringList PartitionModel::supportedFormatTypes() const
{
QStringList types;
QDir dir("/sbin/");
QStringList entries = dir.entryList(QStringList() << QString("mkfs.*"));
for (const QString &entry : entries) {
QFileInfo info(QString("/sbin/%1").arg(entry));
if (info.exists() && info.isExecutable()) {
QStringList parts = entry.split('.');
if (!parts.isEmpty()) {
types << parts.takeLast();
}
}
}
return types;
}
void PartitionModel::refresh()
{
m_manager->refresh();
......@@ -76,6 +112,42 @@ void PartitionModel::refresh(int index)
}
}
void PartitionModel::mount(const QString &deviceName)
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << deviceName << m_partitions.count();
for (const Partition &partition : m_partitions) {
if (deviceName == partition.deviceName()) {
m_manager->mount(partition);
break;
}
}
}
void PartitionModel::unmount(const QString &deviceName)
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << deviceName << m_partitions.count();
for (const Partition &partition : m_partitions) {
if (deviceName == partition.deviceName()) {
m_manager->unmount(partition);
break;
}
}
}
void PartitionModel::format(const QString &deviceName, const QString &type, const QString &label)
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << deviceName << type << label << m_partitions.count();
for (const Partition &partition : m_partitions) {
if (deviceName == partition.deviceName()) {
m_manager->format(partition, type, label);
break;
}
}
}
void PartitionModel::update()
{
const int count = m_partitions.count();
......@@ -127,6 +199,7 @@ QHash<int, QByteArray> PartitionModel::roleNames() const
{ MountFailedRole, "mountFailed" },
{ StorageTypeRole, "storageType" },
{ FilesystemTypeRole, "filesystemType" },
{ DeviceLabelRole, "deviceLabel" },
{ DevicePathRole, "devicePath" },
{ DeviceNameRole, "deviceName" },
{ MountPathRole, "mountPath" },
......@@ -164,6 +237,8 @@ QVariant PartitionModel::data(const QModelIndex &index, int role) const
return partition.storageType();
case FilesystemTypeRole:
return partition.filesystemType();
case DeviceLabelRole:
return partition.deviceLabel();
case DevicePathRole:
return partition.devicePath();
case DeviceNameRole:
......@@ -187,6 +262,7 @@ QVariant PartitionModel::data(const QModelIndex &index, int role) const
void PartitionModel::partitionChanged(const Partition &partition)
{
for (int i = 0; i < m_partitions.count(); ++i) {
qCInfo(lcMemoryCardLog) << "partition changed:" << partition.status() << partition.mountPath();;
if (m_partitions.at(i) == partition) {
QModelIndex index = createIndex(i, 0);
emit dataChanged(index, index);
......
......@@ -44,6 +44,8 @@ class SYSTEMSETTINGS_EXPORT PartitionModel : public QAbstractListModel
Q_FLAGS(StorageTypes)
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
Q_PROPERTY(StorageTypes storageTypes READ storageTypes WRITE setStorageTypes NOTIFY storageTypesChanged)
Q_PROPERTY(QStringList supportedFormatTypes READ supportedFormatTypes CONSTANT)
public:
enum {
ReadOnlyRole,
......@@ -52,6 +54,7 @@ public:
MountFailedRole,
StorageTypeRole,
FilesystemTypeRole,
DeviceLabelRole,
DevicePathRole,
DeviceNameRole,
MountPathRole,
......@@ -61,11 +64,14 @@ public:
PartitionModelRole
};
// For Status role
enum Status {
Unmounted = Partition::Unmounted,
Mounting = Partition::Mounting,
Mounted = Partition::Mounted,
Unmounting = Partition::Unmounting
Unmounting = Partition::Unmounting,
Formatting = Partition::Formatting,
Formatted = Partition::Formatted
};
enum StorageType {
......@@ -75,12 +81,31 @@ public:
Mass = Partition::Mass,
External = Partition::External,
ExcludeParents = Partition::ExcludeParents,
ExcludeParents = Partition::ExcludeParents,
Internal = Partition::Internal,
Any = Partition::Any
};
enum Error {
ErrorFailed = Partition::ErrorFailed,
ErrorCancelled = Partition::ErrorCancelled,
ErrorAlreadyCancelled = Partition::ErrorAlreadyCancelled,
ErrorNotAuthorized = Partition::ErrorNotAuthorized,
ErrorNotAuthorizedCanObtain = Partition::ErrorNotAuthorizedCanObtain,
ErrorNotAuthorizedDismissed = Partition::ErrorNotAuthorizedDismissed,
ErrorAlreadyMounted = Partition::ErrorAlreadyMounted,
ErrorNotMounted = Partition::ErrorNotMounted,
ErrorOptionNotPermitted = Partition::ErrorOptionNotPermitted,
ErrorMountedByOtherUser = Partition::ErrorMountedByOtherUser,
ErrorAlreadyUnmounting = Partition::ErrorAlreadyUnmounting,
ErrorNotSupported = Partition::ErrorNotSupported,
ErrorTimedout = Partition::ErrorTimedout,
ErrorWouldWakeup = Partition::ErrorWouldWakeup,
ErrorDeviceBusy = Partition::ErrorDeviceBusy
};
Q_ENUM(Error)
Q_DECLARE_FLAGS(StorageTypes, StorageType)
explicit PartitionModel(QObject *parent = 0);
......@@ -89,9 +114,15 @@ public:
StorageTypes storageTypes() const;
void setStorageTypes(StorageTypes storageTypes);
QStringList supportedFormatTypes() const;
Q_INVOKABLE void refresh();
Q_INVOKABLE void refresh(int index);
Q_INVOKABLE void mount(const QString &deviceName);
Q_INVOKABLE void unmount(const QString &deviceName);
Q_INVOKABLE void format(const QString &deviceName, const QString &type, const QString &label);
QHash<int, QByteArray> roleNames() const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
......@@ -101,6 +132,11 @@ signals:
void countChanged();
void storageTypesChanged();
void errorMessage(const QString &objectPath, const QString &errorName);
void mountError(Error error);
void unmountError(Error error);
void formatError(Error error);
private:
void update();
......@@ -108,7 +144,6 @@ private:
void partitionAdded(const Partition &partition);
void partitionRemoved(const Partition &partition);
QExplicitlySharedDataPointer<PartitionManagerPrivate> m_manager;
QVector<Partition> m_partitions;
StorageTypes m_storageTypes;
......
......@@ -38,6 +38,7 @@ SOURCES += \
deviceinfo.cpp \
locationsettings.cpp \
timezoneinfo.cpp \
udisks2block.cpp \
udisks2job.cpp \
udisks2monitor.cpp
......@@ -69,11 +70,13 @@ HEADERS += \
$$PUBLIC_HEADERS \
qdbusxml2cpp_dbus_types.h \
batterystatus_p.h \
logging_p.h \
diskusage_p.h \
locationsettings_p.h \
logging_p.h \
partition_p.h \
partitionmanager_p.h \
udisks2block_p.h \
udisks2defines.h \
udisks2job_p.h \
udisks2monitor_p.h
......
#include "udisks2block_p.h"
#include "udisks2defines.h"
#include "logging_p.h"
#include <nemo-dbus/dbus.h>
#include <QDBusInterface>
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
UDisks2::Block::Block(const QString &path, const QVariantMap &data, QObject *parent)
: QObject(parent)
, m_path(path)
, m_data(data)
, m_connection(QDBusConnection::systemBus())
{
if (!m_connection.connect(
UDISKS2_SERVICE,
m_path,
DBUS_OBJECT_PROPERTIES_INTERFACE,
QStringLiteral("PropertiesChanged"),
this,
SLOT(updateProperties(QDBusMessage)))) {
qCWarning(lcMemoryCardLog) << "Failed to connect to Block properties change interface" << m_path << m_connection.lastError().message();
}
QDBusInterface dbusPropertyInterface(UDISKS2_SERVICE,
m_path,
DBUS_OBJECT_PROPERTIES_INTERFACE,
m_connection);
QDBusPendingCall pendingCall = dbusPropertyInterface.asyncCall(DBUS_GET_ALL, UDISKS2_FILESYSTEM_INTERFACE);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, path](QDBusPendingCallWatcher *watcher) {
if (watcher->isValid() && watcher->isFinished()) {
QDBusPendingReply<> reply = *watcher;
QDBusMessage message = reply.reply();
updateMountPoint(message.arguments().at(0));
} else {
QDBusError error = watcher->error();
qCWarning(lcMemoryCardLog) << "Error reading filesystem properties:" << error.name() << error.message();
}
watcher->deleteLater();
});
if (data.isEmpty()) {
pendingCall = dbusPropertyInterface.asyncCall(DBUS_GET_ALL, UDISKS2_BLOCK_INTERFACE);
watcher = new QDBusPendingCallWatcher(pendingCall, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, path](QDBusPendingCallWatcher *watcher) {
if (watcher->isValid() && watcher->isFinished()) {
QDBusPendingReply<> reply = *watcher;
QDBusMessage message = reply.reply();
QVariantMap blockProperties = NemoDBus::demarshallArgument<QVariantMap>(message.arguments().at(0));
qCInfo(lcMemoryCardLog) << "Block properties:" << blockProperties;
m_data = blockProperties;
emit blockUpdated();
} else {
QDBusError error = watcher->error();
qCWarning(lcMemoryCardLog) << "Error reading block properties:" << error.name() << error.message();
}
watcher->deleteLater();
});
}
}
UDisks2::Block::~Block()
{
}
QString UDisks2::Block::path() const
{
return m_path;
}
QString UDisks2::Block::device() const
{
QByteArray d = m_data.value(QStringLiteral("Device")).toByteArray();
return QString::fromLocal8Bit(d);
}
QString UDisks2::Block::preferredDevice() const
{
QByteArray d = m_data.value(QStringLiteral("PreferredDevice")).toByteArray();
return QString::fromLocal8Bit(d);
}
QString UDisks2::Block::drive() const
{
return value(QStringLiteral("Drive")).toString();
}
qint64 UDisks2::Block::deviceNumber() const
{
return value(QStringLiteral("DeviceNumber")).toLongLong();
}
QString UDisks2::Block::id() const
{
return value(QStringLiteral("Id")).toString();
}
qint64 UDisks2::Block::size() const
{
return value(QStringLiteral("Size")).toLongLong();
}
bool UDisks2::Block::isReadOnly() const
{
return value(QStringLiteral("ReadOnly")).toBool();
}
QString UDisks2::Block::idType() const
{
return value(QStringLiteral("IdType")).toString();
}
QString UDisks2::Block::idVersion() const
{
return value(QStringLiteral("IdVersion")).toString();
}
QString UDisks2::Block::idLabel() const
{
return value(QStringLiteral("IdLabel")).toString();
}
QString UDisks2::Block::idUUID() const
{
return value(QStringLiteral("IdUUID")).toString();
}
QString UDisks2::Block::mountPath() const
{
return m_mountPath;
}
QVariant UDisks2::Block::value(const QString &key) const
{
return NemoDBus::demarshallDBusArgument(m_data.value(key));
}
bool UDisks2::Block::hasData() const
{
return !m_data.isEmpty();
}
void UDisks2::Block::updateProperties(const QDBusMessage &message)
{
QList<QVariant> arguments = message.arguments();
QString interface = arguments.value(0).toString();
if (interface == UDISKS2_BLOCK_INTERFACE) {
QVariantMap changedProperties = NemoDBus::demarshallArgument<QVariantMap>(arguments.value(1));
qCInfo(lcMemoryCardLog) << "Changed properties:" << changedProperties;
for (QMap<QString, QVariant>::const_iterator i = changedProperties.begin(); i != changedProperties.end(); ++i) {
m_data.insert(i.key(), i.value());
}
emit blockUpdated();
} else if (interface == UDISKS2_FILESYSTEM_INTERFACE) {
updateMountPoint(arguments.value(1));
}
}
void UDisks2::Block::updateMountPoint(const QVariant &mountPoints)
{
QVariantMap mountPointsMap = NemoDBus::demarshallArgument<QVariantMap>(mountPoints);
QList<QByteArray> mountPointList = NemoDBus::demarshallArgument<QList<QByteArray> >(mountPointsMap.value(QStringLiteral("MountPoints")));
m_mountPath.clear();
for (const QByteArray &bytes : mountPointList) {
if (bytes.startsWith("/run")) {
m_mountPath = QString::fromLocal8Bit(bytes);
break;
}
}
qCInfo(lcMemoryCardLog) << "New file system mount points:" << mountPoints << "resolved mount path: " << m_mountPath;
emit mountPathChanged();
}
/*
* Copyright (C) 2018 Jolla Ltd. <raine.makelainen@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.