From 61b083551265c78110855e79b5f12adcd422affb Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 28 Apr 2009 20:25:07 +0200 Subject: [PATCH] command: added "sticker delete" command --- doc/protocol.xml | 18 ++++++++++++++++++ src/command.c | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/doc/protocol.xml b/doc/protocol.xml index 953012b12..3379fc568 100644 --- a/doc/protocol.xml +++ b/doc/protocol.xml @@ -1273,6 +1273,24 @@ OK + + + + sticker + delete + TYPE + URI + NAME + + + + + Deletes a sticker value from the specified object. If + you do not specify a sticker name, all sticker values + are deleted. + + + diff --git a/src/command.c b/src/command.c index 1290a34e7..d30b63594 100644 --- a/src/command.c +++ b/src/command.c @@ -1588,6 +1588,28 @@ handle_sticker_song(struct client *client, int argc, char *argv[]) return COMMAND_RETURN_ERROR; } + return COMMAND_RETURN_OK; + } else if ((argc == 4 || argc == 5) && + strcmp(argv[1], "delete") == 0) { + struct song *song; + bool ret; + + song = db_get_song(argv[3]); + if (song == NULL) { + command_error(client, ACK_ERROR_NO_EXIST, + "no such song"); + return COMMAND_RETURN_ERROR; + } + + ret = argc == 4 + ? sticker_song_delete(song) + : sticker_song_delete_value(song, argv[4]); + if (!ret) { + command_error(client, ACK_ERROR_SYSTEM, + "no such sticker"); + return COMMAND_RETURN_ERROR; + } + return COMMAND_RETURN_OK; } else if (argc == 5 && strcmp(argv[1], "find") == 0) { /* "sticker find song a/directory name" */