Fix the OTR plugin

This commit is contained in:
mathieui 2018-08-09 00:45:10 +02:00
parent 6cc1360a3a
commit 53ea677bad
No known key found for this signature in database
GPG key ID: C59F84CEEFD616E3

View file

@ -175,14 +175,15 @@ real JID of your contact (or check if the same nick is used by different people)
""" """
from gettext import gettext as _ from gettext import gettext as _
import potr
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
import os import os
import html import html
import curses import curses
from pathlib import Path
import potr
from potr.context import NotEncryptedError, UnencryptedMessage, ErrorReceived, NotOTRMessage,\ from potr.context import NotEncryptedError, UnencryptedMessage, ErrorReceived, NotOTRMessage,\
STATE_ENCRYPTED, STATE_PLAINTEXT, STATE_FINISHED, Context, Account, crypt STATE_ENCRYPTED, STATE_PLAINTEXT, STATE_FINISHED, Context, Account, crypt
@ -360,9 +361,9 @@ class PoezioContext(Context):
'bare_jid': safeJID(self.peer).bare 'bare_jid': safeJID(self.peer).bare
} }
tab = self.core.get_tab_by_name(self.peer) tab = self.core.tabs.by_name(self.peer)
if not tab: if not tab:
tab = self.core.get_tab_by_name(safeJID(self.peer).bare, tab = self.core.tabs.by_name(safeJID(self.peer).bare,
DynamicConversationTab) DynamicConversationTab)
if tab and not tab.locked_resource == safeJID(self.peer).resource: if tab and not tab.locked_resource == safeJID(self.peer).resource:
tab = None tab = None
@ -472,13 +473,13 @@ class Plugin(BasePlugin):
keys_dir = self.config.get('keys_dir', '') keys_dir = self.config.get('keys_dir', '')
otr_dir = Path(keys_dir).expanduser() if keys_dir else xdg.DATA_HOME / 'otr' otr_dir = Path(keys_dir).expanduser() if keys_dir else xdg.DATA_HOME / 'otr'
try: try:
otr_dir.mkdir(parents=True, exists_ok=True) otr_dir.mkdir(parents=True, exist_ok=True)
except OSError as e: except OSError as e:
self.api.information('The OTR-specific folder could not ' self.api.information('The OTR-specific folder could not '
'be created: %s. Poezio will be unable ' 'be created: %s. Poezio will be unable '
'to save keys and trusts' % e, 'OTR') 'to save keys and trusts' % e, 'OTR')
except: except Exception as e:
self.api.information('The OTR-specific folder could not ' self.api.information('The OTR-specific folder could not '
'be created. Poezio will be unable ' 'be created. Poezio will be unable '
'to save keys and trusts', 'OTR') 'to save keys and trusts', 'OTR')