31
31
32
32
#include " partitionmanager_p.h"
33
33
#include " udisks2monitor_p.h"
34
+ #include " udisks2blockdevices_p.h"
34
35
#include " logging_p.h"
35
36
36
37
#include < QFile>
@@ -62,17 +63,22 @@ PartitionManagerPrivate::PartitionManagerPrivate()
62
63
connect (m_udisksMonitor.data (), &UDisks2::Monitor::unmountError, this , &PartitionManagerPrivate::unmountError);
63
64
connect (m_udisksMonitor.data (), &UDisks2::Monitor::formatError, this , &PartitionManagerPrivate::formatError);
64
65
66
+ QVariantMap defaultDrive;
67
+ defaultDrive.insert (QLatin1String (" model" ), QString ());
68
+ defaultDrive.insert (QLatin1String (" vendor" ), QString ());
69
+ defaultDrive.insert (QLatin1String (" connectionBus" ), Partition::SDIO);
70
+
65
71
QExplicitlySharedDataPointer<PartitionPrivate> root (new PartitionPrivate (this ));
66
72
root->storageType = Partition::System;
67
- root->connectionBus = Partition::SDIO;
68
73
root->mountPath = QStringLiteral (" /" );
74
+ root->drive = defaultDrive;
69
75
70
76
m_partitions.append (root);
71
77
72
78
QExplicitlySharedDataPointer<PartitionPrivate> home (new PartitionPrivate (this ));
73
79
home->storageType = Partition::User;
74
- home->connectionBus = Partition::SDIO;
75
80
home->mountPath = QStringLiteral (" /home" );
81
+ home->drive = defaultDrive;
76
82
77
83
m_partitions.append (home);
78
84
refresh (m_partitions, m_partitions);
@@ -152,7 +158,8 @@ void PartitionManagerPrivate::add(QExplicitlySharedDataPointer<PartitionPrivate>
152
158
{
153
159
int insertIndex = 0 ;
154
160
for (const auto existingPartition : m_partitions) {
155
- if (existingPartition->connectionBus <= partition->connectionBus )
161
+ if (existingPartition->drive .value (QLatin1String (" connectionBus" )).toInt ()
162
+ <= partition->drive .value (QLatin1String (" connectionBus" )).toInt ())
156
163
++insertIndex;
157
164
else
158
165
break ;
@@ -299,7 +306,7 @@ void PartitionManagerPrivate::unlock(const Partition &partition, const QString &
299
306
{
300
307
qCInfo (lcMemoryCardLog) << " Can unlock:" << externalMedia.match (partition.deviceName ()).hasMatch () << partition.devicePath ();
301
308
if (externalMedia.match (partition.deviceName ()).hasMatch ()) {
302
- m_udisksMonitor->instance ()-> unlock (partition.devicePath (), passphrase);
309
+ m_udisksMonitor->unlock (partition.devicePath (), passphrase);
303
310
} else {
304
311
qCWarning (lcMemoryCardLog) << " Unlock allowed only for external memory cards," << partition.devicePath () << " is not allowed" ;
305
312
}
@@ -309,7 +316,7 @@ void PartitionManagerPrivate::mount(const Partition &partition)
309
316
{
310
317
qCInfo (lcMemoryCardLog) << " Can mount:" << externalMedia.match (partition.deviceName ()).hasMatch () << partition.devicePath ();
311
318
if (externalMedia.match (partition.deviceName ()).hasMatch ()) {
312
- m_udisksMonitor->instance ()-> mount (partition.devicePath ());
319
+ m_udisksMonitor->mount (partition.devicePath ());
313
320
} else {
314
321
qCWarning (lcMemoryCardLog) << " Mount allowed only for external memory cards," << partition.devicePath () << " is not allowed" ;
315
322
}
@@ -319,7 +326,7 @@ void PartitionManagerPrivate::unmount(const Partition &partition)
319
326
{
320
327
qCInfo (lcMemoryCardLog) << " Can unmount:" << externalMedia.match (partition.deviceName ()).hasMatch () << partition.devicePath ();
321
328
if (externalMedia.match (partition.deviceName ()).hasMatch ()) {
322
- m_udisksMonitor->instance ()-> unmount (partition.devicePath ());
329
+ m_udisksMonitor->unmount (partition.devicePath ());
323
330
} else {
324
331
qCWarning (lcMemoryCardLog) << " Unmount allowed only for external memory cards," << partition.devicePath () << " is not allowed" ;
325
332
}
@@ -330,7 +337,7 @@ void PartitionManagerPrivate::format(const QString &devicePath, const QString &f
330
337
QString deviceName = devicePath.section (QChar (' /' ), 2 );
331
338
qCInfo (lcMemoryCardLog) << " Can format:" << externalMedia.match (deviceName).hasMatch () << devicePath;
332
339
if (externalMedia.match (deviceName).hasMatch ()) {
333
- m_udisksMonitor->instance ()-> format (devicePath, filesystemType, arguments);
340
+ m_udisksMonitor->format (devicePath, filesystemType, arguments);
334
341
} else {
335
342
qCWarning (lcMemoryCardLog) << " Formatting allowed only for external memory cards," << devicePath << " is not allowed" ;
336
343
}
@@ -340,7 +347,7 @@ QString PartitionManagerPrivate::objectPath(const QString &devicePath) const
340
347
{
341
348
QString deviceName = devicePath.section (QChar (' /' ), 2 );
342
349
if (externalMedia.match (deviceName).hasMatch ()) {
343
- return m_udisksMonitor-> instance ()->objectPath (devicePath);
350
+ return UDisks2::BlockDevices:: instance ()->objectPath (devicePath);
344
351
} else {
345
352
qCWarning (lcMemoryCardLog) << " Object path existing only for external memory cards:" << devicePath;
346
353
return QString ();
0 commit comments