applications/luci-p910nd: expose bind parameter
[project/luci.git] / applications / luci-p910nd / luasrc / model / cbi / p910nd.lua
1 --[[
2
3 LuCI p910nd
4 (c) 2008 Yanira <forum-2008@email.de>
5 (c) 2012 Jo-Philipp Wich <jow@openwrt.org>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 ]]--
14
15 local uci = luci.model.uci.cursor_state()
16 local net = require "luci.model.network"
17 local m, s, p, b
18
19 m = Map("p910nd", translate("p910nd - Printer server"),
20         translatef("First you have to install the packages to get support for USB (kmod-usb-printer) or parallel port (kmod-lp)."))
21
22 net = net.init(m.uci)
23
24 s = m:section(TypedSection, "p910nd", translate("Settings"))
25 s.addremove = true
26 s.anonymous = true
27
28 s:option(Flag, "enabled", translate("enable"))
29
30 s:option(Value, "device", translate("Device")).rmempty = true
31
32 b = s:option(Value, "bind", translate("Interface"), translate("Specifies the interface to listen on."))
33 b.template = "cbi/network_netlist"
34 b.nocreate = true
35 b.unspecified = true
36
37 function b.cfgvalue(...)
38         local v = Value.cfgvalue(...)
39         if v then
40                 return (net:get_status_by_address(v))
41         end
42 end
43
44 function b.write(self, section, value)
45         local n = net:get_network(value)
46         if n and n:ipaddr() then
47                 Value.write(self, section, n:ipaddr())
48         end
49 end
50
51 p = s:option(ListValue, "port", translate("Port"), translate("TCP listener port."))
52 p.rmempty = true
53 for i=0,9 do
54         p:value(i, 9100+i)
55 end
56
57 s:option(Flag, "bidirectional", translate("Bidirectional mode"))
58
59 return m