mirror of
https://github.com/SuperBFG7/ympd
synced 2024-12-28 11:50:26 +00:00
cleanup
This commit is contained in:
parent
5d685904c4
commit
aa28b8e8b9
@ -56,7 +56,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
|||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
unsigned int uint_buf1, uint_buf2;
|
unsigned int uint_buf1, uint_buf2, uint_rc;
|
||||||
int je, int_buf, int_rc;
|
int je, int_buf, int_rc;
|
||||||
float float_buf;
|
float float_buf;
|
||||||
char *p_charbuf1, *p_charbuf2;
|
char *p_charbuf1, *p_charbuf2;
|
||||||
@ -135,8 +135,9 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
|||||||
n = mympd_put_welcome(mpd.buf);
|
n = mympd_put_welcome(mpd.buf);
|
||||||
break;
|
break;
|
||||||
case MPD_API_UPDATE_DB:
|
case MPD_API_UPDATE_DB:
|
||||||
mpd_run_update(mpd.conn, NULL);
|
uint_rc = mpd_run_update(mpd.conn, NULL);
|
||||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
if (uint_rc > 0)
|
||||||
|
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"Updating MPD Database...\"}");
|
||||||
break;
|
break;
|
||||||
case MPD_API_SET_PAUSE:
|
case MPD_API_SET_PAUSE:
|
||||||
mpd_run_toggle_pause(mpd.conn);
|
mpd_run_toggle_pause(mpd.conn);
|
||||||
@ -267,14 +268,10 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
|||||||
break;
|
break;
|
||||||
case MPD_API_ADD_TRACK_AFTER:
|
case MPD_API_ADD_TRACK_AFTER:
|
||||||
je = json_scanf(msg.p, msg.len, "{ data: { uri:%Q, to:%d } }", &p_charbuf1, &int_buf);
|
je = json_scanf(msg.p, msg.len, "{ data: { uri:%Q, to:%d } }", &p_charbuf1, &int_buf);
|
||||||
// if (int_buf == -1)
|
|
||||||
// int_buf = 1;
|
|
||||||
if (je == 2) {
|
if (je == 2) {
|
||||||
int_rc = mpd_run_add_id_to(mpd.conn, p_charbuf1, int_buf);
|
int_rc = mpd_run_add_id_to(mpd.conn, p_charbuf1, int_buf);
|
||||||
if (int_rc == -1 )
|
if (int_rc > -1 )
|
||||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"error\", \"data\": \"Cant add %s after track %d\"}", p_charbuf1, int_buf);
|
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"Added song %s after pos %d\"}", p_charbuf1, int_buf);
|
||||||
else
|
|
||||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"Added track %s after track %d\"}", p_charbuf1, int_buf);
|
|
||||||
free(p_charbuf1);
|
free(p_charbuf1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -615,7 +612,7 @@ int mympd_put_welcome(char *buffer) {
|
|||||||
int len;
|
int len;
|
||||||
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
|
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
|
||||||
|
|
||||||
len = json_printf(&out, "{type: %Q, data: { version: %Q}}", "welcome", MYMPD_VERSION);
|
len = json_printf(&out, "{type: welcome, data: { version: %Q}}", MYMPD_VERSION);
|
||||||
|
|
||||||
if (len > MAX_SIZE) fprintf(stderr,"Buffer truncated\n");
|
if (len > MAX_SIZE) fprintf(stderr,"Buffer truncated\n");
|
||||||
return len;
|
return len;
|
||||||
|
Loading…
Reference in New Issue
Block a user