diff frontends/src/quick_frontend/quick_app.py @ 1435:7590bbf44eed

bridge, quick_frontend: the JID that is assigned by the server can differ from the one we asked for (resource)
author souliane <souliane@mailoo.org>
date Wed, 10 Jun 2015 18:04:43 +0200
parents 798e5e38516b
children e27963c9c219
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_app.py	Wed Jun 10 09:18:34 2015 +0200
+++ b/frontends/src/quick_frontend/quick_app.py	Wed Jun 10 18:04:43 2015 +0200
@@ -63,8 +63,8 @@
         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 @@
     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 @@
         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)