summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/configuration
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-10 10:35:59 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-10 10:35:59 +0100
commitc0c87dc9a80d7bf7f6dd7a779a6519a0e1425c5c (patch)
treee70818437f487574f481ab8188377e85e18a2f96 /misc/freeswitch/scripts/configuration
parent70c436c52c76cf866b03fcab6bc43437c9490cd1 (diff)
parent120b8b444b10b0d42c9ddc773a48f3210f316e59 (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'misc/freeswitch/scripts/configuration')
-rw-r--r--misc/freeswitch/scripts/configuration/freeswitch_xml.lua50
1 files changed, 35 insertions, 15 deletions
diff --git a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua b/misc/freeswitch/scripts/configuration/freeswitch_xml.lua
index 5f4602c..3da76df 100644
--- a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua
+++ b/misc/freeswitch/scripts/configuration/freeswitch_xml.lua
@@ -12,12 +12,8 @@ function FreeSwitchXml.new(self, object)
return object
end
-function FreeSwitchXml.param(self, name, value)
- return '<param name="' .. tostring(name) .. '" value="' .. tostring(value) .. '"/>'
-end
-
-function FreeSwitchXml.variable(self, name, value)
- return '<variable name="' .. tostring(name) .. '" value="' .. tostring(value) .. '"/>'
+function FreeSwitchXml.nv_tag(self, name, value, tag)
+ return '<' .. tostring(tag) .. ' name="' .. tostring(name) .. '" value="' .. tostring(value) .. '"/>'
end
function FreeSwitchXml.document(self, sections_xml)
@@ -98,12 +94,12 @@ function FreeSwitchXml.user(self, user, params)
local params_xml = {}
for name, value in pairs(params) do
- params_xml[#params_xml+1] = self:param(name, value)
+ params_xml[#params_xml+1] = self:nv_tag(name, value, 'param')
end
local variables_xml = {}
for name, value in pairs(variables) do
- variables_xml[#variables_xml+1] = self:variable(name, value)
+ variables_xml[#variables_xml+1] = self:nv_tag(name, value, 'variable')
end
local xml_string =
@@ -137,12 +133,12 @@ function FreeSwitchXml.gateway_user(self, user, gateway_name, auth_name)
local params_xml = {}
for name, value in pairs(params) do
- params_xml[#params_xml+1] = self:param(name, value)
+ params_xml[#params_xml+1] = self:nv_tag(name, value, 'param')
end
local variables_xml = {}
for name, value in pairs(variables) do
- variables_xml[#variables_xml+1] = self:variable(name, value)
+ variables_xml[#variables_xml+1] = self:nv_tag(name, value, 'variable')
end
local xml_string =
@@ -169,7 +165,7 @@ function FreeSwitchXml.sofia(self, parameters, profiles_xml)
local params_xml = {}
for name, value in pairs(parameters) do
- params_xml[#params_xml+1] = self:param(name, value)
+ params_xml[#params_xml+1] = self:nv_tag(name, value, 'param')
end
local xml_string =
@@ -192,7 +188,7 @@ end
function FreeSwitchXml.sofia_profile(self, profile_name, parameters, gateways_xml)
params_xml = {}
for name, value in pairs(parameters) do
- params_xml[#params_xml+1] = self:param(name, value)
+ params_xml[#params_xml+1] = self:nv_tag(name, value, 'param')
end
if type(gateways_xml) == "string" then
@@ -225,7 +221,7 @@ function FreeSwitchXml.gateway(self, gateway_name, parameters)
local params_xml = {}
if parameters then
for name, value in pairs(parameters) do
- params_xml[#params_xml+1] = self:param(name, value)
+ params_xml[#params_xml+1] = self:nv_tag(name, value, 'param')
end
end
@@ -291,9 +287,9 @@ function FreeSwitchXml.conference(self, profiles_xml)
end
function FreeSwitchXml.conference_profile(self, profile_name, parameters)
- params_xml = {}
+ local params_xml = {}
for name, value in pairs(parameters) do
- params_xml[#params_xml+1] = self:param(name, value)
+ params_xml[#params_xml+1] = self:nv_tag(name, value, 'param')
end
local xml_string =
@@ -304,3 +300,27 @@ function FreeSwitchXml.conference_profile(self, profile_name, parameters)
</profile>]]
return xml_string
end
+
+function FreeSwitchXml.generic(self, arg)
+ local params_xml = arg.params_xml or {};
+ local params_tag = arg.params_tag or 'settings';
+ local parameter_tag = arg.parameter_tag or 'param';
+
+ if arg.parameters then
+ for name, value in pairs(arg.parameters) do
+ params_xml[#params_xml+1] = self:nv_tag(name, value, parameter_tag)
+ end
+ end
+
+ local xml_string =
+[[
+<section name="configuration" description="FreeSWITCH configuration">
+<configuration name="]] .. tostring(arg.name) .. [[" description="Created by FreeSwitchXml.generic">
+<]] .. tostring(params_tag) .. [[>
+]] .. table.concat(params_xml, "\n") .. [[
+
+</]] .. tostring(params_tag) .. [[>
+</configuration>
+</section>]]
+ return xml_string
+end