mod_*: Fix many unnecessary global accesses in modules (already committed to main repo)

Wed, 29 Apr 2009 02:08:12 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 29 Apr 2009 02:08:12 +0100
changeset 1065
3806173670f2
parent 1064
3e945c3938ad
child 1066
0cb325970a50
child 1067
21f41b06f1d2

mod_*: Fix many unnecessary global accesses in modules (already committed to main repo)

plugins/mod_component.lua file | annotate | diff | comparison | revisions
plugins/mod_console.lua file | annotate | diff | comparison | revisions
plugins/mod_dialback.lua file | annotate | diff | comparison | revisions
plugins/mod_legacyauth.lua file | annotate | diff | comparison | revisions
plugins/mod_muc.lua file | annotate | diff | comparison | revisions
plugins/mod_register.lua file | annotate | diff | comparison | revisions
plugins/mod_saslauth.lua file | annotate | diff | comparison | revisions
plugins/mod_vcard.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_component.lua	Wed Apr 29 02:06:05 2009 +0100
+++ b/plugins/mod_component.lua	Wed Apr 29 02:08:12 2009 +0100
@@ -10,14 +10,19 @@
 	error("Don't load mod_component manually, it should be for a component, please see http://prosody.im/doc/components", 0);
 end
 
+local hosts = _G.hosts;
+
 local t_concat = table.concat;
 
+local lxp = require "lxp";
+local logger = require "util.logger";
+local config = require "core.configmanager";
 local connlisteners = require "net.connlisteners";
 local cm_register_component = require "core.componentmanager".register_component;
 local cm_deregister_component = require "core.componentmanager".deregister_component;
 local uuid_gen = require "util.uuid".generate;
 local sha1 = require "util.hashes".sha1;
-local st = stanza;
+local st = require "util.stanza";
 local init_xmlhandlers = require "core.xmlhandlers";
 
 local sessions = {};
@@ -211,8 +216,8 @@
 
 module:add_event_hook("server-started", 
 	function ()
-		if net_activate_ports then
-			net_activate_ports("component", "component", {5437}, "tcp");
+		if _G.net_activate_ports then
+			_G.net_activate_ports("component", "component", {5437}, "tcp");
 		else
 			error("No net_activate_ports: Using an incompatible version of Prosody?");
 		end
--- a/plugins/mod_console.lua	Wed Apr 29 02:06:05 2009 +0100
+++ b/plugins/mod_console.lua	Wed Apr 29 02:08:12 2009 +0100
@@ -8,6 +8,7 @@
 
 module.host = "*";
 
+local hosts = _G.hosts;
 local connlisteners_register = require "net.connlisteners".register;
 
 local console_listener = { default_port = 5582; default_mode = "*l"; };
--- a/plugins/mod_dialback.lua	Wed Apr 29 02:06:05 2009 +0100
+++ b/plugins/mod_dialback.lua	Wed Apr 29 02:08:12 2009 +0100
@@ -7,7 +7,7 @@
 --
 
 
-
+local hosts = _G.hosts;
 local send_s2s = require "core.s2smanager".send_to_host;
 local s2s_make_authenticated = require "core.s2smanager".make_authenticated;
 local s2s_verify_dialback = require "core.s2smanager".verify_dialback;
--- a/plugins/mod_legacyauth.lua	Wed Apr 29 02:06:05 2009 +0100
+++ b/plugins/mod_legacyauth.lua	Wed Apr 29 02:08:12 2009 +0100
@@ -11,6 +11,9 @@
 local st = require "util.stanza";
 local t_concat = table.concat;
 
+local sessionmanager = require "core.sessionmanager";
+local usermanager = require "core.usermanager";
+
 module:add_feature("jabber:iq:auth");
 module:add_event_hook("stream-features", function (session, features)
 	if not session.username then features:tag("auth", {xmlns='http://jabber.org/features/iq-auth'}):up(); end
--- a/plugins/mod_muc.lua	Wed Apr 29 02:06:05 2009 +0100
+++ b/plugins/mod_muc.lua	Wed Apr 29 02:08:12 2009 +0100
@@ -6,6 +6,8 @@
 -- COPYING file in the source package for more information.
 --
 
+local datamanager = require "util.datamanager";
+local datetime = require "util.datetime";
 
 local register_component = require "core.componentmanager".register_component;
 local deregister_component = require "core.componentmanager".deregister_component;
--- a/plugins/mod_register.lua	Wed Apr 29 02:06:05 2009 +0100
+++ b/plugins/mod_register.lua	Wed Apr 29 02:08:12 2009 +0100
@@ -7,8 +7,10 @@
 --
 
 
-
+local hosts = _G.hosts;
 local st = require "util.stanza";
+local config = require "core.configmanager";
+local datamanager = require "util.datamanager";
 local usermanager_user_exists = require "core.usermanager".user_exists;
 local usermanager_create_user = require "core.usermanager".create_user;
 local datamanager_store = require "util.datamanager".store;
--- a/plugins/mod_saslauth.lua	Wed Apr 29 02:06:05 2009 +0100
+++ b/plugins/mod_saslauth.lua	Wed Apr 29 02:08:12 2009 +0100
@@ -10,8 +10,10 @@
 
 local st = require "util.stanza";
 local sm_bind_resource = require "core.sessionmanager".bind_resource;
+local sm_make_authenticated = require "core.sessionmanager".make_authenticated;
 local base64 = require "util.encodings".base64;
 
+local datamanager_load = require "util.datamanager".load;
 local usermanager_validate_credentials = require "core.usermanager".validate_credentials;
 local t_concat, t_insert = table.concat, table.insert;
 local tostring = tostring;
@@ -49,14 +51,14 @@
 		session.sasl_handler = nil;
 	elseif status == "success" then
 		if not session.sasl_handler.username then error("SASL succeeded but we didn't get a username!"); end -- TODO move this to sessionmanager
-		sessionmanager.make_authenticated(session, session.sasl_handler.username);
+		sm_make_authenticated(session, session.sasl_handler.username);
 		session.sasl_handler = nil;
 		session:reset_stream();
 	end
 end
 
 local function password_callback(node, host, mechanism, decoder)
-	local password = (datamanager.load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords
+	local password = (datamanager_load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords
 	local func = function(x) return x; end;
 	if password then
 		if mechanism == "PLAIN" then
--- a/plugins/mod_vcard.lua	Wed Apr 29 02:06:05 2009 +0100
+++ b/plugins/mod_vcard.lua	Wed Apr 29 02:08:12 2009 +0100
@@ -8,13 +8,13 @@
 
 
 
-require "util.datamanager"
-local datamanager = datamanager;
+local hosts = _G.hosts;
+local datamanager = require "util.datamanager"
 
 local st = require "util.stanza"
 local t_concat, t_insert = table.concat, table.insert;
 
-require "util.jid"
+local jid = require "util.jid"
 local jid_split = jid.split;
 
 module:add_feature("vcard-temp");

mercurial