Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0047.py @ 2129:6a66c8c5a567
core: replaced calls to client.xmlstream.send by client.send which is the right method to use. client.xmlstream should not be used directly
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 04 Feb 2017 17:59:13 +0100 |
parents | 2daf7b4c6756 |
children | 1d3f73e065e1 |
comparison
equal
deleted
inserted
replaced
2128:aa94f33fd2ad | 2129:6a66c8c5a567 |
---|---|
187 # would be better to have generic observer and check id once triggered | 187 # would be better to have generic observer and check id once triggered |
188 client.xmlstream.addObserver(event_data, observer_cb, profile=profile) | 188 client.xmlstream.addObserver(event_data, observer_cb, profile=profile) |
189 client.xmlstream.addOnetimeObserver(event_close, self._onIBBClose, profile=profile) | 189 client.xmlstream.addOnetimeObserver(event_close, self._onIBBClose, profile=profile) |
190 # finally, we send the accept stanza | 190 # finally, we send the accept stanza |
191 iq_result_elt = xmlstream.toResponse(iq_elt, 'result') | 191 iq_result_elt = xmlstream.toResponse(iq_elt, 'result') |
192 client.xmlstream.send(iq_result_elt) | 192 client.send(iq_result_elt) |
193 | 193 |
194 def _onIBBClose(self, iq_elt, profile): | 194 def _onIBBClose(self, iq_elt, profile): |
195 """"Called when an IBB <close> element is received | 195 """"Called when an IBB <close> element is received |
196 | 196 |
197 @param iq_elt(domish.Element): the whole <iq> stanza | 197 @param iq_elt(domish.Element): the whole <iq> stanza |
203 close_elt = iq_elt.elements(NS_IBB, 'close').next() | 203 close_elt = iq_elt.elements(NS_IBB, 'close').next() |
204 # XXX: this observer is only triggered on valid sid, so we don't need to check it | 204 # XXX: this observer is only triggered on valid sid, so we don't need to check it |
205 sid = close_elt['sid'] | 205 sid = close_elt['sid'] |
206 | 206 |
207 iq_result_elt = xmlstream.toResponse(iq_elt, 'result') | 207 iq_result_elt = xmlstream.toResponse(iq_elt, 'result') |
208 client.xmlstream.send(iq_result_elt) | 208 client.send(iq_result_elt) |
209 self._killSession(sid, client) | 209 self._killSession(sid, client) |
210 | 210 |
211 def _onIBBData(self, element, profile): | 211 def _onIBBData(self, element, profile): |
212 """Observer called on <iq> or <message> stanzas with data element | 212 """Observer called on <iq> or <message> stanzas with data element |
213 | 213 |
259 return | 259 return |
260 | 260 |
261 # we can now ack success | 261 # we can now ack success |
262 if element.name == 'iq': | 262 if element.name == 'iq': |
263 iq_result_elt = xmlstream.toResponse(element, 'result') | 263 iq_result_elt = xmlstream.toResponse(element, 'result') |
264 client.xmlstream.send(iq_result_elt) | 264 client.send(iq_result_elt) |
265 | 265 |
266 def _sendError(self, error_condition, sid, iq_elt, client): | 266 def _sendError(self, error_condition, sid, iq_elt, client): |
267 """Send error stanza | 267 """Send error stanza |
268 | 268 |
269 @param error_condition: one of twisted.words.protocols.jabber.error.STANZA_CONDITIONS keys | 269 @param error_condition: one of twisted.words.protocols.jabber.error.STANZA_CONDITIONS keys |
273 """ | 273 """ |
274 iq_elt = error.StanzaError(error_condition).toResponse(iq_elt) | 274 iq_elt = error.StanzaError(error_condition).toResponse(iq_elt) |
275 log.warning(u"Error while managing in-band bytestream session, cancelling: {}".format(error_condition)) | 275 log.warning(u"Error while managing in-band bytestream session, cancelling: {}".format(error_condition)) |
276 if sid is not None: | 276 if sid is not None: |
277 self._killSession(sid, client, error_condition) | 277 self._killSession(sid, client, error_condition) |
278 client.xmlstream.send(iq_elt) | 278 client.send(iq_elt) |
279 | 279 |
280 def startStream(self, file_obj, to_jid, sid, block_size=None, profile=C.PROF_KEY_NONE): | 280 def startStream(self, file_obj, to_jid, sid, block_size=None, profile=C.PROF_KEY_NONE): |
281 """Launch the stream workflow | 281 """Launch the stream workflow |
282 | 282 |
283 @param file_obj(file): file_obj to send | 283 @param file_obj(file): file_obj to send |