comparison src/plugins/plugin_tmp_directory_subscription.py @ 2145:33c8c4973743

core (plugins): added missing contants + use of new constants in PLUGIN_INFO
author Goffi <goffi@goffi.org>
date Sun, 12 Feb 2017 18:59:10 +0100
parents 2daf7b4c6756
children
comparison
equal deleted inserted replaced
2144:1d3f73e065e1 2145:33c8c4973743
17 17
18 # You should have received a copy of the GNU Affero General Public License 18 # You should have received a copy of the GNU Affero General Public License
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.log import getLogger 23 from sat.core.log import getLogger
23 log = getLogger(__name__) 24 log = getLogger(__name__)
24 25
25 26
26 PLUGIN_INFO = { 27 PLUGIN_INFO = {
27 "name": "Directory subscription plugin", 28 C.PI_NAME: "Directory subscription plugin",
28 "import_name": "DIRECTORY-SUBSCRIPTION", 29 C.PI_IMPORT_NAME: "DIRECTORY-SUBSCRIPTION",
29 "type": "TMP", 30 C.PI_TYPE: "TMP",
30 "protocols": [], 31 C.PI_PROTOCOLS: [],
31 "dependencies": ["XEP-0050", "XEP-0055"], 32 C.PI_DEPENDENCIES: ["XEP-0050", "XEP-0055"],
32 "recommendations": [], 33 C.PI_RECOMMENDATIONS: [],
33 "main": "DirectorySubscription", 34 C.PI_MAIN: "DirectorySubscription",
34 "handler": "no", 35 C.PI_HANDLER: "no",
35 "description": _("""Implementation of directory subscription""") 36 C.PI_DESCRIPTION: _("""Implementation of directory subscription""")
36 } 37 }
37 38
38 39
39 NS_COMMANDS = "http://jabber.org/protocol/commands" 40 NS_COMMANDS = "http://jabber.org/protocol/commands"
40 CMD_UPDATE_SUBSCRIBTION = "update" 41 CMD_UPDATE_SUBSCRIBTION = "update"
53 @param raw_data (dict): data received from the frontend 54 @param raw_data (dict): data received from the frontend
54 @param profile (unicode): %(doc_profile)s 55 @param profile (unicode): %(doc_profile)s
55 @return: a deferred dict{unicode: unicode} 56 @return: a deferred dict{unicode: unicode}
56 """ 57 """
57 d = self.host.plugins["XEP-0055"]._getHostServices(profile) 58 d = self.host.plugins["XEP-0055"]._getHostServices(profile)
58 59
59 def got_services(services): 60 def got_services(services):
60 service_jid = services[0] 61 service_jid = services[0]
61 session_id, session_data = self.host.plugins["XEP-0050"].requesting.newSession(profile=profile) 62 session_id, session_data = self.host.plugins["XEP-0050"].requesting.newSession(profile=profile)
62 session_data["jid"] = service_jid 63 session_data["jid"] = service_jid
63 session_data["node"] = CMD_UPDATE_SUBSCRIBTION 64 session_data["node"] = CMD_UPDATE_SUBSCRIBTION
64 data = {"session_id": session_id} 65 data = {"session_id": session_id}
65 return self.host.plugins["XEP-0050"]._requestingEntity(data, profile) 66 return self.host.plugins["XEP-0050"]._requestingEntity(data, profile)
66 67
67 return d.addCallback(got_services) 68 return d.addCallback(got_services)