Mercurial > libervia-backend
diff frontends/src/quick_frontend/quick_app.py @ 1417:176de79c8c39
core, plugin XEP-0045, frontends: change frontend method "setStatusOnline" for "setPresenceStatus":
- remove parameter "online" (can be guess from "presence" value)
- process "statuses" dict in quick_frontend, so this method can get a simple unicode "status"
- add C.PRESENCE_STATUSES_DEFAULT to define the key to use for fallback status
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 20 Apr 2015 16:39:38 +0200 |
parents | 3265a2639182 |
children | 6adf1b0be609 |
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_app.py Sat Apr 18 00:27:39 2015 +0200 +++ b/frontends/src/quick_frontend/quick_app.py Mon Apr 20 16:39:38 2015 +0200 @@ -96,11 +96,11 @@ contact_list.setCache(jid.JID(entity), key, value) if not self.bridge.isConnected(self.profile): - self.host.setStatusOnline(False, profile=self.profile) + self.host.setPresenceStatus(C.PRESENCE_UNAVAILABLE, '', profile=self.profile) else: - self.host.setStatusOnline(True, profile=self.profile) contact_list.fill() + self.host.setPresenceStatus(profile=self.profile) #The waiting subscription requests self.bridge.getWaitingSub(self.profile, callback=self._plug_profile_gotWaitingSub) @@ -125,7 +125,6 @@ #Presence must be requested after rooms are filled self.host.bridge.getPresenceStatuses(self.profile, callback=self._plug_profile_gotPresences) - def _plug_profile_gotPresences(self, presences): def gotEntityData(data, contact): for key in ('avatar', 'nick'): @@ -443,13 +442,13 @@ def connectedHandler(self, profile): """called when the connection is made""" log.debug(_("Connected")) - self.setStatusOnline(True, profile=profile) + self.setPresenceStatus(profile=profile) def disconnectedHandler(self, profile): """called when the connection is closed""" log.debug(_("Disconnected")) self.contact_lists[profile].clearContacts() - self.setStatusOnline(False, profile=profile) + self.setPresenceStatus(C.PRESENCE_UNAVAILABLE, '', profile=profile) def newContactHandler(self, JabberId, attributes, groups, profile): entity = jid.JID(JabberId) @@ -505,20 +504,22 @@ assert alert_type in ['INFO', 'ERROR'] self.showDialog(unicode(msg), unicode(title), alert_type.lower()) - def setStatusOnline(self, online=True, show="", statuses={}, profile=C.PROF_KEY_NONE): + def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): raise NotImplementedError def presenceUpdateHandler(self, entity_s, show, priority, statuses, profile): log.debug(_(u"presence update for %(entity)s (show=%(show)s, priority=%(priority)s, statuses=%(statuses)s) [profile:%(profile)s]") - % {'entity': entity_s, C.PRESENCE_SHOW: show, C.PRESENCE_PRIORITY: priority, C.PRESENCE_STATUSES: statuses, 'profile': profile}) + % {'entity': entity_s, C.PRESENCE_SHOW: show, C.PRESENCE_PRIORITY: priority, C.PRESENCE_STATUSES: statuses, 'profile': profile}) entity = jid.JID(entity_s) if entity == self.profiles[profile].whoami: - if show == "unavailable": - self.setStatusOnline(False, profile=profile) + if show == C.PRESENCE_UNAVAILABLE: + self.setPresenceStatus(C.PRESENCE_UNAVAILABLE, '', profile=profile) else: - self.setStatusOnline(True, show, statuses, profile=profile) + # FIXME: try to retrieve user language status before fallback to default + status = statuses.get(C.PRESENCE_STATUSES_DEFAULT, None) + self.setPresenceStatus(show, status, profile=profile) return # #FIXME: must be moved in a plugin