make gotr plugin visible but not activatable if potr is missing

This commit is contained in:
Yann Leboulanger
2012-05-01 00:48:26 +02:00
parent 8bff21d54b
commit e8f0870878
2 changed files with 136 additions and 129 deletions

View File

@@ -74,13 +74,11 @@ try:
import potr
if not hasattr(potr, 'VERSION') or potr.VERSION < MINVERSION:
raise ImportError('old / unsupported python-otr version')
except ImportError:
HAS_POTR = False
def get_jid_from_fjid(fjid):
def get_jid_from_fjid(fjid):
return gajim.get_room_and_nick_from_fjid(fjid)[0]
class GajimContext(potr.context.Context):
class GajimContext(potr.context.Context):
# self.peer is fjid
# self.jid does not contain resource
__slots__ = ['smpWindow', 'jid']
@@ -148,7 +146,7 @@ class GajimContext(potr.context.Context):
log.debug('getPolicy(key=%s) = %s', key, ret)
return ret
class GajimOtrAccount(potr.context.Account):
class GajimOtrAccount(potr.context.Account):
contextclass = GajimContext
def __init__(self, plugin, accountname):
global PROTOCOL, MMS
@@ -215,7 +213,8 @@ class GajimOtrAccount(potr.context.Account):
except IOError, e:
log.exception('IOError occurred when loading fpr file for %s',
self.name)
except ImportError:
HAS_POTR = False
def otr_dialog_destroy(widget, *args, **kwargs):
widget.destroy()
@@ -236,7 +235,11 @@ class OtrPlugin(GajimPlugin):
self.gui_extension_points = {
'chat_control' : (self.cc_connect, self.cc_disconnect)
}
if not HAS_POTR:
self.activatable = False
self.available_text = 'potr is not installed. Get it from %s' % \
'https://github.com/afflux/pure-python-otr'
else:
for acc in gajim.contacts.get_accounts():
self.us[acc] = GajimOtrAccount(self, acc)
self.us[acc].loadTrusts()

View File

@@ -24,7 +24,11 @@ from common import gajim
from plugins.gui import GajimPluginConfigDialog
import otrmodule
import potr
HAS_PORT = True
try:
import potr
except:
HAS_POTR = False
class OtrPluginConfigDialog(GajimPluginConfigDialog):