Code

mpdclient: don't export mpdclient_finish_command()
authorMax Kellermann <max@duempel.org>
Tue, 29 Sep 2009 18:57:48 +0000 (20:57 +0200)
committerMax Kellermann <max@duempel.org>
Tue, 29 Sep 2009 18:57:48 +0000 (20:57 +0200)
Use plain libmpdclient2 functions plus mpdclient_handle_error()
instead.

src/mpdclient.c
src/mpdclient.h
src/screen_outputs.c
src/screen_search.c

index e7024d298d1dea24c2f20fd6f177e4a220140f88..83246989ba99350184d6dedb73e2a1b6c7023e59 100644 (file)
@@ -130,7 +130,7 @@ mpdclient_handle_error(struct mpdclient *c)
        return error;
 }
 
-gint
+static gint
 mpdclient_finish_command(struct mpdclient *c)
 {
        return mpd_response_finish(c->connection)
index 5d299bfc1be66514a7c13c331e67b5fd4d2d46b2..735c505df7d25828d4ca5a56fb769f9c6e670e82 100644 (file)
@@ -29,9 +29,6 @@ struct mpdclient {
 gint
 mpdclient_handle_error(struct mpdclient *c);
 
-gint
-mpdclient_finish_command(struct mpdclient *c);
-
 struct mpdclient *
 mpdclient_new(void);
 
index ac41c0968556d7772b2e127740491bfa64a67b5d..a91f634b1d499641ec021c82e2fe24f9f7878dfd 100644 (file)
@@ -44,7 +44,6 @@ outputs_repaint(void)
 static int
 toggle_output(struct mpdclient *c, unsigned int output_index)
 {
-       int return_value;
        struct mpd_output *output;
 
        assert(mpd_outputs != NULL);
@@ -55,16 +54,22 @@ toggle_output(struct mpdclient *c, unsigned int output_index)
        output = g_ptr_array_index(mpd_outputs, output_index);
 
        if (!mpd_output_get_enabled(output)) {
-               mpd_send_enable_output(c->connection,
-                                      mpd_output_get_id(output));
+               if (!mpd_run_enable_output(c->connection,
+                                          mpd_output_get_id(output))) {
+                       mpdclient_handle_error(c);
+                       return -1;
+               }
 
                /* XXX reload */
 
                screen_status_printf(_("Output '%s' enabled"),
                                     mpd_output_get_name(output));
        } else {
-               mpd_send_disable_output(c->connection,
-                                       mpd_output_get_id(output));
+               if (!mpd_run_disable_output(c->connection,
+                                           mpd_output_get_id(output))) {
+                       mpdclient_handle_error(c);
+                       return -1;
+               }
 
                /* XXX reload */
 
@@ -72,11 +77,9 @@ toggle_output(struct mpdclient *c, unsigned int output_index)
                                     mpd_output_get_name(output));
        }
 
-       return_value = mpdclient_finish_command(c);
-
        outputs_repaint();
 
-       return return_value;
+       return 0;
 }
 
 static void
index dd8c280a1c151a72ede15c09ce1e30c6993c9ae3..11ffd619f134bcbe50b3ef16ad3fcd6c6d0a52ec 100644 (file)
@@ -299,9 +299,11 @@ search_advanced_query(char *query, struct mpdclient *c)
                while ((entity = mpd_recv_entity(c->connection)) != NULL)
                        filelist_append(fl, entity);
 
-               if (mpdclient_finish_command(c)) {
+               if (!mpd_response_finish(c->connection)) {
                        filelist_free(fl);
                        fl = NULL;
+
+                       mpdclient_handle_error(c);
                }
        }