changeset 074793624d8a in /home/hg/repos/gajim-plugins
author: Bahtiar `kalkin-` Gadimov bahtiar@gadimov.de branches: details:gajim-plugins?cmd=changeset;node=074793624d8a description: Fix delay when sending messages - #13
Use threading for encryption when sending
diffstat:
omemo/__init__.py | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-)
diffs (29 lines):
diff -r b6c7e89ac38d -r 074793624d8a omemo/__init__.py --- a/omemo/__init__.py Wed Jan 27 09:58:02 2016 +0100 +++ b/omemo/__init__.py Thu Jan 28 16:55:52 2016 +0100 @@ -452,14 +452,17 @@ if not state.encryption.is_active(to_jid): return False try: - msg_dict = state.create_msg(gajim.get_jid_from_account(account), - to_jid, plaintext) - if not msg_dict: - return True - encrypted_node = OmemoMessage(msg_dict) - event.msg_iq.delChild('body') - event.msg_iq.addChild(node=encrypted_node) - log.debug(account + ' → ' + str(event.msg_iq)) + from_jid = gajim.get_jid_from_account(account) + def _encrypt_thread(from_jid, to_jid, plaintext): + msg_dict = state.create_msg(from_jid, + to_jid, plaintext) + if not msg_dict: + return True + encrypted_node = OmemoMessage(msg_dict) + event.msg_iq.delChild('body') + event.msg_iq.addChild(node=encrypted_node) + log.debug(account + ' → ' + str(event.msg_iq)) + gajim.thread_interface(_encrypt_thread, [from_jid, to_jid, plaintext]) except: return True