Mercurial > libervia-backend
annotate src/plugins/plugin_tmp_demo_directory.py @ 975:b37b1d183ac3
reverted changeset 5c7707c958d8 (revision 969)
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 03 Apr 2014 14:38:48 +0200 |
parents | 0d1a17375bf5 |
children | 301b342c697a |
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) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) |
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_ |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 from logging import debug, info, warning, error |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 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
|
23 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
|
24 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
|
25 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
|
26 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 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
|
28 "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
|
29 "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
|
30 "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
|
31 "protocols": [], |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 "dependencies": [], |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 "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
|
34 "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
|
35 "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
|
36 } |
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 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
|
39 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 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
|
41 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
|
42 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
|
43 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 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
|
45 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
|
46 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
|
47 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
|
48 |
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 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
|
52 """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
|
53 # 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
|
54 # 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
|
55 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 params = """ |
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 <individual> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 <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
|
60 <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
|
61 <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
|
62 <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
|
63 </category> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 </individual> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 </params> |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 """ % { |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 '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
|
68 '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
|
69 '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
|
70 '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
|
71 '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
|
72 '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
|
73 '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
|
74 } |
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 def __init__(self, host): |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 info(_(u"Plugin demo directory initialization")) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 activate = host.memory.getConfig(CONFIG_SECTION, CONFIG_ACTIVATE) or 'false' |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 if not activate.lower() in ('true', 'yes', '1'): |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 info("not activated") |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 return |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 service_str = host.memory.getConfig(CONFIG_SECTION, CONFIG_SERVICE) or 'salut.libervia.org' |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 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
|
84 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
|
85 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
|
86 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
|
87 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 @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
|
89 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
|
90 """ 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
|
91 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
|
92 @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
|
93 @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
|
94 |
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 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
|
97 if not subscribe: |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 info ("Unsubscribing [%s] from directory" % profile) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 else: |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 info ("Subscribing [%s] to directory" % profile) |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 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
|
131 """ |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 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
|
133 @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
|
134 @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
|
135 @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
|
136 """ |
0d1a17375bf5
plugin demo directory: temporary plugin to integrate Salut's directory in SàT's parameters:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 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
|
138 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
|
139 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
|
140 return True |