p910nd.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. -- Copyright 2008 Yanira <forum-2008@email.de>
  2. -- Copyright 2012 Jo-Philipp Wich <jow@openwrt.org>
  3. -- Licensed to the public under the Apache License 2.0.
  4. local uci = luci.model.uci.cursor_state()
  5. local net = require "luci.model.network"
  6. local m, s, p, b
  7. m = Map("p910nd", translate("p910nd - Printer server"),
  8. translatef("First you have to install the packages to get support for USB (kmod-usb-printer) or parallel port (kmod-lp)."))
  9. net = net.init(m.uci)
  10. s = m:section(TypedSection, "p910nd", translate("Settings"))
  11. s.addremove = true
  12. s.anonymous = true
  13. s:option(Flag, "enabled", translate("enable"))
  14. s:option(Value, "device", translate("Device")).rmempty = true
  15. b = s:option(Value, "bind", translate("Interface"), translate("Specifies the interface to listen on."))
  16. b.template = "cbi/network_netlist"
  17. b.nocreate = true
  18. b.unspecified = true
  19. function b.cfgvalue(...)
  20. local v = Value.cfgvalue(...)
  21. if v then
  22. return (net:get_status_by_address(v))
  23. end
  24. end
  25. function b.write(self, section, value)
  26. local n = net:get_network(value)
  27. if n and n:ipaddr() then
  28. Value.write(self, section, n:ipaddr())
  29. end
  30. end
  31. p = s:option(ListValue, "port", translate("Port"), translate("TCP listener port."))
  32. p.rmempty = true
  33. for i=0,9 do
  34. p:value(i, 9100+i)
  35. end
  36. s:option(Flag, "bidirectional", translate("Bidirectional mode"))
  37. return m