core, plugins file, XEP-0234, bridge: progression api enhancement:
- progressStarted have a new metadata parameter, useful to know the kind of progression, direction, etc. Check bridge doc
- progressGetAllMetadata can be used to retrieve this data and discover on currently running progressions
- progressFinished also have a new metadata parameter, used to e.g. indicate that hash is checked
- core: fixed progressGetAll
- file, XEP-0234: implemented the API modifications, hash is returned on progressFinished
- file: SatFile.checkSize allows to check size independently of close (be sure that all the data have been transfered though)
This commit is contained in:
parent
9b2055bd3f
commit
55c75bc304
1 changed files with 161 additions and 29 deletions
|
|
@ -824,12 +824,14 @@ class SAT(service.Service):
|
|||
client = self.getClient(profile)
|
||||
return [action_tuple[:-1] for action_tuple in client.actions.itervalues()]
|
||||
|
||||
def registerProgressCb(self, progress_id, callback, profile):
|
||||
def registerProgressCb(self, progress_id, callback, metadata=None, profile=C.PROF_KEY_NONE):
|
||||
"""Register a callback called when progress is requested for id"""
|
||||
if metadata is None:
|
||||
metadata = {}
|
||||
client = self.getClient(profile)
|
||||
if progress_id in client._progress_cb:
|
||||
raise exceptions.ConflictError(u"Progress ID is not unique !")
|
||||
client._progress_cb[progress_id] = callback
|
||||
client._progress_cb[progress_id] = (callback, metadata)
|
||||
|
||||
def removeProgressCb(self, progress_id, profile):
|
||||
"""Remove a progress callback"""
|
||||
|
|
@ -855,7 +857,7 @@ class SAT(service.Service):
|
|||
"""
|
||||
client = self.getClient(profile)
|
||||
try:
|
||||
data = client._progress_cb[progress_id](progress_id, profile)
|
||||
data = client._progress_cb[progress_id][0](progress_id, profile)
|
||||
except KeyError:
|
||||
data = {}
|
||||
return data
|
||||
|
|
@ -868,11 +870,30 @@ class SAT(service.Service):
|
|||
data[key] = unicode(value)
|
||||
return progress_all
|
||||
|
||||
def progressGetAll(self, profile_key):
|
||||
"""Return all progress informations
|
||||
def progressGetAllMetadata(self, profile_key):
|
||||
"""Return all progress metadata at once
|
||||
|
||||
@param profile_key: %(doc_profile)s get all progress from this profile
|
||||
if C.PROF_KEY_ALL is used, all progress from all profiles are returned
|
||||
@param profile_key: %(doc_profile)s
|
||||
if C.PROF_KEY_ALL is used, all progress metadata from all profiles are returned
|
||||
@return (dict[dict[dict]]): a dict which map profile to progress_dict
|
||||
progress_dict map progress_id to progress_data
|
||||
progress_metadata is the same dict as sent by [progressStarted]
|
||||
"""
|
||||
clients = self.getClients(profile_key)
|
||||
progress_all = {}
|
||||
for client in clients:
|
||||
profile = client.profile
|
||||
progress_dict = {}
|
||||
progress_all[profile] = progress_dict
|
||||
for progress_id, (dummy, progress_metadata) in client._progress_cb.iteritems():
|
||||
progress_dict[progress_id] = progress_metadata
|
||||
return progress_all
|
||||
|
||||
def progressGetAll(self, profile_key):
|
||||
"""Return all progress status at once
|
||||
|
||||
@param profile_key: %(doc_profile)s
|
||||
if C.PROF_KEY_ALL is used, all progress status from all profiles are returned
|
||||
@return (dict[dict[dict]]): a dict which map profile to progress_dict
|
||||
progress_dict map progress_id to progress_data
|
||||
progress_data is the same dict as returned by [progressGet]
|
||||
|
|
@ -883,10 +904,8 @@ class SAT(service.Service):
|
|||
profile = client.profile
|
||||
progress_dict = {}
|
||||
progress_all[profile] = progress_dict
|
||||
for progress_id, progress_cb in client._progress_cb.iteritems():
|
||||
data = {}
|
||||
progress_dict[progress_id] = data
|
||||
progress_dict[progress_id] = progress_cb(progress_id, data, profile)
|
||||
for progress_id, (progress_cb, dummy) in client._progress_cb.iteritems():
|
||||
progress_dict[progress_id] = progress_cb(progress_id, profile)
|
||||
return progress_all
|
||||
|
||||
def registerCallback(self, callback, *args, **kwargs):
|
||||
|
|
|
|||
Loading…
Reference in a new issue