Commit a306fa45 authored by Raine Makelainen's avatar Raine Makelainen

[systemsettings] Add a role to partition that tells whether partition is...

[systemsettings] Add a role to partition that tells whether partition is encrypted. Contributes to JB#42527

The role isCryptoDevice is true when the block device is encrypted
meaning that it has Encrypted interface but not FileSystem or if the
block has been unlocked and it has crypto backing device.
parent 8ee508e5
......@@ -86,6 +86,11 @@ bool Partition::mountFailed() const
return d && d->mountFailed;
}
bool Partition::isCryptoDevice() const
{
return d ? d->isCryptoDevice : false;
}
Partition::StorageType Partition::storageType() const
{
return d ? d->storageType : Invalid;
......
......@@ -103,6 +103,7 @@ public:
bool canMount() const;
bool mountFailed() const;
bool isCryptoDevice() const;
StorageType storageType() const;
......
......@@ -48,6 +48,7 @@ public:
, status(Partition::Unmounted)
, readOnly(true)
, canMount(false)
, isCryptoDevice(false)
, mountFailed(false)
, deviceRoot(false)
, valid(false)
......@@ -74,6 +75,7 @@ public:
Partition::Status status;
bool readOnly;
bool canMount;
bool isCryptoDevice;
bool mountFailed;
bool deviceRoot;
// If valid, only mount status and available bytes will be checked
......
......@@ -267,7 +267,8 @@ QHash<int, QByteArray> PartitionModel::roleNames() const
{ BytesAvailableRole, "bytesAvailable" },
{ BytesTotalRole, "bytesTotal" },
{ BytesFreeRole, "bytesFree" },
{ PartitionModelRole, "partitionModel" }
{ PartitionModelRole, "partitionModel" },
{ IsCryptoDeviceRoles, "isCryptoDevice"},
};
return roleNames;
......@@ -314,6 +315,8 @@ QVariant PartitionModel::data(const QModelIndex &index, int role) const
return partition.bytesFree();
case PartitionModelRole:
return QVariant::fromValue(static_cast<QObject*>(const_cast<PartitionModel*>((this))));
case IsCryptoDeviceRoles:
return partition.isCryptoDevice();
default:
return QVariant();
}
......
......@@ -61,7 +61,8 @@ public:
BytesAvailableRole,
BytesTotalRole,
BytesFreeRole,
PartitionModelRole
PartitionModelRole,
IsCryptoDeviceRoles,
};
// For Status role
......
......@@ -291,6 +291,7 @@ void UDisks2::Monitor::setPartitionProperties(QExplicitlySharedDataPointer<Parti
partition->canMount = blockDevice->isMountable() && m_manager->supportedFileSystems().contains(partition->filesystemType);
partition->status = blockDevice->isEncrypted() ? Partition::Locked
: blockDevice->mountPath().isEmpty() ? Partition::Unmounted : Partition::Mounted;
partition->isCryptoDevice = blockDevice->isEncrypted() || blockDevice->hasCryptoBackingDevice();
}
void UDisks2::Monitor::updatePartitionProperties(const UDisks2::Block *blockDevice)
......
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