added API command to send messages to MPD channels
authorSuperBFG7 <daniel@despite.ch>
Sat, 18 Mar 2017 12:31:26 +0000 (13:31 +0100)
committerSuperBFG7 <daniel@despite.ch>
Sat, 18 Mar 2017 12:31:26 +0000 (13:31 +0100)
src/mpd_client.c
src/mpd_client.h

index 7271984..0922b66 100644 (file)
@@ -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:
index dd78af9..1fde010 100644 (file)
@@ -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) \