From b80bd744ad873f6fc43018bc4bfb90677de167bd Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 17 Dec 2012 12:01:45 +0100 Subject: Start of GS5. --- misc/freeswitch/scripts/phones/uacsta.lua | 100 ++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 misc/freeswitch/scripts/phones/uacsta.lua (limited to 'misc/freeswitch/scripts/phones/uacsta.lua') diff --git a/misc/freeswitch/scripts/phones/uacsta.lua b/misc/freeswitch/scripts/phones/uacsta.lua new file mode 100644 index 0000000..61cb788 --- /dev/null +++ b/misc/freeswitch/scripts/phones/uacsta.lua @@ -0,0 +1,100 @@ +-- 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 -- cgit v1.2.3