[omemo] Adapt to Gajim changes
This commit is contained in:
@@ -82,6 +82,7 @@ class DeviceManager:
|
|||||||
def get_devices_for_encryption(self, jid):
|
def get_devices_for_encryption(self, jid):
|
||||||
devices_for_encryption = []
|
devices_for_encryption = []
|
||||||
|
|
||||||
|
# TODO:
|
||||||
if app.contacts.get_groupchat_contact(self._account, jid) is not None:
|
if app.contacts.get_groupchat_contact(self._account, jid) is not None:
|
||||||
devices_for_encryption = self._get_devices_for_muc_encryption(jid)
|
devices_for_encryption = self._get_devices_for_muc_encryption(jid)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class OMEMOConfigDialog(GajimPluginConfigDialog):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def update_account_store(self):
|
def update_account_store(self):
|
||||||
for account in sorted(app.contacts.get_accounts()):
|
for account in sorted(app.settings.get_active_accounts()):
|
||||||
if account in self.disabled_accounts:
|
if account in self.disabled_accounts:
|
||||||
continue
|
continue
|
||||||
if account == 'Local':
|
if account == 'Local':
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class KeyDialog(Gtk.Dialog):
|
|||||||
self._groupchat = groupchat
|
self._groupchat = groupchat
|
||||||
self._contact = contact
|
self._contact = contact
|
||||||
self._windows = windows
|
self._windows = windows
|
||||||
self._account = self._contact.account.name
|
self._account = self._contact.account
|
||||||
self._plugin = plugin
|
self._plugin = plugin
|
||||||
self._omemo = self._plugin.get_omemo(self._account)
|
self._omemo = self._plugin.get_omemo(self._account)
|
||||||
self._own_jid = app.get_jid_from_account(self._account)
|
self._own_jid = app.get_jid_from_account(self._account)
|
||||||
|
|||||||
@@ -156,9 +156,7 @@ class OMEMO(BaseModule):
|
|||||||
callback(event)
|
callback(event)
|
||||||
return
|
return
|
||||||
|
|
||||||
to_jid = app.get_jid_without_resource(event.jid)
|
omemo_message = self.backend.encrypt(event.jid, event.message)
|
||||||
|
|
||||||
omemo_message = self.backend.encrypt(to_jid, event.message)
|
|
||||||
if omemo_message is None:
|
if omemo_message is None:
|
||||||
session = event.session if hasattr(event, 'session') else None
|
session = event.session if hasattr(event, 'session') else None
|
||||||
app.nec.push_incoming_event(
|
app.nec.push_incoming_event(
|
||||||
@@ -265,6 +263,7 @@ class OMEMO(BaseModule):
|
|||||||
# History Message from MUC
|
# History Message from MUC
|
||||||
return properties.muc_ofrom.bare
|
return properties.muc_ofrom.bare
|
||||||
|
|
||||||
|
# TODO:
|
||||||
contact = app.contacts.get_gc_contact(self._account, room_jid, resource)
|
contact = app.contacts.get_gc_contact(self._account, room_jid, resource)
|
||||||
if contact is not None:
|
if contact is not None:
|
||||||
return JID.from_string(contact.jid).bare
|
return JID.from_string(contact.jid).bare
|
||||||
@@ -341,13 +340,14 @@ class OMEMO(BaseModule):
|
|||||||
def is_contact_in_roster(self, jid):
|
def is_contact_in_roster(self, jid):
|
||||||
if jid == self._own_jid:
|
if jid == self._own_jid:
|
||||||
return True
|
return True
|
||||||
|
# TODO:
|
||||||
contact = app.contacts.get_first_contact_from_jid(self._account, jid)
|
contact = app.contacts.get_first_contact_from_jid(self._account, jid)
|
||||||
if contact is None:
|
if contact is None:
|
||||||
return False
|
return False
|
||||||
return contact.sub == 'both'
|
return contact.sub == 'both'
|
||||||
|
|
||||||
def on_muc_disco_update(self, event):
|
def on_muc_disco_update(self, event):
|
||||||
self._check_if_omemo_capable(event.room_jid)
|
self._check_if_omemo_capable(event.jid)
|
||||||
|
|
||||||
def on_muc_joined(self, event):
|
def on_muc_joined(self, event):
|
||||||
self._check_if_omemo_capable(event.room_jid)
|
self._check_if_omemo_capable(event.room_jid)
|
||||||
@@ -440,8 +440,7 @@ class OMEMO(BaseModule):
|
|||||||
|
|
||||||
# Trigger dialog to trust new Fingerprints if
|
# Trigger dialog to trust new Fingerprints if
|
||||||
# the Chat Window is Open
|
# the Chat Window is Open
|
||||||
ctrl = app.interface.msg_win_mgr.get_control(
|
ctrl = app.window.get_control(self._account, jid)
|
||||||
jid, self._account)
|
|
||||||
if ctrl:
|
if ctrl:
|
||||||
app.nec.push_incoming_event(
|
app.nec.push_incoming_event(
|
||||||
NetworkEvent('omemo-new-fingerprint', chat_control=ctrl))
|
NetworkEvent('omemo-new-fingerprint', chat_control=ctrl))
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ from gi.repository import Gdk
|
|||||||
|
|
||||||
from nbxmpp.namespaces import Namespace
|
from nbxmpp.namespaces import Namespace
|
||||||
|
|
||||||
from gajim import dialogs
|
|
||||||
from gajim.common import app, ged
|
from gajim.common import app, ged
|
||||||
|
|
||||||
|
from gajim.gui.dialogs import ErrorDialog
|
||||||
|
|
||||||
from gajim.plugins import GajimPlugin
|
from gajim.plugins import GajimPlugin
|
||||||
from gajim.plugins.plugins_i18n import _
|
from gajim.plugins.plugins_i18n import _
|
||||||
from gajim.groupchat_control import GroupchatControl
|
|
||||||
|
|
||||||
AXOLOTL_MISSING = 'You are missing Python3-Axolotl or use an outdated version'
|
AXOLOTL_MISSING = 'You are missing Python3-Axolotl or use an outdated version'
|
||||||
PROTOBUF_MISSING = "OMEMO can't import Google Protobuf, you can find help in " \
|
PROTOBUF_MISSING = "OMEMO can't import Google Protobuf, you can find help in " \
|
||||||
@@ -91,7 +92,7 @@ class OmemoPlugin(GajimPlugin):
|
|||||||
'omemo-new-fingerprint': (ged.PRECORE, self._on_new_fingerprints),
|
'omemo-new-fingerprint': (ged.PRECORE, self._on_new_fingerprints),
|
||||||
'signed-in': (ged.PRECORE, self._on_signed_in),
|
'signed-in': (ged.PRECORE, self._on_signed_in),
|
||||||
'muc-disco-update': (ged.GUI1, self._on_muc_disco_update),
|
'muc-disco-update': (ged.GUI1, self._on_muc_disco_update),
|
||||||
'muc-joined': (ged.GUI1, self._on_muc_joined),
|
'room-joined': (ged.GUI1, self._on_muc_joined),
|
||||||
}
|
}
|
||||||
self.modules = [omemo]
|
self.modules = [omemo]
|
||||||
self.config_dialog = OMEMOConfigDialog(self)
|
self.config_dialog = OMEMOConfigDialog(self)
|
||||||
@@ -236,10 +237,10 @@ class OmemoPlugin(GajimPlugin):
|
|||||||
contact = chat_control.contact
|
contact = chat_control.contact
|
||||||
omemo = self.get_omemo(account)
|
omemo = self.get_omemo(account)
|
||||||
self.new_fingerprints_available(chat_control)
|
self.new_fingerprints_available(chat_control)
|
||||||
if isinstance(chat_control, GroupchatControl):
|
if chat_control.is_groupchat:
|
||||||
room = chat_control.room_jid
|
room = chat_control.room_jid
|
||||||
if not omemo.is_omemo_groupchat(room):
|
if not omemo.is_omemo_groupchat(room):
|
||||||
dialogs.ErrorDialog(
|
ErrorDialog(
|
||||||
_('Bad Configuration'),
|
_('Bad Configuration'),
|
||||||
_('To use OMEMO in a Groupchat, the Groupchat should be'
|
_('To use OMEMO in a Groupchat, the Groupchat should be'
|
||||||
' non-anonymous and members-only.'))
|
' non-anonymous and members-only.'))
|
||||||
@@ -279,7 +280,7 @@ class OmemoPlugin(GajimPlugin):
|
|||||||
jid = chat_control.contact.jid
|
jid = chat_control.contact.jid
|
||||||
account = chat_control.account
|
account = chat_control.account
|
||||||
omemo = self.get_omemo(account)
|
omemo = self.get_omemo(account)
|
||||||
if isinstance(chat_control, GroupchatControl):
|
if chat_control.is_groupchat:
|
||||||
for jid_ in omemo.backend.get_muc_members(chat_control.room_jid,
|
for jid_ in omemo.backend.get_muc_members(chat_control.room_jid,
|
||||||
without_self=False):
|
without_self=False):
|
||||||
fingerprints = omemo.backend.storage.getNewFingerprints(jid_)
|
fingerprints = omemo.backend.storage.getNewFingerprints(jid_)
|
||||||
@@ -287,7 +288,7 @@ class OmemoPlugin(GajimPlugin):
|
|||||||
self._show_fingerprint_window(
|
self._show_fingerprint_window(
|
||||||
chat_control, fingerprints)
|
chat_control, fingerprints)
|
||||||
break
|
break
|
||||||
elif not isinstance(chat_control, GroupchatControl):
|
else:
|
||||||
fingerprints = omemo.backend.storage.getNewFingerprints(jid)
|
fingerprints = omemo.backend.storage.getNewFingerprints(jid)
|
||||||
if fingerprints:
|
if fingerprints:
|
||||||
self._show_fingerprint_window(
|
self._show_fingerprint_window(
|
||||||
@@ -297,13 +298,11 @@ class OmemoPlugin(GajimPlugin):
|
|||||||
contact = chat_control.contact
|
contact = chat_control.contact
|
||||||
account = chat_control.account
|
account = chat_control.account
|
||||||
omemo = self.get_omemo(account)
|
omemo = self.get_omemo(account)
|
||||||
transient = chat_control.parent_win.window
|
|
||||||
|
|
||||||
if 'dialog' not in self._windows:
|
if 'dialog' not in self._windows:
|
||||||
is_groupchat = isinstance(chat_control, GroupchatControl)
|
|
||||||
self._windows['dialog'] = \
|
self._windows['dialog'] = \
|
||||||
KeyDialog(self, contact, transient,
|
KeyDialog(self, contact, app.window,
|
||||||
self._windows, groupchat=is_groupchat)
|
self._windows, groupchat=chat_control.is_groupchat)
|
||||||
if fingerprints:
|
if fingerprints:
|
||||||
log.debug('%s => Showing Fingerprint Prompt for %s',
|
log.debug('%s => Showing Fingerprint Prompt for %s',
|
||||||
account, contact.jid)
|
account, contact.jid)
|
||||||
@@ -326,4 +325,4 @@ class OmemoPlugin(GajimPlugin):
|
|||||||
msg = _('You have undecided fingerprints')
|
msg = _('You have undecided fingerprints')
|
||||||
if msg is None:
|
if msg is None:
|
||||||
return
|
return
|
||||||
chat_control.add_status_message(msg)
|
chat_control.add_info_message(msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user