From 0a976c6b463288df4a9516bbd08f6232a37d427c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 26 Feb 2013 09:21:34 -0500 Subject: enable tel: handling for sip_accounts --- app/controllers/sip_accounts_controller.rb | 5 +++++ app/views/sip_accounts/show.html.haml | 4 ++++ config/locales/views/sip_accounts/de.yml | 2 ++ config/locales/views/sip_accounts/en.yml | 2 ++ config/routes.rb | 3 +++ 5 files changed, 16 insertions(+) diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index b5c3ae4..2886c8b 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -10,6 +10,7 @@ class SipAccountsController < ApplicationController end def show + @register_tel_protocol = "#{request.protocol}#{request.host_with_port}/sip_accounts/#{@sip_account.try(:id)}/call?url=%s" end def new @@ -74,6 +75,10 @@ class SipAccountsController < ApplicationController redirect_to :root, :notice => t('sip_accounts.controller.successfuly_destroyed') end + def call + redirect_to(:back) + end + private def set_and_authorize_parent @parent = @user || @tenant diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml index ede5150..12e54c3 100644 --- a/app/views/sip_accounts/show.html.haml +++ b/app/views/sip_accounts/show.html.haml @@ -60,6 +60,10 @@ = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @sip_account.sip_accountable, :child => @sip_account } +%p + %strong= t('sip_accounts.show.tel_protocol') + ':' + %a{:href => '', :onclick => "navigator.registerProtocolHandler(\"tel\", \"#{@register_tel_protocol}\", \"#{@sip_account.to_s}\");" }= t('sip_accounts.show.register_tel_protocol') + %p %strong= t('ringtones.name') + ':' - if @sip_account.ringtones.count > 0 diff --git a/config/locales/views/sip_accounts/de.yml b/config/locales/views/sip_accounts/de.yml index 7a7e540..2b4939b 100644 --- a/config/locales/views/sip_accounts/de.yml +++ b/config/locales/views/sip_accounts/de.yml @@ -41,6 +41,8 @@ de: registration: 'Registrierung' expires: 'Läuft ab' user_agent: 'User Agent' + tel_protocol: 'TEL Protokoll' + register_tel_protocol: 'Für tel: URLs registrieren' actions: confirm_destroy: 'Sind Sie sicher, dass Sie diesen SIP-Account löschen möchten?' destroy: 'Löschen' diff --git a/config/locales/views/sip_accounts/en.yml b/config/locales/views/sip_accounts/en.yml index 35d5456..78d20c2 100644 --- a/config/locales/views/sip_accounts/en.yml +++ b/config/locales/views/sip_accounts/en.yml @@ -41,6 +41,8 @@ en: registration: 'Registration' expires: 'Expires' user_agent: 'User Agent' + tel_protocol: 'TEL Protocol' + register_tel_protocol: 'Register for tel: URLs with browser' actions: confirm_destroy: 'Are you sure you want to delete this SIP account?' destroy: 'Delete' diff --git a/config/routes.rb b/config/routes.rb index b6943ab..16133d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -274,6 +274,9 @@ Gemeinschaft42c::Application.routes.draw do end end resources :voicemail_settings + member do + get 'call' + end end resources :phones, :only => [] do -- cgit v1.2.3 From 0399b856c75b842f43bc5380f9c19a64c6418f11 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 26 Feb 2013 10:00:36 -0500 Subject: call action added --- app/controllers/sip_accounts_controller.rb | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 2886c8b..022858c 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -1,6 +1,7 @@ class SipAccountsController < ApplicationController load_resource :user load_resource :tenant + #load_resource :sip_account load_and_authorize_resource :sip_account, :through => [:user, :tenant ] before_filter :set_and_authorize_parent @@ -76,7 +77,33 @@ class SipAccountsController < ApplicationController end def call - redirect_to(:back) + if !params[:url].blank? + protocol, separator, phone_number = params[:url].partition(':') + if ! phone_number.blank? + @sip_account.call(phone_number) + render( + :status => 200, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + return; + end + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + return; + end + + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) end private -- cgit v1.2.3