@@ -28,11 +28,6 @@ UDisks2::Block::Block(const QString &path, const UDisks2::InterfacePropertyMap &
28
28
qCWarning (lcMemoryCardLog) << " Failed to connect to Block properties change interface" << m_path << m_connection.lastError ().message ();
29
29
}
30
30
31
- QDBusInterface dbusPropertyInterface (UDISKS2_SERVICE,
32
- m_path,
33
- DBUS_OBJECT_PROPERTIES_INTERFACE,
34
- m_connection);
35
-
36
31
qCInfo (lcMemoryCardLog) << " Creating a new block. Mountable:" << m_mountable << " , encrypted:" << m_encrypted << " object path:" << m_path << " data is empty:" << m_data.isEmpty ();
37
32
38
33
if (m_interfacePropertyMap.isEmpty ()) {
@@ -68,15 +63,7 @@ UDisks2::Block::Block(const QString &path, const UDisks2::InterfacePropertyMap &
68
63
qCInfo (lcMemoryCardLog) << " Drive properties:" << driveProperties;
69
64
m_drive = driveProperties;
70
65
});
71
-
72
- connect (m_pendingDrive.data (), &QObject::destroyed, this , &Block::complete);
73
66
});
74
-
75
- connect (m_pendingEncrypted.data (), &QObject::destroyed, this , &Block::complete);
76
- connect (m_pendingFileSystem.data (), &QObject::destroyed, this , &Block::complete);
77
- connect (m_pendingPartitionTable.data (), &QObject::destroyed, this , &Block::complete);
78
- connect (m_pendingPartition.data (), &QObject::destroyed, this , &Block::complete);
79
- connect (m_pendingBlock.data (), &QObject::destroyed, this , &Block::complete);
80
67
} else {
81
68
if (m_mountable) {
82
69
QVariantMap map = interfacePropertyMap.value (UDISKS2_FILESYSTEM_INTERFACE);
@@ -274,7 +261,8 @@ bool UDisks2::Block::isReadOnly() const
274
261
bool UDisks2::Block::isExternal () const
275
262
{
276
263
const QString prefDevice = preferredDevice ();
277
- return prefDevice != QStringLiteral (" /dev/sailfish/home" ) && prefDevice != QStringLiteral (" /dev/sailfish/root" );
264
+ return prefDevice != QStringLiteral (" /dev/sailfish/home" ) && prefDevice != QStringLiteral (" /dev/sailfish/root" )
265
+ && mountPath () != QStringLiteral (" /home" ) && mountPath () != QStringLiteral (" /" );
278
266
}
279
267
280
268
bool UDisks2::Block::isValid () const
@@ -345,7 +333,7 @@ void UDisks2::Block::addInterface(const QString &interface, QVariantMap property
345
333
{
346
334
m_interfacePropertyMap.insert (interface, propertyMap);
347
335
if (interface == UDISKS2_FILESYSTEM_INTERFACE) {
348
- setMountable ( true );
336
+ updateFileSystemInterface (propertyMap );
349
337
} else if (interface == UDISKS2_ENCRYPTED_INTERFACE) {
350
338
setEncrypted (true );
351
339
}
@@ -359,7 +347,7 @@ void UDisks2::Block::removeInterface(const QString &interface)
359
347
} else if (interface == UDISKS2_DRIVE_INTERFACE) {
360
348
m_drive.clear ();
361
349
} else if (interface == UDISKS2_FILESYSTEM_INTERFACE) {
362
- setMountable ( false );
350
+ updateFileSystemInterface ( QVariantMap () );
363
351
} else if (interface == UDISKS2_ENCRYPTED_INTERFACE) {
364
352
setEncrypted (false );
365
353
}
@@ -451,21 +439,25 @@ bool UDisks2::Block::isCompleted() const
451
439
void UDisks2::Block::updateFileSystemInterface (const QVariant &filesystemInterface)
452
440
{
453
441
QVariantMap filesystem = NemoDBus::demarshallArgument<QVariantMap>(filesystemInterface);
454
- m_interfacePropertyMap.insert (UDISKS2_FILESYSTEM_INTERFACE, filesystem);
442
+
443
+ bool interfaceChange = m_interfacePropertyMap.contains (UDISKS2_FILESYSTEM_INTERFACE) != filesystem.isEmpty ();
444
+ if (filesystem.isEmpty ()) {
445
+ m_interfacePropertyMap.remove (UDISKS2_FILESYSTEM_INTERFACE);
446
+ } else {
447
+ m_interfacePropertyMap.insert (UDISKS2_FILESYSTEM_INTERFACE, filesystem);
448
+ }
455
449
QList<QByteArray> mountPointList = NemoDBus::demarshallArgument<QList<QByteArray> >(filesystem.value (QStringLiteral (" MountPoints" )));
456
450
m_mountPath.clear ();
457
451
458
- for (const QByteArray &bytes : mountPointList) {
459
- if (bytes.startsWith (" /run" )) {
460
- m_mountPath = QString::fromLocal8Bit (bytes);
461
- break ;
462
- }
452
+ if (!mountPointList.isEmpty ()) {
453
+ m_mountPath = QString::fromLocal8Bit (mountPointList.at (0 ));
463
454
}
464
455
465
456
bool triggerUpdate = false ;
466
457
blockSignals (true );
467
- triggerUpdate = setMountable (true );
458
+ triggerUpdate = setMountable (!filesystem. isEmpty () );
468
459
triggerUpdate |= clearFormattingState ();
460
+ triggerUpdate |= interfaceChange;
469
461
blockSignals (false );
470
462
471
463
if (triggerUpdate) {
@@ -529,6 +521,8 @@ void UDisks2::Block::getProperties(const QString &path, const QString &interface
529
521
m_connection);
530
522
QDBusPendingCall pendingCall = dbusPropertyInterface.asyncCall (DBUS_GET_ALL, interface);
531
523
watcherPointer = new QDBusPendingCallWatcher (pendingCall, this );
524
+
525
+ connect (watcherPointer.data (), &QObject::destroyed, this , &Block::complete);
532
526
connect (watcherPointer.data (), &QDBusPendingCallWatcher::finished, this , [success, path, interface](QDBusPendingCallWatcher *watcher) {
533
527
if (watcher->isValid () && watcher->isFinished ()) {
534
528
QDBusPendingReply<> reply = *watcher;
0 commit comments