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

Refactor inter-plugin callback handling #1332

Merged
merged 4 commits into from
Aug 18, 2020

Conversation

cschramm
Copy link
Member

@cschramm cschramm commented Aug 7, 2020

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.

@cschramm
Copy link
Member Author

cschramm commented Aug 8, 2020

😠 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...

@cschramm cschramm force-pushed the plugincallbacks branch 5 times, most recently from 23cedca to eca0de7 Compare August 9, 2020 16:47
@cschramm cschramm marked this pull request as ready for review August 9, 2020 17:06
@cschramm cschramm requested a review from infirit August 9, 2020 17:06
Copy link
Contributor

@infirit infirit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

blueman/gui/manager/ManagerDeviceMenu.py Outdated Show resolved Hide resolved

if ret is not None:
args = ret
def get_loaded_plugins(self, protocol: Type[_U]) -> Iterable[_U]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

blueman/plugins/applet/DBusService.py Show resolved Hide resolved
blueman/plugins/applet/PPPSupport.py Outdated Show resolved Hide resolved
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For alls these any() I find this very hard to read because the if continues on a new line.

blueman/plugins/applet/NMPANSupport.py Show resolved Hide resolved
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.
@cschramm cschramm merged commit d7c0113 into blueman-project:master Aug 18, 2020
@cschramm cschramm deleted the plugincallbacks branch August 18, 2020 17:19
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

Successfully merging this pull request may close these issues.

2 participants