[Interest] How do i monitor DBus functions (not signals)
Mark Gaiser
markg85 at gmail.com
Wed Jan 13 21:19:33 CET 2016
Hi,
I'm trying to monitor "org.freedesktop.Notifications" for the notifications
(see [1] for reference) that broadcasted from there. Every notification
ends up in a "Notify" method on that dbus interface.
I'm trying to monitor that, but kinda fail at it... I can monitor the
notifications with dbus-monitor
"interface='org.freedesktop.Notifications',member='Notify',type='method_call',eavesdrop='true'",
doing the same in code is not firing the slot i'd like it to call..
The code:
...
QDBusConnection::sessionBus().connect("",
"",
"org.freedesktop.Notifications",
"Notify",
this,
SLOT(notify(QDBusMessage)));
// This is the exact same match line as from the command.
QString matchString =
"interface='org.freedesktop.Notifications',member='Notify',type='method_call',eavesdrop='true'";
QDBusInterface busInterface("org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus");
busInterface.call("AddMatch", matchString);
...
In the connect line the "this" object is a simple one function class
inheriting from QObject with a "notify(QDBusMessage message)" member as
public slot.
In the app i've set the env variable: QDBUS_DEBUG=1 (for debugging purpose).
If i run my app and send a notify message like so:
notify-send -a "Chrome" "aaa"
Then i am getting console output in my app like this:
QDBusConnectionPrivate(0x623760) got message (signal):
QDBusMessage(type=MethodCall, service=":1.522",
path="/org/freedesktop/Notifications",
interface="org.freedesktop.Notifications", member="Notify",
signature="susssasa{sv}i", contents=("Chrome", 0, "", "aaa", "", {},
[Argument: a{sv} {"urgency" = [Variant(uchar): 1]}], -1) )
QDBusConnectionPrivate(0x623760) sending message (no reply):
QDBusMessage(type=Error, service="", error
name="org.freedesktop.DBus.Error.UnknownObject", error message="No such
object path '/org/freedesktop/Notifications'", signature="", contents=() )
But the slot notify(QDBusMessage) is not being called...
What am i doing wrong?
I see the error: "No such object path '/org/freedesktop/Notifications", but
if i add this to my code:
QDBusConnection::sessionBus().registerObject("/org/freedesktop/Notifications",
"org.freedesktop.Notifications", this);
I get roughly the same dbus message, but with this error:
No such interface 'org.freedesktop.Notifications' at object path
'/org/freedesktop/Notifications'
And i'm not even sure if i need to look at that error at all...
I hope someone with dbus knowledge can point me in the right direction for
this?
Thank you,
Mark
[1] http://www.galago-project.org/specs/notification/0.9/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160113/b541b97c/attachment.html>
More information about the Interest
mailing list