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
This commit is contained in:
souliane 2015-04-20 16:39:38 +02:00
commit 41b549f7ae

View file

@ -96,11 +96,11 @@ class ProfileManager(object):
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 @@ class ProfileManager(object):
#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 @@ class QuickApp(object):
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 @@ class QuickApp(object):
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