Mercurial > libervia-backend
comparison src/plugins/plugin_sec_otr.py @ 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 | ef7b7dd5c5db |
children | 3158f9e08760 |
comparison
equal
deleted
inserted
replaced
1133:7e6856902488 | 1134:8def4a3f55c2 |
---|---|
152 | 152 |
153 class OTR(object): | 153 class OTR(object): |
154 | 154 |
155 def __init__(self, host): | 155 def __init__(self, host): |
156 log.info(_(u"OTR plugin initialization")) | 156 log.info(_(u"OTR plugin initialization")) |
157 self._fixPotr() # FIXME: to be removed when potr will be fixed | |
157 self.host = host | 158 self.host = host |
158 self.context_managers = {} | 159 self.context_managers = {} |
159 host.trigger.add("MessageReceived", self.MessageReceivedTrigger, priority=100000) | 160 host.trigger.add("MessageReceived", self.MessageReceivedTrigger, priority=100000) |
160 host.trigger.add("sendMessage", self.sendMessageTrigger, priority=100000) | 161 host.trigger.add("sendMessage", self.sendMessageTrigger, priority=100000) |
162 | |
163 def _fixPotr(self): | |
164 # FIXME: potr fix for bad unicode handling | |
165 # this method monkeypatch it, must be removed when potr | |
166 # is fixed | |
167 | |
168 def getDefaultQueryMessage(self, policy): | |
169 defaultQuery = '?OTRv{versions}?\nI would like to start ' \ | |
170 'an Off-the-Record private conversation. However, you ' \ | |
171 'do not have a plugin to support that.\nSee '\ | |
172 'https://otr.cypherpunks.ca/ for more information.' | |
173 v = '2' if policy('ALLOW_V2') else '' | |
174 msg = defaultQuery.format(versions=v) | |
175 return msg.encode('ascii') | |
176 | |
177 potr.context.Account.getDefaultQueryMessage = getDefaultQueryMessage | |
161 | 178 |
162 @defer.inlineCallbacks | 179 @defer.inlineCallbacks |
163 def profileConnected(self, profile): | 180 def profileConnected(self, profile): |
164 client = self.host.getClient(profile) | 181 client = self.host.getClient(profile) |
165 self.context_managers[profile] = ContextManager(self.host, client) | 182 self.context_managers[profile] = ContextManager(self.host, client) |