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
This commit is contained in:
Goffi 2018-02-28 18:28:39 +01:00
commit 2e5991575f

View file

@ -86,6 +86,7 @@ PLUGIN_INFO = {
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 @@ class XEP_0065(object):
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 @@ class XEP_0065(object):
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 @@ class XEP_0065(object):
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