mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
good bye global plugin manager ... we only do per-account object plugin_management for now
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
""" Hooks for python bindings """
|
||||
""" Hooks for Python bindings to Delta Chat Core Rust CFFI"""
|
||||
|
||||
import pluggy
|
||||
|
||||
name = "deltachat"
|
||||
__all__ = ["account_hookspec", "account_hookimpl", "AccountHookSpecs"]
|
||||
|
||||
hookspec = pluggy.HookspecMarker(name)
|
||||
hookimpl = pluggy.HookimplMarker(name)
|
||||
_plugin_manager = None
|
||||
_account_name = "deltachat-account"
|
||||
account_hookspec = pluggy.HookspecMarker(_account_name)
|
||||
account_hookimpl = pluggy.HookimplMarker(_account_name)
|
||||
|
||||
|
||||
def get_plugin_manager():
|
||||
global _plugin_manager
|
||||
if _plugin_manager is None:
|
||||
_plugin_manager = pluggy.PluginManager(name)
|
||||
_plugin_manager.add_hookspecs(DeltaChatHookSpecs)
|
||||
return _plugin_manager
|
||||
class AccountHookSpecs:
|
||||
""" per-Account-instance hook specifications.
|
||||
|
||||
Account hook implementations need to be registered with an Account instance.
|
||||
"""
|
||||
@classmethod
|
||||
def _make_plugin_manager(cls):
|
||||
pm = pluggy.PluginManager(_account_name)
|
||||
pm.add_hookspecs(cls)
|
||||
return pm
|
||||
|
||||
class DeltaChatHookSpecs:
|
||||
""" Plugin Hook specifications for Python bindings to Delta Chat CFFI. """
|
||||
|
||||
@hookspec
|
||||
def process_low_level_event(self, account, event_name, data1, data2):
|
||||
@account_hookspec
|
||||
def process_low_level_event(self, event_name, data1, data2):
|
||||
""" process a CFFI low level events for a given account. """
|
||||
|
||||
Reference in New Issue
Block a user