Skip to content

Instantly share code, notes, and snippets.

@JustinAiken
Created February 17, 2014 16:48
Show Gist options
  • Save JustinAiken/9054304 to your computer and use it in GitHub Desktop.
Save JustinAiken/9054304 to your computer and use it in GitHub Desktop.
Patch
diff --git a/app/classes/talkbox/phone_config_creator.rb b/app/classes/talkbox/phone_config_creator.rb
index 104f263..0a22236 100644
--- a/app/classes/talkbox/phone_config_creator.rb
+++ b/app/classes/talkbox/phone_config_creator.rb
@@ -29,18 +29,22 @@ class PhoneConfigCreator
end
def generate
- if user.office_ext.present? && APP_CONFIG['provision']['pbx_host']
- config_file << pbx_account
- config_file << "# Auto Answer (A1). 0 - no, 1 - yes\nP90 = 0\n"
- config_file << "\n"
- end
-
if user.dialer_ext.present? && APP_CONFIG['provision']['dialer_host']
config_file << sip_account
- config_file << "# Auto Answer (A1). 0 - no, 1 - yes\nP525 = 1\n"
+ config_file << "# Auto Answer (A1). 0 - no, 1 - yes\nP90 = 1\n"
config_file << "\n"
- else
- config_file << "# Account 3 Active\nP501 = 0\n"
+ end
+
+ if user.office_ext.present? && APP_CONFIG['provision']['pbx_host']
+ config_file << pbx_account
+ if @sip_created
+ config_file << "# Auto Answer (A1). 0 - no, 1 - yes\nP525 = 0\n"
+ config_file << "\n"
+ else
+ config_file << "# Auto Answer (A1). 0 - no, 1 - yes\nP90 = 0\n"
+ config_file << "\n"
+ config_file << "# Account 3 Active\nP501 = 0\n" unless @sip_created
+ end
end
config_file << template_file
@@ -84,8 +88,31 @@ private
end
def pbx_account
+ if @sip_created
+<<-EOS
+####################
+# Account 3
+####################
+# Account Active (In Use). 0 - no, 1 - yes
+P501 = 1
+# SIP Server
+P502 = #{APP_CONFIG['provision']['pbx_host']}
+# SIP User ID
+P504 = #{user.office_ext}
+# Authenticate ID
+P505 = #{user.office_ext}
+# Authenticate password
+P506 = pw1234
+# Display Name
+P507 = #{display_name}
+# Voice Mail UserID (User ID/extension for 3rd party voice mail system)
+P626 = *97
+# Account Name
+P517 = #{user.office_ext}
+EOS
+ else
<<-EOS
-#####################
+####################
# Account 1
####################
# SIP Server
@@ -103,27 +130,27 @@ P33 = *97
# Account Name
P270 = #{user.office_ext}
EOS
+ end
end
def sip_account
+ @sip_created = true
<<-EOS
-#########################
-# Account 3
-#########################
-# Account Active (In Use). 0 - no, 1 - yes
-P501 = 1
+####################
+# Account 1
+####################
# SIP Server
-P502 = #{APP_CONFIG['provision']['dialer_host']}
+P47 = #{APP_CONFIG['provision']['dialer_host']}
# SIP User ID
-P504 = #{user.dialer_ext}
+P35 = #{user.dialer_ext}
# Authenticate ID
-P505 = #{user.dialer_ext}
+P36 = #{user.dialer_ext}
# Authenticate password
-P506 = 1234
+P34 = 1234
# Display Name
-P507 = #{display_name}
+P3 = #{display_name}
# Account Name
-P517 = #{user.dialer_ext}
+P270 = #{user.dialer_ext}
EOS
end
end
diff --git a/spec/fixtures/000b822a9250.txt.dialer b/spec/fixtures/000b822a9250.txt.dialer
index b819640..ee76cf2 100644
--- a/spec/fixtures/000b822a9250.txt.dialer
+++ b/spec/fixtures/000b822a9250.txt.dialer
@@ -1,42 +1,42 @@
-#####################
+####################
# Account 1
####################
# SIP Server
-P47 = 10.10.0.2
+P47 = 10.10.0.3
# SIP User ID
-P35 = 2222
+P35 = 301
# Authenticate ID
-P36 = 2222
+P36 = 301
# Authenticate password
-P34 = pws1234
+P34 = 1234
# Display Name
P3 = Joe Bloggs
-# Voice Mail UserID (User ID/extension for 3rd party voice mail system)
-P33 = *97
# Account Name
-P270 = 2222
+P270 = 301
# Auto Answer (A1). 0 - no, 1 - yes
-P90 = 0
+P90 = 1
-#########################
+####################
# Account 3
-#########################
+####################
# Account Active (In Use). 0 - no, 1 - yes
P501 = 1
# SIP Server
-P502 = 10.10.0.3
+P502 = 10.10.0.2
# SIP User ID
-P504 = 301
+P504 = 2222
# Authenticate ID
-P505 = 301
+P505 = 2222
# Authenticate password
-P506 = 1234
+P506 = pw1234
# Display Name
P507 = Joe Bloggs
+# Voice Mail UserID (User ID/extension for 3rd party voice mail system)
+P626 = *97
# Account Name
-P517 = 301
+P517 = 2222
# Auto Answer (A1). 0 - no, 1 - yes
-P525 = 1
+P525 = 0
################################################################################################
## Configuration template for GXP21xx/GXP1450 firmware version 1.0.1.26
diff --git a/spec/fixtures/000b822a9250.txt.office b/spec/fixtures/000b822a9250.txt.office
index 3c87609..e0ef402 100644
--- a/spec/fixtures/000b822a9250.txt.office
+++ b/spec/fixtures/000b822a9250.txt.office
@@ -1,4 +1,4 @@
-#####################
+####################
# Account 1
####################
# SIP Server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment