changeset f1e36838b049 in /home/hg/repos/gajim-plugins
author: Bahtiar `kalkin-` Gadimov bahtiar@gadimov.de branches: details:gajim-plugins?cmd=changeset;node=f1e36838b049 description: Merge branch 'omemo-0.9'
diffstat:
omemo/.github/ISSUE_TEMPLATE.md | 26 + omemo/.pylintrc | 2 +- omemo/CHANGELOG | 8 +- omemo/README.md | 13 +- omemo/__init__.py | 571 ++++++++++++++++++++++++++------------- omemo/config_dialog.ui | 44 +++- omemo/manifest.ini | 2 +- omemo/omemo/state.py | 26 +- omemo/pkgs/PKGBUILD | 8 +- omemo/ui.py | 6 +- omemo/xmpp.py | 51 +- 11 files changed, 506 insertions(+), 251 deletions(-)
diffs (truncated from 1359 to 300 lines):
diff -r 26ac702fc014 -r f1e36838b049 omemo/.github/ISSUE_TEMPLATE.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/omemo/.github/ISSUE_TEMPLATE.md Mon Aug 29 02:24:53 2016 +0200 @@ -0,0 +1,26 @@ +#### General information + +Before opening an issue, please read our Wiki + +* **Gajim Version:** eg 0.16.5 +* **Plugin Version:** eg 0.8.1 +* **OS:** eg Ubuntu 16.04, Windows 7 +* **Server name:** eg conversations.im, jabber.at or self hosted +* **Server software:** ejabberd 16.04 or prosody 0.10 (if known) +* **Installed server modules:** eg MAM + + +#### Steps to reproduce + +1. … +2. … + + +#### Expected result + +What is the expected output? What do you see instead? + + +#### Debug output + +Please start Gajim with `-l gajim.plugin-system.omemo=DEBUG` and post the log file diff -r 26ac702fc014 -r f1e36838b049 omemo/.pylintrc --- a/omemo/.pylintrc Fri Aug 26 20:48:44 2016 +0200 +++ b/omemo/.pylintrc Mon Aug 29 02:24:53 2016 +0200 @@ -327,7 +327,7 @@ ignored-argument-names=_.*
# Maximum number of locals for function / method body -max-locals=15 +max-locals=20
# Maximum number of return / yield for function / method body max-returns=6 diff -r 26ac702fc014 -r f1e36838b049 omemo/CHANGELOG --- a/omemo/CHANGELOG Fri Aug 26 20:48:44 2016 +0200 +++ b/omemo/CHANGELOG Mon Aug 29 02:24:53 2016 +0200 @@ -1,9 +1,14 @@ +0.9.0 / 2016-08-28 +- Send INFO message to resources who dont support OMEMO +- Check dependencys and give correct error message +- Dont process PreKeyWhisperMessages without PreKey +- Dont process PGP messages + 0.8.1 / 2016-08-05 - Query own Device Bundles on send button press - Make Fingerprint Window higher and rename Buttons for something more appropriate - Bugfixes
- 0.8.0 / 2016-08-03 - Encryption improvements: -- SignedPreKey renews every 24 hours @@ -18,7 +23,6 @@ -- SQL Refactoring, so new users dont have to go through DB Migration -- Small bugfixes
- 0.7.5 / 2016-07-20 ================ - Announcing of Support right after Plugin activation diff -r 26ac702fc014 -r f1e36838b049 omemo/README.md --- a/omemo/README.md Fri Aug 26 20:48:44 2016 +0200 +++ b/omemo/README.md Mon Aug 29 02:24:53 2016 +0200 @@ -1,17 +1,20 @@ # OMEMO Plugin for Gajim
-This is an experimental plugin that adds support for the [OMEMO -Encryption](http://conversations.im/omemo) to [Gajim](https://gajim.org/). This +This Plugin adds support for the [OMEMO Encryption](http://conversations.im/omemo) to [Gajim](https://gajim.org/). This plugin is [free software](http://www.gnu.org/philosophy/free-sw.en.html) distributed under the GNU General Public License version 3 or any later version.
-**DO NOT rely on this plugin to protect sensitive information!** +## Installation
-## Installation +Before you open any issues please read our [Wiki](https://github.com/omemo/gajim-omemo/wiki) which addresses some problems that can occur during an install + +### Linux + +See [Linux Wiki](https://github.com/omemo/gajim-omemo/wiki/Installing-on-Linux)
### Windows
-See [Windows Wiki](https://github.com/omemo/gajim-omemo/wiki/Installing-and-Using-on-Windows) +See [Windows Wiki](https://github.com/omemo/gajim-omemo/wiki/Installing-on-Windows)
### Via Package Manager #### Arch diff -r 26ac702fc014 -r f1e36838b049 omemo/__init__.py --- a/omemo/__init__.py Fri Aug 26 20:48:44 2016 +0200 +++ b/omemo/__init__.py Mon Aug 29 02:24:53 2016 +0200 @@ -21,59 +21,91 @@ import logging import os import sqlite3 -import ui -import re +import os + +from common import caps_cache, gajim, ged +from common.pep import SUPPORTED_PERSONAL_USER_EVENTS +from plugins import GajimPlugin +from plugins.helpers import log_calls +from nbxmpp.simplexml import Node +from nbxmpp import NS_CORRECT + +from . import ui +from .ui import Ui +from .xmpp import ( + NS_NOTIFY, NS_OMEMO, NS_EME, BundleInformationAnnouncement, + BundleInformationQuery, DeviceListAnnouncement, DevicelistQuery, + DevicelistPEP, OmemoMessage, successful, unpack_device_bundle, + unpack_device_list_update, unpack_encrypted)
from common import demandimport demandimport.enable() demandimport.ignore += ['_imp']
-# pylint: disable=import-error -from common import caps_cache, gajim, ged -from common.pep import SUPPORTED_PERSONAL_USER_EVENTS -from plugins import GajimPlugin -from plugins.helpers import log_calls
-from nbxmpp.simplexml import Node -from nbxmpp import NS_CORRECT +IQ_CALLBACK = {}
-from .ui import Ui -from .xmpp import ( - NS_NOTIFY, NS_OMEMO, BundleInformationAnnouncement, BundleInformationQuery, - DeviceListAnnouncement, DevicelistQuery, DevicelistPEP, OmemoMessage, - successful, unpack_device_bundle, unpack_device_list_update, - unpack_encrypted) - - -iq_ids_to_callbacks = {} - -AXOLOTL_MISSING = 'Please install python-axolotl.' +AXOLOTL_MISSING = 'You are missing Python-Axolotl or use an outdated version' +PROTOBUF_MISSING = 'OMEMO cant import Google Protobuf, you can find help in ' \ + 'the GitHub Wiki' +GAJIM_VERSION = 'OMEMO only works with the latest Gajim version, get the ' \ + 'latest version from gajim.org' +ERROR_MSG = ''
NS_HINTS = 'urn:xmpp:hints' +NS_PGP = 'urn:xmpp:openpgp:0' +DB_DIR = gajim.gajimpaths.data_root
log = logging.getLogger('gajim.plugin_system.omemo') + try: - from omemo.state import OmemoState - HAS_AXOLOTL = True -except ImportError as e: + from .omemo.state import OmemoState +except Exception as e: log.error(e) - HAS_AXOLOTL = False + ERROR_MSG = 'Error: ' + str(e)
-DB_DIR = gajim.gajimpaths.data_root +try: + import google.protobuf +except Exception as e: + log.error(e) + ERROR_MSG = PROTOBUF_MISSING + +try: + import axolotl +except Exception as e: + log.error(e) + ERROR_MSG = AXOLOTL_MISSING + +GAJIM_VER = gajim.config.get('version') + +if os.name != 'nt': + try: + SETUPTOOLS_MISSING = False + from pkg_resources import parse_version + except Exception as e: + log.error(e) + SETUPTOOLS_MISSING = True + ERROR_MSG = 'You are missing the Setuptools package.' + + if not SETUPTOOLS_MISSING: + if parse_version(GAJIM_VER) < parse_version('0.16.5'): + ERROR_MSG = GAJIM_VERSION + +# pylint: disable=no-init +# pylint: disable=attribute-defined-outside-init
class OmemoPlugin(GajimPlugin): - # pylint: disable=no-init
omemo_states = {} ui_list = {}
@log_calls('OmemoPlugin') def init(self): - # pylint: disable=attribute-defined-outside-init - if not HAS_AXOLOTL: + """ Init """ + if ERROR_MSG: self.activatable = False - self.available_text = _(AXOLOTL_MISSING) + self.available_text = ERROR_MSG return self.events_handlers = { 'mam-message-received': (ged.PRECORE, self.mam_message_received), @@ -96,8 +128,17 @@
@log_calls('OmemoPlugin') def get_omemo_state(self, account): - """ Returns the the OmemoState for specified account. Creates the - OmemoState if it does not exist yet. + """ Returns the the OmemoState for the specified account. + Creates the OmemoState if it does not exist yet. + + Parameters + ---------- + account : str + the account name + + Returns + ------- + OmemoState """ if account not in self.omemo_states: self.deactivate_gajim_e2e(account) @@ -111,10 +152,9 @@
return self.omemo_states[account]
- @log_calls('OmemoPlugin') - def deactivate_gajim_e2e(self, account): - """ Deativates E2E encryption in Gajim per Account - """ + @staticmethod + def deactivate_gajim_e2e(account): + """ Deativates E2E encryption in Gajim """ gajim.config.set_per('accounts', account, 'autonegotiate_esessions', False) gajim.config.set_per('accounts', account, @@ -123,8 +163,11 @@
@log_calls('OmemoPlugin') def signed_in(self, event): - """ - On sign in announce OMEMO support for each account. + """ Method called on SignIn + + Parameters + ---------- + event : SignedInEvent """ account = event.conn.name log.debug(account + @@ -137,6 +180,8 @@
@log_calls('OmemoPlugin') def activate(self): + """ Method called when the Plugin is activated in the PluginManager + """ self.query_for_bundles = [] if NS_NOTIFY not in gajim.gajim_common_features: gajim.gajim_common_features.append(NS_NOTIFY) @@ -153,43 +198,67 @@
@log_calls('OmemoPlugin') def deactivate(self): + """ Method called when the Plugin is deactivated in the PluginManager + + Removes OMEMO from the Entity Capabilities list + """ if NS_NOTIFY in gajim.gajim_common_features: gajim.gajim_common_features.remove(NS_NOTIFY) self._compute_caps_hash()
- @log_calls('OmemoPlugin') - def _compute_caps_hash(self): - for a in gajim.connections: - gajim.caps_hash[a] = caps_cache.compute_caps_hash( - [ - gajim.gajim_identity - ], - gajim.gajim_common_features + gajim.gajim_optional_features[a]) + @staticmethod