Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signal handler for unknwon object path #18

Open
knobo opened this issue Oct 24, 2018 · 2 comments
Open

Signal handler for unknwon object path #18

knobo opened this issue Oct 24, 2018 · 2 comments

Comments

@knobo
Copy link

knobo commented Oct 24, 2018

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.

@knobo
Copy link
Author

knobo commented Oct 25, 2018

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.

@knobo
Copy link
Author

knobo commented Oct 26, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant