summaryrefslogtreecommitdiff
path: root/app/models/gateway.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-25 10:27:27 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-25 10:27:27 +0100
commitdf6e17e48995f25e72509986f30700d778b179b6 (patch)
treef432c24b8e4ad81009188650dabfd99194883265 /app/models/gateway.rb
parent11f186a118285fbc87a536af26730780a9ad01f5 (diff)
parentcce94a74aa5c9691f9b37cd9be5a6831f8063812 (diff)
Merge branch 'develop'5.1.2
Diffstat (limited to 'app/models/gateway.rb')
-rw-r--r--app/models/gateway.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/models/gateway.rb b/app/models/gateway.rb
index 2f17b57..bf391fb 100644
--- a/app/models/gateway.rb
+++ b/app/models/gateway.rb
@@ -27,7 +27,34 @@ class Gateway < ActiveRecord::Base
"#{GATEWAY_PREFIX}#{self.id}"
end
+ def status
+ if self.technology == 'sip' then
+ return status_sip
+ end
+ end
+
+ def inbound_register
+ username = self.gateway_settings.where(:name => 'inbound_username').first.try(:value)
+ if username.blank?
+ return
+ end
+
+ return SipRegistration.where(:sip_user => username).first
+ end
+
private
+ def status_sip
+ require 'freeswitch_event'
+ result = FreeswitchAPI.api_result(FreeswitchAPI.api('sofia', 'xmlstatus', 'gateway', "gateway#{self.id}"))
+ if result =~ /^\<\?xml/
+ data = Hash.from_xml(result)
+ if data
+ return data.fetch('gateway', nil)
+ end
+ end
+ return nil
+ end
+
def downcase_technology
self.technology = self.technology.downcase if !self.technology.blank?
end