Skip to content

Support a destination keyword for signals

Add a new keyword to the signal decorator to allow specifying the destination for a signal (rather than the default NULL). This allows for signals to be recieved by callers that specify GLib's DBUS_SIGNAL_FLAGS_NO_MATCH_RULE, used by libportal for example.

Usage of the keyword:

   @dbus.service.signal("org.example.Sample", signature="a", destination_keyword="dest")
   def SomeSignal(self, value):
	   pass

And the invocation to send to a specific destination:

   myobj.SomeSignal(1, dest=":1.23")

The example part doesn't need to be merged, that was more for testing the signal and showing how it can be used. dbus-monitor sees these as:

signal time=1653614956.679658 sender=:1.1702 -> destination=org.freedesktop.DBus serial=3 path=/SomeObject; interface=com.example.SampleInterface; member=PingSignal                               
   uint32 1                                                                                                                                                                                        
signal time=1653614957.680001 sender=:1.1702 -> destination=(null destination) serial=4 path=/SomeObject; interface=com.example.SampleInterface; member=PingSignal                                 
   uint32 2   

I'm a bit confused about the test cases here for signals, I'd appreciate a bit of clarification where a test like this would go, happy to add it then.

Merge request reports