summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-02-05 15:11:51 +0000
committerMika Havela <mika.havela@gmail.com>2008-02-05 15:11:51 +0000
commitdce730f2e59d6d66d911de45c8a080ac0aa0b2bc (patch)
treeb4cbebfef7e70376c0492bef8b0c2e1957018690
parent10086c539c85fd11cd1c5339e7659b8c04ffb525 (diff)
downloadacf-fetchmail-dce730f2e59d6d66d911de45c8a080ac0aa0b2bc.tar.bz2
acf-fetchmail-dce730f2e59d6d66d911de45c8a080ac0aa0b2bc.tar.xz
When you have a valid configuration in /etc/.fetchmailrc you will see the result in the config-tab.
Valid config should be placed between rows '#Begin Fetchmail...' and '#End Fetchmail...' (each config should be in one row). git-svn-id: svn://svn.alpinelinux.org/acf/fetchmail/trunk@694 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--fetchmail-config-html.lsp50
-rw-r--r--fetchmail-model.lua129
2 files changed, 90 insertions, 89 deletions
diff --git a/fetchmail-config-html.lsp b/fetchmail-config-html.lsp
index df784c7..7c0a0ca 100644
--- a/fetchmail-config-html.lsp
+++ b/fetchmail-config-html.lsp
@@ -59,12 +59,14 @@ informationform(myform,tags)
form.option.controller .. "/" .. form.option.action ?>" method="POST">
<H2>GUIDED CONFIGURATION</H2>
+<? --[[ ?>
<H3>FREQUENCY</H3>
<P>Select how often the mailboxes will be checked. For ETRN transfers (below) this specifies how often transfers are initiated</P>
<?
local tags = { "freq", }
configform(myform,tags)
?>
+<? --]] ?>
<H3>MAILBOXES</H3>
<P>In the boxes below, select up to 10 mailboxes to check for mail. You will need to specify the remote mailbox and password, as well as the local (internal) mailbox to forward the mail to. The SMTP host is the name or address of the SMTP server to send the mail to. For mail destined for the internal branch network, this should be <B>svcoutside</B> (the address of the outside interface of the services BSN component). This is then forwarded to the to the internal component of the BSN for sending on to the branch network.</P>
@@ -79,56 +81,56 @@ local mailboxform = myform[tags]["value"]
?>
<DL>
<?
- io.write("<CENTER><TABLE STYLE='width:90%;border:1px solid #ccc;background:#eee'><TR><TD CLASS='header' WIDTH='130px'>")
- io.write("<CENTER>METHOD</CENTER></TD><TD CLASS='header' COLSPAN=2>")
- io.write("<CENTER>REMOTE</CENTER></TD><TD CLASS='header' COLSPAN=2>")
- io.write("<CENTER>LOCAL</CENTER></TD></TR>")
+ io.write("\n\t<CENTER><TABLE STYLE='width:90%;border:1px solid #ccc;background:#eee'>\n\t\t<TR>\n\t\t\t<TD CLASS='header' WIDTH='130px'>")
+ io.write("<CENTER>METHOD</CENTER></TD>\n\t\t\t<TD CLASS='header' COLSPAN=2>")
+ io.write("<CENTER>REMOTE</CENTER></TD>\n\t\t\t<TD CLASS='header' COLSPAN=2>")
+ io.write("<CENTER>LOCAL</CENTER></TD>\n\t\t</TR>")
for i=1, table.maxn(mailboxform) do
leftpadd="30px"
rightpadd="5px"
- io.write("<TR><TD>")
+ io.write("\n\t\t<TR>\n\t\t\t<TD>")
val = "method"
io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
- io.write("</TD><TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";' WIDTH='5%'>")
+ io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";' WIDTH='5%'>")
val = "remotehost"
io.write(mailboxform[i][val]["label"])
- io.write(":</TD><TD>")
+ io.write(":</TD>\n\t\t\t<TD>")
io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
- io.write("</TD><TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";' WIDTH='5%'>")
+ io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";' WIDTH='5%'>")
val = "localhost"
io.write(mailboxform[i][val]["label"])
- io.write(":</TD><TD>")
+ io.write(":</TD>\n\t\t\t<TD>")
io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
- io.write("</TD></TR>")
- io.write("<TR><TD>")
+ io.write("</TD>\n\t\t</TR>")
+ io.write("\n\t\t<TR>\n\t\t\t<TD>")
val = "disabled"
io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
io.write(" " .. mailboxform[i][val]["label"])
- io.write("</TD><TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
+ io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
val = "remotemailbox"
io.write(mailboxform[i][val]["label"])
- io.write(":</TD><TD>")
+ io.write(":</TD>\n\t\t\t<TD>")
io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
- io.write("</TD><TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
+ io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
val = "localmailbox"
io.write(mailboxform[i][val]["label"])
- io.write(":</TD><TD>")
+ io.write(":</TD>\n\t\t\t<TD>")
io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
- io.write("</TD></TR>")
- io.write("<TR><TD>")
- io.write("</TD><TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
+ io.write("</TD>\n\t\t</TR>")
+ io.write("\n\t\t<TR>\n\t\t\t<TD>")
+ io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
val = "remotepassword"
io.write(mailboxform[i][val]["label"])
- io.write(":</TD><TD>")
+ io.write(":</TD>\n\t\t\t<TD>")
io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
- io.write("</TD><TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
+ io.write("</TD>\n\t\t\t<TD style='padding-left:".. leftpadd .. ";padding-right:".. rightpadd .. ";'>")
val = "localdomain"
io.write(mailboxform[i][val]["label"])
- io.write(":</TD><TD>")
+ io.write(":</TD>\n\t\t\t<TD>")
io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val]))
- io.write("</TD></TR>")
- io.write("<TR><TD COLSPAN=5><HR></TD></TR>")
+ io.write("</TD>\n\t\t</TR>")
+ io.write("\n\t\t<TR>\n\t\t\t<TD COLSPAN=5><HR></TD>\n\t\t</TR>")
end
io.write("</TABLE></CENTER>")
?>
@@ -194,7 +196,7 @@ if (cmdform) and (cmdform[tags[1]]) then
<? end ?>
<?
----[[ DEBUG INFORMATION
+--[[ DEBUG INFORMATION
io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>")
io.write(html.cfe_unpack(form))
io.write("</span>")
diff --git a/fetchmail-model.lua b/fetchmail-model.lua
index 5f589b4..330e68f 100644
--- a/fetchmail-model.lua
+++ b/fetchmail-model.lua
@@ -31,58 +31,54 @@ local function getmethods()
return methods
end
-local function getmailboxes()
- local mailboxes = {}
- for i=1,2 do
- local objects = cfe({})
- objects.label = "Mailbox_" .. tostring(i)
- objects.method = cfe({
- name="method",
- label = "Method",
- type = "select",
- value = "",
- option = getmethods(),
- })
- objects.disabled = cfe({
- name="disabled",
- type="checkbox",
- label = "Disabled",
- checked = "yes",
- })
- objects.remotehost = cfe({
- name="remotehost",
- label = "RemoteHost",
- value = "xxx_RemoteHost",
- })
- objects.remotemailbox = cfe({
- name="remotemailbox",
- label = "Mailbox",
- value = "xxx_RemoteMailbox",
- })
- objects.remotepassword = cfe({
- name="remotepassword",
- label = "Password",
- type = "text",
- value = "xxx_password",
- })
- objects.localhost = cfe({
- name="localhost",
- label = "LocalHost",
- value = "xxx_LocalHost",
- })
- objects.localmailbox = cfe({
- name="localmailbox",
- label = "LocalMailbox",
- value = "xxx_LocalMailbox",
- })
- objects.localdomain = cfe({
- name="localdomain",
- label = "LocalDomain",
- value = "xxx_LocalDomain",
- })
- table.insert(mailboxes, objects)
- end
- return mailboxes
+local function getmailboxes(t)
+ local objects = cfe({})
+ objects.label = "Mailbox " .. tostring(t["RBOX"])
+ objects.method = cfe({
+ name="method",
+ label = "Method",
+ type = "select",
+ value = t["METHOD"],
+ option = getmethods(),
+ })
+ objects.disabled = cfe({
+ name="disabled",
+ type="checkbox",
+ label = "Disabled",
+ checked = t["DISABLED"],
+ })
+ objects.remotehost = cfe({
+ name="remotehost",
+ label = "RemoteHost",
+ value = t["RHOST"],
+ })
+ objects.remotemailbox = cfe({
+ name="remotemailbox",
+ label = "Mailbox",
+ value = t["RBOX"],
+ })
+ objects.remotepassword = cfe({
+ name="remotepassword",
+ label = "Password",
+ type = "passwd",
+ value = t["PASSWD"],
+ })
+ objects.localhost = cfe({
+ name="localhost",
+ label = "LocalHost",
+ value = t["LHOST"],
+ })
+ objects.localmailbox = cfe({
+ name="localmailbox",
+ label = "LocalMailbox",
+ value = t["LBOX"],
+ })
+ objects.localdomain = cfe({
+ name="localdomain",
+ label = "LocalDomain",
+ value = t["DOMAIN"],
+ })
+ return objects
end
local function read_config()
@@ -103,16 +99,14 @@ etrn is:
1 2 3 4 5 6
pool <host> protocol etrn smtpdomain <mydomain>
--]]
--- local configcontent = {}
- local configcontent_popimap = {}
- local configcontent_popdomain = {}
+ local mailboxes = {}
local configcontent_postmaster = {}
local configcontent_etrn = {}
local path = configfile
local valid = nil
configcontenttable = fs.read_file_as_array(path) or {}
for k,v in pairs(configcontenttable) do
- if (string.match(v, "^%s*#Begin Fetchmail Webconf")) then valid=1 end
+ if (string.match(v, "^%s*#Begin Fetchmail")) then valid=1 end
if (valid) then
-- if not (configcontent[k]) then configcontent[k] = {} end
-- if not (configcontent_popimap[k]) then configcontent_popimap[k] = {} end
@@ -124,6 +118,7 @@ pool <host> protocol etrn smtpdomain <mydomain>
local val = {RHOST=2, CHECK=9 ,METHOD=4, RBOX=8, PASSWD=10, LBOX=12, LHOST=14}
local configcontent = {}
configcontent[k] = {}
+ configcontent[k]["DISABLED"] = DISABLED
for kk,vv in pairs(val) do
configcontent[k][kk] = tostring(string.match(v,"^%s*" .. string.rep("%S*%s*",vv-1) .. "(%S*)%s*"))
end
@@ -133,29 +128,33 @@ pool <host> protocol etrn smtpdomain <mydomain>
end
-- Check if row is valid config
if (configcontent[k]["CHECK"]) and (string.lower(configcontent[k]["CHECK"]) == "password") then
- table.insert(configcontent_popimap,configcontent[k])
+ table.insert(mailboxes,getmailboxes(configcontent[k]))
end
-- Set parameters for POP3domain
local val = {RHOST=2, METHOD=6, RBOX=10, CHECK=11, PASSWD=12, LHOST=17, DOMAIN=19,}
local configcontent = {}
configcontent[k] = {}
+ configcontent[k]["DISABLED"] = DISABLED
for kk,vv in pairs(val) do
configcontent[k][kk] = tostring(string.match(v,"^%s*" .. string.rep("%S*%s*",vv-1) .. "(%S*)%s*"))
end
+ -- Display this config as Method=pop3domain (as the current options in the view)
+ configcontent[k]["METHOD"] = "pop3domain"
-- Remove quotes from passwords
if (configcontent[k]["PASSWD"]) then
configcontent[k]["PASSWD"] = string.match(configcontent[k]["PASSWD"], "^\"(.-)\"")
end
-- Check if row is valid config
if (configcontent[k]["CHECK"]) and (string.lower(configcontent[k]["CHECK"]) == "password") then
- table.insert(configcontent_popdomain,configcontent[k])
+ table.insert(mailboxes,getmailboxes(configcontent[k]))
end
-- Set parameters for etrn
local val = {ETRNSMTPHOST=2, CHECK=4, ETRNDOMAIN=6}
local configcontent = {}
configcontent[k] = {}
+ configcontent[k]["DISABLED"] = DISABLED
for kk,vv in pairs(val) do
configcontent[k][kk] = tostring(string.match(v,"^%s*" .. string.rep("%S*%s*",vv-1) .. "(%S*)%s*"))
end
@@ -168,6 +167,7 @@ pool <host> protocol etrn smtpdomain <mydomain>
local val = {CHECK=2, POSTMASTER=3}
local configcontent = {}
configcontent[k] = {}
+ configcontent[k]["DISABLED"] = DISABLED
for kk,vv in pairs(val) do
configcontent[k][kk] = tostring(string.match(v,"^%s*" .. string.rep("%S*%s*",vv-1) .. "(%S*)%s*"))
end
@@ -178,10 +178,9 @@ pool <host> protocol etrn smtpdomain <mydomain>
end
- if (string.match(v, "^%s*#End Fetchmail Webconf")) then valid=nil end
+ if (string.match(v, "^%s*#End Fetchmail")) then valid=nil end
end
- configcontent = configcontent_postmaster
- return configcontent,configcontent_etrn,configcontent_postmaster
+ return mailboxes,configcontent_postmaster,configcontent_etrn
end
-- ################################################################################
@@ -288,7 +287,7 @@ function get_filedetails()
end
function getconfig()
local config = {}
- local configcontent, configcontentetrn, configcontent_postmaster = read_config()
+ local mailboxes,configcontent_postmaster,configcontent_etrn = read_config()
if not (fs.is_file(configfile)) then
config["configfile"] = "Config file '".. configfile .. "' is missing!"
end
@@ -313,7 +312,7 @@ function getconfig()
config["mailboxes"] = cfe({
name="mailboxes",
label = "Mailboxes",
- value = getmailboxes(),
+ value = mailboxes,
})
config["postmaster"] = cfe({
name="postmaster",
@@ -323,12 +322,12 @@ function getconfig()
config["etrnremote"] = cfe({
name="etrnremote",
label = "Remote server",
- value = configcontentetrn["ETRNSMTPHOST"],
+ value = configcontent_etrn["ETRNSMTPHOST"],
})
config["etrnquedomain"] = cfe({
name="etrnquedomain",
label = "Queued domain",
- value = configcontentetrn["ETRNDOMAIN"],
+ value = configcontent_etrn["ETRNDOMAIN"],
})
--[[