Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find methods exposed in a D-Bus interface

Tags:

bluez

dbus

Question: Is there any way in which we can find out the methods (and their signatures) which are exposed in a D-Bus interface?

Issue Description: In my phone, I am calling BlueZ methods using D-Bus to adapter interface, when checked on phone 2 of these methods are not available.

Intention is to check if the method name/signatures are modified in other device, I don't have access to code so looking to find the methods in an interface

like image 463
ashish Avatar asked Nov 13 '13 14:11

ashish


2 Answers

Using dbus-send, you can list the available services on your system:

Session:

dbus-send --session           \
  --dest=org.freedesktop.DBus \
  --type=method_call          \
  --print-reply               \
  /org/freedesktop/DBus       \
  org.freedesktop.DBus.ListNames

System:

dbus-send --system            \
  --dest=org.freedesktop.DBus \
  --type=method_call          \
  --print-reply               \
  /org/freedesktop/DBus       \
  org.freedesktop.DBus.ListNames

You'll get an answer like that:

   array [
      string "org.freedesktop.DBus"
      string ":1.1"
      string ":1.26"
      string "org.asamk.Signal"
   ]

And if you want to list all methods available behind a dbus service, you can still use dbus-send to introspect the dbus service.

For example with org.asamk.Signal:

  dbus-send --system --type=method_call --print-reply \
      --dest=org.asamk.Signal \
      /org/asamk/Signal \
      org.freedesktop.DBus.Introspectable.Introspect

You'll get this kind of result (truncated)

<node name="/org/asamk/Signal">
 <interface name="org.asamk.Signal">
  <method name="sendMessage" >
   ...parameters
  </method>                      
  <method name="sendGroupMessage" >     
   ...parameters
  </method>
 </interface>
</node>

Here there are 2 methods, sendMessage and sendGroupMessage

like image 176
michael_bitard Avatar answered Oct 17 '22 14:10

michael_bitard


You can also take a look at D-Feet.

like image 35
Artefacto Avatar answered Oct 17 '22 14:10

Artefacto