Globally reduce copyright headers
[project/luci.git] / applications / luci-app-minidlna / luasrc / model / cbi / minidlna.lua
1 -- Copyright 2012 Gabor Juhos <juhosg@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local m, s, o
5
6 m = Map("minidlna", translate("miniDLNA"),
7         translate("MiniDLNA is server software with the aim of being fully compliant with DLNA/UPnP-AV clients."))
8
9 m:section(SimpleSection).template  = "minidlna_status"
10
11 s = m:section(TypedSection, "minidlna", "miniDLNA Settings")
12 s.addremove = false
13 s.anonymous = true
14
15 s:tab("general", translate("General Settings"))
16 s:tab("advanced", translate("Advanced Settings"))
17
18 o = s:taboption("general", Flag, "enabled", translate("Enable:"))
19 o.rmempty = false
20
21 function o.cfgvalue(self, section)
22         return luci.sys.init.enabled("minidlna") and self.enabled or self.disabled
23 end
24
25 function o.write(self, section, value)
26         if value == "1" then
27                 luci.sys.init.enable("minidlna")
28                 luci.sys.call("/etc/init.d/minidlna start >/dev/null")
29         else
30                 luci.sys.call("/etc/init.d/minidlna stop >/dev/null")
31                 luci.sys.init.disable("minidlna")
32         end
33
34         return Flag.write(self, section, value)
35 end
36
37 o = s:taboption("general", Value, "port", translate("Port:"),
38         translate("Port for HTTP (descriptions, SOAP, media transfer) traffic."))
39 o.datatype = "port"
40 o.default = 8200
41
42
43 o = s:taboption("general", Value, "interface", translate("Interfaces:"),
44         translate("Network interfaces to serve."))
45
46 o.template = "cbi/network_ifacelist"
47 o.widget   = "checkbox"
48 o.nocreate = true
49
50 function o.cfgvalue(self, section)
51         local rv = { }
52         local val = Value.cfgvalue(self, section)
53         if val then
54                 local ifc
55                 for ifc in val:gmatch("[^,%s]+") do
56                         rv[#rv+1] = ifc
57                 end
58         end
59         return rv
60 end
61
62 function o.write(self, section, value)
63         local rv = { }
64         local ifc
65         for ifc in luci.util.imatch(value) do
66                 rv[#rv+1] = ifc
67         end
68         Value.write(self, section, table.concat(rv, ","))
69 end
70
71
72 o = s:taboption("general", Value, "friendly_name", translate("Friendly name:"),
73         translate("Set this if you want to customize the name that shows up on your clients."))
74 o.rmempty = true
75 o.placeholder = "OpenWrt DLNA Server"
76
77 o = s:taboption("advanced", Value, "db_dir", translate("Database directory:"),
78         translate("Set this if you would like to specify the directory where you want MiniDLNA to store its database and album art cache."))
79 o.rmempty = true
80 o.placeholder = "/var/cache/minidlna"
81
82 o = s:taboption("advanced", Value, "log_dir", translate("Log directory:"),
83         translate("Set this if you would like to specify the directory where you want MiniDLNA to store its log file."))
84 o.rmempty = true
85 o.placeholder = "/var/log"
86
87 s:taboption("advanced", Flag, "inotify", translate("Enable inotify:"),
88         translate("Set this to enable inotify monitoring to automatically discover new files."))
89
90 s:taboption("advanced", Flag, "enable_tivo", translate("Enable TIVO:"),
91         translate("Set this to enable support for streaming .jpg and .mp3 files to a TiVo supporting HMO."))
92 o.rmempty = true
93
94 o = s:taboption("advanced", Flag, "strict_dlna", translate("Strict to DLNA standard:"),
95         translate("Set this to strictly adhere to DLNA standards. This will allow server-side downscaling of very large JPEG images, which may hurt JPEG serving performance on (at least) Sony DLNA products."))
96 o.rmempty = true
97
98 o = s:taboption("advanced", Value, "presentation_url", translate("Presentation URL:"))
99 o.rmempty = true
100 o.placeholder = "http://192.168.1.1/"
101
102 o = s:taboption("advanced", Value, "notify_interval", translate("Notify interval:"),
103         translate("Notify interval in seconds."))
104 o.datatype = "uinteger"
105 o.placeholder = 900
106
107 o = s:taboption("advanced", Value, "serial", translate("Announced serial number:"),
108         translate("Serial number the miniDLNA daemon will report to clients in its XML description."))
109 o.placeholder = "12345678"
110
111 s:taboption("advanced", Value, "model_number", translate("Announced model number:"),
112         translate("Model number the miniDLNA daemon will report to clients in its XML description."))
113 o.placholder = "1"
114
115 o = s:taboption("advanced", Value, "minissdpsocket", translate("miniSSDP socket:"),
116         translate("Specify the path to the MiniSSDPd socket."))
117 o.rmempty = true
118 o.placeholder = "/var/run/minissdpd.sock"
119
120 o = s:taboption("general", ListValue, "root_container", translate("Root container:"))
121 o:value(".", translate("Standard container"))
122 o:value("B", translate("Browse directory"))
123 o:value("M", translate("Music"))
124 o:value("V", translate("Video"))
125 o:value("P", translate("Pictures"))
126
127
128 s:taboption("general", DynamicList, "media_dir", translate("Media directories:"),
129         translate("Set this to the directory you want scanned. If you want to restrict the directory to a specific content type, you can prepend the type ('A' for audio, 'V' for video, 'P' for images), followed by a comma, to the directory (eg. media_dir=A,/mnt/media/Music). Multiple directories can be specified."))
130
131
132 o = s:taboption("general", DynamicList, "album_art_names", translate("Album art names:"),
133         translate("This is a list of file names to check for when searching for album art."))
134 o.rmempty = true
135 o.placeholder = "Cover.jpg"
136
137 function o.cfgvalue(self, section)
138         local rv = { }
139
140         local val = Value.cfgvalue(self, section)
141         if type(val) == "table" then
142                 val = table.concat(val, "/")
143         elseif not val then
144                 val = ""
145         end
146
147         local file
148         for file in val:gmatch("[^/%s]+") do
149                 rv[#rv+1] = file
150         end
151
152         return rv
153 end
154
155 function o.write(self, section, value)
156         local rv = { }
157         local file
158         for file in luci.util.imatch(value) do
159                 rv[#rv+1] = file
160         end
161         Value.write(self, section, table.concat(rv, "/"))
162 end
163
164
165 return m