Globally reduce copyright headers
[project/luci.git] / applications / luci-app-p910nd / luasrc / model / cbi / p910nd.lua
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
5 local uci = luci.model.uci.cursor_state()
6 local net = require "luci.model.network"
7 local m, s, p, b
8
9 m = Map("p910nd", translate("p910nd - Printer server"),
10         translatef("First you have to install the packages to get support for USB (kmod-usb-printer) or parallel port (kmod-lp)."))
11
12 net = net.init(m.uci)
13
14 s = m:section(TypedSection, "p910nd", translate("Settings"))
15 s.addremove = true
16 s.anonymous = true
17
18 s:option(Flag, "enabled", translate("enable"))
19
20 s:option(Value, "device", translate("Device")).rmempty = true
21
22 b = s:option(Value, "bind", translate("Interface"), translate("Specifies the interface to listen on."))
23 b.template = "cbi/network_netlist"
24 b.nocreate = true
25 b.unspecified = true
26
27 function b.cfgvalue(...)
28         local v = Value.cfgvalue(...)
29         if v then
30                 return (net:get_status_by_address(v))
31         end
32 end
33
34 function b.write(self, section, value)
35         local n = net:get_network(value)
36         if n and n:ipaddr() then
37                 Value.write(self, section, n:ipaddr())
38         end
39 end
40
41 p = s:option(ListValue, "port", translate("Port"), translate("TCP listener port."))
42 p.rmempty = true
43 for i=0,9 do
44         p:value(i, 9100+i)
45 end
46
47 s:option(Flag, "bidirectional", translate("Bidirectional mode"))
48
49 return m