core/configmanager.lua

changeset 2637
82cfc1ec4a7c
parent 2552
8dda55217e83
child 2640
2dace3e87dd1
equal deleted inserted replaced
2636:d2805ad5b736 2637:82cfc1ec4a7c
7 -- 7 --
8 8
9 9
10 10
11 local _G = _G; 11 local _G = _G;
12 local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table = 12 local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table, format =
13 setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table; 13 setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table, string.format;
14
15
16 local trb = debug.traceback
14 17
15 local eventmanager = require "core.eventmanager"; 18 local eventmanager = require "core.eventmanager";
16 19
17 module "configmanager" 20 module "configmanager"
18 21
122 set(env.__currenthost or "*", "core", k, v); 125 set(env.__currenthost or "*", "core", k, v);
123 end}); 126 end});
124 127
125 rawset(env, "__currenthost", "*") -- Default is global 128 rawset(env, "__currenthost", "*") -- Default is global
126 function env.Host(name) 129 function env.Host(name)
130 if rawget(config, name) and rawget(config[name].core, "component_module") then
131 error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s",
132 name, config[name].core.component_module:gsub("^%a+$", { component = "external", muc = "MUC"}), name, name), 0);
133 end
127 rawset(env, "__currenthost", name); 134 rawset(env, "__currenthost", name);
128 -- Needs at least one setting to logically exist :) 135 -- Needs at least one setting to logically exist :)
129 set(name or "*", "core", "defined", true); 136 set(name or "*", "core", "defined", true);
130 end 137 end
131 env.host = env.Host; 138 env.host = env.Host;
132 139
133 function env.Component(name) 140 function env.Component(name)
141 if rawget(config, name) and rawget(config[name].core, "defined") and not rawget(config[name].core, "component_module") then
142 error(format("Component %q clashes with previously defined Host %q, for services use a sub-domain like conference.%s",
143 name, name, name), 0);
144 end
134 set(name, "core", "component_module", "component"); 145 set(name, "core", "component_module", "component");
135 -- Don't load the global modules by default 146 -- Don't load the global modules by default
136 set(name, "core", "load_global_modules", false); 147 set(name, "core", "load_global_modules", false);
137 rawset(env, "__currenthost", name); 148 rawset(env, "__currenthost", name);
138 149

mercurial