diff --git a/include/mpd/sticker.h b/include/mpd/sticker.h index 5007e00..a09de70 100644 --- a/include/mpd/sticker.h +++ b/include/mpd/sticker.h @@ -98,6 +98,70 @@ bool mpd_run_sticker_set(struct mpd_connection *connection, const char *type, const char *uri, const char *name, const char *value); +/** + * Adds or increments a sticker value. + * + * @param connection the connection to MPD + * @param type the object type, e.g. "song" + * @param uri the URI of the object + * @param name the name of the sticker + * @param value the unsigned value to set or increment + * @return true on success, false on error + * + * @since libmpdclient 2.23, MPD 0.24 + */ +bool +mpd_send_sticker_inc(struct mpd_connection *connection, const char *type, + const char *uri, const char *name, unsigned value); + +/** + * Shortcut for mpd_send_sticker_inc() and mpd_response_finish(). + * + * @param connection the connection to MPD + * @param type the object type, e.g. "song" + * @param uri the URI of the object + * @param name the name of the sticker + * @param value the unsigned value to set or increment + * @return true on success, false on error + * + * @since libmpdclient 2.23, MPD 0.24 + */ +bool +mpd_run_sticker_inc(struct mpd_connection *connection, const char *type, + const char *uri, const char *name, unsigned value); + +/** + * Adds or decrements a sticker value. + * + * @param connection the connection to MPD + * @param type the object type, e.g. "song" + * @param uri the URI of the object + * @param name the name of the sticker + * @param value the unsigned value to set or increment + * @return true on success, false on error + * + * @since libmpdclient 2.23, MPD 0.24 + */ +bool +mpd_send_sticker_dec(struct mpd_connection *connection, const char *type, + const char *uri, const char *name, unsigned value); + +/** + * Shortcut for mpd_send_sticker_dec() and mpd_response_finish(). + * + * @param connection the connection to MPD + * @param type the object type, e.g. "song" + * @param uri the URI of the object + * @param name the name of the sticker + * @param value the unsigned value to set or increment + * @return true on success, false on error + * + * @since libmpdclient 2.23, MPD 0.24 + */ +bool +mpd_run_sticker_dec(struct mpd_connection *connection, const char *type, + const char *uri, const char *name, unsigned value); + /** * Deletes a sticker value. * diff --git a/libmpdclient.ld b/libmpdclient.ld index db97561..dc141ee 100644 --- a/libmpdclient.ld +++ b/libmpdclient.ld @@ -494,6 +494,10 @@ global: mpd_sticker_search_add_window; mpd_sticker_search_commit; mpd_sticker_search_cancel; + mpd_send_sticker_inc; + mpd_run_sticker_inc; + mpd_send_sticker_dec; + mpd_run_sticker_dec; /* mpd/fingerprint.h */ mpd_parse_fingerprint_type; diff --git a/src/isend.h b/src/isend.h index eb8cfac..4cb37e5 100644 --- a/src/isend.h +++ b/src/isend.h @@ -64,6 +64,11 @@ bool mpd_send_s_s_u_command(struct mpd_connection *connection, const char *command, const char *arg1, const char *arg2, unsigned arg3); +bool +mpd_send_s_s_s_s_u_command(struct mpd_connection *connection, const char *command, + const char *arg1, const char *arg2, const char *arg3, + const char *arg4, unsigned arg5); + bool mpd_send_range_command(struct mpd_connection *connection, const char *command, unsigned arg1, unsigned arg2); diff --git a/src/send.c b/src/send.c index ad7e0ad..f963eb6 100644 --- a/src/send.c +++ b/src/send.c @@ -247,6 +247,18 @@ mpd_send_s_s_u_command(struct mpd_connection *connection, const char *command, arg1, arg2, arg3_string, NULL); } +bool +mpd_send_s_s_s_s_u_command(struct mpd_connection *connection, const char *command, + const char *arg1, const char *arg2, const char *arg3, + const char *arg4, unsigned arg5) +{ + char arg5_string[INTLEN]; + + snprintf(arg5_string, sizeof(arg5_string), "%u", arg5); + return mpd_send_command(connection, command, + arg1, arg2, arg3, arg4, arg5_string, NULL); +} + bool mpd_send_range_command(struct mpd_connection *connection, const char *command, unsigned arg1, unsigned arg2) diff --git a/src/sticker.c b/src/sticker.c index 6f7298d..1dc806b 100644 --- a/src/sticker.c +++ b/src/sticker.c @@ -8,6 +8,7 @@ #include #include #include "internal.h" +#include "isend.h" #include "request.h" #include "run.h" @@ -33,6 +34,40 @@ mpd_run_sticker_set(struct mpd_connection *connection, const char *type, mpd_response_finish(connection); } +bool +mpd_send_sticker_inc(struct mpd_connection *connection, const char *type, + const char *uri, const char *name, unsigned value) +{ + return mpd_send_s_s_s_s_u_command(connection, "sticker", "inc", + type, uri, name, value); +} + +bool +mpd_run_sticker_inc(struct mpd_connection *connection, const char *type, + const char *uri, const char *name, unsigned value) +{ + return mpd_run_check(connection) && + mpd_send_sticker_inc(connection, type, uri, name, value) && + mpd_response_finish(connection); +} + +bool +mpd_send_sticker_dec(struct mpd_connection *connection, const char *type, + const char *uri, const char *name, unsigned value) +{ + return mpd_send_s_s_s_s_u_command(connection, "sticker", "inc", + type, uri, name, value); +} + +bool +mpd_run_sticker_dec(struct mpd_connection *connection, const char *type, + const char *uri, const char *name, unsigned value) +{ + return mpd_run_check(connection) && + mpd_send_sticker_dec(connection, type, uri, name, value) && + mpd_response_finish(connection); +} + bool mpd_send_sticker_delete(struct mpd_connection *connection, const char *type, const char *uri, const char *name)