Sending new property to DBus

Aleksander Morgado aleksander at aleksander.es
Fri Nov 23 14:22:07 UTC 2018


Hey!

> I'm trying to get the connection steps to show on the DBus, so that the data can be used by other programs. To achieve this I made an extra property on the modem_simple interface. I did some research on the source code to figure out how the data actually gets sent to DBus, and I came to the conclusion that the code that does that gets generated when the program gets compiled.
>
> So I added the property, checked if it worked, which it did. And then checked the generated DBus files to see if I could find anything about the property that I made, but I couldn't find anything about it. How does the DBus system actually work? Do the files check all the installed properties and then generate code for it so that it can be sent over DBus? Or how can I get the property to show on the DBus?
>

Yes, the code to manage all DBus related things is generated at
compile time from the service file under /introspection, with
gdbus-codegen. I've given a couple of talks explaining how DBus and
gdbus-codegen work, you can check the slides and some simple examples
here: https://aleksander.es/data/GNOMEASIA2014%20-%20Introduction%20to%20DBus.pdf
(there's also a youtube video of that talk IIRC).

Instead of going over all the steps on how this works, you can take a
look at this recent commit I'm working on:
  https://gitlab.freedesktop.org/mobile-broadband/ModemManager/commit/e68c6bb3225afb8834f1685b50381fd3d8db5c74
In that commit you'll see how a new read-only property
"InitialEpsBearerProperties" is added in the Modem3gpp.xml interface
file. As soon as you add the property in the interface file and build
the project, you'll get the ability to run
"mm_gdbus_modem3gpp_set_initial_eps_bearer_properties" from within the
daemon code (in src/) and also you'll get the ability to run
"mm_gdbus_modem3gpp_get_initial_eps_bearer_properties" from within the
libmm-glib code (in libmm-glib/). The set() method is run on the
SKELETON object inside the daemon, which is the one updating the
property in DBus. The get() method may be run in both the SKELETON (in
daemon) and PROXY (in client) objects. The commit I posted above is a
bit special because the property being added is a dictionary "a{sv}"
for which we provide a custom helper object in the client library
side. The commit also includes the mmcli updates to read and expose
the contents of that new property.

Now, regarding the actual property you want to add, are you just
looking for publishing which of the connection steps of the
Simple.Connect() operation is running at a given time? That is
probably not a bad idea. Were you looking to publish just a enum value
(e.g. SimpleConnectStep) or a full descriptive string? Are you looking
to upstream this change? ;)

-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list