diff options
author | spag <spag@golwen.net> | 2013-01-10 16:41:05 +0100 |
---|---|---|
committer | spag <spag@golwen.net> | 2013-01-10 16:41:05 +0100 |
commit | e8f75901658a648f2cc4e95f49d76f89afceeb33 (patch) | |
tree | f49f2fec97eda163f8a0499820f8807db0359d82 | |
parent | 7326afdd65ae58c7158249c9ea73eaf0db16bbd3 (diff) |
generic tags added
-rw-r--r-- | misc/freeswitch/scripts/configuration/freeswitch_xml.lua | 38 |
1 files changed, 20 insertions, 18 deletions
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 .. '</' .. tostring(arg._name) .. '>'; 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 |