changeset 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 b06047e1c1fb
children e27963c9c219
files frontends/src/quick_frontend/quick_app.py src/bridge/DBus.py src/bridge/bridge_constructor/bridge_template.ini src/core/xmpp.py
diffstat 4 files changed, 18 insertions(+), 12 deletions(-) [+]
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)
 
--- a/src/bridge/DBus.py	Wed Jun 10 09:18:34 2015 +0200
+++ b/src/bridge/DBus.py	Wed Jun 10 18:04:43 2015 +0200
@@ -141,8 +141,8 @@
         pass
 
     @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
-                         signature='s')
-    def connected(self, profile):
+                         signature='ss')
+    def connected(self, profile, jid_s):
         pass
 
     @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
@@ -555,8 +555,8 @@
     def askConfirmation(self, id, conf_type, data, profile):
         self.dbus_bridge.askConfirmation(id, conf_type, data, profile)
 
-    def connected(self, profile):
-        self.dbus_bridge.connected(profile)
+    def connected(self, profile, jid_s):
+        self.dbus_bridge.connected(profile, jid_s)
 
     def contactDeleted(self, entity_jid, profile):
         self.dbus_bridge.contactDeleted(entity_jid, profile)
--- a/src/bridge/bridge_constructor/bridge_template.ini	Wed Jun 10 09:18:34 2015 +0200
+++ b/src/bridge/bridge_constructor/bridge_template.ini	Wed Jun 10 18:04:43 2015 +0200
@@ -8,9 +8,10 @@
 [connected]
 type=signal
 category=core
-sig_in=s
+sig_in=ss
 doc=Connection is done
 doc_param_0=%(doc_profile)s
+doc_param_1=jid_s: the JID that we were assigned by the server, as the resource might differ from the JID we asked for.
 
 [disconnected]
 type=signal
--- a/src/core/xmpp.py	Wed Jun 10 09:18:34 2015 +0200
+++ b/src/core/xmpp.py	Wed Jun 10 18:04:43 2015 +0200
@@ -59,7 +59,7 @@
         self.__connected = True
         log.info(_("********** [%s] CONNECTED **********") % self.profile)
         self.streamInitialized()
-        self.host_app.bridge.connected(self.profile)  # we send the signal to the clients
+        self.host_app.bridge.connected(self.profile, unicode(self.jid))  # we send the signal to the clients
 
     def streamInitialized(self):
         """Called after _authd"""