annotate src/browser/sat_browser/plugin_sec_otr.py @ 522:0de69fec24e9

browser and server sides: OTR plugin, first draft
author souliane <souliane@mailoo.org>
date Tue, 02 Sep 2014 21:28:42 +0200
parents
children 5add182e7dd5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
522
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
1 #!/usr/bin/python
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
3
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
4 # Libervia plugin for OTR encryption
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
6 # Copyright (C) 2013, 2014 Adrien Cossa (souliane@mailoo.org)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
7
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
8 # This program is free software: you can redistribute it and/or modify
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
9 # it under the terms of the GNU Affero General Public License as published by
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
10 # the Free Software Foundation, either version 3 of the License, or
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
11 # (at your option) any later version.
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
12
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
13 # This program is distributed in the hope that it will be useful,
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
16 # GNU Affero General Public License for more details.
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
17
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
18 # You should have received a copy of the GNU Affero General Public License
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
20
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
21 """
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
22 This file is adapted from sat.plugins.plugin.sec_otr. It offers browser-side OTR encryption using otr.js.
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
23 The text messages to display are mostly taken from the Pidgin OTR plugin (GPL 2.0, see http://otr.cypherpunks.ca).
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
24 """
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
25
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
26 from sat.core.i18n import _, D_
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
27 from sat.core.log import getLogger
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
28 from sat.core import exceptions
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
29 log = getLogger(__name__)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
30
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
31 from constants import Const as C
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
32 import jid
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
33 import otrjs_wrapper as otr
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
34 import dialog
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
35
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
36 NS_OTR = "otr_plugin"
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
37 PRIVATE_KEY = "PRIVATE KEY"
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
38 MAIN_MENU = D_('OTR')
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
39 DIALOG_EOL = "<br />"
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
40 AUTH_INFO_TXT = D_("Authenticating a buddy helps ensure that the person you are talking to is who he or she claims to be.{eol}{eol}").format(eol=DIALOG_EOL)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
41 AUTH_FINGERPRINT_TXT = D_("<i>To verify the fingerprint, contact your buddy via some other authenticated channel (i.e. not in this chat), such as the telephone or GPG-signed email. Each of you should tell your fingerprint to the other.</i>{eol}{eol}").format(eol=DIALOG_EOL)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
42 AUTH_QUEST_DEF = D_("<i>To authenticate using a question, pick a question whose answer is known only to you and your buddy. Enter this question and this answer, then wait for your buddy to enter the answer too. If the answers don't match, then you may be talking to an imposter.</i>{eol}{eol}").format(eol=DIALOG_EOL)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
43 AUTH_QUEST_ASK = D_("<i>Your buddy is attempting to determine if he or she is really talking to you, or if it's someone pretending to be you. Your buddy has asked a question, indicated below. To authenticate to your buddy, enter the answer and click OK.</i>{eol}{eol}").format(eol=DIALOG_EOL)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
44 AUTH_SECRET_TXT = D_("{eol}{eol}Enter secret answer here: (case sensitive){eol}").format(eol=DIALOG_EOL)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
45
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
46
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
47 DROP_TXT = D_("You private key is used to encrypt messages for your correspondent, nobody except you must know it, if you are in doubt, you should drop it!{eol}{eol}Are you sure you want to drop your private key?").format(eol=DIALOG_EOL)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
48
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
49 DEFAULT_POLICY_FLAGS = {
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
50 'ALLOW_V2': True,
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
51 'ALLOW_V3': True,
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
52 'REQUIRE_ENCRYPTION': False,
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
53 }
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
54
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
55
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
56 class Context(otr.context.Context):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
57
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
58 def __init__(self, host, account, other_jid):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
59 """
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
60
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
61 @param host (satWebFrontend)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
62 @param account (Account)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
63 @param other_jid (JID): JID of the person your chat buddy
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
64 """
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
65 super(Context, self).__init__(account, other_jid)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
66 self.host = host
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
67
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
68 def getPolicy(self, key):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
69 """Get the value of the specified policy
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
70
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
71 @param key (str): a value in:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
72 - ALLOW_V1 (apriori removed from otr.js)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
73 - ALLOW_V2
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
74 - ALLOW_V3
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
75 - REQUIRE_ENCRYPTION
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
76 - SEND_WHITESPACE_TAG
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
77 - WHITESPACE_START_AKE
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
78 - ERROR_START_AKE
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
79 @return: str
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
80 """
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
81 if key in DEFAULT_POLICY_FLAGS:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
82 return DEFAULT_POLICY_FLAGS[key]
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
83 else:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
84 return False
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
85
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
86 def receiveMessageCb(self, msg, encrypted):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
87 assert isinstance(self.peer, jid.JID)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
88 log.debug("message received (was %s): %s" % ('encrypted' if encrypted else 'plain', msg))
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
89 if not encrypted:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
90 if self.state == otr.context.STATE_ENCRYPTED:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
91 log.warning(u"Received unencrypted message in an encrypted context (from %(jid)s)" % {'jid': self.peer.full()})
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
92 feedback = _(u"WARNING: received unencrypted data in a supposedly encrypted context"),
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
93 self.host.newMessageCb(self.peer, feedback, "headline", self.host.whoami, {})
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
94 self.host.newMessageCb(self.peer, msg, "chat", self.host.whoami, {})
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
95
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
96 def sendMessageCb(self, msg, meta=None):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
97 assert isinstance(self.peer, jid.JID)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
98 log.debug("message to send%s: %s" % ((' (attached meta data: %s)' % meta) if meta else '', msg))
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
99 self.host.bridge.call('sendMessage', (None, self.host.sendError), self.peer.full(), msg, '', 'chat', {'send_only': 'true'})
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
100
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
101 def messageErrorCb(self, error):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
102 log.error('error occured: %s' % error)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
103
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
104 def setStateCb(self, msg_state, status):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
105 other_jid_s = self.peer.full()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
106 feedback = _(u"Error: the state of the conversation with %s is unknown!")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
107
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
108 if status == otr.context.STATUS_AKE_INIT:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
109 return
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
110
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
111 elif status == otr.context.STATUS_SEND_QUERY:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
112 if msg_state in (otr.context.STATE_PLAINTEXT, otr.context.STATE_FINISHED):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
113 feedback = _('Attempting to start a private conversation with %s...')
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
114 elif msg_state == otr.context.STATE_ENCRYPTED:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
115 feedback = _('Attempting to refresh the private conversation with %s...')
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
116
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
117 elif status == otr.context.STATUS_AKE_SUCCESS:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
118 trusted_str = _(u"Verified") if self.getCurrentTrust() else _(u"Unverified")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
119 if msg_state == otr.context.STATE_ENCRYPTED:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
120 feedback = trusted_str + (u" conversation with %s started. Your client is not logging this conversation.")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
121 else:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
122 feedback = _("Error: successfully ake'd with %s but the conversation is not private!")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
123
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
124 elif status == otr.context.STATUS_END_OTR:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
125 if msg_state == otr.context.STATE_PLAINTEXT:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
126 feedback = _("You haven't start any private conversation with %s yet.")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
127 elif msg_state == otr.context.STATE_ENCRYPTED:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
128 feedback = _("%s has ended his/her private conversation with you; you should do the same.")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
129 elif msg_state == otr.context.STATE_FINISHED:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
130 feedback = _("Private conversation with %s lost.")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
131
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
132 self.host.newMessageCb(self.peer, feedback % other_jid_s, "headline", self.host.whoami, {})
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
133
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
134 def setCurrentTrust(self, new_trust='', act='asked', type_='trust'):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
135 log.debug("setCurrentTrust: trust={trust}, act={act}, type={type}".format(type=type_, trust=new_trust, act=act))
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
136 title = (_("Authentication of {jid}") if act == "asked" else _("Authentication to {jid}")).format(jid=self.peer.full())
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
137 if type_ == 'abort':
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
138 msg = _("Authentication aborted.")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
139 elif new_trust:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
140 if act == "asked":
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
141 msg = _("Authentication successful.")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
142 else:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
143 msg = _("Your buddy has successfully authenticated you. You may want to authenticate your buddy as well by asking your own question.")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
144 else:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
145 msg = _("Authentication failed.")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
146 dialog.InfoDialog(title, msg).show()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
147 if act != "asked":
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
148 return
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
149 old_trust = self.getCurrentTrust()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
150 otr.context.Context.setCurrentTrust(self, new_trust)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
151 if old_trust != new_trust:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
152 feedback = _("The privacy status of the current conversation is now: {state}").format(state='Private' if new_trust else 'Unverified')
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
153 self.host.newMessageCb(self.peer, feedback, "headline", self.host.whoami, {})
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
154
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
155 def fingerprintAuthCb(self):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
156 """OTR v2 authentication using manual fingerprint comparison"""
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
157 priv_key = self.user.privkey
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
158
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
159 if priv_key is None: # OTR._authenticate should not let us arrive here
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
160 raise exceptions.InternalError
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
161 return
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
162
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
163 other_key = self.getCurrentKey()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
164 if other_key is None:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
165 # we have a private key, but not the fingerprint of our correspondent
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
166 msg = AUTH_INFO_TXT + ("Your fingerprint is:{eol}{fingerprint}{eol}{eol}Start an OTR conversation to have your correspondent one.").format(fingerprint=priv_key.fingerprint(), eol=DIALOG_EOL)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
167 dialog.InfoDialog(_("Fingerprint"), msg).show()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
168 return
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
169
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
170 def setTrust(confirm):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
171 self.setCurrentTrust('fingerprint' if confirm else '')
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
172
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
173 text = AUTH_INFO_TXT + AUTH_FINGERPRINT_TXT + _("Fingerprint for you, {jid}:{eol}{fingerprint}{eol}{eol}").format(jid=self.host.whoami, fingerprint=priv_key.fingerprint(), eol=DIALOG_EOL)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
174 text += _("Purported fingerprint for {jid}:{eol}{fingerprint}{eol}{eol}").format(jid=self.peer, fingerprint=other_key.fingerprint(), eol=DIALOG_EOL)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
175 text += _("Did you verify that this is in fact the correct fingerprint for {jid}?").format(jid=self.peer)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
176 title = _('Authentication of {jid}').format(jid=self.peer.full())
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
177 dialog.ConfirmDialog(setTrust, text, title).show()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
178
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
179 def smpAuthCb(self, type_, data, act=None):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
180 """OTR v3 authentication using the socialist millionaire protocol.
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
181
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
182 @param type_ (str): a value in ('question', 'trust', 'abort')
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
183 @param data (str, bool): this could be:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
184 - a string containing the question if type_ is 'question'
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
185 - a boolean value telling if the authentication succeed when type_ is 'trust'
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
186 @param act (str): a value in ('asked', 'answered')
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
187 """
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
188 log.debug("smpAuthCb: type={type}, data={data}, act={act}".format(type=type_, data=data, act=act))
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
189 if act is None:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
190 if type_ == 'question':
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
191 act = 'answered' # OTR._authenticate calls this method with act="asked"
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
192 elif type_ == 'abort':
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
193 act = 'asked' # smpAuthAbort triggers this method with act='answered' when needed
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
194
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
195 # FIXME upstream: if buddy uses Pidgin and use fingerprint to authenticate us,
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
196 # we will reach this code... that's wrong, this method is for SMP! There's
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
197 # probably a bug to fix in otr.js. Do it together with the issue that make
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
198 # us need the dirty self.smpAuthAbort.
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
199 else:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
200 log.error("FIXME: unmanaged ambiguous 'act' value in Context.smpAuthCb!")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
201 title = (_("Authentication of {jid}") if act == "asked" else _("Authentication to {jid}")).format(jid=self.peer.full())
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
202 if type_ == 'question':
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
203 if act == 'asked':
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
204 def cb(question, answer=None):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
205 if question is False or not answer: # dialog cancelled or the answer is empty
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
206 return
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
207 self.smpAuthSecret(answer, question)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
208 text = AUTH_INFO_TXT + AUTH_QUEST_DEF + _("Enter question here:{eol}").format(eol=DIALOG_EOL, question=data)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
209 dialog.PromptDialog(cb, [text, AUTH_SECRET_TXT], title=title).show()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
210 else:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
211 def cb(answer):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
212 if not answer: # dialog cancelled or the answer is empty
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
213 self.smpAuthAbort('answered')
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
214 return
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
215 self.smpAuthSecret(answer)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
216 text = AUTH_INFO_TXT + AUTH_QUEST_ASK + _("This is the question asked by your buddy:{eol}{question}").format(eol=DIALOG_EOL, question=data)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
217 dialog.PromptDialog(cb, text + AUTH_SECRET_TXT, title=title).show()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
218 elif type_ == 'trust':
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
219 self.setCurrentTrust('smp' if data else '', act)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
220 elif type_ == 'abort':
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
221 self.setCurrentTrust('', act, 'abort')
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
222
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
223
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
224 class Account(otr.context.Account):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
225
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
226 def __init__(self, host):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
227 log.debug(u"new account: %s" % host.whoami.full())
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
228 if not host.whoami.resource:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
229 log.warning("Account created without resource")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
230 super(Account, self).__init__(host.whoami)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
231 self.host = host
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
232
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
233 def loadPrivkey(self):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
234 return self.privkey
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
235
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
236 def savePrivkey(self):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
237 # TODO: serialize and encrypt the private key and save it to a HTML5 persistent storage
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
238 # We need to ask the user before saving the key (e.g. if he's not on his private machine)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
239 # self.privkey.serializePrivateKey() --> encrypt --> store
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
240 if self.privkey is None:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
241 raise exceptions.InternalError(_("Save is called but privkey is None !"))
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
242 pass
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
243
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
244 def saveTrusts(self):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
245 # TODO save the trusts as it would be done for the private key
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
246 pass
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
247
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
248
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
249 class ContextManager(object):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
250
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
251 def __init__(self, host):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
252 self.host = host
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
253 self.account = Account(host)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
254 self.contexts = {}
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
255
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
256 def startContext(self, other_jid):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
257 assert isinstance(other_jid, jid.JID)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
258 # FIXME upstream: apparently pyjamas doesn't implement setdefault well, it ignores JID.__hash__ redefinition
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
259 #context = self.contexts.setdefault(other_jid, Context(self.host, self.account, other_jid))
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
260 if other_jid not in self.contexts:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
261 self.contexts[other_jid] = Context(self.host, self.account, other_jid)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
262 return self.contexts[other_jid]
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
263
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
264 def getContextForUser(self, other):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
265 log.debug(u"getContextForUser [%s]" % other)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
266 if not other.resource:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
267 log.error("getContextForUser called with a bare jid")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
268 return self.startContext(other)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
269
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
270
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
271 class OTR(object):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
272
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
273 def __init__(self, host):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
274 log.info(_(u"OTR plugin initialization"))
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
275 self.host = host
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
276 self.context_manager = None
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
277 self.last_resources = {}
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
278 self.host.bridge._registerMethods(["skipOTR"])
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
279
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
280 def inhibitMenus(self):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
281 """Tell the caller which dynamic menus should be inhibited"""
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
282 return ["OTR"] # menu categories name to inhibit
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
283
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
284 def extraMenus(self):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
285 # FIXME: handle help strings too
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
286 return [(self._startRefresh, C.MENU_SINGLE, (MAIN_MENU, "Start/Refresh"), (MAIN_MENU, D_("Start/Refresh"))),
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
287 (self._endSession, C.MENU_SINGLE, (MAIN_MENU, "End session"), (MAIN_MENU, D_("End session"))),
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
288 (self._authenticate, C.MENU_SINGLE, (MAIN_MENU, "Authenticate buddy"), (MAIN_MENU, D_("Authenticate buddy"))),
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
289 (self._dropPrivkey, C.MENU_SINGLE, (MAIN_MENU, "Drop private key"), (MAIN_MENU, D_("Drop private key")))]
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
290
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
291 def profileConnected(self):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
292 self.host.bridge.call('skipOTR', None)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
293 self.context_manager = ContextManager(self.host)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
294 # TODO: retrieve the encrypted private key from a HTML5 persistent storage,
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
295 # decrypt it, parse it with otr.crypt.PK.parsePrivateKey(privkey) and
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
296 # assign it to self.context_manager.account.privkey
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
297
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
298 def fixResource(self, jid, cb):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
299 # FIXME: it's dirty, but libervia doesn't manage resources correctly now, refactoring is planed
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
300 if jid.resource:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
301 cb(jid)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
302 elif jid.bare in self.last_resources:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
303 jid.resource = self.last_resources[jid.bare]
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
304 cb(jid)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
305 else:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
306 def gotResource(resource):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
307 jid.setResource(resource)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
308 cb(jid)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
309 self.host.bridge.call('getLastResource', gotResource, jid.full())
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
310
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
311 def messageReceivedTrigger(self, from_jid, msg, msg_type, to_jid, extra):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
312 other_jid = to_jid if from_jid.bare == self.host.whoami.bare else from_jid
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
313
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
314 def cb(jid):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
315 otrctx = self.context_manager.getContextForUser(jid)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
316 otrctx.receiveMessage(msg)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
317 return False # interrupt the main process
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
318
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
319 self.fixResource(other_jid, cb)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
320
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
321 def sendMessageTrigger(self, to_jid, msg, msg_type, extra):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
322 def cb(jid):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
323 otrctx = self.context_manager.getContextForUser(jid)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
324 if msg_type != 'groupchat' and otrctx.state == otr.context.STATE_ENCRYPTED:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
325 log.debug(u"encrypting message")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
326 otrctx.sendMessage(msg)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
327 self.host.newMessageCb(self.host.whoami, msg, msg_type, jid, extra)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
328 else:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
329 log.debug(u"sending message unencrypted")
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
330 self.host.bridge.call('sendMessage', (None, self.host.sendError), to_jid.full(), msg, '', msg_type, extra)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
331
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
332 if msg_type != 'groupchat':
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
333 self.fixResource(to_jid, cb)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
334 else:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
335 cb(to_jid)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
336 return False # interrupt the main process
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
337
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
338 # Menu callbacks
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
339
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
340 def _startRefresh(self, menu_data):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
341 """Start or refresh an OTR session
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
342
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
343 @param menu_data: %(menu_data)s
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
344 """
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
345 def cb(other_jid):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
346 otrctx = self.context_manager.getContextForUser(other_jid)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
347 otrctx.sendQueryMessage()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
348
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
349 try:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
350 other_jid = menu_data['jid']
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
351 self.fixResource(other_jid, cb)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
352 except KeyError:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
353 log.error(_("jid key is not present !"))
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
354 return None
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
355
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
356 def _endSession(self, menu_data):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
357 """End an OTR session
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
358
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
359 @param menu_data: %(menu_data)s
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
360 """
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
361 def cb(other_jid):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
362 otrctx = self.context_manager.getContextForUser(other_jid)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
363 otrctx.disconnect()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
364 try:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
365 other_jid = menu_data['jid']
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
366 self.fixResource(other_jid, cb)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
367 except KeyError:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
368 log.error(_("jid key is not present !"))
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
369 return None
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
370
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
371 def _authenticate(self, menu_data, profile):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
372 """Authenticate other user and see our own fingerprint
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
373
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
374 @param menu_data: %(menu_data)s
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
375 @param profile: %(doc_profile)s
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
376 """
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
377 def cb(to_jid):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
378 otrctx = self.context_manager.getContextForUser(to_jid)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
379 otr_version = otrctx.getUsedVersion()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
380 if otr_version == otr.context.OTR_VERSION_2:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
381 otrctx.fingerprintAuthCb()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
382 elif otr_version == otr.context.OTR_VERSION_3:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
383 otrctx.smpAuthCb('question', None, 'asked')
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
384 else:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
385 dialog.InfoDialog(_("No running session"), _("You must start a private conversation before authenticating your buddy.")).show()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
386
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
387 try:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
388 to_jid = menu_data['jid']
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
389 self.fixResource(to_jid, cb)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
390 except KeyError:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
391 log.error(_("jid key is not present !"))
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
392 return None
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
393
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
394 def _dropPrivkey(self, menu_data, profile):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
395 """Drop our private Key
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
396
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
397 @param menu_data: %(menu_data)s
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
398 @param profile: %(doc_profile)s
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
399 """
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
400 def cb(to_jid):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
401 priv_key = self.context_manager.account.privkey
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
402
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
403 if priv_key is None:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
404 # we have no private key yet
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
405 dialog.InfoDialog(_("No private key"), _("You don't have any private key yet!")).show()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
406 return
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
407
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
408 def dropKey(confirm):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
409 if confirm:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
410 # we end all sessions
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
411 for context in self.context_manager.contexts.values():
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
412 if context.state not in (otr.context.STATE_FINISHED, otr.context.STATE_PLAINTEXT):
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
413 context.disconnect()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
414 self.context_manager.account.privkey = None
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
415 self.context_manager.account.getPrivkey() # as account.privkey are None, getPrivkey will generate a new key, and save it
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
416 dialog.InfoDialog(_("Your private key has been dropped"), _('Drop')).show()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
417
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
418 text = _(DROP_TXT)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
419 title = _('Confirm private key drop')
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
420 dialog.ConfirmDialog(dropKey, text, title).show()
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
421
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
422 try:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
423 to_jid = menu_data['jid']
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
424 self.fixResource(to_jid, cb)
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
425 except KeyError:
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
426 log.error(_("jid key is not present !"))
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
427 return None
0de69fec24e9 browser and server sides: OTR plugin, first draft
souliane <souliane@mailoo.org>
parents:
diff changeset
428