comparison sat/plugins/plugin_xep_0065.py @ 3040:fee60f17ebac

jp: jp asyncio port: /!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\ This patch implements the port of jp to asyncio, so it is now correctly using the bridge asynchronously, and it can be used with bridges like `pb`. This also simplify the code, notably for things which were previously implemented with many callbacks (like pagination with RSM). During the process, some behaviours have been modified/fixed, in jp and backends, check diff for details.
author Goffi <goffi@goffi.org>
date Wed, 25 Sep 2019 08:56:41 +0200
parents ab2696e34d29
children b64dd7c1496d
comparison
equal deleted inserted replaced
3039:a1bc34f90fa5 3040:fee60f17ebac
173 173
174 ProxyInfos = namedtuple("ProxyInfos", ["host", "jid", "port"]) 174 ProxyInfos = namedtuple("ProxyInfos", ["host", "jid", "port"])
175 175
176 176
177 class Candidate(object): 177 class Candidate(object):
178 def __init__( 178 def __init__(self, host, port, type_, priority, jid_, id_=None, priority_local=False,
179 self, 179 factory=None,):
180 host,
181 port,
182 type_,
183 priority,
184 jid_,
185 id_=None,
186 priority_local=False,
187 factory=None,
188 ):
189 """ 180 """
190 @param host(unicode): host IP or domain 181 @param host(unicode): host IP or domain
191 @param port(int): port 182 @param port(int): port
192 @param type_(unicode): stream type (one of XEP_0065.TYPE_*) 183 @param type_(unicode): stream type (one of XEP_0065.TYPE_*)
193 @param priority(int): priority 184 @param priority(int): priority
225 @property 216 @property
226 def priority(self): 217 def priority(self):
227 return self._priority 218 return self._priority
228 219
229 def __str__(self): 220 def __str__(self):
230 # similar to __unicode__ but we don't show jid and we encode id
231 return "Candidate ({0.priority}): host={0.host} port={0.port} type={0.type}{id}".format(
232 self,
233 id=" id={}".format(self.id if self.id is not None else "").encode(
234 "utf-8", "ignore"
235 ),
236 )
237
238 def __unicode__(self):
239 return "Candidate ({0.priority}): host={0.host} port={0.port} jid={0.jid} type={0.type}{id}".format( 221 return "Candidate ({0.priority}): host={0.host} port={0.port} jid={0.jid} type={0.type}{id}".format(
240 self, id=" id={}".format(self.id if self.id is not None else "") 222 self, id=" id={}".format(self.id if self.id is not None else "")
241 ) 223 )
242 224
243 def __eq__(self, other): 225 def __eq__(self, other):