diff options
author | Iordan Iordanov <iiordanov@gmail.com> | 2011-11-22 04:23:46 +0000 |
---|---|---|
committer | Iordan Iordanov <iiordanov@gmail.com> | 2011-11-22 04:23:46 +0000 |
commit | 15b17243b1b788fd98f9c49b10109a05c347ff86 (patch) | |
tree | 36f152ef85e14e49f60a7067716d5e2f83806d33 /applications/luci-pbx-voicemail/luasrc | |
parent | 6663c0a935684e7caabdbae17185ed056287038e (diff) |
1) Adding initial version of luci-pbx-voicemail package.
Diffstat (limited to 'applications/luci-pbx-voicemail/luasrc')
-rw-r--r-- | applications/luci-pbx-voicemail/luasrc/controller/pbx-voicemail.lua | 24 | ||||
-rw-r--r-- | applications/luci-pbx-voicemail/luasrc/model/cbi/pbx-voicemail.lua | 156 |
2 files changed, 180 insertions, 0 deletions
diff --git a/applications/luci-pbx-voicemail/luasrc/controller/pbx-voicemail.lua b/applications/luci-pbx-voicemail/luasrc/controller/pbx-voicemail.lua new file mode 100644 index 0000000000..6f3dfac05e --- /dev/null +++ b/applications/luci-pbx-voicemail/luasrc/controller/pbx-voicemail.lua @@ -0,0 +1,24 @@ +--[[ + Copyright 2011 Iordan Iordanov <iiordanov (AT) gmail.com> + + This file is part of luci-pbx-voicemail. + + luci-pbx-voicemail is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + luci-pbx-voicemail is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with luci-pbx-voicemail. If not, see <http://www.gnu.org/licenses/>. +]]-- + +module("luci.controller.pbx-voicemail", package.seeall) + +function index() + entry({"admin", "services", "pbx", "pbx-voicemail"}, cbi("pbx-voicemail"), "Voicemail", 5) +end diff --git a/applications/luci-pbx-voicemail/luasrc/model/cbi/pbx-voicemail.lua b/applications/luci-pbx-voicemail/luasrc/model/cbi/pbx-voicemail.lua new file mode 100644 index 0000000000..b79d5250f1 --- /dev/null +++ b/applications/luci-pbx-voicemail/luasrc/model/cbi/pbx-voicemail.lua @@ -0,0 +1,156 @@ +--[[ + Copyright 2011 Iordan Iordanov <iiordanov (AT) gmail.com> + + This file is part of luci-pbx-voicemail. + + luci-pbx-voicemail is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + luci-pbx-voicemail is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with luci-pbx-voicemail. If not, see <http://www.gnu.org/licenses/>. +]]-- + +if nixio.fs.access("/etc/init.d/asterisk") then + server = "asterisk" +elseif nixio.fs.access("/etc/init.d/freeswitch") then + server = "freeswitch" +else + server = "" +end + +modulename = "pbx-voicemail" +vmlogfile = "/tmp/last_sent_voicemail.log" + +m = Map (modulename, translate("Voicemail Setup"), + translate("Here you can configure a global voicemail for this PBX. Since this system is \ + intended to run on embedded systems like routers, there is no local storage of voicemail - \ + it must be sent out by email. Therefore you need to configure an outgoing mail (SMTP) server \ + (for example the SMTP server your ISP provides, or GMail), and provide a list of addresses the \ + voicemail will be sent to.")) + +-- Recreate the config, and restart services after changes are commited to the configuration. +function m.on_after_commit(self) + luci.sys.call("/etc/init.d/pbx-" .. server .. " restart 1\>/dev/null 2\>/dev/null") + luci.sys.call("/etc/init.d/" .. server .. " restart 1\>/dev/null 2\>/dev/null") +end + + +---------------------------------------------------------------------------------------------------- +s = m:section(NamedSection, "global_voicemail", "voicemail", translate("Global Voicemail Setup"), + translate("When you enable voicemail, you will have the opportunity to specify \ + email addresses which receive the message. You must also set up an SMTP server below.")) +s.anonymous = true + +enable = s:option(ListValue, "enabled", translate("Enabled")) +enable:value("yes", translate("Yes")) +enable:value("no", translate("No")) +enable.default = "no" + +timeout = s:option(Value, "global_timeout", + translate("Timeout before sending callers to voicemail")) +timeout:depends("enabled", "yes") +timeout.default = 30 + +emails = s:option(DynamicList, "global_email_addresses", + translate("Email addresses to forward to")) +emails:depends("enabled", "yes") + +savepath = s:option(Value, "global_save_path", translate("Directory to save voicemail into"), + translate("You can also retain copies of voicemail messages on the device running \ + your PBX. The path specified here will be created if it doesn't exist. \ + Beware of limited space on embedded devices like routers, and enable this \ + option only if you know what you are doing.")) +savepath.optional = true + +if nixio.fs.access("/etc/pbx-voicemail/greeting.WAV") then + m1 = s:option(DummyValue, "_m1") + m1:depends("enabled", "yes") + m1.default = "NOTE: Found a voicemail greeting. To check or change your voicemail greeting, dial *789 \ + and the system will play your current message. You have 5 seconds to hangup, otherwise a \ + new recording will begin and your old message will be overwritten. Hang up or press # to \ + stop recording. When you press #, the system will play back the new recording." +else + m1 = s:option(DummyValue, "_m1") + m1:depends("enabled", "yes") + m1.default = "WARNING: Could not find voicemail greeting. Callers will hear only a beep before \ + recording starts. To record a greeting, dial *789 and record a greeting after the beep. \ + Hang up or press # to stop recording. When # is pressed the system will play back the \ + recording." +end + + +---------------------------------------------------------------------------------------------------- +s = m:section(NamedSection, "voicemail_smtp", "voicemail", translate("Outgoing mail (SMTP) Server"), + translate("In order for this PBX to send emails containing voicemail recordings, you need to \ + set up an SMTP server here. Your ISP usually provides an SMTP server for that purpose. \ + You can also set up a GMail, Yahoo, or other 3rd party SMTP server.")) +s.anonymous = true + +serv = s:option(Value, "smtp_server", translate("SMTP server hostname or IP")) +serv.datatype = "host" + +port = s:option(Value, "smtp_port", translate("SMTP port number")) +port.datatype = "port" +port.default = "25" + +tls = s:option(ListValue, "smtp_tls", translate("Use TLS (secure connection)")) +tls:value("on", translate("Yes")) +tls:value("off", translate("No")) +tls.default = "on" + +auth = s:option(ListValue, "smtp_auth", translate("SMTP server authentication")) +auth:value("on", translate("Yes")) +auth:value("off", translate("No")) +auth.default = "on" + +user = s:option(Value, "smtp_user", translate("SMTP user name")) +user:depends("smtp_auth", "on") + +pwd = s:option(Value, "smtp_password", translate("SMTP Password"), + translate("Your real SMTP password is not shown for your protection. It will be changed \ + only when you change the value in this box.")) +pwd.password = true +pwd:depends("smtp_auth", "on") + +-- We skip reading off the saved value and return nothing. +function pwd.cfgvalue(self, section) + return "Password Not Displayed" +end + +-- We check the entered value against the saved one, and only write if the entered value is +-- something other than the empty string, and it differes from the saved value. +function pwd.write(self, section, value) + local orig_pwd = m:get(section, self.option) + if value == "Password Not Displayed" then value = "" end + if value and #value > 0 and orig_pwd ~= value then + Value.write(self, section, value) + end +end + +---------------------------------------------------------------------------------------------------- +s = m:section(NamedSection, "voicemail_log", "voicemail", + translate("Last Sent Voicemail Log")) +s.anonymous = true + +s:option (DummyValue, "vmlog") + +sts = s:option(DummyValue, "_sts") +sts.template = "cbi/tvalue" +sts.rows = 5 + +function sts.cfgvalue(self, section) + log = nixio.fs.readfile(vmlogfile) + if log == nil or log == "" then + log = "No errors or messages reported." + end + return log +end + +return m |