Python / C++ application D-Bus usage issues

Tanu Kaskinen tanuk at iki.fi
Mon Dec 17 21:44:04 PST 2012


On Mon, 2012-12-17 at 21:34 -0800, Kip Warner wrote:
> On Tue, 2012-12-18 at 07:22 +0200, Tanu Kaskinen wrote:
> > No. You only need proxy objects for doing method calls on remote
> > objects. You *can* use proxy objects also for receiving signals, but
> > as is clear from the tutorial, that is not necessary. 
> 
> Hey Tanu. Ok, I'm almost there. So I replaced the following in the
> Python application to receive signals...
> 
> myProjectProxy.connect_to_signal(
>     DBUS_SIGNAL_NOTIFICATION, 
>     self.onDBusSignal, 
>     dbus_interface=DBUS_INTERFACE)
> 
> ...with this...
> 
> self._sessionBus.add_signal_receiver(
>     handler_function=self.onDBusSignal,
>     signal_name="SomeSignal",
>     dbus_interface=DBUS_INTERFACE,
>     bus_name=DBUS_SERVICE_NAME,
>     path=DBUS_OBJECT_PATH)
> 
> I think that's right, with the constants as such:
> 
> DBUS_SERVICE_NAME = "com.myproject.MyProjectService"
> DBUS_OBJECT_PATH = "/com/myproject/MyProjectObject"
> DBUS_INTERFACE = "com.myproject.MyProjectInterface"
> 
> Does that look right?

Looks sane to me. I didn't do any checks against the
add_signal_receiver() API or your C++ code, though.

> I'd test it, but I can't because the C++
> application still needs to answer the Introspect message which I'm not
> sure how to do yet.

If you don't use any proxy objects, there won't be anyone calling the
Introspect method, so you don't need to implement support for that. (Or
I don't know if the add_signal_receiver() implementation also needs
introspection support, but I don't see any reason why it would need
that.)

-- 
Tanu



More information about the dbus mailing list