Merge pull request #247 from Wedmer/master
[project/luci.git] / applications / luci-shairplay / luasrc / model / cbi / shairplay.lua
1 --[[
2 LuCI - Lua Configuration Interface - Shairplay support
3
4 Copyright 2014 Álvaro Fernández Rojas <noltari@gmail.com>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 m = Map("shairplay", "Shairplay", translate("Shairplay is a simple AirPlay server implementation, here you can configure the settings."))
16
17 s = m:section(TypedSection, "shairplay", "")
18 s.addremove = true
19 s.anonymous = false
20
21 enable=s:option(Flag, "disabled", translate("Enabled"))
22 enable.enabled="0"
23 enable.disabled="1"
24 enable.default = "1"
25 enable.rmempty = false
26 respawn=s:option(Flag, "respawn", translate("Respawn"))
27 respawn.default = false
28
29 apname = s:option(Value, "apname", translate("Airport Name"))
30 apname.rmempty = true
31
32 port=s:option(Value, "port", translate("Port"))
33 port.rmempty = true
34 port.datatype = "port"
35
36 pw = s:option(Value, "password", translate("Password"))
37 pw.rmempty = true
38 pw.password = true
39
40 hwaddr=s:option(Value, "hwaddr", translate("HW Address"))
41 hwaddr.rmempty = true
42 hwaddr.datatype = "macaddr"
43
44 ao_driver=s:option(ListValue, "ao_driver", translate("AO Driver"))
45 ao_driver:value("", translate("Default"))
46 ao_driver:value("alsa")
47 --ao_driver:value("alsa05")
48 --ao_driver:value("arts")
49 --ao_driver:value("esd")
50 --ao_driver:value("irix")
51 --ao_driver:value("nas")
52 ao_driver:value("oss")
53 --ao_driver:value("sun")
54
55 ao_devicename=s:option(Value, "ao_devicename", translate("AO Device Name"))
56 ao_devicename.rmempty = true
57
58 ao_deviceid = s:option(ListValue, "ao_deviceid", translate("AO Device ID"))
59 ao_deviceid.rmempty = true
60 ao_deviceid:value("", translate("Default"))
61 local pats = io.popen("find /proc/asound/ -type d -name 'card*' | sort")
62 if pats then
63         local l
64         while true do
65                 l = pats:read("*l")
66                 if not l then break end
67
68                 l = string.gsub(l, "/proc/asound/card", "")
69                 if l then
70                         ao_deviceid:value(l)
71                 end
72         end
73         pats:close()
74 end
75
76 return m