Switch to unified view

a/src/httpfs.cxx b/src/httpfs.cxx
...
...
17
17
18
#include <unordered_map>
18
#include <unordered_map>
19
#include <string>
19
#include <string>
20
20
21
#include "libupnpp/log.hxx"
21
#include "libupnpp/log.hxx"
22
#include "libupnpp/upnpplib.hxx"
22
#include "libupnpp/upnpavutils.hxx"
23
#include "libupnpp/upnpavutils.hxx"
23
#include "libupnpp/device/device.hxx"
24
#include "libupnpp/device/device.hxx"
24
25
25
#include "main.hxx"
26
#include "main.hxx"
26
#include "upmpdutils.hxx"
27
#include "upmpdutils.hxx"
27
#include "smallut.h"
28
#include "smallut.h"
28
#include "pathut.h"
29
#include "pathut.h"
29
#include "readfile.h"
30
#include "readfile.h"
30
#include "httpfs.hxx"
31
#include "httpfs.hxx"
32
#include "conftree.h"
31
33
32
using namespace std;
34
using namespace std;
33
using namespace UPnPP;
35
using namespace UPnPP;
34
using namespace UPnPProvider;
36
using namespace UPnPProvider;
35
37
...
...
54
    );
56
    );
55
57
56
// The description XML document is the first thing downloaded by
58
// The description XML document is the first thing downloaded by
57
// clients and tells them what services we export, and where to find
59
// clients and tells them what services we export, and where to find
58
// them. The base data is in /usr/shared/upmpdcli/description.xml, it
60
// them. The base data is in /usr/shared/upmpdcli/description.xml, it
59
// has a number of substitutable fields for optional data, like the
61
// has a number of substitutable fields for optional data, which we
62
// conditionally substitute into the file data (e.g. description of
63
// OpenHome or other optional services)
64
60
// description of OpenHome services
65
// Description of OpenHome services
61
static string ohDesc(
66
static string ohDesc(
62
    "<service>"
67
    "<service>"
63
    "  <serviceType>urn:av-openhome-org:service:Product:1</serviceType>"
68
    "  <serviceType>urn:av-openhome-org:service:Product:1</serviceType>"
64
    "  <serviceId>urn:av-openhome-org:serviceId:Product</serviceId>"
69
    "  <serviceId>urn:av-openhome-org:serviceId:Product</serviceId>"
65
    "  <SCPDURL>/upmpd/OHProduct.xml</SCPDURL>"
70
    "  <SCPDURL>/upmpd/OHProduct.xml</SCPDURL>"
...
...
196
{
201
{
197
    "OHProduct.xml", "OHInfo.xml", "OHTime.xml", "OHVolume.xml", 
202
    "OHProduct.xml", "OHInfo.xml", "OHTime.xml", "OHVolume.xml", 
198
    "OHPlaylist.xml", "OHRadio.xml"
203
    "OHPlaylist.xml", "OHRadio.xml"
199
};
204
};
200
205
201
202
// Read and setup our (mostly XML) data to make it available from the
206
// Read and setup our (mostly XML) data to make it available from the
203
// virtual directory
207
// virtual directory
204
bool initHttpFs(unordered_map<string, VDirContent>& files,
208
bool initHttpFs(unordered_map<string, VDirContent>& files,
205
                const string& datadir,
209
                const string& datadir,
206
                const string& UUID, const string& friendlyname, 
210
                const UDevIds& ids,
207
                bool enableAV, bool enableOH, bool enableReceiver,
211
                bool enableAV, bool enableOH, bool enableReceiver,
208
                bool enableMediaServer, bool msonly,
212
                bool enableMediaServer, bool msonly,
209
                const string& iconpath, const string& presentationhtml)
213
                const string& iconpath, const string& presentationhtml)
210
{
214
{
211
    if (msonly) {
215
    if (msonly) {
...
...
233
        }
237
        }
234
    }
238
    }
235
    string presentationdata;
239
    string presentationdata;
236
    if (!presentationhtml.empty()) {
240
    if (!presentationhtml.empty()) {
237
        if (!file_to_string(presentationhtml, presentationdata, &reason)) {
241
        if (!file_to_string(presentationhtml, presentationdata, &reason)) {
238
            LOGERR("Failed reading " << presentationhtml << " : " << reason << endl);
242
            LOGERR("Failed reading " << presentationhtml << " : " << reason <<
243
                   endl);
239
        }
244
        }
240
    }
245
    }
241
246
242
    string dir("/upmpd/");
247
    string dir("/upmpd/");
243
    for (unsigned int i = 0; i < xmlfilenames.size(); i++) {
248
    for (unsigned int i = 0; i < xmlfilenames.size(); i++) {
...
...
249
        }
254
        }
250
        if (i == 0) {
255
        if (i == 0) {
251
            // Description
256
            // Description
252
            if (!msonly) {
257
            if (!msonly) {
253
                // Set UUID and friendlyname for renderer
258
                // Set UUID and friendlyname for renderer
254
                data = regsub1("@UUID@", data, UUID);
259
                data = regsub1("@UUID@", data, ids.uuid);
255
                data = regsub1("@FRIENDLYNAME@", data, friendlyname);
260
                data = regsub1("@FRIENDLYNAME@", data, ids.fname);
256
            }
261
            }
257
262
258
      if (enableMediaServer && !msonly) {
263
            if (enableMediaServer && !msonly) {
259
                // Edit embedded media server description and
264
                // Edit embedded media server description and
260
                // subsitute it in main description
265
                // subsitute it in main description
261
      string msdesc = regsub1("@UUIDMEDIA@", embedms_desc,
266
                string msdesc = regsub1("@UUIDMEDIA@", embedms_desc, ids.uuidMS);
262
                  uuidMediaServer(UUID));
263
      msdesc = regsub1("@FRIENDLYNAMEMEDIA@", msdesc,
267
                msdesc = regsub1("@FRIENDLYNAMEMEDIA@", msdesc, ids.fnameMS);
264
               friendlyNameMediaServer(friendlyname));
265
                data = regsub1("@MEDIASERVER@", data, msdesc);
268
                data = regsub1("@MEDIASERVER@", data, msdesc);
266
      } else if (msonly) {
269
            } else if (msonly) {
267
                // Substitute values in msonly description
270
                // Substitute values in msonly description
268
      data = regsub1("@UUIDMEDIA@", msonly_desc,
271
                data = regsub1("@UUIDMEDIA@", msonly_desc, ids.uuidMS);
269
                               uuidMediaServer(UUID));
272
                data = regsub1("@FRIENDLYNAMEMEDIA@", data, ids.fnameMS);
270
      data = regsub1("@FRIENDLYNAMEMEDIA@", data,
271
                               friendlyNameMediaServer(friendlyname));
272
            } else {
273
            } else {
273
                // No media server: erase the section
274
                // No media server: erase the section
274
                data = regsub1("@MEDIASERVER@", data, "");
275
                data = regsub1("@MEDIASERVER@", data, "");
275
      }
276
            }
276
277
277
            if (enableAV) {
278
            if (enableAV) {
278
                data = regsub1("@UPNPAV@", data, upnpAVDesc);
279
                data = regsub1("@UPNPAV@", data, upnpAVDesc);
279
            } else {
280
            } else {
280
                data = regsub1("@UPNPAV@", data, "");
281
                data = regsub1("@UPNPAV@", data, "");