Reformatted code base using black.
This commit is contained in:
parent
56319cbad3
commit
53fdaa9d09
1 changed files with 12604 additions and 8966 deletions
|
|
@ -97,7 +97,9 @@ class XEP_0260(BaseTransportHandler):
|
|||
# self._s5b.registerCandidate(candidate)
|
||||
return candidates
|
||||
|
||||
def _build_candidates(self, session, candidates, sid, session_hash, client, mode=None):
|
||||
def _build_candidates(
|
||||
self, session, candidates, sid, session_hash, client, mode=None
|
||||
):
|
||||
"""Build <transport> element with candidates
|
||||
|
||||
@param session(dict): jingle session data
|
||||
|
|
@ -147,7 +149,8 @@ class XEP_0260(BaseTransportHandler):
|
|||
) # requester and target are inversed for peer candidates
|
||||
transport_data["stream_d"] = self._s5b.register_hash(client, session_hash, None)
|
||||
candidates = transport_data["candidates"] = await self._s5b.get_candidates(
|
||||
client, session["local_jid"])
|
||||
client, session["local_jid"]
|
||||
)
|
||||
mode = "tcp" # XXX: we only manage tcp for now
|
||||
transport_elt = self._build_candidates(
|
||||
session, candidates, sid, session_hash, client, mode
|
||||
|
|
@ -155,7 +158,9 @@ class XEP_0260(BaseTransportHandler):
|
|||
|
||||
return transport_elt
|
||||
|
||||
def _proxy_activated_cb(self, iq_result_elt, client, candidate, session, content_name):
|
||||
def _proxy_activated_cb(
|
||||
self, iq_result_elt, client, candidate, session, content_name
|
||||
):
|
||||
"""Called when activation confirmation has been received from proxy
|
||||
|
||||
cf XEP-0260 § 2.4
|
||||
|
|
@ -304,7 +309,11 @@ class XEP_0260(BaseTransportHandler):
|
|||
)
|
||||
args = [client, choosed_candidate, session, content_name]
|
||||
d.addCallbacks(
|
||||
self._proxy_activated_cb, self._proxy_activated_eb, args, None, args
|
||||
self._proxy_activated_cb,
|
||||
self._proxy_activated_eb,
|
||||
args,
|
||||
None,
|
||||
args,
|
||||
)
|
||||
else:
|
||||
# this Deferred will be called when we'll receive activation confirmation from other peer
|
||||
|
|
@ -356,9 +365,7 @@ class XEP_0260(BaseTransportHandler):
|
|||
log.warning("No cid found in <candidate-used>")
|
||||
raise exceptions.DataError
|
||||
try:
|
||||
candidate = next((
|
||||
c for c in transport_data["candidates"] if c.id == cid
|
||||
))
|
||||
candidate = next((c for c in transport_data["candidates"] if c.id == cid))
|
||||
except StopIteration:
|
||||
log.warning("Given cid doesn't correspond to any known candidate !")
|
||||
raise exceptions.DataError # TODO: send an error to other peer, and use better exception
|
||||
|
|
@ -433,10 +440,8 @@ class XEP_0260(BaseTransportHandler):
|
|||
session_hash = transport_data["session_hash"] = self._s5b.get_session_hash(
|
||||
session["local_jid"], session["peer_jid"], sid
|
||||
)
|
||||
peer_session_hash = transport_data[
|
||||
"peer_session_hash"
|
||||
] = self._s5b.get_session_hash(
|
||||
session["peer_jid"], session["local_jid"], sid
|
||||
peer_session_hash = transport_data["peer_session_hash"] = (
|
||||
self._s5b.get_session_hash(session["peer_jid"], session["local_jid"], sid)
|
||||
) # requester and target are inversed for peer candidates
|
||||
peer_candidates = transport_data["peer_candidates"] = self._parse_candidates(
|
||||
transport_elt
|
||||
|
|
@ -505,8 +510,8 @@ class XEP_0260(BaseTransportHandler):
|
|||
def _do_fallback(self, feature_checked, session, content_name, client):
|
||||
"""Do the fallback, method called once feature is checked
|
||||
|
||||
@param feature_checked(bool): True if other peer can do IBB
|
||||
"""
|
||||
@param feature_checked(bool): True if other peer can do IBB
|
||||
"""
|
||||
if not feature_checked:
|
||||
log.warning(
|
||||
"Other peer can't manage jingle IBB, be have to terminate the session"
|
||||
|
|
|
|||
Loading…
Reference in a new issue