comparison src/plugins/plugin_sec_otr.py @ 1135:3158f9e08760

plugin OTR: a warning is logged when Account is instancied with a bare jid.
author Goffi <goffi@goffi.org>
date Mon, 25 Aug 2014 21:32:23 +0200
parents 8def4a3f55c2
children ea2bbdf5b541
comparison
equal deleted inserted replaced
1134:8def4a3f55c2 1135:3158f9e08760
78 client.xmlstream.send(mess_data['xml']) 78 client.xmlstream.send(mess_data['xml'])
79 79
80 def setState(self, state): 80 def setState(self, state):
81 old_state = self.state 81 old_state = self.state
82 super(Context, self).setState(state) 82 super(Context, self).setState(state)
83 log.debug(u"setState: %s (old_state=%s) " % (state, old_state)) 83 log.debug(u"setState: %s (old_state=%s)" % (state, old_state))
84 84
85 if state == potr.context.STATE_PLAINTEXT: 85 if state == potr.context.STATE_PLAINTEXT:
86 feedback = _(u"/!\\ conversation with %(other_jid)s is now UNENCRYPTED") % {'other_jid': self.peer.full()} 86 feedback = _(u"/!\\ conversation with %(other_jid)s is now UNENCRYPTED") % {'other_jid': self.peer.full()}
87 elif state == potr.context.STATE_ENCRYPTED: 87 elif state == potr.context.STATE_ENCRYPTED:
88 try: 88 try:
114 114
115 class Account(potr.context.Account): 115 class Account(potr.context.Account):
116 116
117 def __init__(self, host, client): 117 def __init__(self, host, client):
118 log.debug(u"new account: %s" % client.jid) 118 log.debug(u"new account: %s" % client.jid)
119 super(Account, self).__init__(client.jid, "xmpp", 1024) 119 if not client.jid.resource:
120 log.warning("Account created without resource")
121 super(Account, self).__init__(unicode(client.jid), "xmpp", 1024)
120 self.host = host 122 self.host = host
121 self.client = client 123 self.client = client
122 124
123 def loadPrivkey(self): 125 def loadPrivkey(self):
124 log.debug(u"loadPrivkey") 126 log.debug(u"loadPrivkey")
145 context = self.contexts.setdefault(other_jid, Context(self.host, self.account, other_jid)) 147 context = self.contexts.setdefault(other_jid, Context(self.host, self.account, other_jid))
146 return context 148 return context
147 149
148 def getContextForUser(self, other): 150 def getContextForUser(self, other):
149 log.debug(u"getContextForUser [%s]" % other) 151 log.debug(u"getContextForUser [%s]" % other)
152 if not other.resource:
153 log.warning("getContextForUser called with a bare jid")
150 return self.startContext(other) 154 return self.startContext(other)
151 155
152 156
153 class OTR(object): 157 class OTR(object):
154 158