mirror of
https://github.com/chatmail/core.git
synced 2026-05-21 07:46:31 +03:00
python: move get_dc_event_name() to events
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
- jsonrpc: add `is_broadcast` property to `ChatListItemFetchResult` #3584
|
- jsonrpc: add `is_broadcast` property to `ChatListItemFetchResult` #3584
|
||||||
- jsonrpc: add `was_seen_recently` property to `ChatListItemFetchResult`, `FullChat` and `Contact` #3584
|
- jsonrpc: add `was_seen_recently` property to `ChatListItemFetchResult`, `FullChat` and `Contact` #3584
|
||||||
- jsonrpc: add `webxdc_info` property to `Message` #3588
|
- jsonrpc: add `webxdc_info` property to `Message` #3588
|
||||||
|
- python: move `get_dc_event_name()` from `deltachat` to `deltachat.events` #3564
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
- order contact lists by "last seen";
|
- order contact lists by "last seen";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import sys
|
|||||||
|
|
||||||
from pkg_resources import DistributionNotFound, get_distribution
|
from pkg_resources import DistributionNotFound, get_distribution
|
||||||
|
|
||||||
from . import capi, const, events, hookspec # noqa
|
from . import capi, events, hookspec # noqa
|
||||||
from .account import Account, get_core_info # noqa
|
from .account import Account, get_core_info # noqa
|
||||||
from .capi import ffi # noqa
|
from .capi import ffi # noqa
|
||||||
from .chat import Chat # noqa
|
from .chat import Chat # noqa
|
||||||
@@ -17,14 +17,6 @@ except DistributionNotFound:
|
|||||||
__version__ = "0.0.0.dev0-unknown"
|
__version__ = "0.0.0.dev0-unknown"
|
||||||
|
|
||||||
|
|
||||||
def get_dc_event_name(integer, _DC_EVENTNAME_MAP={}):
|
|
||||||
if not _DC_EVENTNAME_MAP:
|
|
||||||
for name in dir(const):
|
|
||||||
if name.startswith("DC_EVENT_"):
|
|
||||||
_DC_EVENTNAME_MAP[getattr(const, name)] = name
|
|
||||||
return _DC_EVENTNAME_MAP[integer]
|
|
||||||
|
|
||||||
|
|
||||||
def register_global_plugin(plugin):
|
def register_global_plugin(plugin):
|
||||||
"""Register a global plugin which implements one or more
|
"""Register a global plugin which implements one or more
|
||||||
of the :class:`deltachat.hookspec.Global` hooks.
|
of the :class:`deltachat.hookspec.Global` hooks.
|
||||||
|
|||||||
@@ -8,14 +8,21 @@ import traceback
|
|||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from queue import Empty, Queue
|
from queue import Empty, Queue
|
||||||
|
|
||||||
import deltachat
|
from . import const
|
||||||
|
|
||||||
from .capi import ffi, lib
|
from .capi import ffi, lib
|
||||||
from .cutil import from_optional_dc_charpointer
|
from .cutil import from_optional_dc_charpointer
|
||||||
from .hookspec import account_hookimpl
|
from .hookspec import account_hookimpl
|
||||||
from .message import map_system_message
|
from .message import map_system_message
|
||||||
|
|
||||||
|
|
||||||
|
def get_dc_event_name(integer, _DC_EVENTNAME_MAP={}):
|
||||||
|
if not _DC_EVENTNAME_MAP:
|
||||||
|
for name in dir(const):
|
||||||
|
if name.startswith("DC_EVENT_"):
|
||||||
|
_DC_EVENTNAME_MAP[getattr(const, name)] = name
|
||||||
|
return _DC_EVENTNAME_MAP[integer]
|
||||||
|
|
||||||
|
|
||||||
class FFIEvent:
|
class FFIEvent:
|
||||||
def __init__(self, name: str, data1, data2):
|
def __init__(self, name: str, data1, data2):
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -239,7 +246,7 @@ class EventThread(threading.Thread):
|
|||||||
data1 = lib.dc_event_get_data1_int(event)
|
data1 = lib.dc_event_get_data1_int(event)
|
||||||
# the following code relates to the deltachat/_build.py's helper
|
# the following code relates to the deltachat/_build.py's helper
|
||||||
# function which provides us signature info of an event call
|
# function which provides us signature info of an event call
|
||||||
evt_name = deltachat.get_dc_event_name(evt)
|
evt_name = get_dc_event_name(evt)
|
||||||
if lib.dc_event_has_string_data(evt):
|
if lib.dc_event_has_string_data(evt):
|
||||||
data2 = from_optional_dc_charpointer(lib.dc_event_get_data2_str(event))
|
data2 = from_optional_dc_charpointer(lib.dc_event_get_data2_str(event))
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user