WIP - DBUS

D-Bus

Backgroud

컴퓨터 위에서 동작하는 소프트웨어 패키지, 웹 서비스와 같은 다양한 소프트웨어 컴포넌트들은
보통 하나의 서비스를 제공하며, 이들은 Client Application에 의하여 사용되거나, 다른 컴포턴트에
의하여 실행 되어진다. 이때 서비스와 클라이언트 간에 IPC 통신을 위하여 채널을 설립하는데, 이렇게 각각의 채널을 설립하게
되는 메쉬형 구조는 비효율적이며, 신뢰할 수 없는 환경 가지게 된다. D-Bus는 Single Shared Virtual Channel을 통하여 각각 통신들을 모아, Software-bus abstraction을 제공한다.

Single System Bus

모든 user와 process들이 사용할 수 있으며, 운영체제에서 제공하는 service들이나 system daemon과 같은
system services들에 접근하기 위하여 제공되는 bus이다.

Session Bus

user들의 login session간에 각각 존재하며 system bus에 접근 할 수 있으나 다른 session bus에는 접근 할 수 없음.

In computing, D-Bus (for “Desktop Bus”), a software bus, is an inter-process communication (IPC) and remote procedure call (RPC) mechanism that allows communication between multiple computer programs (that is, processes) concurrently running on the same machine.

  • 한 호스트 내에서 여러 프로세스간에 통신하는 소프트웨어 버스.
  • IPC(Interporcess communication)를 위한 시스템.
  • D-Bus는 메시지 버스 시스템으로 프로세스 간의 통신을 쉽게하는 수단을 제공한다. 시스템 전반과 각 사용자 세션 모두에 대해 실행될 수 있는 데몬과 응용프로그램이 D-Bus를 사용할 수 있게 하는 일련의 라이브러리로 이루어져 있다.
  • D-Bus는 systemd를 사용하면 자동으로 활성화된다. systemd가 dbus에 의존하기 때문이다.
  • D-Bus는 소프트웨어 컴포넌트간에 IPC 매커니즘으로 디자인 됨.

An individual software component is a software package, a web service, a web resource,
or a module that encapsulates a set of related functions (or data).

##
1. Clone source code
  - https://github.com/GNOME/glib/blob/master/gio/tests/gdbus-example-server.c
2. Build source code
  $ pkg-config --libs --cflags gio-2.0
  $ gcc gdbus-example-server.c -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include  -lgio-2.0 -lgobject-2.0 -lglib-2.0
3. Run server
  $ ./a.out

## cmd-tool
$ gdbus introspect --session --dest org.gtk.GDBus.TestServer --object-path /org/gtk/GDBus/TestObject
$ gdbus monitor --session --dest org.gtk.GDBus.TestServer
$ gdbus call --session --dest org.gtk.GDBus.TestServer --object-path /org/gtk/GDBus/TestObject --method org.gtk.GDBus.TestInterface.HelloWorld Wowgdbus!
("You greeted me with 'Wowgdbus!'. Thanks!",)

https://en.wikipedia.org/wiki/D-Bus https://dbus.freedesktop.org/doc/dbus-tutorial.html