Software /
code /
prosody
Comparison
core/modulemanager.lua @ 191:e64c8a44060f
Fix s2s once and for all
- Moved dialback to the new mod_dialback (mostly).
- Modules can now supply a list of origins to handle to add_handler
- Modules can now handle and process any stanza, overriding the core
- Modules handle non-jabber:client/jabber:server xmlns'd stanzas
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 01 Nov 2008 21:07:14 +0000 |
parent | 188:0d9f03009b8a |
child | 196:ebe23269b377 |
comparison
equal
deleted
inserted
replaced
190:1e993b7deae7 | 191:e64c8a44060f |
---|---|
29 else | 29 else |
30 log("warning", "mod_%s wants to handle tag 'iq' with query namespace '%s' but mod_%s already handles that", getfenv(2).module.name, xmlns, handler_info[handlers[origin_type].iq[xmlns]].module.name); | 30 log("warning", "mod_%s wants to handle tag 'iq' with query namespace '%s' but mod_%s already handles that", getfenv(2).module.name, xmlns, handler_info[handlers[origin_type].iq[xmlns]].module.name); |
31 end | 31 end |
32 end | 32 end |
33 | 33 |
34 function modulehelpers.add_handler(origin_type, tag, xmlns, handler) | 34 local function _add_handler(module, origin_type, tag, xmlns, handler) |
35 if not (origin_type and tag and xmlns and handler) then return false; end | |
36 handlers[origin_type] = handlers[origin_type] or {}; | 35 handlers[origin_type] = handlers[origin_type] or {}; |
37 if not handlers[origin_type][tag] then | 36 if not handlers[origin_type][tag] then |
38 handlers[origin_type][tag] = handlers[origin_type][tag] or {}; | 37 handlers[origin_type][tag] = handlers[origin_type][tag] or {}; |
39 handlers[origin_type][tag][xmlns]= handler; | 38 handlers[origin_type][tag][xmlns]= handler; |
40 handler_info[handler] = getfenv(2).module; | 39 handler_info[handler] = module; |
41 log("debug", "mod_%s now handles tag '%s'", getfenv(2).module.name, tag); | 40 log("debug", "mod_%s now handles tag '%s'", module.name, tag); |
42 elseif handler_info[handlers[origin_type][tag]] then | 41 elseif handler_info[handlers[origin_type][tag]] then |
43 log("warning", "mod_%s wants to handle tag '%s' but mod_%s already handles that", getfenv(2).module.name, tag, handler_info[handlers[origin_type][tag]].module.name); | 42 log("warning", "mod_%s wants to handle tag '%s' but mod_%s already handles that", module.name, tag, handler_info[handlers[origin_type][tag]].module.name); |
44 end | 43 end |
44 end | |
45 | |
46 function modulehelpers.add_handler(origin_type, tag, xmlns, handler) | |
47 if not (origin_type and tag and xmlns and handler) then return false; end | |
48 if type(origin_type) == "table" then | |
49 for _, origin_type in ipairs(origin_type) do | |
50 _add_handler(getfenv(2).module, origin_type, tag, xmlns, handler); | |
51 end | |
52 return; | |
53 end | |
54 _add_handler(getfenv(2).module, origin_type, tag, xmlns, handler); | |
45 end | 55 end |
46 | 56 |
47 function loadall() | 57 function loadall() |
48 load("saslauth"); | 58 load("saslauth"); |
49 load("legacyauth"); | 59 load("legacyauth"); |
51 load("register"); | 61 load("register"); |
52 load("tls"); | 62 load("tls"); |
53 load("vcard"); | 63 load("vcard"); |
54 load("private"); | 64 load("private"); |
55 load("version"); | 65 load("version"); |
66 load("dialback"); | |
56 end | 67 end |
57 | 68 |
58 function load(name) | 69 function load(name) |
59 local mod, err = loadfile("plugins/mod_"..name..".lua"); | 70 local mod, err = loadfile("plugins/mod_"..name..".lua"); |
60 if not mod then | 71 if not mod then |