summaryrefslogtreecommitdiffstats
path: root/fetchmail-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-10-18 22:33:13 +0000
committerTed Trask <ttrask01@yahoo.com>2013-10-18 22:33:13 +0000
commitd630f6b8d5d133a83a87e48954f93105033f1c24 (patch)
treeaad787d54acba3467d2e4c0c8b4327a54b52a287 /fetchmail-model.lua
parent1d8f30e830ea4417e34c895d277f2d05b7a6f26d (diff)
downloadacf-fetchmail-d630f6b8d5d133a83a87e48954f93105033f1c24.tar.bz2
acf-fetchmail-d630f6b8d5d133a83a87e48954f93105033f1c24.tar.xz
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.
Diffstat (limited to 'fetchmail-model.lua')
-rw-r--r--fetchmail-model.lua30
1 files changed, 16 insertions, 14 deletions
diff --git a/fetchmail-model.lua b/fetchmail-model.lua
index ba896c9..cd36f89 100644
--- a/fetchmail-model.lua
+++ b/fetchmail-model.lua
@@ -1,4 +1,4 @@
-module(..., package.seeall)
+local mymodule = {}
-- Load libraries
modelfunctions = require("modelfunctions")
@@ -388,12 +388,12 @@ end
-- ################################################################################
-- PUBLIC FUNCTIONS
-function get_startstop(self, clientdata)
+function mymodule.get_startstop(self, clientdata)
local actions = {"Run", "Test"}
return cfe({ type="group", label="Management", value={}, option=actions })
end
-function startstop_service(self, startstop, action)
+function mymodule.startstop_service(self, startstop, action)
if action and (action:lower() == "run" or action:lower() == "test") then
local cmd
if action:lower() == "run" then
@@ -408,16 +408,16 @@ function startstop_service(self, startstop, action)
return startstop
end
-function getstatus()
+function mymodule.getstatus()
return modelfunctions.getstatus(processname, packagename, "Fetchmail Status")
end
-function get_filedetails()
+function mymodule.get_filedetails()
-- FIXME - validation
return modelfunctions.getfiledetails(configfile)
end
-function update_filecontent(self, filedetails)
+function mymodule.update_filecontent(self, filedetails)
-- FIXME - validation
local retval = modelfunctions.setfiledetails(self, filedetails, {configfile})
posix.chmod(configfile, "rw-------")
@@ -426,7 +426,7 @@ function update_filecontent(self, filedetails)
return retval
end
-function getconfig()
+function mymodule.getconfig()
local interval = cfe({ value="60", label="Polling Interval", descr="Interval in seconds" })
local postmaster = cfe({ label="Postmaster", descr="If defined, undeliverable mail is sent to this account, otherwise it is discarded" })
local bounceerrors = cfe({ type="boolean", value=true, label="Bounce Errors", descr="Bounce errors back to the sender or send them to the postmaster" })
@@ -448,7 +448,7 @@ function getconfig()
return cfe({ type="group", value={interval=interval, postmaster=postmaster, bounceerrors=bounceerrors}, label="Fetchmail Global Config" })
end
-function updateconfig(self, conf)
+function mymodule.updateconfig(self, conf)
local success, conf = validateconfig(conf)
if success then
@@ -491,7 +491,7 @@ function updateconfig(self, conf)
return conf
end
-function readentries()
+function mymodule.readentries()
local entries = cfe({ type="structure", value={}, label="List of Fetchmail entries" })
config = config or parseconfigfile(fs.read_file(configfile) or "")
for i,entry in ipairs(config or {}) do
@@ -519,7 +519,7 @@ function readentries()
return entries
end
-function readentry(entryname, meth, remotemailbx, localdom)
+function mymodule.readentry(entryname, meth, remotemailbx, localdom)
local enabled = cfe({ type="boolean", value=true, label="Enable", seq=2 })
local method = cfe({ type="select", value="pop3", label="Method", option=methods, seq=3 })
local remotehost = cfe({ value=entryname, label="Remote Host", seq=1 })
@@ -581,7 +581,7 @@ function readentry(entryname, meth, remotemailbx, localdom)
return cfe({ type="group", value={enabled=enabled, method=method, remotehost=remotehost, remotemailbox=remotemailbox, remotepassword=remotepassword, localhost=localhost, localmailbox=localmailbox, localdomain=localdomain, ssl=ssl, envelope=envelope}, label="Fetchmail Entry" })
end
-function updateentry(self, entrystruct)
+function mymodule.updateentry(self, entrystruct)
local success, entrystruct = validateentry(entrystruct)
local entry = findentryline(entrystruct.value.remotehost.value, entrystruct.value.method.value, entrystruct.value.remotemailbox.value, entrystruct.value.localdomain.value)
if not entry then
@@ -598,7 +598,7 @@ function updateentry(self, entrystruct)
return entrystruct
end
-function createentry(self, entrystruct)
+function mymodule.createentry(self, entrystruct)
local success, entrystruct = validateentry(entrystruct)
local entry = findentryline(entrystruct.value.remotehost.value, entrystruct.value.method.value, entrystruct.value.remotemailbox.value, entrystruct.value.localdomain.value)
if entry then
@@ -615,7 +615,7 @@ function createentry(self, entrystruct)
return entrystruct
end
-function get_deleteentry(self, clientdata)
+function mymodule.get_deleteentry(self, clientdata)
local retval = {}
retval.remotehost = cfe({ value=clientdata.remotehost or "", label="Remote Host" })
retval.method = cfe({ type="select", value=clientdata.method or "pop3", label="Method", option=methods })
@@ -625,7 +625,7 @@ function get_deleteentry(self, clientdata)
return cfe({ type="group", value=retval, label="Delete Entry" })
end
-function deleteentry(self, ent)
+function mymodule.deleteentry(self, ent)
local entry = findentryline(ent.value.remotehost.value, ent.value.method.value, ent.value.remotemailbox.value, ent.value.localdomain.value)
if entry then
writeentryline(nil, entry)
@@ -635,3 +635,5 @@ function deleteentry(self, ent)
return ent
end
+
+return mymodule