[mpd] implement command "findadd"

This commit is contained in:
chme 2015-05-01 11:07:03 +02:00
parent fb92040d4b
commit 76011c927c
1 changed files with 38 additions and 0 deletions

View File

@ -2113,6 +2113,44 @@ mpd_command_find(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
static int static int
mpd_command_findadd(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) mpd_command_findadd(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
{ {
struct query_params qp;
struct player_source *ps;
int ret;
if (argc < 3 || ((argc - 1) % 2) != 0)
{
ret = asprintf(errmsg, "Missing argument(s) for command 'findadd'");
if (ret < 0)
DPRINTF(E_LOG, L_MPD, "Out of memory\n");
return ACK_ERROR_ARG;
}
memset(&qp, 0, sizeof(struct query_params));
qp.type = Q_ITEMS;
qp.sort = S_NAME;
qp.idx_type = I_NONE;
mpd_get_query_params_find(argc - 1, argv + 1, &qp);
ps = player_queue_make(&qp);
if (!ps)
{
ret = asprintf(errmsg, "Failed to add songs to playlist");
if (ret < 0)
DPRINTF(E_LOG, L_MPD, "Out of memory\n");
return ACK_ERROR_UNKNOWN;
}
player_queue_add(ps);
ret = player_playback_start(NULL);
if (ret < 0)
{
DPRINTF(E_LOG, L_MPD, "Could not start playback\n");
}
return 0; return 0;
} }