comparison src/core/xmpp.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 614145ef6e60
comparison
equal deleted inserted replaced
1416:a419da93afef 1417:176de79c8c39
313 313
314 if not statuses: 314 if not statuses:
315 statuses = {} 315 statuses = {}
316 316
317 if None in statuses: # we only want string keys 317 if None in statuses: # we only want string keys
318 statuses["default"] = statuses[None] 318 statuses[C.PRESENCE_STATUSES_DEFAULT] = statuses.pop(None)
319 del statuses[None]
320 319
321 self.host.memory.setPresenceStatus(entity, show or "", 320 self.host.memory.setPresenceStatus(entity, show or "",
322 int(priority), statuses, 321 int(priority), statuses,
323 self.parent.profile) 322 self.parent.profile)
324 323
332 331
333 if not statuses: 332 if not statuses:
334 statuses = {} 333 statuses = {}
335 334
336 if None in statuses: # we only want string keys 335 if None in statuses: # we only want string keys
337 statuses["default"] = statuses[None] 336 statuses[C.PRESENCE_STATUSES_DEFAULT] = statuses.pop(None)
338 del statuses[None]
339 self.host.memory.setPresenceStatus(entity, "unavailable", 0, statuses, self.parent.profile) 337 self.host.memory.setPresenceStatus(entity, "unavailable", 0, statuses, self.parent.profile)
340 338
341 if not self.host.trigger.point("presenceReceived", entity, "unavailable", 0, statuses, self.parent.profile): 339 if not self.host.trigger.point("presenceReceived", entity, "unavailable", 0, statuses, self.parent.profile):
342 return 340 return
343 341
354 if statuses is None: 352 if statuses is None:
355 statuses = {} 353 statuses = {}
356 354
357 # default for us is None for wokkel 355 # default for us is None for wokkel
358 # so we must temporarily switch to wokkel's convention... 356 # so we must temporarily switch to wokkel's convention...
359 if 'default' in statuses: 357 if C.PRESENCE_STATUSES_DEFAULT in statuses:
360 statuses[None] = statuses['default'] 358 statuses[None] = statuses.pop(C.PRESENCE_STATUSES_DEFAULT)
361 del statuses['default']
362 359
363 presence_elt = xmppim.AvailablePresence(entity, show, statuses, priority) 360 presence_elt = xmppim.AvailablePresence(entity, show, statuses, priority)
364 361
365 # ... before switching back 362 # ... before switching back
366 if None in statuses: 363 if None in statuses:
367 statuses['default'] = statuses[None] 364 statuses['default'] = statuses.pop(None)
368 del statuses[None]
369 365
370 if not self.host.trigger.point("presence_available", presence_elt, self.parent): 366 if not self.host.trigger.point("presence_available", presence_elt, self.parent):
371 return 367 return
372 self.send(presence_elt) 368 self.send(presence_elt)
373 369