2 LuCI - Lua Configuration Interface
4 Copyright 2008 Jo-Philipp Wich <xm@subsignal.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
16 local ast = require("luci.asterisk")
18 local function find_outgoing_contexts(uci)
22 -- uci:foreach("asterisk", "dialplan",
24 -- if not h[s['.name']] then
25 -- c[#c+1] = { s['.name'], "Dialplan: %s" % s['.name'] }
26 -- h[s['.name']] = true
30 uci:foreach("asterisk", "dialzone",
32 if not h[s['.name']] then
33 c[#c+1] = { s['.name'], "Dialzone: %s" % s['.name'] }
41 local function find_incoming_contexts(uci)
45 uci:foreach("asterisk", "sip",
47 if s.context and not h[s.context] and
48 uci:get_bool("asterisk", s['.name'], "provider")
50 c[#c+1] = { s.context, "Incoming: %s" % s['.name'] or s.context }
58 local function find_trunks(uci)
61 uci:foreach("asterisk", "sip",
63 if uci:get_bool("asterisk", s['.name'], "provider") then
65 "SIP/%s" % s['.name'],
66 "SIP: %s" % s['.name']
71 uci:foreach("asterisk", "iax",
74 "IAX/%s" % s['.name'],
75 "IAX: %s" % s.extension or s['.name']
84 dialzone {name} - Outgoing zone.
85 uses - Outgoing line to use: TYPE/Name
86 match (list) - Number to match
87 countrycode - The effective country code of this dialzone
88 international (list) - International prefix to match
89 localzone - dialzone for local numbers
90 addprefix - Prexix required to dial out.
91 localprefix - Prefix for a local call
97 -- SIP dialzone configuration
100 cbimap = Map("asterisk", "Edit Dialplan Entry")
102 entry = cbimap:section(NamedSection, arg[1])
104 back = entry:option(DummyValue, "_overview", "Back to dialplan overview")
106 back.titleref = luci.dispatcher.build_url("admin", "asterisk", "dialplans")
108 desc = entry:option(Value, "description", "Description")
109 function desc.cfgvalue(self, s, ...)
110 return Value.cfgvalue(self, s, ...) or s
113 match = entry:option(DynamicList, "match", "Number matches")
115 intl = entry:option(DynamicList, "international", "Intl. prefix matches (optional)")
117 trunk = entry:option(MultiValue, "uses", "Used trunk")
118 for _, v in ipairs(find_trunks(cbimap.uci)) do
119 trunk:value(unpack(v))
122 aprefix = entry:option(Value, "addprefix", "Add prefix to dial out (optional)")
123 --ast.idd.cbifill(aprefix)
125 ccode = entry:option(Value, "countrycode", "Effective countrycode (optional)")
126 ast.cc.cbifill(ccode)
128 lzone = entry:option(ListValue, "localzone", "Dialzone for local numbers")
129 lzone:value("", "no special treatment of local numbers")
130 for _, v in ipairs(find_outgoing_contexts(cbimap.uci)) do
131 lzone:value(unpack(v))
134 lprefix = entry:option(Value, "localprefix", "Prefix for local calls (optional)")