|
2 months ago | |
---|---|---|
4d | 4 years ago | |
4e | 4 years ago | |
4f | 4 years ago | |
50 | 4 years ago | |
60 | 2 months ago | |
.gitignore | 5 years ago | |
LICENSE | 5 years ago | |
README.md | 2 months ago | |
build_4d.sh | 2 months ago | |
build_4e.sh | 2 months ago | |
build_4f.sh | 2 months ago | |
build_50.sh | 2 months ago | |
build_60.sh | 2 months 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 Freedesktop.org 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 under 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.
In example 50 we show how multi node service could be implemented.
In example 60 we show how service "org.example.Service" from example 4d is used with properties. The exercise here is to show how properties interface could be implemented.
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"
Test for example 60:
dbus-send --session --print-reply --dest=org.example.Service \
/org/example/service \
org.example.Service.GetValue
method return time=1689208101.372665 sender=:1.206 -> destination=:1.207 serial=5 reply_serial=2
uint64 123456
Testing with the client
./tqdbusexample_client
[2023/07/13 08:22:01.935] GetValue returned: 123456
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
Generate code example 60
generate root node
# generate the dbus classes
$ dbusxml2qt3 test1.xml
[2023/07/13 20:47:20.787] ClassGenerator: processing interface 'org.example.Service'
[2023/07/13 20:47:20.787] ClassGenerator: processing interface 'org.freedesktop.DBus.Properties'
[2023/07/13 20:47:20.787] Properties not yet supported for interfaces
[2023/07/13 20:47:20.788] Generating org.freedesktop.DBus.Introspectable on demand
Files generated
dbusbaseNode.cpp
dbusbaseNode.h
introspectableInterface.cpp
introspectableInterface.h
propertiesInterface.cpp
propertiesInterface.h
propertiesProxy.cpp
propertiesProxy.h
serviceInterface.cpp
serviceInterface.h
serviceNode.cpp
serviceNode.h
serviceProxy.cpp
serviceProxy.h
create main.cpp and the service implementation "testservice"
Also a client example is provided here
Content of the directory
$ ls -1
dbusbaseNode.cpp
dbusbaseNode.h
exampleclient.cpp
exampleclient.h
introspectableInterface.cpp
introspectableInterface.h
main.cpp
propertiesInterface.cpp
propertiesInterface.h
propertiesProxy.cpp
propertiesProxy.h
serviceInterface.cpp
serviceInterface.h
serviceNode.cpp
serviceNode.h
serviceProxy.cpp
serviceProxy.h
test1.xml
testservice.cpp
testservice.h
build
$ bash ../build_60.sh
run
$ ./tqdbusexample
Requesting name 'org.example.Service' successfull
test
See test section in Overview