From 366bf5fbeabb3290ccad46853db75fce746178b5 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 13 Jun 2016 18:30:32 -0600 Subject: [PATCH] Add local_stream.lua to xml_handler. --- .../scripts/configuration/local_stream.lua | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 resources/install/scripts/app/xml_handler/resources/scripts/configuration/local_stream.lua diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/configuration/local_stream.lua b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/local_stream.lua new file mode 100644 index 0000000000..b3a3bc6f60 --- /dev/null +++ b/resources/install/scripts/app/xml_handler/resources/scripts/configuration/local_stream.lua @@ -0,0 +1,77 @@ + +--connect to the database + require "resources.functions.database_handle"; + dbh = database_handle('system'); + +--exits the script if we didn't connect properly + assert(dbh:connected()); + +--start the xml array + local xml = {} + table.insert(xml, [[]]); + table.insert(xml, [[]]); + table.insert(xml, [[
]]); + table.insert(xml, [[ ]]); + + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + --table.insert(xml, [[ ]]); + +--run the query + sql = "select * from v_music_on_hold "; + sql = sql .. "order by music_on_hold_name asc "; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); + end + x = 0; + dbh:query(sql, function(row) + + --build the xml ]]..row.music_on_hold_name..[[" + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); + if (row.music_on_hold_chime_list ~= nil) then + table.insert(xml, [[ ]]); + end + if (row.music_on_hold_chime_freq ~= nil) then + table.insert(xml, [[ ]]); + end + if (row.music_on_hold_chime_max ~= nil) then + table.insert(xml, [[ ]]); + end + table.insert(xml, [[ ]]); + + end) + +--close the extension tag if it was left open + table.insert(xml, [[ ]]); + table.insert(xml, [[
]]); + table.insert(xml, [[
]]); + XML_STRING = table.concat(xml, "\n"); + if (debug["xml_string"]) then + freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: " .. XML_STRING .. "\n"); + end + +--close the database connection + dbh:release(); + +--send the xml to the console + if (debug["xml_string"]) then + local file = assert(io.open(temp_dir .. "/local_stream.conf.xml", "w")); + file:write(XML_STRING); + file:close(); + end