Comparison

core/configmanager.lua @ 3384:b7600dd7cd42

configmanager: Remove dependency on eventmanager, and global 'prosody' object
author Matthew Wild <mwild1@gmail.com>
date Sat, 17 Jul 2010 14:50:16 +0100
parent 3012:6d86e26f0923
child 3515:bb494c3aa364
comparison
equal deleted inserted replaced
3383:c7acddf80583 3384:b7600dd7cd42
11 local _G = _G; 11 local _G = _G;
12 local setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table, format = 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, string.format; 13 setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table, string.format;
14 14
15 15
16 local eventmanager = require "core.eventmanager"; 16 local fire_event = prosody and prosody.events.fire_event or function () end;
17 17
18 module "configmanager" 18 module "configmanager"
19 19
20 local parsers = {}; 20 local parsers = {};
21 21
71 local f, err = io.open(filename); 71 local f, err = io.open(filename);
72 if f then 72 if f then
73 local ok, err = parsers[format].load(f:read("*a"), filename); 73 local ok, err = parsers[format].load(f:read("*a"), filename);
74 f:close(); 74 f:close();
75 if ok then 75 if ok then
76 eventmanager.fire_event("config-reloaded", { filename = filename, format = format }); 76 fire_event("config-reloaded", { filename = filename, format = format });
77 end 77 end
78 return ok, "parser", err; 78 return ok, "parser", err;
79 end 79 end
80 return f, "file", err; 80 return f, "file", err;
81 end 81 end