Skip to content

Refactor inter-plugin callback handling#1332

Merged
cschramm merged 4 commits intoblueman-project:masterfrom
cschramm:plugincallbacks
Aug 18, 2020
Merged

Refactor inter-plugin callback handling#1332
cschramm merged 4 commits intoblueman-project:masterfrom
cschramm:plugincallbacks

Conversation

@cschramm
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread blueman/gui/manager/ManagerDeviceMenu.py Outdated

if ret is not None:
args = ret
def get_loaded_plugins(self, protocol: Type[_U]) -> Iterable[_U]:
Copy link
Copy Markdown
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...

Comment thread blueman/plugins/applet/DBusService.py
Comment thread blueman/plugins/applet/PPPSupport.py Outdated
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
Copy Markdown
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.

Comment thread blueman/plugins/applet/NMPANSupport.py
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