Mercurial > libervia-backend
comparison src/core/sat_main.py @ 541:8b116fa42a31
core, bridge: waiting confirmation management (new getWaitingConf method)
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 14 Nov 2012 20:24:28 +0100 |
parents | 2c4016921403 |
children | f25eef861b43 |
comparison
equal
deleted
inserted
replaced
540:47e45a577ab7 | 541:8b116fa42a31 |
---|---|
127 self.bridge.register("getContacts", self.getContacts) | 127 self.bridge.register("getContacts", self.getContacts) |
128 self.bridge.register("getContactsFromGroup", self.getContactsFromGroup) | 128 self.bridge.register("getContactsFromGroup", self.getContactsFromGroup) |
129 self.bridge.register("getLastResource", self.memory.getLastResource) | 129 self.bridge.register("getLastResource", self.memory.getLastResource) |
130 self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus) | 130 self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus) |
131 self.bridge.register("getWaitingSub", self.memory.getWaitingSub) | 131 self.bridge.register("getWaitingSub", self.memory.getWaitingSub) |
132 self.bridge.register("getWaitingConf", self.getWaitingConf) | |
132 self.bridge.register("sendMessage", self.sendMessage) | 133 self.bridge.register("sendMessage", self.sendMessage) |
133 self.bridge.register("getConfig", self.memory.getConfig) | 134 self.bridge.register("getConfig", self.memory.getConfig) |
134 self.bridge.register("setParam", self.setParam) | 135 self.bridge.register("setParam", self.setParam) |
135 self.bridge.register("getParamA", self.memory.getStringParamA) | 136 self.bridge.register("getParamA", self.memory.getStringParamA) |
136 self.bridge.register("asyncGetParamA", self.memory.asyncGetStringParamA) | 137 self.bridge.register("asyncGetParamA", self.memory.asyncGetStringParamA) |
450 error (_("Unknown action type")) | 451 error (_("Unknown action type")) |
451 return "" | 452 return "" |
452 | 453 |
453 | 454 |
454 ## jabber methods ## | 455 ## jabber methods ## |
456 | |
457 def getWaitingConf(self, profile_key=None): | |
458 assert(profile_key) | |
459 client = self.getClient(profile_key) | |
460 if not client: | |
461 raise ProfileNotInCacheError | |
462 ret = [] | |
463 for conf_id in client._waiting_conf: | |
464 conf_type, data = client._waiting_conf[conf_id][:2] | |
465 ret.append((conf_id, conf_type, data)) | |
466 return ret | |
455 | 467 |
456 def sendMessage(self, to, msg, subject=None, mess_type='auto', profile_key='@DEFAULT@'): | 468 def sendMessage(self, to, msg, subject=None, mess_type='auto', profile_key='@DEFAULT@'): |
457 #FIXME: check validity of recipient | 469 #FIXME: check validity of recipient |
458 profile = self.memory.getProfileName(profile_key) | 470 profile = self.memory.getProfileName(profile_key) |
459 assert(profile) | 471 assert(profile) |
633 if not client: | 645 if not client: |
634 raise ProfileUnknownError(_("Asking confirmation a non-existant profile")) | 646 raise ProfileUnknownError(_("Asking confirmation a non-existant profile")) |
635 if client._waiting_conf.has_key(conf_id): | 647 if client._waiting_conf.has_key(conf_id): |
636 error (_("Attempt to register two callbacks for the same confirmation")) | 648 error (_("Attempt to register two callbacks for the same confirmation")) |
637 else: | 649 else: |
638 client._waiting_conf[conf_id] = cb | 650 client._waiting_conf[conf_id] = (conf_type, data, cb) |
639 self.bridge.askConfirmation(conf_type, conf_id, data, profile) | 651 self.bridge.askConfirmation(conf_id, conf_type, data, profile) |
640 | 652 |
641 | 653 |
642 def confirmationAnswer(self, conf_id, accepted, data, profile): | 654 def confirmationAnswer(self, conf_id, accepted, data, profile): |
643 """Called by frontends to answer confirmation requests""" | 655 """Called by frontends to answer confirmation requests""" |
644 client = self.getClient(profile) | 656 client = self.getClient(profile) |
645 if not client: | 657 if not client: |
646 raise ProfileUnknownError(_("Confirmation answer from a non-existant profile")) | 658 raise ProfileUnknownError(_("Confirmation answer from a non-existant profile")) |
647 debug (_("Received confirmation answer for conf_id [%(conf_id)s]: %(success)s") % {'conf_id': conf_id, 'success':_("accepted") if accepted else _("refused")}) | 659 debug (_("Received confirmation answer for conf_id [%(conf_id)s]: %(success)s") % {'conf_id': conf_id, 'success':_("accepted") if accepted else _("refused")}) |
648 if not client._waiting_conf.has_key(conf_id): | 660 if not client._waiting_conf.has_key(conf_id): |
649 error (_("Received an unknown confirmation")) | 661 error (_("Received an unknown confirmation (%(id)s for %(profile)s)") % {'id': conf_id, 'profile': profile}) |
650 else: | 662 else: |
651 cb = client._waiting_conf[conf_id] | 663 cb = client._waiting_conf[conf_id][-1] |
652 del client._waiting_conf[conf_id] | 664 del client._waiting_conf[conf_id] |
653 cb(conf_id, accepted, data, profile) | 665 cb(conf_id, accepted, data, profile) |
654 | 666 |
655 def registerProgressCB(self, progress_id, CB, profile): | 667 def registerProgressCB(self, progress_id, CB, profile): |
656 """Register a callback called when progress is requested for id""" | 668 """Register a callback called when progress is requested for id""" |