3f59e536434ed16b3ce9ea1caa62a3c92a687f26
[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 s:taboption("advanced", Flag, "wide_links", translate("Allow wide links"),
95         translate("Set this to allow serving content outside the media root (via symlinks)."))
96 o.rmempty = true
97
98 o = s:taboption("advanced", Flag, "strict_dlna", translate("Strict to DLNA standard:"),
99         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."))
100 o.rmempty = true
101
102 o = s:taboption("advanced", Value, "presentation_url", translate("Presentation URL:"))
103 o.rmempty = true
104 o.placeholder = "http://192.168.1.1/"
105
106 o = s:taboption("advanced", Value, "notify_interval", translate("Notify interval:"),
107         translate("Notify interval in seconds."))
108 o.datatype = "uinteger"
109 o.placeholder = 900
110
111 o = s:taboption("advanced", Value, "serial", translate("Announced serial number:"),
112         translate("Serial number the miniDLNA daemon will report to clients in its XML description."))
113 o.placeholder = "12345678"
114
115 s:taboption("advanced", Value, "model_number", translate("Announced model number:"),
116         translate("Model number the miniDLNA daemon will report to clients in its XML description."))
117 o.placholder = "1"
118
119 o = s:taboption("advanced", Value, "minissdpsocket", translate("miniSSDP socket:"),
120         translate("Specify the path to the MiniSSDPd socket."))
121 o.rmempty = true
122 o.placeholder = "/var/run/minissdpd.sock"
123
124 o = s:taboption("general", ListValue, "root_container", translate("Root container:"))
125 o:value(".", translate("Standard container"))
126 o:value("B", translate("Browse directory"))
127 o:value("M", translate("Music"))
128 o:value("V", translate("Video"))
129 o:value("P", translate("Pictures"))
130
131
132 s:taboption("general", DynamicList, "media_dir", translate("Media directories:"),
133         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. A,/mnt/media/Music). Multiple directories can be specified."))
134
135
136 o = s:taboption("general", DynamicList, "album_art_names", translate("Album art names:"),
137         translate("This is a list of file names to check for when searching for album art."))
138 o.rmempty = true
139 o.placeholder = "Cover.jpg"
140
141 function o.cfgvalue(self, section)
142         local rv = { }
143
144         local val = Value.cfgvalue(self, section)
145         if type(val) == "table" then
146                 val = table.concat(val, "/")
147         elseif not val then
148                 val = ""
149         end
150
151         local file
152         for file in val:gmatch("[^/%s]+") do
153                 rv[#rv+1] = file
154         end
155
156         return rv
157 end
158
159 function o.write(self, section, value)
160         local rv = { }
161         local file
162         for file in luci.util.imatch(value) do
163                 rv[#rv+1] = file
164         end
165         Value.write(self, section, table.concat(rv, "/"))
166 end
167
168
169 return m