comparison libervia.py @ 127:e19a8de8b3de

radio collective first draft
author Goffi <goffi@goffi.org>
date Sun, 22 Jan 2012 19:38:05 +0100
parents adecb2566b53
children 2849ec993d89
comparison
equal deleted inserted replaced
126:adecb2566b53 127:e19a8de8b3de
239 name == 'tarotGameInvalidCards' or \ 239 name == 'tarotGameInvalidCards' or \
240 name == 'tarotGameCardsPlayed' or \ 240 name == 'tarotGameCardsPlayed' or \
241 name == 'tarotGameYourTurn' or \ 241 name == 'tarotGameYourTurn' or \
242 name == 'tarotGameScore': 242 name == 'tarotGameScore':
243 self._tarotGameGenericCb(name, args[0], args[1:]) 243 self._tarotGameGenericCb(name, args[0], args[1:])
244 elif name == 'radiocolStarted':
245 self._radioColStartedCb(*args)
244 elif name == 'subscribe': 246 elif name == 'subscribe':
245 self._subscribeCb(*args) 247 self._subscribeCb(*args)
246 elif name == 'contactDeleted': 248 elif name == 'contactDeleted':
247 self._contactDeletedCb(*args) 249 self._contactDeletedCb(*args)
248 elif name == 'newContact': 250 elif name == 'newContact':
308 if not showed: 310 if not showed:
309 #The message has not been showed, we must indicate it 311 #The message has not been showed, we must indicate it
310 other = _to if _from.bare == self.whoami.bare else _from 312 other = _to if _from.bare == self.whoami.bare else _from
311 self.contact_panel.setContactMessageWaiting(other.bare, True) 313 self.contact_panel.setContactMessageWaiting(other.bare, True)
312 314
313
314
315 def _presenceUpdateCb(self, entity, show, priority, statuses): 315 def _presenceUpdateCb(self, entity, show, priority, statuses):
316 _entity = JID(entity) 316 _entity = JID(entity)
317 #XXX: QnD way to get our status 317 #XXX: QnD way to get our status
318 if self.whoami and self.whoami.bare == _entity.bare and statuses: 318 if self.whoami and self.whoami.bare == _entity.bare and statuses:
319 self.status_panel.changeStatus(statuses.values()[0]) 319 self.status_panel.changeStatus(statuses.values()[0])
325 self.room_list.add(_target) 325 self.room_list.add(_target)
326 chat_panel = panels.ChatPanel(self, _target, type='group') 326 chat_panel = panels.ChatPanel(self, _target, type='group')
327 chat_panel.setUserNick(user_nick) 327 chat_panel.setUserNick(user_nick)
328 if _target.node.startswith('sat_tarot_'): #XXX: it's not really beautiful, but it works :) 328 if _target.node.startswith('sat_tarot_'): #XXX: it's not really beautiful, but it works :)
329 self.addTab(chat_panel, "Tarot") 329 self.addTab(chat_panel, "Tarot")
330 elif _target.node.startswith('sat_radiocol_'):
331 self.addTab(chat_panel, "Radio collective")
330 else: 332 else:
331 self.addTab(chat_panel, _target.node) 333 self.addTab(chat_panel, _target.node)
332 chat_panel.setPresents(room_nicks) 334 chat_panel.setPresents(room_nicks)
333 chat_panel.historyPrint() 335 chat_panel.historyPrint()
334 336
351 def _tarotGameGenericCb(self, event_name, room_jid, args): 353 def _tarotGameGenericCb(self, event_name, room_jid, args):
352 for lib_wid in self.libervia_widgets: 354 for lib_wid in self.libervia_widgets:
353 if isinstance(lib_wid,panels.ChatPanel) and lib_wid.type == 'group' and lib_wid.target.bare == room_jid: 355 if isinstance(lib_wid,panels.ChatPanel) and lib_wid.type == 'group' and lib_wid.target.bare == room_jid:
354 getattr(lib_wid.getGame("Tarot"), event_name)(*args) 356 getattr(lib_wid.getGame("Tarot"), event_name)(*args)
355 357
358 def _radioColStartedCb(self, room_jid, referee):
359 for lib_wid in self.libervia_widgets:
360 if isinstance(lib_wid,panels.ChatPanel) and lib_wid.type == 'group' and lib_wid.target.bare == room_jid:
361 lib_wid.startGame("RadioCol", referee)
362
356 def _getPresenceStatusCb(self, presence_data): 363 def _getPresenceStatusCb(self, presence_data):
357 for entity in presence_data: 364 for entity in presence_data:
358 for resource in presence_data[entity]: 365 for resource in presence_data[entity]:
359 args = presence_data[entity][resource] 366 args = presence_data[entity][resource]
360 self._presenceUpdateCb("%s/%s" % (entity, resource), *args) 367 self._presenceUpdateCb("%s/%s" % (entity, resource), *args)