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 823aceded3
Fix README mark down formatting
2 years ago
4d Examples updated after dbus-1-tqt commit 8276da2 2 years ago
4e Examples updated after dbus-1-tqt commit 8276da2 2 years ago
4f Examples updated after dbus-1-tqt commit 8276da2 2 years ago
50 Examples updated after dbus-1-tqt commit 8276da2 2 years ago
.gitignore Initial commit 3 years ago
LICENSE Initial commit 3 years ago
README.md Fix README mark down formatting 2 years ago
build_4d.sh Updated examples after commit 61b1be0 to dbus-1-tqt 3 years ago
build_4e.sh Examples updated after dbus-1-tqt commit 8276da2 2 years ago
build_4f.sh Updated examples after commit 61b1be0 to dbus-1-tqt 3 years ago
build_50.sh Example 50 after dbus-1-tqt commit d8f3b1e0af 2 years ago

README.md

dbus-1-tqt-example

PoC to discuss around dbus-1-tqt dbusxml2qt3

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

Test for example 50:

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/node1 \
   org.freedesktop.DBus.Introspectable.Introspect
dbus-send --print-reply --session --dest=org.example.service /org/example/service/node2 \
   org.freedesktop.DBus.Introspectable.Introspect
dbus-send --print-reply --session --dest=org.example.service /org/example/service/node3 \
   org.freedesktop.DBus.Introspectable.Introspect


dbus-send --print-reply --session --dest=org.example.service \
  /org/example/service/node1  \
  org.example.service.Service1.ListSorter array:string:"x","a","c","b"
  
dbus-send --print-reply --session --dest=org.example.service \
  /org/example/service/node2  \
  org.example.service.Service2.ListSorter array:string:"x","a","c","b"
  
dbus-send --print-reply --session --dest=org.example.service \
  /org/example/service/node3  \
  org.example.service.Service3.ListSorter array:string:"x","a","c","b"

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

# will generate only the root node
$ dbusxml2qt3 -n rootNode -c RootNode test1.xml
[2020/02/23 22:44:55.076] ClassGenerator: processing interface 'org.freedesktop.DBus.Introspectable'
[2020/02/23 22:44:55.076] ClassGenerator: processing interface 'org.freedesktop.DBus.ObjectManager'

# will generate the interface and proxy classes for the services in the 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
rootNode.cpp
rootNode.h
serviceInterface.cpp
serviceInterface.h
serviceNode.cpp
serviceNode.h
serviceProxy.cpp
serviceProxy.h

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
rootNode.cpp
rootNode.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

Generate code example 50

$ dbusxml2qt3 org.example.service.xml
[2020/02/22 21:35:56.346] ClassGenerator: processing interface 'org.freedesktop.DBus.Introspectable'
[2020/02/22 21:35:56.346] ClassGenerator: processing interface 'org.freedesktop.DBus.ObjectManager'

ls -1
dbusbaseNode.cpp
dbusbaseNode.h
objectmanagerInterface.cpp
objectmanagerInterface.h
objectmanagerProxy.cpp
objectmanagerProxy.h
org.example.service.node1.xml
org.example.service.node2.xml
org.example.service.node3.xml
org.example.service.xml
serviceNode.cpp
serviceNode.h

$ dbusxml2qt3 org.example.service.node1.xml
[2020/02/22 21:36:19.626] ClassGenerator: processing interface 'org.example.service.Service1'
[2020/02/22 21:36:19.627] Generating org.freedesktop.DBus.Introspectable on demand

ls -1
dbusbaseNode.cpp
dbusbaseNode.h
introspectableInterface.cpp
introspectableInterface.h
node1Node.cpp
node1Node.h
objectmanagerInterface.cpp
objectmanagerInterface.h
objectmanagerProxy.cpp
objectmanagerProxy.h
org.example.service.node1.xml
org.example.service.node2.xml
org.example.service.node3.xml
org.example.service.xml
service1Interface.cpp
service1Interface.h
service1Proxy.cpp
service1Proxy.h
serviceNode.cpp
serviceNode.h


$ dbusxml2qt3 org.example.service.node2.xml
[2020/02/22 21:36:37.473] ClassGenerator: processing interface 'org.example.service.Service2'
[2020/02/22 21:36:37.474] Generating org.freedesktop.DBus.Introspectable on demand

ls -1
dbusbaseNode.cpp
dbusbaseNode.h
introspectableInterface.cpp
introspectableInterface.h
node1Node.cpp
node1Node.h
node2Node.cpp
node2Node.h
objectmanagerInterface.cpp
objectmanagerInterface.h
objectmanagerProxy.cpp
objectmanagerProxy.h
org.example.service.node1.xml
org.example.service.node2.xml
org.example.service.node3.xml
org.example.service.xml
service1Interface.cpp
service1Interface.h
service1Proxy.cpp
service1Proxy.h
service2Interface.cpp
service2Interface.h
service2Proxy.cpp
service2Proxy.h
serviceNode.cpp
serviceNode.h

$ dbusxml2qt3 org.example.service.node3.xml
[2020/02/22 21:36:53.078] ClassGenerator: processing interface 'org.example.service.Service3'
[2020/02/22 21:36:53.079] Generating org.freedesktop.DBus.Introspectable on demand

ls -1
dbusbaseNode.cpp
dbusbaseNode.h
introspectableInterface.cpp
introspectableInterface.h
node1Node.cpp
node1Node.h
node2Node.cpp
node2Node.h
node3Node.cpp
node3Node.h
objectmanagerInterface.cpp
objectmanagerInterface.h
objectmanagerProxy.cpp
objectmanagerProxy.h
org.example.service.node1.xml
org.example.service.node2.xml
org.example.service.node3.xml
org.example.service.xml
service1Interface.cpp
service1Interface.h
service1Proxy.cpp
service1Proxy.h
service2Interface.cpp
service2Interface.h
service2Proxy.cpp
service2Proxy.h
service3Interface.cpp
service3Interface.h
service3Proxy.cpp
service3Proxy.h
serviceNode.cpp
serviceNode.h

create main.cpp and the service implementations "testservice"

main.cpp
testservice.cpp
testservice.h

build

$ bash ../build_50.sh

run

$ ./tqdbusexample
[2020/02/22 21:19:54.621] Requesting name 'org.example.service' successfull

test

See test section in Overview