Commit Graph

8 Commits

Author SHA1 Message Date
patrick96 325ef4c3b3 Cleanup builder
Removes unused methods and fields
2022-03-14 22:58:01 +01:00
patrick96 1a59599388 fix(modules): Avoid downcast in module constructor
The previous CAST_MOD(Impl) for the action_router constructor was
illegal because `this` is not yet of type Impl (because the subclass
constructor has not run yet).

The action_router now accepts std::function for its callbacks.

Fixes #2519
2021-10-03 03:18:39 +02:00
Patrick Ziegler 26be83f893
module: Implement action router (#2336)
* module: Implement proof of concept action router

Action implementation inside module becomes much cleaner because each
module just registers action names together with a callback (pointer to
member function) and the action router does the rest.

* Make input function final

This forces all modules to use the action router

* modules: Catch exceptions in action handlers

* Use action router for all modules

* Use action_ prefix for function names

The mpd module's 'stop' action overwrote the base module's stop function
which caused difficult to debug behavior.

To prevent this in the future we now prefix each function that is
responsible for an action with 'action_'

* Cleanup

* actions: Throw exception when re-registering action

Action names are unique inside modules. Unfortunately there is no way to
ensure this statically, the next best thing is to crash the module and
let the user know that this is a bug.

* Formatting

* actions: Ignore data for actions without data

This is the same behavior as before.

* action_router: Write tests
2021-01-04 10:25:52 +01:00
patrick96 9fb75779f3 Incorporate reviews 2020-11-26 20:53:53 +01:00
patrick96 af5af1e497 Fix unused argument warning 2020-11-26 20:53:53 +01:00
patrick96 bc1b86c584 actions: Separate data from action string
Modules now no longer need to manually parse the action string and
extract data from it.
2020-11-26 20:53:53 +01:00
patrick96 ae2350167b actions: Switch all modules over to new system
All modules now expose their actions as public static constants

Issues: The menu module no longer closes when an item is clicked (before
it would intercept any executed command and look if it matches one of
its exec commands)
2020-11-26 20:53:53 +01:00
Michael Carlberg e0688307f3 wip(systray): Add module base 2017-01-01 21:28:28 +01:00