Switch to unified view

a/src/contentdirectory.cxx b/src/contentdirectory.cxx
...
...
34
34
35
#include "pathut.h"
35
#include "pathut.h"
36
#include "smallut.h"
36
#include "smallut.h"
37
#include "upmpdutils.hxx"
37
#include "upmpdutils.hxx"
38
#include "main.hxx"
38
#include "main.hxx"
39
#include "cdplugins/tidal.hxx"
39
#include "cdplugins/plgwithslave.hxx"
40
40
41
using namespace std;
41
using namespace std;
42
using namespace std::placeholders;
42
using namespace std::placeholders;
43
using namespace UPnPProvider;
43
using namespace UPnPProvider;
44
44
...
...
68
        }
68
        }
69
            port = usport;
69
            port = usport;
70
        LOGDEB("ContentDirectory: host "<< host<< " port " << port << endl);
70
        LOGDEB("ContentDirectory: host "<< host<< " port " << port << endl);
71
    }
71
    }
72
    if (!appname.compare("tidal")) {
72
    if (!appname.compare("tidal")) {
73
      Tidal *tidal = new Tidal("tidal", service);
73
      return new PlgWithSlave("tidal", service);
74
      return tidal;
74
        } else if (!appname.compare("qobuz")) {
75
      return new PlgWithSlave("qobuz", service);
75
    } else {
76
    } else {
76
        return nullptr;
77
        return nullptr;
77
    }
78
    }
78
    }
79
    }
79
    CDPlugin *pluginForApp(const string& appname) {
80
    CDPlugin *pluginForApp(const string& appname) {
...
...
155
156
156
static vector<UpSong> rootdir;
157
static vector<UpSong> rootdir;
157
void makerootdir()
158
void makerootdir()
158
{
159
{
159
    rootdir.push_back(UpSong::container("0$tidal$", "0", "Tidal"));
160
    rootdir.push_back(UpSong::container("0$tidal$", "0", "Tidal"));
161
    rootdir.push_back(UpSong::container("0$qobuz$", "0", "Qobuz"));
160
}
162
}
161
163
162
// Returns totalmatches
164
// Returns totalmatches
163
static size_t readroot(int offs, int cnt, vector<UpSong>& out)
165
static size_t readroot(int offs, int cnt, vector<UpSong>& out)
164
{
166
{
...
...
396
std::string ContentDirectory::getpathprefix(CDPlugin *plg)
398
std::string ContentDirectory::getpathprefix(CDPlugin *plg)
397
{
399
{
398
    return string("/") + plg->getname();
400
    return string("/") + plg->getname();
399
}
401
}
400
402
403
static string firstpathelt(const string& path)
404
{
405
    // The parameter is normally a path, but make this work with an URL too
406
    string::size_type pos = path.find("://");
407
    if (pos != string::npos) {
408
        pos += 3;
409
        pos = path.find("/", pos);
410
    } else {
411
        pos = 0;
412
    }
413
    pos = path.find_first_not_of("/", pos);
414
    if (pos == string::npos) {
415
        return string();
416
    }
417
    string::size_type epos = path.find_first_of("/", pos);
418
    if (epos != string::npos) {
419
        return path.substr(pos, epos -pos);
420
    } else {
421
        return path.substr(pos);
422
    }
423
}
424
425
CDPlugin *ContentDirectory::getpluginforpath(const string& path)
426
{
427
    string app = firstpathelt(path);
428
    return m->pluginForApp(app);
429
}
401
430
402
std::string ContentDirectory::getupnpaddr(CDPlugin *)
431
std::string ContentDirectory::getupnpaddr(CDPlugin *)
403
{
432
{
404
    return m->host;
433
    return m->host;
405
}
434
}
...
...
435
{
464
{
436
    return g_config;
465
    return g_config;
437
}
466
}
438
467
439
468
440
const std::vector<std::string> ContentDirectory::getexecpath(CDPlugin *plg)
469
std::string ContentDirectory::getexecpath(CDPlugin *plg)
441
{
470
{
442
    string pthcdplugs = path_cat(g_datadir, "cdplugins");
471
    string pth = path_cat(g_datadir, "cdplugins");
443
    return {pthcdplugs, path_cat(pthcdplugs, plg->getname())};
472
    pth = path_cat(pth, plg->getname());
473
    return path_cat(pth, plg->getname() + "-app" + ".py");
444
}
474
}