Globally reduce copyright headers
[project/luci.git] / applications / luci-app-ltqtapi / luasrc / controller / ltqtapi.lua
1 -- Copyright 2019 John Crispin <blogic@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 module("luci.controller.ltqtapi", package.seeall)
5
6 function index()
7         if not nixio.fs.access("/etc/config/telephony") then
8                 return
9         end
10
11         page = node("admin", "telephony")
12         page.target = firstchild()
13         page.title  = _("VoIP")
14         page.order  = 90
15
16         entry({"admin", "telephony", "account"}, cbi("luci_ltqtapi/account") , _("Account"), 10)
17         entry({"admin", "telephony", "contact"}, cbi("luci_ltqtapi/contact") , _("Contacts"), 20)
18
19         entry({"admin", "telephony", "status"}, call("tapi_status")).leaf = true
20 end
21
22 function tapi_status()
23         local st = { }
24         local state = require "luci.model.uci".cursor_state()
25         state:load("telephony")
26
27         st.status = "Offline";
28         if state:get("telephony", "state", "port1", "0") == "0" then
29                 st.line1 = "Idle";
30         else
31                 st.line1 = "Calling";
32         end
33         if state:get("telephony", "state", "port2", "0") == "0" then
34                 st.line2 = "Idle";
35         else
36                 st.line2 = "Calling";
37         end
38         luci.http.prepare_content("application/json")
39         luci.http.write_json(st)
40 end