Switch to unified view

a/src/ohradio.cxx b/src/ohradio.cxx
...
...
47
47
48
static const string sTpProduct("urn:av-openhome-org:service:Radio:1");
48
static const string sTpProduct("urn:av-openhome-org:service:Radio:1");
49
static const string sIdProduct("urn:av-openhome-org:serviceId:Radio");
49
static const string sIdProduct("urn:av-openhome-org:serviceId:Radio");
50
50
51
struct RadioMeta {
51
struct RadioMeta {
52
    RadioMeta(const string& t, const string& u, const string& au)
52
    RadioMeta(const string& t, const string& u, const string& au = string(),
53
              const string& as = string())
53
        : title(t), uri(u), artUri(au) {
54
        : title(t), uri(u), artUri(au), artScript(as) {
54
    }
55
    }
55
    string title;
56
    string title;
56
    string uri;
57
    string uri;
57
    string artUri;
58
    string artUri;
59
    string artScript;
58
};
60
};
59
61
60
static vector<RadioMeta> o_radios;
62
static vector<RadioMeta> o_radios;
61
63
62
OHRadio::OHRadio(UpMpd *dev)
64
OHRadio::OHRadio(UpMpd *dev)
...
...
112
static void getRadiosFromConf(ConfSimple* conf)
114
static void getRadiosFromConf(ConfSimple* conf)
113
{
115
{
114
    vector<string> allsubk = conf->getSubKeys_unsorted();
116
    vector<string> allsubk = conf->getSubKeys_unsorted();
115
    for (auto it = allsubk.begin(); it != allsubk.end(); it++) {
117
    for (auto it = allsubk.begin(); it != allsubk.end(); it++) {
116
        if (it->find("radio ") == 0) {
118
        if (it->find("radio ") == 0) {
117
            string uri, artUri;
119
            string uri, artUri, artScript;
118
            string title = it->substr(6);
120
            string title = it->substr(6);
119
            bool ok = conf->get("url", uri, *it);
121
            bool ok = conf->get("url", uri, *it);
120
            conf->get("artUrl", artUri, *it);
122
            conf->get("artUrl", artUri, *it);
123
            conf->get("artScript", artScript, *it);
124
            trimstring(artScript, " \t\n\r");
121
            if (ok && !uri.empty()) {
125
            if (ok && !uri.empty()) {
122
                o_radios.push_back(RadioMeta(title, uri, artUri));
126
                o_radios.push_back(RadioMeta(title, uri, artUri, artScript));
123
                LOGDEB1("OHRadio::readRadios:RADIO: [" << title << "] uri ["
127
                LOGDEB1("OHRadio::readRadios:RADIO: [" << title << "] uri ["
124
                        << uri << "] artUri [" << artUri << "]\n");
128
                        << uri << "] artUri [" << artUri << "]\n");
125
            }
129
            }
126
        }
130
        }
127
    }
131
    }
...
...
193
    makeIdArray(st["IdArray"]);
197
    makeIdArray(st["IdArray"]);
194
    if (m_active && m_id >= 0 && m_id < o_radios.size()) {
198
    if (m_active && m_id >= 0 && m_id < o_radios.size()) {
195
        if (mpds.currentsong.album.empty()) {
199
        if (mpds.currentsong.album.empty()) {
196
            mpds.currentsong.album = o_radios[m_id].title;
200
            mpds.currentsong.album = o_radios[m_id].title;
197
        }
201
        }
202
203
        // Some radios provide a url to the art for the current song. Possibly
204
        // execute script to retrieve it
205
        LOGDEB("OHRadio::makestate: artScript: " << o_radios[m_id].artScript <<
206
               endl);
207
        if (o_radios[m_id].artScript.size()) {
208
            string nsong(mpds.currentsong.title+mpds.currentsong.artist);
209
            if (nsong.compare(m_currentsong)) {
210
                m_currentsong = nsong;
211
                string uri;
212
                vector<string> cmd;
213
                stringToStrings(o_radios[m_id].artScript, cmd);
214
                if (ExecCmd::backtick(cmd, uri)) {
215
                    trimstring(uri, " \t\r\n");
216
                    LOGDEB("OHRadio::makestate: artScript got: [" <<
217
                           uri << "]\n");
218
                    m_dynarturi = mpds.currentsong.artUri = uri;
219
                } else {
220
                    m_dynarturi =mpds.currentsong.artUri = o_radios[m_id].artUri;
221
                }
222
            } else {
223
                mpds.currentsong.artUri = m_dynarturi;
224
            }
225
        } else {
198
        mpds.currentsong.artUri = o_radios[m_id].artUri;
226
            mpds.currentsong.artUri = o_radios[m_id].artUri;
227
        }
199
        string meta = didlmake(mpds.currentsong);
228
        string meta = didlmake(mpds.currentsong);
200
        st["Metadata"] =  meta;
229
        st["Metadata"] =  meta;
201
        m_dev->m_ohif->setMetatext(meta);
230
        m_dev->m_ohif->setMetatext(meta);
202
    } else {
231
    } else {
203
        if (m_active) 
232
        if (m_active)