Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
bsdutils
bsdisks
Commits
b20aab5bb443
Commit
01f8a746
authored
Oct 20, 2020
by
Gleb Popov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename ObjectManager::addInterface to addInterfaces() and make it signal all
added interfaces at once. Reported by: tijl
parent
a32bcc3d2fe0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
objectmanager.cpp
objectmanager.cpp
+22
-13
objectmanager.h
objectmanager.h
+1
-1
No files found.
objectmanager.cpp
View file @
b20aab5b
...
...
@@ -274,16 +274,19 @@ bool ObjectManager::registerBlock(Block* b, bool tryPostponed)
qDebug
()
<<
"Registering "
+
devPath
;
QDBusConnection
::
systemBus
().
registerObject
(
devPath
,
b
);
addInterface
(
b
->
dbusPath
,
QStringLiteral
(
"org.freedesktop.UDisks2.Block"
),
new
BlockAdaptor
(
b
));
QList
<
std
::
pair
<
QString
,
QDBusAbstractAdaptor
*>>
interfaces
;
interfaces
<<
std
::
make_pair
(
QStringLiteral
(
"org.freedesktop.UDisks2.Block"
),
new
BlockAdaptor
(
b
));
if
(
b
->
bFilesystem
)
addI
nterface
(
b
->
dbusPath
,
QStringLiteral
(
"org.freedesktop.UDisks2.Filesystem"
),
new
FilesystemAdaptor
(
b
));
i
nterface
s
<<
std
::
make_pair
(
QStringLiteral
(
"org.freedesktop.UDisks2.Filesystem"
),
new
FilesystemAdaptor
(
b
));
if
(
b
->
bPartTable
)
addI
nterface
(
b
->
dbusPath
,
QStringLiteral
(
"org.freedesktop.UDisks2.PartitionTable"
),
new
PartitionTableAdaptor
(
b
));
i
nterface
s
<<
std
::
make_pair
(
QStringLiteral
(
"org.freedesktop.UDisks2.PartitionTable"
),
new
PartitionTableAdaptor
(
b
));
if
(
b
->
bPartition
)
addInterface
(
b
->
dbusPath
,
"org.freedesktop.UDisks2.Partition"
,
new
PartitionAdaptor
(
b
));
interfaces
<<
std
::
make_pair
(
QStringLiteral
(
"org.freedesktop.UDisks2.Partition"
),
new
PartitionAdaptor
(
b
));
addInterfaces
(
b
->
dbusPath
,
interfaces
);
}
else
{}
// we were updating things after updateBlock()
...
...
@@ -301,7 +304,7 @@ void ObjectManager::registerDrive(Drive* d)
qDebug
()
<<
"Registering "
+
dbusPath
;
QDBusConnection
::
systemBus
().
registerObject
(
dbusPath
,
d
);
addInterface
(
d
->
dbusPath
,
"org.freedesktop.UDisks2.Drive"
,
new
DriveAdaptor
(
d
));
addInterface
s
(
d
->
dbusPath
,
{
std
::
make_pair
(
"org.freedesktop.UDisks2.Drive"
,
new
DriveAdaptor
(
d
))
})
;
tryRegisterPostponed
();
}
...
...
@@ -433,18 +436,24 @@ void ObjectManager::addPartition(Block* b, const QString& tableBlockName, const
}
void
ObjectManager
::
addInterface
(
QDBusObjectPath
path
,
QString
iface
,
QDBusAbstractAdaptor
*
adaptor
)
void
ObjectManager
::
addInterface
s
(
QDBusObjectPath
path
,
Q
List
<
std
::
pair
<
Q
String
,
QDBusAbstractAdaptor
*
>>
newInterfaces
)
{
QVariantMapMap
&
interfaces
=
m_managedObjects
[
path
];
QVariantMap
properties
;
for
(
int
i
=
adaptor
->
metaObject
()
->
propertyOffset
();
i
<
adaptor
->
metaObject
()
->
propertyCount
();
++
i
)
{
auto
propertyName
=
adaptor
->
metaObject
()
->
property
(
i
).
name
();
properties
.
insert
(
QString
::
fromLatin1
(
propertyName
),
adaptor
->
property
(
propertyName
));
}
for
(
auto
pair
:
newInterfaces
)
{
const
QString
&
iface
=
pair
.
first
;
QDBusAbstractAdaptor
*
adaptor
=
pair
.
second
;
QVariantMap
properties
;
for
(
int
i
=
adaptor
->
metaObject
()
->
propertyOffset
();
i
<
adaptor
->
metaObject
()
->
propertyCount
();
++
i
)
{
auto
propertyName
=
adaptor
->
metaObject
()
->
property
(
i
).
name
();
properties
.
insert
(
QString
::
fromLatin1
(
propertyName
),
adaptor
->
property
(
propertyName
));
}
interfaces
[
iface
]
=
properties
;
interfaces
[
iface
]
=
properties
;
}
emit
InterfacesAdded
(
path
,
interfaces
);
}
...
...
objectmanager.h
View file @
b20aab5b
...
...
@@ -68,7 +68,7 @@ private:
void
addPartition
(
Block
*
b
,
const
QString
&
tableBlockName
,
const
Part
&
partInfo
);
void
addInterface
(
QDBusObjectPath
path
,
QString
iface
,
QDBusAbstractAdaptor
*
adaptor
);
void
addInterface
s
(
QDBusObjectPath
path
,
Q
List
<
std
::
pair
<
Q
String
,
QDBusAbstractAdaptor
*
>>
newInterfaces
);
void
removeInterfaces
(
QDBusObjectPath
path
,
QStringList
ifaces
);
DBUSManagerStruct
m_managedObjects
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment