diff src/plugins/plugin_xep_0065.py @ 2502:7ad5f2c4e34a

XEP-0065,XEP-0096,XEP-0166,XEP-0235,XEP-0300: file transfer improvments: huge patch sorry :) many things are improved by this patch, notably: - updated to last protocol changes (urn:xmpp:jingle:apps:file-transfer:5 and urn:xmpp:hashes:2) - XEP-0234: file request implementation - XEP-0234: methods to parse and generate <file> element (can be used by other plugins easily) - XEP-0234: range data is now in a namedtuple - path and namespace can be specified when sending/requesting a file (not standard, but needed for file sharing) - better error/termination handling - trigger points to handle file requests by other plugins - preparation to use file plugins with components
author Goffi <goffi@goffi.org>
date Wed, 28 Feb 2018 18:28:39 +0100
parents e2a7bb875957
children
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0065.py	Wed Feb 28 18:28:39 2018 +0100
+++ b/src/plugins/plugin_xep_0065.py	Wed Feb 28 18:28:39 2018 +0100
@@ -86,6 +86,7 @@
     C.PI_NAME: "XEP 0065 Plugin",
     C.PI_IMPORT_NAME: "XEP-0065",
     C.PI_TYPE: "XEP",
+    C.PI_MODES: C.PLUG_MODE_BOTH,
     C.PI_PROTOCOLS: ["XEP-0065"],
     C.PI_DEPENDENCIES: ["IP"],
     C.PI_RECOMMENDATIONS: ["NAT-PORT"],
@@ -769,7 +770,7 @@
             pass
         try:
             proxy = (yield self.host.findServiceEntities(client, 'proxy', 'bytestreams')).pop()
-        except (defer.CancelledError, StopIteration):
+        except (defer.CancelledError, StopIteration, KeyError):
             notFound(server)
         iq_elt = client.IQ('get')
         iq_elt['to'] = proxy.full()
@@ -966,19 +967,19 @@
         session = self.getSession(client, session_hash)
         session[DEFER_KEY].errback(exceptions.TimeOutError)
 
-    def killSession(self, reason, session_hash, sid, client):
+    def killSession(self, failure_, session_hash, sid, client):
         """Clean the current session
 
         @param session_hash(str): hash as returned by getSessionHash
         @param sid(None, unicode): session id
             or None if self.xep_0065_sid_session was not used
         @param client: %(doc_client)s
-        @param reason(None, failure.Failure): None if eveything was fine, a failure else
-        @return (None, failure.Failure): reason is returned
+        @param failure_(None, failure.Failure): None if eveything was fine, a failure else
+        @return (None, failure.Failure): failure_ is returned
         """
         log.debug(u'Cleaning session with hash {hash}{id}: {reason}'.format(
             hash=session_hash,
-            reason='' if reason is None else reason.value,
+            reason='' if failure_ is None else failure_.value,
             id='' if sid is None else u' (id: {})'.format(sid),
             ))
 
@@ -1007,7 +1008,7 @@
         except (internet_error.AlreadyCalled, internet_error.AlreadyCancelled):
             pass
 
-        return reason
+        return failure_
 
     def startStream(self, client, stream_object, to_jid, sid):
         """Launch the stream workflow