PDA

View Full Version : Problem in Qt DBus (register service name for system bus connection)



ktchow1
19th April 2012, 03:51
Dear all

I try the Qt4.7 DBus example, including :

- chat room example
- remote car example

using the code and project setting provided with Qt. Session bus is used in both examples, and they work well. But now I would like to change the session bus into system bus, by changing the line : QDBusConnection::sessionBus() into QDBusConnection::systemBus() only, while keeping the rest unchanged. However it doesnt work now. By tracking the programme line by line, I find that it fails to invoke : registerService("xxx.yyy.zzz"). Can anyone help to solve the problem? Does it involve the system bus permission in linux?

thank you very much
best regards
k.t.

Arctus
11th September 2012, 08:33
Old post but I was stuck with the same problem, so for anyone else interested the solution is you need to create a DBus policy conf.

For example:

/etc/dbus-1/system.d/org.kde.foohelper.conf


<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>

<!-- Only user root can own the foo helper -->
<policy user="root">
<allow own="org.kde.foohelper"/>
</policy>

<!-- Allow anyone to call into the service - we'll reject callers using PolicyKit -->
<policy context="default">
<allow send_interface="org.kde.foohelper"/>
<allow receive_sender="org.kde.foohelper"/>
<allow receive_interface="org.kde.foohelper"/>
</policy>

</busconfig>


http://techbase.kde.org/Development/Tutorials/PolicyKit/Helper_HowTo#The_DBus_policy_file

http://dbus.freedesktop.org/doc/dbus-daemon.1.html#lbAF