summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-07-23 10:48:26 +0200
committerPeter Kozak <spag@golwen.net>2013-07-23 10:48:26 +0200
commit14c3b2eacd2739ccffc8b4a086323962c467fa76 (patch)
tree0d3b4e07c551d64824d7fb716c4f6bda3f0a5bf4
parent76dff727fbdf8e44e05bd9231f6958c0250f5883 (diff)
extension_modules added to snom provisioning
-rw-r--r--app/controllers/config_snom_controller.rb699
-rw-r--r--app/views/config_snom/snom_phone.xml.haml205
-rw-r--r--app/views/config_snom/snom_vision.xml.haml44
3 files changed, 711 insertions, 237 deletions
diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb
index 2b779e1..412c4fc 100644
--- a/app/controllers/config_snom_controller.rb
+++ b/app/controllers/config_snom_controller.rb
@@ -1,6 +1,6 @@
class ConfigSnomController < ApplicationController
- MAX_SIP_ACCOUNTS_COUNT = 11
- MAX_SOFTKEYS_COUNT = 12 + (42 * 3) - 1
+ MAX_SIP_ACCOUNTS_COUNT = 11
+ MAX_SOFTKEYS_COUNT = 12 + (42 * 3) - 1
MAX_DIRECTORY_ENTRIES = 20
KEY_REGEXP = {
'0' => "[ -.,_0]+",
@@ -15,12 +15,112 @@ class ConfigSnomController < ApplicationController
'9' => "[wxyz9]",
}
- skip_authorization_check
-
- before_filter { |controller|
+ SNOM_PHONE_DEFAULTS = {
+ 'Snom 300' => {
+ :softkeys_physical => 6,
+ :softkeys_logical => 6,
+ },
+ 'Snom 320' => {
+ :softkeys_physical => 12,
+ :softkeys_logical => 12,
+ },
+ 'Snom 360' => {
+ :softkeys_physical => 12,
+ :softkeys_logical => 12,
+ },
+ 'Snom 360' => {
+ :softkeys_physical => 12,
+ :softkeys_logical => 12,
+ },
+ 'Snom 370' => {
+ :softkeys_physical => 12,
+ :softkeys_logical => 12,
+ },
+ 'Snom 820' => {
+ :softkeys_physical => 4,
+ :softkeys_logical => 16,
+ },
+ 'Snom 821' => {
+ :softkeys_physical => 4,
+ :softkeys_logical => 12,
+ },
+ 'Snom 870' => {
+ :softkeys_physical => 0,
+ :softkeys_logical => 16,
+ },
+ 'Snom vision' => {
+ :softkeys_physical => 16,
+ :softkeys_logical => 48,
+ :pages => 3,
+ },
+ }
+
+ skip_authorization_check
+
+ before_filter { |controller|
@mac_address = params[:mac_address].to_s.upcase.gsub(/[^0-9A-F]/,'')
@provisioning_authenticated = false
+ if !params[:phone].blank?
+ @phone = Phone.where({ :id => params[:phone].to_i }).first
+ if !params[:sip_account].blank?
+ @sip_account = @phone.sip_accounts.where({ :id => params[:sip_account].to_i }).first
+ end
+ end
+ }
+
+ def show
+ if @mac_address.blank?
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Phone not found -->",
+ )
+ return
+ end
+
+ mac_address_to_model = {
+ '00041325' => 'Snom 300',
+ '00041328' => 'Snom 300',
+ '0004132D' => 'Snom 300',
+ '0004132F' => 'Snom 300',
+ '00041334' => 'Snom 300',
+ '00041350' => 'Snom 300',
+ '0004133B' => 'Snom 300',
+ '00041337' => 'Snom 300',
+ '00041324' => 'Snom 320',
+ '00041327' => 'Snom 320',
+ '0004132C' => 'Snom 320',
+ '00041331' => 'Snom 320',
+ '00041335' => 'Snom 320',
+ '00041338' => 'Snom 320',
+ '00041351' => 'Snom 320',
+ '00041323' => 'Snom 360',
+ '00041329' => 'Snom 360',
+ '0004132B' => 'Snom 360',
+ '00041339' => 'Snom 360',
+ '00041390' => 'Snom 360',
+ '00041326' => 'Snom 370',
+ '0004132E' => 'Snom 370',
+ '0004133A' => 'Snom 370',
+ '00041352' => 'Snom 370',
+ '00041340' => 'Snom 820',
+ '00041345' => 'Snom 821',
+ '00041348' => 'Snom 821',
+ '00041341' => 'Snom 870',
+ '00041332' => 'Snom meetingPoint',
+ '00041343' => 'Snom vision',
+ }
+ phone_model_str = mac_address_to_model[@mac_address[0, 8]]
+ if phone_model_str == 'Snom vision'
+ snom_vision
+ elsif !phone_model_str.blank?
+ snom_phone
+ end
+ end
+
+ def snom_phone
if !params[:provisioning_key].blank?
@phone = Phone.where({ :provisioning_key => params[:provisioning_key] }).first
if @phone
@@ -154,6 +254,7 @@ class ConfigSnomController < ApplicationController
:content_type => 'text/plain',
:text => "<!-- Phone not found -->",
)
+ return
end
if ! params[:sip_account].blank?
@@ -178,10 +279,17 @@ class ConfigSnomController < ApplicationController
if ! params[:keys].blank?
@dialpad_keys = params[:keys].to_s.strip
end
- }
-
-
- def show
+
+ if ! @phone
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Phone not found -->",
+ )
+ return
+ end
+
send_sensitve = @provisioning_authenticated || !@phone.provisioning_key_active
@phone_settings = Hash.new()
@@ -230,15 +338,15 @@ class ConfigSnomController < ApplicationController
end
end
- if ! request.env['HTTP_USER_AGENT'].index('snom')
- Rails.logger.info "---> User-Agent indicates not a Snom phone (#{request.env['HTTP_USER_AGENT'].inspect})"
- else
- Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request_remote_ip.inspect}"
- @phone.update_attributes({ :ip_address => request_remote_ip })
- end
+ if ! request.env['HTTP_USER_AGENT'].index('snom')
+ Rails.logger.info "---> User-Agent indicates not a Snom phone (#{request.env['HTTP_USER_AGENT'].inspect})"
+ else
+ Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request_remote_ip.inspect}"
+ @phone.update_attributes({ :ip_address => request_remote_ip })
+ end
@softkeys = Array.new()
- @sip_accounts = Array.new()
+ @sip_accounts = Array.new()
phone_sip_accounts = Array.new()
if send_sensitve
@@ -252,16 +360,16 @@ class ConfigSnomController < ApplicationController
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 = {
+ snom_sip_account = {
:id => sip_account.id,
:active => 'on',
- :pname => sip_account.auth_name,
- :pass => sip_account.password,
- :host => sip_account.host,
- :outbound => sip_account.host,
- :name => sip_account.auth_name,
- :realname => 'Call',
- :user_idle_text => sip_account.caller_name,
+ :pname => sip_account.auth_name,
+ :pass => sip_account.password,
+ :host => sip_account.host,
+ :outbound => sip_account.host,
+ :name => sip_account.auth_name,
+ :realname => 'Call',
+ :user_idle_text => sip_account.caller_name,
:expiry => expiry_seconds,
}
@@ -282,217 +390,11 @@ class ConfigSnomController < ApplicationController
@sip_accounts.push(snom_sip_account)
sip_account_index = @sip_accounts.length
sip_account.softkeys.order(:position).each do |softkey|
- if softkey.softkey_function
- softkey_function = softkey.softkey_function.name
- end
- case softkey_function
- when 'blf'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "blf <sip:#{softkey.number}@#{sip_account.host}>|f-ia-"})
- when 'speed_dial'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "speed #{softkey.number}"})
- when 'dtmf'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "dtmf #{softkey.number}"})
- when 'log_out'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "speed f-lo"})
- when 'log_in'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "speed f-li-#{softkey.number}"})
- when 'conference'
- conference = softkey.softkeyable
- if conference.class == Conference
- @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 => "sip:conference#{conference.id}@#{sip_account.host}",
- :for => "sip:conference#{conference.id}@#{sip_account.host}",
- },
- :actions => [{
- :type => :dial,
- :target => "f-ta-#{softkey.number}",
- :when => 'on press',
- :states => 'connected,holding',
- },{
- :type => :dial,
- :target => softkey.number,
- :when => 'on press',
- }],
- })
- end
- 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 => "sip:park+#{parking_stall.name}@#{sip_account.host}",
- :for => "sip:park+#{parking_stall.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({
- :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 => "sip:f-cftg-#{softkey.softkeyable_id}@#{sip_account.host}",
- :for => "sip:f-cftg-#{softkey.softkeyable_id}@#{sip_account.host}"
- },
- :actions => [{
- :type => :url,
- :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/call_forwarding.xml?id=#{softkey.softkeyable_id}&function=toggle",
- :when => 'on press',
- }],
- })
- end
- when 'call_forwarding_always'
- phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'SipAccount').first
- if phone_number
- account_param = (phone_number.phone_numberable_id != snom_sip_account[:id] ? "&account=#{phone_number.phone_numberable_id}" : '')
- else
- phone_number = sip_account.phone_numbers.first
- account_param = ''
- end
-
- @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 => "f-cfutg-#{phone_number.id}@#{sip_account.host}",
- :for => "#{sip_account.auth_name}@#{sip_account.host}"
- },
- :actions => [{
- :type => :url,
- :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/call_forwarding.xml?type=always&function=toggle#{account_param}",
- :when => 'on press',
- }],
- })
- when 'call_forwarding_assistant'
- phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'SipAccount').first
- if phone_number
- account_param = (phone_number.phone_numberable_id != snom_sip_account[:id] ? "&account=#{phone_number.phone_numberable_id}" : '')
- else
- phone_number = sip_account.phone_numbers.first
- account_param = ''
- end
-
- @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 => "f-cfatg-#{phone_number.id}@#{sip_account.host}",
- :for => "#{sip_account.auth_name}@#{sip_account.host}"
- },
- :actions => [{
- :type => :url,
- :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/call_forwarding.xml?type=assistant&function=toggle#{account_param}",
- :when => 'on press',
- }],
- })
- when 'hunt_group_membership'
- phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'HuntGroup').first
- if phone_number
- hunt_group = HuntGroup.where(:id => phone_number.phone_numberable_id).first
- end
-
- sip_account_phone_numbers = Array.new()
- SipAccount.where(:id => @sip_accounts.first[:id]).first.phone_numbers.each do |phone_number|
- sip_account_phone_numbers.push(phone_number.number)
- end
-
- hunt_group_member_numbers = PhoneNumber.where(:number => sip_account_phone_numbers, :phone_numberable_type => 'HuntGroupMember')
-
- hunt_group_member = nil
- if hunt_group and hunt_group_member_numbers
- hunt_group_member_numbers.each do |hunt_group_member_number|
- hunt_group_member = hunt_group.hunt_group_members.where(:id => hunt_group_member_number.phone_numberable_id).first
- if hunt_group_member
- break
- end
- end
- end
-
- if hunt_group_member
- @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 => "f-hgmtg-#{hunt_group_member.id}@#{sip_account.host}",
- :for => "#{sip_account.auth_name}@#{sip_account.host}"
- },
- :actions => [{
- :type => :url,
- :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/hunt_group.xml?group=#{hunt_group.id}&account=#{hunt_group_member.id}&function=toggle",
- :when => 'on press',
- }],
- })
- else
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => 'none'})
- end
- when 'acd_membership'
- acd_agent = nil
- phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'AutomaticCallDistributor').first
- if phone_number
- acd = AutomaticCallDistributor.where(:id => phone_number.phone_numberable_id).first
- if acd
- acd_agent = acd.acd_agents.where(:destination_type => 'SipAccount', :destination_id => sip_account.id).first
- end
- end
-
- if acd_agent
- @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 => "f-acdmtg-#{acd_agent.id}@#{sip_account.host}",
- :for => "#{sip_account.auth_name}@#{sip_account.host}"
- },
- :actions => [{
- :type => :url,
- :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/acd.xml?acd=#{acd.id}&agent=#{acd_agent.id}&function=toggle",
- :when => 'on press',
- }],
- })
- else
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => 'none'})
- end
- when 'hold'
- @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "keyevent F_R"})
- else
- @softkeys.push({:label => softkey.label, :data => 'none'})
- end
+ @softkeys.push(format_key(softkey, sip_account_index))
+ end
+ if @softkeys.any? && @phone.extension_modules.any?
+ phone_defaults = SNOM_PHONE_DEFAULTS[@phone.phone_model.name]
+ @softkeys = @softkeys.first(phone_defaults[:softkeys_physical])
end
end
end
@@ -603,7 +505,7 @@ class ConfigSnomController < ApplicationController
end
@softkeys.length().upto(MAX_SOFTKEYS_COUNT) do |index|
- @softkeys.push({:label => "", :data => "none"})
+ @softkeys.push({:label => "", :type => 'none', :value => ''})
end
@state_settings_url = "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/state_settings.xml"
@@ -611,11 +513,117 @@ class ConfigSnomController < ApplicationController
respond_to { |format|
format.any {
self.formats = [ :xml ]
- render
+ render :snom_phone
}
}
end
+ def snom_vision
+ if !params[:provisioning_key].blank?
+ @extension_module = ExtensionModule.where({ :provisioning_key => params[:provisioning_key] }).first
+ if @extension_module
+ @provisioning_authenticated = true
+ @mac_address = @extension_module.mac_address
+ end
+ elsif @mac_address
+ @extension_module = ExtensionModule.where({ :mac_address => @mac_address }).first
+ end
+
+
+ if !@extension_module
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Extension module not found -->",
+ )
+ return
+ end
+
+ if ! request.env['HTTP_USER_AGENT'].index('snom')
+ Rails.logger.info "---> User-Agent indicates not a Snom Vision (#{request.env['HTTP_USER_AGENT'].inspect})"
+ else
+ Rails.logger.info "---> Extension module #{@mac_address.inspect}, IP address #{request_remote_ip.inspect}"
+ @extension_module.update_attributes({ :ip_address => request_remote_ip })
+ end
+
+ phone = @extension_module.phone
+
+ provisioning_protocol = request.protocol
+
+ @settings = {
+ :auth_type => 'basic',
+ :provisioning_server => "#{provisioning_protocol}#{request.host_with_port}/settings-#{@extension_module.mac_address}.xml",
+ :user => '',
+ :passwd => '',
+ :phone_ip => '',
+ }
+
+ @buttons = Array.new()
+ softkeys = Array.new()
+ send_sensitve = @provisioning_authenticated || !@extension_module.provisioning_key_active
+
+ if send_sensitve && phone
+ if @provisioning_authenticated && !@extension_module.provisioning_key_active
+ @extension_module.update_attributes({ :provisioning_key_active => true })
+ end
+
+ @settings[:user] = phone.http_user
+ @settings[:passwd] = phone.http_password
+ @settings[:phone_ip] = phone.ip_address
+
+ if !GsParameter.get('PROVISIONING_KEY_LENGTH').nil? && GsParameter.get('PROVISIONING_KEY_LENGTH') > 0 && !@extension_module.provisioning_key.blank?
+ @settings[:provisioning_server] = "#{provisioning_protocol}#{request.host_with_port}/snom_vision-#{@extension_module.provisioning_key}.xml"
+ end
+
+ phone.sip_accounts.each do |sip_account|
+ softkeys.concat(sip_account.softkeys.order(:position))
+ end
+
+ phone_defaults = SNOM_PHONE_DEFAULTS[phone.phone_model.name]
+ softkeys.shift(phone_defaults[:softkeys_physical] * @extension_module.position)
+
+ else
+ @buttons << {
+ :imageurl => '',
+ :label => 'No provisioning key!',
+ :type => 'none',
+ :value => '',
+ }
+ end
+
+ softkeys.each do |softkey|
+ image_url = nil
+ if softkey.softkeyable.class == SipAccount
+ if softkey.softkeyable.sip_accountable.class == User
+ user = softkey.softkeyable.sip_accountable
+ if user.image?
+ image_url = "#{provisioning_protocol}#{request.host_with_port}#{user.image_url(:small)}"
+ end
+ end
+ elsif softkey.softkeyable.class == PhoneBookEntry
+ entry = softkey.softkeyable
+ if entry.image?
+ image_url = "#{provisioning_protocol}#{request.host_with_port}#{entry.image_url(:small)}"
+ end
+ end
+
+ button = format_key(softkey)
+ if button
+ button[:imageurl] = image_url
+ end
+ @buttons.push(button)
+ end
+
+ respond_to { |format|
+ format.any {
+ self.formats = [ :xml ]
+ render :snom_vision
+ }
+ }
+ end
+
+
def idle_screen
snom_360_bg = 'Qk0+BAAAAAAAAD4AAAAoAAAAgAAAAEAAAAABAAEAAAAAAAAEAAATCwAAEwsAAAIAAAACAAAA////
@@ -1329,4 +1337,221 @@ AAAA'
return date.strftime('%d.%m %H:%M')
end
+ def format_key(softkey, sip_account_index = nil)
+ if !softkey.softkey_function
+ return nil
+ end
+
+ sip_account = softkey.sip_account
+
+ case softkey.softkey_function.name
+ when 'blf'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'blf', :value => "<sip:#{softkey.number}@#{sip_account.host}>|f-ia-"}
+ when 'speed_dial'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'speed', :value => softkey.number.to_s}
+ when 'dtmf'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'dtmf', :value => softkey.number.to_s}
+ when 'log_out'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'speed', :value => 'f-lo'}
+ when 'log_in'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'speed', :value => "f-li-#{softkey.number}"}
+ when 'conference'
+ conference = softkey.softkeyable
+ if conference.class == Conference
+ return {
+ :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 => "sip:conference#{conference.id}@#{sip_account.host}",
+ :for => "sip:conference#{conference.id}@#{sip_account.host}",
+ },
+ :actions => [{
+ :type => :dial,
+ :target => "f-ta-#{softkey.number}",
+ :when => 'on press',
+ :states => 'connected,holding',
+ },{
+ :type => :dial,
+ :target => softkey.number,
+ :when => 'on press',
+ }],
+ }
+ end
+ when 'parking_stall'
+ parking_stall = softkey.softkeyable
+ if parking_stall.class == ParkingStall
+ return {
+ :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 => "sip:park+#{parking_stall.name}@#{sip_account.host}",
+ :for => "sip:park+#{parking_stall.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
+ return {
+ :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 => "sip:f-cftg-#{softkey.softkeyable_id}@#{sip_account.host}",
+ :for => "sip:f-cftg-#{softkey.softkeyable_id}@#{sip_account.host}"
+ },
+ :actions => [{
+ :type => :url,
+ :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/call_forwarding.xml?id=#{softkey.softkeyable_id}&function=toggle",
+ :when => 'on press',
+ }],
+ }
+ end
+ when 'call_forwarding_always'
+ phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'SipAccount').first
+ if phone_number
+ account_param = (phone_number.phone_numberable_id != snom_sip_account[:id] ? "&account=#{phone_number.phone_numberable_id}" : '')
+ else
+ phone_number = sip_account.phone_numbers.first
+ account_param = ''
+ end
+
+ return {
+ :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 => "f-cfutg-#{phone_number.id}@#{sip_account.host}",
+ :for => "#{sip_account.auth_name}@#{sip_account.host}"
+ },
+ :actions => [{
+ :type => :url,
+ :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/call_forwarding.xml?type=always&function=toggle#{account_param}",
+ :when => 'on press',
+ }],
+ }
+ when 'call_forwarding_assistant'
+ phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'SipAccount').first
+ if phone_number
+ account_param = (phone_number.phone_numberable_id != snom_sip_account[:id] ? "&account=#{phone_number.phone_numberable_id}" : '')
+ else
+ phone_number = sip_account.phone_numbers.first
+ account_param = ''
+ end
+
+ return {
+ :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 => "f-cfatg-#{phone_number.id}@#{sip_account.host}",
+ :for => "#{sip_account.auth_name}@#{sip_account.host}"
+ },
+ :actions => [{
+ :type => :url,
+ :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/call_forwarding.xml?type=assistant&function=toggle#{account_param}",
+ :when => 'on press',
+ }],
+ }
+ when 'hunt_group_membership'
+ phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'HuntGroup').first
+ if phone_number
+ hunt_group = HuntGroup.where(:id => phone_number.phone_numberable_id).first
+ end
+
+ sip_account_phone_numbers = Array.new()
+ SipAccount.where(:id => @sip_accounts.first[:id]).first.phone_numbers.each do |phone_number|
+ sip_account_phone_numbers.push(phone_number.number)
+ end
+
+ hunt_group_member_numbers = PhoneNumber.where(:number => sip_account_phone_numbers, :phone_numberable_type => 'HuntGroupMember')
+
+ hunt_group_member = nil
+ if hunt_group and hunt_group_member_numbers
+ hunt_group_member_numbers.each do |hunt_group_member_number|
+ hunt_group_member = hunt_group.hunt_group_members.where(:id => hunt_group_member_number.phone_numberable_id).first
+ if hunt_group_member
+ break
+ end
+ end
+ end
+
+ if hunt_group_member
+ return {
+ :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 => "f-hgmtg-#{hunt_group_member.id}@#{sip_account.host}",
+ :for => "#{sip_account.auth_name}@#{sip_account.host}"
+ },
+ :actions => [{
+ :type => :url,
+ :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/hunt_group.xml?group=#{hunt_group.id}&account=#{hunt_group_member.id}&function=toggle",
+ :when => 'on press',
+ }],
+ }
+ else
+ return {:context => sip_account_index, :label => softkey.label, :type => 'none', :value => ''}
+ end
+ when 'acd_membership'
+ acd_agent = nil
+ phone_number = PhoneNumber.where(:number => softkey.number, :phone_numberable_type => 'AutomaticCallDistributor').first
+ if phone_number
+ acd = AutomaticCallDistributor.where(:id => phone_number.phone_numberable_id).first
+ if acd
+ acd_agent = acd.acd_agents.where(:destination_type => 'SipAccount', :destination_id => sip_account.id).first
+ end
+ end
+
+ if acd_agent
+ return {
+ :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 => "f-acdmtg-#{acd_agent.id}@#{sip_account.host}",
+ :for => "#{sip_account.auth_name}@#{sip_account.host}"
+ },
+ :actions => [{
+ :type => :url,
+ :target => "#{request.protocol}#{request.host_with_port}/config_snom/#{@phone.id}/#{snom_sip_account[:id]}/acd.xml?acd=#{acd.id}&agent=#{acd_agent.id}&function=toggle",
+ :when => 'on press',
+ }],
+ }
+ else
+ return {:context => sip_account_index, :label => softkey.label, :type => 'none', :value => ''}
+ end
+ when 'hold'
+ return {:context => sip_account_index, :label => softkey.label, :type => 'keyevent', :value => 'F_R'}
+ else
+ return {:label => softkey.label, :type => 'none', :value => ''}
+ end
+ end
+
end
diff --git a/app/views/config_snom/snom_phone.xml.haml b/app/views/config_snom/snom_phone.xml.haml
new file mode 100644
index 0000000..ce5171b
--- /dev/null
+++ b/app/views/config_snom/snom_phone.xml.haml
@@ -0,0 +1,205 @@
+!!! XML
+%settings
+ %phone-settings
+ %auto_reboot_on_setting_change{:perm => 'RW'}= 'off'
+ - if !@phone_settings[:setting_server].blank?
+ %setting_server{:perm => 'RW'}= @phone_settings[:setting_server]
+ %web_language{:perm => 'RW'}= 'English'
+ %language{:perm => 'RW'}= @phone_settings[:language]
+ %timezone{:perm => 'RW'}= 'GER+1'
+ %date_us_format{:perm => 'RW'}= 'off'
+ %time_24_format{:perm => 'RW'}= 'on'
+ %reset_settings{:perm => 'RW'}= ''
+ %update_policy{:perm => 'RW'}= 'settings_only'
+ %settings_refresh_timer{:perm => 'RW'}= '0'
+ %firmware_status{:perm => 'RW'}= ''
+ %webserver_type{:perm => 'R'}= 'http_https'
+ %http_scheme{:perm => 'RW'}= 'off'
+ %http_port{:perm => 'R'}= '80'
+ %https_port{:perm => 'R'}= '443'
+ %http_user{:perm => 'R'}= @phone_settings[:http_user]
+ %http_pass{:perm => 'R'}= @phone_settings[:http_pass]
+ %admin_mode_password{:perm => 'R'}= @phone_settings[:admin_mode_password]
+ %tone_scheme{:perm => 'RW'}= @phone_settings[:tone_scheme]
+ %keytones{:perm => 'RW'}= 'off'
+ %dtmf_speaker_phone{:perm => 'RW'}= 'off'
+ %disable_redirection_menu{:perm => 'R'}= 'on'
+ %retry_after_failed_register{:perm => 'RW'}= '70'
+ %encode_display_name{:perm => 'R'}= 'on'
+ %dtmf_payload_type{:perm => 'RW'}= '101'
+ %ignore_security_warning{:perm => 'R'}= 'on'
+ %call_completion{:perm => 'RW'}= 'on'
+ %block_url_dialing{:perm => 'RW'}= 'on'
+ %redirect_ringing{:perm => 'RW'}= 'on'
+ %goto_virtual_keys_state_on_activity{:perm => 'RW'}= 'off'
+ %goto_monitor_state_on_line_activity{:perm => 'RW'}= 'on'
+ %ringer_animation{:perm => 'RW'}= 'on'
+ %display_method{:perm => 'RW'}= 'display_name_number'
+ %callpickup_dialoginfo{:perm => 'RW'}= 'on'
+ %pickup_indication{:perm => 'RW'}= 'off'
+ %auto_connect_indication{:perm => 'RW'}= 'off'
+ %show_local_line{:perm => 'RW'}= 'off'
+ %mwi_notification{:perm => 'RW'}= 'silent'
+ %mwi_dialtone{:perm => 'RW'}= 'normal'
+ %prefer_saved_over_received_photo{:perm => 'RW'}= 'off'
+ %no_dnd{:perm => 'RW'}= 'off'
+ %transfer_on_hangup{:perm => 'RW'}= 'on'
+ %transfer_on_hangup_non_pots{:perm => 'RW'}= 'off'
+ %call_join_xfer{:perm => 'RW'}= 'on'
+ %conf_hangup{:perm => 'RW'}= 'on'
+ %logon_wizard{:perm => 'RW'}= 'off'
+ %disable_deflection{:perm => 'RW'}= 'off'
+ %csta_control{:perm => 'RW'}= 'on'
+ %save_latest_callrecords_to_flash{:perm => 'RW'}= 'off'
+ %use_proxy_number_guessing{:perm => 'RW'}= 'off'
+ %guess_number{:perm => 'RW'}= 'off'
+ %guess_start_length{:perm => 'RW'}= '3'
+ %ieee8021x_eap_md5_username{:perm => 'RW'}= GsParameter.get('PROVISIONING_IEEE8021X_EAP_USERNAME')
+ %ieee8021x_eap_md5_password{:perm => 'RW'}= GsParameter.get('PROVISIONING_IEEE8021X_EAP_PASSWORD')
+
+ - 0.upto(9) do |ringer_idx|
+ %internal_ringer_text{:idx => ringer_idx, :perm => 'RW'}= "Ringer#{(ringer_idx+1)}"
+ %internal_ringer_file{:idx => ringer_idx, :perm => 'RW'}= "Ringer#{(ringer_idx+1)}"
+
+ %internal_ringer_text{:idx => 10, :perm => 'RW'}= "Ringer0"
+ %internal_ringer_file{:idx => 10, :perm => 'RW'}= "Silent"
+
+ %gui_fkey1{:perm => 'R'}= 'none'
+ %gui_fkey2{:perm => 'R'}= 'none'
+ %gui_fkey3{:perm => 'R'}= 'none'
+ %gui_fkey4{:perm => 'R'}= 'none'
+
+ %dkey_menu{:perm => 'RW'}= @dkeys[:menu]
+ %dkey_retrieve{:perm => 'RW'}= @dkeys[:retrieve]
+ %dkey_conf{:perm => 'RW'}= @dkeys[:conf]
+ %dkey_redial{:perm => 'RW'}= @dkeys[:redial]
+ %dkey_directory{:perm => 'RW'}= @dkeys[:directory]
+ %dkey_touch_idle_adr_book{:perm => 'RW'}= @dkeys[:touch_idle_adr_book]
+ %dkey_touch_idle_list_missed{:perm => 'RW'}= @dkeys[:touch_idle_list_missed]
+ %dkey_touch_idle_list_taken{:perm => 'RW'}= @dkeys[:touch_idle_list_taken]
+ %dkey_touch_idle_redial{:perm => 'RW'}= @dkeys[:touch_idle_redial]
+ %dkey_touch_idle_dialog{:perm => 'RW'}= @dkeys[:touch_idle_dialog]
+
+ %idle_ok_key_action{:perm => 'RW'}= @dkeys[:idle_ok]
+ %idle_cancel_key_action{:perm => 'RW'}= @dkeys[:idle_cancel]
+ %idle_up_key_action{:perm => 'RW'}= @dkeys[:idle_up]
+ %idle_down_key_action{:perm => 'RW'}= @dkeys[:idle_down]
+ %idle_left_key_action{:perm => 'RW'}= @dkeys[:idle_left]
+ %idle_right_key_action{:perm => 'RW'}= @dkeys[:idle_right]
+
+ / Display
+ %backlight{:perm => 'RW'}= '15'
+ %backlight_idle{:perm => 'RW'}= '0'
+ %dim_timer{:perm => 'RW'}= '300'
+
+ / LED
+ %led_on{:perm => 'RW'}= 'ON BUSY IN_A_CALL CALLING IN_A_MEETING URGENT_INTERRUPTIONS_ONLY HOLDING DND ACTIVE INACTIVE BE_RIGHT_BACK AWAY UNAVAILABLE AVAILABLE PhoneHasCall CurrentIdentityHasVoiceMessages PhoneHasVoiceMessages'
+ %led_blink_slow{:perm => 'RW'}= 'PARKED HOLDING_BOSSADMIN Wrap-Up'
+ %led_blink_medium{:perm => 'RW'}= ''
+ %led_blink_fast{:perm => 'RW'}= 'RINGING PhoneHasCallInStateRinging'
+ %led_blink_short_off{:perm => 'RW'}= 'PhoneHasMissedCalls'
+ %led_red{:perm => 'RW'}= 'BUSY IN_A_CALL CALLING IN_A_MEETING URGENT_INTERRUPTIONS_ONLY HOLDING DND'
+ %led_green{:perm => 'RW'}= 'Wrap-Up'
+ %led_orange{:perm => 'RW'}= 'AWAY INACTIVE BE_RIGHT_BACK INACTIVE'
+ %led_blue{:perm => 'RW'}= ''
+ %led_red_green{:perm => 'RW'}= ''
+ %led_red_orange{:perm => 'RW'}= ''
+ %led_green_orange{:perm => 'RW'}= ''
+ %led_call_indicator_usage{:perm => 'RW'}= 'PhoneHasCallInStateRinging PhoneHasCall PhoneHasMissedCalls'
+ %led_message_usage{:perm => 'RW'}= 'CurrentIdentityHasVoiceMessages PhoneHasVoiceMessages'
+
+
+ - if @phone.phone_model.name == 'Snom 870'
+ / Snom 870 idle icons
+ %idle_icon_01{:perm => 'RW'}= '9'
+ %idle_icon_02{:perm => 'RW'}= '20'
+ %idle_icon_03{:perm => 'RW'}= '4'
+ %idle_icon_04{:perm => 'RW'}= '-1'
+ %idle_icon_05{:perm => 'RW'}= '6'
+ %idle_icon_06{:perm => 'RW'}= '-1'
+ %idle_icon_07{:perm => 'RW'}= '-1'
+ %idle_icon_08{:perm => 'RW'}= '-1'
+ %idle_icon_09{:perm => 'RW'}= '-1'
+ %idle_icon_10{:perm => 'RW'}= '-1'
+ %idle_icon_11{:perm => 'RW'}= '15'
+ %idle_icon_12{:perm => 'RW'}= '-1'
+ %idle_icon_13{:perm => 'RW'}= '-1'
+ %idle_icon_14{:perm => 'RW'}= '13'
+ %idle_icon_15{:perm => 'RW'}= '12'
+
+ != "\<!-- sip accounts: #{@sip_accounts.count} --\>"
+ - @sip_accounts.each_with_index do |sip_account, array_index|
+ - index = array_index + 1
+ != "\<!-- sip account #{array_index}: #{sip_account[:user_idle_text]}, #{sip_account[:active]} --\>"
+ %user_active{:idx => index, :perm => 'R'}= sip_account[:active]
+ %user_pname{:idx => index, :perm => 'R'}= sip_account[:pname]
+ %user_pass{:idx => index, :perm => 'R'}= sip_account[:pass]
+ %user_host{:idx => index, :perm => 'R'}= sip_account[:host]
+ %user_outbound{:idx => index, :perm => 'R'}= sip_account[:outbound]
+ %user_name{:idx => index, :perm => 'R'}= sip_account[:name]
+ %user_realname{:idx => index, :perm => 'R'}= sip_account[:realname]
+ %user_idle_text{:idx => index, :perm => 'R'}= sip_account[:user_idle_text]
+ %user_mailbox{:idx => index, :perm => 'R'}= sip_account[:mailbox]
+ %user_expiry{:idx => index, :perm => 'R'}= sip_account[:expiry]
+ %user_server_type{:idx => index, :perm => 'R'}= 'default'
+ %user_send_local_name{:idx => index, :perm => 'RW'}= 'on'
+ %user_dtmf_info{:idx => index, :perm => 'RW'}= 'off'
+ %user_dp_exp{:idx => index, :perm => 'RW'}= ''
+ %user_dp_str{:idx => index, :perm => 'RW'}= ''
+ %user_dp{:idx => index, :perm => 'RW'}= ''
+ %user_q{:idx => index, :perm => 'RW'}= '1.0'
+ %user_failover_identity{:idx => index, :perm => 'RW'}= 'none'
+ %user_full_sdp_answer{:idx => index, :perm => 'RW'}= 'on'
+ %user_dynamic_payload{:idx => index, :perm => 'RW'}= 'on'
+ %user_g726_packing_order{:idx => index, :perm => 'R'}= 'on'
+ %user_srtp{:idx => index, :perm => 'RW'}= 'off'
+ %user_savp{:idx => index, :perm => 'RW'}= 'off'
+ %codec_size{:idx => index, :perm => 'RW'}= '20'
+ %codec1_name{:idx => index, :perm => 'RW'}= "0"
+ %codec2_name{:idx => index, :perm => 'RW'}= "8"
+ %codec3_name{:idx => index, :perm => 'RW'}= "3"
+ %codec4_name{:idx => index, :perm => 'RW'}= "9"
+ %codec5_name{:idx => index, :perm => 'RW'}= "2"
+ %codec6_name{:idx => index, :perm => 'RW'}= "18"
+ %codec7_name{:idx => index, :perm => 'RW'}= "4"
+ %record_missed_calls{:idx => index, :perm => 'RW'}= 'on'
+ %record_received_calls{:idx => index, :perm => 'RW'}= 'off'
+ %record_missed_calls_cwi_off{:idx => index, :perm => 'RW'}= 'off'
+ %record_dialed_calls{:idx => index, :perm => 'RW'}= 'off'
+
+ / all sip accounts done
+
+ %functionKeys
+ - @softkeys.each_with_index do |softkey, index|
+ - if softkey[:type]
+ %fkey{:idx => index, :context => (softkey[:context] ? softkey[:context].to_s : 'active'), :label => softkey[:label], :perm => 'RW'}= "#{softkey[:type]} #{softkey[:value]}"
+ - elsif softkey[:general_type]
+ %fkey{:idx => index, :context => (softkey[:context] ? softkey[:context].to_s : 'active'), :label => softkey[:label], :perm => 'RW'}
+ %general{:type => softkey[:general_type]}
+ %default_state{:name => 'initial'}
+ %appearance
+ %line_info_layer
+ %line_format{:line => '0'}= '$state $type'
+ %line_format{:line => '1'}= '$continue $name'
+ - if softkey[:subscription]
+ %subscription{:type => 'dialog', :to => softkey[:subscription][:to], :for => softkey[:subscription][:for]}
+ %NotifyParsingRules{:type => 'applies'}
+ %level1{:translates_to => 'OK'}= "/dialog-info[@entity=\"#{softkey[:subscription][:to]}\"]"
+ %NotifyParsingRules{:type => 'state'}
+ %level1{:translates_to => 'unknown'}= '/dialog-info/dialog/state[.="terminated"]'
+ %level2{:translates_to => 'ringing'}= '/dialog-info/dialog/state[.="early"]'
+ %level3{:translates_to => 'active'}= '/dialog-info/dialog/state[.="confirmed"]'
+ %level4{:fetch_content => 'true'}= '/dialog-info/dialog/state'
+ %default{:translates_to => 'unknown'}
+ - if softkey[:actions]
+ %action
+ - softkey[:actions].each do |action|
+ - if action[:type] == :url
+ %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
+ / Phone menu
+ %file{:url => @state_settings_url, :type => "gui_xml_state_settings"}
diff --git a/app/views/config_snom/snom_vision.xml.haml b/app/views/config_snom/snom_vision.xml.haml
new file mode 100644
index 0000000..38a8d35
--- /dev/null
+++ b/app/views/config_snom/snom_vision.xml.haml
@@ -0,0 +1,44 @@
+!!! XML
+%settings
+ %webserver
+ %auth_type{:perm => '$'}= @settings[:auth_type]
+ %user{:perm => '!'}= @settings[:user]
+ %passwd{:perm => '!'}= @settings[:passwd]
+
+ %global
+ %periodic_provisioning{:perm => '$'}
+ %periodic_provisioning_interval{:perm => '$'}
+ %provisioning_server{:perm => '!'}= @settings[:provisioning_server]
+
+ %gui
+ %phone_ip{:perm => '!'}= @settings[:phone_ip]
+ %phone_scheme{:perm => '$'}https
+ %phone_user{:perm => '!'}= @settings[:user]
+ %phone_passwd{:perm => '!'}= @settings[:passwd]
+
+ != "\<!-- active buttons: #{@buttons.count} --\>"
+ - index_left = 0
+ - index_right = 0
+ - for page in 1..3 do
+ != "\<!-- page: #{page} --\>"
+ - for key in 1..8 do
+ - index_left = index_left + 1
+ - button = @buttons.shift
+ - if !button
+ - button = {}
+
+ %left_button_imageurl{:idx=> index_left, :perm=>"!"}= button[:imageurl]
+ %left_button_name{:idx=> index_left, :perm=>"!"}= button[:label]
+ %left_button_type{:idx=> index_left, :perm=>"!"}= button[:type]
+ %left_button_value{:idx=> index_left, :perm=>"!"}= button[:value]
+
+ - for key in 1..8 do
+ - index_right = index_right + 1
+ - button = @buttons.shift
+ - if !button
+ - button = {}
+
+ %right_button_imageurl{:idx=> index_right, :perm=>"!"}= button[:imageurl]
+ %right_button_name{:idx=> index_right, :perm=>"!"}= button[:label]
+ %right_button_type{:idx=> index_right, :perm=>"!"}= button[:type]
+ %right_button_value{:idx=> index_right, :perm=>"!"}= button[:value]