Skip to content

Commit 07668ea

Browse files
authored
Merge pull request #138 from jcorporation/sticker_inc_dec
Support "sticker inc" and "sticker dec" commands (MPD 0.24)
2 parents e0f2eae + 679ca05 commit 07668ea

File tree

5 files changed

+120
-0
lines changed

5 files changed

+120
-0
lines changed

include/mpd/sticker.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,70 @@ bool
9898
mpd_run_sticker_set(struct mpd_connection *connection, const char *type,
9999
const char *uri, const char *name, const char *value);
100100

101+
/**
102+
* Adds or increments a sticker value.
103+
*
104+
* @param connection the connection to MPD
105+
* @param type the object type, e.g. "song"
106+
* @param uri the URI of the object
107+
* @param name the name of the sticker
108+
* @param value the unsigned value to set or increment
109+
* @return true on success, false on error
110+
*
111+
* @since libmpdclient 2.23, MPD 0.24
112+
*/
113+
bool
114+
mpd_send_sticker_inc(struct mpd_connection *connection, const char *type,
115+
const char *uri, const char *name, unsigned value);
116+
117+
/**
118+
* Shortcut for mpd_send_sticker_inc() and mpd_response_finish().
119+
*
120+
* @param connection the connection to MPD
121+
* @param type the object type, e.g. "song"
122+
* @param uri the URI of the object
123+
* @param name the name of the sticker
124+
* @param value the unsigned value to set or increment
125+
* @return true on success, false on error
126+
*
127+
* @since libmpdclient 2.23, MPD 0.24
128+
*/
129+
bool
130+
mpd_run_sticker_inc(struct mpd_connection *connection, const char *type,
131+
const char *uri, const char *name, unsigned value);
132+
133+
/**
134+
* Adds or decrements a sticker value.
135+
*
136+
* @param connection the connection to MPD
137+
* @param type the object type, e.g. "song"
138+
* @param uri the URI of the object
139+
* @param name the name of the sticker
140+
* @param value the unsigned value to set or increment
141+
* @return true on success, false on error
142+
*
143+
* @since libmpdclient 2.23, MPD 0.24
144+
*/
145+
bool
146+
mpd_send_sticker_dec(struct mpd_connection *connection, const char *type,
147+
const char *uri, const char *name, unsigned value);
148+
149+
/**
150+
* Shortcut for mpd_send_sticker_dec() and mpd_response_finish().
151+
*
152+
* @param connection the connection to MPD
153+
* @param type the object type, e.g. "song"
154+
* @param uri the URI of the object
155+
* @param name the name of the sticker
156+
* @param value the unsigned value to set or increment
157+
* @return true on success, false on error
158+
*
159+
* @since libmpdclient 2.23, MPD 0.24
160+
*/
161+
bool
162+
mpd_run_sticker_dec(struct mpd_connection *connection, const char *type,
163+
const char *uri, const char *name, unsigned value);
164+
101165
/**
102166
* Deletes a sticker value.
103167
*

libmpdclient.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,10 @@ global:
494494
mpd_sticker_search_add_window;
495495
mpd_sticker_search_commit;
496496
mpd_sticker_search_cancel;
497+
mpd_send_sticker_inc;
498+
mpd_run_sticker_inc;
499+
mpd_send_sticker_dec;
500+
mpd_run_sticker_dec;
497501

498502
/* mpd/fingerprint.h */
499503
mpd_parse_fingerprint_type;

src/isend.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ bool
6464
mpd_send_s_s_u_command(struct mpd_connection *connection, const char *command,
6565
const char *arg1, const char *arg2, unsigned arg3);
6666

67+
bool
68+
mpd_send_s_s_s_s_u_command(struct mpd_connection *connection, const char *command,
69+
const char *arg1, const char *arg2, const char *arg3,
70+
const char *arg4, unsigned arg5);
71+
6772
bool
6873
mpd_send_range_command(struct mpd_connection *connection, const char *command,
6974
unsigned arg1, unsigned arg2);

src/send.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,18 @@ mpd_send_s_s_u_command(struct mpd_connection *connection, const char *command,
247247
arg1, arg2, arg3_string, NULL);
248248
}
249249

250+
bool
251+
mpd_send_s_s_s_s_u_command(struct mpd_connection *connection, const char *command,
252+
const char *arg1, const char *arg2, const char *arg3,
253+
const char *arg4, unsigned arg5)
254+
{
255+
char arg5_string[INTLEN];
256+
257+
snprintf(arg5_string, sizeof(arg5_string), "%u", arg5);
258+
return mpd_send_command(connection, command,
259+
arg1, arg2, arg3, arg4, arg5_string, NULL);
260+
}
261+
250262
bool
251263
mpd_send_range_command(struct mpd_connection *connection, const char *command,
252264
unsigned arg1, unsigned arg2)

src/sticker.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <mpd/pair.h>
99
#include <mpd/response.h>
1010
#include "internal.h"
11+
#include "isend.h"
1112
#include "request.h"
1213
#include "run.h"
1314

@@ -33,6 +34,40 @@ mpd_run_sticker_set(struct mpd_connection *connection, const char *type,
3334
mpd_response_finish(connection);
3435
}
3536

37+
bool
38+
mpd_send_sticker_inc(struct mpd_connection *connection, const char *type,
39+
const char *uri, const char *name, unsigned value)
40+
{
41+
return mpd_send_s_s_s_s_u_command(connection, "sticker", "inc",
42+
type, uri, name, value);
43+
}
44+
45+
bool
46+
mpd_run_sticker_inc(struct mpd_connection *connection, const char *type,
47+
const char *uri, const char *name, unsigned value)
48+
{
49+
return mpd_run_check(connection) &&
50+
mpd_send_sticker_inc(connection, type, uri, name, value) &&
51+
mpd_response_finish(connection);
52+
}
53+
54+
bool
55+
mpd_send_sticker_dec(struct mpd_connection *connection, const char *type,
56+
const char *uri, const char *name, unsigned value)
57+
{
58+
return mpd_send_s_s_s_s_u_command(connection, "sticker", "inc",
59+
type, uri, name, value);
60+
}
61+
62+
bool
63+
mpd_run_sticker_dec(struct mpd_connection *connection, const char *type,
64+
const char *uri, const char *name, unsigned value)
65+
{
66+
return mpd_run_check(connection) &&
67+
mpd_send_sticker_dec(connection, type, uri, name, value) &&
68+
mpd_response_finish(connection);
69+
}
70+
3671
bool
3772
mpd_send_sticker_delete(struct mpd_connection *connection, const char *type,
3873
const char *uri, const char *name)

0 commit comments

Comments
 (0)