1 -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
4 local ast = require("luci.asterisk")
6 local function find_outgoing_contexts(uci)
10 -- uci:foreach("asterisk", "dialplan",
12 -- if not h[s['.name']] then
13 -- c[#c+1] = { s['.name'], "Dialplan: %s" % s['.name'] }
14 -- h[s['.name']] = true
18 uci:foreach("asterisk", "dialzone",
20 if not h[s['.name']] then
21 c[#c+1] = { s['.name'], "Dialzone: %s" % s['.name'] }
29 local function find_incoming_contexts(uci)
33 uci:foreach("asterisk", "sip",
35 if s.context and not h[s.context] and
36 uci:get_bool("asterisk", s['.name'], "provider")
38 c[#c+1] = { s.context, "Incoming: %s" % s['.name'] or s.context }
46 local function find_trunks(uci)
49 uci:foreach("asterisk", "sip",
51 if uci:get_bool("asterisk", s['.name'], "provider") then
53 "SIP/%s" % s['.name'],
54 "SIP: %s" % s['.name']
59 uci:foreach("asterisk", "iax",
62 "IAX/%s" % s['.name'],
63 "IAX: %s" % s.extension or s['.name']
72 dialzone {name} - Outgoing zone.
73 uses - Outgoing line to use: TYPE/Name
74 match (list) - Number to match
75 countrycode - The effective country code of this dialzone
76 international (list) - International prefix to match
77 localzone - dialzone for local numbers
78 addprefix - Prexix required to dial out.
79 localprefix - Prefix for a local call
85 -- SIP dialzone configuration
88 cbimap = Map("asterisk", "Edit Dialplan Entry")
90 entry = cbimap:section(NamedSection, arg[1])
92 back = entry:option(DummyValue, "_overview", "Back to dialplan overview")
94 back.titleref = luci.dispatcher.build_url("admin", "asterisk", "dialplans")
96 desc = entry:option(Value, "description", "Description")
97 function desc.cfgvalue(self, s, ...)
98 return Value.cfgvalue(self, s, ...) or s
101 match = entry:option(DynamicList, "match", "Number matches")
103 intl = entry:option(DynamicList, "international", "Intl. prefix matches (optional)")
105 trunk = entry:option(MultiValue, "uses", "Used trunk")
106 for _, v in ipairs(find_trunks(cbimap.uci)) do
107 trunk:value(unpack(v))
110 aprefix = entry:option(Value, "addprefix", "Add prefix to dial out (optional)")
111 --ast.idd.cbifill(aprefix)
113 ccode = entry:option(Value, "countrycode", "Effective countrycode (optional)")
114 ast.cc.cbifill(ccode)
116 lzone = entry:option(ListValue, "localzone", "Dialzone for local numbers")
117 lzone:value("", "no special treatment of local numbers")
118 for _, v in ipairs(find_outgoing_contexts(cbimap.uci)) do
119 lzone:value(unpack(v))
122 lprefix = entry:option(Value, "localprefix", "Prefix for local calls (optional)")