prevent traceback when server doen't include a query in jabber:iq:roster reply. Fixes #4579

This commit is contained in:
Yann Leboulanger 2008-12-15 15:32:59 +00:00
parent 5c8cd8839a
commit 24bb239fdb
1 changed files with 15 additions and 13 deletions

View File

@ -68,19 +68,21 @@ class Roster(PlugIn):
if not sender is None and not sender.bareMatch(
self._owner.User + '@' + self._owner.Server):
return
for item in stanza.getTag('query').getTags('item'):
jid=item.getAttr('jid')
if item.getAttr('subscription')=='remove':
if jid in self._data: del self._data[jid]
return
self.DEBUG('Setting roster item %s...'%jid,'ok')
if jid not in self._data: self._data[jid]={}
self._data[jid]['name']=item.getAttr('name')
self._data[jid]['ask']=item.getAttr('ask')
self._data[jid]['subscription']=item.getAttr('subscription')
self._data[jid]['groups']=[]
if 'resources' not in self._data[jid]: self._data[jid]['resources']={}
for group in item.getTags('group'): self._data[jid]['groups'].append(group.getData())
query = stanza.getTag('query')
if query:
for item in query.getTags('item'):
jid=item.getAttr('jid')
if item.getAttr('subscription')=='remove':
if jid in self._data: del self._data[jid]
return
self.DEBUG('Setting roster item %s...'%jid,'ok')
if jid not in self._data: self._data[jid]={}
self._data[jid]['name']=item.getAttr('name')
self._data[jid]['ask']=item.getAttr('ask')
self._data[jid]['subscription']=item.getAttr('subscription')
self._data[jid]['groups']=[]
if 'resources' not in self._data[jid]: self._data[jid]['resources']={}
for group in item.getTags('group'): self._data[jid]['groups'].append(group.getData())
self._data[self._owner.User+'@'+self._owner.Server]={'resources':{},'name':None,'ask':None,'subscription':None,'groups':None,}
self.set=1