Switch to unified view

a/src/ohradio.cxx b/src/ohradio.cxx
...
...
107
                          bind(&OHRadio::stop, this, _1, _2));
107
                          bind(&OHRadio::stop, this, _1, _2));
108
    dev->addActionMapping(this, "TransportState",
108
    dev->addActionMapping(this, "TransportState",
109
                          bind(&OHRadio::transportState, this, _1, _2));
109
                          bind(&OHRadio::transportState, this, _1, _2));
110
}
110
}
111
111
112
static void getRadiosFromConf(ConfSimple* conf)
113
{
114
    vector<string> allsubk = conf->getSubKeys_unsorted();
115
    for (auto it = allsubk.begin(); it != allsubk.end(); it++) {
116
        if (it->find("radio ") == 0) {
117
            string uri, artUri;
118
            string title = it->substr(6);
119
            bool ok = conf->get("url", uri, *it);
120
            conf->get("artUrl", artUri, *it);
121
            if (ok && !uri.empty()) {
122
                o_radios.push_back(RadioMeta(title, uri, artUri));
123
                LOGDEB1("OHRadio::readRadios:RADIO: [" << title << "] uri ["
124
                        << uri << "] artUri [" << artUri << "]\n");
125
            }
126
        }
127
    }
128
}
129
112
bool OHRadio::readRadios()
130
bool OHRadio::readRadios()
113
{
131
{
114
    // Id 0 means no selection
132
    // Id 0 means no selection
115
    o_radios.push_back(RadioMeta("Unknown radio", "", ""));
133
    o_radios.push_back(RadioMeta("Unknown radio", "", ""));
116
    
134
    
117
    UPnPP::PTMutexLocker conflock(g_configlock);
135
    UPnPP::PTMutexLocker conflock(g_configlock);
118
    vector<string> allsubk = g_config->getSubKeys_unsorted();
136
    getRadiosFromConf(g_config);
119
    for (auto it = allsubk.begin(); it != allsubk.end(); it++) {
137
    // Also if radiolist is defined, get from there
120
        LOGDEB("OHRadio::readRadios: subk " << *it << endl);
138
    string radiolistfn;
121
        if (it->find("radio ") == 0) {
139
    if (g_config->get("radiolist", radiolistfn)) {
122
            string uri, artUri;
140
        ConfSimple rdconf(radiolistfn.c_str(), 1);
123
            string title = it->substr(6);
141
        if (!rdconf.ok()) {
124
            bool ok = g_config->get("url", uri, *it);
142
            LOGERR("OHRadio::readRadios: failed initializing from " <<
125
            g_config->get("artUrl", artUri, *it);
143
                   radiolistfn << endl);
126
            if (ok && !uri.empty()) {
144
        } else {
127
                o_radios.push_back(RadioMeta(title, uri, artUri));
145
            getRadiosFromConf(&rdconf);
128
                LOGDEB("OHRadio::readRadios:RADIO: [" << title << "] uri [" <<
129
                       uri << "] artUri [" << artUri << "]\n");
130
            }
146
        }
131
        }
147
    }
132
    }
133
    LOGDEB("OHRadio::readRadios: " << o_radios.size() << " radios found\n");
134
    return true;
148
    return true;
135
}
149
}
136
150
137
static string mpdstatusToTransportState(MpdStatus::State st)
151
static string mpdstatusToTransportState(MpdStatus::State st)
138
{
152
{