Switch to unified view

a/upmpd/mpdcli.cxx b/upmpd/mpdcli.cxx
...
...
65
        if (!mpd_run_password(M_CONN, m_password.c_str())) {
65
        if (!mpd_run_password(M_CONN, m_password.c_str())) {
66
            LOGERR("Password wrong" << endl);
66
            LOGERR("Password wrong" << endl);
67
            return false;
67
            return false;
68
        }
68
        }
69
    }
69
    }
70
    mpd_run_consume(M_CONN, true);
71
    return true;
70
    return true;
72
}
71
}
73
72
74
bool MPDCli::showError(const string& who)
73
bool MPDCli::showError(const string& who)
75
{
74
{
...
...
369
    if (!ok())
368
    if (!ok())
370
        return false;
369
        return false;
371
    RETRY_CMD(mpd_run_repeat(M_CONN, on));
370
    RETRY_CMD(mpd_run_repeat(M_CONN, on));
372
    return true;
371
    return true;
373
}
372
}
373
374
bool MPDCli::consume(bool on)
375
{
376
    LOGDEB("MPDCli::consume:" << on << endl);
377
    if (!ok())
378
        return false;
379
380
    RETRY_CMD(mpd_run_consume(M_CONN, on));
381
    return true;
382
}
374
bool MPDCli::random(bool on)
383
bool MPDCli::random(bool on)
375
{
384
{
376
    LOGDEB("MPDCli::random:" << on << endl);
385
    LOGDEB("MPDCli::random:" << on << endl);
377
    if (!ok())
386
    if (!ok())
378
        return false;
387
        return false;
...
...
401
    RETRY_CMD((id=mpd_run_add_id_to(M_CONN, uri.c_str(), (unsigned)pos))!=-1);
410
    RETRY_CMD((id=mpd_run_add_id_to(M_CONN, uri.c_str(), (unsigned)pos))!=-1);
402
411
403
    return id;
412
    return id;
404
}
413
}
405
414
406
bool MPDCli::insertAfterId(const string& uri, int id)
415
int MPDCli::insertAfterId(const string& uri, int id)
407
{
416
{
408
    LOGDEB("MPDCli::insertAfterId: id " << id << " uri " << uri << endl);
417
    LOGDEB("MPDCli::insertAfterId: id " << id << " uri " << uri << endl);
409
    if (!ok())
418
    if (!ok())
410
        return -1;
419
        return -1;
411
420
412
    if (!updStatus())
421
    if (!updStatus())
413
        return -1;
422
        return -1;
414
423
415
    // id == 0 means insert at start
424
    // id == 0 means insert at start
416
    if (id == 0) {
425
    if (id == 0) {
417
        return insert(uri, 0) != -1;
426
        return insert(uri, 0);
418
    }
427
    }
419
428
420
    vector<mpd_song*> songs;
429
    vector<mpd_song*> songs;
421
    if (!getQueueSongs(songs)) {
430
    if (!getQueueSongs(songs)) {
422
        return false;
431
        return false;
423
    }
432
    }
424
    bool ok = false;
433
    int newid = -1;
425
    for (unsigned int pos = 0; pos < songs.size(); pos++) {
434
    for (unsigned int pos = 0; pos < songs.size(); pos++) {
426
        unsigned int qid = mpd_song_get_id(songs[pos]);
435
        unsigned int qid = mpd_song_get_id(songs[pos]);
427
        if (qid == (unsigned int)id) {
436
        if (qid == (unsigned int)id || pos == songs.size() -1) {
428
            ok = insert(uri, pos+1) != -1;
437
            newid = insert(uri, pos+1);
429
            break;
438
            break;
430
        }
439
        }
431
    }
440
    }
432
    freeSongs(songs);
441
    freeSongs(songs);
433
    return ok;
442
    return newid;
434
}
443
}
435
444
436
bool MPDCli::clearQueue()
445
bool MPDCli::clearQueue()
437
{
446
{
438
    LOGDEB("MPDCli::clearQueue " << endl);
447
    LOGDEB("MPDCli::clearQueue " << endl);