1
0

ltqtapi.lua 1.0 KB

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