From dce730f2e59d6d66d911de45c8a080ac0aa0b2bc Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Tue, 5 Feb 2008 15:11:51 +0000 Subject: 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 --- fetchmail-config-html.lsp | 50 +++++++++--------- fetchmail-model.lua | 129 +++++++++++++++++++++++----------------------- 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">

GUIDED CONFIGURATION

+

FREQUENCY

Select how often the mailboxes will be checked. For ETRN transfers (below) this specifies how often transfers are initiated

+

MAILBOXES

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 svcoutside (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.

@@ -79,56 +81,56 @@ local mailboxform = myform[tags]["value"] ?>
") + io.write("\n\t
") - io.write("
METHOD
") - io.write("
REMOTE
") - io.write("
LOCAL
\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t") for i=1, table.maxn(mailboxform) do leftpadd="30px" rightpadd="5px" - io.write("\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t") - io.write("\n\t\t") + io.write("\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t") - io.write("\n\t\t") + io.write("\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t") - io.write("") + io.write("\n\t\t") + io.write("\n\t\t\n\t\t\t\n\t\t") end io.write("
") + io.write("
METHOD
") + io.write("
REMOTE
") + io.write("
LOCAL
") + io.write("\n\t\t
") val = "method" io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val])) - io.write("") + io.write("") val = "remotehost" io.write(mailboxform[i][val]["label"]) - io.write(":") + io.write(":") io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val])) - io.write("") + io.write("") val = "localhost" io.write(mailboxform[i][val]["label"]) - io.write(":") + io.write(":") io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val])) - io.write("
") + io.write("
") val = "disabled" io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val])) io.write(" " .. mailboxform[i][val]["label"]) - io.write("") + io.write("") val = "remotemailbox" io.write(mailboxform[i][val]["label"]) - io.write(":") + io.write(":") io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val])) - io.write("") + io.write("") val = "localmailbox" io.write(mailboxform[i][val]["label"]) - io.write(":") + io.write(":") io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val])) - io.write("
") - io.write("") + io.write("
") + io.write("") val = "remotepassword" io.write(mailboxform[i][val]["label"]) - io.write(":") + io.write(":") io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val])) - io.write("") + io.write("") val = "localdomain" io.write(mailboxform[i][val]["label"]) - io.write(":") + io.write(":") io.write(html.form[mailboxform[i][val]["type"]](mailboxform[i][val])) - io.write("


") ?> @@ -194,7 +196,7 @@ if (cmdform) and (cmdform[tags[1]]) then DEBUGGING

DEBUG INFO: CFE

") io.write(html.cfe_unpack(form)) io.write("
") 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 protocol etrn smtpdomain --]] --- 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 protocol etrn smtpdomain 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 protocol etrn smtpdomain 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 protocol etrn smtpdomain 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 protocol etrn smtpdomain 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"], }) --[[ -- cgit v1.2.3