2 Copyright 2011 Iordan Iordanov <iiordanov (AT) gmail.com>
4 This file is part of luci-pbx-voicemail.
6 luci-pbx-voicemail 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-voicemail 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-voicemail. 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-voicemail"
29 vmlogfile = "/tmp/last_sent_voicemail.log"
31 m = Map (modulename, translate("Voicemail Setup"),
32 translate("Here you can configure a global voicemail for this PBX. Since this system is \
33 intended to run on embedded systems like routers, there is no local storage of voicemail - \
34 it must be sent out by email. Therefore you need to configure an outgoing mail (SMTP) server \
35 (for example the SMTP server your ISP provides, or GMail), and provide a list of addresses the \
36 voicemail will be sent to."))
38 -- Recreate the config, and restart services after changes are commited to the configuration.
39 function m.on_after_commit(self)
40 luci.sys.call("/etc/init.d/pbx-" .. server .. " restart 1\>/dev/null 2\>/dev/null")
41 luci.sys.call("/etc/init.d/" .. server .. " restart 1\>/dev/null 2\>/dev/null")
45 ----------------------------------------------------------------------------------------------------
46 s = m:section(NamedSection, "global_voicemail", "voicemail", translate("Global Voicemail Setup"),
47 translate("When you enable voicemail, you will have the opportunity to specify \
48 email addresses which receive the message. You must also set up an SMTP server below."))
51 enable = s:option(ListValue, "enabled", translate("Enabled"))
52 enable:value("yes", translate("Yes"))
53 enable:value("no", translate("No"))
56 emails = s:option(DynamicList, "global_email_addresses",
57 translate("Email addresses to forward voicemail to"))
58 emails:depends("enabled", "yes")
60 savepath = s:option(Value, "global_save_path", translate("Directory to save voicemail into"),
61 translate("You can also retain copies of voicemail messages on the device running \
62 your PBX. The path specified here will be created if it doesn't exist. \
63 Beware of limited space on embedded devices like routers, and enable this \
64 option only if you know what you are doing."))
65 savepath.optional = true
67 if nixio.fs.access("/etc/pbx-voicemail/greeting.WAV") then
68 m1 = s:option(DummyValue, "_m1")
69 m1:depends("enabled", "yes")
70 m1.default = "NOTE: Found a voicemail greeting. To check or change your voicemail greeting, dial *789 \
71 and the system will play your current message. You have 5 seconds to hangup, otherwise a \
72 new recording will begin and your old message will be overwritten. Hang up or press # to \
73 stop recording. When you press #, the system will play back the new recording."
75 m1 = s:option(DummyValue, "_m1")
76 m1:depends("enabled", "yes")
77 m1.default = "WARNING: Could not find voicemail greeting. Callers will hear only a beep before \
78 recording starts. To record a greeting, dial *789 and record a greeting after the beep. \
79 Hang up or press # to stop recording. When # is pressed the system will play back the \
84 ----------------------------------------------------------------------------------------------------
85 s = m:section(NamedSection, "voicemail_smtp", "voicemail", translate("Outgoing mail (SMTP) Server"),
86 translate("In order for this PBX to send emails containing voicemail recordings, you need to \
87 set up an SMTP server here. Your ISP usually provides an SMTP server for that purpose. \
88 You can also set up a GMail, Yahoo, or other 3rd party SMTP server."))
91 serv = s:option(Value, "smtp_server", translate("SMTP server hostname or IP address"))
92 serv.datatype = "host"
94 port = s:option(Value, "smtp_port", translate("SMTP port number"))
95 port.datatype = "port"
98 tls = s:option(ListValue, "smtp_tls", translate("Secure connection using TLS"))
99 tls:value("on", translate("Yes"))
100 tls:value("off", translate("No"))
103 auth = s:option(ListValue, "smtp_auth", translate("SMTP server authentication"))
104 auth:value("on", translate("Yes"))
105 auth:value("off", translate("No"))
108 user = s:option(Value, "smtp_user", translate("SMTP user name"))
109 user:depends("smtp_auth", "on")
111 pwd = s:option(Value, "smtp_password", translate("SMTP Password"),
112 translate("Your real SMTP password is not shown for your protection. It will be changed \
113 only when you change the value in this box."))
115 pwd:depends("smtp_auth", "on")
117 -- We skip reading off the saved value and return nothing.
118 function pwd.cfgvalue(self, section)
119 return "Password Not Displayed"
122 -- We check the entered value against the saved one, and only write if the entered value is
123 -- something other than the empty string, and it differes from the saved value.
124 function pwd.write(self, section, value)
125 local orig_pwd = m:get(section, self.option)
126 if value == "Password Not Displayed" then value = "" end
127 if value and #value > 0 and orig_pwd ~= value then
128 Value.write(self, section, value)
132 ----------------------------------------------------------------------------------------------------
133 s = m:section(NamedSection, "voicemail_log", "voicemail",
134 translate("Last Sent Voicemail Log"))
137 s:option (DummyValue, "vmlog")
139 sts = s:option(DummyValue, "_sts")
140 sts.template = "cbi/tvalue"
143 function sts.cfgvalue(self, section)
144 log = nixio.fs.readfile(vmlogfile)
145 if log == nil or log == "" then
146 log = "No errors or messages reported."