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", "asterisk", "")
21 cbimap.uci:foreach("asterisk", "sip",
23 if s.type == "peer" then
25 s.info = ast.sip.peer(s.name)
31 sip_table = cbimap:section(Table, sip_peers, "SIP Trunks")
32 sip_table.template = "cbi/tblsection"
33 sip_table.extedit = luci.dispatcher.build_url("admin", "asterisk", "trunks", "sip", "%s")
35 name = sip_table:option(DummyValue, "name")
36 user = sip_table:option(DummyValue, "username")
38 host = sip_table:option(DummyValue, "host")
39 function host.cfgvalue(self, s)
40 if sip_peers[s].info.address then
41 return "%s:%i" %{ sip_peers[s].info.address, sip_peers[s].info.port }
47 context = sip_table:option(DummyValue, "context")
48 context.href = luci.dispatcher.build_url("admin", "asterisk", "dialplan")
50 nat = sip_table:option(DummyValue, "nat")
51 function nat.cfgvalue(self, s)
52 return sip_peers[s].info.Nat or "none"
55 online = sip_table:option(DummyValue, "online")
56 function online.cfgvalue(self, s)
57 if sip_peers[s].info.online == nil then
60 return sip_peers[s].info.online and "yes" or "no"
64 delay = sip_table:option(DummyValue, "delay")
65 function delay.cfgvalue(self, s)
66 if sip_peers[s].info.online then
67 return "%i ms" % sip_peers[s].info.delay