core, bridge: waiting confirmation management (new getWaitingConf method)
This commit is contained in:
parent
5327fecca3
commit
75bb00a0d4
3 changed files with 37 additions and 9 deletions
|
|
@ -116,7 +116,7 @@ class DbusObject(dbus.service.Object):
|
|||
|
||||
@dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
signature='ssa{ss}s')
|
||||
def askConfirmation(self, conf_type, id, data, profile):
|
||||
def askConfirmation(self, id, conf_type, data, profile):
|
||||
pass
|
||||
|
||||
@dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
|
|
@ -351,6 +351,12 @@ class DbusObject(dbus.service.Object):
|
|||
def getVersion(self, ):
|
||||
return self._callback("getVersion", )
|
||||
|
||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
in_signature='s', out_signature='a(ssa{ss})',
|
||||
async_callbacks=None)
|
||||
def getWaitingConf(self, profile_key):
|
||||
return self._callback("getWaitingConf", unicode(profile_key))
|
||||
|
||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
in_signature='s', out_signature='a{ss}',
|
||||
async_callbacks=None)
|
||||
|
|
@ -509,8 +515,8 @@ class DBusBridge(Bridge):
|
|||
def actionResultExt(self, answer_type, id, data, profile):
|
||||
self.dbus_bridge.actionResultExt(answer_type, id, data, profile)
|
||||
|
||||
def askConfirmation(self, conf_type, id, data, profile):
|
||||
self.dbus_bridge.askConfirmation(conf_type, id, data, profile)
|
||||
def askConfirmation(self, id, conf_type, data, profile):
|
||||
self.dbus_bridge.askConfirmation(id, conf_type, data, profile)
|
||||
|
||||
def connected(self, profile):
|
||||
self.dbus_bridge.connected(profile)
|
||||
|
|
|
|||
|
|
@ -108,10 +108,10 @@ type=signal
|
|||
category=core
|
||||
sig_in=ssa{ss}s
|
||||
doc=A confirmation is needed for an action
|
||||
doc_param_0=conf_type: Type of the confirmation, can be:
|
||||
doc_param_0=id: Id of the confirmation query
|
||||
doc_param_1=conf_type: Type of the confirmation, can be:
|
||||
- YES/NO: A question which need a yes or no answer
|
||||
- FILE_TRANSFER: A confirmation is needed before transfering a file
|
||||
doc_param_1=id: Id of the confirmation query
|
||||
doc_param_2=data: conf_type dependent data
|
||||
doc_param_3=%(doc_profile)s
|
||||
|
||||
|
|
@ -331,6 +331,16 @@ doc=Get subscription requests in queue
|
|||
doc_param_0=%(doc_profile_key)s
|
||||
doc_return=Dict where contact JID is the key, and value is the subscription type
|
||||
|
||||
[getWaitingConf]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
sig_out=a(ssa{ss})
|
||||
doc=Get confirmations requests in queue
|
||||
doc_param_0=%(doc_profile_key)s
|
||||
doc_return=List of confirmation request data, same as for [askConfirmation]
|
||||
|
||||
|
||||
[sendMessage]
|
||||
type=method
|
||||
category=core
|
||||
|
|
|
|||
|
|
@ -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