comparison libervia/backend/plugins/plugin_xep_0447.py @ 4335:430d5d99a740

plugin XEP-0358: "Publishing Available Jingle Sessions" implementation: rel 453
author Goffi <goffi@goffi.org>
date Tue, 03 Dec 2024 00:13:07 +0100 (12 days ago)
parents 111dce64dcb5
children
comparison
equal deleted inserted replaced
4334:111dce64dcb5 4335:430d5d99a740
45 from libervia.backend.core.constants import Const as C 45 from libervia.backend.core.constants import Const as C
46 from libervia.backend.core.core_types import SatXMPPEntity 46 from libervia.backend.core.core_types import SatXMPPEntity
47 from libervia.backend.core.i18n import _ 47 from libervia.backend.core.i18n import _
48 from libervia.backend.core.log import getLogger 48 from libervia.backend.core.log import getLogger
49 from libervia.backend.plugins.plugin_xep_0103 import URLData, XEP_0103 49 from libervia.backend.plugins.plugin_xep_0103 import URLData, XEP_0103
50 from libervia.backend.plugins.plugin_xep_0358 import JinglePub, XEP_0358
50 from libervia.backend.plugins.plugin_xep_0446 import FileMetadata, XEP_0446 51 from libervia.backend.plugins.plugin_xep_0446 import FileMetadata, XEP_0446
51 from libervia.backend.tools import stream 52 from libervia.backend.tools import stream
52 from libervia.backend.tools.web import treq_client_no_ssl 53 from libervia.backend.tools.web import treq_client_no_ssl
53 54
54 log = getLogger(__name__) 55 log = getLogger(__name__)
61 C.PI_MODES: C.PLUG_MODE_BOTH, 62 C.PI_MODES: C.PLUG_MODE_BOTH,
62 C.PI_PROTOCOLS: ["XEP-0447"], 63 C.PI_PROTOCOLS: ["XEP-0447"],
63 C.PI_DEPENDENCIES: [ 64 C.PI_DEPENDENCIES: [
64 "XEP-0103", 65 "XEP-0103",
65 "XEP-0334", 66 "XEP-0334",
67 "XEP-0358",
66 "XEP-0446", 68 "XEP-0446",
67 "ATTACH", 69 "ATTACH",
68 "DOWNLOAD", 70 "DOWNLOAD",
69 ], 71 ],
70 C.PI_RECOMMENDATIONS: ["XEP-0363"], 72 C.PI_RECOMMENDATIONS: ["XEP-0363"],
184 186
185 def to_element(self) -> domish.Element: 187 def to_element(self) -> domish.Element:
186 return super().to_element() 188 return super().to_element()
187 189
188 190
191 class JinglePubSource(JinglePub, Source):
192 type = "jingle"
193
194 @classmethod
195 def from_element(cls, element: domish.Element) -> Self:
196 return super().from_element(element)
197
198 def to_element(self) -> domish.Element:
199 return super().to_element()
200
201
189 class XEP_0447: 202 class XEP_0447:
190 namespace = NS_SFS 203 namespace = NS_SFS
191 204
192 def __init__(self, host): 205 def __init__(self, host):
193 self.host = host 206 self.host = host
194 log.info(_("XEP-0447 (Stateless File Sharing) plugin initialization")) 207 log.info(_("XEP-0447 (Stateless File Sharing) plugin initialization"))
195 host.register_namespace("sfs", NS_SFS) 208 host.register_namespace("sfs", NS_SFS)
196 FileSharing._sfs = self 209 FileSharing._sfs = self
197 self._sources_handlers: dict[tuple[str, str], type[Source]] = {} 210 self._sources_handlers: dict[tuple[str, str], type[Source]] = {}
198 self._u = cast(XEP_0103, host.plugins["XEP-0103"]) 211 self._u = cast(XEP_0103, host.plugins["XEP-0103"])
212 self._jp = cast(XEP_0358, host.plugins["XEP-0358"])
199 self._hints = host.plugins["XEP-0334"] 213 self._hints = host.plugins["XEP-0334"]
200 self._m = cast(XEP_0446, host.plugins["XEP-0446"]) 214 self._m = cast(XEP_0446, host.plugins["XEP-0446"])
201 self._http_upload = host.plugins.get("XEP-0363") 215 self._http_upload = host.plugins.get("XEP-0363")
202 self._attach = host.plugins["ATTACH"] 216 self._attach = host.plugins["ATTACH"]
203 self._attach.register(self.can_handle_attachment, self.attach, priority=1000) 217 self._attach.register(self.can_handle_attachment, self.attach, priority=1000)