Commit 1796c15c authored by Raine Makelainen's avatar Raine Makelainen

[partitionmodel] Change lock, unlock, mount, unmount to devicePath based. Contributes to JB#42996

parent 30067332
......@@ -278,9 +278,9 @@ void PartitionManagerPrivate::refresh(const Partitions &partitions, Partitions &
void PartitionManagerPrivate::lock(const Partition &partition)
{
qCInfo(lcMemoryCardLog) << "Can lock:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.deviceName();
qCInfo(lcMemoryCardLog) << "Can lock:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.devicePath();
if (externalMedia.match(partition.deviceName()).hasMatch()) {
m_udisksMonitor->lock(partition.deviceName());
m_udisksMonitor->lock(partition.devicePath());
} else {
qCWarning(lcMemoryCardLog) << "Lock allowed only for external memory cards," << partition.devicePath() << "is not allowed";
}
......@@ -288,9 +288,9 @@ void PartitionManagerPrivate::lock(const Partition &partition)
void PartitionManagerPrivate::unlock(const Partition &partition, const QString &passphrase)
{
qCInfo(lcMemoryCardLog) << "Can unlock:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.deviceName();
qCInfo(lcMemoryCardLog) << "Can unlock:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.devicePath();
if (externalMedia.match(partition.deviceName()).hasMatch()) {
m_udisksMonitor->instance()->unlock(partition.deviceName(), passphrase);
m_udisksMonitor->instance()->unlock(partition.devicePath(), passphrase);
} else {
qCWarning(lcMemoryCardLog) << "Unlock allowed only for external memory cards," << partition.devicePath() << "is not allowed";
}
......@@ -298,9 +298,9 @@ void PartitionManagerPrivate::unlock(const Partition &partition, const QString &
void PartitionManagerPrivate::mount(const Partition &partition)
{
qCInfo(lcMemoryCardLog) << "Can mount:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.deviceName();
qCInfo(lcMemoryCardLog) << "Can mount:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.devicePath();
if (externalMedia.match(partition.deviceName()).hasMatch()) {
m_udisksMonitor->instance()->mount(partition.deviceName());
m_udisksMonitor->instance()->mount(partition.devicePath());
} else {
qCWarning(lcMemoryCardLog) << "Mount allowed only for external memory cards," << partition.devicePath() << "is not allowed";
}
......@@ -308,9 +308,9 @@ void PartitionManagerPrivate::mount(const Partition &partition)
void PartitionManagerPrivate::unmount(const Partition &partition)
{
qCInfo(lcMemoryCardLog) << "Can unmount:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.deviceName();
qCInfo(lcMemoryCardLog) << "Can unmount:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.devicePath();
if (externalMedia.match(partition.deviceName()).hasMatch()) {
m_udisksMonitor->instance()->unmount(partition.deviceName());
m_udisksMonitor->instance()->unmount(partition.devicePath());
} else {
qCWarning(lcMemoryCardLog) << "Unmount allowed only for external memory cards," << partition.devicePath() << "is not allowed";
}
......@@ -318,10 +318,10 @@ void PartitionManagerPrivate::unmount(const Partition &partition)
void PartitionManagerPrivate::format(const Partition &partition, const QString &type, const QString &label, const QString &passphrase)
{
qCInfo(lcMemoryCardLog) << "Can format:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.deviceName();
qCInfo(lcMemoryCardLog) << "Can format:" << externalMedia.match(partition.deviceName()).hasMatch() << partition.devicePath();
if (externalMedia.match(partition.deviceName()).hasMatch()) {
m_udisksMonitor->instance()->format(partition.deviceName(), type, label, passphrase);
m_udisksMonitor->instance()->format(partition.devicePath(), type, label, passphrase);
} else {
qCWarning(lcMemoryCardLog) << "Formatting allowed only for external memory cards," << partition.devicePath() << "is not allowed";
}
......@@ -330,7 +330,7 @@ void PartitionManagerPrivate::format(const Partition &partition, const QString &
QString PartitionManagerPrivate::objectPath(const Partition &partition) const
{
if (externalMedia.match(partition.deviceName()).hasMatch()) {
return m_udisksMonitor->instance()->objectPath(partition.deviceName());
return m_udisksMonitor->instance()->objectPath(partition.devicePath());
} else {
qCWarning(lcMemoryCardLog) << "Object path existing only for external memory cards:" << partition.devicePath();
return QString();
......
......@@ -119,63 +119,63 @@ void PartitionModel::refresh(int index)
}
}
void PartitionModel::lock(const QString &deviceName)
void PartitionModel::lock(const QString &devicePath)
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << deviceName << m_partitions.count();
if (const Partition *partition = getPartition(deviceName)) {
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << devicePath << m_partitions.count();
if (const Partition *partition = getPartition(devicePath)) {
m_manager->lock(*partition);
} else {
qCWarning(lcMemoryCardLog) << "Unable to lock unknown device:" << deviceName;
qCWarning(lcMemoryCardLog) << "Unable to lock unknown device:" << devicePath;
}
}
void PartitionModel::unlock(const QString &deviceName, const QString &passphrase)
void PartitionModel::unlock(const QString &devicePath, const QString &passphrase)
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << deviceName << m_partitions.count();
if (const Partition *partition = getPartition(deviceName)) {
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << devicePath << m_partitions.count();
if (const Partition *partition = getPartition(devicePath)) {
m_manager->unlock(*partition, passphrase);
} else {
qCWarning(lcMemoryCardLog) << "Unable to unlock unknown device:" << deviceName;
qCWarning(lcMemoryCardLog) << "Unable to unlock unknown device:" << devicePath;
}
}
void PartitionModel::mount(const QString &deviceName)
void PartitionModel::mount(const QString &devicePath)
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << deviceName << m_partitions.count();
if (const Partition *partition = getPartition(deviceName)) {
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << devicePath << m_partitions.count();
if (const Partition *partition = getPartition(devicePath)) {
m_manager->mount(*partition);
} else {
qCWarning(lcMemoryCardLog) << "Unable to mount unknown device:" << deviceName;
qCWarning(lcMemoryCardLog) << "Unable to mount unknown device:" << devicePath;
}
}
void PartitionModel::unmount(const QString &deviceName)
void PartitionModel::unmount(const QString &devicePath)
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << deviceName << m_partitions.count();
if (const Partition *partition = getPartition(deviceName)) {
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << devicePath << m_partitions.count();
if (const Partition *partition = getPartition(devicePath)) {
m_manager->unmount(*partition);
} else {
qCWarning(lcMemoryCardLog) << "Unable to unmount unknown device:" << deviceName;
qCWarning(lcMemoryCardLog) << "Unable to unmount unknown device:" << devicePath;
}
}
void PartitionModel::format(const QString &deviceName, const QString &type, const QString &label, const QString &passphrase)
void PartitionModel::format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase)
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << deviceName << type << label << m_partitions.count();
if (const Partition *partition = getPartition(deviceName)) {
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << devicePath << type << label << m_partitions.count();
if (const Partition *partition = getPartition(devicePath)) {
m_manager->format(*partition, type, label, passphrase);
} else {
qCWarning(lcMemoryCardLog) << "Unable to format unknown device:" << deviceName;
qCWarning(lcMemoryCardLog) << "Unable to format unknown device:" << devicePath;
}
}
QString PartitionModel::objectPath(const QString &deviceName) const
QString PartitionModel::objectPath(const QString &devicePath) const
{
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << deviceName;
if (const Partition *partition = getPartition(deviceName)) {
qCInfo(lcMemoryCardLog) << Q_FUNC_INFO << devicePath;
if (const Partition *partition = getPartition(devicePath)) {
return m_manager->objectPath(*partition);
} else {
qCWarning(lcMemoryCardLog) << "Unable to get object path for unknown device:" << deviceName;
qCWarning(lcMemoryCardLog) << "Unable to get object path for unknown device:" << devicePath;
return QString();
}
}
......@@ -222,10 +222,10 @@ void PartitionModel::update()
}
}
const Partition *PartitionModel::getPartition(const QString &deviceName) const
const Partition *PartitionModel::getPartition(const QString &devicePath) const
{
for (const Partition &partition : m_partitions) {
if (deviceName == partition.deviceName()) {
if (devicePath == partition.devicePath()) {
return &partition;
}
}
......
......@@ -127,13 +127,13 @@ public:
Q_INVOKABLE void refresh();
Q_INVOKABLE void refresh(int index);
Q_INVOKABLE void lock(const QString &deviceName);
Q_INVOKABLE void unlock(const QString &deviceName, const QString &passphrase);
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, const QString &passphrase = QString());
Q_INVOKABLE void lock(const QString &devicePath);
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 QString objectPath(const QString &deviceName) const;
Q_INVOKABLE QString objectPath(const QString &devicePath) const;
QHash<int, QByteArray> roleNames() const;
......@@ -154,7 +154,7 @@ signals:
private:
void update();
const Partition *getPartition(const QString &deviceName) const;
const Partition *getPartition(const QString &devicePath) const;
void partitionChanged(const Partition &partition);
void partitionAdded(const Partition &partition);
......
This diff is collapsed.
......@@ -54,16 +54,16 @@ class Job;
struct Operation
{
Operation(const QString &command, const QString &deviceName, const QString &dbusObjectPath, const QString &type, const QVariantHash &arguments)
Operation(const QString &command, const QString &devicePath, const QString &dbusObjectPath, const QString &type, const QVariantHash &arguments)
: command(command)
, deviceName(deviceName)
, devicePath(devicePath)
, dbusObjectPath(dbusObjectPath)
, type(type)
, arguments(arguments)
{}
QString command;
QString deviceName;
QString devicePath;
QString dbusObjectPath;
QString type;
QVariantHash arguments;
......@@ -78,18 +78,18 @@ public:
static Monitor *instance();
void lock(const QString &deviceName);
void unlock(const QString &deviceName, const QString &passphrase);
void lock(const QString &devicePath);
void unlock(const QString &devicePath, const QString &passphrase);
void mount(const QString &deviceName);
void unmount(const QString &deviceName);
void mount(const QString &devicePath);
void unmount(const QString &devicePath);
void format(const QString &deviceName, const QString &type, const QString &label, const QString &passphrase);
void format(const QString &devicePath, const QString &type, const QString &label, const QString &passphrase);
QString objectPath(const QString &deviceName) const;
QString objectPath(const QString &devicePath) const;
signals:
void status(const QString &deviceName, Partition::Status);
void status(const QString &devicePath, Partition::Status);
void errorMessage(const QString &objectPath, const QString &errorName);
void lockError(Partition::Error error);
void unlockError(Partition::Error error);
......@@ -107,14 +107,14 @@ private:
void updatePartitionStatus(const UDisks2::Job *job, bool success);
bool externalBlockDevice(const QString &objectPathStr) const;
void startLuksOperation(const QString &deviceName, const QString &dbusMethod, const QString &dbusObjectPath, const QVariantList &arguments);
void startMountOperation(const QString &deviceName, const QString &dbusMethod, const QString &dbusObjectPath, const QVariantList &arguments);
void startLuksOperation(const QString &devicePath, const QString &dbusMethod, const QString &dbusObjectPath, const QVariantList &arguments);
void startMountOperation(const QString &devicePath, const QString &dbusMethod, const QString &dbusObjectPath, const QVariantList &arguments);
void lookupPartitions(PartitionManagerPrivate::Partitions &affectedPartitions, const QStringList &objects);
void createPartition(const Block *block);
void createBlockDevice(const QString &path, const UDisks2::InterfacePropertyMap &interfacePropertyMap);
void createBlockDevice(const QString &dbusObjectPath, const UDisks2::InterfacePropertyMap &interfacePropertyMap);
void doFormat(const QString &deviceName, const QString &dbusObjectPath, const QString &type, const QVariantHash &arguments);
void doFormat(const QString &devicePath, const QString &dbusObjectPath, const QString &type, const QVariantHash &arguments);
void getBlockDevices();
private:
......
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