bridge, quick_frontend: the JID that is assigned by the server can differ from the one we asked for (resource)

This commit is contained in:
souliane 2015-06-10 18:04:43 +02:00
commit 640537662a

View file

@ -63,8 +63,8 @@ class ProfileManager(object):
self.bridge.asyncGetParamA("JabberID", "Connection", profile_key=self.profile,
callback=self._plug_profile_jid, errback=self._getParamError)
def _plug_profile_jid(self, _jid):
self.whoami = jid.JID(_jid)
def _plug_profile_jid(self, jid_s):
self.whoami = jid.JID(jid_s) # resource might change after the connection
self.bridge.asyncGetParamA("autoconnect", "Connection", profile_key=self.profile,
callback=self._plug_profile_autoconnect, errback=self._getParamError)
@ -439,9 +439,14 @@ class QuickApp(object):
def newWidget(self, widget):
raise NotImplementedError
def connectedHandler(self, profile):
"""called when the connection is made"""
def connectedHandler(self, profile, jid_s):
"""Called when the connection is made.
@param jid_s (unicode): the JID that we were assigned by the server,
as the resource might differ from the JID we asked for.
"""
log.debug(_("Connected"))
self.profiles[profile].whoami = jid.JID(jid_s)
self.setPresenceStatus(profile=profile)
self.contact_lists[profile].fill()
@ -451,8 +456,8 @@ class QuickApp(object):
self.contact_lists[profile].clearContacts()
self.setPresenceStatus(C.PRESENCE_UNAVAILABLE, '', profile=profile)
def newContactHandler(self, JabberId, attributes, groups, profile):
entity = jid.JID(JabberId)
def newContactHandler(self, jid_s, attributes, groups, profile):
entity = jid.JID(jid_s)
_groups = list(groups)
self.contact_lists[profile].setContact(entity, _groups, attributes, in_roster=True)