Merge with 0.6 on prosody.im

vault/0.11 0.6.0
Matthew Wild 17 years ago
commit ff6b4c2c6d
  1. 6
      core/loggingmanager.lua
  2. 34
      core/sessionmanager.lua
  3. 2
      net/xmppclient_listener.lua
  4. 4
      plugins/mod_presence.lua
  5. 30
      prosody
  6. 31
      util/serialization.lua

@ -17,6 +17,12 @@ local math_max, rep = math.max, string.rep;
local os_date, os_getenv = os.date, os.getenv;
local getstyle, getstring = require "util.termcolours".getstyle, require "util.termcolours".getstring;
if os.getenv("__FLUSH_LOG") then
local io_flush = io.flush;
local _io_write = io_write;
io_write = function(...) _io_write(...); io_flush(); end
end
local config = require "core.configmanager";
local eventmanager = require "core.eventmanager";
local logger = require "util.logger";

@ -201,22 +201,32 @@ function streamclosed(session)
end
function send_to_available_resources(user, host, stanza)
local jid = user.."@"..host;
local count = 0;
local to = stanza.attr.to;
stanza.attr.to = nil;
local h = hosts[host];
if h and h.type == "local" then
local u = h.sessions[user];
if u then
for k, session in pairs(u.sessions) do
if session.presence then
session.send(stanza);
count = count + 1;
end
local user = bare_sessions[jid];
if user then
for k, session in pairs(user.sessions) do
if session.presence then
session.send(stanza);
count = count + 1;
end
end
end
return count;
end
function send_to_interested_resources(user, host, stanza)
local jid = user.."@"..host;
local count = 0;
local user = bare_sessions[jid];
if user then
for k, session in pairs(user.sessions) do
if session.interested then
session.send(stanza);
count = count + 1;
end
end
end
stanza.attr.to = to;
return count;
end

@ -61,7 +61,7 @@ local function session_reset_stream(session)
function session.data(conn, data)
local ok, err = parser:parse(data);
if ok then return; end
log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "));
log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_"));
session:close("xml-not-well-formed");
end

@ -233,6 +233,7 @@ function handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_b
-- TODO send last recieved unavailable presence (or we MAY do nothing, which is fine too)
end
else
core_route_stanza(origin, st.presence({from=to_bare, to=from_bare, type="unavailable"})); -- acknowledging receipt
if not rostermanager.is_contact_pending_in(node, host, from_bare) then
if rostermanager.set_contact_pending_in(node, host, from_bare) then
sessionmanager.send_to_available_resources(node, host, stanza);
@ -241,14 +242,17 @@ function handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_b
end
elseif stanza.attr.type == "unsubscribe" then
if rostermanager.process_inbound_unsubscribe(node, host, from_bare) then
sessionmanager.send_to_interested_resources(node, host, stanza);
rostermanager.roster_push(node, host, from_bare);
end
elseif stanza.attr.type == "subscribed" then
if rostermanager.process_inbound_subscription_approval(node, host, from_bare) then
sessionmanager.send_to_interested_resources(node, host, stanza);
rostermanager.roster_push(node, host, from_bare);
end
elseif stanza.attr.type == "unsubscribed" then
if rostermanager.process_inbound_subscription_cancellation(node, host, from_bare) then
sessionmanager.send_to_interested_resources(node, host, stanza);
rostermanager.roster_push(node, host, from_bare);
end
end -- discard any other type

@ -14,7 +14,7 @@ CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR");
CFG_PLUGINDIR=os.getenv("PROSODY_PLUGINDIR");
CFG_DATADIR=os.getenv("PROSODY_DATADIR");
-- -- -- -- -- -- -- ---- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
if CFG_SOURCEDIR then
package.path = CFG_SOURCEDIR.."/?.lua;"..package.path;
@ -58,7 +58,27 @@ config = require "core.configmanager"
function read_config()
-- TODO: Check for other formats when we add support for them
-- Use lfs? Make a new conf/ dir?
local ok, level, err = config.load((CFG_CONFIGDIR or ".").."/prosody.cfg.lua");
local filenames = {};
local filename;
if arg[1] == "--config" and arg[2] then
table.insert(filenames, arg[2]);
if CFG_CONFIGDIR then
table.insert(filenames, CFG_CONFIGDIR.."/"..arg[2]);
end
else
table.insert(filenames, (CFG_CONFIGDIR or ".").."/prosody.cfg.lua");
end
for _,_filename in ipairs(filenames) do
filename = _filename;
local file = io.open(filename);
if file then
file:close();
CFG_CONFIGDIR = filename:match("^(.*)[\\/][^\\/]*$");
break;
end
end
local ok, level, err = config.load(filename);
if not ok then
print("\n");
print("**************************");
@ -82,13 +102,13 @@ function read_config()
end
function load_libraries()
--- Initialize logging
-- Initialize logging
require "core.loggingmanager"
--- Check runtime dependencies
-- Check runtime dependencies
require "util.dependencies"
--- Load socket framework
-- Load socket framework
server = require "net.server"
end

@ -13,6 +13,7 @@ local t_insert = table.insert;
local t_concat = table.concat;
local error = error;
local pairs = pairs;
local next = next;
local debug_traceback = debug.traceback;
local log = require "util.logger".init("serialization");
@ -34,21 +35,25 @@ local function _simplesave(o, ind, t, func)
elseif type(o) == "string" then
func(t, (("%q"):format(o):gsub("\\\n", "\\n")));
elseif type(o) == "table" then
func(t, "{\n");
for k,v in pairs(o) do
func(t, indent(ind));
func(t, "[");
func(t, basicSerialize(k));
func(t, "] = ");
if ind == 0 then
_simplesave(v, 0, t, func);
else
_simplesave(v, ind+1, t, func);
if next(o) then
func(t, "{\n");
for k,v in pairs(o) do
func(t, indent(ind));
func(t, "[");
func(t, basicSerialize(k));
func(t, "] = ");
if ind == 0 then
_simplesave(v, 0, t, func);
else
_simplesave(v, ind+1, t, func);
end
func(t, ";\n");
end
func(t, ",\n");
func(t, indent(ind-1));
func(t, "}");
else
func(t, "{}");
end
func(t, indent(ind-1));
func(t, "}");
elseif type(o) == "boolean" then
func(t, (o and "true" or "false"));
else

Loading…
Cancel
Save