applications/luci-asterisk: rework voicemail management
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 29 Mar 2009 23:39:40 +0000 (23:39 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 29 Mar 2009 23:39:40 +0000 (23:39 +0000)
applications/luci-asterisk/luasrc/controller/asterisk.lua
applications/luci-asterisk/luasrc/model/cbi/asterisk/voicemail.lua [new file with mode: 0644]
applications/luci-asterisk/luasrc/model/cbi/asterisk/voicemail_settings.lua [new file with mode: 0644]
applications/luci-asterisk/luasrc/view/asterisk/dialplans.htm

index 3bd369d..b321b5a 100644 (file)
@@ -40,19 +40,22 @@ function index()
                cbi("asterisk-mod-res-feature"), "Feature Module Configuration", 9 )
 
 
-       entry({"admin", "asterisk"},                            cbi("asterisk/main"),           "Asterisk",  99).i18n = "asterisk"
+       entry({"admin", "asterisk"},                                    cbi("asterisk/main"),                   "Asterisk",  99).i18n = "asterisk"
 
-       entry({"admin", "asterisk", "phones"},                  cbi("asterisk/phones"),         "Phones",       1)
-       entry({"admin", "asterisk", "phones", "sip"},           cbi("asterisk/phone_sip"),      nil,            1).leaf = true
-       --entry({"admin", "asterisk", "phones", "exten"},       cbi("asterisk/phone_exten"),    "Extensions",   2).leaf = true
+       entry({"admin", "asterisk", "phones"},                          cbi("asterisk/phones"),                 "Phones",       1)
+       entry({"admin", "asterisk", "phones", "sip"},                   cbi("asterisk/phone_sip"),              nil,            1).leaf = true
+       --entry({"admin", "asterisk", "phones", "exten"},               cbi("asterisk/phone_exten"),            "Extensions",   2).leaf = true
 
-       entry({"admin", "asterisk", "trunks"},                  cbi("asterisk/trunks"),         "Trunks",       2)
-       entry({"admin", "asterisk", "trunks", "sip"},           cbi("asterisk/trunk_sip"),      nil,            1).leaf = true
+       entry({"admin", "asterisk", "trunks"},                          cbi("asterisk/trunks"),                 "Trunks",       2)
+       entry({"admin", "asterisk", "trunks", "sip"},                   cbi("asterisk/trunk_sip"),              nil,            1).leaf = true
 
-       --entry({"admin", "asterisk", "dialplans"},                     cbi("asterisk/dialplans"),      "Call Routing", 3)
-       entry({"admin", "asterisk", "dialplans"},                       call("handle_dialplan"),        "Call Routing", 3)
-       entry({"admin", "asterisk", "dialplans", "out"},        cbi("asterisk/dialplan_out"),   nil,            1).leaf = true
-       entry({"admin", "asterisk", "dialplans", "zones"},      call("handle_dialzones"),               "Dial Zones",   2).leaf = true
+       entry({"admin", "asterisk", "voicemail"},                       cbi("asterisk/voicemail"),              "Voicemail",    3)
+       entry({"admin", "asterisk", "voicemail", "mailboxes"},  cbi("asterisk/voicemail"),                      "Mailboxes",    1)
+       entry({"admin", "asterisk", "voicemail", "settings"},   cbi("asterisk/voicemail_settings"),     "Settings",     2)
+
+       entry({"admin", "asterisk", "dialplans"},                               call("handle_dialplan"),                "Call Routing", 4)
+       entry({"admin", "asterisk", "dialplans", "out"},                cbi("asterisk/dialplan_out"),           nil,            1).leaf = true
+       entry({"admin", "asterisk", "dialplans", "zones"},              call("handle_dialzones"),                       "Dial Zones",   2).leaf = true
 
 end
 
diff --git a/applications/luci-asterisk/luasrc/model/cbi/asterisk/voicemail.lua b/applications/luci-asterisk/luasrc/model/cbi/asterisk/voicemail.lua
new file mode 100644 (file)
index 0000000..efd6a29
--- /dev/null
@@ -0,0 +1,40 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+require "luci.sys.zoneinfo"
+
+
+cbimap = Map("asterisk", "Voicemail - Mailboxes")
+
+voicemail = cbimap:section(TypedSection, "voicemail", "Voicemail Boxes")
+voicemail.addremove = true
+voicemail.anonymous = true
+voicemail.template = "cbi/tblsection"
+
+context = voicemail:option(ListValue, "context", "Context")
+context:value("default")
+
+voicemail:option(Value, "number", "Mailbox Number", "Unique mailbox identifier")
+voicemail:option(Value, "name", "Ownername", "Human readable display name")
+voicemail:option(Value, "password", "Password", "Access protection")
+voicemail:option(Value, "email", "eMail", "Where to send voice messages")
+voicemail:option(Value, "page", "Pager", "Pager number")
+
+zone = voicemail:option(ListValue, "zone", "Timezone", "Used time format")
+zone.titleref = luci.dispatcher.build_url("admin/asterisk/voicemail/settings")
+cbimap.uci:foreach("asterisk", "voicezone",
+       function(s) zone:value(s['.name']) end)
+
+
+return cbimap
diff --git a/applications/luci-asterisk/luasrc/model/cbi/asterisk/voicemail_settings.lua b/applications/luci-asterisk/luasrc/model/cbi/asterisk/voicemail_settings.lua
new file mode 100644 (file)
index 0000000..8ad3ee1
--- /dev/null
@@ -0,0 +1,61 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+]]--
+
+require "luci.sys.zoneinfo"
+
+
+cbimap = Map("asterisk", "Voicemail - Common Settings")
+
+voicegeneral = cbimap:section(TypedSection, "voicegeneral",
+       "General Voicemail Options", "Common settings for all mailboxes are " ..
+       "defined here. Most of them are optional. The storage format should " ..
+       "never be changed once set.")
+
+voicegeneral.anonymous = true
+voicegeneral.addremove = false
+
+format = voicegeneral:option(ListValue, "Storage format")
+format:value("wav49")
+format:value("gsm")
+format:value("wav")
+
+voicegeneral:option(Flag, "sendvoicemail", "Enable sending of emails")
+voicegeneral:option(Flag, "attach", "Attach voice messages to emails")
+voicegeneral:option(Value, "serveremail", "Used email sender address")
+voicegeneral:option(Value, "emaildateformat", "Date format used in emails").optional = true
+voicegeneral:option(Value, "maxlogins", "Max. failed login attempts").optional = true
+voicegeneral:option(Value, "maxmsg", "Max. allowed messages per mailbox").optional = true
+voicegeneral:option(Value, "minmessage", "Min. number of seconds for voicemail").optional = true
+voicegeneral:option(Value, "maxmessage", "Max. number of seconds for voicemail").optional = true
+voicegeneral:option(Value, "maxsilence", "Seconds of silence until stop recording").optional = true
+voicegeneral:option(Value, "maxgreet", "Max. number of seconds for greetings").optional = true
+voicegeneral:option(Value, "skipms", "Milliseconds to skip for rew./ff.").optional = true
+voicegeneral:option(Value, "silencethreshold", "Threshold to detect silence").optional = true
+
+
+voicezone = cbimap:section(TypedSection, "voicezone", "Time Zones",
+       "Time zones define how dates and times are expressen when used in " ..
+       "an voice mails. Refer to the asterisk manual for placeholder values.")
+
+voicezone.addremove = true
+voicezone.sectionhead = "Name"
+voicezone.template = "cbi/tblsection"
+
+tz = voicezone:option(ListValue, "zone", "Location")
+for _, z in ipairs(luci.sys.zoneinfo.TZ) do tz:value(z[1]) end
+
+voicezone:option(Value, "message", "Date Format")
+
+
+return cbimap
index 3ffe6c5..47e6105 100644 (file)
@@ -160,7 +160,7 @@ $Id$
                                                Add Dialzone:<br />
                                                <select style="width:30%" name="addzone.<%=plan.name%>">
                                                        <option value="">-- please select --</option>
-                                                       <% for _, zone in pairs(ast.dialzone.zones()) do %>
+                                                       <% for _, zone in luci.util.kspairs(ast.dialzone.zones()) do %>
                                                                <% if not zones_used[zone.name] then %>
                                                                        <option value="<%=zone.name%>"><%=zone.name%> (<%=zone.description%>)</option>
                                                                <% end %>
@@ -171,7 +171,7 @@ $Id$
                                                Add Voicemailbox:<br />
                                                <select style="width:20%" name="addvbox.<%=plan.name%>" onchange="this.form['addvboxext.<%=plan.name%>'].value=this.options[this.selectedIndex].value.split('@')[0]">
                                                        <option value="">-- please select --</option>
-                                                       <% for ext, box in pairs(ast.voicemail.boxes()) do %>
+                                                       <% for ext, box in luci.util.kspairs(ast.voicemail.boxes()) do %>
                                                                <% if not boxes_used[box.id] then %>
                                                                        <option value="<%=box.id%>"><%=box.id%> (<%=box.name%>)</option>
                                                                <% end %>