core, bridge: waiting confirmation management (new getWaitingConf method)
This commit is contained in:
parent
5327fecca3
commit
75bb00a0d4
1 changed files with 37 additions and 9 deletions
|
|
@ -129,6 +129,7 @@ class SAT(service.Service):
|
|||
self.bridge.register("getLastResource", self.memory.getLastResource)
|
||||
self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus)
|
||||
self.bridge.register("getWaitingSub", self.memory.getWaitingSub)
|
||||
self.bridge.register("getWaitingConf", self.getWaitingConf)
|
||||
self.bridge.register("sendMessage", self.sendMessage)
|
||||
self.bridge.register("getConfig", self.memory.getConfig)
|
||||
self.bridge.register("setParam", self.setParam)
|
||||
|
|
@ -452,6 +453,17 @@ class SAT(service.Service):
|
|||
|
||||
|
||||
## jabber methods ##
|
||||
|
||||
def getWaitingConf(self, profile_key=None):
|
||||
assert(profile_key)
|
||||
client = self.getClient(profile_key)
|
||||
if not client:
|
||||
raise ProfileNotInCacheError
|
||||
ret = []
|
||||
for conf_id in client._waiting_conf:
|
||||
conf_type, data = client._waiting_conf[conf_id][:2]
|
||||
ret.append((conf_id, conf_type, data))
|
||||
return ret
|
||||
|
||||
def sendMessage(self, to, msg, subject=None, mess_type='auto', profile_key='@DEFAULT@'):
|
||||
#FIXME: check validity of recipient
|
||||
|
|
@ -635,8 +647,8 @@ class SAT(service.Service):
|
|||
if client._waiting_conf.has_key(conf_id):
|
||||
error (_("Attempt to register two callbacks for the same confirmation"))
|
||||
else:
|
||||
client._waiting_conf[conf_id] = cb
|
||||
self.bridge.askConfirmation(conf_type, conf_id, data, profile)
|
||||
client._waiting_conf[conf_id] = (conf_type, data, cb)
|
||||
self.bridge.askConfirmation(conf_id, conf_type, data, profile)
|
||||
|
||||
|
||||
def confirmationAnswer(self, conf_id, accepted, data, profile):
|
||||
|
|
@ -646,9 +658,9 @@ class SAT(service.Service):
|
|||
raise ProfileUnknownError(_("Confirmation answer from a non-existant profile"))
|
||||
debug (_("Received confirmation answer for conf_id [%(conf_id)s]: %(success)s") % {'conf_id': conf_id, 'success':_("accepted") if accepted else _("refused")})
|
||||
if not client._waiting_conf.has_key(conf_id):
|
||||
error (_("Received an unknown confirmation"))
|
||||
error (_("Received an unknown confirmation (%(id)s for %(profile)s)") % {'id': conf_id, 'profile': profile})
|
||||
else:
|
||||
cb = client._waiting_conf[conf_id]
|
||||
cb = client._waiting_conf[conf_id][-1]
|
||||
del client._waiting_conf[conf_id]
|
||||
cb(conf_id, accepted, data, profile)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue