changeset 1134:8def4a3f55c2

plugin OTR: temporary potr monkey patch to work around a unicode bug, to be removed as soon as a potr fixed version is released (potr maintainer should do it soon)
author Goffi <goffi@goffi.org>
date Mon, 25 Aug 2014 21:32:23 +0200
parents 7e6856902488
children 3158f9e08760
files src/plugins/plugin_sec_otr.py
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_sec_otr.py	Mon Aug 25 21:32:23 2014 +0200
+++ b/src/plugins/plugin_sec_otr.py	Mon Aug 25 21:32:23 2014 +0200
@@ -154,11 +154,28 @@
 
     def __init__(self, host):
         log.info(_(u"OTR plugin initialization"))
+        self._fixPotr() # FIXME: to be removed when potr will be fixed
         self.host = host
         self.context_managers = {}
         host.trigger.add("MessageReceived", self.MessageReceivedTrigger, priority=100000)
         host.trigger.add("sendMessage", self.sendMessageTrigger, priority=100000)
 
+    def _fixPotr(self):
+        # FIXME: potr fix for bad unicode handling
+        # this method monkeypatch it, must be removed when potr
+        # is fixed
+
+        def getDefaultQueryMessage(self, policy):
+            defaultQuery = '?OTRv{versions}?\nI would like to start ' \
+                           'an Off-the-Record private conversation. However, you ' \
+                           'do not have a plugin to support that.\nSee '\
+                           'https://otr.cypherpunks.ca/ for more information.'
+            v = '2' if policy('ALLOW_V2') else ''
+            msg = defaultQuery.format(versions=v)
+            return msg.encode('ascii')
+
+        potr.context.Account.getDefaultQueryMessage = getDefaultQueryMessage
+
     @defer.inlineCallbacks
     def profileConnected(self, profile):
         client = self.host.getClient(profile)