summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--freeswitch-controller.lua20
-rw-r--r--freeswitch-model.lua30
2 files changed, 27 insertions, 23 deletions
diff --git a/freeswitch-controller.lua b/freeswitch-controller.lua
index 7f9d628..baf1b35 100644
--- a/freeswitch-controller.lua
+++ b/freeswitch-controller.lua
@@ -1,31 +1,33 @@
-module (..., package.seeall)
+local mymodule = {}
-default_action = "status"
+mymodule.default_action = "status"
-status = function( self )
+mymodule.status = function( self )
return self.model.get_status()
end
-startstop = function( self )
+mymodule.startstop = function( self )
return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata)
end
-listfiles = function( self )
+mymodule.listfiles = function( self )
return self.model.list_files()
end
-editfile = function( self )
+mymodule.editfile = function( self )
return self.handle_form(self, self.model.get_file, self.model.update_file, self.clientdata, "Save", "Edit File", "File Saved")
end
-function createfile(self)
+function mymodule.createfile(self)
return self.handle_form(self, self.model.getnewfile, self.model.createfile, self.clientdata, "Create", "Create New Freeswitch File", "Freeswitch File Created")
end
-function deletefile(self)
+function mymodule.deletefile(self)
return self.handle_form(self, self.model.getdeletefile, self.model.deletefile, self.clientdata, "Delete", "Delete Freeswitch File", "Freeswitch File Deleted")
end
-function reloadxml(self)
+function mymodule.reloadxml(self)
return self.handle_form(self, self.model.getreloadxml, self.model.reload_xml, self.clientdata, "Reload", "Reload Freeswitch XML")
end
+
+return mymodule
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