Mercurial > libervia-backend
annotate sat/plugins/plugin_xep_0047.py @ 2566:735467eb6cf7
core: replaced gtk3reactor by gireactor
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 03 Apr 2018 20:54:17 +0200 |
parents | 26edcf3a30eb |
children | 56f94936df1e |
rev | line source |
---|---|
1934
2daf7b4c6756
use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents:
1766
diff
changeset
|
1 #!/usr/bin/env python2 |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
4 # SAT plugin for managing gateways (xep-0047) |
2483 | 5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
10 # (at your option) any later version. |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
15 # GNU Affero General Public License for more details. |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
771 | 20 from sat.core.i18n import _ |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
941
diff
changeset
|
21 from sat.core.log import getLogger |
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
941
diff
changeset
|
22 log = getLogger(__name__) |
1558
6a8dd91476f0
plugin XEP-0047: minor improvements
Goffi <goffi@goffi.org>
parents:
1524
diff
changeset
|
23 from sat.core.constants import Const as C |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
24 from sat.core import exceptions |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
25 from twisted.words.protocols.jabber import jid |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
26 from twisted.words.protocols.jabber import xmlstream |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
27 from twisted.words.protocols.jabber import error |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 from twisted.internet import reactor |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
29 from twisted.internet import defer |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
30 from twisted.python import failure |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 from wokkel import disco, iwokkel |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 from zope.interface import implements |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 import base64 |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 try: |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 from twisted.words.protocols.xmlstream import XMPPHandler |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 except ImportError: |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 from wokkel.subprotocols import XMPPHandler |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 MESSAGE = '/message' |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 IQ_SET = '/iq[@type="set"]' |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 NS_IBB = 'http://jabber.org/protocol/ibb' |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 IBB_OPEN = IQ_SET + '/open[@xmlns="' + NS_IBB + '"]' |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
47 IBB_CLOSE = IQ_SET + '/close[@xmlns="' + NS_IBB + '" and @sid="{}"]' |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
48 IBB_IQ_DATA = IQ_SET + '/data[@xmlns="' + NS_IBB + '" and @sid="{}"]' |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
49 IBB_MESSAGE_DATA = MESSAGE + '/data[@xmlns="' + NS_IBB + '" and @sid="{}"]' |
1628
e9936fcfaf91
plugin 0047: increased timeout to 120s
Goffi <goffi@goffi.org>
parents:
1583
diff
changeset
|
50 TIMEOUT = 120 # timeout for workflow |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
51 DEFER_KEY = 'finished' # key of the deferred used to track session end |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 PLUGIN_INFO = { |
2145
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
54 C.PI_NAME: "In-Band Bytestream Plugin", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
55 C.PI_IMPORT_NAME: "XEP-0047", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
56 C.PI_TYPE: "XEP", |
2504
67cc54b01a12
plugin file sharing component: first draft:
Goffi <goffi@goffi.org>
parents:
2489
diff
changeset
|
57 C.PI_MODES: C.PLUG_MODE_BOTH, |
2145
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
58 C.PI_PROTOCOLS: ["XEP-0047"], |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
59 C.PI_MAIN: "XEP_0047", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
60 C.PI_HANDLER: "yes", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
61 C.PI_DESCRIPTION: _("""Implementation of In-Band Bytestreams""") |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 } |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 |
594
e629371a28d3
Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
588
diff
changeset
|
64 |
588
beaf6bec2fcd
Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
65 class XEP_0047(object): |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 NAMESPACE = NS_IBB |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
67 BLOCK_SIZE = 4096 |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 def __init__(self, host): |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
941
diff
changeset
|
70 log.info(_("In-Band Bytestreams plugin initialization")) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 self.host = host |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 |
2144
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2129
diff
changeset
|
73 def getHandler(self, client): |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 return XEP_0047_handler(self) |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 |
2144
1d3f73e065e1
core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents:
2129
diff
changeset
|
76 def profileConnected(self, client): |
594
e629371a28d3
Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
588
diff
changeset
|
77 client.xep_0047_current_stream = {} # key: stream_id, value: data(dict) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
78 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
79 def _timeOut(self, sid, client): |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
80 """Delete current_stream id, called after timeout |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
81 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
82 @param sid(unicode): session id of client.xep_0047_current_stream |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
83 @param client: %(doc_client)s |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
84 """ |
1583
d46aae87c03a
plugins XEP-0047, XEP-0065, XEP-0096: fixed use of failure.condition insteand of failure.value + removed gettext use for local logs
Goffi <goffi@goffi.org>
parents:
1578
diff
changeset
|
85 log.info(u"In-Band Bytestream: TimeOut reached for id {sid} [{profile}]" |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
86 .format(sid=sid, profile=client.profile)) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
87 self._killSession(sid, client, "TIMEOUT") |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
88 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
89 def _killSession(self, sid, client, failure_reason=None): |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
90 """Delete a current_stream id, clean up associated observers |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
91 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
92 @param sid(unicode): session id |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
93 @param client: %(doc_client)s |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
94 @param failure_reason(None, unicode): if None the session is successful |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
95 else, will be used to call failure_cb |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
96 """ |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
97 try: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
98 session = client.xep_0047_current_stream[sid] |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
99 except KeyError: |
1583
d46aae87c03a
plugins XEP-0047, XEP-0065, XEP-0096: fixed use of failure.condition insteand of failure.value + removed gettext use for local logs
Goffi <goffi@goffi.org>
parents:
1578
diff
changeset
|
100 log.warning(u"kill id called on a non existant id") |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 return |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
102 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
103 try: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
104 observer_cb = session['observer_cb'] |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
105 except KeyError: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
106 pass |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
107 else: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
108 client.xmlstream.removeObserver(session["event_data"], observer_cb) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
109 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
110 if session['timer'].active(): |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
111 session['timer'].cancel() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
112 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
113 del client.xep_0047_current_stream[sid] |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
115 success = failure_reason is None |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
116 stream_d = session[DEFER_KEY] |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
117 |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 if success: |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
119 stream_d.callback(None) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 else: |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
121 stream_d.errback(failure.Failure(exceptions.DataError(failure_reason))) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
122 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
123 def createSession(self, *args, **kwargs): |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
124 """like [_createSession] but return the session deferred instead of the whole session |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
125 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
126 session deferred is fired when transfer is finished |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
127 """ |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
128 return self._createSession(*args, **kwargs)[DEFER_KEY] |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
129 |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
130 def _createSession(self, client, stream_object, to_jid, sid): |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 """Called when a bytestream is imminent |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
132 |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
133 @param stream_object(IConsumer): stream object where data will be written |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
134 @param to_jid(jid.JId): jid of the other peer |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
135 @param sid(unicode): session id |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
136 @return (dict): session data |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
137 """ |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
138 if sid in client.xep_0047_current_stream: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
139 raise exceptions.ConflictError(u'A session with this id already exists !') |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
140 session_data = client.xep_0047_current_stream[sid] = \ |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
141 {'id': sid, |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
142 DEFER_KEY: defer.Deferred(), |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
143 'to': to_jid, |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
144 'stream_object': stream_object, |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
145 'seq': -1, |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
146 'timer': reactor.callLater(TIMEOUT, self._timeOut, sid, client), |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
147 } |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
149 return session_data |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
150 |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
151 def _onIBBOpen(self, iq_elt, client): |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
152 """"Called when an IBB <open> element is received |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
153 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
154 @param iq_elt(domish.Element): the whole <iq> stanza |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
155 """ |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
156 log.debug(_(u"IBB stream opening")) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
157 iq_elt.handled = True |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
158 open_elt = iq_elt.elements(NS_IBB, 'open').next() |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 block_size = open_elt.getAttribute('block-size') |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 sid = open_elt.getAttribute('sid') |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 stanza = open_elt.getAttribute('stanza', 'iq') |
594
e629371a28d3
Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
588
diff
changeset
|
162 if not sid or not block_size or int(block_size) > 65535: |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
163 return self._sendError('not-acceptable', sid or None, iq_elt, client) |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
536
diff
changeset
|
164 if not sid in client.xep_0047_current_stream: |
1409
3265a2639182
massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents:
1396
diff
changeset
|
165 log.warning(_(u"Ignoring unexpected IBB transfer: %s" % sid)) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
166 return self._sendError('not-acceptable', sid or None, iq_elt, client) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
167 session_data = client.xep_0047_current_stream[sid] |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
168 if session_data["to"] != jid.JID(iq_elt['from']): |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
941
diff
changeset
|
169 log.warning(_("sended jid inconsistency (man in the middle attack attempt ?)")) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
170 return self._sendError('not-acceptable', sid, iq_elt, client) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
172 # at this stage, the session looks ok and will be accepted |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
174 # we reset the timeout: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
175 session_data["timer"].reset(TIMEOUT) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
177 # we save the xmlstream, events and observer data to allow observer removal |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
178 session_data["event_data"] = event_data = (IBB_MESSAGE_DATA if stanza == 'message' else IBB_IQ_DATA).format(sid) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
179 session_data["observer_cb"] = observer_cb = self._onIBBData |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
180 event_close = IBB_CLOSE.format(sid) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
181 # we now set the stream observer to look after data packet |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
182 # FIXME: if we never get the events, the observers stay. |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
183 # would be better to have generic observer and check id once triggered |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
184 client.xmlstream.addObserver(event_data, observer_cb, client=client) |
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
185 client.xmlstream.addOnetimeObserver(event_close, self._onIBBClose, client=client) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
186 # finally, we send the accept stanza |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
187 iq_result_elt = xmlstream.toResponse(iq_elt, 'result') |
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
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
188 client.send(iq_result_elt) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
189 |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
190 def _onIBBClose(self, iq_elt, client): |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
191 """"Called when an IBB <close> element is received |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
192 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
193 @param iq_elt(domish.Element): the whole <iq> stanza |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
194 """ |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
195 iq_elt.handled = True |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
941
diff
changeset
|
196 log.debug(_("IBB stream closing")) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
197 close_elt = iq_elt.elements(NS_IBB, 'close').next() |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
198 # XXX: this observer is only triggered on valid sid, so we don't need to check it |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
199 sid = close_elt['sid'] |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
200 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
201 iq_result_elt = xmlstream.toResponse(iq_elt, 'result') |
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
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
202 client.send(iq_result_elt) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
203 self._killSession(sid, client) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
204 |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
205 def _onIBBData(self, element, client): |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
206 """Observer called on <iq> or <message> stanzas with data element |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
207 |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
208 Manage the data elelement (check validity and write to the stream_object) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
209 @param element(domish.Element): <iq> or <message> stanza |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
210 """ |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
211 element.handled = True |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
212 data_elt = element.elements(NS_IBB, 'data').next() |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
213 sid = data_elt['sid'] |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
214 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
215 try: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
216 session_data = client.xep_0047_current_stream[sid] |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
217 except KeyError: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
218 log.warning(_(u"Received data for an unknown session id")) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
219 return self._sendError('item-not-found', None, element, client) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
220 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
221 from_jid = session_data["to"] |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
222 stream_object = session_data["stream_object"] |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
223 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
224 if from_jid.full() != element['from']: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
225 log.warning(_(u"sended jid inconsistency (man in the middle attack attempt ?)\ninitial={initial}\ngiven={given}").format(initial=from_jid, given=element['from'])) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
226 if element.name == 'iq': |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
227 self._sendError('not-acceptable', sid, element, client) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
228 return |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
229 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
230 session_data["seq"] = (session_data["seq"] + 1) % 65535 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
231 if int(data_elt.getAttribute("seq", -1)) != session_data["seq"]: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
232 log.warning(_(u"Sequence error")) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
233 if element.name == 'iq': |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
234 reason = 'not-acceptable' |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
235 self._sendError(reason, sid, element, client) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
236 self.terminateStream(session_data, client, reason) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
237 return |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
238 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
239 # we reset the timeout: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
240 session_data["timer"].reset(TIMEOUT) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
241 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
242 # we can now decode the data |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
243 try: |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
244 stream_object.write(base64.b64decode(str(data_elt))) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
245 except TypeError: |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
246 # The base64 data is invalid |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
247 log.warning(_(u"Invalid base64 data")) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
248 if element.name == 'iq': |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
249 self._sendError('not-acceptable', sid, element, client) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
250 self.terminateStream(session_data, client, reason) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
251 return |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
252 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
253 # we can now ack success |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
254 if element.name == 'iq': |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
255 iq_result_elt = xmlstream.toResponse(element, 'result') |
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
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
256 client.send(iq_result_elt) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
257 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
258 def _sendError(self, error_condition, sid, iq_elt, client): |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
259 """Send error stanza |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
260 |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
261 @param error_condition: one of twisted.words.protocols.jabber.error.STANZA_CONDITIONS keys |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
262 @param sid(unicode,None): jingle session id, or None, if session must not be destroyed |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
263 @param iq_elt(domish.Element): full <iq> stanza |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
264 @param client: %(doc_client)s |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
265 """ |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
266 iq_elt = error.StanzaError(error_condition).toResponse(iq_elt) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
267 log.warning(u"Error while managing in-band bytestream session, cancelling: {}".format(error_condition)) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
268 if sid is not None: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
269 self._killSession(sid, client, error_condition) |
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
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
270 client.send(iq_elt) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
271 |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
272 def startStream(self, client, stream_object, to_jid, sid, block_size=None): |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
273 """Launch the stream workflow |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
274 |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
275 @param stream_object(ifaces.IStreamProducer): stream object to send |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
276 @param to_jid(jid.JID): JID of the recipient |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
277 @param sid(unicode): Stream session id |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
278 @param block_size(int, None): size of the block (or None for default) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
279 """ |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
280 session_data = self._createSession(client, stream_object, to_jid, sid) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
281 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
282 if block_size is None: |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
283 block_size = XEP_0047.BLOCK_SIZE |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
284 assert block_size <= 65535 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
285 session_data["block_size"] = block_size |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
286 |
1578 | 287 iq_elt = client.IQ() |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
288 iq_elt['to'] = to_jid.full() |
1578 | 289 open_elt = iq_elt.addElement((NS_IBB, 'open')) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
290 open_elt['block-size'] = str(block_size) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
291 open_elt['sid'] = sid |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
292 open_elt['stanza'] = 'iq' # TODO: manage <message> stanza ? |
1578 | 293 args = [session_data, client] |
294 d = iq_elt.send() | |
295 d.addCallbacks(self._IQDataStreamCb, self._IQDataStreamEb, args, None, args) | |
1558
6a8dd91476f0
plugin XEP-0047: minor improvements
Goffi <goffi@goffi.org>
parents:
1524
diff
changeset
|
296 return session_data[DEFER_KEY] |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
297 |
1578 | 298 def _IQDataStreamCb(self, iq_elt, session_data, client): |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
299 """Called during the whole data streaming |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
300 |
1578 | 301 @param iq_elt(domish.Element): iq result |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
302 @param session_data(dict): data of this streaming session |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
303 @param client: %(doc_client)s |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
304 """ |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
305 session_data["timer"].reset(TIMEOUT) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
306 |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
307 buffer_ = session_data["stream_object"].read(session_data["block_size"]) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
308 if buffer_: |
1578 | 309 next_iq_elt = client.IQ() |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
310 next_iq_elt['to'] = session_data["to"].full() |
1578 | 311 data_elt = next_iq_elt.addElement((NS_IBB, 'data')) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
312 seq = session_data['seq'] = (session_data['seq'] + 1) % 65535 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
313 data_elt['seq'] = unicode(seq) |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
314 data_elt['sid'] = session_data['id'] |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
315 data_elt.addContent(base64.b64encode(buffer_)) |
1578 | 316 args = [session_data, client] |
317 d = next_iq_elt.send() | |
318 d.addCallbacks(self._IQDataStreamCb, self._IQDataStreamEb, args, None, args) | |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
319 else: |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
320 self.terminateStream(session_data, client) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
321 |
1578 | 322 def _IQDataStreamEb(self, failure, session_data, client): |
323 if failure.check(error.StanzaError): | |
1583
d46aae87c03a
plugins XEP-0047, XEP-0065, XEP-0096: fixed use of failure.condition insteand of failure.value + removed gettext use for local logs
Goffi <goffi@goffi.org>
parents:
1578
diff
changeset
|
324 log.warning(u"IBB transfer failed: {}".format(failure.value)) |
1578 | 325 else: |
1583
d46aae87c03a
plugins XEP-0047, XEP-0065, XEP-0096: fixed use of failure.condition insteand of failure.value + removed gettext use for local logs
Goffi <goffi@goffi.org>
parents:
1578
diff
changeset
|
326 log.error(u"IBB transfer failed: {}".format(failure.value)) |
1578 | 327 self.terminateStream(session_data, client, "IQ_ERROR") |
328 | |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
329 def terminateStream(self, session_data, client, failure_reason=None): |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
330 """Terminate the stream session |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
331 |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
332 @param session_data(dict): data of this streaming session |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
333 @param client: %(doc_client)s |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
334 @param failure_reason(unicode, None): reason of the failure, or None if steam was successful |
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
335 """ |
1578 | 336 iq_elt = client.IQ() |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
337 iq_elt['to'] = session_data["to"].full() |
1578 | 338 close_elt = iq_elt.addElement((NS_IBB, 'close')) |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
339 close_elt['sid'] = session_data['id'] |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
340 iq_elt.send() |
1524
7b0fcefd52d4
plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents:
1409
diff
changeset
|
341 self._killSession(session_data['id'], client, failure_reason) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
342 |
594
e629371a28d3
Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
588
diff
changeset
|
343 |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
344 class XEP_0047_handler(XMPPHandler): |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
345 implements(iwokkel.IDisco) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
346 |
594
e629371a28d3
Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
588
diff
changeset
|
347 def __init__(self, parent): |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
348 self.plugin_parent = parent |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
585
diff
changeset
|
349 |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
350 def connectionInitialized(self): |
2489
e2a7bb875957
plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
351 self.xmlstream.addObserver(IBB_OPEN, self.plugin_parent._onIBBOpen, client=self.parent) |
384
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
352 |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
353 def getDiscoInfo(self, requestor, target, nodeIdentifier=''): |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
354 return [disco.DiscoFeature(NS_IBB)] |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
355 |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
356 def getDiscoItems(self, requestor, target, nodeIdentifier=''): |
785420cd63f7
plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
357 return [] |