mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
rename hooks to use "ac_" (account) and "dc_" (global)
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
- introduced PerAccount and Global hooks that plugins can implement
|
- introduced PerAccount and Global hooks that plugins can implement
|
||||||
|
|
||||||
- introduced `member_added()` and `member_removed()` plugin events.
|
- introduced `ac_member_added()` and `ac_member_removed()` plugin events.
|
||||||
|
|
||||||
- introduced two documented examples for an echo and a group-membership
|
- introduced two documented examples for an echo and a group-membership
|
||||||
tracking plugin.
|
tracking plugin.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from deltachat import account_hookimpl, run_cmdline
|
|||||||
|
|
||||||
class EchoPlugin:
|
class EchoPlugin:
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def process_incoming_message(self, message):
|
def ac_incoming_message(self, message):
|
||||||
print("process_incoming message", message)
|
print("process_incoming message", message)
|
||||||
if message.text.strip() == "/quit":
|
if message.text.strip() == "/quit":
|
||||||
message.account.shutdown()
|
message.account.shutdown()
|
||||||
@@ -18,8 +18,8 @@ class EchoPlugin:
|
|||||||
message.chat.send_text("echoing from {}:\n{}".format(addr, text))
|
message.chat.send_text("echoing from {}:\n{}".format(addr, text))
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def process_message_delivered(self, message):
|
def ac_message_delivered(self, message):
|
||||||
print("process_message_delivered", message)
|
print("ac_message_delivered", message)
|
||||||
|
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from deltachat import account_hookimpl, run_cmdline
|
|||||||
|
|
||||||
class GroupTrackingPlugin:
|
class GroupTrackingPlugin:
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def process_incoming_message(self, message):
|
def ac_incoming_message(self, message):
|
||||||
print("process_incoming message", message)
|
print("process_incoming message", message)
|
||||||
if message.text.strip() == "/quit":
|
if message.text.strip() == "/quit":
|
||||||
message.account.shutdown()
|
message.account.shutdown()
|
||||||
@@ -18,18 +18,18 @@ class GroupTrackingPlugin:
|
|||||||
message.chat.send_text("echoing from {}:\n{}".format(addr, text))
|
message.chat.send_text("echoing from {}:\n{}".format(addr, text))
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def configure_completed(self, success):
|
def ac_configure_completed(self, success):
|
||||||
print("*** configure_completed:", success)
|
print("*** ac_configure_completed:", success)
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def member_added(self, chat, contact):
|
def ac_member_added(self, chat, contact):
|
||||||
print("*** member_added", contact.addr, "from", chat)
|
print("*** ac_member_added", contact.addr, "from", chat)
|
||||||
for member in chat.get_contacts():
|
for member in chat.get_contacts():
|
||||||
print("chat member: {}".format(member.addr))
|
print("chat member: {}".format(member.addr))
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def member_removed(self, chat, contact):
|
def ac_member_removed(self, chat, contact):
|
||||||
print("*** member_removed", contact.addr, "from", chat)
|
print("*** ac_member_removed", contact.addr, "from", chat)
|
||||||
|
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ def test_group_tracking_plugin(acfactory, lp):
|
|||||||
ac1, ac2 = acfactory.get_two_online_accounts(quiet=True)
|
ac1, ac2 = acfactory.get_two_online_accounts(quiet=True)
|
||||||
|
|
||||||
botproc.fnmatch_lines("""
|
botproc.fnmatch_lines("""
|
||||||
*configure_completed: True*
|
*ac_configure_completed: True*
|
||||||
""")
|
""")
|
||||||
ac1.add_account_plugin(FFIEventLogger(ac1, "ac1"))
|
ac1.add_account_plugin(FFIEventLogger(ac1, "ac1"))
|
||||||
ac2.add_account_plugin(FFIEventLogger(ac2, "ac2"))
|
ac2.add_account_plugin(FFIEventLogger(ac2, "ac2"))
|
||||||
@@ -50,7 +50,7 @@ def test_group_tracking_plugin(acfactory, lp):
|
|||||||
ch.send_text("hello")
|
ch.send_text("hello")
|
||||||
|
|
||||||
botproc.fnmatch_lines("""
|
botproc.fnmatch_lines("""
|
||||||
*member_added {}*
|
*ac_member_added {}*
|
||||||
""".format(ac1.get_config("addr")))
|
""".format(ac1.get_config("addr")))
|
||||||
|
|
||||||
lp.sec("adding third member {}".format(ac2.get_config("addr")))
|
lp.sec("adding third member {}".format(ac2.get_config("addr")))
|
||||||
@@ -62,11 +62,11 @@ def test_group_tracking_plugin(acfactory, lp):
|
|||||||
|
|
||||||
lp.sec("now looking at what the bot received")
|
lp.sec("now looking at what the bot received")
|
||||||
botproc.fnmatch_lines("""
|
botproc.fnmatch_lines("""
|
||||||
*member_added {}*
|
*ac_member_added {}*
|
||||||
""".format(contact3.addr))
|
""".format(contact3.addr))
|
||||||
|
|
||||||
lp.sec("contact successfully added, now removing")
|
lp.sec("contact successfully added, now removing")
|
||||||
ch.remove_contact(contact3)
|
ch.remove_contact(contact3)
|
||||||
botproc.fnmatch_lines("""
|
botproc.fnmatch_lines("""
|
||||||
*member_removed {}*
|
*ac_member_removed {}*
|
||||||
""".format(contact3.addr))
|
""".format(contact3.addr))
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ class Account(object):
|
|||||||
raise ValueError("Could not dc_open: {}".format(db_path))
|
raise ValueError("Could not dc_open: {}".format(db_path))
|
||||||
self._configkeys = self.get_config("sys.config_keys").split()
|
self._configkeys = self.get_config("sys.config_keys").split()
|
||||||
atexit.register(self.shutdown)
|
atexit.register(self.shutdown)
|
||||||
hook.account_init(account=self)
|
hook.dc_account_init(account=self)
|
||||||
|
|
||||||
@hookspec.account_hookimpl
|
@hookspec.account_hookimpl
|
||||||
def process_ffi_event(self, ffi_event):
|
def ac_process_ffi_event(self, ffi_event):
|
||||||
name, kwargs = self._map_ffi_event(ffi_event)
|
name, kwargs = self._map_ffi_event(ffi_event)
|
||||||
if name is not None:
|
if name is not None:
|
||||||
ev = HookEvent(self, name=name, kwargs=kwargs)
|
ev = HookEvent(self, name=name, kwargs=kwargs)
|
||||||
@@ -72,8 +72,8 @@ class Account(object):
|
|||||||
# def __del__(self):
|
# def __del__(self):
|
||||||
# self.shutdown()
|
# self.shutdown()
|
||||||
|
|
||||||
def log_line(self, msg):
|
def ac_log_line(self, msg):
|
||||||
self._pm.hook.log_line(message=msg)
|
self._pm.hook.ac_log_line(message=msg)
|
||||||
|
|
||||||
def _check_config_key(self, name):
|
def _check_config_key(self, name):
|
||||||
if name not in self._configkeys:
|
if name not in self._configkeys:
|
||||||
@@ -579,7 +579,7 @@ class Account(object):
|
|||||||
atexit.unregister(self.shutdown)
|
atexit.unregister(self.shutdown)
|
||||||
self._shutdown_event.set()
|
self._shutdown_event.set()
|
||||||
hook = hookspec.Global._get_plugin_manager().hook
|
hook = hookspec.Global._get_plugin_manager().hook
|
||||||
hook.account_after_shutdown(account=self, dc_context=dc_context)
|
hook.dc_account_after_shutdown(account=self, dc_context=dc_context)
|
||||||
|
|
||||||
def _handle_current_events(self):
|
def _handle_current_events(self):
|
||||||
""" handle all currently queued events and then return. """
|
""" handle all currently queued events and then return. """
|
||||||
@@ -611,26 +611,26 @@ class Account(object):
|
|||||||
data1 = ffi_event.data1
|
data1 = ffi_event.data1
|
||||||
if data1 == 0 or data1 == 1000:
|
if data1 == 0 or data1 == 1000:
|
||||||
success = data1 == 1000
|
success = data1 == 1000
|
||||||
return "configure_completed", dict(success=success)
|
return "ac_configure_completed", dict(success=success)
|
||||||
elif name == "DC_EVENT_INCOMING_MSG":
|
elif name == "DC_EVENT_INCOMING_MSG":
|
||||||
msg = self.get_message_by_id(ffi_event.data2)
|
msg = self.get_message_by_id(ffi_event.data2)
|
||||||
return "process_incoming_message", dict(message=msg)
|
return "ac_incoming_message", dict(message=msg)
|
||||||
elif name == "DC_EVENT_MSGS_CHANGED":
|
elif name == "DC_EVENT_MSGS_CHANGED":
|
||||||
if ffi_event.data2 != 0:
|
if ffi_event.data2 != 0:
|
||||||
msg = self.get_message_by_id(ffi_event.data2)
|
msg = self.get_message_by_id(ffi_event.data2)
|
||||||
if msg.is_in_fresh():
|
if msg.is_in_fresh():
|
||||||
return "process_incoming_message", dict(message=msg)
|
return "ac_incoming_message", dict(message=msg)
|
||||||
elif name == "DC_EVENT_MSG_DELIVERED":
|
elif name == "DC_EVENT_MSG_DELIVERED":
|
||||||
msg = self.get_message_by_id(ffi_event.data2)
|
msg = self.get_message_by_id(ffi_event.data2)
|
||||||
return "process_message_delivered", dict(message=msg)
|
return "ac_message_delivered", dict(message=msg)
|
||||||
elif name == "DC_EVENT_MEMBER_ADDED":
|
elif name == "DC_EVENT_MEMBER_ADDED":
|
||||||
chat = self.get_chat_by_id(ffi_event.data1)
|
chat = self.get_chat_by_id(ffi_event.data1)
|
||||||
contact = self.get_contact_by_id(ffi_event.data2)
|
contact = self.get_contact_by_id(ffi_event.data2)
|
||||||
return "member_added", dict(chat=chat, contact=contact)
|
return "ac_member_added", dict(chat=chat, contact=contact)
|
||||||
elif name == "DC_EVENT_MEMBER_REMOVED":
|
elif name == "DC_EVENT_MEMBER_REMOVED":
|
||||||
chat = self.get_chat_by_id(ffi_event.data1)
|
chat = self.get_chat_by_id(ffi_event.data1)
|
||||||
contact = self.get_contact_by_id(ffi_event.data2)
|
contact = self.get_contact_by_id(ffi_event.data2)
|
||||||
return "member_removed", dict(chat=chat, contact=contact)
|
return "ac_member_removed", dict(chat=chat, contact=contact)
|
||||||
return None, {}
|
return None, {}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,19 +7,19 @@ from .hookspec import account_hookimpl, global_hookimpl
|
|||||||
|
|
||||||
|
|
||||||
@global_hookimpl
|
@global_hookimpl
|
||||||
def account_init(account):
|
def dc_account_init(account):
|
||||||
# send all FFI events for this account to a plugin hook
|
# send all FFI events for this account to a plugin hook
|
||||||
def _ll_event(ctx, evt_name, data1, data2):
|
def _ll_event(ctx, evt_name, data1, data2):
|
||||||
assert ctx == account._dc_context
|
assert ctx == account._dc_context
|
||||||
ffi_event = FFIEvent(name=evt_name, data1=data1, data2=data2)
|
ffi_event = FFIEvent(name=evt_name, data1=data1, data2=data2)
|
||||||
account._pm.hook.process_ffi_event(
|
account._pm.hook.ac_process_ffi_event(
|
||||||
account=account, ffi_event=ffi_event
|
account=account, ffi_event=ffi_event
|
||||||
)
|
)
|
||||||
deltachat.set_context_callback(account._dc_context, _ll_event)
|
deltachat.set_context_callback(account._dc_context, _ll_event)
|
||||||
|
|
||||||
|
|
||||||
@global_hookimpl
|
@global_hookimpl
|
||||||
def account_after_shutdown(dc_context):
|
def dc_account_after_shutdown(dc_context):
|
||||||
deltachat.clear_context_callback(dc_context)
|
deltachat.clear_context_callback(dc_context)
|
||||||
|
|
||||||
|
|
||||||
@@ -50,17 +50,17 @@ class FFIEventLogger:
|
|||||||
self.init_time = time.time()
|
self.init_time = time.time()
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def process_ffi_event(self, ffi_event):
|
def ac_process_ffi_event(self, ffi_event):
|
||||||
self._log_event(ffi_event)
|
self._log_event(ffi_event)
|
||||||
|
|
||||||
def _log_event(self, ffi_event):
|
def _log_event(self, ffi_event):
|
||||||
# don't show events that are anyway empty impls now
|
# don't show events that are anyway empty impls now
|
||||||
if ffi_event.name == "DC_EVENT_GET_STRING":
|
if ffi_event.name == "DC_EVENT_GET_STRING":
|
||||||
return
|
return
|
||||||
self.account.log_line(str(ffi_event))
|
self.account.ac_log_line(str(ffi_event))
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def log_line(self, message):
|
def ac_log_line(self, message):
|
||||||
t = threading.currentThread()
|
t = threading.currentThread()
|
||||||
tname = getattr(t, "name", t)
|
tname = getattr(t, "name", t)
|
||||||
if tname == "MainThread":
|
if tname == "MainThread":
|
||||||
@@ -81,7 +81,7 @@ class FFIEventTracker:
|
|||||||
self._event_queue = Queue()
|
self._event_queue = Queue()
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def process_ffi_event(self, ffi_event):
|
def ac_process_ffi_event(self, ffi_event):
|
||||||
self._event_queue.put(ffi_event)
|
self._event_queue.put(ffi_event)
|
||||||
|
|
||||||
def set_timeout(self, timeout):
|
def set_timeout(self, timeout):
|
||||||
@@ -110,7 +110,7 @@ class FFIEventTracker:
|
|||||||
assert not rex.match(ev.name), "event found {}".format(ev)
|
assert not rex.match(ev.name), "event found {}".format(ev)
|
||||||
|
|
||||||
def get_matching(self, event_name_regex, check_error=True, timeout=None):
|
def get_matching(self, event_name_regex, check_error=True, timeout=None):
|
||||||
self.account.log_line("-- waiting for event with regex: {} --".format(event_name_regex))
|
self.account.ac_log_line("-- waiting for event with regex: {} --".format(event_name_regex))
|
||||||
rex = re.compile("(?:{}).*".format(event_name_regex))
|
rex = re.compile("(?:{}).*".format(event_name_regex))
|
||||||
while 1:
|
while 1:
|
||||||
ev = self.get(timeout=timeout, check_error=check_error)
|
ev = self.get(timeout=timeout, check_error=check_error)
|
||||||
|
|||||||
@@ -3,29 +3,29 @@
|
|||||||
import pluggy
|
import pluggy
|
||||||
|
|
||||||
|
|
||||||
_account_name = "deltachat-account"
|
account_spec_name = "deltachat-account"
|
||||||
account_hookspec = pluggy.HookspecMarker(_account_name)
|
account_hookspec = pluggy.HookspecMarker(account_spec_name)
|
||||||
account_hookimpl = pluggy.HookimplMarker(_account_name)
|
account_hookimpl = pluggy.HookimplMarker(account_spec_name)
|
||||||
|
|
||||||
_global_name = "deltachat-global"
|
global_spec_name = "deltachat-global"
|
||||||
global_hookspec = pluggy.HookspecMarker(_global_name)
|
global_hookspec = pluggy.HookspecMarker(global_spec_name)
|
||||||
global_hookimpl = pluggy.HookimplMarker(_global_name)
|
global_hookimpl = pluggy.HookimplMarker(global_spec_name)
|
||||||
|
|
||||||
|
|
||||||
class PerAccount:
|
class PerAccount:
|
||||||
""" per-Account-instance hook specifications.
|
""" per-Account-instance hook specifications.
|
||||||
|
|
||||||
Except for process_ffi_event all hooks are executed
|
Except for ac_process_ffi_event all hooks are executed
|
||||||
in the thread which calls Account.wait_shutdown().
|
in the thread which calls Account.wait_shutdown().
|
||||||
"""
|
"""
|
||||||
@classmethod
|
@classmethod
|
||||||
def _make_plugin_manager(cls):
|
def _make_plugin_manager(cls):
|
||||||
pm = pluggy.PluginManager(_account_name)
|
pm = pluggy.PluginManager(account_spec_name)
|
||||||
pm.add_hookspecs(cls)
|
pm.add_hookspecs(cls)
|
||||||
return pm
|
return pm
|
||||||
|
|
||||||
@account_hookspec
|
@account_hookspec
|
||||||
def process_ffi_event(self, ffi_event):
|
def ac_process_ffi_event(self, ffi_event):
|
||||||
""" process a CFFI low level events for a given account.
|
""" process a CFFI low level events for a given account.
|
||||||
|
|
||||||
ffi_event has "name", "data1", "data2" values as specified
|
ffi_event has "name", "data1", "data2" values as specified
|
||||||
@@ -37,27 +37,27 @@ class PerAccount:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
@account_hookspec
|
@account_hookspec
|
||||||
def log_line(self, message):
|
def ac_log_line(self, message):
|
||||||
""" log a message related to the account. """
|
""" log a message related to the account. """
|
||||||
|
|
||||||
@account_hookspec
|
@account_hookspec
|
||||||
def configure_completed(self, success):
|
def ac_configure_completed(self, success):
|
||||||
""" Called when a configure process completed. """
|
""" Called when a configure process completed. """
|
||||||
|
|
||||||
@account_hookspec
|
@account_hookspec
|
||||||
def process_incoming_message(self, message):
|
def ac_incoming_message(self, message):
|
||||||
""" Called on any incoming message (to deaddrop or chat). """
|
""" Called on any incoming message (to deaddrop or chat). """
|
||||||
|
|
||||||
@account_hookspec
|
@account_hookspec
|
||||||
def process_message_delivered(self, message):
|
def ac_message_delivered(self, message):
|
||||||
""" Called when an outgoing message has been delivered to SMTP. """
|
""" Called when an outgoing message has been delivered to SMTP. """
|
||||||
|
|
||||||
@account_hookspec
|
@account_hookspec
|
||||||
def member_added(self, chat, contact):
|
def ac_member_added(self, chat, contact):
|
||||||
""" Called for each contact added to a chat. """
|
""" Called for each contact added to a chat. """
|
||||||
|
|
||||||
@account_hookspec
|
@account_hookspec
|
||||||
def member_removed(self, chat, contact):
|
def ac_member_removed(self, chat, contact):
|
||||||
""" Called for each contact removed from a chat. """
|
""" Called for each contact removed from a chat. """
|
||||||
|
|
||||||
|
|
||||||
@@ -71,14 +71,14 @@ class Global:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _get_plugin_manager(cls):
|
def _get_plugin_manager(cls):
|
||||||
if cls._plugin_manager is None:
|
if cls._plugin_manager is None:
|
||||||
cls._plugin_manager = pm = pluggy.PluginManager(_global_name)
|
cls._plugin_manager = pm = pluggy.PluginManager(global_spec_name)
|
||||||
pm.add_hookspecs(cls)
|
pm.add_hookspecs(cls)
|
||||||
return cls._plugin_manager
|
return cls._plugin_manager
|
||||||
|
|
||||||
@global_hookspec
|
@global_hookspec
|
||||||
def account_init(self, account):
|
def dc_account_init(self, account):
|
||||||
""" called when `Account::__init__()` function starts executing. """
|
""" called when `Account::__init__()` function starts executing. """
|
||||||
|
|
||||||
@global_hookspec
|
@global_hookspec
|
||||||
def account_after_shutdown(self, account, dc_context):
|
def dc_account_after_shutdown(self, account, dc_context):
|
||||||
""" Called after the account has been shutdown. """
|
""" Called after the account has been shutdown. """
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ class IOThreads:
|
|||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def log_execution(self, message):
|
def log_execution(self, message):
|
||||||
self.account.log_line(message + " START")
|
self.account.ac_log_line(message + " START")
|
||||||
yield
|
yield
|
||||||
self.account.log_line(message + " FINISHED")
|
self.account.ac_log_line(message + " FINISHED")
|
||||||
|
|
||||||
def stop(self, wait=False):
|
def stop(self, wait=False):
|
||||||
self._thread_quitflag = True
|
self._thread_quitflag = True
|
||||||
@@ -68,7 +68,7 @@ class IOThreads:
|
|||||||
ev = next(it)
|
ev = next(it)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
break
|
break
|
||||||
self.account.log_line("calling hook name={} kwargs={}".format(ev.name, ev.kwargs))
|
self.account.ac_log_line("calling hook name={} kwargs={}".format(ev.name, ev.kwargs))
|
||||||
ev.call_hook()
|
ev.call_hook()
|
||||||
|
|
||||||
def imap_thread_run(self):
|
def imap_thread_run(self):
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ImexTracker:
|
|||||||
self._imex_events = Queue()
|
self._imex_events = Queue()
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def process_ffi_event(self, ffi_event):
|
def ac_process_ffi_event(self, ffi_event):
|
||||||
if ffi_event.name == "DC_EVENT_IMEX_PROGRESS":
|
if ffi_event.name == "DC_EVENT_IMEX_PROGRESS":
|
||||||
self._imex_events.put(ffi_event.data1)
|
self._imex_events.put(ffi_event.data1)
|
||||||
elif ffi_event.name == "DC_EVENT_IMEX_FILE_WRITTEN":
|
elif ffi_event.name == "DC_EVENT_IMEX_FILE_WRITTEN":
|
||||||
@@ -47,7 +47,7 @@ class ConfigureTracker:
|
|||||||
self._ffi_events = []
|
self._ffi_events = []
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def process_ffi_event(self, ffi_event):
|
def ac_process_ffi_event(self, ffi_event):
|
||||||
self._ffi_events.append(ffi_event)
|
self._ffi_events.append(ffi_event)
|
||||||
if ffi_event.name == "DC_EVENT_SMTP_CONNECTED":
|
if ffi_event.name == "DC_EVENT_SMTP_CONNECTED":
|
||||||
self._smtp_finished.set()
|
self._smtp_finished.set()
|
||||||
@@ -55,7 +55,7 @@ class ConfigureTracker:
|
|||||||
self._imap_finished.set()
|
self._imap_finished.set()
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def configure_completed(self, success):
|
def ac_configure_completed(self, success):
|
||||||
self._configure_events.put(success)
|
self._configure_events.put(success)
|
||||||
|
|
||||||
def wait_smtp_connected(self):
|
def wait_smtp_connected(self):
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ class TestOfflineChat:
|
|||||||
|
|
||||||
chat.add_contact(contact1)
|
chat.add_contact(contact1)
|
||||||
for ev in ac1.iter_events(timeout=1):
|
for ev in ac1.iter_events(timeout=1):
|
||||||
if ev.name == "member_added":
|
if ev.name == "ac_member_added":
|
||||||
assert ev.kwargs["chat"] == chat
|
assert ev.kwargs["chat"] == chat
|
||||||
if ev.kwargs["contact"] == ac1.get_self_contact():
|
if ev.kwargs["contact"] == ac1.get_self_contact():
|
||||||
continue
|
continue
|
||||||
@@ -193,7 +193,7 @@ class TestOfflineChat:
|
|||||||
ac1._handle_current_events()
|
ac1._handle_current_events()
|
||||||
chat.remove_contact(contact1)
|
chat.remove_contact(contact1)
|
||||||
for ev in ac1.iter_events(timeout=1):
|
for ev in ac1.iter_events(timeout=1):
|
||||||
if ev.name == "member_removed":
|
if ev.name == "ac_member_removed":
|
||||||
assert ev.kwargs["chat"] == chat
|
assert ev.kwargs["chat"] == chat
|
||||||
if ev.kwargs["contact"] == ac1.get_self_contact():
|
if ev.kwargs["contact"] == ac1.get_self_contact():
|
||||||
continue
|
continue
|
||||||
@@ -463,11 +463,11 @@ class TestOfflineChat:
|
|||||||
|
|
||||||
class InPlugin:
|
class InPlugin:
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def member_added(self, chat, contact):
|
def ac_member_added(self, chat, contact):
|
||||||
in_list.append(("added", chat, contact))
|
in_list.append(("added", chat, contact))
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def member_removed(self, chat, contact):
|
def ac_member_removed(self, chat, contact):
|
||||||
in_list.append(("removed", chat, contact))
|
in_list.append(("removed", chat, contact))
|
||||||
|
|
||||||
ac1.add_account_plugin(InPlugin())
|
ac1.add_account_plugin(InPlugin())
|
||||||
@@ -1051,14 +1051,14 @@ class TestOnlineAccount:
|
|||||||
|
|
||||||
class InPlugin:
|
class InPlugin:
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def process_incoming_message(self, message):
|
def ac_incoming_message(self, message):
|
||||||
message_queue.put(message)
|
message_queue.put(message)
|
||||||
|
|
||||||
delivered = queue.Queue()
|
delivered = queue.Queue()
|
||||||
|
|
||||||
class OutPlugin:
|
class OutPlugin:
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def process_message_delivered(self, message):
|
def ac_message_delivered(self, message):
|
||||||
delivered.put(message)
|
delivered.put(message)
|
||||||
|
|
||||||
ac1.add_account_plugin(OutPlugin())
|
ac1.add_account_plugin(OutPlugin())
|
||||||
@@ -1287,11 +1287,11 @@ class TestOnlineAccount:
|
|||||||
|
|
||||||
class InPlugin:
|
class InPlugin:
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def member_added(self, chat, contact):
|
def ac_member_added(self, chat, contact):
|
||||||
in_list.put(("added", chat, contact))
|
in_list.put(("added", chat, contact))
|
||||||
|
|
||||||
@account_hookimpl
|
@account_hookimpl
|
||||||
def member_removed(self, chat, contact):
|
def ac_member_removed(self, chat, contact):
|
||||||
in_list.put(("removed", chat, contact))
|
in_list.put(("removed", chat, contact))
|
||||||
|
|
||||||
ac2.add_account_plugin(InPlugin())
|
ac2.add_account_plugin(InPlugin())
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def test_dc_close_events(tmpdir, acfactory):
|
|||||||
|
|
||||||
class ShutdownPlugin:
|
class ShutdownPlugin:
|
||||||
@global_hookimpl
|
@global_hookimpl
|
||||||
def account_after_shutdown(self, account):
|
def dc_account_after_shutdown(self, account):
|
||||||
assert account._dc_context is None
|
assert account._dc_context is None
|
||||||
shutdowns.append(account)
|
shutdowns.append(account)
|
||||||
register_global_plugin(ShutdownPlugin())
|
register_global_plugin(ShutdownPlugin())
|
||||||
|
|||||||
Reference in New Issue
Block a user