8 #include "debug_printf.h"
10 #include "libmpd-internal.h"
13 int mpd_sticker_supported ( MpdObj
*mi
)
15 if(mi
== NULL
) return FALSE
;
17 if(mpd_server_check_command_allowed(mi
, "sticker") == MPD_SERVER_COMMAND_ALLOWED
) {
24 char * mpd_sticker_song_get(MpdObj
*mi
, const char *path
, const char *tag
)
26 char *retv_value
= NULL
;
28 if(!mpd_check_connected(mi
))
30 debug_printf(DEBUG_INFO
,"not connected\n");
33 if(mpd_server_check_command_allowed(mi
, "sticker") != MPD_SERVER_COMMAND_ALLOWED
) {
34 debug_printf(DEBUG_WARNING
, "Command not allowed\n");
39 debug_printf(DEBUG_ERROR
,"lock failed\n");
43 mpd_sendGetSongSticker(mi
->connection
,path
, tag
);
44 retv_value
= mpd_getNextSticker(mi
->connection
);
45 mpd_finishCommand(mi
->connection
);
46 if(retv_value
&& strlen(retv_value
) > strlen(tag
)){
47 retv
= g_strdup(&retv_value
[strlen(tag
)]+1);
50 if(mi
->connection
->error
== MPD_ERROR_ACK
&& mi
->connection
->errorCode
== MPD_ACK_ERROR_NO_EXIST
)
52 mpd_clearError(mi
->connection
);
56 if(mpd_unlock_conn(mi
))
58 debug_printf(DEBUG_ERROR
, "Failed to unlock");
65 int mpd_sticker_song_set(MpdObj
*mi
, const char *path
, const char *tag
, const char *value
)
67 if(!mpd_check_connected(mi
))
69 debug_printf(DEBUG_INFO
,"not connected\n");
70 return MPD_NOT_CONNECTED
;
72 if(mpd_server_check_command_allowed(mi
, "sticker") != MPD_SERVER_COMMAND_ALLOWED
) {
73 debug_printf(DEBUG_WARNING
, "Command not allowed\n");
74 return MPD_SERVER_NOT_SUPPORTED
;
78 debug_printf(DEBUG_ERROR
,"lock failed\n");
79 return MPD_LOCK_FAILED
;
82 mpd_sendSetSongSticker(mi
->connection
,path
, tag
,value
);
83 mpd_finishCommand(mi
->connection
);
84 if(mpd_unlock_conn(mi
))
86 debug_printf(DEBUG_ERROR
, "Failed to unlock");
87 return MPD_LOCK_FAILED
;