From 640537662a913aa4d1ae11fb5b5a8a3e59aa29ea Mon Sep 17 00:00:00 2001 From: souliane Date: Wed, 10 Jun 2015 18:04:43 +0200 Subject: [PATCH] bridge, quick_frontend: the JID that is assigned by the server can differ from the one we asked for (resource) --- frontends/src/quick_frontend/quick_app.py | 17 +++++++++++------ src/bridge/DBus.py | 8 ++++---- .../bridge_constructor/bridge_template.ini | 3 ++- src/core/xmpp.py | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/frontends/src/quick_frontend/quick_app.py b/frontends/src/quick_frontend/quick_app.py index 3cb3acb3..1fed170e 100644 --- a/frontends/src/quick_frontend/quick_app.py +++ b/frontends/src/quick_frontend/quick_app.py @@ -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) diff --git a/src/bridge/DBus.py b/src/bridge/DBus.py index f90f147d..a8527056 100755 --- a/src/bridge/DBus.py +++ b/src/bridge/DBus.py @@ -141,8 +141,8 @@ class DbusObject(dbus.service.Object): 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 @@ class DBusBridge(Bridge): 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) diff --git a/src/bridge/bridge_constructor/bridge_template.ini b/src/bridge/bridge_constructor/bridge_template.ini index 0d12befc..4b40b3ce 100644 --- a/src/bridge/bridge_constructor/bridge_template.ini +++ b/src/bridge/bridge_constructor/bridge_template.ini @@ -8,9 +8,10 @@ doc_security_limit=security_limit: -1 means no security, 0 is the maximum securi [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 diff --git a/src/core/xmpp.py b/src/core/xmpp.py index 54281011..10ad776a 100644 --- a/src/core/xmpp.py +++ b/src/core/xmpp.py @@ -59,7 +59,7 @@ class SatXMPPClient(client.XMPPClient): 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"""