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 cbimap = Map("asterisk", "Registered Trunks")
19 cbimap.pageaction = false
22 cbimap.uci:foreach("asterisk", "sip",
24 if s.type == "peer" then
26 s.info = ast.sip.peer(s.name)
32 sip_table = cbimap:section(TypedSection, "sip", "SIP Trunks")
33 sip_table.template = "cbi/tblsection"
34 sip_table.extedit = luci.dispatcher.build_url("admin", "asterisk", "trunks", "sip", "%s")
35 sip_table.addremove = true
36 sip_table.sectionhead = "Extension"
38 function sip_table.filter(self, s)
40 cbimap.uci:get("asterisk", s, "type") == nil or
41 cbimap.uci:get_bool("asterisk", s, "provider")
45 function sip_table.create(self, section)
46 if TypedSection.create(self, section) then
49 self.invalid_cts = true
53 function sip_table.parse(self, ...)
54 TypedSection.parse(self, ...)
56 cbimap.uci:tset("asterisk", created, {
62 cbimap.uci:save("asterisk")
63 luci.http.redirect(luci.dispatcher.build_url(
64 "admin", "asterisk", "trunks", "sip", created
70 user = sip_table:option(DummyValue, "username", "Username")
72 host = sip_table:option(DummyValue, "host", "Hostname")
73 function host.cfgvalue(self, s)
74 if sip_peers[s] and sip_peers[s].info.address then
75 return "%s:%i" %{ sip_peers[s].info.address, sip_peers[s].info.port }
81 context = sip_table:option(DummyValue, "context", "Dialplan")
82 context.href = luci.dispatcher.build_url("admin", "asterisk", "dialplan")
83 function context.cfgvalue(...)
84 return AbstractValue.cfgvalue(...) or "(default)"
87 online = sip_table:option(DummyValue, "online", "Registered")
88 function online.cfgvalue(self, s)
89 if sip_peers[s] and sip_peers[s].info.online == nil then
92 return sip_peers[s] and sip_peers[s].info.online
93 and "yes" or "no (%s)" %{
94 sip_peers[s] and sip_peers[s].info.Status:lower() or "unknown"
99 delay = sip_table:option(DummyValue, "delay", "Delay")
100 function delay.cfgvalue(self, s)
101 if sip_peers[s] and sip_peers[s].info.online then
102 return "%i ms" % sip_peers[s].info.delay
108 info = sip_table:option(Button, "_info", "Info")
109 function info.write(self, s)
110 luci.http.redirect(luci.dispatcher.build_url(
111 "admin", "asterisk", "trunks", "sip", s, "info"