# HG changeset patch # User Goffi # Date 1446498161 -3600 # Node ID 6a8dd91476f0905c3e7a378316a7ccb105498aae # Parent 22f0307864b408ba35dbc619c6c0e91f2f6fadd5 plugin XEP-0047: minor improvements diff -r 22f0307864b4 -r 6a8dd91476f0 src/plugins/plugin_xep_0047.py --- a/src/plugins/plugin_xep_0047.py Mon Nov 02 22:02:41 2015 +0100 +++ b/src/plugins/plugin_xep_0047.py Mon Nov 02 22:02:41 2015 +0100 @@ -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 @@ 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 @@ @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 @@ 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 @@ 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 @@ 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