2 Copyright 2011 Iordan Iordanov <iiordanov (AT) gmail.com>
4 This file is part of luci-pbx.
6 luci-pbx is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 luci-pbx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with luci-pbx. If not, see <http://www.gnu.org/licenses/>.
20 if nixio.fs.access("/etc/init.d/asterisk") then
22 elseif nixio.fs.access("/etc/init.d/freeswitch") then
28 modulename = "pbx-users"
29 modulenamecalls = "pbx-calls"
30 modulenameadvanced = "pbx-advanced"
33 m = Map (modulename, translate("User Accounts"),
34 translate("Here you must configure at least one SIP account, which you \
35 will use to register with this service. Use this account either in an analog telephony \
36 adapter (ATA), or in a SIP softphone like CSipSimple, Linphone, or Sipdroid on your \
37 Android smartphone, or X-lite or Ekiga on your computer. By default, all SIP accounts \
38 will ring simultaneously if a call is made to one of your VoIP provider accounts or GV \
41 -- Recreate the config, and restart services after changes are commited to the configuration.
42 function m.on_after_commit(self)
43 luci.sys.call("/etc/init.d/pbx-" .. server .. " restart 1\>/dev/null 2\>/dev/null")
44 luci.sys.call("/etc/init.d/" .. server .. " restart 1\>/dev/null 2\>/dev/null")
47 externhost = m.uci:get(modulenameadvanced, "advanced", "externhost")
48 bindport = m.uci:get(modulenameadvanced, "advanced", "bindport")
49 ipaddr = m.uci:get("network", "lan", "ipaddr")
51 -----------------------------------------------------------------------------
52 s = m:section(NamedSection, "server", "user", translate("Server Setting"))
55 if ipaddr == nil or ipaddr == "" then
56 ipaddr = "(IP address not static)"
59 if bindport ~= nil then
61 ipaddr = ipaddr .. ":" .. bindport
64 s:option(DummyValue, "ipaddr", translate("Server Setting for Local SIP Devices"),
65 translate("Enter this IP (or IP:port) in the Server/Registrar setting of SIP devices you will \
66 use ONLY locally and never from a remote location.")).default = ipaddr
68 if externhost ~= nil then
69 if bindport ~= nil then
70 just_externhost = externhost
71 externhost = externhost .. ":" .. bindport
73 s:option(DummyValue, "externhost", translate("Server Setting for Remote SIP Devices"),
74 translate("Enter this hostname (or hostname:port) in the Server/Registrar setting of SIP \
75 devices you will use from a remote location (they will work locally too).")
76 ).default = externhost
79 if bindport ~= nil then
80 s:option(DummyValue, "bindport", translate("Port Setting for SIP Devices"),
81 translatef("If setting Server/Registrar to %s or %s does not work for you, try setting \
82 it to %s or %s and entering this port number in a separate field which specifies the \
83 Server/Registrar port number. Beware that some devices have a confusing \
84 setting which sets the port where SIP requests originate from on the SIP \
85 device itself (bind port). The port specified on this page is NOT this bind port \
86 but the this service listens on.",
87 ipaddr, externhost, just_ipaddr, just_externhost)).default = bindport
90 -----------------------------------------------------------------------------
91 s = m:section(TypedSection, "local_user", translate("SIP Device/Softphone Accounts"))
95 s:option(Value, "fullname", translate("Full Name"),
96 translate("You can specify a real name to show up in the Caller ID here."))
98 du = s:option(Value, "defaultuser", translate("User Name"),
99 translate("Use (four to five digit) numeric user name if you are connecting normal telephones \
100 with ATAs to this system (so they can dial user names)."))
101 du.datatype = "uciname"
103 pwd = s:option(Value, "secret", translate("Password"),
104 translate("Your password disappears when saved for your protection. It will be changed \
105 only when you enter a value different from the saved one."))
109 -- We skip reading off the saved value and return nothing.
110 function pwd.cfgvalue(self, section)
114 -- We check the entered value against the saved one, and only write if the entered value is
115 -- something other than the empty string, and it differes from the saved value.
116 function pwd.write(self, section, value)
117 local orig_pwd = m:get(section, self.option)
118 if value and #value > 0 and orig_pwd ~= value then
119 Value.write(self, section, value)
123 p = s:option(ListValue, "ring", translate("Receives Incoming Calls"))
124 p:value("yes", translate("Yes"))
125 p:value("no", translate("No"))
128 p = s:option(ListValue, "can_call", translate("Makes Outgoing Calls"))
129 p:value("yes", translate("Yes"))
130 p:value("no", translate("No"))