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")
21 if arg[2] == "info" then
22 form = SimpleForm("asterisk", "SIP Phone Information")
24 form.submit = "Back to overview"
26 local info, keys = ast.sip.peer(arg[1])
29 for _, key in ipairs(keys) do
32 val = type(info[key]) == "boolean"
33 and ( info[key] and "yes" or "no" )
34 or ( info[key] == nil or #info[key] == 0 )
36 or tostring(info[key])
40 itbl = form:section(Table, data, "SIP Phone %q" % arg[1])
41 itbl:option(DummyValue, "key", "Key")
42 itbl:option(DummyValue, "val", "Value")
44 function itbl.parse(...)
46 luci.dispatcher.build_url("admin", "asterisk", "phones")
53 -- SIP phone configuration
56 cbimap = Map("asterisk", "Edit SIP Client")
58 peer = cbimap:section(NamedSection, arg[1])
67 back = peer:option(DummyValue, "_overview", "Back to phone overview")
69 back.titleref = luci.dispatcher.build_url("admin", "asterisk", "phones")
71 exten = peer:option(Value, "extension", "Extension Number")
72 cbimap.uci:foreach("asterisk", "dialplanexten",
76 "%s (via %s/%s)" %{ s.extension, s.type:upper(), s.target }
80 display = peer:option(Value, "callerid", "Display Name")
82 username = peer:option(Value, "username", "Authorization ID")
83 password = peer:option(Value, "secret", "Authorization Password")
84 password.password = true
86 active = peer:option(Flag, "disable", "Active")
87 active.enabled = "yes"
88 active.disabled = "no"
89 function active.cfgvalue(...)
90 return AbstractValue.cfgvalue(...) or "yes"
93 regtimeout = peer:option(Value, "registertimeout", "Registration Time Value")
94 function regtimeout.cfgvalue(...)
95 return AbstractValue.cfgvalue(...) or "60"
98 sipport = peer:option(Value, "port", "SIP Port")
99 function sipport.cfgvalue(...)
100 return AbstractValue.cfgvalue(...) or "5060"
103 linekey = peer:option(ListValue, "_linekey", "Linekey Mode (broken)")
104 linekey:value("", "Off")
105 linekey:value("trunk", "Trunk Appearance")
106 linekey:value("call", "Call Appearance")
108 dialplan = peer:option(ListValue, "context", "Dialplan Context")
109 cbimap.uci:foreach("asterisk", "dialplan",
110 function(s) dialplan:value(s['.name']) end)