From add87812d10f78dfb5c80d48540c47331631695a Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Mon, 19 Dec 2011 16:21:00 +0100
Subject: [PATCH] don't hide otr plugin when potr is not available, just inform
 user when he wants to enable it.

---
 gotr/manifest.ini |  2 +-
 gotr/otrmodule.py | 16 +++++++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/gotr/manifest.ini b/gotr/manifest.ini
index 7d0a04f8..64246c54 100644
--- a/gotr/manifest.ini
+++ b/gotr/manifest.ini
@@ -1,7 +1,7 @@
 [info]
 name: Off-The-Record Encryption
 short_name: gotr
-version: 1.1
+version: 1.2
 description: See http://www.cypherpunks.ca/otr/
 authors: Kjell Braden <afflux.gajim@pentabarf.de>
 homepage: http://gajim-otr.pentabarf.de
diff --git a/gotr/otrmodule.py b/gotr/otrmodule.py
index a896a043..9823631e 100644
--- a/gotr/otrmodule.py
+++ b/gotr/otrmodule.py
@@ -63,14 +63,17 @@ from common.connection_handlers_events import MessageOutgoingEvent
 from plugins import GajimPlugin
 from message_control import TYPE_CHAT, MessageControl
 from plugins.helpers import log_calls, log
+from plugins.plugin import GajimPluginException
 
 import ui
 
 
 import pickle
-import potr
-if not hasattr(potr, 'VERSION') or potr.VERSION < MINVERSION:
-    raise ImportError('old / unsupported python-otr version')
+HAS_POTR = True
+try:
+    import potr
+except ImportError:
+    HAS_POTR = False
 
 class GajimContext(potr.context.Context):
     __slots__ = ['smpWindow']
@@ -233,6 +236,13 @@ class OtrPlugin(GajimPlugin):
             if acc not in self.config or None not in self.config[acc]:
                 self.config[acc] = {None:DEFAULTFLAGS.copy()}
 
+    @log_calls('OtrPlugin')
+    def activate(self):
+        if not HAS_POTR:
+            raise GajimPluginException('python-otr is missing!')
+        if not hasattr(potr, 'VERSION') or potr.VERSION < MINVERSION:
+            raise GajimPluginException('old / unsupported python-otr version')
+
     def get_otr_status(self, account, contact):
         ctx = self.us[account].getContext(contact.get_full_jid())
 
-- 
GitLab