changeset bfa12b3fd164 in /home/hg/repos/gajim-plugins author: Bahtiar `kalkin-` Gadimov <[email protected]> branches: details:gajim-plugins?cmd=changeset;node=bfa12b3fd164 description: Release omemo plugin version 0.4
diffstat: omemo/CHANGELOG | 13 + omemo/README.md | 6 +- omemo/__init__.py | 83 +- omemo/aes_gcm.py | 160 -- omemo/lib/python-omemo/.ackrc | 19 + omemo/lib/python-omemo/.bumpversion.cfg | 11 + omemo/lib/python-omemo/.cookiecutterrc | 47 + omemo/lib/python-omemo/.coveragerc | 12 + omemo/lib/python-omemo/.editorconfig | 13 + omemo/lib/python-omemo/.gitignore | 63 + omemo/lib/python-omemo/.travis.yml | 44 + omemo/lib/python-omemo/AUTHORS.rst | 7 + omemo/lib/python-omemo/CHANGELOG.rst | 8 + omemo/lib/python-omemo/CONTRIBUTING.rst | 280 ++++ omemo/lib/python-omemo/COPYING | 675 ++++++++++ omemo/lib/python-omemo/MANIFEST.in | 21 + omemo/lib/python-omemo/README.rst | 123 + omemo/lib/python-omemo/appveyor.yml | 110 + omemo/lib/python-omemo/ci/appveyor-bootstrap.py | 113 + omemo/lib/python-omemo/ci/appveyor-download.py | 107 + omemo/lib/python-omemo/ci/appveyor-with-compiler.cmd | 46 + omemo/lib/python-omemo/ci/bootstrap.py | 53 + omemo/lib/python-omemo/ci/templates/.travis.yml | 37 + omemo/lib/python-omemo/ci/templates/appveyor.yml | 53 + omemo/lib/python-omemo/docs/authors.rst | 1 + omemo/lib/python-omemo/docs/changelog.rst | 1 + omemo/lib/python-omemo/docs/conf.py | 54 + omemo/lib/python-omemo/docs/contributing.rst | 1 + omemo/lib/python-omemo/docs/index.rst | 22 + omemo/lib/python-omemo/docs/installation.rst | 7 + omemo/lib/python-omemo/docs/readme.rst | 1 + omemo/lib/python-omemo/docs/reference/index.rst | 7 + omemo/lib/python-omemo/docs/reference/omemo.rst | 8 + omemo/lib/python-omemo/docs/requirements.txt | 2 + omemo/lib/python-omemo/docs/spelling_wordlist.txt | 11 + omemo/lib/python-omemo/docs/usage.rst | 7 + omemo/lib/python-omemo/setup.cfg | 44 + omemo/lib/python-omemo/setup.py | 67 + omemo/lib/python-omemo/src/.gitignore | 2 + omemo/lib/python-omemo/src/.style.yapf | 4 + omemo/lib/python-omemo/src/COPYING | 674 +++++++++ omemo/lib/python-omemo/src/omemo.png | Bin omemo/lib/python-omemo/src/omemo/__init__.py | 1 + omemo/lib/python-omemo/src/omemo/aes_gcm.py | 160 ++ omemo/lib/python-omemo/src/omemo/db_helpers.py | 13 + omemo/lib/python-omemo/src/omemo/encryption.py | 95 + omemo/lib/python-omemo/src/omemo/liteaxolotlstore.py | 127 + omemo/lib/python-omemo/src/omemo/liteidentitykeystore.py | 76 + omemo/lib/python-omemo/src/omemo/liteprekeystore.py | 72 + omemo/lib/python-omemo/src/omemo/litesessionstore.py | 80 + omemo/lib/python-omemo/src/omemo/litesignedprekeystore.py | 77 + omemo/lib/python-omemo/src/omemo/state.py | 316 ++++ omemo/lib/python-omemo/tests/test_db_helpers.py | 19 + omemo/lib/python-omemo/tests/test_encryption_store.py | 31 + omemo/lib/python-omemo/tests/test_migrate_encryption_state.py | 47 + omemo/lib/python-omemo/tests/test_omemo.py | 6 + omemo/lib/python-omemo/tests/test_omemo_state.py | 107 + omemo/lib/python-omemo/tox.ini | 131 + omemo/manifest.ini | 4 +- omemo/omemo | 1 + omemo/pkgs/PKGBUILD | 4 +- omemo/state.py | 273 ---- omemo/store/__init__.py | 1 - omemo/store/encryption.py | 58 - omemo/store/liteaxolotlstore.py | 125 - omemo/store/liteidentitykeystore.py | 76 - omemo/store/liteprekeystore.py | 73 - omemo/store/litesessionstore.py | 80 - omemo/store/litesignedprekeystore.py | 77 - omemo/test_encryption_store.py | 31 - omemo/xmpp.py | 3 + 71 files changed, 4187 insertions(+), 994 deletions(-) diffs (truncated from 5675 to 300 lines): diff -r 0ad2a8bf5e82 -r bfa12b3fd164 omemo/CHANGELOG --- a/omemo/CHANGELOG Sun Jan 10 21:12:12 2016 +0100 +++ b/omemo/CHANGELOG Tue Jan 26 15:13:15 2016 +0100 @@ -1,3 +1,16 @@ +0.4 / 2016-01-21 +================== + + * Update README.md + * Fix #32: Add own devices as possible OMEMO partners. + * Fix one of the errors in #26 + * Fix sqlite db intialization + * Use the standalone python-omemo library + * FIx LOG_DB errors / lost messages + * Move all OMEMO related parts to own dir + * Rename all links from kalkin/.. to omemo/... + * Update archlinux PKGBUILD to 0.3 + 0.3 / 2016-01-10 ================== * Save if OMEMO is enabled between restarts - #17 diff -r 0ad2a8bf5e82 -r bfa12b3fd164 omemo/README.md --- a/omemo/README.md Sun Jan 10 21:12:12 2016 +0100 +++ b/omemo/README.md Tue Jan 26 15:13:15 2016 +0100 @@ -41,20 +41,20 @@ ```shell mkdir ~/.local/share/gajim/plugins -p cd ~/.local/share/gajim/plugins -git clone https://github.com/kalkin/gajim-omemo +git clone https://github.com/omemo/gajim-omemo ``` ## Support this project I develop this project in my free time. Your donation allows me to spend more time working on it and on free software generally. -My Bitcoin Address is: `1CnNM3Mree9hU8eRjCXrfCWV mX6oBnEfV1` +My Bitcoin Address is: `1CnNM3Mree9hU8eRjCXrfCWVmX6oBnEfV1` [](https://flattr.com/thing/5038679) ## I found a bug Please report it to the [issue -tracker](https://github.com/kalkin/gajim-omemo/issues). If you are experiencing +tracker](https://github.com/omemo/gajim-omemo/issues). If you are experiencing misbehaviour please provide detailed steps to reproduce and debugging output. Always mention the exact Gajim version. diff -r 0ad2a8bf5e82 -r bfa12b3fd164 omemo/__init__.py --- a/omemo/__init__.py Sun Jan 10 21:12:12 2016 +0100 +++ b/omemo/__init__.py Tue Jan 26 15:13:15 2016 +0100 @@ -19,6 +19,8 @@ # import logging +import os +import sqlite3 from common import caps_cache, gajim, ged from common.pep import SUPPORTED_PERSONAL_USER_EVENTS @@ -37,12 +39,14 @@ log = logging.getLogger('gajim.plugin_system.omemo') try: - from .state import OmemoState + from omemo.state import OmemoState HAS_AXOLOTL = True except ImportError: log.error(AXOLOTL_MISSING) HAS_AXOLOTL = False +DB_DIR = gajim.gajimpaths.data_root + class OmemoPlugin(GajimPlugin): @@ -75,7 +79,9 @@ OmemoState if it does not exist yet. """ if account not in self.omemo_states: - self.omemo_states[account] = OmemoState(account) + db_path = os.path.join(DB_DIR, 'omemo_' + account + '.db') + conn = sqlite3.connect(db_path, check_same_thread=False) + self.omemo_states[account] = OmemoState(conn) return self.omemo_states[account] @log_calls('OmemoPlugin') @@ -84,8 +90,7 @@ On sign in announce OMEMO support for each account. """ account = show.conn.name - state = self.get_omemo_state(account) - self.announce_support(state) + self.announce_support(account) @log_calls('OmemoPlugin') def activate(self): @@ -183,9 +188,9 @@ my_jid = gajim.get_jid_from_account(account_name) if contact_jid == my_jid: - log.info(state.name + ' ⇒ Received own device_list:' + str( + log.info(account_name + ' ⇒ Received own device_list:' + str( devices_list)) - state.add_own_devices(devices_list) + state.add_own_devices(my_jid, devices_list) if not state.own_device_id_published() or anydup( state.own_devices): @@ -194,7 +199,7 @@ # also remove duplicates devices_list = list(set(state.own_devices)) devices_list.append(state.own_device_id) - self.publish_own_devices_list(state) + self.publish_own_devices_list(account_name, state) else: log.info(account_name + ' ⇒ Received device_list for ' + contact_jid + ':' + str(devices_list)) @@ -213,14 +218,14 @@ return True @log_calls('OmemoPlugin') - def publish_own_devices_list(self, state): + def publish_own_devices_list(self, account_name, state): devices_list = state.own_devices devices_list += [state.own_device_id] - log.debug(state.name + ' ⇒ Publishing own devices_list ' + str( + log.debug(account_name + ' ⇒ Publishing own devices_list ' + str( devices_list)) iq = DeviceListAnnouncement(devices_list) - gajim.connections[state.name].connection.send(iq) + gajim.connections[account_name].connection.send(iq) id_ = str(iq.getAttr('id')) iq_ids_to_callbacks[id_] = lambda event: log.debug(event) @@ -231,7 +236,8 @@ if account_name not in self.ui_list: self.ui_list[account_name] = {} state = self.get_omemo_state(account_name) - if contact_jid in state.device_ids: + my_jid = gajim.get_jid_from_account(account_name) + if contact_jid in state.device_ids or contact_jid == my_jid: log.debug(account_name + " ⇒ Adding OMEMO ui for " + contact_jid) omemo_enabled = state.encryption.is_active(contact_jid) self.ui_list[account_name][contact_jid] = Ui(self, chat_control, @@ -274,18 +280,23 @@ to_jid = recipient.jid my_jid = gajim.get_jid_from_account(account) for device_id in state.devices_without_sessions(to_jid): - self.fetch_device_bundle_information(state, to_jid, device_id) + self.fetch_device_bundle_information(account, state, to_jid, + device_id) for device_id in state.own_devices_without_sessions(my_jid): - self.fetch_device_bundle_information(state, my_jid, device_id) + self.fetch_device_bundle_information(account, state, my_jid, + device_id) @log_calls('OmemoPlugin') - def fetch_device_bundle_information(self, state, jid, device_id): + def fetch_device_bundle_information(self, account_name, state, jid, + device_id): """ Fetch bundle information for specified jid, key, and create axolotl session on success. Parameters ---------- + account_name : str + The account name state : (OmemoState) The OmemoState which is missing device bundle information jid : str @@ -293,18 +304,19 @@ device_id : int The device_id for which we are missing an axolotl session """ - log.debug(state.name + '→ Fetch bundle device ' + str(device_id) + '#' + log.debug(account_name + '→ Fetch bundle device ' + str(device_id) + '#' + jid) iq = BundleInformationQuery(jid, device_id) iq_id = str(iq.getAttr('id')) iq_ids_to_callbacks[iq_id] = \ - lambda stanza: self.session_from_prekey_bundle(state, stanza, - jid, device_id) - gajim.connections[state.name].connection.send(iq) + lambda stanza: self.session_from_prekey_bundle(account_name, state, + stanza, jid, + device_id) + gajim.connections[account_name].connection.send(iq) @log_calls('OmemoPlugin') - def session_from_prekey_bundle(self, state, stanza, recipient_id, - device_id): + def session_from_prekey_bundle(self, account_name, state, stanza, + recipient_id, device_id): """ Starts a session when a bundle information announcement is received. @@ -325,6 +337,8 @@ Parameters: ----------- + account_name : str + The account name state : (OmemoState) The OmemoState used stanza @@ -341,7 +355,7 @@ return if state.build_session(recipient_id, device_id, bundle_dict): - self.update_prekeys(state.name, recipient_id) + self.update_prekeys(account_name, recipient_id) @log_calls('OmemoPlugin') def update_prekeys(self, account, recipient_id): @@ -368,23 +382,23 @@ Parameters ---------- account : str - The account name + the account name See also -------- 4.3 Announcing bundle information: http://conversations.im/xeps/multi-end.html#usecases-announcing """ - state = self.get_omemo_state(account.name) + state = self.get_omemo_state(account) iq = BundleInformationAnnouncement(state.bundle, state.own_device_id) - gajim.connections[state.name].connection.send(iq) + gajim.connections[account].connection.send(iq) id_ = str(iq.getAttr("id")) - log.debug(account.name + " → Announcing OMEMO support via PEP") + log.debug(account + " → Announcing OMEMO support via PEP") iq_ids_to_callbacks[id_] = lambda stanza: \ - self.handle_announcement_result(stanza, state) + self.handle_announcement_result(account, stanza, state) @log_calls('OmemoPlugin') - def handle_announcement_result(self, stanza, state): + def handle_announcement_result(self, account, stanza, state): """ Updates own device list if announcement was successfull. If the OMEMO support announcement was successfull update own device @@ -392,17 +406,20 @@ Parameters ---------- + account : str + the account name stanza The stanza object received from callback + state : (OmemoState) + The OmemoState used """ - account = state.name state = self.get_omemo_state(account) if successful(stanza): log.debug(account + ' → Publishing bundle was successful') if not state.own_device_id_published(): log.warn(account + ' → Device list needs updating') - self.publish_own_devices_list(state) + self.publish_own_devices_list(account, state) else: log.debug(account + ' → Device list up to date') else: @@ -414,9 +431,9 @@ state = self.get_omemo_state(account) devices_list = [state.own_device_id] - log.info(state.name + ' ⇒ Clearing devices_list ' + str(devices_list)) + log.info(account + ' ⇒ Clearing devices_list ' + str(devices_list)) iq = DeviceListAnnouncement(devices_list) - connection = gajim.connections[state.name].connection + connection = gajim.connections[account].connection if not connection: # not connected return connection.send(iq) @@ -435,8 +452,8 @@ 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) + 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) diff -r 0ad2a8bf5e82 -r bfa12b3fd164 omemo/aes_gcm.py --- a/omemo/aes_gcm.py Sun Jan 10 21:12:12 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2014 Jonathan Zdziarski <[email protected]> -# _______________________________________________ Commits mailing list [email protected] https://lists.gajim.org/cgi-bin/listinfo/commits
