dbus
dbus copied to clipboard
Signal handler for unknwon object path
How do I make signal handler for signals where I don't know the object path? Like for example when ofono notifies about a new phone connected.
For now I'm going to do something like this:
(define-dbus-object mobile
(:path "*DEFAULT HANDLER*"))
(defmethod dbus/publish::missing-handler :around ((message dbus/messages:signal-message) connection)
(let* ((member (dbus/publish::full-member-name
(dbus/messages::message-interface message)
(dbus/messages::message-member message)))
(signal-handlers (dbus/publish::dbus-object-signal-handlers
(dbus/publish::require-dbus-object 'mobile)))
(handler (gethash member signal-handlers))
(object (dbus/publish::require-dbus-object 'mobile)))
(if handler
(dbus/publish::dispatch-message message object connection)
;; Maybe auto generate an object and handlers at this point
(call-next-method))))
But I hope the api could be extended to handle situations like this.
I might rewrite publish to make members and signals match (or (service interface method path) (service interface method) (service method path) (service method) (service path) (service)).
A signal will match the most specific one So if I define a signal handler for (service), it can work as a catch all handler.