diff options
author | Nathan Fritz <nathan@andyet.net> | 2010-03-26 13:55:03 -0700 |
---|---|---|
committer | Nathan Fritz <nathan@andyet.net> | 2010-03-26 13:55:03 -0700 |
commit | 0fc9072e5d0ebd90339e2a809ead8ec8b15f6d7e (patch) | |
tree | 34e05aef9ba6a5ae007ceefb43c2d2051f3abeaa /sleekxmpp/__init__.py | |
parent | 0659ddeff07b33d3f5e2c21cf9378dfc091386f1 (diff) | |
download | slixmpp-0fc9072e5d0ebd90339e2a809ead8ec8b15f6d7e.tar.gz slixmpp-0fc9072e5d0ebd90339e2a809ead8ec8b15f6d7e.tar.bz2 slixmpp-0fc9072e5d0ebd90339e2a809ead8ec8b15f6d7e.tar.xz slixmpp-0fc9072e5d0ebd90339e2a809ead8ec8b15f6d7e.zip |
fixed bug #16 Roster not updating
Diffstat (limited to 'sleekxmpp/__init__.py')
-rw-r--r-- | sleekxmpp/__init__.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/sleekxmpp/__init__.py b/sleekxmpp/__init__.py index b81e8a13..8452e65d 100644 --- a/sleekxmpp/__init__.py +++ b/sleekxmpp/__init__.py @@ -163,7 +163,8 @@ class ClientXMPP(basexmpp, XMLStream): def getRoster(self): """Request the roster be sent.""" - self.Iq().setValues({'type': 'get'}).enable('roster').send() + iq = self.Iq().setValues({'type': 'get'}).enable('roster').send() + self._handleRoster(iq, request=True) def _handleStreamFeatures(self, features): self.features = [] @@ -245,11 +246,12 @@ class ClientXMPP(basexmpp, XMLStream): self.sessionstarted = True self.event("session_start") - def _handleRoster(self, iq): - for jid in iq['roster']['items']: - if not jid.bare in self.roster: - self.roster[jid.bare] = {'groups': [], 'name': '', 'subscription': 'none', 'presence': {}, 'in_roster': True} - self.roster[jid.bare].update(iq['roster']['jid']) - if iq['type'] == 'set': - self.send(self.Iq().setValues({'type': 'result', 'id': iq['id']}).enable('roster')) + def _handleRoster(self, iq, request=False): + if iq['type'] == 'set' or (iq['type'] == 'result' and request): + for jid in iq['roster']['items']: + if not jid in self.roster: + self.roster[jid] = {'groups': [], 'name': '', 'subscription': 'none', 'presence': {}, 'in_roster': True} + self.roster[jid].update(iq['roster']['items'][jid]) + if iq['type'] == 'set': + self.send(self.Iq().setValues({'type': 'result', 'id': iq['id']}).enable('roster')) self.event("roster_update", iq) |