Commit 6e6c8803 authored by Ted Trask's avatar Ted Trask
Browse files

Remove all calls to 'module' in preparation for move to Lua 5.2

Use mymodule parameter for module definition.
This was also helpful in revealing places where the code relied on the global environment.
parent 3cdbb88e
module(..., package.seeall)
local mymodule = {}
default_action = "status"
mymodule.default_action = "status"
function status(self)
function mymodule.status(self)
return self.model.getstatus()
end
function startstop(self)
function mymodule.startstop(self)
return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata)
end
function config(self)
function mymodule.config(self)
return self.handle_form(self, self.model.getconfig, self.model.setconfig, self.clientdata, "Save", "Edit Config", "Configuration Set")
end
function expert(self)
function mymodule.expert(self)
return self.handle_form(self, self.model.getconfigfile, self.model.setconfigfile, self.clientdata, "Save", "Edit Config File", "Configuration File Set")
end
function viewleases(self)
function mymodule.viewleases(self)
return self.model.getleases()
end
return mymodule
module(..., package.seeall)
local mymodule = {}
-- Load libraries
modelfunctions = require("modelfunctions")
......@@ -267,19 +267,19 @@ end
-- ################################################################################
-- PUBLIC FUNCTIONS
function get_startstop(self, clientdata)
function mymodule.get_startstop(self, clientdata)
return modelfunctions.get_startstop(processname)
end
function startstop_service(self, startstop, action)
function mymodule.startstop_service(self, startstop, action)
return modelfunctions.startstop_service(startstop, action)
end
function getstatus()
function mymodule.getstatus()
return modelfunctions.getstatus(processname, packagename, "DNS Masq Status")
end
function getconfig()
function mymodule.getconfig()
local conf = parse_file(fs.read_file(configfile) or "") or {}
local dns_filtering = {}
dns_filtering.enabled = dns_filtering_is_enabled(conf)
......@@ -303,7 +303,7 @@ function getconfig()
return cfe({ type="group", value=output, label="DNS Masq Config" })
end
function setconfig(self, config)
function mymodule.setconfig(self, config)
local success, config = validateconfig(self, config)
if success then
......@@ -330,16 +330,18 @@ function setconfig(self, config)
return config
end
function getconfigfile()
function mymodule.getconfigfile()
-- FIXME Validate
return modelfunctions.getfiledetails(configfile)
end
function setconfigfile(self, filedetails)
function mymodule.setconfigfile(self, filedetails)
-- FIXME Validate
return modelfunctions.setfiledetails(self, filedetails, {configfile})
end
function getleases()
function mymodule.getleases()
return modelfunctions.getfiledetails(leasefile)
end
return mymodule
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment