0
我目前正在使用GDBus与ConsoleKit进行通话。我使用ConsoleKit2 XML文件和gdbus-codegen
来生成代码。一切工作正常。但是,我怎样才能检查一个对象是否存在?例如,我想查看是否有/org/freedesktop/ConsoleKit/Session2
(只是一个例子,我知道我可以枚举Seat对象中的所有会话)。检查D-Bus对象是否存在
我尝试使用org.freedesktop.DBus.Peer.Ping
功能,但将返回
dbus-send --system --print-reply --reply-timeout=2000 --type=method_call --dest=org.freedesktop.DBus /org/freedesktop/ConsoleKit/Seat1 org.freedesktop.DBus.Peer.Ping
Error org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 1 matched rules; type="method_call", sender=":1.168" (uid=1000 pid=18279 comm="dbus-send --system --print-reply --reply-timeout=2") interface="org.freedesktop.DBus.Peer" member="Ping" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)
谢谢你的帮助。第二个想法也出现在我的脑海里,但我认为它会很难看。然后它会是数字1.我知道它不是确定性的,我只是使用硬编码路径作为例子。我也知道logind是这样做的新方式,我的应用程序中的下一步将是logind支持,但由于某些发行版仍然使用consolekit(例如,Gentoo Linux仍然可以使用Consolekit),所以我想同时支持这两种。再次感谢你。 – Nidhoegger