From 09f6490dc92d9685afa5f77563ea8c230c450211 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:34:21 +0100 Subject: subscribe to default voicemail account --- app/controllers/config_snom_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/controllers/config_snom_controller.rb') diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 8db1d57..b692693 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -260,9 +260,13 @@ class ConfigSnomController < ApplicationController :name => sip_account.auth_name, :realname => 'Call', :idle_text => sip_account.caller_name, - :mailbox => "", :expiry => expiry_seconds, } + + if sip_account.voicemail_account + snom_sip_account[:mailbox] = "" + end + @sip_accounts.push(snom_sip_account) sip_account_index = @sip_accounts.length sip_account.softkeys.order(:position).each do |softkey| -- cgit v1.2.3 From c5bfe11c01f2b3575ec96b6bd6f567976d93ff63 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 7 May 2013 12:58:01 +0200 Subject: support for additional provisioning parameters --- app/controllers/config_snom_controller.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'app/controllers/config_snom_controller.rb') diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index b692693..805f682 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -242,6 +242,7 @@ class ConfigSnomController < ApplicationController phone_sip_accounts = Array.new() if send_sensitve + phone_parameters = GsParameter.get_list('phones', 'snom') if @phone.sip_accounts && @phone.sip_accounts.count > 0 phone_sip_accounts = @phone.sip_accounts elsif @phone.fallback_sip_account @@ -250,6 +251,7 @@ class ConfigSnomController < ApplicationController expiry_seconds = GsParameter.get('SIP_EXPIRY_SECONDS') phone_sip_accounts.each do |sip_account| if (sip_account.sip_accountable_type == @phone.phoneable_type) and (sip_account.sip_accountable_id == @phone.phoneable_id) + snom_sip_account = { :id => sip_account.id, :active => 'on', @@ -259,7 +261,7 @@ class ConfigSnomController < ApplicationController :outbound => sip_account.host, :name => sip_account.auth_name, :realname => 'Call', - :idle_text => sip_account.caller_name, + :user_idle_text => sip_account.caller_name, :expiry => expiry_seconds, } @@ -267,6 +269,16 @@ class ConfigSnomController < ApplicationController snom_sip_account[:mailbox] = "" end + phone_parameters.each do |name, value| + snom_sip_account[name.to_sym] = value.gsub!(/\{([a-z0-9_\.]+)\}/) { |v| + source = sip_account + $1.split('.').each do |method| + source = source.send(method) if source.respond_to?(method) + end + source.to_s + } + end + @sip_accounts.push(snom_sip_account) sip_account_index = @sip_accounts.length sip_account.softkeys.order(:position).each do |softkey| -- cgit v1.2.3 From ea2a4bbe0fc05e175bb05b0b8cbf3a02f008c7f9 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 7 May 2013 14:42:14 +0200 Subject: voicemail menu added --- app/controllers/config_snom_controller.rb | 85 ++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 8 deletions(-) (limited to 'app/controllers/config_snom_controller.rb') diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 805f682..4b9489b 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -802,7 +802,7 @@ AAAA' @phone_xml_object = { :name => 'snom_phone_directory', - :title => "$(lang:menu100_phone_book) #{@dialpad_keys}".strip, + :title => "#{t('config_snom.phone_book.title')} #{@dialpad_keys}".strip, :entries => [], :softkeys => [], } @@ -865,7 +865,6 @@ AAAA' end def call_history - if ! @sip_account render( :status => 404, @@ -876,10 +875,10 @@ AAAA' return end - if ['dialed', 'missed', 'received'].include? @type + if ['dialed', 'missed', 'received', 'forwarded'].include? @type @phone_xml_object = { :name => "snom_phone_directory", - :title => "$(lang:menu100_call_lists) - #{@type.to_s.camelize}", + :title => "#{t('config_snom.call_history.title')} - #{@type.to_s.camelize}", :entries => [] } @@ -909,11 +908,81 @@ AAAA' base_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.split("?")[0]}" @phone_xml_object = { :name => 'snom_phone_menu', - :title => '$(lang:menu100_call_lists)', + :title => t('config_snom.call_history.title'), + :entries => [ + {:text => t('config_snom.call_history.missed'), :url => "#{base_url}?&type=missed", :selected => false}, + {:text => t('config_snom.call_history.received'), :url => "#{base_url}?&type=received", :selected => false}, + {:text => t('config_snom.call_history.dialed'), :url => "#{base_url}?&type=dialed", :selected => false}, + ] + } + end + + respond_to { |format| + format.any { + self.formats = [ :xml ] + render :action => "_#{@phone_xml_object[:name]}" + } + } + + end + + def voicemail + if ! @sip_account + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + return + end + + if !@sip_account.voicemail_account + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + return + end + + account = @sip_account.voicemail_account + + if ['read', 'unread'].include? @type + if @type == 'unread' + messages = account.voicemail_messages.where('read_epoch IS NULL OR read_epoch = 0') + elsif @type == 'read' + messages = account.voicemail_messages.where('read_epoch > 0') + end + @phone_xml_object = { + :name => "snom_phone_directory", + :title => t("config_snom.voicemail.#{@type}_count", :count => messages.count), + :entries => [] + } + messages.each do |message| + @phone_xml_object[:entries].push({ + :selected => false, + :number => "f-vmplay-#{message.uuid}", + :text => "#{call_date_compact(Time.at(message.created_epoch).to_datetime)} #{message.cid_name} #{message.cid_number}", + }) + end + elsif @type == 'settings' + base_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.split("?")[0]}" + @phone_xml_object = { + :name => 'snom_phone_menu', + :title => t('config_snom.voicemail_settings.title'), + :entries => [] + } + else + base_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.split("?")[0]}" + @phone_xml_object = { + :name => 'snom_phone_menu', + :title => account, :entries => [ - {:text => '$(lang:list_missed)', :url => "#{base_url}?&type=missed", :selected => false}, - {:text => '$(lang:list_taken)', :url => "#{base_url}?&type=received", :selected => false}, - {:text => '$(lang:list_dialed)', :url => "#{base_url}?&type=dialed", :selected => false}, + {:text => t('config_snom.voicemail.unread_count', :count => account.voicemail_messages.where('read_epoch IS NULL OR read_epoch = 0').count), :url => "#{base_url}?&type=unread", :selected => false}, + {:text => t('config_snom.voicemail.read_count', :count => account.voicemail_messages.where('read_epoch > 0').count), :url => "#{base_url}?&type=read", :selected => false}, + {:text => t('config_snom.voicemail.settings'), :url => "#{base_url}?&type=settings", :selected => false}, ] } end -- cgit v1.2.3