mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-06 03:50:08 +02:00
Add support for the callback in python/cffi
This uses one global event handler function on the C level, as enforced by CFFI, and caters for registering a per-context event handeler. A simple fixture for doing this during tests is also implemented.
This commit is contained in:
parent
ee6798ec0e
commit
08689b2a04
4 changed files with 47 additions and 4 deletions
14
python/src/deltachat/__init__.py
Normal file
14
python/src/deltachat/__init__.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from deltachat import capi
|
||||
|
||||
|
||||
_DC_CALLBACK_MAP = {}
|
||||
|
||||
|
||||
@capi.ffi.def_extern()
|
||||
def py_dc_callback(ctx, evt, data1, data2):
|
||||
"""The global event handler.
|
||||
|
||||
CFFI only allows us to set one global event handler, so this one
|
||||
looks up the correct event handler for the given context.
|
||||
"""
|
||||
return _DC_CALLBACK_MAP.get(ctx, lambda *a: 0)
|
Loading…
Add table
Add a link
Reference in a new issue