changeset 75ede510ed84 in /home/hg/repos/gajim-plugins
author: Bahtiar `kalkin-` Gadimov <[email protected]>
branches:
details:gajim-plugins?cmd=changeset;node=75ede510ed84
description: Merge branch 'omemo-0.9.5'
diffstat:
omemo/CHANGELOG | 5 +
omemo/README.md | 7 +
omemo/__init__.py | 373 ++++++++++++++++++++---
omemo/config_dialog.ui | 194 ++++++++++++-
omemo/fpr_dialog.ui | 27 +-
omemo/manifest.ini | 2 +-
omemo/omemo/liteaxolotlstore.py | 18 +
omemo/omemo/liteidentitykeystore.py | 13 +-
omemo/omemo/litesessionstore.py | 57 ++-
omemo/omemo/state.py | 151 +++++++--
omemo/pkgs/PKGBUILD | 6 +-
omemo/ui.py | 555 +++++++++++++++++++++++------------
12 files changed, 1074 insertions(+), 334 deletions(-)
diffs (truncated from 2101 to 300 lines):
diff -r 1063fb15f4da -r 75ede510ed84 omemo/CHANGELOG
--- a/omemo/CHANGELOG Mon Oct 17 15:14:30 2016 +0200
+++ b/omemo/CHANGELOG Fri Oct 21 03:47:13 2016 +0200
@@ -1,3 +1,8 @@
+0.9.5 / 2016-10-10
+- Add GroupChat BETA
+- Add Option to delete Fingerprints
+- Add Option to deactivate Accounts for OMEMO
+
0.9.0 / 2016-08-28
- Send INFO message to resources who dont support OMEMO
- Check dependencys and give correct error message
diff -r 1063fb15f4da -r 75ede510ed84 omemo/README.md
--- a/omemo/README.md Mon Oct 17 15:14:30 2016 +0200
+++ b/omemo/README.md Fri Oct 21 03:47:13 2016 +0200
@@ -57,6 +57,13 @@
you can receive messages from fingerprints where you didnt made a trust
decision, but you cant
receive Messages from *not trusted* fingerprints
+## Filetransfer
+
+For Filetransfer use the **httpupload** plugin.
+
+For decrypting and showing pictures in chat use the **url_image_preview**
plugin.
+
+If you want to use these plugins together with *OMEMO* you have to install the
`python-cryptography` package
## Debugging
To see OMEMO related debug output start Gajim with the parameter `-l
diff -r 1063fb15f4da -r 75ede510ed84 omemo/__init__.py
--- a/omemo/__init__.py Mon Oct 17 15:14:30 2016 +0200
+++ b/omemo/__init__.py Fri Oct 21 03:47:13 2016 +0200
@@ -21,14 +21,15 @@
import logging
import os
import sqlite3
-import os
+import shutil
+import message_control
-from common import caps_cache, gajim, ged
+from common import caps_cache, gajim, ged, configpaths
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 nbxmpp import NS_CORRECT, NS_ADDRESS
from . import ui
from .ui import Ui
@@ -40,7 +41,7 @@
from common import demandimport
demandimport.enable()
-demandimport.ignore += ['_imp']
+demandimport.ignore += ['_imp', '_thread', 'axolotl']
IQ_CALLBACK = {}
@@ -54,42 +55,51 @@
NS_HINTS = 'urn:xmpp:hints'
NS_PGP = 'urn:xmpp:openpgp:0'
-DB_DIR = gajim.gajimpaths.data_root
+DB_DIR_OLD = gajim.gajimpaths.data_root
+DB_DIR_NEW = configpaths.gajimpaths['MY_DATA']
log = logging.getLogger('gajim.plugin_system.omemo')
try:
- from .omemo.state import OmemoState
-except Exception as e:
- log.error(e)
- ERROR_MSG = 'Error: ' + str(e)
-
-try:
- import google.protobuf
+ prototest = __import__('google.protobuf')
except Exception as e:
log.error(e)
ERROR_MSG = PROTOBUF_MISSING
try:
- import axolotl
+ axolotltest = __import__('axolotl')
except Exception as e:
log.error(e)
ERROR_MSG = AXOLOTL_MISSING
+if not ERROR_MSG:
+ try:
+ from .omemo.state import OmemoState
+ except Exception as e:
+ log.error(e)
+ ERROR_MSG = 'Error: ' + str(e)
+
GAJIM_VER = gajim.config.get('version')
+GROUPCHAT = False
if os.name != 'nt':
try:
SETUPTOOLS_MISSING = False
- from pkg_resources import parse_version
+ pkg = __import__('pkg_resources')
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'):
+ if pkg.parse_version(GAJIM_VER) < pkg.parse_version('0.16.5'):
ERROR_MSG = GAJIM_VERSION
+ if pkg.parse_version(GAJIM_VER) > pkg.parse_version('0.16.5'):
+ GROUPCHAT = True
+else:
+ # if GAJIM_VER < 0.16.5, the Plugin fails on missing dependencys earlier
+ if not GAJIM_VER == '0.16.5':
+ GROUPCHAT = True
# pylint: disable=no-init
# pylint: disable=attribute-defined-outside-init
@@ -99,6 +109,8 @@
omemo_states = {}
ui_list = {}
+ groupchat = {}
+ temp_groupchat = {}
@log_calls('OmemoPlugin')
def init(self):
@@ -116,15 +128,48 @@
'stanza-message-outgoing':
(ged.PRECORE, self.handle_outgoing_stanza),
'message-outgoing':
- (ged.PRECORE, self.handle_outgoing_event),
- }
+ (ged.PRECORE, self.handle_outgoing_event)}
+ if GROUPCHAT:
+ self.events_handlers['gc-stanza-message-outgoing'] =\
+ (ged.PRECORE, self.handle_outgoing_gc_stanza)
+ self.events_handlers['gc-presence-received'] =\
+ (ged.PRECORE, self.gc_presence_received)
+ self.events_handlers['gc-config-changed-received'] =\
+ (ged.PRECORE, self.gc_config_changed_received)
+ self.events_handlers['muc-admin-received'] =\
+ (ged.PRECORE, self.room_memberlist_received)
+
self.config_dialog = ui.OMEMOConfigDialog(self)
self.gui_extension_points = {'chat_control': (self.connect_ui,
- self.disconnect_ui)}
+ self.disconnect_ui),
+ 'groupchat_control': (self.connect_ui,
+ self.disconnect_ui)}
SUPPORTED_PERSONAL_USER_EVENTS.append(DevicelistPEP)
self.plugin = self
self.announced = []
self.query_for_bundles = []
+ self.disabled_accounts = []
+ self.gc_message = {}
+
+ self.config_default_values = {'DISABLED_ACCOUNTS': ([], ''), }
+
+ for account in self.plugin.config['DISABLED_ACCOUNTS']:
+ self.disabled_accounts.append(account)
+
+ def migrate_dbpath(self, account, my_jid):
+ old_dbpath = os.path.join(DB_DIR_OLD, 'omemo_' + account + '.db')
+ new_dbpath = os.path.join(DB_DIR_NEW, 'omemo_' + my_jid + '.db')
+
+ if os.path.exists(old_dbpath):
+ log.debug('Migrating DBName and Path ..')
+ try:
+ shutil.move(old_dbpath, new_dbpath)
+ return new_dbpath
+ except Exception:
+ log.exception('Migration Error:')
+ return old_dbpath
+
+ return new_dbpath
@log_calls('OmemoPlugin')
def get_omemo_state(self, account):
@@ -140,13 +185,14 @@
-------
OmemoState
"""
+ if account in self.disabled_accounts:
+ return
if account not in self.omemo_states:
self.deactivate_gajim_e2e(account)
- db_path = os.path.join(DB_DIR, 'omemo_' + account + '.db')
+ my_jid = gajim.get_jid_from_account(account)
+ db_path = self.migrate_dbpath(account, my_jid)
+
conn = sqlite3.connect(db_path, check_same_thread=False)
-
- my_jid = gajim.get_jid_from_account(account)
-
self.omemo_states[account] = OmemoState(my_jid, conn, account,
self.plugin)
@@ -170,6 +216,8 @@
event : SignedInEvent
"""
account = event.conn.name
+ if account in self.disabled_accounts:
+ return
log.debug(account +
' => Announce Support after Sign In')
self.query_for_bundles = []
@@ -183,11 +231,15 @@
""" 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)
- self._compute_caps_hash()
- # Publish bundle information
+ # Publish bundle information and Entity Caps
for account in gajim.connections:
+ if account in self.disabled_accounts:
+ log.debug(account +
+ ' => Account is disabled')
+ continue
+ if NS_NOTIFY not in gajim.gajim_optional_features[account]:
+ gajim.gajim_optional_features[account].append(NS_NOTIFY)
+ self._compute_caps_hash(account)
if account not in self.announced:
if gajim.account_is_connected(account):
log.debug(account +
@@ -202,23 +254,25 @@
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()
+ for account in gajim.connections:
+ if account in self.disabled_accounts:
+ continue
+ if NS_NOTIFY in gajim.gajim_optional_features[account]:
+ gajim.gajim_optional_features[account].remove(NS_NOTIFY)
+ self._compute_caps_hash(account)
@staticmethod
- def _compute_caps_hash():
+ def _compute_caps_hash(account):
""" Computes the hash for Entity Capabilities and publishes it """
- for acc in gajim.connections:
- gajim.caps_hash[acc] = caps_cache.compute_caps_hash(
- [gajim.gajim_identity],
- gajim.gajim_common_features +
- gajim.gajim_optional_features[acc])
- # re-send presence with new hash
- connected = gajim.connections[acc].connected
- if connected > 1 and gajim.SHOW_LIST[connected] != 'invisible':
- gajim.connections[acc].change_status(
- gajim.SHOW_LIST[connected], gajim.connections[acc].status)
+ gajim.caps_hash[account] = caps_cache.compute_caps_hash(
+ [gajim.gajim_identity],
+ gajim.gajim_common_features +
+ gajim.gajim_optional_features[account])
+ # re-send presence with new hash
+ connected = gajim.connections[account].connected
+ if connected > 1 and gajim.SHOW_LIST[connected] != 'invisible':
+ gajim.connections[account].change_status(
+ gajim.SHOW_LIST[connected], gajim.connections[account].status)
@log_calls('OmemoPlugin')
def mam_message_received(self, msg):
@@ -235,12 +289,15 @@
-------
Return means that the Event is passed on to Gajim
"""
+ account = msg.conn.name
+ if account in self.disabled_accounts:
+ return
+
if msg.msg_.getTag('openpgp', namespace=NS_PGP):
return
omemo_encrypted_tag = msg.msg_.getTag('encrypted', namespace=NS_OMEMO)
if omemo_encrypted_tag:
- account = msg.conn.name
log.debug(account + ' => OMEMO MAM msg received')
state = self.get_omemo_state(account)
@@ -293,12 +350,14 @@
-------
Return means that the Event is passed on to Gajim
"""
+ account = msg.conn.name
+ if account in self.disabled_accounts:
+ return
+
if msg.stanza.getTag('openpgp', namespace=NS_PGP):
return
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits