Mercurial > libervia-backend
comparison libervia/backend/plugins/plugin_xep_0100.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 4b842c1fb686 |
children | 7ded09452875 |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
59 | 59 |
60 class XEP_0100(object): | 60 class XEP_0100(object): |
61 def __init__(self, host): | 61 def __init__(self, host): |
62 log.info(_("Gateways plugin initialization")) | 62 log.info(_("Gateways plugin initialization")) |
63 self.host = host | 63 self.host = host |
64 self.__gateways = {} # dict used to construct the answer to gateways_find. Key = target jid | 64 self.__gateways = ( |
65 {} | |
66 ) # dict used to construct the answer to gateways_find. Key = target jid | |
65 host.bridge.add_method( | 67 host.bridge.add_method( |
66 "gateways_find", | 68 "gateways_find", |
67 ".plugin", | 69 ".plugin", |
68 in_sign="ss", | 70 in_sign="ss", |
69 out_sign="s", | 71 out_sign="s", |
86 security_limit=1, | 88 security_limit=1, |
87 help_string=D_("Find gateways"), | 89 help_string=D_("Find gateways"), |
88 ) | 90 ) |
89 | 91 |
90 def _gateways_menu(self, data, profile): | 92 def _gateways_menu(self, data, profile): |
91 """ XMLUI activated by menu: return Gateways UI | 93 """XMLUI activated by menu: return Gateways UI |
92 | 94 |
93 @param profile: %(doc_profile)s | 95 @param profile: %(doc_profile)s |
94 """ | 96 """ |
95 client = self.host.get_client(profile) | 97 client = self.host.get_client(profile) |
96 try: | 98 try: |
146 d = self.gateway_register(target_jid, profile) | 148 d = self.gateway_register(target_jid, profile) |
147 d.addCallback(lambda xmlui: {"xmlui": xmlui.toXml()}) | 149 d.addCallback(lambda xmlui: {"xmlui": xmlui.toXml()}) |
148 return d | 150 return d |
149 | 151 |
150 def _get_identity_desc(self, identity): | 152 def _get_identity_desc(self, identity): |
151 """ Return a human readable description of identity | 153 """Return a human readable description of identity |
152 @param identity: tuple as returned by Disco identities (category, type) | 154 @param identity: tuple as returned by Disco identities (category, type) |
153 | 155 |
154 """ | 156 """ |
155 category, type_ = identity | 157 category, type_ = identity |
156 if category != "gateway": | 158 if category != "gateway": |
251 d.addCallback(self._gateways_result_2_xmlui, target_jid) | 253 d.addCallback(self._gateways_result_2_xmlui, target_jid) |
252 d.addCallback(lambda xmlui: xmlui.toXml()) | 254 d.addCallback(lambda xmlui: xmlui.toXml()) |
253 return d | 255 return d |
254 | 256 |
255 def gateways_find(self, target, profile): | 257 def gateways_find(self, target, profile): |
256 """Find gateways in the target JID, using discovery protocol | 258 """Find gateways in the target JID, using discovery protocol""" |
257 """ | |
258 client = self.host.get_client(profile) | 259 client = self.host.get_client(profile) |
259 log.debug( | 260 log.debug( |
260 _("find gateways (target = %(target)s, profile = %(profile)s)") | 261 _("find gateways (target = %(target)s, profile = %(profile)s)") |
261 % {"target": target.full(), "profile": profile} | 262 % {"target": target.full(), "profile": profile} |
262 ) | 263 ) |