Switch to unified view

a/src/mediaserver/contentdirectory.cxx b/src/mediaserver/contentdirectory.cxx
...
...
41
using namespace std::placeholders;
41
using namespace std::placeholders;
42
using namespace UPnPProvider;
42
using namespace UPnPProvider;
43
43
44
class ContentDirectory::Internal {
44
class ContentDirectory::Internal {
45
public:
45
public:
46
    Internal (ContentDirectory *sv)
46
    Internal (ContentDirectory *sv, MediaServer *dv)
47
    : service(sv), updateID("1") {
47
    : service(sv), msdev(dv), updateID("1") { }
48
    }
48
49
    ~Internal() {
49
    ~Internal() {
50
    for (auto& it : plugins) {
50
    for (auto& it : plugins) {
51
        delete it.second;
51
        delete it.second;
52
    }
52
    }
53
    }
53
    }
54
54
    // 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
55
    // wait on first access
56
    // wait on first access
56
    void maybeStartSomePlugins();
57
    void maybeStartSomePlugins();
57
    CDPlugin *pluginFactory(const string& appname) {
58
    CDPlugin *pluginFactory(const string& appname) {
58
    LOGDEB("ContentDirectory::pluginFactory: for " << appname << endl);
59
    LOGDEB("ContentDirectory::pluginFactory: for " << appname << endl);
...
...
83
        plugins[appname] = plug;
84
        plugins[appname] = plug;
84
        }
85
        }
85
        return plug;
86
        return plug;
86
    }
87
    }
87
    }
88
    }
89
90
    ContentDirectory *service;
91
    MediaServer *msdev;
88
    unordered_map<string, CDPlugin *> plugins;
92
    unordered_map<string, CDPlugin *> plugins;
89
    ContentDirectory *service;
90
    string host;
93
    string host;
91
    int port;
94
    int port;
92
    string updateID;
95
    string updateID;
93
};
96
};
94
97
95
static const string
98
static const string
96
sTpContentDirectory("urn:schemas-upnp-org:service:ContentDirectory:1");
99
sTpContentDirectory("urn:schemas-upnp-org:service:ContentDirectory:1");
97
static const string
100
static const string
98
sIdContentDirectory("urn:upnp-org:serviceId:ContentDirectory");
101
sIdContentDirectory("urn:upnp-org:serviceId:ContentDirectory");
99
102
100
ContentDirectory::ContentDirectory(UPnPProvider::UpnpDevice *dev)
103
ContentDirectory::ContentDirectory(MediaServer *dev)
101
    : UpnpService(sTpContentDirectory, sIdContentDirectory, dev),
104
    : UpnpService(sTpContentDirectory, sIdContentDirectory, dev),
102
      m(new Internal(this))
105
      m(new Internal(this, dev))
103
{
106
{
104
    dev->addActionMapping(
107
    dev->addActionMapping(
105
        this, "GetSearchCapabilities",
108
        this, "GetSearchCapabilities",
106
        bind(&ContentDirectory::actGetSearchCapabilities, this, _1, _2));
109
        bind(&ContentDirectory::actGetSearchCapabilities, this, _1, _2));
107
    dev->addActionMapping(
110
    dev->addActionMapping(
...
...
521
        
524
        
522
    dir->addVDir(path, ops);
525
    dir->addVDir(path, ops);
523
    return true;
526
    return true;
524
}
527
}
525
528
526
529
bool ContentDirectory::config_get(const string& nm, string& val)
527
ConfSimple *ContentDirectory::getconfig(CDPlugin *)
528
{
530
{
531
    if (nullptr == g_config) {
532
        return false;
533
    }
534
    std::unique_lock<std::mutex>(g_configlock);
529
    return g_config;
535
    return g_config->get(nm, val);
530
}
536
}
531
537
532
533
std::string ContentDirectory::getexecpath(CDPlugin *plg)
538
std::string ContentDirectory::getfname()
534
{
539
{
535
    string pth = path_cat(g_datadir, "cdplugins");
540
    return m->msdev->getfname();
536
    pth = path_cat(pth, plg->getname());
537
    return path_cat(pth, plg->getname() + "-app" + ".py");
538
}
541
}
542