Commit e091ed13 authored by Raine Makelainen's avatar Raine Makelainen

Merge branch 'jb42963' into 'master'

Stay in formatting state until filesystem/encrypted interface appear

See merge request mer-core/nemo-qml-plugin-systemsettings!82
parents ec94f5bf 035ce6b7
......@@ -317,12 +317,12 @@ void PartitionManagerPrivate::unmount(const Partition &partition)
}
}
void PartitionManagerPrivate::format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase)
void PartitionManagerPrivate::format(const QString &devicePath, const QString &filesystemType, const QVariantMap &arguments)
{
QString deviceName = devicePath.section(QChar('/'), 2);
qCInfo(lcMemoryCardLog) << "Can format:" << externalMedia.match(deviceName).hasMatch() << devicePath;
if (externalMedia.match(deviceName).hasMatch()) {
m_udisksMonitor->instance()->format(devicePath, type, label, passphrase);
m_udisksMonitor->instance()->format(devicePath, filesystemType, arguments);
} else {
qCWarning(lcMemoryCardLog) << "Formatting allowed only for external memory cards," << devicePath << "is not allowed";
}
......
......@@ -70,7 +70,7 @@ public:
void unlock(const Partition &partition, const QString &passphrase);
void mount(const Partition &partition);
void unmount(const Partition &partition);
void format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase);
void format(const QString &devicePath, const QString &filesystemType, const QVariantMap &arguments);
QString objectPath(const QString &devicePath) const;
......
......@@ -37,6 +37,7 @@
#include <QDir>
#include <QFileInfo>
#include <QtQml/qqmlinfo.h>
PartitionModel::PartitionModel(QObject *parent)
: QAbstractListModel(parent)
......@@ -155,10 +156,29 @@ void PartitionModel::unmount(const QString &devicePath)
}
}
void PartitionModel::format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase)
void PartitionModel::format(const QString &devicePath, const QVariantMap &arguments)
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << devicePath << type << label << m_partitions.count();
m_manager->format(devicePath, type, label, passphrase);
QString filesystemType = arguments.value(QLatin1String("filesystemType"), QString()).toString();
if (filesystemType.isEmpty()) {
qmlInfo(this) << "Missing or empty filesystemType argument, cannot format.";
return;
}
// Only fixing invalid args would be enough. Udisks don't care if key is unknown like auto-mount.
QVariantMap args;
args.insert(QLatin1String("label"), arguments.value(QLatin1String("label"), QString()).toString());
args.insert(QLatin1String("no-block"), true);
args.insert(QLatin1String("take-ownership"), true);
args.insert(QLatin1String("update-partition-type"), true);
args.insert(QLatin1String("auto-mount"), arguments.value(QLatin1String("auto-mount"), false).toBool());
QString passphrase = arguments.value(QLatin1String("encrypt-passphrase"), QString()).toString();
if (!passphrase.isEmpty()) {
args.insert(QLatin1String("encrypt.passphrase"), passphrase);
}
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << devicePath << filesystemType << args << m_partitions.count();
m_manager->format(devicePath, filesystemType, args);
}
QString PartitionModel::objectPath(const QString &devicePath) const
......
......@@ -131,7 +131,7 @@ public:
Q_INVOKABLE void unlock(const QString &devicePath, const QString &passphrase);
Q_INVOKABLE void mount(const QString &devicePath);
Q_INVOKABLE void unmount(const QString &devicePath);
Q_INVOKABLE void format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase = QString());
Q_INVOKABLE void format(const QString &devicePath, const QVariantMap &arguments);
Q_INVOKABLE QString objectPath(const QString &devicePath) const;
......
......@@ -67,6 +67,10 @@ UDisks2::Block::Block(const QString &path, const UDisks2::InterfacePropertyMap &
// We have either org.freedesktop.UDisks2.Filesystem or org.freedesktop.UDisks2.Encrypted interface.
complete();
}
connect(this, &Block::completed, this, [this]() {
clearFormattingState();
});
}
// Use when morphing a block e.g. updating encrypted block to crypto backing block device (e.i. to a block that implements file system).
......@@ -102,6 +106,8 @@ UDisks2::Block &UDisks2::Block::operator=(const UDisks2::Block &other)
m_mountable = other.m_mountable;
m_mountPath = other.m_mountPath;
m_encrypted = other.m_encrypted;
m_formatting = other.m_formatting;
m_locking = other.m_locking;
return *this;
}
......@@ -169,16 +175,14 @@ bool UDisks2::Block::isEncrypted() const
return m_encrypted;
}
void UDisks2::Block::setEncrypted(bool encrypted)
bool UDisks2::Block::setEncrypted(bool encrypted)
{
if (m_encrypted != encrypted) {
m_encrypted = encrypted;
blockSignals(true);
setMountable(!m_encrypted);
blockSignals(false);
emit updated();
return true;
}
return false;
}
bool UDisks2::Block::isMountable() const
......@@ -186,23 +190,29 @@ bool UDisks2::Block::isMountable() const
return m_mountable;
}
void UDisks2::Block::setMountable(bool mountable)
bool UDisks2::Block::setMountable(bool mountable)
{
if (m_mountable != mountable) {
m_mountable = mountable;
if (m_mountable && m_formatting) {
m_formatting = false;
emit formatted();
}
emit updated();
return true;
}
return false;
}
bool UDisks2::Block::isFormatting() const
{
return m_formatting;
}
void UDisks2::Block::setFormatting()
bool UDisks2::Block::setFormatting(bool formatting)
{
m_formatting = true;
if (m_formatting != formatting) {
m_formatting = formatting;
emit updated();
return true;
}
return false;
}
bool UDisks2::Block::isLocking() const
......@@ -289,17 +299,23 @@ void UDisks2::Block::updateProperties(const QDBusMessage &message)
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) {
for (QMap<QString, QVariant>::const_iterator i = changedProperties.constBegin(); i != changedProperties.constEnd(); ++i) {
m_data.insert(i.key(), i.value());
}
emit updated();
if (!clearFormattingState()) {
emit updated();
}
} else if (interface == UDISKS2_FILESYSTEM_INTERFACE) {
m_mountable = true;
updateMountPoint(arguments.value(1));
}
}
bool UDisks2::Block::isCompleted() const
{
return !m_pendingFileSystem && !m_pendingBlock && !m_pendingEncrypted;
}
void UDisks2::Block::updateMountPoint(const QVariant &mountPoints)
{
QVariantMap mountPointsMap = NemoDBus::demarshallArgument<QVariantMap>(mountPoints);
......@@ -313,17 +329,35 @@ void UDisks2::Block::updateMountPoint(const QVariant &mountPoints)
}
}
qCInfo(lcMemoryCardLog) << "New file system mount points:" << mountPoints << "resolved mount path: " << m_mountPath;
bool triggerUpdate = false;
blockSignals(true);
triggerUpdate = setMountable(true);
triggerUpdate |= clearFormattingState();
blockSignals(false);
if (triggerUpdate) {
emit updated();
}
qCInfo(lcMemoryCardLog) << "New file system mount points:" << mountPoints << "resolved mount path: " << m_mountPath << "trigger update:" << triggerUpdate;
emit mountPathChanged();
}
void UDisks2::Block::complete()
{
if (!m_pendingFileSystem && !m_pendingBlock && !m_pendingEncrypted) {
if (isCompleted()) {
QMetaObject::invokeMethod(this, "completed", Qt::QueuedConnection);
}
}
bool UDisks2::Block::clearFormattingState()
{
if (isCompleted() && isMountable() && isFormatting()) {
return setFormatting(false);
}
return false;
}
void UDisks2::Block::getFileSystemInterface()
{
QDBusInterface dbusPropertyInterface(UDISKS2_SERVICE,
......@@ -336,7 +370,6 @@ void UDisks2::Block::getFileSystemInterface()
if (watcher->isValid() && watcher->isFinished()) {
QDBusPendingReply<> reply = *watcher;
QDBusMessage message = reply.reply();
m_mountable = true;
updateMountPoint(message.arguments().at(0));
} else {
QDBusError error = watcher->error();
......@@ -359,8 +392,6 @@ void UDisks2::Block::getEncryptedInterface()
m_pendingEncrypted = new QDBusPendingCallWatcher(pendingCall, this);
connect(m_pendingEncrypted, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) {
if (watcher->isValid() && watcher->isFinished()) {
QDBusPendingReply<> reply = *watcher;
QDBusMessage message = reply.reply();
m_encrypted = true;
} else {
QDBusError error = watcher->error();
......
......@@ -68,13 +68,13 @@ public:
QString cryptoBackingDeviceObjectPath() const;
bool isEncrypted() const;
void setEncrypted(bool encrypted);
bool setEncrypted(bool encrypted);
bool isMountable() const;
void setMountable(bool mountable);
bool setMountable(bool mountable);
bool isFormatting() const;
void setFormatting();
bool setFormatting(bool formatting);
bool isLocking() const;
void setLocking();
......@@ -107,8 +107,11 @@ private slots:
void updateProperties(const QDBusMessage &message);
private:
bool isCompleted() const;
void updateMountPoint(const QVariant &mountPoints);
void complete();
bool clearFormattingState();
void getFileSystemInterface();
void getEncryptedInterface();
......
......@@ -138,21 +138,19 @@ void UDisks2::Monitor::lock(const QString &devicePath)
QVariantMap options;
arguments << options;
for (QMap<QString, Block *>::const_iterator i = m_blockDevices.begin(); i != m_blockDevices.end(); ++i) {
Block *block = i.value();
if (block->device() == devicePath || block->cryptoBackingDevicePath() == devicePath) {
block->dumpInfo();
block->setLocking();
// Unmount if mounted.
if (!block->mountPath().isEmpty()) {
m_operationQueue.enqueue(Operation(UDISKS2_ENCRYPTED_LOCK, devicePath));
unmount(block->device());
} else {
startLuksOperation(devicePath, UDISKS2_ENCRYPTED_LOCK, objectPath(devicePath), arguments);
}
break;
if (Block *block = findBlock(devicePath)) {
block->dumpInfo();
block->setLocking();
// Unmount if mounted.
if (!block->mountPath().isEmpty()) {
m_operationQueue.enqueue(Operation(UDISKS2_ENCRYPTED_LOCK, devicePath));
unmount(block->device());
} else {
startLuksOperation(devicePath, UDISKS2_ENCRYPTED_LOCK, objectPath(devicePath), arguments);
}
} else {
qCWarning(lcMemoryCardLog) << "Block device" << devicePath << "not found";
}
}
......@@ -182,7 +180,7 @@ void UDisks2::Monitor::unmount(const QString &devicePath)
startMountOperation(devicePath, UDISKS2_FILESYSTEM_UNMOUNT, objectPath(devicePath), arguments);
}
void UDisks2::Monitor::format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase)
void UDisks2::Monitor::format(const QString &devicePath, const QString &filesystemType, const QVariantMap &arguments)
{
if (devicePath.isEmpty()) {
qCCritical(lcMemoryCardLog) << "Cannot format without device name";
......@@ -190,33 +188,34 @@ void UDisks2::Monitor::format(const QString &devicePath, const QString &type, co
}
QStringList fsList = m_manager->supportedFileSystems();
if (!fsList.contains(type)) {
if (!fsList.contains(filesystemType)) {
qCWarning(lcMemoryCardLog) << "Can only format" << fsList.join(", ") << "filesystems.";
return;
}
QVariantHash arguments;
arguments.insert(QStringLiteral("label"), QString(label));
arguments.insert(QStringLiteral("no-block"), true);
arguments.insert(QStringLiteral("take-ownership"), true);
arguments.insert(QStringLiteral("update-partition-type"), true);
if (!passphrase.isEmpty()) {
arguments.insert(QStringLiteral("encrypt.passphrase"), passphrase);
}
const QString objectPath = this->objectPath(devicePath);
PartitionManagerPrivate::Partitions affectedPartitions;
lookupPartitions(affectedPartitions, QStringList() << objectPath);
for (auto partition : affectedPartitions) {
if (partition->status == Partition::Mounted) {
m_operationQueue.enqueue(Operation(UDISKS2_BLOCK_FORMAT, devicePath, objectPath, type, arguments));
// Mark block to formatting state.
if (Block *block = findBlock(devicePath)) {
block->setFormatting(true);
}
// Lock unlocked block device before formatting.
if (!partition->cryptoBackingDevicePath.isEmpty()) {
lock(partition->cryptoBackingDevicePath);
m_operationQueue.enqueue(Operation(UDISKS2_BLOCK_FORMAT, partition->cryptoBackingDevicePath, objectPath, filesystemType, arguments));
return;
} else if (partition->status == Partition::Mounted) {
m_operationQueue.enqueue(Operation(UDISKS2_BLOCK_FORMAT, devicePath, objectPath, filesystemType, arguments));
unmount(devicePath);
return;
}
}
doFormat(devicePath, objectPath, type, arguments);
doFormat(devicePath, objectPath, filesystemType, arguments);
}
void UDisks2::Monitor::interfacesAdded(const QDBusObjectPath &objectPath, const UDisks2::InterfacePropertyMap &interfaces)
......@@ -229,12 +228,13 @@ void UDisks2::Monitor::interfacesAdded(const QDBusObjectPath &objectPath, const
if ((interfaces.contains(UDISKS2_FILESYSTEM_INTERFACE) ||
interfaces.contains(UDISKS2_ENCRYPTED_INTERFACE)) && externalBlockDevice(path)) {
bool hasFileSystem = interfaces.contains(UDISKS2_FILESYSTEM_INTERFACE);
if (m_blockDevices.contains(path)) {
UDisks2::Block *block = m_blockDevices.value(path);
if (hasFileSystem) {
if (interfaces.contains(UDISKS2_FILESYSTEM_INTERFACE)) {
block->setMountable(true);
} else {
}
if (interfaces.contains(UDISKS2_ENCRYPTED_INTERFACE)) {
block->setEncrypted(true);
}
} else {
......@@ -284,14 +284,23 @@ void UDisks2::Monitor::interfacesRemoved(const QDBusObjectPath &objectPath, cons
// Crypto device got removed
bool deviceMapped = path.startsWith(QStringLiteral("/org/freedesktop/UDisks2/block_devices/dm_"));
if (deviceMapped && block->isLocking()) {
createBlockDevice(block->cryptoBackingDeviceObjectPath(), UDisks2::InterfacePropertyMap());
if (deviceMapped && (block->isLocking() || block->isFormatting())) {
UDisks2::Block *newBlock = createBlockDevice(block->cryptoBackingDeviceObjectPath(), UDisks2::InterfacePropertyMap());
if (newBlock && block->isFormatting()) {
newBlock->setFormatting(true);
}
}
block->deleteLater();
} else if (m_blockDevices.contains(path) && interfaces.contains(UDISKS2_FILESYSTEM_INTERFACE)) {
} else if (m_blockDevices.contains(path)) {
UDisks2::Block *block = m_blockDevices.value(path);
block->setMountable(false);
if (interfaces.contains(UDISKS2_FILESYSTEM_INTERFACE)) {
block->setMountable(false);
}
if (interfaces.contains(UDISKS2_ENCRYPTED_INTERFACE)) {
block->setEncrypted(false);
}
}
}
......@@ -316,8 +325,16 @@ void UDisks2::Monitor::setPartitionProperties(QExplicitlySharedDataPointer<Parti
partition->isSupportedFileSystemType = m_manager->supportedFileSystems().contains(partition->filesystemType);
partition->readOnly = blockDevice->isReadOnly();
partition->canMount = blockDevice->isMountable() && m_manager->supportedFileSystems().contains(partition->filesystemType);
partition->status = blockDevice->isEncrypted() ? Partition::Locked
: blockDevice->mountPath().isEmpty() ? Partition::Unmounted : Partition::Mounted;
if (blockDevice->isFormatting()) {
partition->status = Partition::Formatting;
} else if (blockDevice->isEncrypted()) {
partition->status = Partition::Locked;
} else if (blockDevice->mountPath().isEmpty()) {
partition->status = Partition::Unmounted;
} else {
partition->status = Partition::Mounted;
}
partition->isCryptoDevice = blockDevice->isEncrypted() || blockDevice->hasCryptoBackingDevice();
partition->isEncrypted = blockDevice->isEncrypted();
partition->cryptoBackingDevicePath = blockDevice->cryptoBackingDevicePath();
......@@ -402,12 +419,6 @@ void UDisks2::Monitor::updatePartitionStatus(const UDisks2::Job *job, bool succe
partition->filesystemType.clear();
partition->canMount = false;
partition->valid = false;
QString blockDevicePath = UDISKS2_BLOCK_DEVICE_PATH.arg(partition->deviceName);
if (m_blockDevices.contains(blockDevicePath)) {
Block *block = m_blockDevices.value(blockDevicePath);
block->setFormatting();
}
}
} else {
partition->activeState = QStringLiteral("failed");
......@@ -510,7 +521,10 @@ void UDisks2::Monitor::startMountOperation(const QString &devicePath, const QStr
connect(watcher, &QDBusPendingCallWatcher::finished,
this, [this, devicePath, dbusMethod](QDBusPendingCallWatcher *watcher) {
if (watcher->isValid() && watcher->isFinished()) {
if (dbusMethod == UDISKS2_FILESYSTEM_MOUNT) {
Block *block = findBlock(devicePath);
if (block && block->isFormatting()) {
// Do nothing
} else if (dbusMethod == UDISKS2_FILESYSTEM_MOUNT) {
emit status(devicePath, Partition::Mounted);
} else {
emit status(devicePath, Partition::Unmounted);
......@@ -550,7 +564,10 @@ void UDisks2::Monitor::startMountOperation(const QString &devicePath, const QStr
watcher->deleteLater();
});
if (dbusMethod == UDISKS2_FILESYSTEM_MOUNT) {
Block *block = findBlock(devicePath);
if (block && block->isFormatting()) {
emit status(devicePath, Partition::Formatting);
} else if (dbusMethod == UDISKS2_FILESYSTEM_MOUNT) {
emit status(devicePath, Partition::Mounting);
} else {
emit status(devicePath, Partition::Unmounting);
......@@ -560,10 +577,10 @@ void UDisks2::Monitor::startMountOperation(const QString &devicePath, const QStr
void UDisks2::Monitor::lookupPartitions(PartitionManagerPrivate::Partitions &affectedPartitions, const QStringList &objects)
{
QStringList blockDevs;
for (const QString objectPath : objects) {
for (QMap<QString, Block *>::const_iterator i = m_blockDevices.begin(); i != m_blockDevices.end(); ++i) {
for (const QString &objectPath : objects) {
for (QMap<QString, Block *>::const_iterator i = m_blockDevices.constBegin(); i != m_blockDevices.constEnd(); ++i) {
Block *block = i.value();
if (block->path() == objectPath) {
if (block->path() == objectPath || block->cryptoBackingDeviceObjectPath() == objectPath) {
blockDevs << block->device();
}
}
......@@ -590,10 +607,10 @@ void UDisks2::Monitor::createPartition(const UDisks2::Block *block)
m_manager->add(addedPartitions);
}
void UDisks2::Monitor::createBlockDevice(const QString &dbusObjectPath, const UDisks2::InterfacePropertyMap &interfacePropertyMap)
UDisks2::Block *UDisks2::Monitor::createBlockDevice(const QString &dbusObjectPath, const UDisks2::InterfacePropertyMap &interfacePropertyMap)
{
if (m_blockDevices.contains(dbusObjectPath)) {
return;
return m_blockDevices.value(dbusObjectPath, nullptr);
}
// First guards that we don't create extensively block devices that cannot be
......@@ -632,6 +649,20 @@ void UDisks2::Monitor::createBlockDevice(const QString &dbusObjectPath, const UD
} else if (!m_blockDevices.contains(completedBlock->path())) {
m_blockDevices.insert(completedBlock->path(), completedBlock);
createPartition(completedBlock);
if (completedBlock->isFormatting()) {
if (!m_operationQueue.isEmpty()) {
Operation op = m_operationQueue.head();
if (op.command == UDISKS2_BLOCK_FORMAT) {
m_operationQueue.dequeue();
QMetaObject::invokeMethod(this, "doFormat", Qt::QueuedConnection,
Q_ARG(QString, op.devicePath), Q_ARG(QString, op.dbusObjectPath),
Q_ARG(QString, op.filesystemType), Q_ARG(QVariantMap, op.arguments));
}
} else {
qCDebug(lcMemoryCardLog) << "Formatting cannot be executed. Is block mounted:" << !completedBlock->mountPath().isEmpty();
}
}
}
} else {
// This is garbage block device that should not be exposed
......@@ -685,34 +716,40 @@ void UDisks2::Monitor::createBlockDevice(const QString &dbusObjectPath, const UD
Operation op = m_operationQueue.head();
if (op.command == UDISKS2_BLOCK_FORMAT && block->mountPath().isEmpty()) {
m_operationQueue.dequeue();
doFormat(op.devicePath, op.dbusObjectPath, op.type, op.arguments);
doFormat(op.devicePath, op.dbusObjectPath, op.filesystemType, op.arguments);
} else if (op.command == UDISKS2_ENCRYPTED_LOCK && block->mountPath().isEmpty()) {
m_operationQueue.dequeue();
lock(op.devicePath);
}
}
});
return block;
}
return nullptr;
}
void UDisks2::Monitor::doFormat(const QString &devicePath, const QString &dbusObjectPath, const QString &type, const QVariantHash &arguments)
void UDisks2::Monitor::doFormat(const QString &devicePath, const QString &dbusObjectPath, const QString &filesystemType, const QVariantMap &arguments)
{
QDBusInterface blockDeviceInterface(UDISKS2_SERVICE,
dbusObjectPath,
UDISKS2_BLOCK_INTERFACE,
QDBusConnection::systemBus());
QDBusPendingCall pendingCall = blockDeviceInterface.asyncCall(UDISKS2_BLOCK_FORMAT, type, arguments);
QDBusPendingCall pendingCall = blockDeviceInterface.asyncCall(UDISKS2_BLOCK_FORMAT, filesystemType, arguments);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
connect(watcher, &QDBusPendingCallWatcher::finished,
this, [this, devicePath, arguments](QDBusPendingCallWatcher *watcher) {
this, [this, devicePath, dbusObjectPath, arguments](QDBusPendingCallWatcher *watcher) {
if (watcher->isValid() && watcher->isFinished()) {
emit status(devicePath, Partition::Formatted);
} else if (watcher->isError()) {
Block *block = findBlock(devicePath);
if (block) {
block->setFormatting(false);
}
QDBusError error = watcher->error();
QByteArray errorData = error.name().toLocal8Bit();
const char *errorCStr = errorData.constData();
qCWarning(lcMemoryCardLog) << "Format error:" << errorCStr;
qCWarning(lcMemoryCardLog) << "Format error:" << errorCStr << dbusObjectPath;
for (uint i = 0; i < sizeof(dbus_error_entries) / sizeof(ErrorEntry); i++) {
if (strcmp(dbus_error_entries[i].dbusErrorName, errorCStr) == 0) {
......@@ -752,6 +789,18 @@ void UDisks2::Monitor::getBlockDevices()
});
}
UDisks2::Block *UDisks2::Monitor::findBlock(const QString &devicePath) const
{
for (QMap<QString, Block *>::const_iterator i = m_blockDevices.constBegin(); i != m_blockDevices.constEnd(); ++i) {
Block *block = i.value();
if (block->device() == devicePath || block->cryptoBackingDevicePath() == devicePath) {
return block;
}
}
return nullptr;
}
QString UDisks2::Monitor::objectPath(const QString &devicePath) const
{
for (QMap<QString, Block *>::const_iterator i = m_blockDevices.begin(); i != m_blockDevices.end(); ++i) {
......
......@@ -54,19 +54,19 @@ class Job;
struct Operation
{
Operation(const QString &command, const QString &devicePath, const QString &dbusObjectPath = QString(), const QString &type = QString(), const QVariantHash &arguments = QVariantHash())
Operation(const QString &command, const QString &devicePath, const QString &dbusObjectPath = QString(), const QString &filesystemType = QString(), const QVariantMap &arguments = QVariantMap())
: command(command)
, devicePath(devicePath)
, dbusObjectPath(dbusObjectPath)
, type(type)
, filesystemType(filesystemType)
, arguments(arguments)
{}
QString command;
QString devicePath;
QString dbusObjectPath;
QString type;
QVariantHash arguments;
QString filesystemType;
QVariantMap arguments;
};
class Monitor : public QObject
......@@ -84,7 +84,7 @@ public:
void mount(const QString &devicePath);
void unmount(const QString &devicePath);
void format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase);
void format(const QString &devicePath, const QString &filesystemType, const QVariantMap &arguments);
QString objectPath(const QString &devicePath) const;
......@@ -100,11 +100,12 @@ signals:
private slots:
void interfacesAdded(const QDBusObjectPath &objectPath, const UDisks2::InterfacePropertyMap &interfaces);
void interfacesRemoved(const QDBusObjectPath &objectPath, const QStringList &interfaces);
void doFormat(const QString &devicePath, const QString &dbusObjectPath, const QString &filesystemType, const QVariantMap &arguments);
private:
void setPartitionProperties(QExplicitlySharedDataPointer<PartitionPrivate> &partition, const UDisks2::Block *blockDevice);
void updatePartitionProperties(const UDisks2::Block *blockDevice);
void updatePartitionStatus(const UDisks2::Job *job, bool success);
void setPartitionProperties(QExplicitlySharedDataPointer<PartitionPrivate> &partition, const Block *blockDevice);
void updatePartitionProperties(const Block *blockDevice);
void updatePartitionStatus(const Job *job, bool success);
bool externalBlockDevice(const QString &objectPathStr) const;
void startLuksOperation(const QString &devicePath, const QString &dbusMethod, const QString &dbusObjectPath, const QVariantList &arguments);
......@@ -112,17 +113,18 @@ private:
void lookupPartitions(PartitionManagerPrivate::Partitions &affectedPartitions, const QStringList &objects);
void createPartition(const Block *block);
void createBlockDevice(const QString &dbusObjectPath, const UDisks2::InterfacePropertyMap &interfacePropertyMap);
Block *createBlockDevice(const QString &dbusObjectPath, const UDisks2::InterfacePropertyMap &interfacePropertyMap);
void doFormat(const QString &devicePath, const QString &dbusObjectPath, const QString &type, const QVariantHash &arguments);
void getBlockDevices();
Block *findBlock(const QString &devicePath) const;
private:
static Monitor *sharedInstance;
QExplicitlySharedDataPointer<PartitionManagerPrivate> m_manager;
QMap<QString, UDisks2::Job *> m_jobsToWait;
QMap<QString, UDisks2::Block *> m_blockDevices;
QMap<QString, Job *> m_jobsToWait;
QMap<QString, Block *> m_blockDevices;
QQueue<Operation> m_operationQueue;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment