[Interest] Using QDBusConnection::sessionBus()

Thiago Macieira thiago.macieira at intel.com
Mon Dec 21 14:01:18 CET 2015


On Sunday 20 December 2015 11:01:56 Bernhard Lindner wrote:
> Thanks Thiago that you actually responded to that confusing question. I was
> exhausted and didn't add the most important information. Let me try again
> after getting some sleep:
> 
> I intended to use QDBusConnection::sessionBus() (Kubuntu 15.10 running
> Qt5.4.2) to access the systemd user session bus like this:
> 
> QDBusConnection dBus = QDBusConnection::sessionBus();
> QDBusInterface systemDManagerInterface("org.freedesktop.systemd1", "/org/
> freedesktop/systemd1", "org.freedesktop.systemd1.Manager", dBus);
> 
> That creates an invalid interface. Using systemBus() my code works fine but
> I need to access the user session bus not the system bus.

Bus is the connection valid? Is it connected?

It's possible that you're getting an invalid interface because there is no 
service called org.freedesktop.systemd1 on your session bus. I don't have one 
here.

> I tried a lot of things and this is what I could observe:
> 
> 1 ."busctl --user | grep systemd" lists "org.freedesktop.systemd1" as
> "(activatable)"

Same here.

> 2. "qdbusviewer" does not list something that contains "systemd" in its
> "Session Bus" tab.

Same here. But if you call ListActivatableNames, it's there.

$ qdbus org.freedesktop.DBus / org.freedesktop.DBus.ListActivatableNames | 
grep systemd1
org.freedesktop.systemd1

> I am pretty new to linux and totally new to systemd and D-Bus. And confused.
> Any ideas why the above code does not return a valid systemd bus interface
> using sessionBus()?

>From what I can tell here, you're doing nothing wrong. The bug is in systemd.

If I try to call it directly:
$ qdbus org.freedesktop.systemd1                                           
Error: org.freedesktop.DBus.Error.Spawn.ChildExited
Process org.freedesktop.systemd1 exited with status 1

It shouldn't exit. It did. Therefore, systemd issue.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list