Switch to unified view

a/src/mpdcli.cxx b/src/mpdcli.cxx
...
...
51
    if (!openconn()) {
51
    if (!openconn()) {
52
        return;
52
        return;
53
    }
53
    }
54
    m_have_addtagid = checkForCommand("addtagid");
54
    m_have_addtagid = checkForCommand("addtagid");
55
55
56
    m_ok = true;
57
    m_ok = updStatus();
58
59
    std::unique_lock<std::mutex>(g_configlock);
56
    std::unique_lock<std::mutex>(g_configlock);
60
    g_config->get("onstart", m_onstart);
57
    g_config->get("onstart", m_onstart);
61
    g_config->get("onplay", m_onplay);
58
    g_config->get("onplay", m_onplay);
62
    g_config->get("onstop", m_onstop);
59
    g_config->get("onstop", m_onstop);
63
    string scratch;
60
    string scratch;
...
...
69
    m_externalvolumecontrol = false;
66
    m_externalvolumecontrol = false;
70
    string value;
67
    string value;
71
    if (g_config->get("externalvolumecontrol", value)) {
68
    if (g_config->get("externalvolumecontrol", value)) {
72
        m_externalvolumecontrol = atoi(value.c_str()) != 0;
69
        m_externalvolumecontrol = atoi(value.c_str()) != 0;
73
    }
70
    }
71
72
    m_ok = true;
73
    m_ok = updStatus();
74
}
74
}
75
75
76
MPDCli::~MPDCli()
76
MPDCli::~MPDCli()
77
{
77
{
78
    if (m_conn) 
78
    if (m_conn) 
...
...
215
    m_stat.random = mpd_status_get_random(mpds);
215
    m_stat.random = mpd_status_get_random(mpds);
216
    m_stat.single = mpd_status_get_single(mpds);
216
    m_stat.single = mpd_status_get_single(mpds);
217
    m_stat.consume = mpd_status_get_consume(mpds);
217
    m_stat.consume = mpd_status_get_consume(mpds);
218
    m_stat.qlen = mpd_status_get_queue_length(mpds);
218
    m_stat.qlen = mpd_status_get_queue_length(mpds);
219
    m_stat.qvers = mpd_status_get_queue_version(mpds);
219
    m_stat.qvers = mpd_status_get_queue_version(mpds);
220
    m_stat.state = MpdStatus::MPDS_UNK;
220
221
221
    switch (mpd_status_get_state(mpds)) {
222
    switch (mpd_status_get_state(mpds)) {
222
    case MPD_STATE_STOP:
223
    case MPD_STATE_STOP:
223
        // Only execute onstop command if mpd was playing or paused
224
        // Only execute onstop command if mpd was playing or paused
224
        if (!m_onstop.empty() && (m_stat.state == MpdStatus::MPDS_PLAY ||
225
        if (!m_onstop.empty() && (m_stat.state == MpdStatus::MPDS_PLAY ||
...
...
229
        }
230
        }
230
        m_stat.state = MpdStatus::MPDS_STOP;
231
        m_stat.state = MpdStatus::MPDS_STOP;
231
        break;
232
        break;
232
    case MPD_STATE_PLAY:
233
    case MPD_STATE_PLAY:
233
        // Only execute onplay command if mpd was stopped
234
        // Only execute onplay command if mpd was stopped
234
        if (!m_onplay.empty() && m_stat.state == MpdStatus::MPDS_STOP) {
235
        if (!m_onplay.empty() && (m_stat.state == MpdStatus::MPDS_UNK ||
236
                                  m_stat.state == MpdStatus::MPDS_STOP)) {
235
            if (system(m_onplay.c_str())) {
237
            if (system(m_onplay.c_str())) {
236
                LOGERR("MPDCli::updStatus: " << m_onplay << " failed "<< endl);
238
                LOGERR("MPDCli::updStatus: " << m_onplay << " failed "<< endl);
237
            }
239
            }
238
        }
240
        }
239
        m_stat.state = MpdStatus::MPDS_PLAY;
241
        m_stat.state = MpdStatus::MPDS_PLAY;