summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'misc/freeswitch/scripts')
-rw-r--r--misc/freeswitch/scripts/dialplan/dialplan.lua1
-rw-r--r--misc/freeswitch/scripts/dialplan/presence.lua1
-rw-r--r--misc/freeswitch/scripts/event/presence_update.lua4
-rw-r--r--misc/freeswitch/scripts/phones/phone.lua7
-rw-r--r--misc/freeswitch/scripts/phones/yealink.lua60
5 files changed, 70 insertions, 3 deletions
diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua
index 1133f58..b39acff 100644
--- a/misc/freeswitch/scripts/dialplan/dialplan.lua
+++ b/misc/freeswitch/scripts/dialplan/dialplan.lua
@@ -18,6 +18,7 @@ local CALL_FORWARDING_SERVICES = {
HUNT_GROUP_EMPTY = 'offline',
ACD_NO_AGENTS = 'offline',
ACD_TIMEOUT = 'noanswer',
+ NO_USER_RESPONSE = 'offline',
}
-- create dialplan object
diff --git a/misc/freeswitch/scripts/dialplan/presence.lua b/misc/freeswitch/scripts/dialplan/presence.lua
index 0f63ce9..af05756 100644
--- a/misc/freeswitch/scripts/dialplan/presence.lua
+++ b/misc/freeswitch/scripts/dialplan/presence.lua
@@ -53,6 +53,7 @@ function Presence.set(self, state, caller_number)
event:addHeader('presence-call-direction', direction);
event:addHeader('answer-state', state);
event:addHeader('unique-id', self.uuid);
+ event:addHeader('event_origin', 'gemeinschaft');
if caller_number then
if self.inbound then
event:addHeader('Caller-Destination-Number', caller_number);
diff --git a/misc/freeswitch/scripts/event/presence_update.lua b/misc/freeswitch/scripts/event/presence_update.lua
index cf29ca9..24b19d5 100644
--- a/misc/freeswitch/scripts/event/presence_update.lua
+++ b/misc/freeswitch/scripts/event/presence_update.lua
@@ -128,7 +128,9 @@ function PresenceUpdate.presence_in(self, event)
direction = false;
end
- if protocol == 'conf' then
+ if tostring(event:getHeader('event_origin')) == 'gemeinschaft' then
+ self.log:debug('[', uuid,'] PRESENCE_', call_direction:upper(),'_LOOP ignored - protocol: ', protocol, ', account: ', account, ', state: ', state);
+ elseif protocol == 'conf' then
state = event:getHeader('answer-state');
local login = tostring(event:getHeader('proto'));
self.log:info('[', uuid,'] PRESENCE_CONFERENCE_', call_direction:upper(), ' ', common.str.to_i(account), ' - identifier: ', account, ', state: ', state);
diff --git a/misc/freeswitch/scripts/phones/phone.lua b/misc/freeswitch/scripts/phones/phone.lua
index 6219eb1..174503b 100644
--- a/misc/freeswitch/scripts/phones/phone.lua
+++ b/misc/freeswitch/scripts/phones/phone.lua
@@ -27,11 +27,14 @@ function Phone.list_by_sql(self, sql_query)
phone.record.ieee_name = common.str.downcase(account_entry.ieee_name);
if phone.record.ieee_name == 'snom technology ag' then
- require 'phones.snom'
+ require 'phones.snom';
phone.model = phones.snom.Snom:new{ log = self.log };
elseif account_entry.ieee_name == 'siemens enterprise communicationsgmbh & co. kg' then
- require 'phones.siemens'
+ require 'phones.siemens';
phone.model = phones.siemens.Siemens:new{ log = self.log };
+ elseif phone.record.ieee_name == 'xiamen yealink network technology co.,ltd' then
+ require 'phones.yealink';
+ phone.model = phones.yealink.Yealink:new{ log = self.log };
end
table.insert(account_phones, phone);
end)
diff --git a/misc/freeswitch/scripts/phones/yealink.lua b/misc/freeswitch/scripts/phones/yealink.lua
new file mode 100644
index 0000000..2794ed6
--- /dev/null
+++ b/misc/freeswitch/scripts/phones/yealink.lua
@@ -0,0 +1,60 @@
+-- Gemeinschaft 5 module: general yealink model class
+-- (c) AMOOMA GmbH 2013
+--
+
+module(...,package.seeall)
+
+Yealink = {}
+
+-- Create Yealink object
+function Yealink.new(self, arg)
+ arg = arg or {}
+ object = arg.object or {}
+ setmetatable(object, self);
+ self.__index = self;
+ self.log = arg.log;
+ self.reboot = arg.reboot or true;
+ return object;
+end
+
+-- send reload message to phone
+function Yealink.resync(self, arg)
+ if arg.reboot == nil then
+ arg.reboot = self.reboot;
+ end
+
+ local success = nil;
+ if arg.auth_name and arg.domain then
+ success = self:resync_sip(arg.auth_name, arg.domain, arg.reboot);
+ end
+
+ if arg.ip_address and arg.reboot then
+ success = self:resync_http(arg.ip_address, arg.http_user, arg.http_password, arg.http_port);
+ end
+
+ return success;
+end
+
+-- send reload message to sip_account
+function Yealink.resync_sip(self, sip_account, domain, reboot)
+ local event = freeswitch.Event('NOTIFY');
+ event:addHeader('profile', 'gemeinschaft');
+ event:addHeader('event-string', 'check-sync;reboot=' .. tostring(reboot));
+ event:addHeader('user', sip_account);
+ event:addHeader('host', domain);
+ event:addHeader('content-type', 'application/simple-message-summary');
+ return event:fire();
+end
+
+-- send reload message to ip
+function Yealink.resync_http(self, ip_address, http_user, http_password, http_port)
+ local port_str = '';
+ if tonumber(http_port) then
+ port_str = ':' .. http_port;
+ end
+
+ local command = 'http_request.lua yealink_resync http://' .. tostring(ip_address):gsub('[^0-9%.]', '') .. port_str .. '/cgi-bin/ConfigManApp.com?key=Reboot ' .. (http_user or '') .. ' ' .. (http_password or '');
+
+ require 'common.fapi'
+ return common.fapi.FApi:new():execute('luarun', command);
+end