Refactor inter-plugin callback handling#1332
Merged
cschramm merged 4 commits intoblueman-project:masterfrom Aug 18, 2020
Merged
Refactor inter-plugin callback handling#1332cschramm merged 4 commits intoblueman-project:masterfrom
cschramm merged 4 commits intoblueman-project:masterfrom
Conversation
77d8bf6 to
1accd27
Compare
Member
Author
|
😠 Gonna kick out Python 3.6 soon-ish. 🏈 Edit: Worked around it by not introducing a Generic at all. Curious how long that'll hold... |
23cedca to
eca0de7
Compare
eca0de7 to
eaa4984
Compare
infirit
reviewed
Aug 10, 2020
Contributor
infirit
left a comment
There was a problem hiding this comment.
TBH I could not understand what you were doing at first but figured it out. It is definitely an improvement over the callback, not sure how these will work out in the long run but we'll see 😄 .
In general ok just a couple questions and comments.
|
|
||
| if ret is not None: | ||
| args = ret | ||
| def get_loaded_plugins(self, protocol: Type[_U]) -> Iterable[_U]: |
Contributor
There was a problem hiding this comment.
I don't like the name because it does a bit more than just get loaded plugins, it get loaded plugins with a certain class. But I can't think of a better one...
| elif isinstance(service, SerialService) and 'PPPSupport' in self.parent.Plugins.get_loaded(): | ||
| if any(plugin.service_connect_handler(service, ok, err) | ||
| for plugin in self.parent.Plugins.get_loaded_plugins(ServiceConnectHandler)): | ||
| pass |
Contributor
There was a problem hiding this comment.
For alls these any() I find this very hard to read because the if continues on a new line.
Use mixins for dynamically defining functionality instead of dynamically adding it to / removing it from the AppletPlugin and dynamically calling it. PluginManager now only provides a convenience way of getting loaded plugins that are instances of a specific mixin and calls are done directly without any necessity for fancy call handling as the caller can do whatever it wants to do directly.
* Move logic from PowerManager.on_power_state_query into update_power_state. * Move logic from StatusIcon.on_power_state_changed into PowerManager.update_power_state, similar to what ShowConnected does. PowerManager depends on StatusIcons, so this is fine. * Drop PowerManager.on_power_state_change_requested which has no effect. * Drop SerialManager.rfcomm_connect_handler as its logic is already present in DBusService.connect_service.
eaa4984 to
a7ccce0
Compare
a7ccce0 to
2aa0378
Compare
infirit
approved these changes
Aug 18, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use mixins for dynamically defining functionality instead of dynamically adding it to / removing it from the AppletPlugin and dynamically calling it. PluginManager now only provides a convenience way of getting loaded plugins that are instances of a specific mixin and calls are done directly without any necessity for fancy call handling as the caller can do whatever it wants to do directly.
Depends on #1329 (due to many conflicting code locations) and currently does not work due to circular dependencies at least between StatusIcon and PowerManager.