plugins XEP-0096, XEP-0260, file: sendFile method is managed by file plugin, which choose the best available method + progress_id fix

This commit is contained in:
Goffi 2015-11-14 19:18:05 +01:00
commit aaa3c32378

View file

@ -46,6 +46,7 @@ PLUGIN_INFO = {
class XEP_0096(object):
# TODO: call self._f.unregister when unloading order will be managing (i.e. when depenencies will be unloaded at the end)
def __init__(self, host):
log.info(_("Plugin XEP_0096 initialization"))
@ -53,6 +54,7 @@ class XEP_0096(object):
self.managed_stream_m = [self.host.plugins["XEP-0065"].NAMESPACE,
self.host.plugins["XEP-0047"].NAMESPACE] # Stream methods managed
self._f = self.host.plugins["FILE"]
self._f.register(NS_SI_FT, self.sendFile, priority=0, method_name=u"Stream Initiation")
self._si = self.host.plugins["XEP-0095"]
self._si.registerSIProfile(SI_PROFILE_NAME, self._transferRequest)
host.bridge.addMethod("siSendFile", ".plugin", in_sign='sssss', out_sign='s', method=self._sendFile)
@ -167,7 +169,7 @@ class XEP_0096(object):
#if we are here, the transfer can start, we just need user's agreement
data = {"name": filename, "peer_jid": peer_jid, "size": file_size, "date": file_date, "hash": file_hash, "desc": file_desc,
"range": range_, "range_offset": range_offset, "range_length": range_length,
"si_id": si_id, "stream_method": stream_method, "stream_plugin": plugin}
"si_id": si_id, "progress_id": si_id, "stream_method": stream_method, "stream_plugin": plugin}
d = self._f.getDestDir(peer_jid, data, data, profile)
d.addCallback(self.confirmationCb, iq_elt, data, profile)
@ -317,6 +319,7 @@ class XEP_0096(object):
file_obj = self._f.File(self.host,
filepath,
uid=sid,
size=size,
profile=client.profile
)
@ -333,7 +336,7 @@ class XEP_0096(object):
self.host.bridge.newAlert(_("The contact {} has refused your file").format(from_s), _("File refused"), "INFO", client.profile)
else:
log.warning(_(u"Error during file transfer"))
self.host.bridge.newAlert(_(u"Something went wrong during the file transfer session intialisation: {reason}").format(reason=unicode(stanza_err.value)), _("File transfer error"), "ERROR", client.profile)
self.host.bridge.newAlert(_(u"Something went wrong during the file transfer session initialisation: {reason}").format(reason=unicode(stanza_err.value)), _("File transfer error"), "ERROR", client.profile)
elif failure.check(exceptions.DataError):
log.warning(u'Invalid stanza received')
else: