Commit 30067332 authored by Raine Makelainen's avatar Raine Makelainen

[partitionmodel] Expose cryptoBackingDevicePath. Contributes to JB#42996

parent e9c1aa8e
......@@ -126,6 +126,11 @@ QString Partition::filesystemType() const
return d ? d->filesystemType : QString();
}
QString Partition::cryptoBackingDevicePath() const
{
return d ? d->cryptoBackingDevicePath : QString();
}
bool Partition::isSupportedFileSystemType() const
{
......
......@@ -105,6 +105,7 @@ public:
bool mountFailed() const;
bool isCryptoDevice() const;
bool isEncrypted() const;
QString cryptoBackingDevicePath() const;
StorageType storageType() const;
......
......@@ -70,6 +70,7 @@ public:
QString mountPath;
QString filesystemType;
QString activeState;
QString cryptoBackingDevicePath;
qint64 bytesAvailable;
qint64 bytesTotal;
qint64 bytesFree;
......
......@@ -253,6 +253,7 @@ QHash<int, QByteArray> PartitionModel::roleNames() const
{ IsCryptoDeviceRoles, "isCryptoDevice"},
{ IsSupportedFileSystemType, "isSupportedFileSystemType"},
{ IsEncryptedRoles, "isEncrypted"},
{ CryptoBackingDevicePath, "cryptoBackingDevicePath"},
};
return roleNames;
......@@ -305,6 +306,8 @@ QVariant PartitionModel::data(const QModelIndex &index, int role) const
return partition.isSupportedFileSystemType();
case IsEncryptedRoles:
return partition.isEncrypted();
case CryptoBackingDevicePath:
return partition.cryptoBackingDevicePath();
default:
return QVariant();
}
......
......@@ -65,6 +65,7 @@ public:
IsCryptoDeviceRoles,
IsSupportedFileSystemType,
IsEncryptedRoles,
CryptoBackingDevicePath
};
// For Status role
......
......@@ -152,10 +152,10 @@ bool UDisks2::Block::hasCryptoBackingDevice() const
return cryptoBackingDev != QLatin1String("/");
}
QString UDisks2::Block::cryptoBackingDeviceName() const
QString UDisks2::Block::cryptoBackingDevicePath() const
{
const QString object = cryptoBackingDeviceObjectPath();
return Block::cryptoBackingDeviceName(object);
return Block::cryptoBackingDevicePath(object);
}
QString UDisks2::Block::cryptoBackingDeviceObjectPath() const
......@@ -259,10 +259,10 @@ void UDisks2::Block::dumpInfo() const
qCInfo(lcMemoryCardLog) << "- idversion:" << idVersion() << "idlabel:" << idLabel();
qCInfo(lcMemoryCardLog) << "- iduuid:" << idUUID();
qCInfo(lcMemoryCardLog) << "- ismountable:" << isMountable() << "mount path:" << mountPath();
qCInfo(lcMemoryCardLog) << "- isencrypted:" << isEncrypted() << "crypto backing device:" << cryptoBackingDeviceName();
qCInfo(lcMemoryCardLog) << "- isencrypted:" << isEncrypted() << "crypto backing device:" << cryptoBackingDevicePath();
}
QString UDisks2::Block::cryptoBackingDeviceName(const QString &objectPath)
QString UDisks2::Block::cryptoBackingDevicePath(const QString &objectPath)
{
if (objectPath == QLatin1String("/") || objectPath.isEmpty()) {
return QString();
......
......@@ -64,7 +64,7 @@ public:
qint64 size() const;
bool hasCryptoBackingDevice() const;
QString cryptoBackingDeviceName() const;
QString cryptoBackingDevicePath() const;
QString cryptoBackingDeviceObjectPath() const;
bool isEncrypted() const;
......@@ -92,7 +92,7 @@ public:
void dumpInfo() const;
static QString cryptoBackingDeviceName(const QString &objectPath);
static QString cryptoBackingDevicePath(const QString &objectPath);
signals:
void completed();
......
......@@ -295,14 +295,16 @@ void UDisks2::Monitor::setPartitionProperties(QExplicitlySharedDataPointer<Parti
: blockDevice->mountPath().isEmpty() ? Partition::Unmounted : Partition::Mounted;
partition->isCryptoDevice = blockDevice->isEncrypted() || blockDevice->hasCryptoBackingDevice();
partition->isEncrypted = blockDevice->isEncrypted();
partition->cryptoBackingDevicePath = blockDevice->cryptoBackingDevicePath();
}
void UDisks2::Monitor::updatePartitionProperties(const UDisks2::Block *blockDevice)
{
bool hasCryptoBackingDevice = blockDevice->hasCryptoBackingDevice();
const QString cryptoBackingDevice = blockDevice->cryptoBackingDeviceName();
const QString cryptoBackingDevicePath = blockDevice->cryptoBackingDevicePath();
for (auto partition : m_manager->m_partitions) {
if ((partition->devicePath == blockDevice->device()) || (hasCryptoBackingDevice && (partition->devicePath == cryptoBackingDevice))) {
if ((partition->devicePath == blockDevice->device()) || (hasCryptoBackingDevice && (partition->devicePath == cryptoBackingDevicePath))) {
setPartitionProperties(partition, blockDevice);
partition->valid = true;
m_manager->refresh(partition.data());
......
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