changeset 13:447db2e8c622

Better access mode handling.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 08 Sep 2010 12:04:14 +0200
parents 9a6b8b3357c6
children 06abc804e2ab
files configuration.js
diffstat 1 files changed, 25 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/configuration.js
+++ b/configuration.js
@@ -26,12 +26,9 @@ config.version = '0.1';
 config.os = 'GNU/Linux';
 config.allowCreateNode = [/@example\.com$/]; // value is an array of RegExp JIDs. If only super-owner should be able to create nodes, use [].
 
+config.access = 'open'; // values include open, whitelist (by members) and authorize (owners of the node receive notification). presence and roster aren’t implemented yet.
+
 config.activated = [
-	//'access-authorize',
-	//'access-open',
-	//'access-presence', // Impossible à utiliser dans un component
-	//'access-roster', // Impossible à utiliser dans un component
-	'access-whitelist',
 	'auto-create',
 	//'auto-subscribe', // Impossible à utiliser dans un component
 	//'collections', //TODO
@@ -216,13 +213,33 @@ config.enabled = function(feature) {
 	return false;
 };
 
-if (config.enabled('access-whitelist')) {
+config.enable = function(feature) {
+	config.activated.push(feature);
+}
+
+config.disable = function(feature) {
+	if (typeof feature == 'string')
+		config.activated.splice(config.activated.indexOf(feature), 1);
+	else if (typeof feature == 'function') {
+		for (var i in config.activated)
+			if (feature(config.activated[i]))
+				config.disable(config.activated[i]);
+	}
+}
+
+if (config.access == 'whitelist') {
+	config.disable(/access-.+/);
+	config.enable('access-whitelist');
 	config.service_configuration.node_config['pubsub#access_model'].value = 'whitelist';
 	config.service_configuration['publish-options']['pubsub#access_model'].value = 'whitelist';
-} else if (config.enabled('access-authorize')) {
+} else if (config.access == 'authorize')) {
+	config.disable(/access-.+/);
+	config.enable('access-authorize');
 	config.service_configuration.node_config['pubsub#access_model'].value = 'authorize';
 	config.service_configuration['publish-options']['pubsub#access_model'].value = 'authorize';
-} else if (config.enabled('access-open')) {
+} else if (config.access == 'open')) {
+	config.disable(/access-.+/);
+	config.enable('access-open');
 	config.service_configuration.node_config['pubsub#access_model'].value = 'open';
 	config.service_configuration['publish-options']['pubsub#access_model'].value = 'open';
 }