diff options
-rw-r--r-- | app/controllers/config_snom_controller.rb | 47 | ||||
-rw-r--r-- | app/models/fax_document.rb | 4 | ||||
-rw-r--r-- | app/models/sip_account.rb | 4 | ||||
-rw-r--r-- | app/models/softkey.rb | 8 | ||||
-rw-r--r-- | app/views/config_snom/show.xml.haml | 4 | ||||
-rw-r--r-- | config/schedule.rb | 25 | ||||
-rw-r--r-- | db/migrate/20130213082703_add_language_to_sip_account.rb | 5 | ||||
-rw-r--r-- | db/migrate/20130213110000_add_sounds_to_parameters.rb | 10 | ||||
-rw-r--r-- | misc/freeswitch/conf/freeswitch.xml | 95 | ||||
-rw-r--r-- | misc/freeswitch/scripts/common/conference.lua | 11 | ||||
-rw-r--r-- | misc/freeswitch/scripts/common/sip_account.lua | 1 | ||||
-rw-r--r-- | misc/freeswitch/scripts/dialplan/dialplan.lua | 12 |
12 files changed, 164 insertions, 62 deletions
diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 58cced2..d36f990 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -282,28 +282,31 @@ class ConfigSnomController < ApplicationController @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "speed f-li-#{softkey.number}"}) when 'conference' @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "blf <sip:#{softkey.number}@#{sip_account.host}>|f-ta-"}) - when 'call_parking' - @softkeys.push({ - :context => sip_account_index, - :function => softkey.softkey_function.name, - :label => softkey.label, - :softkey => softkey, - :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"), - :subscription => { - :to => "park+#{@softkeys.softkeyable_id}@#{sip_account.host}", - :for => "#{sip_account.auth_name}@#{sip_account.host}" - }, - :actions => [{ - :type => :dial, - :target => "f-tpark-#{@softkeys.softkeyable_id}", - :when => 'on press', - :states => 'connected,holding', - },{ - :type => :dial, - :target => "f-park-#{@softkeys.softkeyable_id}", - :when => 'on press', - }], - }) + when 'parking_stall' + parking_stall = softkey.softkeyable + if parking_stall.class == ParkingStall + @softkeys.push({ + :context => sip_account_index, + :function => softkey.softkey_function.name, + :label => softkey.label, + :softkey => softkey, + :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"), + :subscription => { + :to => "park+#{parking_stall.name}@#{sip_account.host}", + :for => "#{sip_account.auth_name}@#{sip_account.host}" + }, + :actions => [{ + :type => :dial, + :target => "f-cpa-#{parking_stall.name}", + :when => 'on press', + :states => 'connected,holding', + },{ + :type => :dial, + :target => "f-cpa-#{parking_stall.name}", + :when => 'on press', + }], + }) + end when 'call_forwarding' if softkey.softkeyable.class == CallForward then @softkeys.push({ diff --git a/app/models/fax_document.rb b/app/models/fax_document.rb index be689e2..16fdc70 100644 --- a/app/models/fax_document.rb +++ b/app/models/fax_document.rb @@ -48,10 +48,6 @@ class FaxDocument < ActiveRecord::Base end end - def to_s - name - end - def render_thumbnails directory = "/tmp/GS-#{GsParameter.get('GEMEINSCHAFT_VERSION')}/fax_thumbnails/#{self.id}" system('mkdir -p ' + directory) diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index 9ba1f8b..7df8e3b 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -6,7 +6,7 @@ class SipAccount < ActiveRecord::Base attr_accessible :auth_name, :caller_name, :password, :voicemail_pin, :tenant_id, :call_waiting, :clir, :clip_no_screening, :clip, :description, :callforward_rules_act_per_sip_account, - :hotdeskable, :gs_node_id + :hotdeskable, :gs_node_id, :language_code # Associations: # @@ -31,6 +31,8 @@ class SipAccount < ActiveRecord::Base belongs_to :gs_node + belongs_to :language, :foreign_key => 'language_code', :primary_key => 'code' + # Delegations: # delegate :host, :to => :sip_domain, :allow_nil => true diff --git a/app/models/softkey.rb b/app/models/softkey.rb index 83c88ab..4b758e0 100644 --- a/app/models/softkey.rb +++ b/app/models/softkey.rb @@ -48,14 +48,14 @@ class Softkey < ActiveRecord::Base end def to_s - if (['call_forwarding'].include?(self.softkey_function.name)) - "#{self.softkeyable}" - else + if self.softkeyable.blank? if ['log_out', 'log_in'].include?(self.softkey_function.name) I18n.t("softkeys.functions.#{self.softkey_function.name}") else - "#{self.softkey_function.name} : #{self.number.to_s}" + "#{self.softkey_function.name} : #{self.number.to_s}" end + else + "#{self.softkeyable}" end end diff --git a/app/views/config_snom/show.xml.haml b/app/views/config_snom/show.xml.haml index 33204dc..1102ad1 100644 --- a/app/views/config_snom/show.xml.haml +++ b/app/views/config_snom/show.xml.haml @@ -176,7 +176,9 @@ %action - softkey[:actions].each do |action| - if action[:type] == :url - %url{:target => action[:target], :when => action[:when]} + %url{:target => action[:target], :when => action[:when], :states => action[:states]} + - elsif action[:type] == :dial + %dial{:target => action[:target], :when => action[:when], :states => action[:states], :request_uri => '$(remote_uri)'} %uploads - if @state_settings_url diff --git a/config/schedule.rb b/config/schedule.rb index 0b5f0ca..94603f1 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -1,24 +1,13 @@ -# Use this file to easily define all of your cron jobs. +# Daily Backup # -# It's helpful, but not entirely necessary to understand cron before proceeding. -# http://en.wikipedia.org/wiki/Cron - -# Example: -# -# set :output, "/path/to/my/cron_log.log" -# -# every 2.hours do -# command "/usr/bin/some_great_command" -# runner "MyModel.some_method" -# rake "some:great:rake:task" -# end -# -# every 4.days do -# runner "AnotherModel.prune_old_records" -# end - every 1.day, :at => '4:00 am' do rake "backup:daily_backup" end +# Auto-Reboot of Phones which should be rebootet +# +every 1.day, :at => '2:30 am' do + command "/opt/GS5/script/logout_phones.sh" +end + # Learn more: http://github.com/javan/whenever diff --git a/db/migrate/20130213082703_add_language_to_sip_account.rb b/db/migrate/20130213082703_add_language_to_sip_account.rb new file mode 100644 index 0000000..24343ef --- /dev/null +++ b/db/migrate/20130213082703_add_language_to_sip_account.rb @@ -0,0 +1,5 @@ +class AddLanguageToSipAccount < ActiveRecord::Migration + def change + add_column :sip_accounts, :language_code, :string + end +end diff --git a/db/migrate/20130213110000_add_sounds_to_parameters.rb b/db/migrate/20130213110000_add_sounds_to_parameters.rb new file mode 100644 index 0000000..8c4cd94 --- /dev/null +++ b/db/migrate/20130213110000_add_sounds_to_parameters.rb @@ -0,0 +1,10 @@ +class AddSoundsToParameters < ActiveRecord::Migration + def up + GsParameter.create(:entity => 'dialplan', :section => 'sounds', :name => 'en', :value => '/opt/freeswitch/sounds/en/us/callie', :class_type => 'String') + GsParameter.create(:entity => 'dialplan', :section => 'sounds', :name => 'de', :value => '/opt/freeswitch/sounds/de/de/callie', :class_type => 'String') + end + + def down + GsParameter.where(:entity => 'dialplan', :section => 'sounds').destroy_all + end +end diff --git a/misc/freeswitch/conf/freeswitch.xml b/misc/freeswitch/conf/freeswitch.xml index a5fe873..4969b07 100644 --- a/misc/freeswitch/conf/freeswitch.xml +++ b/misc/freeswitch/conf/freeswitch.xml @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <document type="freeswitch/xml"> - <X-PRE-PROCESS cmd="set" data="sound_prefix=/opt/freeswitch/sounds/en/us/callie"/> <section name="languages" description="Language Management"> - <language name="en" say-module="en" sound-prefix="/opt/freeswitch/sounds/en/us/callie"> + <language name="en" say-module="en"> <phrases> <macros> <macro name="voicemail_hello"> @@ -463,10 +462,55 @@ </match> </input> </macro> + <macro name="conference_welcome"> + <input pattern="^(.*)$"> + <match> + <action function="play-file" data="conference/conf-welcome.wav"/> + </match> + </input> + </macro> + <macro name="conference_goodbye"> + <input pattern="^(.*)$"> + <match> + <action function="play-file" data="conference/conf-goodbye.wav"/> + </match> + </input> + </macro> + <macro name="conference_bad_pin"> + <input pattern="^(.*)$"> + <match> + <action function="play-file" data="conference/conf-bad-pin.wav"/> + </match> + </input> + </macro> + <macro name="conference_record_name"> + <input pattern="^(.*)$"> + <match> + <action function="play-file" data="voicemail/vm-record_name1.wav"/> + <action function="play-file" data="tone_stream://%(1000,0,500)"/> + </match> + </input> + </macro> + <macro name="conference_has_joined"> + <input pattern="^(.+)$"> + <match> + <action function="play-file" data="$1"/> + <action function="play-file" data="conference/conf-has_joined.wav"/> + </match> + </input> + </macro> + <macro name="conference_has_left"> + <input pattern="^(.+)$"> + <match> + <action function="play-file" data="$1"/> + <action function="play-file" data="conference/conf-has_left.wav"/> + </match> + </input> + </macro> </macros> </phrases> </language> - <language name="de" say-module="de" sound-prefix="/opt/freeswitch/sounds/de/de/callie"> + <language name="de" say-module="de"> <phrases> <macros> <macro name="voicemail_hello"> @@ -927,6 +971,51 @@ </match> </input> </macro> + <macro name="conference_welcome"> + <input pattern="^(.*)$"> + <match> + <action function="play-file" data="conference/conf-welcome.wav"/> + </match> + </input> + </macro> + <macro name="conference_goodbye"> + <input pattern="^(.*)$"> + <match> + <action function="play-file" data="conference/conf-goodbye.wav"/> + </match> + </input> + </macro> + <macro name="conference_bad_pin"> + <input pattern="^(.*)$"> + <match> + <action function="play-file" data="conference/conf-bad-pin.wav"/> + </match> + </input> + </macro> + <macro name="conference_record_name"> + <input pattern="^(.*)$"> + <match> + <action function="play-file" data="voicemail/vm-record_name1.wav"/> + <action function="play-file" data="tone_stream://%(1000,0,500)"/> + </match> + </input> + </macro> + <macro name="conference_has_joined"> + <input pattern="^(.+)$"> + <match> + <action function="play-file" data="$1"/> + <action function="play-file" data="conference/conf-has_joined.wav"/> + </match> + </input> + </macro> + <macro name="conference_has_left"> + <input pattern="^(.+)$"> + <match> + <action function="play-file" data="$1"/> + <action function="play-file" data="conference/conf-has_left.wav"/> + </match> + </input> + </macro> </macros> </phrases> </language> diff --git a/misc/freeswitch/scripts/common/conference.lua b/misc/freeswitch/scripts/common/conference.lua index ca5fa62..f6a4d87 100644 --- a/misc/freeswitch/scripts/common/conference.lua +++ b/misc/freeswitch/scripts/common/conference.lua @@ -157,7 +157,7 @@ function Conference.enter(self, caller, domain) caller:answer(); caller:sleep(1000); - caller.session:streamFile('conference/conf-welcome.wav'); + caller.session:sayPhrase('conference_welcome'); if pin and pin ~= "" then local digits = ""; @@ -165,12 +165,12 @@ function Conference.enter(self, caller, domain) if digits == pin then break elseif digits ~= "" then - caller.session:streamFile('conference/conf-bad-pin.wav'); + caller.session:sayPhrase('conference_bad_pin'); end digits = caller.session:read(PIN_LENGTH_MIN, PIN_LENGTH_MAX, 'conference/conf-enter_conf_pin.wav', PIN_TIMEOUT, '#'); end if digits ~= pin then - caller.session:streamFile("conference/conf-goodbye.wav"); + caller.session:sayPhrase('conference_goodbye'); return "CALL_REJECTED"; end end @@ -192,8 +192,7 @@ function Conference.enter(self, caller, domain) if common.str.to_b(self.record.announce_new_member_by_name) or common.str.to_b(self.record.announce_left_member_by_name) then local uid = session:get_uuid(); name_file = "/tmp/conference_caller_name_" .. uid .. ".wav"; - caller.session:streamFile("voicemail/vm-record_name1.wav"); - caller.session:execute("playback", "tone_stream://%(1000,0,500)"); + caller.session:sayPhrase('conference_record_name'); session:recordFile(name_file, ANNOUNCEMENT_MAX_LEN, ANNOUNCEMENT_SILENCE_THRESHOLD, ANNOUNCEMENT_SILENCE_LEN); caller.session:streamFile(name_file); end @@ -209,7 +208,7 @@ function Conference.enter(self, caller, domain) local result = caller.session:execute('conference', self.record.id .. "@profile_" .. self.record.id .. "++flags{" .. table.concat(flags, '|') .. "}"); self.log:debug('exited conference - result: ' .. tostring(result)); - caller.session:streamFile("conference/conf-goodbye.wav") + caller.session:sayPhrase('conference_goodbye'); -- Play leaving caller's name if recorded if name_file then diff --git a/misc/freeswitch/scripts/common/sip_account.lua b/misc/freeswitch/scripts/common/sip_account.lua index d023f20..5b1ea56 100644 --- a/misc/freeswitch/scripts/common/sip_account.lua +++ b/misc/freeswitch/scripts/common/sip_account.lua @@ -38,6 +38,7 @@ function SipAccount.find_by_sql(self, where) `a`.`sip_accountable_id`, \ `a`.`hotdeskable`, \ `a`.`gs_node_id`, \ + `a`.`language_code`, \ `b`.`host`, \ `c`.`sip_host`, \ `c`.`profile_name` \ diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua index 72503e5..b27bb9d 100644 --- a/misc/freeswitch/scripts/dialplan/dialplan.lua +++ b/misc/freeswitch/scripts/dialplan/dialplan.lua @@ -270,7 +270,10 @@ function Dialplan.retrieve_caller_data(self) for index, caller_number in ipairs(self.caller.caller_phone_numbers) do self.caller.caller_phone_numbers_hash[caller_number] = true; end - self.log:info('CALLER_DATA - caller account: ', self.caller.account.class, '=', self.caller.account.id, '/', self.caller.account.uuid, ', phone_numbers: ', #self.caller.caller_phone_numbers); + if not common.str.blank(self.caller.account.record.language_code) then + self.caller.language = self.caller.account.record.language_code; + end + self.log:info('CALLER_DATA - caller account: ', self.caller.account.class, '=', self.caller.account.id, '/', self.caller.account.uuid, ', phone_numbers: ', #self.caller.caller_phone_numbers, ', language: ', self.caller.language); if self.caller.account.owner then self.log:info('CALLER_DATA - caller owner: ', self.caller.account.owner.class, '=', self.caller.account.owner.id, '/', self.caller.account.owner.uuid); else @@ -859,7 +862,6 @@ function Dialplan.run(self, destination) self.caller:set_variable('hangup_after_bridge', false); self.caller:set_variable('bridge_early_media', 'true'); - self.caller:set_variable('default_language', self.default_language); self.caller:set_variable('gs_save_cdr', true); self.caller:set_variable('gs_call_service', 'dial'); self.caller.session:setAutoHangup(false); @@ -876,6 +878,8 @@ function Dialplan.run(self, destination) self:retrieve_caller_data(); self.route_failover = common.configuration_table.get(self.database, 'call_route', 'failover'); + self.caller.language = self.caller.language or self.default_language; + if not destination or destination.type == 'unknown' then local route = nil; if self.caller.gateway then @@ -937,7 +941,9 @@ function Dialplan.run(self, destination) end end - self.log:info('DIALPLAN start - caller_id: ',self.caller.caller_id_number, ' "', self.caller.caller_id_name, '" , number: ', destination.number); + self.caller:set_variable('default_language', self.caller.language); + self.caller:set_variable('sound_prefix', common.str.try(self.config, 'sounds.' .. tostring(self.caller.language))); + self.log:info('DIALPLAN start - caller_id: ',self.caller.caller_id_number, ' "', self.caller.caller_id_name, '" , number: ', destination.number, ', language: ', self.caller.language); local result = { continue = false }; local loop = self.caller.loop_count; |