Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0261.py @ 4037:524856bd7b19
massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a
pre-PEP8 code, to use the same coding style as in Twisted.
However, snake_case is more readable and it's better to follow PEP8 best practices, so it
has been decided to move on full snake_case. Because Libervia has a huge codebase, this
ended with a ugly mix of camelCase and snake_case.
To fix that, this patch does a big refactoring by renaming every function and method
(including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case.
This is a massive change, and may result in some bugs.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:54:42 +0200 |
parents | be6d91572633 |
children |
comparison
equal
deleted
inserted
replaced
4036:c4464d7ae97b | 4037:524856bd7b19 |
---|---|
54 def __init__(self, host): | 54 def __init__(self, host): |
55 log.info(_("plugin Jingle In-Band Bytestreams")) | 55 log.info(_("plugin Jingle In-Band Bytestreams")) |
56 self.host = host | 56 self.host = host |
57 self._j = host.plugins["XEP-0166"] # shortcut to access jingle | 57 self._j = host.plugins["XEP-0166"] # shortcut to access jingle |
58 self._ibb = host.plugins["XEP-0047"] # and in-band bytestream | 58 self._ibb = host.plugins["XEP-0047"] # and in-band bytestream |
59 self._j.registerTransport( | 59 self._j.register_transport( |
60 NS_JINGLE_IBB, self._j.TRANSPORT_STREAMING, self, -10000 | 60 NS_JINGLE_IBB, self._j.TRANSPORT_STREAMING, self, -10000 |
61 ) # must be the lowest priority | 61 ) # must be the lowest priority |
62 | 62 |
63 def getHandler(self, client): | 63 def get_handler(self, client): |
64 return XEP_0261_handler() | 64 return XEP_0261_handler() |
65 | 65 |
66 def jingleSessionInit(self, client, session, content_name): | 66 def jingle_session_init(self, client, session, content_name): |
67 transport_elt = domish.Element((NS_JINGLE_IBB, "transport")) | 67 transport_elt = domish.Element((NS_JINGLE_IBB, "transport")) |
68 content_data = session["contents"][content_name] | 68 content_data = session["contents"][content_name] |
69 transport_data = content_data["transport_data"] | 69 transport_data = content_data["transport_data"] |
70 transport_data["block_size"] = self._ibb.BLOCK_SIZE | 70 transport_data["block_size"] = self._ibb.BLOCK_SIZE |
71 transport_elt["block-size"] = str(transport_data["block_size"]) | 71 transport_elt["block-size"] = str(transport_data["block_size"]) |
72 transport_elt["sid"] = transport_data["sid"] = str(uuid.uuid4()) | 72 transport_elt["sid"] = transport_data["sid"] = str(uuid.uuid4()) |
73 return transport_elt | 73 return transport_elt |
74 | 74 |
75 def jingleHandler(self, client, action, session, content_name, transport_elt): | 75 def jingle_handler(self, client, action, session, content_name, transport_elt): |
76 content_data = session["contents"][content_name] | 76 content_data = session["contents"][content_name] |
77 transport_data = content_data["transport_data"] | 77 transport_data = content_data["transport_data"] |
78 if action in ( | 78 if action in ( |
79 self._j.A_SESSION_ACCEPT, | 79 self._j.A_SESSION_ACCEPT, |
80 self._j.A_ACCEPTED_ACK, | 80 self._j.A_ACCEPTED_ACK, |
88 peer_jid = session["peer_jid"] | 88 peer_jid = session["peer_jid"] |
89 sid = transport_data["sid"] | 89 sid = transport_data["sid"] |
90 stream_object = content_data["stream_object"] | 90 stream_object = content_data["stream_object"] |
91 if action == self._j.A_START: | 91 if action == self._j.A_START: |
92 block_size = transport_data["block_size"] | 92 block_size = transport_data["block_size"] |
93 d = self._ibb.startStream( | 93 d = self._ibb.start_stream( |
94 client, stream_object, local_jid, peer_jid, sid, block_size | 94 client, stream_object, local_jid, peer_jid, sid, block_size |
95 ) | 95 ) |
96 d.chainDeferred(content_data["finished_d"]) | 96 d.chainDeferred(content_data["finished_d"]) |
97 else: | 97 else: |
98 d = self._ibb.createSession( | 98 d = self._ibb.create_session( |
99 client, stream_object, local_jid, peer_jid, sid) | 99 client, stream_object, local_jid, peer_jid, sid) |
100 d.chainDeferred(content_data["finished_d"]) | 100 d.chainDeferred(content_data["finished_d"]) |
101 else: | 101 else: |
102 log.warning("FIXME: unmanaged action {}".format(action)) | 102 log.warning("FIXME: unmanaged action {}".format(action)) |
103 return transport_elt | 103 return transport_elt |