summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-10 21:59:10 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-10 21:59:10 +0100
commit48accca73c9564bd2ee8bd296d47eb5c27dbcd51 (patch)
tree9b3a41fa814fdc1746f70a6c6c196331134f2e99 /misc
parent878412b12dd34004d37b8b79945786e506f8fa08 (diff)
parent213eccb7678e74a5c06e6f9ff5ba3bad2dd90b3c (diff)
Merge branch 'develop' of github.com:amooma/GS5 into develop
Diffstat (limited to 'misc')
-rw-r--r--misc/freeswitch/scripts/common/configuration_table.lua19
-rw-r--r--misc/freeswitch/scripts/configuration.lua41
-rw-r--r--misc/freeswitch/scripts/configuration/freeswitch_xml.lua38
3 files changed, 70 insertions, 28 deletions
diff --git a/misc/freeswitch/scripts/common/configuration_table.lua b/misc/freeswitch/scripts/common/configuration_table.lua
index 731bf2f..85bc014 100644
--- a/misc/freeswitch/scripts/common/configuration_table.lua
+++ b/misc/freeswitch/scripts/common/configuration_table.lua
@@ -21,17 +21,20 @@ function get(database, entity, section)
local parameter_class = '';
database:query(sql_query, function(parameters)
- if not root[parameters.section] then
- root[parameters.section] = {};
+ local p_section = common.str.strip(parameters.section):lower();
+ local p_class_type = common.str.strip(parameters.class_type):lower();
+ local p_name = common.str.strip(parameters.name);
+
+ if not root[p_section] then
+ root[p_section] = {};
end
- parameter_class = tostring(parameters.class_type):lower();
- if parameter_class == 'boolean' then
- root[parameters.section][parameters.name] = common.str.to_b(parameters.value);
- elseif parameter_class == 'integer' then
- root[parameters.section][parameters.name] = common.str.to_i(parameters.value);
+ if p_class_type == 'boolean' then
+ root[p_section][p_name] = common.str.to_b(parameters.value);
+ elseif p_class_type == 'integer' then
+ root[p_section][p_name] = common.str.to_i(parameters.value);
else
- root[parameters.section][parameters.name] = tostring(parameters.value);
+ root[p_section][p_name] = tostring(parameters.value);
end
end)
diff --git a/misc/freeswitch/scripts/configuration.lua b/misc/freeswitch/scripts/configuration.lua
index 0cd3752..ec5099e 100644
--- a/misc/freeswitch/scripts/configuration.lua
+++ b/misc/freeswitch/scripts/configuration.lua
@@ -98,9 +98,9 @@ end
function conf_conference(database)
require 'common.configuration_table'
- XML_STRING = xml:document(xml:conference());
-
+
local config = common.configuration_table.get(database, 'conferences');
+ XML_STRING = xml:document(xml:conference(nil, config.controls_speaker, config.controls_moderator));
local event_name = params:getHeader("Event-Name")
if event_name == 'COMMAND' then
@@ -125,6 +125,41 @@ function conf_conference(database)
end
end
+function conf_voicemail(database)
+ require 'common.configuration_table';
+ local parameters = common.configuration_table.get(database, 'voicemail', 'parameters');
+
+ if tostring(parameters['odbc-dsn']) == 'default' then
+ parameters['odbc-dsn'] = 'gemeinschaft:' .. tostring(database.user_name) .. ':' .. tostring(database.password);
+ end
+
+ local params_xml = {};
+ for name, value in pairs(parameters) do
+ params_xml[#params_xml+1] = xml:tag{ _name = 'param', name = name, value = value };
+ end
+
+ XML_STRING = xml:document(
+ xml:tag{
+ _name = 'section',
+ name = 'configuration',
+ description = 'Gemeinschaft 5 FreeSWITCH configuration',
+ _data = xml:tag{
+ _name = 'configuration',
+ name = 'voicemail.conf',
+ description = 'Voicemail configuration',
+ _data = xml:tag{
+ _name = 'profiles',
+ _data = xml:tag{
+ _name = 'profile',
+ name = 'default',
+ _data = table.concat(params_xml, '\n'),
+ },
+ },
+ },
+ }
+ );
+end
+
function conf_post_switch(database)
require 'common.configuration_table';
local parameters = common.configuration_table.get(database, 'post_load_switch', 'settings');
@@ -220,6 +255,8 @@ if XML_REQUEST.section == 'configuration' and XML_REQUEST.tag_name == 'configura
conf_sofia(database);
elseif XML_REQUEST.key_value == "conference.conf" then
conf_conference(database);
+ elseif XML_REQUEST.key_value == "voicemail.conf" then
+ conf_voicemail(database);
elseif XML_REQUEST.key_value == "post_load_switch.conf" then
conf_post_switch(database);
end
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