@@ -20,6 +20,7 @@ UDisks2::Block::Block(const QString &path, const UDisks2::InterfacePropertyMap &
20
20
, m_pendingFileSystem(nullptr )
21
21
, m_pendingBlock(nullptr )
22
22
, m_pendingEncrypted(nullptr )
23
+ , m_pendingDrive(nullptr )
23
24
{
24
25
if (!m_connection.connect (
25
26
UDISKS2_SERVICE,
@@ -50,6 +51,7 @@ UDisks2::Block::Block(const QString &path, const UDisks2::InterfacePropertyMap &
50
51
QVariantMap blockProperties = NemoDBus::demarshallArgument<QVariantMap>(message.arguments ().at (0 ));
51
52
qCInfo (lcMemoryCardLog) << " Block properties:" << blockProperties;
52
53
m_data = blockProperties;
54
+ getDriveProperties ();
53
55
} else {
54
56
QDBusError error = watcher->error ();
55
57
qCWarning (lcMemoryCardLog) << " Error reading block properties:" << error.name () << error.message ();
@@ -63,6 +65,7 @@ UDisks2::Block::Block(const QString &path, const UDisks2::InterfacePropertyMap &
63
65
QVariantMap map = interfacePropertyMap.value (UDISKS2_FILESYSTEM_INTERFACE);
64
66
updateMountPoint (map);
65
67
}
68
+ getDriveProperties ();
66
69
67
70
// We have either org.freedesktop.UDisks2.Filesystem or org.freedesktop.UDisks2.Encrypted interface.
68
71
complete ();
@@ -103,6 +106,7 @@ UDisks2::Block &UDisks2::Block::operator=(const UDisks2::Block &other)
103
106
104
107
m_interfacePropertyMap = other.m_interfacePropertyMap ;
105
108
m_data = other.m_data ;
109
+ m_drive = other.m_drive ;
106
110
m_mountable = other.m_mountable ;
107
111
m_mountPath = other.m_mountPath ;
108
112
m_encrypted = other.m_encrypted ;
@@ -138,6 +142,25 @@ QString UDisks2::Block::drive() const
138
142
return value (QStringLiteral (" Drive" )).toString ();
139
143
}
140
144
145
+ QString UDisks2::Block::connectionBus () const
146
+ {
147
+ QString bus = NemoDBus::demarshallDBusArgument (m_drive.value (QStringLiteral (" ConnectionBus" ))).toString ();
148
+
149
+ // Do a bit of guesswork as we're missing connection between unlocked crypto block to crypto backing block device
150
+ // from where we could see the drive where this block belongs to.
151
+ if (bus != QLatin1String (" /" ) && hasCryptoBackingDevice ()) {
152
+ QString cryptoBackingPath = cryptoBackingDevicePath ();
153
+ if (cryptoBackingPath.contains (QLatin1String (" mmcblk" ))) {
154
+ return QStringLiteral (" sdio" );
155
+ } else if (cryptoBackingPath.startsWith (QLatin1String (" /dev/sd" ))) {
156
+ return QStringLiteral (" usb" );
157
+ }
158
+ return QStringLiteral (" ieee1394" );
159
+ }
160
+
161
+ return bus;
162
+ }
163
+
141
164
qint64 UDisks2::Block::deviceNumber () const
142
165
{
143
166
return value (QStringLiteral (" DeviceNumber" )).toLongLong ();
@@ -153,6 +176,11 @@ qint64 UDisks2::Block::size() const
153
176
return value (QStringLiteral (" Size" )).toLongLong ();
154
177
}
155
178
179
+ bool UDisks2::Block::isCryptoBlock () const
180
+ {
181
+ return isEncrypted () || hasCryptoBackingDevice ();
182
+ }
183
+
156
184
bool UDisks2::Block::hasCryptoBackingDevice () const
157
185
{
158
186
const QString cryptoBackingDev = cryptoBackingDeviceObjectPath ();
@@ -274,7 +302,7 @@ bool UDisks2::Block::hasData() const
274
302
void UDisks2::Block::dumpInfo () const
275
303
{
276
304
qCInfo (lcMemoryCardLog) << " Block device:" << device () << " Preferred device:" << preferredDevice ();
277
- qCInfo (lcMemoryCardLog) << " - drive:" << drive () << " dNumber :" << deviceNumber ();
305
+ qCInfo (lcMemoryCardLog) << " - drive:" << drive () << " device number :" << deviceNumber () << " connection bus: " << connectionBus ();
278
306
qCInfo (lcMemoryCardLog) << " - id:" << id () << " size:" << size ();
279
307
qCInfo (lcMemoryCardLog) << " - isreadonly:" << isReadOnly () << " idtype:" << idType ();
280
308
qCInfo (lcMemoryCardLog) << " - idversion:" << idVersion () << " idlabel:" << idLabel ();
@@ -313,7 +341,7 @@ void UDisks2::Block::updateProperties(const QDBusMessage &message)
313
341
314
342
bool UDisks2::Block::isCompleted () const
315
343
{
316
- return !m_pendingFileSystem && !m_pendingBlock && !m_pendingEncrypted;
344
+ return !m_pendingFileSystem && !m_pendingBlock && !m_pendingEncrypted && !m_pendingDrive ;
317
345
}
318
346
319
347
void UDisks2::Block::updateMountPoint (const QVariant &mountPoints)
@@ -403,3 +431,30 @@ void UDisks2::Block::getEncryptedInterface()
403
431
complete ();
404
432
});
405
433
}
434
+
435
+ void UDisks2::Block::getDriveProperties ()
436
+ {
437
+ QDBusInterface drivePropertyInterface (UDISKS2_SERVICE,
438
+ drive (),
439
+ DBUS_OBJECT_PROPERTIES_INTERFACE,
440
+ m_connection);
441
+ QDBusPendingCall pendingCall = drivePropertyInterface.asyncCall (DBUS_GET_ALL, UDISKS2_DRIVE_INTERFACE);
442
+ m_pendingDrive = new QDBusPendingCallWatcher (pendingCall, this );
443
+ connect (m_pendingDrive, &QDBusPendingCallWatcher::finished, this , [this ](QDBusPendingCallWatcher *watcher) {
444
+ if (watcher->isValid () && watcher->isFinished ()) {
445
+ QDBusPendingReply<> reply = *watcher;
446
+ QDBusMessage message = reply.reply ();
447
+ QVariantMap driveProperties = NemoDBus::demarshallArgument<QVariantMap>(message.arguments ().at (0 ));
448
+ qCInfo (lcMemoryCardLog) << " Drive properties:" << driveProperties;
449
+ m_drive = driveProperties;
450
+ } else {
451
+ QDBusError error = watcher->error ();
452
+ qCWarning (lcMemoryCardLog) << " Error reading drive properties:" << error.name () << error.message ();
453
+ m_drive.clear ();
454
+ }
455
+
456
+ m_pendingDrive->deleteLater ();
457
+ m_pendingDrive = nullptr ;
458
+ complete ();
459
+ });
460
+ }
0 commit comments