Changeset

4940:39781d4d3173

Merge 0.9->trunk
author Matthew Wild <mwild1@gmail.com>
date Thu, 05 Jul 2012 17:40:12 +0100
parents 4932:212e81ac6ebb (diff) 4939:0545a574667b (current diff)
children 4942:716db7d94481
files
diffstat 5 files changed, 71 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/core/certmanager.lua	Wed Jul 04 23:44:13 2012 +0100
+++ b/core/certmanager.lua	Thu Jul 05 17:40:12 2012 +0100
@@ -78,7 +78,7 @@
 			else
 				reason = "Reason: "..tostring(reason):lower();
 			end
-			log("error", "SSL/TLS: Failed to load %s: %s (for %s)", file, reason, host);
+			log("error", "SSL/TLS: Failed to load '%s': %s (for %s)", file, reason, host);
 		else
 			log("error", "SSL/TLS: Error initialising for %s: %s", host, err);
 		end
--- a/core/s2smanager.lua	Wed Jul 04 23:44:13 2012 +0100
+++ b/core/s2smanager.lua	Thu Jul 05 17:40:12 2012 +0100
@@ -133,7 +133,7 @@
 function retire_session(session, reason)
 	local log = session.log or log;
 	for k in pairs(session) do
-		if k ~= "trace" and k ~= "log" and k ~= "id" then
+		if k ~= "trace" and k ~= "log" and k ~= "id" and k ~= "conn" then
 			session[k] = nil;
 		end
 	end
--- a/plugins/mod_admin_adhoc.lua	Wed Jul 04 23:44:13 2012 +0100
+++ b/plugins/mod_admin_adhoc.lua	Thu Jul 05 17:40:12 2012 +0100
@@ -27,6 +27,14 @@
 module:depends("adhoc");
 local adhoc_new = module:require "adhoc".new;
 
+local function generate_error_message(errors)
+	local errmsg = {};
+	for name, err in pairs(errors) do
+		errmsg[#errmsg + 1] = name .. ": " .. err;
+	end
+	return { status = "completed", error = { message = t_concat(errmsg, "\n") } };
+end
+
 function add_user_command_handler(self, data, state)
 	local add_user_layout = dataforms_new{
 		title = "Adding a User";
@@ -42,9 +50,9 @@
 		if data.action == "cancel" then
 			return { status = "canceled" };
 		end
-		local fields = add_user_layout:data(data.form);
-		if not fields.accountjid then
-			return { status = "completed", error = { message = "You need to specify a JID." } };
+		local fields, err = add_user_layout:data(data.form);
+		if err then
+			return generate_error_message(err);
 		end
 		local username, host, resource = jid.split(fields.accountjid);
 		if data.to ~= host then
@@ -85,9 +93,9 @@
 		if data.action == "cancel" then
 			return { status = "canceled" };
 		end
-		local fields = change_user_password_layout:data(data.form);
-		if not fields.accountjid or fields.accountjid == "" or not fields.password then
-			return { status = "completed", error = { message = "Please specify username and password" } };
+		local fields, err = change_user_password_layout:data(data.form);
+		if err then
+			return generate_error_message(err);
 		end
 		local username, host, resource = jid.split(fields.accountjid);
 		if data.to ~= host then
@@ -126,7 +134,10 @@
 		if data.action == "cancel" then
 			return { status = "canceled" };
 		end
-		local fields = delete_user_layout:data(data.form);
+		local fields, err = delete_user_layout:data(data.form);
+		if err then
+			return generate_error_message(err);
+		end
 		local failed = {};
 		local succeeded = {};
 		for _, aJID in ipairs(fields.accountjids) do
@@ -175,7 +186,10 @@
 			return { status = "canceled" };
 		end
 
-		local fields = end_user_session_layout:data(data.form);
+		local fields, err = end_user_session_layout:data(data.form);
+		if err then
+			return generate_error_message(err);
+		end
 		local failed = {};
 		local succeeded = {};
 		for _, aJID in ipairs(fields.accountjids) do
@@ -223,9 +237,9 @@
 		if data.action == "cancel" then
 			return { status = "canceled" };
 		end
-		local fields = get_user_password_layout:data(data.form);
-		if not fields.accountjid then
-			return { status = "completed", error = { message = "Please specify a JID." } };
+		local fields, err = get_user_password_layout:data(data.form);
+		if err then
+			return generate_error_message(err);
 		end
 		local user, host, resource = jid.split(fields.accountjid);
 		local accountjid = "";
@@ -261,10 +275,10 @@
 			return { status = "canceled" };
 		end
 
-		local fields = get_user_roster_layout:data(data.form);
+		local fields, err = get_user_roster_layout:data(data.form);
 
-		if not fields.accountjid then
-			return { status = "completed", error = { message = "Please specify a JID" } };
+		if err then
+			return generate_error_message(err);
 		end
 
 		local user, host, resource = jid.split(fields.accountjid);
@@ -323,10 +337,10 @@
 			return { status = "canceled" };
 		end
 
-		local fields = get_user_stats_layout:data(data.form);
+		local fields, err = get_user_stats_layout:data(data.form);
 
-		if not fields.accountjid then
-			return { status = "completed", error = { message = "Please specify a JID." } };
+		if err then
+			return generate_error_message(err);
 		end
 
 		local user, host, resource = jid.split(fields.accountjid);
@@ -376,7 +390,11 @@
 			return { status = "canceled" };
 		end
 
-		local fields = get_online_users_layout:data(data.form);
+		local fields, err = get_online_users_layout:data(data.form);
+
+		if err then
+			return generate_error_message(err);
+		end
 
 		local max_items = nil
 		if fields.max_items ~= "all" then
@@ -436,11 +454,9 @@
 		if data.action == "cancel" then
 			return { status = "canceled" };
 		end
-		local fields = layout:data(data.form);
-		if (not fields.module) or (fields.module == "") then
-			return { status = "completed", error = {
-				message = "Please specify a module."
-			} };
+		local fields, err = layout:data(data.form);
+		if err then
+			return generate_error_message(err);
 		end
 		if modulemanager.is_loaded(data.to, fields.module) then
 			return { status = "completed", info = "Module already loaded" };
@@ -470,11 +486,9 @@
 		if data.action == "cancel" then
 			return { status = "canceled" };
 		end
-		local fields = layout:data(data.form);
-		if #fields.modules == 0 then
-			return { status = "completed", error = {
-				message = "Please specify a module. (This means your client misbehaved, as this field is required)"
-			} };
+		local fields, err = layout:data(data.form);
+		if err then
+			return generate_error_message(err);
 		end
 		local ok_list, err_list = {}, {};
 		for _, module in ipairs(fields.modules) do
@@ -538,7 +552,11 @@
 			return { status = "canceled" };
 		end
 
-		local fields = shut_down_service_layout:data(data.form);
+		local fields, err = shut_down_service_layout:data(data.form);
+
+		if err then
+			return generate_error_message(err);
+		end
 
 		if fields.announcement and #fields.announcement > 0 then
 			local message = st.message({type = "headline"}, fields.announcement):up()
@@ -566,11 +584,9 @@
 		if data.action == "cancel" then
 			return { status = "canceled" };
 		end
-		local fields = layout:data(data.form);
-		if #fields.modules == 0 then
-			return { status = "completed", error = {
-				message = "Please specify a module. (This means your client misbehaved, as this field is required)"
-			} };
+		local fields, err = layout:data(data.form);
+		if err then
+			return generate_error_message(err);
 		end
 		local ok_list, err_list = {}, {};
 		for _, module in ipairs(fields.modules) do
--- a/plugins/mod_dialback.lua	Wed Jul 04 23:44:13 2012 +0100
+++ b/plugins/mod_dialback.lua	Thu Jul 05 17:40:12 2012 +0100
@@ -84,7 +84,7 @@
 			origin.from_host = from;
 		end
 		if not origin.to_host then
-			origin.to_host = nameprep(attr.to);
+			origin.to_host = to;
 		end
 
 		origin.log("debug", "asking %s if key %s belongs to them", from, stanza[1]);
--- a/plugins/muc/mod_muc.lua	Wed Jul 04 23:44:13 2012 +0100
+++ b/plugins/muc/mod_muc.lua	Thu Jul 05 17:40:12 2012 +0100
@@ -65,19 +65,27 @@
 	if forced then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end
 end
 
+local persistent_errors = false;
 for jid in pairs(persistent_rooms) do
 	local node = jid_split(jid);
-	local data = datamanager.load(node, muc_host, "config") or {};
-	local room = muc_new_room(jid, {
-		max_history_length = max_history_messages;
-	});
-	room._data = data._data;
-	room._data.max_history_length = max_history_messages; -- Overwrite old max_history_length in data with current settings
-	room._affiliations = data._affiliations;
-	room.route_stanza = room_route_stanza;
-	room.save = room_save;
-	rooms[jid] = room;
+	local data = datamanager.load(node, muc_host, "config");
+	if data then
+		local room = muc_new_room(jid, {
+			max_history_length = max_history_messages;
+		});
+		room._data = data._data;
+		room._data.max_history_length = max_history_messages; -- Overwrite old max_history_length in data with current settings
+		room._affiliations = data._affiliations;
+		room.route_stanza = room_route_stanza;
+		room.save = room_save;
+		rooms[jid] = room;
+	else -- missing room data
+		persistent_rooms[jid] = nil;
+		module:log("error", "Missing data for room '%s', removing from persistent room list", jid);
+		persistent_errors = true;
+	end
 end
+if persistent_errors then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end
 
 local host_room = muc_new_room(muc_host, {
 	max_history_length = max_history_messages;