[httpd_daap] Honour sort param "artist" for album groups (fixes issue #358)

This commit is contained in:
ejurgensen 2017-03-05 09:45:34 +01:00
parent 9f2f5566d2
commit 6c94cdd635

View File

@ -666,15 +666,10 @@ get_query_params(struct evkeyvalq *query, int *sort_headers, struct query_params
{
*sort_headers = 0;
param = evhttp_find_header(query, "include-sort-headers");
if (param)
{
if (strcmp(param, "1") == 0)
if (param && (strcmp(param, "1") == 0))
{
*sort_headers = 1;
DPRINTF(E_DBG, L_DAAP, "Sort headers requested\n");
}
else
DPRINTF(E_DBG, L_DAAP, "Unknown include-sort-headers param: %s\n", param);
DPRINTF(E_SPAM, L_DAAP, "Sort headers requested\n");
}
}
@ -1661,6 +1656,7 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
memset(&qp, 0, sizeof(struct query_params));
get_query_params(query, NULL, &qp);
qp.type = Q_PL;
if (qp.sort == S_NONE)
qp.sort = S_PLAYLIST;
ret = db_query_start(&qp);
@ -1876,14 +1872,21 @@ daap_reply_groups(struct evhttp_request *req, struct evbuffer *evbuf, char **uri
param = evhttp_find_header(query, "group-type");
if (strcmp(param, "artists") == 0)
{
// Request from Remote may have the form:
// groups?meta=dmap.xxx,dma...&type=music&group-type=artists&sort=album&include-sort-headers=1&query=('...')&session-id=...
// Note: Since grouping by artist and sorting by album is crazy we override
tag = "agar";
qp.type = Q_GROUP_ARTISTS;
qp.sort = S_ARTIST;
}
else
{
// Request from Remote may have the form:
// groups?meta=dmap.xxx,dma...&type=music&group-type=albums&sort=artist&include-sort-headers=0&query=('...'))&session-id=...
// Sort may also be 'album'
tag = "agal";
qp.type = Q_GROUP_ALBUMS;
if (qp.sort == S_NONE)
qp.sort = S_ALBUM;
}