From d4f341aff0862f1690ec0f7407cea9d79efa60ac Mon Sep 17 00:00:00 2001 From: Kai Elwert Date: Sat, 14 Aug 2010 12:13:41 +0200 Subject: [PATCH] Handle include-sort-headers parameter in DAAP queries --- src/httpd_daap.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/httpd_daap.c b/src/httpd_daap.c index 4181e298..90273b21 100644 --- a/src/httpd_daap.c +++ b/src/httpd_daap.c @@ -848,7 +848,7 @@ dmap_add_field(struct evbuffer *evbuf, const struct dmap_field *df, char *strval static void -get_query_params(struct evkeyvalq *query, struct query_params *qp) +get_query_params(struct evkeyvalq *query, int *sort_headers, struct query_params *qp) { const char *param; char *ptr; @@ -916,6 +916,22 @@ get_query_params(struct evkeyvalq *query, struct query_params *qp) DPRINTF(E_DBG, L_DAAP, "Sorting songlist by %s\n", param); } + if (sort_headers) + { + *sort_headers = 0; + param = evhttp_find_header(query, "include-sort-headers"); + if (param) + { + if (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); + } + } + param = evhttp_find_header(query, "query"); if (!param) param = evhttp_find_header(query, "filter"); @@ -1420,7 +1436,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf, } memset(&qp, 0, sizeof(struct query_params)); - get_query_params(query, &qp); + get_query_params(query, NULL, &qp); if (playlist != -1) { @@ -1766,7 +1782,7 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char ** } memset(&qp, 0, sizeof(struct query_params)); - get_query_params(query, &qp); + get_query_params(query, NULL, &qp); qp.type = Q_PL; ret = db_query_start(&qp); @@ -2009,7 +2025,7 @@ daap_reply_groups(struct evhttp_request *req, struct evbuffer *evbuf, char **uri } memset(&qp, 0, sizeof(struct query_params)); - get_query_params(query, &qp); + get_query_params(query, NULL, &qp); qp.type = Q_GROUPS; ret = db_query_start(&qp); @@ -2214,7 +2230,7 @@ daap_reply_browse(struct evhttp_request *req, struct evbuffer *evbuf, char **uri return; } - get_query_params(query, &qp); + get_query_params(query, NULL, &qp); ret = db_query_start(&qp); if (ret < 0)