-- CommonModule: Uacsta
--
module(...,package.seeall)
Uacsta = {}
-- Create Uacsta object
function Uacsta.new(self, arg)
arg = arg or {}
object = arg.object or {}
setmetatable(object, self)
self.__index = self
self.log = arg.log;
return object
end
function Uacsta.send(self, sip_account, domain, body)
local event = freeswitch.Event("NOTIFY");
event:addHeader("profile", "gemeinschaft");
event:addHeader("event-string", "uaCSTA");
event:addHeader("user", sip_account);
event:addHeader("host", domain);
event:addHeader("content-type", "application/csta+xml");
event:addBody(body);
event:fire();
end
function Uacsta.make_call(self, sip_account, domain, number)
local body =
[[
]] .. sip_account .. [[
]] .. number .. [[
doNotPrompt
]]
self:send(sip_account, domain, body);
end
function Uacsta.answer_call(self, sip_account, domain)
local body =
[[
]] .. sip_account .. [[
]]
self:send(sip_account, domain, body);
end
function Uacsta.set_microphone_mute(self, sip_account, domain, value)
local body =
[[
]] .. sip_account .. [[
1
]] .. tostring(value) .. [[
]]
self:send(sip_account, domain, body);
end
function Uacsta.set_speaker_volume(self, sip_account, domain, value)
local body =
[[
]] .. sip_account .. [[
1
]] .. tonumber(value) .. [[
]]
self:send(sip_account, domain, body);
end
function Uacsta.set_do_not_disturb(self, sip_account, domain, value)
local body =
[[
]] .. sip_account .. [[
]] .. tostring(value) .. [[
]]
self:send(sip_account, domain, body);
end
function Uacsta.set_forwarding(self, sip_account, domain, forwarding_type, number, activate)
local forwarding_types = { "forwardImmediate", "forwardBusy", "forwardNoAns" }
local body =
[[
]] .. sip_account .. [[
]] .. tostring(forwarding_types[tonumber(forwarding_type)]) .. [[
]] .. number .. [[
]] .. tostring(activate) .. [[
]]
self:send(sip_account, domain, body);
end