Switch to unified view

a/src/ohradio.cxx b/src/ohradio.cxx
...
...
45
45
46
static const string sTpProduct("urn:av-openhome-org:service:Radio:1");
46
static const string sTpProduct("urn:av-openhome-org:service:Radio:1");
47
static const string sIdProduct("urn:av-openhome-org:serviceId:Radio");
47
static const string sIdProduct("urn:av-openhome-org:serviceId:Radio");
48
48
49
struct RadioMeta {
49
struct RadioMeta {
50
    RadioMeta(const string& t, const string& u)
50
    RadioMeta(const string& t, const string& u, const string& au)
51
        : title(t), uri(u) {
51
        : title(t), uri(u), artUri(au) {
52
    }
52
    }
53
    string title;
53
    string title;
54
    string uri;
54
    string uri;
55
    string artUri;
55
};
56
};
56
57
57
static vector<RadioMeta> o_radios;
58
static vector<RadioMeta> o_radios;
58
59
59
OHRadio::OHRadio(UpMpd *dev)
60
OHRadio::OHRadio(UpMpd *dev)
...
...
96
}
97
}
97
98
98
void OHRadio::readRadios()
99
void OHRadio::readRadios()
99
{
100
{
100
    // Id 0 means no selection
101
    // Id 0 means no selection
101
    o_radios.push_back(RadioMeta("Unknown radio", ""));
102
    o_radios.push_back(RadioMeta("Unknown radio", "", ""));
102
    
103
    
103
    vector<string> allsubk = g_config->getSubKeys_unsorted();
104
    vector<string> allsubk = g_config->getSubKeys_unsorted();
104
    for (auto it = allsubk.begin(); it != allsubk.end(); it++) {
105
    for (auto it = allsubk.begin(); it != allsubk.end(); it++) {
105
        LOGDEB("OHRadio::readRadios: subk " << *it << endl);
106
        LOGDEB("OHRadio::readRadios: subk " << *it << endl);
106
        if (it->find("radio ") == 0) {
107
        if (it->find("radio ") == 0) {
107
            string uri;
108
            string uri, artUri;
108
            string title = it->substr(6);
109
            string title = it->substr(6);
109
            bool ok = g_config->get("url", uri, *it);
110
            bool ok = g_config->get("url", uri, *it);
111
            g_config->get("artUrl", artUri, *it);
110
            if (ok && !uri.empty()) {
112
            if (ok && !uri.empty()) {
111
                o_radios.push_back(RadioMeta(title, uri));
113
                o_radios.push_back(RadioMeta(title, uri, artUri));
112
                LOGDEB("OHRadio::readRadios:RADIO: [" <<
114
                LOGDEB("OHRadio::readRadios:RADIO: [" <<
113
                       title << "] uri [" << uri << "]\n");
115
                       title << "] uri [" << uri << "]\n");
114
            }
116
            }
115
        }
117
        }
116
    }
118
    }
...
...
350
    LOGDEB("OHRadio::id" << endl);
352
    LOGDEB("OHRadio::id" << endl);
351
    data.addarg("Value", SoapHelp::i2s(m_id));
353
    data.addarg("Value", SoapHelp::i2s(m_id));
352
    return UPNP_E_SUCCESS;
354
    return UPNP_E_SUCCESS;
353
}
355
}
354
356
355
static string radioDidlMake(const string& uri, const string& title,
357
static string radioDidlMake(const string& title, const string& uri,
356
                            const string& artUri)
358
                            const string& artUri)
357
{
359
{
358
    string out("<DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n"
360
    string out("<DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n"
359
               "xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\"\n"
361
               "xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\"\n"
360
               "xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\">\n"
362
               "xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\">\n"
...
...
379
    string meta;
381
    string meta;
380
    if (id >= 0 && id  < o_radios.size()) {
382
    if (id >= 0 && id  < o_radios.size()) {
381
        if (0 && id == m_id) {
383
        if (0 && id == m_id) {
382
            meta = m_state["Metadata"];
384
            meta = m_state["Metadata"];
383
        } else {
385
        } else {
384
            meta = radioDidlMake(o_radios[id].uri, o_radios[id].title, "");
386
            meta = radioDidlMake(o_radios[id].title, o_radios[id].uri, 
387
                                 o_radios[id].artUri);
385
        }
388
        }
386
    }
389
    }
387
    return meta;
390
    return meta;
388
}
391
}
389
392