summaryrefslogtreecommitdiffstats
path: root/freeswitch-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-10-19 23:52:24 +0000
committerTed Trask <ttrask01@yahoo.com>2013-10-19 23:52:24 +0000
commitf047cc93b9c8ef2b81bc692af3a2868969992bdf (patch)
tree735a4e45bbdad5ce3fa93f3f73f58ccf466eac0b /freeswitch-model.lua
parent6ec8af74ad7e18d815888eb511c09802ffcd2ab4 (diff)
downloadacf-freeswitch-f047cc93b9c8ef2b81bc692af3a2868969992bdf.tar.bz2
acf-freeswitch-f047cc93b9c8ef2b81bc692af3a2868969992bdf.tar.xz
Remove all calls to 'module' in preparation for move to Lua 5.2
Use mymodule parameter for module definition. This was also helpful in revealing places where the code relied on the global environment.
Diffstat (limited to 'freeswitch-model.lua')
-rw-r--r--freeswitch-model.lua30
1 files changed, 16 insertions, 14 deletions
diff --git a/freeswitch-model.lua b/freeswitch-model.lua
index ffdc699..4e2b140 100644
--- a/freeswitch-model.lua
+++ b/freeswitch-model.lua
@@ -1,4 +1,4 @@
-module (..., package.seeall)
+local mymodule = {}
-- Load libraries
modelfunctions = require("modelfunctions")
@@ -23,33 +23,33 @@ end
-- ################################################################################
-- PUBLIC FUNCTIONS
-get_status = function()
+mymodule.get_status = function()
return modelfunctions.getstatus(processname, packagename, "Freeswitch Status")
end
-function get_startstop(self, clientdata)
+function mymodule.get_startstop(self, clientdata)
return modelfunctions.get_startstop(processname)
end
-function startstop_service(self, startstop, action)
+function mymodule.startstop_service(self, startstop, action)
return modelfunctions.startstop_service(startstop, action)
end
-function getreloadxml()
+function mymodule.getreloadxml()
return cfe({ type="group", value={}, label="Reload Freeswitch XML" })
end
-function reload_xml(self, relo)
+function mymodule.reload_xml(self, relo)
relo.descr, relo.errtxt = modelfunctions.run_executable({"fs_cli", "-x", "reloadxml"}, true)
return relo
end
-get_file = function(self, clientdata)
+mymodule.get_file = function(self, clientdata)
local filename = clientdata.filename
return modelfunctions.getfiledetails(filename, is_valid_filename)
end
-update_file = function(self, filedetails)
+mymodule.update_file = function(self, filedetails)
local ret = modelfunctions.setfiledetails(self, filedetails, is_valid_filename)
if not ret.errtxt then
posix.chmod(filedetails.value.filename.value, "rw-------")
@@ -58,7 +58,7 @@ update_file = function(self, filedetails)
return ret
end
-list_files = function()
+mymodule.list_files = function()
local retval = {}
for file in fs.find(null, baseurl) do
local details = fs.stat(file)
@@ -71,12 +71,12 @@ list_files = function()
return cfe({ type="structure", value=retval, label="List of Freeswitch files" })
end
-function getnewfile()
+function mymodule.getnewfile()
local filename = cfe({ label="File Name", descr="Must be in "..baseurl })
return cfe({ type="group", value={filename=filename}, label="Freeswitch File" })
end
-function createfile(self, filedetails)
+function mymodule.createfile(self, filedetails)
local success = true
local path = string.match(filedetails.value.filename.value, "^%s*(.*%S)%s*$") or ""
if not string.find(path, "/") then
@@ -103,15 +103,15 @@ function createfile(self, filedetails)
return filedetails
end
-function getdeletefile(self, clientdata)
+function mymodule.getdeletefile(self, clientdata)
local retval = {}
retval.filename = cfe({ label="File Name", value=clientdata.filename or "" })
return cfe({ type="group", value=retval, label="Delete Freeswitch File" })
end
-function deletefile(self, delfile)
+function mymodule.deletefile(self, delfile)
delfile.errtxt = "Failed to delete Freeswitch File - invalid filename"
- for i,file in ipairs(list_files().value) do
+ for i,file in ipairs(mymodule.list_files().value) do
if delfile.value.filename.value == file.filename then
delfile.errtxt = nil
os.remove(delfile.value.filename.value)
@@ -121,3 +121,5 @@ function deletefile(self, delfile)
return delfile
end
+
+return mymodule