mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-13 07:53:23 -05:00
add daap URIs for delete playlist and delete playlist items
This commit is contained in:
parent
c2de7ce606
commit
0aadff5e5a
@ -199,6 +199,8 @@ DAAP_ITEMS taglist[] = {
|
||||
{ 0x01, "MPTY", "org.mt-daapd.playlist-type" },
|
||||
{ 0x0C, "MAPR", "org.mt-daapd.addplaylist" },
|
||||
{ 0x0C, "MAPI", "org.mt-daapd.addplaylistitem" },
|
||||
{ 0x0C, "MDPR", "org.mt-daapd.delplaylist" },
|
||||
{ 0x0C, "MDPI", "org.mt-daapd.delplaylistitem" },
|
||||
{ 0x00, NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -55,6 +55,8 @@ static void dispatch_browse(WS_CONNINFO *pwsc, DBQUERYINFO *pqi);
|
||||
static void dispatch_playlists(WS_CONNINFO *pqsc, DBQUERYINFO *pqi);
|
||||
static void dispatch_addplaylist(WS_CONNINFO *pwsc, DBQUERYINFO *pqi);
|
||||
static void dispatch_addplaylistitems(WS_CONNINFO *pwsc, DBQUERYINFO *pqi);
|
||||
static void dispatch_deleteplaylist(WS_CONNINFO *pwsc, DBQUERYINFO *pqi);
|
||||
static void dispatch_deleteplaylistitems(WS_CONNINFO *pwsc, DBQUERYINFO *pqi);
|
||||
static void dispatch_items(WS_CONNINFO *pwsc, DBQUERYINFO *pqi);
|
||||
static void dispatch_logout(WS_CONNINFO *pwsc, DBQUERYINFO *pqi);
|
||||
|
||||
@ -203,7 +205,11 @@ void daap_handler(WS_CONNINFO *pwsc) {
|
||||
(!strcasecmp(pqi->uri_sections[3],"add")))
|
||||
/* /databases/id/containers/add */
|
||||
return dispatch_addplaylist(pwsc,pqi);
|
||||
|
||||
if((!strcasecmp(pqi->uri_sections[2],"containers")) &&
|
||||
(!strcasecmp(pqi->uri_sections[3],"del")))
|
||||
/* /databases/id/containers/del */
|
||||
return dispatch_deleteplaylist(pwsc,pqi);
|
||||
|
||||
pwsc->close=1;
|
||||
free(pqi);
|
||||
ws_returnerror(pwsc,404,"Page not found");
|
||||
@ -215,6 +221,12 @@ void daap_handler(WS_CONNINFO *pwsc) {
|
||||
pqi->playlist_id=atoi(pqi->uri_sections[3]);
|
||||
return dispatch_playlistitems(pwsc,pqi);
|
||||
}
|
||||
if((!strcasecmp(pqi->uri_sections[2],"containers")) &&
|
||||
(!strcasecmp(pqi->uri_sections[4],"del"))) {
|
||||
/* /databases/id/containers/id/del */
|
||||
pqi->playlist_id=atoi(pqi->uri_sections[3]);
|
||||
return dispatch_deleteplaylistitems(pwsc,pqi);
|
||||
}
|
||||
}
|
||||
if(pqi->uri_count == 6) {
|
||||
if((!strcasecmp(pqi->uri_sections[2],"containers")) &&
|
||||
@ -814,6 +826,75 @@ void dispatch_addplaylistitems(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a playlist
|
||||
*/
|
||||
void dispatch_deleteplaylist(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
||||
char playlist_response[20];
|
||||
char *current;
|
||||
|
||||
if(!ws_getvar(pwsc,"dmap.itemid")) {
|
||||
DPRINTF(E_LOG,L_DAAP,"attempt to delete playlist with no dmap.itemid\n");
|
||||
ws_returnerror(pwsc,500,"no itemid specified");
|
||||
return;
|
||||
}
|
||||
|
||||
db_delete_playlist(atoi(ws_getvar(pwsc,"dmap.itemid")));
|
||||
|
||||
/* success(ish)... spool out a dmap block */
|
||||
current = playlist_response;
|
||||
current += db_dmap_add_container(current,"MDPR",12);
|
||||
current += db_dmap_add_int(current,"mstt",200); /* 12 */
|
||||
|
||||
dispatch_output_start(pwsc,pqi,20);
|
||||
dispatch_output_write(pwsc,pqi,playlist_response,20);
|
||||
dispatch_output_end(pwsc,pqi);
|
||||
|
||||
pwsc->close=1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a playlist item
|
||||
*/
|
||||
void dispatch_deleteplaylistitems(WS_CONNINFO *pwsc, DBQUERYINFO *pqi) {
|
||||
char playlist_response[20];
|
||||
char *current;
|
||||
char *tempstring;
|
||||
char *token;
|
||||
|
||||
if(!ws_getvar(pwsc,"dmap.itemid")) {
|
||||
DPRINTF(E_LOG,L_DAAP,"attempt to delete playlist items with no dmap.itemid\n");
|
||||
ws_returnerror(pwsc,500,"no itemid specified");
|
||||
return;
|
||||
}
|
||||
|
||||
tempstring=strdup(ws_getvar(pwsc,"dmap.itemid"));
|
||||
current=tempstring;
|
||||
|
||||
while((token=strsep(¤t,","))) {
|
||||
if(token) {
|
||||
db_delete_playlist_item(pqi->playlist_id,atoi(token));
|
||||
}
|
||||
}
|
||||
|
||||
free(tempstring);
|
||||
|
||||
/* success(ish)... spool out a dmap block */
|
||||
current = playlist_response;
|
||||
current += db_dmap_add_container(current,"MDPI",12);
|
||||
current += db_dmap_add_int(current,"mstt",200); /* 12 */
|
||||
|
||||
dispatch_output_start(pwsc,pqi,20);
|
||||
dispatch_output_write(pwsc,pqi,playlist_response,20);
|
||||
dispatch_output_end(pwsc,pqi);
|
||||
|
||||
pwsc->close=1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* add a playlist
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user