Mercurial > psgxs
comparison configuration.js @ 0:9ee956af41e3
Initial commit
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 27 Jun 2010 22:05:12 +0200 |
parents | |
children | c2954a9e5665 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:9ee956af41e3 |
---|---|
1 /* | |
2 * Copyright (C) 2010 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | |
3 * | |
4 * This file is part of PSĜS, a PubSub server written in JavaScript. | |
5 * | |
6 * PSĜS is free software: you can redistribute it and/or modify | |
7 * it under the terms of the GNU Affero General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License. | |
10 * | |
11 * PSĜS is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU Affero General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Affero General Public License | |
17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>. | |
18 */ | |
19 | |
20 var config = exports; | |
21 | |
22 config.jid = 'pubsub.example.org'; | |
23 config.password = 'pubsub.example.org'; | |
24 | |
25 config.activated = [ | |
26 //'access-authorize', | |
27 //'access-open', | |
28 //'access-presence', // Impossible à utiliser dans un component | |
29 //'access-roster', // Impossible à utiliser dans un component | |
30 'access-whitelist', | |
31 'auto-create', | |
32 //'auto-subscribe', // Impossible à utiliser dans un component | |
33 //'collections', //TODO | |
34 'config-node', | |
35 'create-and-configure', | |
36 'create-nodes', | |
37 'delete-items', | |
38 'delete-nodes', | |
39 //'filtered-notifications', // Impossible à utiliser dans un component | |
40 'get-pending', | |
41 'instant-nodes', | |
42 'item-ids', | |
43 'last-published', // Impossible de se baser sur la présence dans un component | |
44 //'leased-subscription', //TODO | |
45 'manage-subscriptions', | |
46 'member-affiliation', | |
47 'meta-data', | |
48 'modify-affiliations', | |
49 //'multi-collection', //TODO | |
50 //'multi-subscribe', //TODO | |
51 'outcast-affiliation', | |
52 'persistent-items', | |
53 //'presence-notifications', // Impossible à utiliser dans un component | |
54 //'presence-subscribe', // Impossible à utiliser dans un component | |
55 'publish', | |
56 'publish-options', | |
57 'publish-only-affiliation', | |
58 'publisher-affiliation', | |
59 'purge-nodes', | |
60 'retract-items', | |
61 'retrieve-affiliations', | |
62 'retrieve-default', | |
63 'retrieve-default-sub', | |
64 'retrieve-items', | |
65 'retrieve-subscriptions', | |
66 'subscribe', | |
67 'subscription-options', | |
68 'subscription-notifications', | |
69 ]; | |
70 | |
71 config.service_configuration = { | |
72 subscribe_authorization: { | |
73 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#subscribe_authorization'}, | |
74 _TITLE: 'PubSub subscriber request', | |
75 _INSTRUCTIONS: 'To approve this entity’s subscription request,\nclick the OK button. To deny the request, click the\ncancel button.', | |
76 'pubsub#allow': {type: 'boolean', label: 'Whether to allow the subscription', value: false}, | |
77 'pubsub#node': {type: 'text-single', label: 'The NodeID of the relevant node'}, | |
78 'pubsub#subid': {type: 'hidden'}, | |
79 'pubsub#subscriber_jid': {type: 'jid-single', label: 'The address (JID) of the subscriber'}, | |
80 }, | |
81 subscribe_options: { | |
82 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#subscribe_options'}, | |
83 'pubsub#deliver': {type: 'boolean', label: 'Whether an entity wants to receive or disable notifications', value: true}, | |
84 'pubsub#digest': {type: 'boolean', label: 'Whether an entity wants to receive digests (aggregations) of notifications or all notifications individually', value: false}, | |
85 'pubsub#digest_frequency': {type: 'text-single', label: 'The minimum number of milliseconds between sending any two notification digests', value: 60*1000}, | |
86 // 'pubsub#expire': {type: 'text-single', label: 'The DateTime at which a leased subscription will end or has ended'}, | |
87 // 'pubsub#include_body': {type: 'boolean', label: 'Whether an entity wants to receive an XMPP message body in addition to the payload format', value: false}, | |
88 // 'pubsub#show-values': {type: 'list-multi', label: 'The presence states for which an entity wants to receive notifications', options: { | |
89 // away: {label: 'XMPP Show Value of Away'}, | |
90 // chat: {label: 'XMPP Show Value of Chat'}, | |
91 // dnd: {label: 'XMPP Show Value of DND (Do Not Disturb)'}, | |
92 // online: {label: 'Mere Availability in XMPP (No Show Value)'}, | |
93 // xa: {label: 'XMPP Show Value of XA (Extended Away)'}, | |
94 // }, value: ['online', 'chat', 'away']}, | |
95 // 'pubsub#subscription_type': {type: 'list-single', options: { | |
96 // items: {label: 'Receive notification of new items only'}, | |
97 // nodes: {label: 'Receive notification of new nodes only'}, | |
98 // }}, | |
99 // 'pubsub#subscription_depth': {type: 'list-single', options: { | |
100 // '1': {label: 'Receive notification from direct child nodes only'}, | |
101 // all: {label: 'Receive notification from all descendent nodes'}, | |
102 // }}, | |
103 }, | |
104 node_metadata: { | |
105 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#meta-data'}, | |
106 'pubsub#contact': {type: 'jid-multi', label: 'The JIDs of those to contact with questions'}, | |
107 'pubsub#creation_date': {type: 'text-single', label: 'The datetime when the node was created', value: function(){return new Date();}}, | |
108 'pubsub#creator': {type: 'jid-single', label: 'The JID of the node creator'}, | |
109 'pubsub#description': {type: 'text-single', label: 'A description of the node'}, | |
110 'pubsub#language': {type: 'list-single', label: 'The default language of the node'}, | |
111 'pubsub#num_subscribers': {type: 'text-single', label: 'The number of subscribers to the node', value: 0}, | |
112 'pubsub#owner': {type: 'jid-multi', label: 'The JIDs of those with an affiliation of owner'}, | |
113 'pubsub#publisher': {type: 'jid-multi', label: 'The JIDs of those with an affiliation of publisher'}, | |
114 'pubsub#title': {type: 'text-single', label: 'The name of the node'}, | |
115 'pubsub#type': {type: 'text-single', label: 'Payload type'}, | |
116 }, | |
117 node_config: { | |
118 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#node_config'}, | |
119 'pubsub#access_model': {type: 'list-single', label: 'Who may subscribe and retrieve items', options: { | |
120 authorize: {label: 'Subscription requests must be approved and only subscribers may retrieve items'}, | |
121 open: {label: 'Anyone may subscribe and retrieve items'}, | |
122 // presence: {label: 'Anyone with a presence subscription of both or from may subscribe and retrieve items'}, | |
123 // roster: {label: 'Anyone in the specified roster group(s) may subscribe and retrieve items'}, | |
124 whitelist: {label: 'Only those on a whitelist may subscribe and retrieve items'}, | |
125 }}, | |
126 // 'pubsub#body_xslt': {type: 'text-single', label: 'The URL of an XSL transformation which can be applied to payloads in order to generate an appropriate message body element.'}, | |
127 // 'pubsub#children_association_policy': {type: 'list-single', label: 'Who may associate leaf nodes with a collection', options: { | |
128 // all: {label: 'Anyone may associate leaf nodes with the collection'}, | |
129 // owners: {label: 'Only collection node owners may associate leaf nodes with the collection'}, | |
130 // whitelist: {label: 'Only those on a whitelist may associate leaf nodes with the collection'}, | |
131 // }}, | |
132 // 'pubsub#children_association_whitelist': {type: 'jid-multi', label: 'The list of JIDs that may associate leaf nodes with a collection'}, | |
133 // 'pubsub#children': {type: 'text-multi', label: 'The child nodes (leaf or collection) associated with a collection'}, | |
134 // 'pubsub#children_max': {type: 'text-single', label: 'The maximum number of child nodes that can be associated with a collection'}, | |
135 // 'pubsub#collection': {type: 'text-multi', label: 'The collection(s) with which a node is affiliated'}, | |
136 'pubsub#contact': {type: 'jid-multi', label: 'The JIDs of those to contact with questions'}, | |
137 // 'pubsub#dataform_xslt': {type: 'text-single', label: 'The URL of an XSL transformation which can be applied to the payload format in order to generate a valid Data Forms result that the client could display using a generic Data Forms rendering engine'}, | |
138 'pubsub#deliver_notifications': {type: 'boolean', label: 'Whether to deliver event notifications', value: true}, | |
139 // 'pubsub#deliver_payloads': {type: 'boolean', label: 'Whether to deliver payloads with event notifications; applies only to leaf nodes'}, | |
140 'pubsub#description': {type: 'text-single', label: 'A description of the node'}, | |
141 // 'pubsub#item_expire': {type: 'text-single', label: 'Number of seconds after which to automatically purge items'}, | |
142 // 'pubsub#itemreply': {type: 'list-single', label: 'Whether owners or publisher should receive replies to items', options: { | |
143 // owner: {label: 'Statically specify a replyto of the node owner(s)'}, | |
144 // publisher: {label: 'Dynamically specify a replyto of the item publisher'}, | |
145 // }}, | |
146 'pubsub#language': {type: 'list-single', label: 'The default language of the node'}, | |
147 // 'pubsub#max_items': {type: 'text-single', label: 'The maximum number of items to persist'}, | |
148 // 'pubsub#max_payload_size': {type: 'text-single', label: 'The maximum payload size in bytes'}, | |
149 'pubsub#node_type': {type: 'list-single', label: 'Whether the node is a leaf (default) or a collection', options: { | |
150 leaf: {label: 'The node is a leaf node (default)'}, | |
151 collection: {label: 'The node is a collection node'}, | |
152 }, value: 'leaf'}, | |
153 // 'pubsub#notification_type': {type: 'list-single', label: 'Specify the delivery style for notifications', options: { | |
154 // normal: {label: 'Messages of type normal'}, | |
155 // headline: {label: 'Messages of type headline'}, | |
156 // iq: {label: 'IQ stanzas (works only with presence-based delivery)'}, | |
157 // }}, | |
158 // 'pubsub#notify_config': {type: 'boolean', label: 'Whether to notify subscribers when the node configuration changes'}, | |
159 // 'pubsub#notify_delete': {type: 'boolean', label: 'Whether to notify subscribers when the node is deleted'}, | |
160 // 'pubsub#notify_retract': {type: 'boolean', label: 'Whether to notify subscribers when items are removed from the node'}, | |
161 // 'pubsub#notify_sub': {type: 'boolean', label: 'Whether to notify owners about new subscribers and unsubscribes'}, | |
162 // 'pubsub#persist_items': {type: 'boolean', label: 'Whether to persist items to storage'}, | |
163 // 'pubsub#presence_based_delivery': {type: 'boolean', label: 'Whether to deliver notifications to available users only'}, | |
164 'pubsub#publish_model': {type: 'list-single', label: 'The publisher model', options: { | |
165 publishers: {label: 'Only publishers may publish'}, | |
166 subscribers: {label: 'Subscribers may publish'}, | |
167 open: {label: 'Anyone may publish'}, | |
168 }, value: 'publishers'}, | |
169 // 'pubsub#purge_offline': {type: 'boolean', label: 'Whether to purge all items when the relevant publisher goes offline'}, | |
170 // 'pubsub#roster_groups_allowed': {type: 'list-multi', label: 'The roster group(s) allowed to subscribe and retrieve items'}, | |
171 // 'pubsub#send_last_published_item': {type: 'list-single', label: 'When to send the last published item', options: { | |
172 // never: {label: 'Never'}, | |
173 // on_sub: {label: 'When a new subscription is processed'}, | |
174 // on_sub_and_presence: {label: 'When a new subscription is processed and whenever a subscriber comes online'}, | |
175 // }, value: 'never'}, | |
176 // 'pubsub#tempsub': {type: 'boolean', label: 'Whether to make all subscriptions temporary, based on subscriber presence'}, | |
177 'pubsub#subscribe': {type: 'boolean', label: 'Whether to allow subscriptions', value: true}, | |
178 'pubsub#title': {type: 'text-single', label: 'A friendly name for the node'}, | |
179 'pubsub#type': {type: 'text-single', label: 'The type of node data, usually specified by the namespace of the payload (if any)', value: 'http://www.w3.org/2005/Atom'}, | |
180 }, | |
181 'publish-options': { | |
182 FORM_TYPE: {type: 'hidden', value: 'http://jabber.org/protocol/pubsub#publish-options'}, | |
183 'pubsub#access_model': {type: 'list-single', label: 'Precondition: node configuration with the specified access model', options: { | |
184 authorize: {label: 'Access model of authorize'}, | |
185 open: {label: 'Access model of open'}, | |
186 // presence: {label: 'Access model of presence'}, | |
187 // roster: {label: 'Access model of roster'}, | |
188 whitelist: {label: 'Access model of whitelist'}, | |
189 }, value: 'open'}, | |
190 }, | |
191 }; | |
192 | |
193 config.Configuration = function(def, params) { | |
194 for (var i in def) { | |
195 if (typeof (def[i].value) != 'undefined') { | |
196 if (typeof (def[i].value) == 'function') | |
197 this[i] = def[i].value(); | |
198 else | |
199 this[i] = def[i].value; | |
200 } | |
201 } | |
202 if (params) | |
203 for (var i in params) | |
204 this[i] = params[i]; | |
205 }; | |
206 | |
207 config.enabled = function(feature) { | |
208 for (var i in config.activated) | |
209 if (typeof i == 'string' && feature == config.activated[i]) | |
210 return true; | |
211 return false; | |
212 }; | |
213 | |
214 if (config.enabled('access-whitelist')) { | |
215 config.service_configuration.node_config['pubsub#access_model'].value = 'whitelist'; | |
216 config.service_configuration['publish-options']['pubsub#access_model'].value = 'whitelist'; | |
217 } else if (config.enabled('access-authorize')) { | |
218 config.service_configuration.node_config['pubsub#access_model'].value = 'authorize'; | |
219 config.service_configuration['publish-options']['pubsub#access_model'].value = 'authorize'; | |
220 } else if (config.enabled('access-open')) { | |
221 config.service_configuration.node_config['pubsub#access_model'].value = 'open'; | |
222 config.service_configuration['publish-options']['pubsub#access_model'].value = 'open'; | |
223 } |