annotate libervia/backend/plugins/plugin_xep_0047.py @ 4271:a5d27f69eedb

plugin misc list: Comments node creation can now be specified with `comments` field in `extra`.
author Goffi <goffi@goffi.org>
date Thu, 20 Jun 2024 14:36:09 +0200
parents 0d7bb4df2343
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
1 #!/usr/bin/env python3
3137
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
2
384
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)
3479
be6d91572633 date update
Goffi <goffi@goffi.org>
parents: 3392
diff changeset
5 # Copyright (C) 2009-2021 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
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
20 from libervia.backend.core.i18n import _
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
21 from libervia.backend.core.log import getLogger
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
22
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 941
diff changeset
23 log = getLogger(__name__)
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
24 from libervia.backend.core.constants import Const as C
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
25 from libervia.backend.core import exceptions
1524
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 jid
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 xmlstream
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
28 from twisted.words.protocols.jabber import error
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
29 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
30 from twisted.internet import defer
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
31 from twisted.python import failure
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
32
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from wokkel import disco, iwokkel
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
34
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
35 from zope.interface import implementer
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
36
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
37 import base64
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
38
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
39 try:
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
40 from twisted.words.protocols.xmlstream import XMPPHandler
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
41 except ImportError:
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
42 from wokkel.subprotocols import XMPPHandler
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
43
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
44 MESSAGE = "/message"
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
45 IQ_SET = '/iq[@type="set"]'
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
46 NS_IBB = "http://jabber.org/protocol/ibb"
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
47 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
48 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
49 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
50 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
51 TIMEOUT = 120 # timeout for workflow
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
52 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
53
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
54 PLUGIN_INFO = {
2145
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
55 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
56 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
57 C.PI_TYPE: "XEP",
2504
67cc54b01a12 plugin file sharing component: first draft:
Goffi <goffi@goffi.org>
parents: 2489
diff changeset
58 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
59 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
60 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
61 C.PI_HANDLER: "yes",
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
62 C.PI_DESCRIPTION: _("""Implementation of In-Band Bytestreams"""),
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
63 }
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
64
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
65
588
beaf6bec2fcd Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
66 class XEP_0047(object):
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
67 NAMESPACE = NS_IBB
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
68 BLOCK_SIZE = 4096
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
69
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
70 def __init__(self, host):
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 941
diff changeset
71 log.info(_("In-Band Bytestreams plugin initialization"))
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
72 self.host = host
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
73
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
74 def get_handler(self, client):
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
75 return XEP_0047_handler(self)
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
76
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
77 def profile_connected(self, client):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
78 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
79
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
80 def _time_out(self, sid, client):
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
81 """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
82
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
83 @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
84 @param client: %(doc_client)s
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
85 """
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
86 log.info(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
87 "In-Band Bytestream: TimeOut reached for id {sid} [{profile}]".format(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
88 sid=sid, profile=client.profile
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
89 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
90 )
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
91 self._kill_session(sid, client, "TIMEOUT")
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
92
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
93 def _kill_session(self, sid, client, failure_reason=None):
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
94 """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
95
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
96 @param sid(unicode): session id
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
97 @param client: %(doc_client)s
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
98 @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
99 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
100 """
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
101 try:
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
102 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
103 except KeyError:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
104 log.warning("kill id called on a non existant id")
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
105 return
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
106
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
107 try:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
108 observer_cb = session["observer_cb"]
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
109 except KeyError:
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
110 pass
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
111 else:
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
112 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
113
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
114 if session["timer"].active():
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
115 session["timer"].cancel()
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
116
538
2c4016921403 core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents: 536
diff changeset
117 del client.xep_0047_current_stream[sid]
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
118
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
119 success = failure_reason is None
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
120 stream_d = session[DEFER_KEY]
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
121
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
122 if success:
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
123 stream_d.callback(None)
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
124 else:
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
125 stream_d.errback(failure.Failure(exceptions.DataError(failure_reason)))
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
126
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
127 def create_session(self, *args, **kwargs):
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
128 """like [_create_session] 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
129
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
130 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
131 """
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
132 return self._create_session(*args, **kwargs)[DEFER_KEY]
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
133
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
134 def _create_session(self, client, stream_object, local_jid, to_jid, sid):
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
135 """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
136
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
137 @param stream_object(IConsumer): stream object where data will be written
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
138 @param local_jid(jid.JID): same as [start_stream]
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
139 @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
140 @param sid(unicode): session id
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
141 @return (dict): session data
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
142 """
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
143 if sid in client.xep_0047_current_stream:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
144 raise exceptions.ConflictError("A session with this id already exists !")
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
145 session_data = client.xep_0047_current_stream[sid] = {
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
146 "id": sid,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
147 DEFER_KEY: defer.Deferred(),
2927
69e4716d6268 plugins (jingle) file transfer: use initial "from" attribute as local jid instead of client.jid:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
148 "local_jid": local_jid,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
149 "to": to_jid,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
150 "stream_object": stream_object,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
151 "seq": -1,
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
152 "timer": reactor.callLater(TIMEOUT, self._time_out, sid, client),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
153 }
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
154
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
155 return session_data
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
156
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
157 def _on_ibb_open(self, iq_elt, client):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
158 """ "Called when an IBB <open> element is received
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
159
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
160 @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
161 """
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
162 log.debug(_("IBB stream opening"))
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
163 iq_elt.handled = True
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
164 open_elt = next(iq_elt.elements(NS_IBB, "open"))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
165 block_size = open_elt.getAttribute("block-size")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
166 sid = open_elt.getAttribute("sid")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
167 stanza = open_elt.getAttribute("stanza", "iq")
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
168 if not sid or not block_size or int(block_size) > 65535:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
169 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
170 if not sid in client.xep_0047_current_stream:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
171 log.warning(_("Ignoring unexpected IBB transfer: %s" % sid))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
172 return self._sendError("not-acceptable", sid or None, iq_elt, client)
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
173 session_data = client.xep_0047_current_stream[sid]
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
174 if session_data["to"] != jid.JID(iq_elt["from"]):
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
175 log.warning(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
176 _("sended jid inconsistency (man in the middle attack attempt ?)")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
177 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
178 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
179
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
180 # 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
181
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
182 # we reset the timeout:
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
183 session_data["timer"].reset(TIMEOUT)
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
184
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
185 # we save the xmlstream, events and observer data to allow observer removal
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
186 session_data["event_data"] = event_data = (
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
187 IBB_MESSAGE_DATA if stanza == "message" else IBB_IQ_DATA
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
188 ).format(sid)
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
189 session_data["observer_cb"] = observer_cb = self._on_ibb_data
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
190 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
191 # 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
192 # 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
193 # 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
194 client.xmlstream.addObserver(event_data, observer_cb, client=client)
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
195 client.xmlstream.addOnetimeObserver(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
196 event_close, self._on_ibb_close, client=client
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
197 )
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
198 # finally, we send the accept stanza
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
199 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
200 client.send(iq_result_elt)
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
201
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
202 def _on_ibb_close(self, iq_elt, client):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
203 """ "Called when an IBB <close> element is received
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
204
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
205 @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
206 """
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
207 iq_elt.handled = True
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 941
diff changeset
208 log.debug(_("IBB stream closing"))
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
209 close_elt = next(iq_elt.elements(NS_IBB, "close"))
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
210 # XXX: this observer is only triggered on valid sid, so we don't need to check it
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
211 sid = close_elt["sid"]
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
212
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
213 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
214 client.send(iq_result_elt)
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
215 self._kill_session(sid, client)
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
216
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
217 def _on_ibb_data(self, element, client):
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
218 """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
219
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
220 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
221 @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
222 """
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
223 element.handled = True
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
224 data_elt = next(element.elements(NS_IBB, "data"))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
225 sid = data_elt["sid"]
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
226
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
227 try:
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
228 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
229 except KeyError:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
230 log.warning(_("Received data for an unknown session id"))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
231 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
232
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
233 from_jid = session_data["to"]
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
234 stream_object = session_data["stream_object"]
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
235
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
236 if from_jid.full() != element["from"]:
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
237 log.warning(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
238 _(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
239 "sended jid inconsistency (man in the middle attack attempt ?)\ninitial={initial}\ngiven={given}"
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
240 ).format(initial=from_jid, given=element["from"])
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
241 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
242 if element.name == "iq":
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
243 self._sendError("not-acceptable", sid, element, client)
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
244 return
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
245
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
246 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
247 if int(data_elt.getAttribute("seq", -1)) != session_data["seq"]:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
248 log.warning(_("Sequence error"))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
249 if element.name == "iq":
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
250 reason = "not-acceptable"
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
251 self._sendError(reason, sid, element, client)
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
252 self.terminate_stream(session_data, client, reason)
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
253 return
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
254
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
255 # we reset the timeout:
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
256 session_data["timer"].reset(TIMEOUT)
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
257
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
258 # we can now decode the data
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
259 try:
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
260 stream_object.write(base64.b64decode(str(data_elt)))
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
261 except TypeError:
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
262 # The base64 data is invalid
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
263 log.warning(_("Invalid base64 data"))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
264 if element.name == "iq":
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
265 self._sendError("not-acceptable", sid, element, client)
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
266 self.terminate_stream(session_data, client, reason)
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
267 return
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
268
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
269 # we can now ack success
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
270 if element.name == "iq":
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
271 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
272 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
273
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
274 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
275 """Send error stanza
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
276
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
277 @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
278 @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
279 @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
280 @param client: %(doc_client)s
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 iq_elt = error.StanzaError(error_condition).toResponse(iq_elt)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
283 log.warning(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
284 "Error while managing in-band bytestream session, cancelling: {}".format(
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
285 error_condition
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
286 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
287 )
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
288 if sid is not None:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
289 self._kill_session(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
290 client.send(iq_elt)
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
291
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
292 def start_stream(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
293 self, client, stream_object, local_jid, to_jid, sid, block_size=None
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
294 ):
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
295 """Launch the stream workflow
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
296
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
297 @param stream_object(ifaces.IStreamProducer): stream object to send
2927
69e4716d6268 plugins (jingle) file transfer: use initial "from" attribute as local jid instead of client.jid:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
298 @param local_jid(jid.JID): jid to use as local jid
69e4716d6268 plugins (jingle) file transfer: use initial "from" attribute as local jid instead of client.jid:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
299 This is needed for client which can be addressed with a different jid than
69e4716d6268 plugins (jingle) file transfer: use initial "from" attribute as local jid instead of client.jid:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
300 client.jid if a local part is used (e.g. piotr@file.example.net where
69e4716d6268 plugins (jingle) file transfer: use initial "from" attribute as local jid instead of client.jid:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
301 client.jid would be file.example.net)
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
302 @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
303 @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
304 @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
305 """
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
306 session_data = self._create_session(client, stream_object, local_jid, to_jid, sid)
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
307
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
308 if block_size is None:
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
309 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
310 assert block_size <= 65535
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
311 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
312
1578
7fef6cdf5953 plugin XEP-0047: some cleaning
Goffi <goffi@goffi.org>
parents: 1558
diff changeset
313 iq_elt = client.IQ()
2927
69e4716d6268 plugins (jingle) file transfer: use initial "from" attribute as local jid instead of client.jid:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
314 iq_elt["from"] = local_jid.full()
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
315 iq_elt["to"] = to_jid.full()
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
316 open_elt = iq_elt.addElement((NS_IBB, "open"))
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
317 open_elt["block-size"] = str(block_size)
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
318 open_elt["sid"] = sid
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
319 open_elt["stanza"] = "iq" # TODO: manage <message> stanza ?
1578
7fef6cdf5953 plugin XEP-0047: some cleaning
Goffi <goffi@goffi.org>
parents: 1558
diff changeset
320 args = [session_data, client]
7fef6cdf5953 plugin XEP-0047: some cleaning
Goffi <goffi@goffi.org>
parents: 1558
diff changeset
321 d = iq_elt.send()
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
322 d.addCallbacks(self._iq_data_stream_cb, self._iq_data_stream_eb, args, None, args)
1558
6a8dd91476f0 plugin XEP-0047: minor improvements
Goffi <goffi@goffi.org>
parents: 1524
diff changeset
323 return session_data[DEFER_KEY]
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
324
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
325 def _iq_data_stream_cb(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
326 """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
327
1578
7fef6cdf5953 plugin XEP-0047: some cleaning
Goffi <goffi@goffi.org>
parents: 1558
diff changeset
328 @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
329 @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
330 @param client: %(doc_client)s
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 session_data["timer"].reset(TIMEOUT)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
333
3392
0957ea9137b8 plugin XEP-0047: fixed file reading and content encoding
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
334 # FIXME: producer/consumer mechanism is not used properly here
0957ea9137b8 plugin XEP-0047: fixed file reading and content encoding
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
335 buffer_ = session_data["stream_object"].file_obj.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
336 if buffer_:
1578
7fef6cdf5953 plugin XEP-0047: some cleaning
Goffi <goffi@goffi.org>
parents: 1558
diff changeset
337 next_iq_elt = client.IQ()
2927
69e4716d6268 plugins (jingle) file transfer: use initial "from" attribute as local jid instead of client.jid:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
338 next_iq_elt["from"] = session_data["local_jid"].full()
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
339 next_iq_elt["to"] = session_data["to"].full()
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
340 data_elt = next_iq_elt.addElement((NS_IBB, "data"))
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
341 seq = session_data["seq"] = (session_data["seq"] + 1) % 65535
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
342 data_elt["seq"] = str(seq)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
343 data_elt["sid"] = session_data["id"]
3392
0957ea9137b8 plugin XEP-0047: fixed file reading and content encoding
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
344 data_elt.addContent(base64.b64encode(buffer_).decode())
1578
7fef6cdf5953 plugin XEP-0047: some cleaning
Goffi <goffi@goffi.org>
parents: 1558
diff changeset
345 args = [session_data, client]
7fef6cdf5953 plugin XEP-0047: some cleaning
Goffi <goffi@goffi.org>
parents: 1558
diff changeset
346 d = next_iq_elt.send()
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
347 d.addCallbacks(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
348 self._iq_data_stream_cb, self._iq_data_stream_eb, args, None, args
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
349 )
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
350 else:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
351 self.terminate_stream(session_data, client)
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
352
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
353 def _iq_data_stream_eb(self, failure, session_data, client):
1578
7fef6cdf5953 plugin XEP-0047: some cleaning
Goffi <goffi@goffi.org>
parents: 1558
diff changeset
354 if failure.check(error.StanzaError):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
355 log.warning("IBB transfer failed: {}".format(failure.value))
1578
7fef6cdf5953 plugin XEP-0047: some cleaning
Goffi <goffi@goffi.org>
parents: 1558
diff changeset
356 else:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
357 log.error("IBB transfer failed: {}".format(failure.value))
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
358 self.terminate_stream(session_data, client, "IQ_ERROR")
1578
7fef6cdf5953 plugin XEP-0047: some cleaning
Goffi <goffi@goffi.org>
parents: 1558
diff changeset
359
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
360 def terminate_stream(self, session_data, client, failure_reason=None):
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
361 """Terminate the stream session
1524
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
362
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
363 @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
364 @param client: %(doc_client)s
7b0fcefd52d4 plugin XEP-0047, XEP-0096: In-Band Bystream plugin cleaning:
Goffi <goffi@goffi.org>
parents: 1409
diff changeset
365 @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
366 """
1578
7fef6cdf5953 plugin XEP-0047: some cleaning
Goffi <goffi@goffi.org>
parents: 1558
diff changeset
367 iq_elt = client.IQ()
2927
69e4716d6268 plugins (jingle) file transfer: use initial "from" attribute as local jid instead of client.jid:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
368 iq_elt["from"] = session_data["local_jid"].full()
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
369 iq_elt["to"] = session_data["to"].full()
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
370 close_elt = iq_elt.addElement((NS_IBB, "close"))
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
371 close_elt["sid"] = session_data["id"]
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
372 iq_elt.send()
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
373 self._kill_session(session_data["id"], client, failure_reason)
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
374
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
375
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2927
diff changeset
376 @implementer(iwokkel.IDisco)
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
377 class XEP_0047_handler(XMPPHandler):
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
378
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
379 def __init__(self, parent):
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
380 self.plugin_parent = parent
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 585
diff changeset
381
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
382 def connectionInitialized(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
383 self.xmlstream.addObserver(
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
384 IBB_OPEN, self.plugin_parent._on_ibb_open, client=self.parent
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
385 )
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
386
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
387 def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
388 return [disco.DiscoFeature(NS_IBB)]
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
389
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
390 def getDiscoItems(self, requestor, target, nodeIdentifier=""):
384
785420cd63f7 plugins: In-Band Bytestreams (XEP-0047) implementation
Goffi <goffi@goffi.org>
parents:
diff changeset
391 return []