Switch to unified view

a/upmpd/mpdcli.cxx b/upmpd/mpdcli.cxx
...
...
207
    bool ret = mapSong(upsong, song);
207
    bool ret = mapSong(upsong, song);
208
    mpd_song_free(song);
208
    mpd_song_free(song);
209
    return ret;
209
    return ret;
210
}    
210
}    
211
211
212
bool  MPDCli::mapSong(UpSong& upsong, struct mpd_song *song)
212
UpSong&  MPDCli::mapSong(UpSong& upsong, struct mpd_song *song)
213
{
213
{
214
    const char *cp;
214
    const char *cp;
215
216
    upsong.clear();
217
215
218
    cp = mpd_song_get_uri(song);
216
    cp = mpd_song_get_uri(song);
219
    if (cp != 0)
217
    if (cp != 0)
220
        upsong.uri = cp;
218
        upsong.uri = cp;
221
219
    else 
220
        upson.uri.clear();
222
    cp = mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);
221
    cp = mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);
223
    if (cp != 0)
222
    if (cp != 0)
224
        upsong.artist = cp;
223
        upsong.artist = cp;
225
224
    else
225
        upsong.artist.clear();
226
    cp = mpd_song_get_tag(song, MPD_TAG_ALBUM, 0);
226
    cp = mpd_song_get_tag(song, MPD_TAG_ALBUM, 0);
227
    if (cp != 0)
227
    if (cp != 0)
228
        upsong.album = cp;
228
        upsong.album = cp;
229
229
    else
230
        upsong.album.clear();
230
    cp = mpd_song_get_tag(song, MPD_TAG_TITLE, 0);
231
    cp = mpd_song_get_tag(song, MPD_TAG_TITLE, 0);
231
    if (cp != 0) 
232
    if (cp != 0) 
232
        upsong.title = cp;
233
        upsong.title = cp;
233
234
    else
235
        upsong.title.clear();
234
    cp = mpd_song_get_tag(song, MPD_TAG_TRACK, 0);
236
    cp = mpd_song_get_tag(song, MPD_TAG_TRACK, 0);
235
    if (cp != 0)
237
    if (cp != 0)
236
        upsong.tracknum = cp;
238
        upsong.tracknum = cp;
237
239
    else 
240
        upsong.tracknum.clear();
238
    cp = mpd_song_get_tag(song, MPD_TAG_GENRE, 0);
241
    cp = mpd_song_get_tag(song, MPD_TAG_GENRE, 0);
239
    if (cp != 0)
242
    if (cp != 0)
240
        upsong.genre = cp;
243
        upsong.genre = cp;
244
    else
245
        upsong.genre.clear();
241
246
242
    upsong.duration_secs = mpd_song_get_duration(song);
247
    upsong.duration_secs = mpd_song_get_duration(song);
243
    upsong.mpdid = mpd_song_get_id(song);
248
    upsong.mpdid = mpd_song_get_id(song);
244
249
245
    return true;
250
    return upsong;
246
}
251
}
247
252
248
bool MPDCli::setVolume(int volume, bool isMute)
253
bool MPDCli::setVolume(int volume, bool isMute)
249
{
254
{
250
    if (!ok()) {
255
    if (!ok()) {
...
...
498
    for (vector<mpd_song*>::iterator it = songs.begin();
503
    for (vector<mpd_song*>::iterator it = songs.begin();
499
         it != songs.end(); it++) {
504
         it != songs.end(); it++) {
500
        mpd_song_free(*it);
505
        mpd_song_free(*it);
501
    }
506
    }
502
}
507
}
508
503
bool MPDCli::getQueueIds(std::vector<unsigned int>& vids)
509
bool MPDCli::getQueueData(std::vector<UpSong>& vdata)
504
{
510
{
505
    vector<mpd_song*> songs;
511
    vector<mpd_song*> songs;
506
    if (!getQueueSongs(songs)) {
512
    if (!getQueueSongs(songs)) {
507
        return false;
513
        return false;
508
    }
514
    }
509
    vids.reserve(songs.size());
515
    vdata.reserve(songs.size());
516
    UpSong usong;
510
    for (unsigned int pos = 0; pos < songs.size(); pos++) {
517
    for (unsigned int pos = 0; pos < songs.size(); pos++) {
511
        vids.push_back(mpd_song_get_id(songs[pos]));
518
        vdata.push_back(mapSong(usong, songs[pos]););
512
    }
519
    }
513
    freeSongs(songs);
520
    freeSongs(songs);
514
    return true;
521
    return true;
515
}
522
}
516
523
...
...
606
      return 1;
613
      return 1;
607
  }
614
  }
608
  return 0;
615
  return 0;
609
}
616
}
610
617
611
612
#endif
618
#endif
613