From 07c6df23bcce91aeaa3e28318e0985b1cfa549be Mon Sep 17 00:00:00 2001 From: SuperBFG7 Date: Sat, 18 Mar 2017 13:31:26 +0100 Subject: [PATCH] added API command to send messages to MPD channels --- src/mpd_client.c | 21 +++++++++++++++++++++ src/mpd_client.h | 1 + 2 files changed, 22 insertions(+) diff --git a/src/mpd_client.c b/src/mpd_client.c index 7271984..0922b66 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -229,6 +229,27 @@ out_save_queue: out_search: free(p_charbuf); break; + case MPD_API_SEND_MESSAGE: + p_charbuf = strdup(c->content); + if(strcmp(strtok(p_charbuf, ","), "MPD_API_SEND_MESSAGE")) + goto out_send_message; + + if((token = strtok(NULL, ",")) == NULL) + goto out_send_message; + + free(p_charbuf); + p_charbuf = strdup(get_arg1(c->content)); + + if ( strtok(p_charbuf, ",") == NULL ) + goto out_send_message; + + if ( (token = strtok(NULL, ",")) == NULL ) + goto out_send_message; + + mpd_run_send_message(mpd.conn, p_charbuf, token); +out_send_message: + free(p_charbuf); + break; #ifdef WITH_MPD_HOST_CHANGE /* Commands allowed when disconnected from MPD server */ case MPD_API_SET_MPDHOST: diff --git a/src/mpd_client.h b/src/mpd_client.h index dd78af9..1fde010 100644 --- a/src/mpd_client.h +++ b/src/mpd_client.h @@ -48,6 +48,7 @@ X(MPD_API_RM_TRACK) \ X(MPD_API_RM_ALL) \ X(MPD_API_SEARCH) \ + X(MPD_API_SEND_MESSAGE) \ X(MPD_API_SET_VOLUME) \ X(MPD_API_SET_PAUSE) \ X(MPD_API_SET_PLAY) \ -- 2.20.1