用dbus-send查看当前system bus或者session bus上面挂载了多少service.

在Linux PC/手机启动后,dbus-daemo就启动了。

这是如果一个程序启动了,会有一个connection挂载到dbus-daemon上面的,同时维护了这个程序的service.

可以采用dbus-send命令来查看system bus或者session bus上面到底挂载了哪些service, 即,当前有哪些程序

是和dbus-daemon有关联的:

 

1 查看system bus上面挂载的service.

test@test-desktop:~$ dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListActivatableNames

method return sender=org.freedesktop.DBus -> dest=:1.25 reply_serial=2
   array [
      string "org.freedesktop.DBus"
      string "net.ekiga.helper"
      string "org.freedesktop.PowerManagement"
      string "org.freedesktop.Tracker"
      string "org.freedesktop.Notifications"
      string "org.freedesktop.SystemToolsBackends.GroupsConfig"
      string "org.freedesktop.SystemToolsBackends.NTPConfig"
      string "org.freedesktop.SystemToolsBackends.NFSConfig"
      string "org.gnome.Tomboy"
      string "org.freedesktop.SystemToolsBackends.HostsConfig"
      string "org.freedesktop.SystemToolsBackends"
      string "net.ekiga.instance"
      string "org.gnome.GnomeVFS.Daemon"
      string "com.redhat.dhcp"
      string "org.freedesktop.SystemToolsBackends.IfacesConfig"
      string "org.freedesktop.SystemToolsBackends.TimeConfig"
      string "org.freedesktop.SystemToolsBackends.ServicesConfig"
      string "org.gnome.Rhythmbox"
      string "org.freedesktop.SystemToolsBackends.Platform"
      string "org.freedesktop.SystemToolsBackends.SMBConfig"
      string "org.gnome.SettingsDaemon"
      string "org.freedesktop.SystemToolsBackends.UsersConfig"
   ]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2 查看session bus上面挂载的service .
test@test-desktop:~$ dbus-send --session --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListActivatableNames
method return sender=org.freedesktop.DBus -> dest=:1.18 reply_serial=2
   array [
      string "org.freedesktop.DBus"
      string "net.ekiga.helper"
      string "org.freedesktop.PowerManagement"
      string "org.freedesktop.Tracker"
      string "org.freedesktop.Notifications"
      string "org.freedesktop.SystemToolsBackends.GroupsConfig"
      string "org.freedesktop.SystemToolsBackends.NTPConfig"
      string "org.freedesktop.SystemToolsBackends.NFSConfig"
      string "org.gnome.Tomboy"
      string "org.freedesktop.SystemToolsBackends.HostsConfig"
      string "org.freedesktop.SystemToolsBackends"
      string "net.ekiga.instance"
      string "org.gnome.GnomeVFS.Daemon"
      string "com.redhat.dhcp"
      string "org.freedesktop.SystemToolsBackends.IfacesConfig"
      string "org.freedesktop.SystemToolsBackends.TimeConfig"
      string "org.freedesktop.SystemToolsBackends.ServicesConfig"
      string "org.gnome.Rhythmbox"
      string "org.freedesktop.SystemToolsBackends.Platform"
      string "org.freedesktop.SystemToolsBackends.SMBConfig"
      string "org.gnome.SettingsDaemon"
      string "org.freedesktop.SystemToolsBackends.UsersConfig"
   ]

 

看看Nokia的maemo平台启动后,我们可以看有哪些后台程序在和D-BUS之间有通信:

用dbus-send查看当前system bus或者session bus上面挂载了多少service._第1张图片

 

更多的用法,其实就是调用org.freedesktop.Dbus提供的标准接口:

[sbox-CHINOOK_X86: ~] >  dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Introspectable.Introspect

method return sender=org.freedesktop.DBus -> dest=:1.8
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="org.freedesktop.DBus.Introspectable">
    <method name="Introspect">
      <arg name="data" direction="out" type="s"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus">
    <method name="RequestName">
      <arg direction="in" type="s"/>
      <arg direction="in" type="u"/>
      <arg direction="out" type="u"/>
    </method>
    <method name="ReleaseName">
      <arg direction="in" type="s"/>
      <arg direction="out" type="u"/>
    </method>
    <method name="StartServiceByName">
      <arg direction="in" type="s"/>
      <arg direction="in" type="u"/>
      <arg direction="out" type="u"/>
    </method>
    <method name="Hello">
      <arg direction="out" type="s"/>
    </method>
    <method name="NameHasOwner">
      <arg direction="in" type="s"/>
      <arg direction="out" type="b"/>
    </method>
    <method name="ListNames">
      <arg direction="out" type="as"/>
    </method>
    <method name="ListActivatableNames">
      <arg direction="out" type="as"/>
    </method>
    <method name="AddMatch">
      <arg direction="in" type="s"/>
    </method>
    <method name="RemoveMatch">
      <arg direction="in" type="s"/>
    </method>
    <method name="GetNameOwner">
      <arg direction="in" type="s"/>
      <arg direction="out" type="s"/>
    </method>
    <method name="ListQueuedOwners">
      <arg direction="in" type="s"/>
      <arg direction="out" type="as"/>
    </method>
    <method name="GetConnectionUnixUser">
      <arg direction="in" type="s"/>
      <arg direction="out" type="u"/>
    </method>
    <method name="GetConnectionUnixProcessID">
      <arg direction="in" type="s"/>
      <arg direction="out" type="u"/>
    </method>
    <method name="GetConnectionSELinuxSecurityContext">
      <arg direction="in" type="s"/>
      <arg direction="out" type="ay"/>
    </method>
    <method name="ReloadConfig">
    </method>
    <signal name="NameOwnerChanged">
      <arg type="s"/>
      <arg type="s"/>
      <arg type="s"/>
    </signal>
    <signal name="NameLost">
      <arg type="s"/>
    </signal>
    <signal name="NameAcquired">
      <arg type="s"/>
    </signal>
  </interface>
</node>
"

 

///////////////////////////////////////////////////////////////////////////

[sbox-CHINOOK_X86: ~] >  dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames
method return sender=org.freedesktop.DBus -> dest=:1.10
   array [
      string "org.freedesktop.DBus"
      string "com.nokia.hildon-desktop"
      string "com.nokia.SM_DIMMED_infoprint"
      string "org.gnome.GConf"
      string "com.nokia.hildon_input_method"
      string ":1.10"
      string "com.nokia.AS_DIMMED_infoprint"
      string ":1.0"
      string ":1.1"
      string ":1.2"
      string ":1.3"
      string ":1.4"
      string ":1.5"
   ]
[sbox-CHINOOK_X86: ~] >

/////////////////////////////////////////////////////////////////////////////

详细的东西多看看dbus的文档:

http://dbus.freedesktop.org/doc/dbus-specification.html

来源:http://blog.csdn.net/cuijpus/article/details/2455173

你可能感兴趣的:(session,String,service,System,interface,Signal)