From a93f71d0c74c51ef744ed9a0b7152ca20160420e Mon Sep 17 00:00:00 2001 From: spag Date: Wed, 9 Jan 2013 12:40:36 +0100 Subject: db based configuration --- misc/freeswitch/scripts/configuration/freeswitch_xml.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'misc/freeswitch/scripts/configuration/freeswitch_xml.lua') diff --git a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua b/misc/freeswitch/scripts/configuration/freeswitch_xml.lua index c81bf50..5f4602c 100644 --- a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua +++ b/misc/freeswitch/scripts/configuration/freeswitch_xml.lua @@ -13,11 +13,11 @@ function FreeSwitchXml.new(self, object) end function FreeSwitchXml.param(self, name, value) - return '' + return '' end function FreeSwitchXml.variable(self, name, value) - return '' + return '' end function FreeSwitchXml.document(self, sections_xml) @@ -78,9 +78,8 @@ function FreeSwitchXml.group_default(self, entries_xml) return xml_string end -function FreeSwitchXml.user(self, user) - require 'common.configuration_file' - local params = common.configuration_file.get('/opt/freeswitch/scripts/ini/sip_accounts.ini', 'parameters'); +function FreeSwitchXml.user(self, user, params) + params = params or {}; params['password'] = user.password; params['vm-password'] = user.voicemail_pin; -- cgit v1.2.3 From edd484c7936db3995e0e8e2bd93b6115aa7554fa Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 10 Jan 2013 10:03:08 +0100 Subject: method generic added --- .../scripts/configuration/freeswitch_xml.lua | 50 +++++++++++++++------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'misc/freeswitch/scripts/configuration/freeswitch_xml.lua') 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 '' -end - -function FreeSwitchXml.variable(self, name, value) - return '' +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) ]] 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 = +[[ +
+ +<]] .. tostring(params_tag) .. [[> +]] .. table.concat(params_xml, "\n") .. [[ + + + +
]] + return xml_string +end -- cgit v1.2.3 From 64011eee947e3719dfce524b5c2bae2f8bed4e88 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 10 Jan 2013 13:09:53 +0100 Subject: generic tag method added --- .../scripts/configuration/freeswitch_xml.lua | 35 ++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'misc/freeswitch/scripts/configuration/freeswitch_xml.lua') diff --git a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua b/misc/freeswitch/scripts/configuration/freeswitch_xml.lua index 3da76df..65e7998 100644 --- a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua +++ b/misc/freeswitch/scripts/configuration/freeswitch_xml.lua @@ -12,8 +12,19 @@ function FreeSwitchXml.new(self, object) return object end -function FreeSwitchXml.nv_tag(self, name, value, tag) - return '<' .. tostring(tag) .. ' name="' .. tostring(name) .. '" value="' .. tostring(value) .. '"/>' +function FreeSwitchXml.to_tag(self, arg) + if not arg.tag_name then + return ''; + end + + local xml_tag = '<' .. tostring(arg.tag_name); + for key, value in pairs(arg) do + if tostring(key) ~= 'tag_name' then + xml_tag = xml_tag .. ' ' .. tostring(key) .. '="' .. tostring(value) .. '"'; + end + end + + return xml_tag .. '/>'; end function FreeSwitchXml.document(self, sections_xml) @@ -94,12 +105,12 @@ function FreeSwitchXml.user(self, user, params) local params_xml = {} for name, value in pairs(params) do - params_xml[#params_xml+1] = self:nv_tag(name, value, 'param') + params_xml[#params_xml+1] = self:to_tag{ tag_name = 'param', name = name, value = value }; end local variables_xml = {} for name, value in pairs(variables) do - variables_xml[#variables_xml+1] = self:nv_tag(name, value, 'variable') + variables_xml[#variables_xml+1] = self:to_tag{ tag_name = 'variable', name = name, value = value }; end local xml_string = @@ -133,12 +144,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:nv_tag(name, value, 'param') + params_xml[#params_xml+1] = self:to_tag{ tag_name = 'param', name = name, value = value }; end local variables_xml = {} for name, value in pairs(variables) do - variables_xml[#variables_xml+1] = self:nv_tag(name, value, 'variable') + variables_xml[#variables_xml+1] = self:to_tag{ tag_name = 'variable', name = name, value = value }; end local xml_string = @@ -165,7 +176,7 @@ function FreeSwitchXml.sofia(self, parameters, profiles_xml) local params_xml = {} for name, value in pairs(parameters) do - params_xml[#params_xml+1] = self:nv_tag(name, value, 'param') + params_xml[#params_xml+1] = self:to_tag{ tag_name = 'param', name = name, value = value }; end local xml_string = @@ -188,7 +199,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:nv_tag(name, value, 'param') + params_xml[#params_xml+1] = self:to_tag{ tag_name = 'param', name = name, value = value }; end if type(gateways_xml) == "string" then @@ -221,7 +232,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:nv_tag(name, value, 'param') + params_xml[#params_xml+1] = self:to_tag{ tag_name = 'param', name = name, value = value }; end end @@ -234,7 +245,7 @@ function FreeSwitchXml.gateway(self, gateway_name, parameters) return xml_string end -function FreeSwitchXml.conference(self, profiles_xml) +function FreeSwitchXml.conference(self, profiles_xml, speaker, moderator) if type(profiles_xml) == "string" then profiles_xml = { profiles_xml } elseif type(profiles_xml) == "nil" then @@ -289,7 +300,7 @@ end function FreeSwitchXml.conference_profile(self, profile_name, parameters) local params_xml = {} for name, value in pairs(parameters) do - params_xml[#params_xml+1] = self:nv_tag(name, value, 'param') + params_xml[#params_xml+1] = self:to_tag{ tag_name = 'param', name = name, value = value }; end local xml_string = @@ -308,7 +319,7 @@ function FreeSwitchXml.generic(self, arg) if arg.parameters then for name, value in pairs(arg.parameters) do - params_xml[#params_xml+1] = self:nv_tag(name, value, parameter_tag) + params_xml[#params_xml+1] = self:to_tag{ tag_name = parameter_tag, name = name, value = value }; end end -- cgit v1.2.3 From 44059b1cb8348c2ee24e056f81c3380abd55096d Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 10 Jan 2013 14:22:49 +0100 Subject: read conference controls from database --- .../scripts/configuration/freeswitch_xml.lua | 42 ++++++++++------------ 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'misc/freeswitch/scripts/configuration/freeswitch_xml.lua') diff --git a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua b/misc/freeswitch/scripts/configuration/freeswitch_xml.lua index 65e7998..09472bf 100644 --- a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua +++ b/misc/freeswitch/scripts/configuration/freeswitch_xml.lua @@ -252,6 +252,20 @@ function FreeSwitchXml.conference(self, profiles_xml, speaker, moderator) profiles_xml = { "" } end + local speaker_xml = {} + if speaker then + for name, value in pairs(speaker) do + speaker_xml[#speaker_xml+1] = self:to_tag{ tag_name = 'control', action = name, digits = value }; + end + end + + local moderator_xml = {} + if moderator then + for name, value in pairs(speaker) do + moderator_xml[#moderator_xml+1] = self:to_tag{ tag_name = 'control', action = name, digits = value }; + end + end + local xml_string = [[
@@ -260,32 +274,12 @@ function FreeSwitchXml.conference(self, profiles_xml, speaker, moderator) - - - - - - - - - - - - +]] .. table.concat(speaker_xml, "\n") .. [[ + - - - - - - - - - - - - +]] .. table.concat(moderator_xml, "\n") .. [[ + -- cgit v1.2.3 From e8f75901658a648f2cc4e95f49d76f89afceeb33 Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 10 Jan 2013 16:41:05 +0100 Subject: generic tags added --- .../scripts/configuration/freeswitch_xml.lua | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'misc/freeswitch/scripts/configuration/freeswitch_xml.lua') diff --git a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua b/misc/freeswitch/scripts/configuration/freeswitch_xml.lua index 09472bf..53ecccf 100644 --- a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua +++ b/misc/freeswitch/scripts/configuration/freeswitch_xml.lua @@ -12,19 +12,21 @@ function FreeSwitchXml.new(self, object) return object end -function FreeSwitchXml.to_tag(self, arg) - if not arg.tag_name then - return ''; - end - local xml_tag = '<' .. tostring(arg.tag_name); +function FreeSwitchXml.tag(self, arg) + local xml_tag = '<' .. tostring(arg._name); for key, value in pairs(arg) do - if tostring(key) ~= 'tag_name' then + if tostring(key) ~= '_name' and tostring(key) ~= '_data' then xml_tag = xml_tag .. ' ' .. tostring(key) .. '="' .. tostring(value) .. '"'; end end + xml_tag = xml_tag .. '>'; + + if arg._data then + xml_tag = xml_tag .. '\n' .. tostring(arg._data) .. '\n'; + end - return xml_tag .. '/>'; + return xml_tag .. ''; end function FreeSwitchXml.document(self, sections_xml) @@ -105,12 +107,12 @@ function FreeSwitchXml.user(self, user, params) local params_xml = {} for name, value in pairs(params) do - params_xml[#params_xml+1] = self:to_tag{ tag_name = 'param', name = name, value = value }; + params_xml[#params_xml+1] = self:tag{ _name = 'param', name = name, value = value }; end local variables_xml = {} for name, value in pairs(variables) do - variables_xml[#variables_xml+1] = self:to_tag{ tag_name = 'variable', name = name, value = value }; + variables_xml[#variables_xml+1] = self:tag{ _name = 'variable', name = name, value = value }; end local xml_string = @@ -144,12 +146,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:to_tag{ tag_name = 'param', name = name, value = value }; + params_xml[#params_xml+1] = self:tag{ _name = 'param', name = name, value = value }; end local variables_xml = {} for name, value in pairs(variables) do - variables_xml[#variables_xml+1] = self:to_tag{ tag_name = 'variable', name = name, value = value }; + variables_xml[#variables_xml+1] = self:tag{ _name = 'variable', name = name, value = value }; end local xml_string = @@ -176,7 +178,7 @@ function FreeSwitchXml.sofia(self, parameters, profiles_xml) local params_xml = {} for name, value in pairs(parameters) do - params_xml[#params_xml+1] = self:to_tag{ tag_name = 'param', name = name, value = value }; + params_xml[#params_xml+1] = self:tag{ _name = 'param', name = name, value = value }; end local xml_string = @@ -199,7 +201,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:to_tag{ tag_name = 'param', name = name, value = value }; + params_xml[#params_xml+1] = self:tag{ _name = 'param', name = name, value = value }; end if type(gateways_xml) == "string" then @@ -232,7 +234,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:to_tag{ tag_name = 'param', name = name, value = value }; + params_xml[#params_xml+1] = self:tag{ _name = 'param', name = name, value = value }; end end @@ -255,14 +257,14 @@ function FreeSwitchXml.conference(self, profiles_xml, speaker, moderator) local speaker_xml = {} if speaker then for name, value in pairs(speaker) do - speaker_xml[#speaker_xml+1] = self:to_tag{ tag_name = 'control', action = name, digits = value }; + speaker_xml[#speaker_xml+1] = self:tag{ _name = 'control', action = name, digits = value }; end end local moderator_xml = {} if moderator then for name, value in pairs(speaker) do - moderator_xml[#moderator_xml+1] = self:to_tag{ tag_name = 'control', action = name, digits = value }; + moderator_xml[#moderator_xml+1] = self:tag{ _name = 'control', action = name, digits = value }; end end @@ -294,7 +296,7 @@ end function FreeSwitchXml.conference_profile(self, profile_name, parameters) local params_xml = {} for name, value in pairs(parameters) do - params_xml[#params_xml+1] = self:to_tag{ tag_name = 'param', name = name, value = value }; + params_xml[#params_xml+1] = self:tag{ _name = 'param', name = name, value = value }; end local xml_string = @@ -313,7 +315,7 @@ function FreeSwitchXml.generic(self, arg) if arg.parameters then for name, value in pairs(arg.parameters) do - params_xml[#params_xml+1] = self:to_tag{ tag_name = parameter_tag, name = name, value = value }; + params_xml[#params_xml+1] = self:tag{ _name = parameter_tag, name = name, value = value }; end end -- cgit v1.2.3 From 697477cca48c8402c6d8e1df73d5c8c902c582ee Mon Sep 17 00:00:00 2001 From: spag Date: Fri, 11 Jan 2013 16:00:10 +0100 Subject: obsolete xml generator removed --- .../scripts/configuration/freeswitch_xml.lua | 333 --------------------- 1 file changed, 333 deletions(-) delete mode 100644 misc/freeswitch/scripts/configuration/freeswitch_xml.lua (limited to 'misc/freeswitch/scripts/configuration/freeswitch_xml.lua') diff --git a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua b/misc/freeswitch/scripts/configuration/freeswitch_xml.lua deleted file mode 100644 index 53ecccf..0000000 --- a/misc/freeswitch/scripts/configuration/freeswitch_xml.lua +++ /dev/null @@ -1,333 +0,0 @@ --- ConfigurationModule: FreeSwitchXml --- -module(...,package.seeall) - -FreeSwitchXml = {} - --- Create FreeSwitchXml object -function FreeSwitchXml.new(self, object) - object = object or {} - setmetatable(object, self) - self.__index = self - return object -end - - -function FreeSwitchXml.tag(self, arg) - local xml_tag = '<' .. tostring(arg._name); - for key, value in pairs(arg) do - if tostring(key) ~= '_name' and tostring(key) ~= '_data' then - xml_tag = xml_tag .. ' ' .. tostring(key) .. '="' .. tostring(value) .. '"'; - end - end - xml_tag = xml_tag .. '>'; - - if arg._data then - xml_tag = xml_tag .. '\n' .. tostring(arg._data) .. '\n'; - end - - return xml_tag .. ''; -end - -function FreeSwitchXml.document(self, sections_xml) - if type(sections_xml) == "string" then - sections_xml = { sections_xml } - elseif type(sections_xml) == "nil" then - sections_xml = { "" } - end - - local xml_string= -[[ - -]] .. table.concat(sections_xml, "\n") .. [[ - -]] - - return xml_string -end - -function FreeSwitchXml.directory(self, entries_xml, domain) - if type(entries_xml) == "string" then - entries_xml = { entries_xml } - elseif type(entries_xml) == "nil" then - entries_xml = { "" } - end - - local xml_string = -[[ -
- - - - -]] .. table.concat(entries_xml, "\n") .. [[ - - -
]] - return xml_string -end - -function FreeSwitchXml.group_default(self, entries_xml) - if type(entries_xml) == "string" then - entries_xml = { entries_xml } - elseif type(entries_xml) == "nil" then - entries_xml = { "" } - end - - local xml_string = -[[ - - - -]] .. table.concat(entries_xml, "\n") .. [[ - - - -]] - return xml_string -end - -function FreeSwitchXml.user(self, user, params) - params = params or {}; - - params['password'] = user.password; - params['vm-password'] = user.voicemail_pin; - - local variables = { - user_context = "default", - gs_from_gateway = "false", - gs_account_id = user.id, - gs_account_uuid = user.uuid, - gs_account_type = "SipAccount", - gs_account_state = user.state, - gs_account_caller_name = user.caller_name, - gs_account_owner_type = user.sip_accountable_type, - gs_account_owner_id = user.sip_accountable_id - } - - local params_xml = {} - for name, value in pairs(params) do - params_xml[#params_xml+1] = self:tag{ _name = 'param', name = name, value = value }; - end - - local variables_xml = {} - for name, value in pairs(variables) do - variables_xml[#variables_xml+1] = self:tag{ _name = 'variable', name = name, value = value }; - end - - local xml_string = -[[ - - -]] .. table.concat(params_xml, "\n") .. [[ - - - -]] .. table.concat(variables_xml, "\n") .. [[ - - -]] - return xml_string -end - -function FreeSwitchXml.gateway_user(self, user, gateway_name, auth_name) - user.id = user.id or 0 - - local params = { - ['password'] = user.password, - } - - local variables = { - user_context = "default", - gs_from_gateway = "true", - gs_gateway_name = gateway_name, - gs_gateway_id = user.id - } - - local params_xml = {} - for name, value in pairs(params) do - params_xml[#params_xml+1] = self:tag{ _name = 'param', name = name, value = value }; - end - - local variables_xml = {} - for name, value in pairs(variables) do - variables_xml[#variables_xml+1] = self:tag{ _name = 'variable', name = name, value = value }; - end - - local xml_string = -[[ - - -]] .. table.concat(params_xml, "\n") .. [[ - - - -]] .. table.concat(variables_xml, "\n") .. [[ - - -]] - return xml_string -end - -function FreeSwitchXml.sofia(self, parameters, profiles_xml) - if type(profiles_xml) == "string" then - profiles_xml = { profiles_xml } - elseif type(profiles_xml) == "nil" then - profiles_xml = { "" } - end - - local params_xml = {} - for name, value in pairs(parameters) do - params_xml[#params_xml+1] = self:tag{ _name = 'param', name = name, value = value }; - end - - local xml_string = -[[ -
- - -]] .. table.concat(params_xml, "\n") .. [[ - - - -]] .. table.concat(profiles_xml, "\n") .. [[ - - - -
]] - return xml_string -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:tag{ _name = 'param', name = name, value = value }; - end - - if type(gateways_xml) == "string" then - gateways_xml = { gateways_xml } - elseif type(gateways_xml) == "nil" then - gateways_xml = { "" } - end - - local xml_string = -[[ - - - - -]] .. table.concat(gateways_xml, "\n") .. [[ - - - - - - -]] .. table.concat(params_xml, "\n") .. [[ - - -]] - return xml_string -end - -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:tag{ _name = 'param', name = name, value = value }; - end - end - - local xml_string = -[[ - -]] .. table.concat(params_xml, "\n") .. [[ - -]] - return xml_string -end - -function FreeSwitchXml.conference(self, profiles_xml, speaker, moderator) - if type(profiles_xml) == "string" then - profiles_xml = { profiles_xml } - elseif type(profiles_xml) == "nil" then - profiles_xml = { "" } - end - - local speaker_xml = {} - if speaker then - for name, value in pairs(speaker) do - speaker_xml[#speaker_xml+1] = self:tag{ _name = 'control', action = name, digits = value }; - end - end - - local moderator_xml = {} - if moderator then - for name, value in pairs(speaker) do - moderator_xml[#moderator_xml+1] = self:tag{ _name = 'control', action = name, digits = value }; - end - end - - local xml_string = -[[ -
- - - - - -]] .. table.concat(speaker_xml, "\n") .. [[ - - - -]] .. table.concat(moderator_xml, "\n") .. [[ - - - - -]] .. table.concat(profiles_xml, "\n") .. [[ - - - -
]] - return xml_string -end - -function FreeSwitchXml.conference_profile(self, profile_name, parameters) - local params_xml = {} - for name, value in pairs(parameters) do - params_xml[#params_xml+1] = self:tag{ _name = 'param', name = name, value = value }; - end - - local xml_string = -[[ - -]] .. table.concat(params_xml, "\n") .. [[ - -]] - 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:tag{ _name = parameter_tag, name = name, value = value }; - end - end - - local xml_string = -[[ -
- -<]] .. tostring(params_tag) .. [[> -]] .. table.concat(params_xml, "\n") .. [[ - - - -
]] - return xml_string -end -- cgit v1.2.3