ec43021650
Implemented: - OTR encryption - Store OTR keys and known fingerprints to Gajim data directory in SQLite format - Handling OTR errors Todo: - Fingerprints verification - SMP protocol - Presence handling (e.g. close OTR channel when contacts goes offline)
68 lines
2.2 KiB
Python
68 lines
2.2 KiB
Python
# Copyright (C) 2019 Philipp Hörist <philipp AT hoerist.com>
|
|
# Copyright (C) 2019 Pavel R. <pd at narayana dot im>
|
|
|
|
# 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/>.
|
|
|
|
# TODO: OTR state notifications
|
|
# TODO: Fingerprints authentication GUI
|
|
# TODO: SMP authentication GUI
|
|
|
|
import logging
|
|
import os
|
|
import nbxmpp
|
|
from gajim.common import app
|
|
from gajim.common.connection_handlers_events import MessageOutgoingEvent
|
|
from gajim.plugins import GajimPlugin
|
|
from gajim.plugins.plugins_i18n import _
|
|
from otrplugin.modules import otr
|
|
|
|
log = logging.getLogger('gajim.p.otrplugin')
|
|
|
|
class OTRPlugin(GajimPlugin):
|
|
def init(self):
|
|
self.description = _('Provides Off-the-Record encryption for tet messages')
|
|
self.encryption_name = otr.ENCRYPTION_NAME
|
|
self.modules = [otr]
|
|
self.gui_extension_points = {
|
|
'encrypt' + self.encryption_name: (self.encrypt_message, None),
|
|
'encryption_state' + self.encryption_name: (self.encryption_state, None),
|
|
}
|
|
self.activatable = not otr.ERROR
|
|
self.available_text = otr.ERROR
|
|
return
|
|
|
|
def activate(self):
|
|
pass
|
|
|
|
def deactivate(self):
|
|
pass
|
|
|
|
@staticmethod
|
|
def activate_encryption(chat_control):
|
|
return True
|
|
|
|
@staticmethod
|
|
def encryption_state(chat_control, state):
|
|
state['visible'] = True
|
|
state['authenticated'] = False
|
|
|
|
def encrypt_message(self, conn, event, callback):
|
|
if not event.message: return
|
|
otr = app.connections[event.account].get_module('OTR')
|
|
otr.encrypt_message(event, callback)
|
|
|
|
# if not set, gajim will not allow us to send file with OTR encryption enabled
|
|
def encrypt_file(self, file, account, callback):
|
|
callback(file)
|