comparison frontends/src/quick_frontend/quick_app.py @ 2050:046449cc2bff

core, bridge, frontends: removed deprecated bridge method askConfirmation, confirmationAnswer, actionResult, actionResultExt and getWaitingConf
author Goffi <goffi@goffi.org>
date Sun, 28 Aug 2016 19:23:58 +0200
parents b67aece4a667
children 7bfa97e533ac
comparison
equal deleted inserted replaced
2049:b67aece4a667 2050:046449cc2bff
44 unicode = str 44 unicode = str
45 45
46 46
47 class ProfileManager(object): 47 class ProfileManager(object):
48 """Class managing all data relative to one profile, and plugging in mechanism""" 48 """Class managing all data relative to one profile, and plugging in mechanism"""
49 # TODO: handle waiting XMLUI requests: getWaitingConf doesn't exist anymore
50 # and a way to keep some XMLUI request between sessions is expected in backend
49 host = None 51 host = None
50 bridge = None 52 bridge = None
51 cache_keys_to_get = ['avatar'] 53 cache_keys_to_get = ['avatar']
52 54
53 def __init__(self, profile): 55 def __init__(self, profile):
133 show = presences[contact][res][0] 135 show = presences[contact][res][0]
134 priority = presences[contact][res][1] 136 priority = presences[contact][res][1]
135 statuses = presences[contact][res][2] 137 statuses = presences[contact][res][2]
136 self.host.presenceUpdateHandler(jabber_id, show, priority, statuses, self.profile) 138 self.host.presenceUpdateHandler(jabber_id, show, priority, statuses, self.profile)
137 self.host.bridge.getEntityData(contact, ['avatar', 'nick'], self.profile, callback=lambda data, contact=contact: gotEntityData(data, contact), errback=lambda failure, contact=contact: log.debug(u"No cache data for {}".format(contact))) 139 self.host.bridge.getEntityData(contact, ['avatar', 'nick'], self.profile, callback=lambda data, contact=contact: gotEntityData(data, contact), errback=lambda failure, contact=contact: log.debug(u"No cache data for {}".format(contact)))
138
139 #Finaly, we get the waiting confirmation requests
140 self.bridge.getWaitingConf(self.profile, callback=self._plug_profile_gotWaitingConf)
141
142 def _plug_profile_gotWaitingConf(self, waiting_confs):
143 for confirm_id, confirm_type, data in waiting_confs:
144 self.host.askConfirmationHandler(confirm_id, confirm_type, data, self.profile)
145 140
146 # At this point, profile should be fully plugged 141 # At this point, profile should be fully plugged
147 # and we launch frontend specific method 142 # and we launch frontend specific method
148 self.host.profilePlugged(self.profile) 143 self.host.profilePlugged(self.profile)
149 144
236 self.registerSignal("connected") 231 self.registerSignal("connected")
237 self.registerSignal("disconnected") 232 self.registerSignal("disconnected")
238 self.registerSignal("actionNew") 233 self.registerSignal("actionNew")
239 self.registerSignal("newContact") 234 self.registerSignal("newContact")
240 self.registerSignal("messageNew") 235 self.registerSignal("messageNew")
241 self.registerSignal("newAlert")
242 self.registerSignal("presenceUpdate") 236 self.registerSignal("presenceUpdate")
243 self.registerSignal("subscribe") 237 self.registerSignal("subscribe")
244 self.registerSignal("paramUpdate") 238 self.registerSignal("paramUpdate")
245 self.registerSignal("contactDeleted") 239 self.registerSignal("contactDeleted")
246 self.registerSignal("entityDataUpdated") 240 self.registerSignal("entityDataUpdated")
247 self.registerSignal("askConfirmation")
248 self.registerSignal("actionResult")
249 self.registerSignal("progressStarted") 241 self.registerSignal("progressStarted")
250 self.registerSignal("progressFinished") 242 self.registerSignal("progressFinished")
251 self.registerSignal("progressError") 243 self.registerSignal("progressError")
252 self.registerSignal("actionResultExt", self.actionResultHandler)
253 self.registerSignal("mucRoomJoined", iface="plugin") 244 self.registerSignal("mucRoomJoined", iface="plugin")
254 self.registerSignal("mucRoomLeft", iface="plugin") 245 self.registerSignal("mucRoomLeft", iface="plugin")
255 self.registerSignal("mucRoomUserChangedNick", iface="plugin") 246 self.registerSignal("mucRoomUserChangedNick", iface="plugin")
256 self.registerSignal("mucRoomNewSubject", iface="plugin") 247 self.registerSignal("mucRoomNewSubject", iface="plugin")
257 self.registerSignal("chatStateReceived", iface="plugin") 248 self.registerSignal("chatStateReceived", iface="plugin")
261 # FIXME: do it dynamically 252 # FIXME: do it dynamically
262 quick_games.Tarot.registerSignals(self) 253 quick_games.Tarot.registerSignals(self)
263 quick_games.Quiz.registerSignals(self) 254 quick_games.Quiz.registerSignals(self)
264 quick_games.Radiocol.registerSignals(self) 255 quick_games.Radiocol.registerSignals(self)
265 256
266 self.current_action_ids = set() # FIXME: to be removed
267 self.current_action_ids_cb = {} # FIXME: to be removed
268 self._notif_id = 0 257 self._notif_id = 0
269 self._notifications = OrderedDict() 258 self._notifications = OrderedDict()
270 self.media_dir = self.bridge.getConfig('', 'media_dir') 259 self.media_dir = self.bridge.getConfig('', 'media_dir')
271 self.features = None 260 self.features = None
272 261
483 target = to_jid if from_me else from_jid 472 target = to_jid if from_me else from_jid
484 contact_list = self.contact_lists[profile] 473 contact_list = self.contact_lists[profile]
485 # we want to be sure to have at least one QuickChat instance 474 # we want to be sure to have at least one QuickChat instance
486 self.widgets.getOrCreateWidget(quick_chat.QuickChat, target, type_=C.CHAT_ONE2ONE, on_new_widget=None, profile=profile) 475 self.widgets.getOrCreateWidget(quick_chat.QuickChat, target, type_=C.CHAT_ONE2ONE, on_new_widget=None, profile=profile)
487 476
488 self.current_action_ids = set() # FIXME: to be removed
489 self.current_action_ids_cb = {} # FIXME: to be removed
490
491 if not from_jid in contact_list and from_jid.bare != self.profiles[profile].whoami.bare: 477 if not from_jid in contact_list and from_jid.bare != self.profiles[profile].whoami.bare:
492 #XXX: needed to show entities which haven't sent any 478 #XXX: needed to show entities which haven't sent any
493 # presence information and which are not in roster 479 # presence information and which are not in roster
494 contact_list.setContact(from_jid) 480 contact_list.setContact(from_jid)
495 481
513 499
514 if not self.trigger.point("messageSendTrigger", to_jid, message, subject, mess_type, extra, callback, errback, profile_key=profile_key): 500 if not self.trigger.point("messageSendTrigger", to_jid, message, subject, mess_type, extra, callback, errback, profile_key=profile_key):
515 return 501 return
516 502
517 self.bridge.messageSend(unicode(to_jid), message, subject, mess_type, extra, profile_key, callback=callback, errback=errback) 503 self.bridge.messageSend(unicode(to_jid), message, subject, mess_type, extra, profile_key, callback=callback, errback=errback)
518
519 def newAlertHandler(self, msg, title, alert_type, profile):
520 assert alert_type in ['INFO', 'ERROR']
521 self.showDialog(unicode(msg), unicode(title), alert_type.lower())
522 504
523 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): 505 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE):
524 raise NotImplementedError 506 raise NotImplementedError
525 507
526 def presenceUpdateHandler(self, entity_s, show, priority, statuses, profile): 508 def presenceUpdateHandler(self, entity_s, show, priority, statuses, profile):
786 def gotFilename(filename): 768 def gotFilename(filename):
787 self.contact_lists[profile].setCache(entity, 'avatar', filename) 769 self.contact_lists[profile].setCache(entity, 'avatar', filename)
788 self.callListeners('avatar', entity, filename, profile=profile) 770 self.callListeners('avatar', entity, filename, profile=profile)
789 self.bridge.getAvatarFile(value, callback=gotFilename) 771 self.bridge.getAvatarFile(value, callback=gotFilename)
790 772
791 def askConfirmationHandler(self, confirm_id, confirm_type, data, profile):
792 raise NotImplementedError
793
794 def actionResultHandler(self, type, id, data, profile):
795 raise NotImplementedError
796
797 def actionManager(self, action_data, callback=None, ui_show_cb=None, user_action=True, profile=C.PROF_KEY_NONE): 773 def actionManager(self, action_data, callback=None, ui_show_cb=None, user_action=True, profile=C.PROF_KEY_NONE):
798 """Handle backend action 774 """Handle backend action
799 775
800 @param action_data(dict): action dict as sent by launchAction or returned by an UI action 776 @param action_data(dict): action dict as sent by launchAction or returned by an UI action
801 @param callback(None, callback): if not None, callback to use on XMLUI answer 777 @param callback(None, callback): if not None, callback to use on XMLUI answer