Switch to unified view

a/upmpd/ohplaylist.cxx b/upmpd/ohplaylist.cxx
...
...
134
        //sdeb += SoapArgs::i2s(val) + " ";
134
        //sdeb += SoapArgs::i2s(val) + " ";
135
    }
135
    }
136
    //LOGDEB("OHPlaylist: current ids: " << sdeb << endl);
136
    //LOGDEB("OHPlaylist: current ids: " << sdeb << endl);
137
    return base64_encode(out1);
137
    return base64_encode(out1);
138
}
138
}
139
string OHPlaylist::makeIdArray()
140
{
141
    string out;
142
139
140
bool OHPlaylist::makeIdArray(string& out)
141
{
143
    // Retrieve the data for current queue songs from mpd, and make an
142
    // Retrieve the data for current queue songs from mpd, and make an
144
    // ohPlaylist id array.
143
    // ohPlaylist id array.
145
    vector<UpSong> vdata;
144
    vector<UpSong> vdata;
146
    bool ok = m_dev->m_mpdcli->getQueueData(vdata);
145
    bool ok = m_dev->m_mpdcli->getQueueData(vdata);
147
    if (ok) {
146
    if (!ok)
147
        return false;
148
148
        out = translateIdArray(vdata);
149
    out = translateIdArray(vdata);
149
    }
150
150
151
    // Update metadata cache: entries not in the curren id list are
151
    // Update metadata cache: entries not in the curren id list are
152
    // not valid any more. Also there may be entries which were added
152
    // not valid any more. Also there may be entries which were added
153
    // through an MPD client and which don't know about, record the
153
    // through an MPD client and which don't know about, record the
154
    // metadata for these. We don't update the current array, but
154
    // metadata for these. We don't update the current array, but
...
...
169
            nmeta[usong.mpdid] = didlmake(usong);
169
            nmeta[usong.mpdid] = didlmake(usong);
170
        }
170
        }
171
    }
171
    }
172
    m_metacache = nmeta;
172
    m_metacache = nmeta;
173
173
174
    return out;
174
    return true;
175
}
175
}
176
176
177
bool OHPlaylist::makestate(unordered_map<string, string> &st)
177
bool OHPlaylist::makestate(unordered_map<string, string> &st)
178
{
178
{
179
    st.clear();
179
    st.clear();
...
...
184
    st["Repeat"] = SoapArgs::i2s(mpds.rept);
184
    st["Repeat"] = SoapArgs::i2s(mpds.rept);
185
    st["Shuffle"] = SoapArgs::i2s(mpds.random);
185
    st["Shuffle"] = SoapArgs::i2s(mpds.random);
186
    st["Id"] = SoapArgs::i2s(mpds.songid);
186
    st["Id"] = SoapArgs::i2s(mpds.songid);
187
    st["TracksMax"] = SoapArgs::i2s(tracksmax);
187
    st["TracksMax"] = SoapArgs::i2s(tracksmax);
188
    st["ProtocolInfo"] = upmpdProtocolInfo;
188
    st["ProtocolInfo"] = upmpdProtocolInfo;
189
    st["IdArray"] = makeIdArray();
189
    makeIdArray(st["IdArray"]);
190
190
191
    return true;
191
    return true;
192
}
192
}
193
193
194
bool OHPlaylist::getEventData(bool all, std::vector<std::string>& names, 
194
bool OHPlaylist::getEventData(bool all, std::vector<std::string>& names, 
...
...
392
392
393
// Report the uri and metadata for a given track id. 
393
// Report the uri and metadata for a given track id. 
394
// Returns a 800 fault code if the given id is not in the playlist. 
394
// Returns a 800 fault code if the given id is not in the playlist. 
395
int OHPlaylist::ohread(const SoapArgs& sc, SoapData& data)
395
int OHPlaylist::ohread(const SoapArgs& sc, SoapData& data)
396
{
396
{
397
    LOGDEB("OHPlaylist::ohread" << endl);
398
    int id;
397
    int id;
399
    bool ok = sc.getInt("Id", &id);
398
    bool ok = sc.getInt("Id", &id);
399
    LOGDEB("OHPlaylist::ohread id " << id << endl);
400
    UpSong song;
400
    UpSong song;
401
    if (ok) {
401
    if (ok) {
402
        ok = m_dev->m_mpdcli->statSong(song, id, true);
402
        ok = m_dev->m_mpdcli->statSong(song, id, true);
403
    }
403
    }
404
    if (ok) {
404
    if (ok) {
...
...
522
// Returns current list of id as array of big endian 32bits integers,
522
// Returns current list of id as array of big endian 32bits integers,
523
// base-64-encoded. 
523
// base-64-encoded. 
524
int OHPlaylist::idArray(const SoapArgs& sc, SoapData& data)
524
int OHPlaylist::idArray(const SoapArgs& sc, SoapData& data)
525
{
525
{
526
    LOGDEB("OHPlaylist::idArray" << endl);
526
    LOGDEB("OHPlaylist::idArray" << endl);
527
    data.addarg("Token", "0");
527
    string idarray;
528
    if (makeIdArray(idarray)) {
529
        const MpdStatus &mpds = m_dev->getMpdStatusNoUpdate();
530
        LOGDEB("OHPlaylist::idArray: qvers " << mpds.qvers << endl);
531
        data.addarg("Token", SoapArgs::i2s(mpds.qvers));
528
    data.addarg("Array", makeIdArray());
532
        data.addarg("Array", idarray);
529
    return UPNP_E_SUCCESS;
533
        return UPNP_E_SUCCESS;
534
    }
535
    return UPNP_E_INTERNAL_ERROR;
530
}
536
}
531
537
532
// Check if id array changed since last call (which returned a gen token)
538
// Check if id array changed since last call (which returned a gen token)
533
int OHPlaylist::idArrayChanged(const SoapArgs& sc, SoapData& data)
539
int OHPlaylist::idArrayChanged(const SoapArgs& sc, SoapData& data)
534
{
540
{
535
    LOGDEB("OHPlaylist::idArrayChanged" << endl);
541
    LOGDEB("OHPlaylist::idArrayChanged" << endl);
536
    int token;
542
    int qvers;
537
    bool ok = sc.getInt("Token", &token);
543
    bool ok = sc.getInt("Token", &qvers);
544
    const MpdStatus &mpds = m_dev->getMpdStatusNoUpdate();
545
    
546
    LOGDEB("OHPlaylist::idArrayChanged: query qvers " << qvers << 
547
           " mpd qvers " << mpds.qvers << endl);
548
538
    // Bool indicating if array changed
549
    // Bool indicating if array changed
539
    data.addarg("Value", "0");
550
    int val = mpds.qvers == qvers;
551
    data.addarg("Value", SoapArgs::i2s(val));
540
552
541
    return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
553
    return ok ? UPNP_E_SUCCESS : UPNP_E_INTERNAL_ERROR;
542
}
554
}
543
555
544
int OHPlaylist::protocolInfo(const SoapArgs& sc, SoapData& data)
556
int OHPlaylist::protocolInfo(const SoapArgs& sc, SoapData& data)