Switch to unified view

a/src/httpfs.cxx b/src/httpfs.cxx
...
...
129
129
130
static const string presDesc(
130
static const string presDesc(
131
    "<presentationURL>/upmpd/presentation.html</presentationURL>"
131
    "<presentationURL>/upmpd/presentation.html</presentationURL>"
132
    );
132
    );
133
133
134
static const string deviceMedia(
134
// description file fragment for Media Server as embedded device
135
static const string embedms_desc(
135
    "<device>"
136
    "<device>"
136
    "<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>"
137
    "<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>"
137
    "<friendlyName>@FRIENDLYNAMEMEDIA@</friendlyName>"
138
    "<friendlyName>@FRIENDLYNAMEMEDIA@</friendlyName>"
138
    "<UDN>uuid:@UUIDMEDIA@</UDN>"
139
    "<UDN>uuid:@UUIDMEDIA@</UDN>"
139
    "<serviceList>"
140
    "<serviceList>"
...
...
153
    "</service>"
154
    "</service>"
154
    "</serviceList>"
155
    "</serviceList>"
155
    "</device>"
156
    "</device>"
156
    );
157
    );
157
158
159
// Description file for Media Server as root device
160
static const string msonly_desc(
161
    "<?xml version=\"1.0\"?>"
162
    "<root xmlns=\"urn:schemas-upnp-org:device-1-0\">"
163
    "<specVersion><major>1</major><minor>0</minor></specVersion>"
164
    "<device>"
165
    "<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>"
166
    "<friendlyName>@FRIENDLYNAMEMEDIA@</friendlyName>"
167
    "<UDN>uuid:@UUIDMEDIA@</UDN>"
168
    "@ICONLIST@"
169
    "<serviceList><service>"
170
    "<serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>"
171
    "<serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>"
172
    "<SCPDURL>/upmpd/ConnectionManager.xml</SCPDURL>"
173
    "<controlURL>/ctl1/ConnectionManager</controlURL>"
174
    "<eventSubURL>/evt1/ConnectionManager</eventSubURL>"
175
    "</service><service>"
176
    "<serviceType>urn:schemas-upnp-org:service:ContentDirectory:1</serviceType>"
177
    "<serviceId>urn:upnp-org:serviceId:ContentDirectory</serviceId>"
178
    "<SCPDURL>/upmpd/ContentDirectory.xml</SCPDURL>"
179
    "<controlURL>/ctl1/ContentDirectory</controlURL>"
180
    "<eventSubURL>/evt1/ContentDirectory</eventSubURL>"
181
    "</service></serviceList>"
182
    "</device>"
183
    "</root>"
184
    );
185
158
// The base XML description files. !Keep description.xml first!
186
// The base XML description files. !Keep description.xml first!
159
static vector<const char *> xmlfilenames = 
187
static vector<const char *> xmlfilenames = 
160
{
188
{
161
    /* keep first */ "description.xml", /* keep first */
189
    /* keep first */ "description.xml", /* keep first */
162
    "RenderingControl.xml", "AVTransport.xml", "ConnectionManager.xml",
190
    "RenderingControl.xml", "AVTransport.xml", "ConnectionManager.xml",
191
    "ContentDirectory.xml"
163
};
192
};
164
193
165
// Optional OpenHome service description files
194
// Optional OpenHome service description files
166
static vector<const char *> ohxmlfilenames = 
195
static vector<const char *> ohxmlfilenames = 
167
{
196
{
168
    "OHProduct.xml", "OHInfo.xml", "OHTime.xml", "OHVolume.xml", 
197
    "OHProduct.xml", "OHInfo.xml", "OHTime.xml", "OHVolume.xml", 
169
    "OHPlaylist.xml", "OHRadio.xml", "ContentDirectory.xml"
198
    "OHPlaylist.xml", "OHRadio.xml"
170
};
199
};
171
200
172
/** Read protocol info file. This contains the connection manager
201
/** Read protocol info file. This contains the connection manager
173
 * protocol info data
202
 * protocol info data
174
 *
203
 *
...
...
215
// virtual directory
244
// virtual directory
216
bool initHttpFs(unordered_map<string, VDirContent>& files,
245
bool initHttpFs(unordered_map<string, VDirContent>& files,
217
                const string& datadir,
246
                const string& datadir,
218
                const string& UUID, const string& friendlyname, 
247
                const string& UUID, const string& friendlyname, 
219
                bool enableAV, bool enableOH, bool enableReceiver,
248
                bool enableAV, bool enableOH, bool enableReceiver,
220
                bool enableL16, bool enableMediaServer,
249
                bool enableL16, bool enableMediaServer, bool msonly,
221
                const string& iconpath, const string& presentationhtml)
250
                const string& iconpath, const string& presentationhtml)
222
{
251
{
252
    if (msonly) {
253
        enableAV=enableOH=enableReceiver=enableL16=false;
254
        enableMediaServer = true;
255
    }
256
223
    if (enableOH) {
257
    if (enableOH) {
224
        if (enableReceiver) {
258
        if (enableReceiver) {
225
            ohxmlfilenames.push_back("OHReceiver.xml");
259
            ohxmlfilenames.push_back("OHReceiver.xml");
226
        }
260
        }
227
        xmlfilenames.insert(xmlfilenames.end(), ohxmlfilenames.begin(),
261
        xmlfilenames.insert(xmlfilenames.end(), ohxmlfilenames.begin(),
...
...
261
        if (!file_to_string(filename, data, &reason)) {
295
        if (!file_to_string(filename, data, &reason)) {
262
            LOGFAT("Failed reading " << filename << " : " << reason << endl);
296
            LOGFAT("Failed reading " << filename << " : " << reason << endl);
263
            return false;
297
            return false;
264
        }
298
        }
265
        if (i == 0) {
299
        if (i == 0) {
266
            // Special for description: set UUID and friendlyname
300
            // Description
301
            if (!msonly) {
302
                // Set UUID and friendlyname for renderer
267
            data = regsub1("@UUID@", data, UUID);
303
                data = regsub1("@UUID@", data, UUID);
268
            data = regsub1("@FRIENDLYNAME@", data, friendlyname);
304
                data = regsub1("@FRIENDLYNAME@", data, friendlyname);
305
            }
269
306
270
        if (enableMediaServer) {
307
        if (enableMediaServer && !msonly) {
308
                // Edit embedded media server description and
309
                // subsitute it in main description
271
        string msdesc = regsub1("@UUIDMEDIA@", deviceMedia,
310
        string msdesc = regsub1("@UUIDMEDIA@", embedms_desc,
272
                    uuidMediaServer(UUID));
311
                    uuidMediaServer(UUID));
273
        msdesc = regsub1("@FRIENDLYNAMEMEDIA@", msdesc,
312
        msdesc = regsub1("@FRIENDLYNAMEMEDIA@", msdesc,
274
                 friendlyNameMediaServer(friendlyname));
313
                 friendlyNameMediaServer(friendlyname));
275
                data = regsub1("@MEDIASERVER@", data, msdesc);
314
                data = regsub1("@MEDIASERVER@", data, msdesc);
276
      } else {
315
      } else if (msonly) {
316
                // Substitute values in msonly description
317
      data = regsub1("@UUIDMEDIA@", msonly_desc,
318
                               uuidMediaServer(UUID));
319
      data = regsub1("@FRIENDLYNAMEMEDIA@", data,
320
                               friendlyNameMediaServer(friendlyname));
321
            } else {
322
                // No media server: erase the section
277
                data = regsub1("@MEDIASERVER@", data, "");
323
                data = regsub1("@MEDIASERVER@", data, "");
278
        }
324
        }
279
325
280
            if (enableAV) {
326
            if (enableAV) {
281
                data = regsub1("@UPNPAV@", data, upnpAVDesc);
327
                data = regsub1("@UPNPAV@", data, upnpAVDesc);
...
...
298
                data = regsub1("@ICONLIST@", data, "");
344
                data = regsub1("@ICONLIST@", data, "");
299
            if (!presentationdata.empty())
345
            if (!presentationdata.empty())
300
                data = regsub1("@PRESENTATION@", data, presDesc);
346
                data = regsub1("@PRESENTATION@", data, presDesc);
301
            else
347
            else
302
                data = regsub1("@PRESENTATION@", data, "");
348
                data = regsub1("@PRESENTATION@", data, "");
303
        }
349
        } // End description file editing
350
304
        files.insert(pair<string, VDirContent>
351
        files.insert(pair<string, VDirContent>
305
                     (dir + xmlfilenames[i], 
352
                     (dir + xmlfilenames[i], 
306
                      VDirContent(data, "application/xml")));
353
                      VDirContent(data, "application/xml")));
307
    }
354
    }
308
355