comparison sat/plugins/plugin_tmp_directory_subscription.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children ab2696e34d29
comparison
equal deleted inserted replaced
2623:49533de4540b 2624:56f94936df1e
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. 19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 20
21 from sat.core.i18n import _, D_ 21 from sat.core.i18n import _, D_
22 from sat.core.constants import Const as C 22 from sat.core.constants import Const as C
23 from sat.core.log import getLogger 23 from sat.core.log import getLogger
24
24 log = getLogger(__name__) 25 log = getLogger(__name__)
25 26
26 27
27 PLUGIN_INFO = { 28 PLUGIN_INFO = {
28 C.PI_NAME: "Directory subscription plugin", 29 C.PI_NAME: "Directory subscription plugin",
31 C.PI_PROTOCOLS: [], 32 C.PI_PROTOCOLS: [],
32 C.PI_DEPENDENCIES: ["XEP-0050", "XEP-0055"], 33 C.PI_DEPENDENCIES: ["XEP-0050", "XEP-0055"],
33 C.PI_RECOMMENDATIONS: [], 34 C.PI_RECOMMENDATIONS: [],
34 C.PI_MAIN: "DirectorySubscription", 35 C.PI_MAIN: "DirectorySubscription",
35 C.PI_HANDLER: "no", 36 C.PI_HANDLER: "no",
36 C.PI_DESCRIPTION: _("""Implementation of directory subscription""") 37 C.PI_DESCRIPTION: _("""Implementation of directory subscription"""),
37 } 38 }
38 39
39 40
40 NS_COMMANDS = "http://jabber.org/protocol/commands" 41 NS_COMMANDS = "http://jabber.org/protocol/commands"
41 CMD_UPDATE_SUBSCRIBTION = "update" 42 CMD_UPDATE_SUBSCRIBTION = "update"
42 43
43 44
44 class DirectorySubscription(object): 45 class DirectorySubscription(object):
45
46 def __init__(self, host): 46 def __init__(self, host):
47 log.info(_("Directory subscription plugin initialization")) 47 log.info(_("Directory subscription plugin initialization"))
48 self.host = host 48 self.host = host
49 host.importMenu((D_("Service"), D_("Directory subscription")), self.subscribe, security_limit=1, help_string=D_("User directory subscription")) 49 host.importMenu(
50 (D_("Service"), D_("Directory subscription")),
51 self.subscribe,
52 security_limit=1,
53 help_string=D_("User directory subscription"),
54 )
50 55
51 def subscribe(self, raw_data, profile): 56 def subscribe(self, raw_data, profile):
52 """Request available commands on the jabber search service associated to profile's host. 57 """Request available commands on the jabber search service associated to profile's host.
53 58
54 @param raw_data (dict): data received from the frontend 59 @param raw_data (dict): data received from the frontend
57 """ 62 """
58 d = self.host.plugins["XEP-0055"]._getHostServices(profile) 63 d = self.host.plugins["XEP-0055"]._getHostServices(profile)
59 64
60 def got_services(services): 65 def got_services(services):
61 service_jid = services[0] 66 service_jid = services[0]
62 session_id, session_data = self.host.plugins["XEP-0050"].requesting.newSession(profile=profile) 67 session_id, session_data = self.host.plugins[
68 "XEP-0050"
69 ].requesting.newSession(profile=profile)
63 session_data["jid"] = service_jid 70 session_data["jid"] = service_jid
64 session_data["node"] = CMD_UPDATE_SUBSCRIBTION 71 session_data["node"] = CMD_UPDATE_SUBSCRIBTION
65 data = {"session_id": session_id} 72 data = {"session_id": session_id}
66 return self.host.plugins["XEP-0050"]._requestingEntity(data, profile) 73 return self.host.plugins["XEP-0050"]._requestingEntity(data, profile)
67 74