Skip to content

Commit

Permalink
[partitionmodel] Expose cryptoBackingDevicePath. Contributes to JB#42996
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Sep 19, 2018
1 parent e9c1aa8 commit 3006733
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/partition.cpp
Expand Up @@ -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
{

Expand Down
1 change: 1 addition & 0 deletions src/partition.h
Expand Up @@ -105,6 +105,7 @@ class SYSTEMSETTINGS_EXPORT Partition
bool mountFailed() const;
bool isCryptoDevice() const;
bool isEncrypted() const;
QString cryptoBackingDevicePath() const;

StorageType storageType() const;

Expand Down
1 change: 1 addition & 0 deletions src/partition_p.h
Expand Up @@ -70,6 +70,7 @@ class PartitionPrivate : public QSharedData
QString mountPath;
QString filesystemType;
QString activeState;
QString cryptoBackingDevicePath;
qint64 bytesAvailable;
qint64 bytesTotal;
qint64 bytesFree;
Expand Down
3 changes: 3 additions & 0 deletions src/partitionmodel.cpp
Expand Up @@ -253,6 +253,7 @@ QHash<int, QByteArray> PartitionModel::roleNames() const
{ IsCryptoDeviceRoles, "isCryptoDevice"},
{ IsSupportedFileSystemType, "isSupportedFileSystemType"},
{ IsEncryptedRoles, "isEncrypted"},
{ CryptoBackingDevicePath, "cryptoBackingDevicePath"},
};

return roleNames;
Expand Down Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions src/partitionmodel.h
Expand Up @@ -65,6 +65,7 @@ class SYSTEMSETTINGS_EXPORT PartitionModel : public QAbstractListModel
IsCryptoDeviceRoles,
IsSupportedFileSystemType,
IsEncryptedRoles,
CryptoBackingDevicePath
};

// For Status role
Expand Down
8 changes: 4 additions & 4 deletions src/udisks2block.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/udisks2block_p.h
Expand Up @@ -64,7 +64,7 @@ class Block : public QObject
qint64 size() const;

bool hasCryptoBackingDevice() const;
QString cryptoBackingDeviceName() const;
QString cryptoBackingDevicePath() const;
QString cryptoBackingDeviceObjectPath() const;

bool isEncrypted() const;
Expand Down Expand Up @@ -92,7 +92,7 @@ class Block : public QObject

void dumpInfo() const;

static QString cryptoBackingDeviceName(const QString &objectPath);
static QString cryptoBackingDevicePath(const QString &objectPath);

signals:
void completed();
Expand Down
6 changes: 4 additions & 2 deletions src/udisks2monitor.cpp
Expand Up @@ -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());
Expand Down

0 comments on commit 3006733

Please sign in to comment.