diff src/plugins/plugin_xep_0096.py @ 1585:846a39900fa6

plugins XEP-0096, XEP-0260, file: sendFile method is managed by file plugin, which choose the best available method + progress_id fix
author Goffi <goffi@goffi.org>
date Sat, 14 Nov 2015 19:18:05 +0100
parents d46aae87c03a
children d470affbe65c
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0096.py	Fri Nov 13 16:46:32 2015 +0100
+++ b/src/plugins/plugin_xep_0096.py	Sat Nov 14 19:18:05 2015 +0100
@@ -46,6 +46,7 @@
 
 
 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 @@
         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 @@
         #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 @@
 
         file_obj = self._f.File(self.host,
                                 filepath,
+                                uid=sid,
                                 size=size,
                                 profile=client.profile
                                 )
@@ -333,7 +336,7 @@
                 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: