Switch to unified view

a/src/mediaserver/contentdirectory.cxx b/src/mediaserver/contentdirectory.cxx
...
...
52
    }
52
    }
53
    }
53
    }
54
54
55
    // Start plugins which have long init so that the user has less to
55
    // Start plugins which have long init so that the user has less to
56
    // wait on first access
56
    // wait on first access
57
    void maybeStartSomePlugins();
57
    void maybeStartSomePlugins(bool enabled);
58
    CDPlugin *pluginFactory(const string& appname) {
58
    CDPlugin *pluginFactory(const string& appname) {
59
    LOGDEB("ContentDirectory::pluginFactory: for " << appname << endl);
59
    LOGDEB("ContentDirectory::pluginFactory: for " << appname << endl);
60
60
61
    if (host.empty()) {
61
    if (host.empty()) {
62
        UpnpDevice *dev;
62
        UpnpDevice *dev;
...
...
98
static const string
98
static const string
99
sTpContentDirectory("urn:schemas-upnp-org:service:ContentDirectory:1");
99
sTpContentDirectory("urn:schemas-upnp-org:service:ContentDirectory:1");
100
static const string
100
static const string
101
sIdContentDirectory("urn:upnp-org:serviceId:ContentDirectory");
101
sIdContentDirectory("urn:upnp-org:serviceId:ContentDirectory");
102
102
103
ContentDirectory::ContentDirectory(MediaServer *dev)
103
ContentDirectory::ContentDirectory(MediaServer *dev, bool enabled)
104
    : UpnpService(sTpContentDirectory, sIdContentDirectory, dev),
104
    : UpnpService(sTpContentDirectory, sIdContentDirectory, dev),
105
      m(new Internal(this, dev))
105
      m(new Internal(this, dev))
106
{
106
{
107
    dev->addActionMapping(
107
    dev->addActionMapping(
108
        this, "GetSearchCapabilities",
108
        this, "GetSearchCapabilities",
...
...
117
        this, "Browse",
117
        this, "Browse",
118
        bind(&ContentDirectory::actBrowse, this, _1, _2));
118
        bind(&ContentDirectory::actBrowse, this, _1, _2));
119
    dev->addActionMapping(
119
    dev->addActionMapping(
120
        this, "Search",
120
        this, "Search",
121
        bind(&ContentDirectory::actSearch, this, _1, _2));
121
        bind(&ContentDirectory::actSearch, this, _1, _2));
122
    m->maybeStartSomePlugins();
122
    m->maybeStartSomePlugins(enabled);
123
}
123
}
124
124
125
ContentDirectory::~ContentDirectory()
125
ContentDirectory::~ContentDirectory()
126
{
126
{
127
    delete m;
127
    delete m;
...
...
249
    } 
249
    } 
250
    return id.substr(dol0 + 1, dol1 - dol0 -1);
250
    return id.substr(dol0 + 1, dol1 - dol0 -1);
251
}
251
}
252
252
253
253
254
void ContentDirectory::Internal::maybeStartSomePlugins()
254
void ContentDirectory::Internal::maybeStartSomePlugins(bool enabled)
255
{
255
{
256
    // If enabled is not set, no service is locally enabled, we are
257
    // working for ohcredentials. Explicitely start the microhttpd
258
    // daemon in this case, as we'll need it before any plugin is
259
    // created.
260
    if (!enabled) {
261
        PlgWithSlave::maybeStartMHD(this->service);
262
    }
256
    for (auto& entry : rootdir) {
263
    for (auto& entry : rootdir) {
257
        string app = appForId(entry.id);
264
        string app = appForId(entry.id);
258
        string sas;
265
        string sas;
259
        if (g_config->get(app + "autostart", sas) && stringToBool(sas)) {
266
        if (g_config->get(app + "autostart", sas) && stringToBool(sas)) {
260
            LOGDEB0("ContentDirectory::Internal::maybeStartSomePlugins: "
267
            LOGDEB0("ContentDirectory::Internal::maybeStartSomePlugins: "
...
...
527
    }
534
    }
528
        
535
        
529
    dir->addVDir(path, ops);
536
    dir->addVDir(path, ops);
530
    return true;
537
    return true;
531
}
538
}
539
std::string ContentDirectory::getfname()
540
{
541
    return m->msdev->getfname();
542
}
532
543
533
bool ContentDirectory::config_get(const string& nm, string& val)
544
bool CDPluginServices::config_get(const string& nm, string& val)
534
{
545
{
535
    if (nullptr == g_config) {
546
    if (nullptr == g_config) {
536
        return false;
547
        return false;
537
    }
548
    }
538
    return g_config->get(nm, val);
549
    return g_config->get(nm, val);
539
}
550
}
540
551
541
std::string ContentDirectory::getfname()
552
int CDPluginServices::microhttpport()
542
{
553
{
543
    return m->msdev->getfname();
554
    int port = 49149;
555
    string sport;
556
    if (g_config->get("plgmicrohttpport", sport)) {
557
        port = atoi(sport.c_str());
558
    }
559
    return port;
544
}
560
}
545
561
562