Notes of GDBus

Conceptions: – D-BUS is an IPC method. what is IPC ? – It is common on Linux-like platform – High level API implemented by dbus-glib, python … so on. – server – client services Notice: use GDBus instead of dbus-glib: comparing    → GDBus: Then following are some code snippets and configuration examples.
TO-DO: – system.conf (push under the etc/dbus-1/system.d/) – makefile – implement server and client
Server & Client example: pre-define:  Object: g_dbus_connection_register_object  Interface name  Service name Initial: – g_queue_new – g_dbus_node_info_new_for_xml: method calls, signals – g_bus_own_name – GDBusConnection Flows: – Response: g_dbus_method_invocation_return_value – Error handlers …
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
<!-- Only root or user avahi can own the Avahi service -->
<policy user="root">
<allow own="test.dbuscall.dest"/>
<allow own="test.dbuscall.source"/>
<!-- Allow anyone to invoke methods on Avahi server, except SetHostName -->
<policy context="default">
<allow send_destination="test.dbuscall.dest"/> <!--server -->
<allow receive_sender="test.dbuscall.source"/> <!--client-->
makefile: NEW!! library: gio-unix-2.0 ref: OLD … libaries: dbus dbus-glib source/header: dbus-1.0 glib-2.0 ref:
How to test your configuration? a. add test-dbus.conf under /etc/dbus-1/system.d  adb shell  mount -o rw,remount /  adb push /test-dbus.conf /etc/dbus-1/system.d
b. You need two terminals  terminal i.:   adb shell   ./data/gio_server_test  terminal ii:   adb shell   dbus-send –system –print-reply –type=method_call –dest=org.gtk.GDBus.TestServer /org/gtk/GDBus/TestObject org.gtk.GDBus.TestInterface.HelloWorld string:’HiHi’
References: Tutorial: Introductions: GDBus: