You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Emanoil Kotsev da1782ccbb Updated examples after commit 61b1be0 to dbus-1-tqt 2 days ago
4d Updated examples after commit 61b1be0 to dbus-1-tqt 2 days ago
4e Updated examples after commit 61b1be0 to dbus-1-tqt 2 days ago
4f Updated examples after commit 61b1be0 to dbus-1-tqt 2 days ago
.gitignore Initial commit 6 months ago
LICENSE Initial commit 6 months ago
README.md Updated examples after commit 61b1be0 to dbus-1-tqt 2 days ago
build_4d.sh Updated examples after commit 61b1be0 to dbus-1-tqt 2 days ago
build_4e.sh Updated examples after commit 61b1be0 to dbus-1-tqt 2 days ago
build_4f.sh Updated examples after commit 61b1be0 to dbus-1-tqt 2 days ago

README.md

dbus-1-tqt-example

PoC to discuss around https://mirror.git.trinitydesktop.org/gitea/TDE/dbus-1-tqt/issues/3 5 7 9 11

All examples are based on the example in dbus-1-tqt for a service providing method “ListSorter”. In examples 4d and 4e below the service is calles “org.example.Service”. In example 4f the service is calles “org.example.Service1” to comply with bluez5 naming conventions.

In example 4d we show how service “org.example.Service” is placed under “/org/example/service”.

In example 4e we show how service “org.example.Service” is placed under object path “/org/example/service”. Another standard DBus service “org.freedesktop.DBus.ObjectManager” is placed unser object path “/”.

In example 4f we show how service “org.example.Service” from example 4d is used asynchronously. The async use of a service has the advantage of non blocking in GUI context.

Overview

Build:
git clone https://mirror.git.trinitydesktop.org/gitea/deloptes/dbus-1-tqt-example
cd dbus-1-tqt-example/4<example>
bash  ../build_4<example>.sh  
Run:
./tqdbusexample
Test for example 4d and 4e:
dbus-send --print-reply --session --dest=org.example.Service / \
   org.freedesktop.DBus.Introspectable.Introspect
dbus-send --print-reply --session --dest=org.example.Service /org \
   org.freedesktop.DBus.Introspectable.Introspect
dbus-send --print-reply --session --dest=org.example.Service /org/example \
   org.freedesktop.DBus.Introspectable.Introspect
dbus-send --print-reply --session --dest=org.example.Service /org/example/service \
   org.freedesktop.DBus.Introspectable.Introspect

dbus-send --print-reply --session --dest=org.example.Service \
  /org/example/service  \
  org.example.Service.ListSorter array:string:"x","a","c","b"

$ dbus-send --print-reply --session --dest=org.example.Service   /org/example/service    org.example.Service.CheckPrimitive int32:-1
method return time=1571079829.536462 sender=:1.42 -> destination=:1.45 serial=7 reply_serial=2
   boolean false
$ dbus-send --print-reply --session --dest=org.example.Service   /org/example/service    org.example.Service.CheckPrimitive int32:1
method return time=1571079832.192439 sender=:1.42 -> destination=:1.46 serial=8 reply_serial=2
   boolean true
Test for example 4f:
dbus-send --print-reply --session --dest=org.example.Service1 / \
   org.freedesktop.DBus.Introspectable.Introspect
dbus-send --print-reply --session --dest=org.example.Service1 /org \
   org.freedesktop.DBus.Introspectable.Introspect
dbus-send --print-reply --session --dest=org.example.Service1 /org/example \
   org.freedesktop.DBus.Introspectable.Introspect
dbus-send --print-reply --session --dest=org.example.Service1 /org/example/service \
   org.freedesktop.DBus.Introspectable.Introspect

$ dbus-send --print-reply --session --dest=org.example.Service1   /org/example/service    \
org.example.Service1.ListSorter1 array:string:"x","a","c","b"

method return time=1571080228.620007 sender=:1.47 -> destination=:1.52 serial=9 reply_serial=2
   array [
      string "a"
      string "b"
      string "c"
      string "x"
   ]

$ dbus-send --print-reply --session --dest=org.example.Service1   /org/example/service    \
org.example.Service1.ListSorter2 array:string:"x","a","c","b"

method return time=1571080234.428228 sender=:1.47 -> destination=:1.53 serial=10 reply_serial=2
   array [
      string "a"
      string "b"
      string "c"
      string "x"
   ]

In another shell

$ ./tqdbusclient
AsyncCallId: 4
Output:      a, b, c, d, x
AsyncCallId: 5
Output:      a, b, c, d, x

Detailed overview

Generate code example 4d

There is only one definitions “test1.xml”. Just run dbusxml2qt3 test1.xml and implement.

Content of the directory

$ ls -1
dbusbaseNode.cpp
dbusbaseNode.h
introspectableInterface.cpp
introspectableInterface.h
serviceInterface.cpp
serviceInterface.h
serviceNode.cpp
serviceNode.h
serviceProxy.cpp
serviceProxy.h
test1.xml
create main.cpp and the service implementation “testservice”

Content of the directory

$ ls -1
dbusbaseNode.cpp
dbusbaseNode.h
introspectableInterface.cpp
introspectableInterface.h
main.cpp
serviceInterface.cpp
serviceInterface.h
serviceNode.cpp
serviceNode.h
serviceProxy.cpp
serviceProxy.h
test1.xml
testservice.cpp
testservice.h
build
$ bash ../build_4d.sh
run
$ ./tqdbusexample
Requesting name 'org.example.Service' successfull
test

See test section in Overview

Generate code example 4e
generate root node
$ dbusxml2qt3 test1.xml
[2019/10/14 19:01:11.171] ClassGenerator: processing interface 'org.freedesktop.DBus.Introspectable'
[2019/10/14 19:01:11.171] ClassGenerator: processing interface 'org.freedesktop.DBus.ObjectManager'
dbusxml2qt3: cannot generate node without class name.

$ dbusxml2qt3 test2.xml
[2019/10/14 19:00:45.004] ClassGenerator: processing interface 'org.example.Service'
[2019/10/14 19:00:45.005] Generating org.freedesktop.DBus.Introspectable on demand

Files generated

dbusbaseNode.cpp
dbusbaseNode.h
introspectableInterface.cpp
introspectableInterface.h
objectmanagerInterface.cpp
objectmanagerInterface.h
objectmanagerProxy.cpp
objectmanagerProxy.h
serviceInterface.cpp
serviceInterface.h
serviceNode.cpp
serviceNode.h
serviceProxy.cpp
serviceProxy.h
test1.xml
test2.xml
create main.cpp and the service implementation “testservice”

Content of the directory

$ ls -1
dbusbaseNode.cpp
dbusbaseNode.h
introspectableInterface.cpp
introspectableInterface.h
main.cpp
objectmanagerInterface.cpp
objectmanagerInterface.h
objectmanagerProxy.cpp
objectmanagerProxy.h
serviceInterface.cpp
serviceInterface.h
serviceNode.cpp
serviceNode.h
serviceProxy.cpp
serviceProxy.h
test1.xml
test2.xml
testservice.cpp
testservice.h
build
$ bash ../build_4e.sh
run
$ ./tqdbusexample
Requesting name 'org.example.Service' successfull
test

See test section in Overview

Generate code example 4f

There is only one definitions “test1.xml”. Just run dbusxml2qt3 test1.xml and implement.

Content of the directory

$ ls -1
dbusbaseNode.cpp
dbusbaseNode.h
introspectableInterface.cpp
introspectableInterface.h
service1Interface.cpp
service1Interface.h
service1Proxy.cpp
service1Proxy.h
serviceNode.cpp
serviceNode.h
test1.xml
create main.cpp and the service implementation “testservice”

Content of the directory

$ ls -1
dbusbaseNode.cpp
dbusbaseNode.h
introspectableInterface.cpp
introspectableInterface.h
main.cpp
service1Interface.cpp
service1Interface.h
service1Proxy.cpp
service1Proxy.h
serviceNode.cpp
serviceNode.h
test1.xml
testservice.cpp
testservice.h
build
$ bash ../build_4f.sh
run
$ ./tqdbusexample
Requesting name 'org.example.Service1' successfull
test

See test section in Overview