summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/migrate/20130109090000_populate_gs_parameter_with_dialplan_defaults.rb42
-rw-r--r--db/migrate/20130110133500_set_voicemail_parameters.rb45
-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
5 files changed, 136 insertions, 49 deletions
diff --git a/db/migrate/20130109090000_populate_gs_parameter_with_dialplan_defaults.rb b/db/migrate/20130109090000_populate_gs_parameter_with_dialplan_defaults.rb
index 12ac63c..fe1cdae 100644
--- a/db/migrate/20130109090000_populate_gs_parameter_with_dialplan_defaults.rb
+++ b/db/migrate/20130109090000_populate_gs_parameter_with_dialplan_defaults.rb
@@ -73,28 +73,28 @@ class PopulateGsParameterWithDialplanDefaults < ActiveRecord::Migration
GsParameter.create(:entity => 'perimeter', :section => 'general', :name => 'execute', :value => 'sudo /usr/local/bin/ban_ip.sh {ip_address}', :class_type => 'String')
# conferences defaults
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'caller-controls ', :value => 'speaker', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'caller-controls', :value => 'speaker', :class_type => 'String')
GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'moderator-controls', :value => 'moderator', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'max-members ', :value => 100, :class_type => 'Integer')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'rate ', :value => 16000, :class_type => 'Integer')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'interval ', :value => 20, :class_type => 'Integer')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'energy-level ', :value => 300, :class_type => 'Integer')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'sound-prefix ', :value => '/opt/freeswitch/sounds/en/us/callie', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'muted-sound ', :value => 'conference/conf-muted.wav', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'unmuted-sound ', :value => 'conference/conf-unmuted.wav', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'alone-sound ', :value => 'conference/conf-alone.wav', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'moh-sound ', :value => 'local_stream://moh', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'enter-sound ', :value => 'tone_stream://%(200,0,500,600,700)', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'exit-sound ', :value => 'tone_stream://%(500,0,300,200,100,50,25)', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'kicked-sound ', :value => 'conference/conf-kicked.wav', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'locked-sound ', :value => 'conference/conf-locked.wav', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'is-locked-sound ', :value => 'conference/conf-is-locked.wav', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'is-unlocked-sound ', :value => 'conference/conf-is-unlocked.wav', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'pin-sound ', :value => 'conference/conf-pin.wav', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'bad-pin-sound ', :value => 'conference/conf-bad-pin.wav', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'caller-id-name ', :value => 'Conference', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'caller-id-number ', :value => '', :class_type => 'String')
- GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'comfort-noise ', :value => 'true', :class_type => 'Boolean')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'max-members', :value => 100, :class_type => 'Integer')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'rate', :value => 16000, :class_type => 'Integer')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'interval', :value => 20, :class_type => 'Integer')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'energy-level', :value => 300, :class_type => 'Integer')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'sound-prefix', :value => '/opt/freeswitch/sounds/en/us/callie', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'muted-sound', :value => 'conference/conf-muted.wav', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'unmuted-sound', :value => 'conference/conf-unmuted.wav', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'alone-sound', :value => 'conference/conf-alone.wav', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'moh-sound', :value => 'local_stream://moh', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'enter-sound', :value => 'tone_stream://%(200,0,500,600,700)', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'exit-sound', :value => 'tone_stream://%(500,0,300,200,100,50,25)', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'kicked-sound', :value => 'conference/conf-kicked.wav', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'locked-sound', :value => 'conference/conf-locked.wav', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'is-locked-sound', :value => 'conference/conf-is-locked.wav', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'is-unlocked-sound', :value => 'conference/conf-is-unlocked.wav', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'pin-sound', :value => 'conference/conf-pin.wav', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'bad-pin-sound', :value => 'conference/conf-bad-pin.wav', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'caller-id-name', :value => 'Conference', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'caller-id-number', :value => '', :class_type => 'String')
+ GsParameter.create(:entity => 'conferences', :section => 'parameters', :name => 'comfort-noise', :value => 'true', :class_type => 'Boolean')
#dialplan defaults
GsParameter.create(:entity => 'dialplan', :section => 'parameters', :name => 'node_id', :value => 1, :class_type => 'Integer')
diff --git a/db/migrate/20130110133500_set_voicemail_parameters.rb b/db/migrate/20130110133500_set_voicemail_parameters.rb
new file mode 100644
index 0000000..3e7c192
--- /dev/null
+++ b/db/migrate/20130110133500_set_voicemail_parameters.rb
@@ -0,0 +1,45 @@
+class SetVoicemailParameters < ActiveRecord::Migration
+ def up
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'file-extension', :value => 'wav', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'terminator-key', :value => '#', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'max-login-attempts', :value => '3', :class_type => 'Integer')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'digit-timeout', :value => '10000', :class_type => 'Integer')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'min-record-len', :value => '3', :class_type => 'Integer')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'max-record-len', :value => '300', :class_type => 'Integer')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'max-retries', :value => '3', :class_type => 'Integer')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'tone-spec', :value => '%(1000, 0, 640)', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'callback-dialplan', :value => 'XML', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'callback-context', :value => 'default', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'play-new-messages-key', :value => '1', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'play-saved-messages-key', :value => '2', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'login-keys', :value => '0', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'main-menu-key', :value => '0', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'config-menu-key', :value => '5', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'record-greeting-key', :value => '1', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'choose-greeting-key', :value => '2', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'change-pass-key', :value => '6', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'record-name-key', :value => '3', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'record-file-key', :value => '3', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'listen-file-key', :value => '1', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'save-file-key', :value => '2', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'delete-file-key', :value => '7', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'undelete-file-key', :value => '8', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'email-key', :value => '4', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'pause-key', :value => '0', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'restart-key', :value => '1', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'ff-key', :value => '6', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'rew-key', :value => '4', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'skip-greet-key', :value => '#', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'record-silence-threshold', :value => '200', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'record-silence-hits', :value => '2', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'operator-extension', :value => 'operator XML default', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'operator-key', :value => '9', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'vmain-extension', :value => 'vmain XML default', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'vmain-key', :value => '*', :class_type => 'String')
+ GsParameter.create(:entity => 'voicemail', :section => 'parameters', :name => 'odbc-dsn', :value => 'default', :class_type => 'String')
+ end
+
+ def down
+ GsParameter.where(:entity => 'voicemail', :section => 'parameters').destroy_all
+ end
+end
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