bugfixes, send not-acceptable for fields with only unsupported options
This commit is contained in:
parent
e1c4d80e65
commit
9985b784d5
2 changed files with 20 additions and 13 deletions
|
@ -1584,6 +1584,9 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
if bare_jid != jid:
|
if bare_jid != jid:
|
||||||
session = self.find_session(bare_jid, thread_id, type)
|
session = self.find_session(bare_jid, thread_id, type)
|
||||||
if session:
|
if session:
|
||||||
|
if not session.received_thread_id:
|
||||||
|
thread_id = session.thread_id
|
||||||
|
|
||||||
self.move_session(bare_jid, thread_id, jid.split("/")[1])
|
self.move_session(bare_jid, thread_id, jid.split("/")[1])
|
||||||
return session
|
return session
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,8 @@ class StanzaSession(object):
|
||||||
return "".join([random.choice(string.letters) for x in xrange(0,32)])
|
return "".join([random.choice(string.letters) for x in xrange(0,32)])
|
||||||
|
|
||||||
def send(self, msg):
|
def send(self, msg):
|
||||||
if self.thread_id and isinstance(msg, xmpp.Message):
|
if self.thread_id:
|
||||||
msg.setThread(self.thread_id)
|
msg.NT.thread = self.thread_id
|
||||||
|
|
||||||
msg.setAttr('to', self.jid)
|
msg.setAttr('to', self.jid)
|
||||||
self.conn.send_stanza(msg)
|
self.conn.send_stanza(msg)
|
||||||
|
@ -530,10 +530,10 @@ class EncryptedStanzaSession(StanzaSession):
|
||||||
elif name == 'logging':
|
elif name == 'logging':
|
||||||
my_prefs = self.logging_preference()
|
my_prefs = self.logging_preference()
|
||||||
|
|
||||||
if my_prefs[0] in options:
|
if my_prefs[0] in options: # our first choice is offered, select it
|
||||||
pref = my_prefs[0]
|
pref = my_prefs[0]
|
||||||
negotiated['logging'] = pref
|
negotiated['logging'] = pref
|
||||||
else:
|
else: # see if other acceptable choices are offered
|
||||||
for pref in my_prefs:
|
for pref in my_prefs:
|
||||||
if pref in options:
|
if pref in options:
|
||||||
ask_user['logging'] = pref
|
ask_user['logging'] = pref
|
||||||
|
@ -572,6 +572,8 @@ class EncryptedStanzaSession(StanzaSession):
|
||||||
x.addChild(node=xmpp.DataField(name='accept', value='true'))
|
x.addChild(node=xmpp.DataField(name='accept', value='true'))
|
||||||
|
|
||||||
for name in negotiated:
|
for name in negotiated:
|
||||||
|
# some fields are internal and should not be sent
|
||||||
|
if not name in ('send_pubkey', 'recv_pubkey'):
|
||||||
x.addChild(node=xmpp.DataField(name=name, value=negotiated[name]))
|
x.addChild(node=xmpp.DataField(name=name, value=negotiated[name]))
|
||||||
|
|
||||||
self.negotiated = negotiated
|
self.negotiated = negotiated
|
||||||
|
@ -616,14 +618,16 @@ class EncryptedStanzaSession(StanzaSession):
|
||||||
feature.addChild(node=x)
|
feature.addChild(node=x)
|
||||||
|
|
||||||
if not_acceptable:
|
if not_acceptable:
|
||||||
pass
|
response = xmpp.Error(response, xmpp.ERR_NOT_ACCEPTABLE)
|
||||||
# XXX
|
|
||||||
# <error code='406' type='modify'>
|
feature = xmpp.Node(xmpp.NS_FEATURE + ' feature')
|
||||||
# <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
|
|
||||||
# <feature xmlns='http://jabber.org/protocol/feature-neg'>
|
for f in not_acceptable:
|
||||||
# <field var='security'/>
|
n = xmpp.Node('field')
|
||||||
# </feature>
|
n['var'] = f
|
||||||
# </error>
|
feature.addChild(node=n)
|
||||||
|
|
||||||
|
response.T.error.addChild(node=feature)
|
||||||
|
|
||||||
self.send(response)
|
self.send(response)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue