'Subscription tracker. Used internally for setting items state in
internal roster representation.'

def RosterIqHandler(self, dis, stanza):

    for item in stanza.getTag('query').getTags('item'):
        jid = item.getAttr('jid')
        if (item.getAttr('subscription') == 'remove'):
            if self._data.has_key(jid):
                del self._data[jid]
            raise NodeProcessed
        self.DEBUG(('Setting    roster    item    %s...' % jid), 'ok')
        if (not self._data.has_key(jid)):
            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 (not self._data[jid].has_key('resources')):
            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
    raise NodeProcessed
