diff options
Diffstat (limited to 'sleekxmpp/clientxmpp.py')
-rw-r--r-- | sleekxmpp/clientxmpp.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/sleekxmpp/clientxmpp.py b/sleekxmpp/clientxmpp.py index ae3803ef..6bcb36ba 100644 --- a/sleekxmpp/clientxmpp.py +++ b/sleekxmpp/clientxmpp.py @@ -96,6 +96,7 @@ class ClientXMPP(BaseXMPP): self.add_event_handler('connected', self._reset_connection_state) self.add_event_handler('session_bind', self._handle_session_bind) + self.add_event_handler('roster_update', self._handle_roster) self.register_stanza(StreamFeatures) @@ -106,7 +107,7 @@ class ClientXMPP(BaseXMPP): self.register_handler( Callback('Roster Update', StanzaPath('iq@type=set/roster'), - self._handle_roster)) + lambda iq: self.event('roster_update', iq))) # Setup default stream features self.register_plugin('feature_starttls') @@ -154,8 +155,6 @@ class ClientXMPP(BaseXMPP): address = (self.boundjid.host, 5222) self.dns_service = 'xmpp-client' - self._expected_server_name = self.boundjid.host - return XMLStream.connect(self, address[0], address[1], use_tls=use_tls, use_ssl=use_ssl, reattempt=reattempt) @@ -244,14 +243,22 @@ class ClientXMPP(BaseXMPP): if 'rosterver' in self.features: iq['roster']['ver'] = self.client_roster.version - if not block and callback is None: - callback = lambda resp: self._handle_roster(resp) + + if not block or callback is not None: + block = False + if callback is None: + callback = lambda resp: self.event('roster_update', resp) + else: + orig_cb = callback + def wrapped(resp): + self.event('roster_update', resp) + orig_cb(resp) + callback = wrapped response = iq.send(block, timeout, callback) - self.event('roster_received', response) if block: - self._handle_roster(response) + self.event('roster_update', response) return response def _reset_connection_state(self, event=None): @@ -302,7 +309,6 @@ class ClientXMPP(BaseXMPP): roster[jid].save(remove=(item['subscription'] == 'remove')) - self.event("roster_update", iq) if iq['type'] == 'set': resp = self.Iq(stype='result', sto=iq['from'], |