comparison 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
comparison
equal deleted inserted replaced
1434:b06047e1c1fb 1435:7590bbf44eed
61 """Plug the profile to the host""" 61 """Plug the profile to the host"""
62 # we get the essential params 62 # we get the essential params
63 self.bridge.asyncGetParamA("JabberID", "Connection", profile_key=self.profile, 63 self.bridge.asyncGetParamA("JabberID", "Connection", profile_key=self.profile,
64 callback=self._plug_profile_jid, errback=self._getParamError) 64 callback=self._plug_profile_jid, errback=self._getParamError)
65 65
66 def _plug_profile_jid(self, _jid): 66 def _plug_profile_jid(self, jid_s):
67 self.whoami = jid.JID(_jid) 67 self.whoami = jid.JID(jid_s) # resource might change after the connection
68 self.bridge.asyncGetParamA("autoconnect", "Connection", profile_key=self.profile, 68 self.bridge.asyncGetParamA("autoconnect", "Connection", profile_key=self.profile,
69 callback=self._plug_profile_autoconnect, errback=self._getParamError) 69 callback=self._plug_profile_autoconnect, errback=self._getParamError)
70 70
71 def _plug_profile_autoconnect(self, value_str): 71 def _plug_profile_autoconnect(self, value_str):
72 autoconnect = C.bool(value_str) 72 autoconnect = C.bool(value_str)
437 return NotImplementedError 437 return NotImplementedError
438 438
439 def newWidget(self, widget): 439 def newWidget(self, widget):
440 raise NotImplementedError 440 raise NotImplementedError
441 441
442 def connectedHandler(self, profile): 442 def connectedHandler(self, profile, jid_s):
443 """called when the connection is made""" 443 """Called when the connection is made.
444
445 @param jid_s (unicode): the JID that we were assigned by the server,
446 as the resource might differ from the JID we asked for.
447 """
444 log.debug(_("Connected")) 448 log.debug(_("Connected"))
449 self.profiles[profile].whoami = jid.JID(jid_s)
445 self.setPresenceStatus(profile=profile) 450 self.setPresenceStatus(profile=profile)
446 self.contact_lists[profile].fill() 451 self.contact_lists[profile].fill()
447 452
448 def disconnectedHandler(self, profile): 453 def disconnectedHandler(self, profile):
449 """called when the connection is closed""" 454 """called when the connection is closed"""
450 log.debug(_("Disconnected")) 455 log.debug(_("Disconnected"))
451 self.contact_lists[profile].clearContacts() 456 self.contact_lists[profile].clearContacts()
452 self.setPresenceStatus(C.PRESENCE_UNAVAILABLE, '', profile=profile) 457 self.setPresenceStatus(C.PRESENCE_UNAVAILABLE, '', profile=profile)
453 458
454 def newContactHandler(self, JabberId, attributes, groups, profile): 459 def newContactHandler(self, jid_s, attributes, groups, profile):
455 entity = jid.JID(JabberId) 460 entity = jid.JID(jid_s)
456 _groups = list(groups) 461 _groups = list(groups)
457 self.contact_lists[profile].setContact(entity, _groups, attributes, in_roster=True) 462 self.contact_lists[profile].setContact(entity, _groups, attributes, in_roster=True)
458 463
459 def newMessageHandler(self, from_jid_s, msg, type_, to_jid_s, extra, profile): 464 def newMessageHandler(self, from_jid_s, msg, type_, to_jid_s, extra, profile):
460 from_jid = jid.JID(from_jid_s) 465 from_jid = jid.JID(from_jid_s)