From ed7e784ffec6ce44e82178fdf31b3aa759fc1c53 Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 2 Nov 2015 22:02:41 +0100 Subject: [PATCH] plugin XEP-0047: minor improvements --- src/plugins/plugin_xep_0047.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/plugin_xep_0047.py b/src/plugins/plugin_xep_0047.py index 76a30c74..f4e8f610 100644 --- a/src/plugins/plugin_xep_0047.py +++ b/src/plugins/plugin_xep_0047.py @@ -20,6 +20,7 @@ from sat.core.i18n import _ from sat.core.log import getLogger log = getLogger(__name__) +from sat.core.constants import Const as C from sat.core import exceptions from twisted.words.protocols.jabber import client as jabber_client from twisted.words.protocols.jabber import jid @@ -277,7 +278,7 @@ class XEP_0047(object): self._killSession(sid, client, error_condition) client.xmlstream.send(iq_elt) - def startStream(self, file_obj, to_jid, sid, block_size=None, profile=None): + def startStream(self, file_obj, to_jid, sid, block_size=None, profile=C.PROF_KEY_NONE): """Launch the stream workflow @param file_obj(file): file_obj to send @@ -287,7 +288,6 @@ class XEP_0047(object): @param profile: %(doc_profile)s """ session_data = self._createSession(file_obj, to_jid, sid, profile) - session_defer = session_data[DEFER_KEY] client = self.host.getClient(profile) if block_size is None: @@ -295,7 +295,7 @@ class XEP_0047(object): assert block_size <= 65535 session_data["block_size"] = block_size - iq_elt = jabber_client.IQ(client.xmlstream, 'set') + iq_elt = jabber_client.IQ(client.xmlstream, 'set') # FIXME: use client.IQ here iq_elt['from'] = client.jid.full() iq_elt['to'] = to_jid.full() open_elt = iq_elt.addElement('open', NS_IBB) @@ -304,7 +304,7 @@ class XEP_0047(object): open_elt['stanza'] = 'iq' # TODO: manage stanza ? iq_elt.addCallback(self._IQDataStream, session_data, client) iq_elt.send() - return session_defer + return session_data[DEFER_KEY] def _IQDataStream(self, session_data, client, iq_elt): """Called during the whole data streaming @@ -322,7 +322,7 @@ class XEP_0047(object): buffer_ = session_data["file_obj"].read(session_data["block_size"]) if buffer_: - next_iq_elt = jabber_client.IQ(client.xmlstream, 'set') + next_iq_elt = jabber_client.IQ(client.xmlstream, 'set') # FIXME: use client.IQ here next_iq_elt['to'] = session_data["to"].full() data_elt = next_iq_elt.addElement('data', NS_IBB) seq = session_data['seq'] = (session_data['seq'] + 1) % 65535