parent
9cbc6991ae
commit
1c71637adc
@ -1,9 +1,9 @@
|
||||
[info]
|
||||
name: otrplugin
|
||||
short_name: otrplugin
|
||||
version: 0.3.2
|
||||
version: 0.4
|
||||
description: Off-the-Record encryption
|
||||
authors: Pavel R <pd@narayana.im>
|
||||
homepage: https://dev.narayana.im/gajim-otrplugin
|
||||
min_gajim_version: 1.0.3
|
||||
max_gajim_version: 1.1.99
|
||||
authors: Pavel R <pd@narayana.im>, Bohdan Horbeshko <bodqhrohro@gmail.com>
|
||||
homepage: https://dev.narayana.im/narayana/gajim-otrplugin
|
||||
min_gajim_version: 1.3.0
|
||||
max_gajim_version: 1.3.99
|
||||
|
@ -0,0 +1,63 @@
|
||||
## Copyright (C) 2008-2012 Kjell Braden <afflux@pentabarf.de>
|
||||
## Copyright (C) 2019 Pavel R. <pd at narayana dot im>
|
||||
## Copyright (C) 2022 Bohdan Horbeshko <bodqhrohro@gmail.com>
|
||||
|
||||
# This file is part of Gajim OTR Plugin.
|
||||
#
|
||||
# Gajim OTR Plugin is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published
|
||||
# by the Free Software Foundation; version 3 only.
|
||||
#
|
||||
# This software is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You can always obtain full license text at <http://www.gnu.org/licenses/>.
|
||||
|
||||
from nbxmpp.structs import StanzaHandler
|
||||
from gajim.common.modules.base import BaseModule
|
||||
from gajim.common import app
|
||||
from .otr import OTR as OTRInstance
|
||||
|
||||
name = 'OTR'
|
||||
zeroconf = False
|
||||
|
||||
class OTR(BaseModule):
|
||||
|
||||
_nbxmpp_extends = 'OTR'
|
||||
|
||||
def __init__(self, con):
|
||||
BaseModule.__init__(self, con, plugin=True)
|
||||
|
||||
self.handlers = [
|
||||
StanzaHandler(name='message',
|
||||
callback=self._message_received,
|
||||
priority=9),
|
||||
]
|
||||
|
||||
self.available = True
|
||||
self.otr = OTRInstance(con.name)
|
||||
|
||||
def activate(self):
|
||||
""" Method called when the Plugin is activated in the PluginManager
|
||||
"""
|
||||
pass
|
||||
|
||||
def deactivate(self):
|
||||
""" Method called when the Plugin is deactivated in the PluginManager
|
||||
"""
|
||||
pass
|
||||
|
||||
def _message_received(self, client, stanza, properties):
|
||||
if properties.is_omemo or properties.is_openpgp or properties.is_pgp_legacy: return # skip other encryptions
|
||||
if properties.from_muc: return # skip MUC messages
|
||||
msgtxt = stanza.getBody() or ''
|
||||
# if (event.encrypted) or (event.name[0:2] == 'gc') or not (event.msgtxt or '').startswith('?OTR'): return # skip non-OTR messages..
|
||||
if not msgtxt.startswith('?OTR'): return # skip non-OTR messages..
|
||||
if properties.mam != None: return stanza.setBody('') # skip MAM messages (we can not decrypt OTR out of session)..
|
||||
if (app.settings.get_contact_setting(self._account,properties.jid.bare,'encryption')!=self._nbxmpp_extends): return # skip all when encryption not set to OTR
|
||||
self.otr.decrypt(stanza,properties)
|
||||
|
||||
def get_instance(*args, **kwargs):
|
||||
return OTR(*args, **kwargs), 'OTR'
|
Loading…
Reference in new issue