[mpd] support "track" parameter in commands "list", "find", "search"

This commit is contained in:
chme 2015-05-02 09:18:18 +02:00
parent ed8b69c118
commit fefd91fabc
3 changed files with 27 additions and 0 deletions

View File

@ -1539,6 +1539,10 @@ db_query_start(struct query_params *qp)
ret = db_build_query_browse(qp, "disc", "disc", &query); ret = db_build_query_browse(qp, "disc", "disc", &query);
break; break;
case Q_BROWSE_TRACKS:
ret = db_build_query_browse(qp, "track", "track", &query);
break;
case Q_COUNT_ITEMS: case Q_COUNT_ITEMS:
ret = db_build_query_count_items(qp, &query); ret = db_build_query_count_items(qp, &query);
break; break;

View File

@ -42,6 +42,7 @@ enum query_type {
Q_BROWSE_YEARS = Q_F_BROWSE | (1 << 11), Q_BROWSE_YEARS = Q_F_BROWSE | (1 << 11),
Q_COUNT_ITEMS = (1 << 12), Q_COUNT_ITEMS = (1 << 12),
Q_BROWSE_DISCS = Q_F_BROWSE | (1 << 13), Q_BROWSE_DISCS = Q_F_BROWSE | (1 << 13),
Q_BROWSE_TRACKS = Q_F_BROWSE | (1 << 14),
}; };
#define ARTWORK_UNKNOWN 0 #define ARTWORK_UNKNOWN 0

View File

@ -1991,6 +1991,14 @@ mpd_get_query_params_find(int argc, char **argv, struct query_params *qp)
else else
c1 = sqlite3_mprintf("(f.disc = %d)", num); c1 = sqlite3_mprintf("(f.disc = %d)", num);
} }
else if (0 == strcasecmp(argv[i], "track"))
{
ret = safe_atou32(argv[i + 1], &num);
if (ret < 0)
DPRINTF(E_WARN, L_MPD, "Track parameter '%s' is not an integer and will be ignored\n", argv[i + 1]);
else
c1 = sqlite3_mprintf("(f.track = %d)", num);
}
else if (i == 0 && argc == 1) else if (i == 0 && argc == 1)
{ {
// Special case: a single token is allowed if listing albums for an artist // Special case: a single token is allowed if listing albums for an artist
@ -2226,6 +2234,12 @@ mpd_command_list(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
qp.sort = S_NONE; qp.sort = S_NONE;
type = "Disc: "; type = "Disc: ";
} }
else if (0 == strcasecmp(argv[1], "track"))
{
qp.type = Q_BROWSE_TRACKS;
qp.sort = S_NONE;
type = "Track: ";
}
else else
{ {
DPRINTF(E_WARN, L_MPD, "Unsupported type argument for command 'list': %s\n", argv[1]); DPRINTF(E_WARN, L_MPD, "Unsupported type argument for command 'list': %s\n", argv[1]);
@ -2450,6 +2464,14 @@ mpd_get_query_params_search(int argc, char **argv, struct query_params *qp)
else else
c1 = sqlite3_mprintf("(f.disc = %d)", num); c1 = sqlite3_mprintf("(f.disc = %d)", num);
} }
else if (0 == strcasecmp(argv[i], "track"))
{
ret = safe_atou32(argv[i + 1], &num);
if (ret < 0)
DPRINTF(E_WARN, L_MPD, "Track parameter '%s' is not an integer and will be ignored\n", argv[i + 1]);
else
c1 = sqlite3_mprintf("(f.track = %d)", num);
}
else else
{ {
DPRINTF(E_WARN, L_MPD, "Parameter '%s' is not supported by forked-daapd and will be ignored\n", argv[i]); DPRINTF(E_WARN, L_MPD, "Parameter '%s' is not supported by forked-daapd and will be ignored\n", argv[i]);