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")
22 cbimap = Map("asterisk", "Edit SIP Trunk")
24 peer = cbimap:section(NamedSection, arg[1], "Foo")
26 name = peer:option(DummyValue, "username")
28 outproxy = peer:option(Value, "outboundproxy")
37 cbimap = Map("asterisk", "asterisk", "")
40 cbimap.uci:foreach("asterisk", "sip",
42 if s.type == "peer" then
44 s.info = ast.sip.peer(s.name)
50 sip_table = cbimap:section(Table, sip_peers, "SIP Trunks")
51 sip_table.template = "cbi/tblsection"
52 sip_table.extedit = luci.dispatcher.build_url("admin", "asterisk", "trunks", "sip", "%s")
54 name = sip_table:option(DummyValue, "name")
55 user = sip_table:option(DummyValue, "username")
57 host = sip_table:option(DummyValue, "host")
58 function host.cfgvalue(self, s)
59 if sip_peers[s].info.address then
60 return "%s:%i" %{ sip_peers[s].info.address, sip_peers[s].info.port }
66 context = sip_table:option(DummyValue, "context")
67 context.href = luci.dispatcher.build_url("admin", "asterisk", "dialplan")
69 nat = sip_table:option(DummyValue, "nat")
70 function nat.cfgvalue(self, s)
71 return sip_peers[s].info.Nat or "none"
74 online = sip_table:option(DummyValue, "online")
75 function online.cfgvalue(self, s)
76 if sip_peers[s].info.online == nil then
79 return sip_peers[s].info.online and "yes" or "no"
83 delay = sip_table:option(DummyValue, "delay")
84 function delay.cfgvalue(self, s)
85 if sip_peers[s].info.online then
86 return "%i ms" % sip_peers[s].info.delay