|
a/src/httpfs.cxx |
|
b/src/httpfs.cxx |
|
... |
|
... |
196 |
{
|
196 |
{
|
197 |
"OHProduct.xml", "OHInfo.xml", "OHTime.xml", "OHVolume.xml",
|
197 |
"OHProduct.xml", "OHInfo.xml", "OHTime.xml", "OHVolume.xml",
|
198 |
"OHPlaylist.xml", "OHRadio.xml"
|
198 |
"OHPlaylist.xml", "OHRadio.xml"
|
199 |
};
|
199 |
};
|
200 |
|
200 |
|
201 |
/** Read protocol info file. This contains the connection manager
|
|
|
202 |
* protocol info data
|
|
|
203 |
*
|
|
|
204 |
* We strip white-space from beginning/ends of lines, and allow
|
|
|
205 |
* #-started comments (on a line alone only, comments after data not allowed).
|
|
|
206 |
*/
|
|
|
207 |
static bool read_protocolinfo(const string& fn, bool enableL16, string& out)
|
|
|
208 |
{
|
|
|
209 |
LOGDEB1("read_protocolinfo: fn " << fn << "\n");
|
|
|
210 |
ifstream input;
|
|
|
211 |
input.open(fn, ios::in);
|
|
|
212 |
if (!input.is_open()) {
|
|
|
213 |
LOGERR("read_protocolinfo: open failed: " << fn << "\n");
|
|
|
214 |
return false;
|
|
|
215 |
}
|
|
|
216 |
bool eof = false;
|
|
|
217 |
for (;;) {
|
|
|
218 |
string line;
|
|
|
219 |
getline(input, line);
|
|
|
220 |
if (!input.good()) {
|
|
|
221 |
if (input.bad()) {
|
|
|
222 |
LOGERR("read_protocolinfo: read error: " << fn << "\n");
|
|
|
223 |
return false;
|
|
|
224 |
}
|
|
|
225 |
// Must be eof ? But maybe we have a partial line which
|
|
|
226 |
// must be processed. This happens if the last line before
|
|
|
227 |
// eof ends with a backslash, or there is no final \n
|
|
|
228 |
eof = true;
|
|
|
229 |
}
|
|
|
230 |
trimstring(line, " \t\n\r,");
|
|
|
231 |
if (!line.empty()) {
|
|
|
232 |
if (enableL16 && line[0] == '@') {
|
|
|
233 |
line = regsub1("@ENABLEL16@", line, "");
|
|
|
234 |
} else {
|
|
|
235 |
line = regsub1("@ENABLEL16@", line, "#");
|
|
|
236 |
}
|
|
|
237 |
if (line[0] == '#')
|
|
|
238 |
continue;
|
|
|
239 |
|
|
|
240 |
out += line + ',';
|
|
|
241 |
}
|
|
|
242 |
if (eof)
|
|
|
243 |
break;
|
|
|
244 |
}
|
|
|
245 |
trimstring(out, ",");
|
|
|
246 |
LOGDEB0("read_protocolinfo data: [" << out << "]\n");
|
|
|
247 |
return true;
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
|
201 |
|
251 |
// Read and setup our (mostly XML) data to make it available from the
|
202 |
// Read and setup our (mostly XML) data to make it available from the
|
252 |
// virtual directory
|
203 |
// virtual directory
|
253 |
bool initHttpFs(unordered_map<string, VDirContent>& files,
|
204 |
bool initHttpFs(unordered_map<string, VDirContent>& files,
|
254 |
const string& datadir,
|
205 |
const string& datadir,
|
255 |
const string& UUID, const string& friendlyname,
|
206 |
const string& UUID, const string& friendlyname,
|
256 |
bool enableAV, bool enableOH, bool enableReceiver,
|
207 |
bool enableAV, bool enableOH, bool enableReceiver,
|
257 |
bool enableL16, bool enableMediaServer, bool msonly,
|
208 |
bool enableMediaServer, bool msonly,
|
258 |
const string& iconpath, const string& presentationhtml)
|
209 |
const string& iconpath, const string& presentationhtml)
|
259 |
{
|
210 |
{
|
260 |
if (msonly) {
|
211 |
if (msonly) {
|
261 |
enableAV=enableOH=enableReceiver=enableL16=false;
|
212 |
enableAV=enableOH=enableReceiver=false;
|
262 |
enableMediaServer = true;
|
213 |
enableMediaServer = true;
|
263 |
}
|
214 |
}
|
264 |
|
215 |
|
265 |
if (enableOH) {
|
216 |
if (enableOH) {
|
266 |
if (enableReceiver) {
|
217 |
if (enableReceiver) {
|
|
... |
|
... |
268 |
}
|
219 |
}
|
269 |
xmlfilenames.insert(xmlfilenames.end(), ohxmlfilenames.begin(),
|
220 |
xmlfilenames.insert(xmlfilenames.end(), ohxmlfilenames.begin(),
|
270 |
ohxmlfilenames.end());
|
221 |
ohxmlfilenames.end());
|
271 |
}
|
222 |
}
|
272 |
|
223 |
|
273 |
string protofile(path_cat(datadir, "protocolinfo.txt"));
|
|
|
274 |
if (!read_protocolinfo(protofile, enableL16, g_protocolInfo)) {
|
|
|
275 |
LOGFAT("Failed reading protocol info from " << protofile << endl);
|
|
|
276 |
return false;
|
|
|
277 |
}
|
|
|
278 |
|
|
|
279 |
vector<ProtocolinfoEntry> vpe;
|
|
|
280 |
parseProtocolInfo(g_protocolInfo, vpe);
|
|
|
281 |
for (const auto& it : vpe) {
|
|
|
282 |
g_supportedFormats.insert(it.contentFormat);
|
|
|
283 |
}
|
|
|
284 |
|
|
|
285 |
string reason;
|
224 |
string reason;
|
286 |
string icondata;
|
225 |
string icondata;
|
287 |
if (!iconpath.empty()) {
|
226 |
if (!iconpath.empty()) {
|
288 |
if (!file_to_string(iconpath, icondata, &reason)) {
|
227 |
if (!file_to_string(iconpath, icondata, &reason)) {
|
289 |
if (iconpath.compare("/usr/share/upmpdcli/icon.png")) {
|
228 |
if (iconpath.compare("/usr/share/upmpdcli/icon.png")) {
|