Mercurial > libervia-backend
annotate src/plugins/plugin_tmp_demo_directory.py @ 1498:e3330ce65285
plugin XEP-0055: add "simple" and "advanced" modes to Jabber search:
- simple search queries the service offered by the user's server, asks for a single input and compile the results of the queries done on each search field
- advanced allows to select the search service and to perform a "normal" search (the user can fill in all the fields that are implemented by the service)
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 21 Aug 2015 19:02:11 +0200 |
parents | 069ad98b360d |
children |
rev | line source |
---|---|
869
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # SAT plugin for account creation (experimental) |
1396 | 5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Jérôme Poisson (goffi@goffi.org) |
869
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 from sat.core.i18n import _, D_ |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
869
diff
changeset
|
21 from sat.core.log import getLogger |
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
869
diff
changeset
|
22 log = getLogger(__name__) |
869
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 from twisted.internet import defer |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from twisted.words.protocols.jabber.xmlstream import IQ |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 from twisted.words.protocols.jabber import jid |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 from wokkel import data_form |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 PLUGIN_INFO = { |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 "name": "Demo directory plugin", |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 "import_name": "DEMO-DIRECTORY", |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 "type": "TMP", |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 "protocols": [], |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 "dependencies": [], |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 "main": "DemoDirectory", |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 "handler": "no", |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 "description": _(u"""Plugin to add paramaters to subscribe to the demo directory""") |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 } |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 NS_COMMANDS = "http://jabber.org/protocol/commands" |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 CONFIG_SECTION = "plugin demo directory" |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 CONFIG_ACTIVATE = "activate" |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 CONFIG_SERVICE = "service" |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 PARAM_CATEGORY = ("directory", D_("Directory")) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 PARAM_NAME_INFO = D_("To appear on the directory, check the box. To be removed from the directory, just uncheck it.") |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 PARAM_NAME_DESC = ("description", D_("Some words about you")) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 PARAM_NAME_SUB = ("subscribe", D_("I want to appear in the public demo directory")) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 class DemoDirectory(object): |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 """Account plugin: create a SàT + Prosody account, used by Libervia""" |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 # XXX: This plugin is a Q&D one used for the demo. |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 # TODO: A generic way to add menu/parameters for local services would be nice |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 params = """ |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 <params> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 <individual> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 <category name="%(category_name)s" label="%(category_label)s"> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 <param label="%(info)s" type="text" security="1" /> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 <param name="%(desc)s" label="%(desc_label)s" type="string" security="1" /> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 <param name="%(sub)s" label="%(sub_label)s" value='false' type="bool" security="1" /> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 </category> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 </individual> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 </params> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 """ % { |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 'category_name': PARAM_CATEGORY[0], |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 'category_label': _(PARAM_CATEGORY[1]), |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 'info': _(PARAM_NAME_INFO), |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 'desc': PARAM_NAME_DESC[0], |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 'desc_label': _(PARAM_NAME_DESC[1]), |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 'sub': PARAM_NAME_SUB[0], |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 'sub_label': _(PARAM_NAME_SUB[1]), |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 } |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 def __init__(self, host): |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
869
diff
changeset
|
78 log.info(_(u"Plugin demo directory initialization")) |
1234
9c17bd37e6e5
core: better management of default value in getConfig
Goffi <goffi@goffi.org>
parents:
993
diff
changeset
|
79 activate = host.memory.getConfig(CONFIG_SECTION, CONFIG_ACTIVATE, 'false') |
869
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 if not activate.lower() in ('true', 'yes', '1'): |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
869
diff
changeset
|
81 log.info("not activated") |
869
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 return |
1234
9c17bd37e6e5
core: better management of default value in getConfig
Goffi <goffi@goffi.org>
parents:
993
diff
changeset
|
83 service_str = host.memory.getConfig(CONFIG_SECTION, CONFIG_SERVICE, 'salut.libervia.org') |
869
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 self.service = jid.JID(service_str) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 self.host = host |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 host.memory.updateParams(self.params) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 host.trigger.add("paramUpdateTrigger", self.paramUpdateTrigger) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 @defer.inlineCallbacks |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 def manageSubscription(self, subscribe, profile): |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 """ Subscribe or unsubscribe according to subscribe value |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 This follow the implementation of the "Salut", this is not for general purpose |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 @param subscribe: True to subscribe, else unsubscribe |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 @param profile: %(doc_profile)s |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 """ |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 client = self.host.getClient(profile) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 if not subscribe: |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
869
diff
changeset
|
99 log.info ("Unsubscribing [%s] from directory" % profile) |
869
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 unsub_req = IQ(client.xmlstream, 'set') |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 unsub_req['from'] = client.jid.full() |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 unsub_req['to'] = self.service.userhost() |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 command_elt = unsub_req.addElement('command', NS_COMMANDS) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 command_elt['node'] = 'unsubscribe' |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 command_elt['action'] = 'execute' |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 yield unsub_req.send(self.service.userhost()) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 else: |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
869
diff
changeset
|
108 log.info ("Subscribing [%s] to directory" % profile) |
869
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 sub_req = IQ(client.xmlstream, 'set') |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 sub_req['from'] = client.jid.full() |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 sub_req['to'] = self.service.userhost() |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 command_elt = sub_req.addElement('command', NS_COMMANDS) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 command_elt['node'] = 'subscribe' |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 command_elt['action'] = 'execute' |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 sub_first_elt = yield sub_req.send(self.service.userhost()) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 sub_cmd = sub_first_elt.elements(NS_COMMANDS, 'command').next() |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 session_id = sub_cmd['sessionid'] |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 sub_req = IQ(client.xmlstream, 'set') |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 sub_req['from'] = client.jid.full() |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 sub_req['to'] = self.service.userhost() |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 command_elt = sub_req.addElement('command', NS_COMMANDS) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 command_elt['node'] = 'subscribe' |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 command_elt['action'] = 'execute' |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 command_elt['sessionid'] = session_id |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 description = self.host.memory.getParamA(PARAM_NAME_DESC[0], PARAM_CATEGORY[0], profile_key=client.profile) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 ret_form = data_form.Form('submit') |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 ret_form.makeFields({'jid': client.jid.userhost(), 'description': description}) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 command_elt.addChild(ret_form.toElement()) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 yield sub_req.send(self.service.userhost()) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 def paramUpdateTrigger(self, name, value, category, type_, profile): |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 """ |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 Reset all the existing chat state entity data associated with this profile after a parameter modification. |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 @param name: parameter name |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 @param value: "true" to activate the notifications, or any other value to delete it |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 @param category: parameter category |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 """ |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 if (category, name) == (PARAM_CATEGORY[0], PARAM_NAME_SUB[0]): |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 self.manageSubscription(value.lower()=='true', profile) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 return False |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 return True |