Arn
Arn

Reputation: 600

how to get "properties" through gdbus

Can anybody tell me where I can find documentation on how to use gdbus call to get information from the system?

I am following APIs here: https://www.freedesktop.org/software/ModemManager/api/latest/gdbus-org.freedesktop.ModemManager1.Modem.html#gdbus-method-org-freedesktop-ModemManager1-Modem.Command

and I want to read for example:
Model
Revision
State
PowerState

etc.

I was wondering how to create a call to get the "properties" out of the modem through gdbus

Thanks

Upvotes: 1

Views: 4446

Answers (1)

lzmartinico
lzmartinico

Reputation: 159

DBus Properties are accessible through method:

org.freedesktop.DBus.Properties.Get (in STRING interface_name,
                                     in STRING property_name, 
                                     out VARIANT value); 

or

org.freedesktop.DBus.Properties.GetAll (in STRING interface_name,
                                        out DICT<STRING,VARIANT> props)

To get Model, for example, you could use dbus-send like so:

dbus-send --system --dest=org.freedesktop.ModemManager1 --print-reply \
/path/to/Modem/object org.freedesktop.DBus.Properties.Get \
string:'org.freedesktop.ModemManager1.Modem' string:'Model'

where /path/to/Modem/object will be something like /org/freedesktop.ModemManager1/Modems/# and # is the unique integer identifier for the modem you want to get the information for. For more information on dbus-send check the documentation https://dbus.freedesktop.org/doc/dbus-send.1.html

Upvotes: 1

Related Questions