summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/phones/gigaset.lua
blob: b37b6385c82aa3ab72731ae99ca7f20b3f55d32e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
-- Gemeinschaft 5 module: general gigaset model class
-- (c) Peter Kozak 2013
-- 

module(...,package.seeall)

Gigaset = {}

-- Create Gigaset object
function Gigaset.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 Gigaset.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 Gigaset.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 phpne ip
function Gigaset.resync_http(self, ip_address, http_user, http_password, http_port)
  return nil;
end