hypfvieh / dbus-java

Improved version of java DBus library provided by freedesktop.org (https://dbus.freedesktop.org/doc/dbus-java/)
https://hypfvieh.github.io/dbus-java/
MIT License
185 stars 73 forks source link

Receive arbitrary signals #39

Closed rm5248 closed 5 years ago

rm5248 commented 5 years ago

For a project that I'm working on, I need to have the ability to listen to arbitrary signals on the bus. A few years ago, I patched dbus-java(2.7) to give it this capability. I just tried with the current version of dbus-java and it won't work correctly, due to how signals work(you need to create a class in the correct package for it to be called correctly). Two questions with this:

  1. Does this make sense as a feature to add? It's needed for my case, but I don't know if it makes sense to add to the library. Most other dbus implementations do provide a way to listen to arbitrary signals.
  2. Assuming it makes sense, the way that I implemented it before was to add in AbstractConnection a new variable for the custom signals, the same type as handledSignals and then looks at these custom handlers after looking at the normal(typed) handlers.

I can do the implementation, I just wanted to get feedback before I started on this.

hypfvieh commented 5 years ago

Sounds good to me. I think this feature maybe useful for other cases as well. If you do the implementation and send a PR, I'll take a look and merge it afterwards.

hypfvieh commented 5 years ago

Thanks for your PR. I cleaned it up a bit and merged it.

I also removed the sendSignal method, as this method is a copy of sendMessage. Instead I updated the javadoc of sendMessage (renaming this method would break the compatibility with older code). I don't think we should add more methods to the AbstractConnection class if not necessary.

rm5248 commented 5 years ago

That all looks good to me. I will continue to test it out on my end to ensure that everything is working appropriately.