summaryrefslogtreecommitdiff
path: root/misc/freeswitch
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2013-02-12 14:10:26 +0100
committerspag <spag@golwen.net>2013-02-12 14:10:26 +0100
commitfbdb5dca9b3979010b87b16fcb3bf9410c453e91 (patch)
treeced0f7648f7dd6e8f1b580bf839e14e873c2de1a /misc/freeswitch
parent71ed94d7048b97dd804900fb6fba987b26d5a32a (diff)
call parking class added
Diffstat (limited to 'misc/freeswitch')
-rw-r--r--misc/freeswitch/scripts/dialplan/call_parking.lua83
1 files changed, 83 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/dialplan/call_parking.lua b/misc/freeswitch/scripts/dialplan/call_parking.lua
new file mode 100644
index 0000000..cc2cf4b
--- /dev/null
+++ b/misc/freeswitch/scripts/dialplan/call_parking.lua
@@ -0,0 +1,83 @@
+-- Gemeinschaft 5 module: call parking class
+-- (c) AMOOMA GmbH 2013
+--
+
+module(...,package.seeall)
+
+PARKING_STALL_FORMAT = '[0-9A-Z_%+%-]+';
+UUID_FORMAT = '[0-9a-f%-]+';
+
+CallParking = {}
+
+-- create acd object
+function CallParking.new(self, arg)
+ arg = arg or {}
+ object = arg.object or {}
+ setmetatable(object, self);
+ self.__index = self;
+ self.class = 'parkingstall';
+ self.log = arg.log;
+ self.database = arg.database;
+ self.lot = arg.lot or 'default';
+ self.caller = arg.caller;
+ return object;
+end
+
+
+function CallParking.find_by_name(self, name)
+ local sql_query = 'SELECT * FROM `parking_stalls` WHERE `name`= '.. self.database:escape(name, '"') .. ' LIMIT 1';
+ local parking_stall = nil;
+
+ self.database:query(sql_query, function(entry)
+ parking_stall = CallParking:new(self);
+ parking_stall.record = entry;
+ parking_stall.id = tonumber(entry.id);
+ parking_stall.name = entry.name;
+ end)
+
+ return parking_stall;
+end
+
+
+function CallParking.list_occupied(self, lot)
+ lot = lot or self.lot;
+
+ require 'common.fapi'
+ local valet_info = common.fapi.FApi:new{ log = self.log }:execute('valet_info', lot);
+
+ local parking_stalls = {};
+ tostring(valet_info):gsub('<extension uuid="(' .. UUID_FORMAT .. ')">(' .. PARKING_STALL_FORMAT .. ')</extension>', function(channel_uuid, parking_stall)
+ parking_stalls[parking_stall] = channel_uuid;
+ end);
+
+ return parking_stalls;
+end
+
+
+function CallParking.occupied(self)
+ local occupied_stalls = self:list_occupied();
+ if occupied_stalls then
+ return occupied_stalls[self.name];
+ end
+end
+
+
+function CallParking.park_retrieve(self)
+ self.caller:execute("valet_park", self.lot .. ' ' .. self.name);
+end
+
+
+function CallParking.park(self)
+ if self:occupied() then
+ return false;
+ end
+ self.caller:execute("valet_park", self.lot .. ' ' .. self.name);
+end
+
+
+function CallParking.retrieve(self)
+ if not self:occupied() then
+ return false;
+ end
+ self.caller:execute("valet_park", self.lot .. ' ' .. self.name);
+end