Code

mpdclient: moved code to mpdclient_handle_error()
authorMax Kellermann <max@duempel.org>
Thu, 10 Sep 2009 15:52:32 +0000 (17:52 +0200)
committerMax Kellermann <max@duempel.org>
Thu, 10 Sep 2009 15:52:32 +0000 (17:52 +0200)
src/mpdclient.c

index a4224a68cd3183ffe8826aa0f1e9af11f3269e13..42cc576d3a31e297543f27b371f77d372a1df015 100644 (file)
@@ -120,27 +120,31 @@ error_cb(mpdclient_t *c, gint error, const gchar *msg)
 /*** mpdclient functions ****************************************************/
 /****************************************************************************/
 
-gint
-mpdclient_finish_command(mpdclient_t *c)
+static gint
+mpdclient_handle_error(mpdclient_t *c)
 {
-       mpd_finishCommand(c->connection);
+       enum mpd_error error = c->connection->error;
 
-       if (c->connection->error) {
-               gint error = c->connection->error;
+       if (error == MPD_ERROR_SUCCESS)
+               return 0;
 
-               if (error == MPD_ERROR_ACK &&
-                   c->connection->errorCode == MPD_ACK_ERROR_PERMISSION &&
-                   screen_auth(c) == 0)
-                       return 0;
+       if (error == MPD_ERROR_ACK &&
+           c->connection->errorCode == MPD_ACK_ERROR_PERMISSION &&
+           screen_auth(c) == 0)
+               return 0;
 
-               if (error == MPD_ERROR_ACK)
-                       error = error | (c->connection->errorCode << 8);
+       if (error == MPD_ERROR_ACK)
+               error = error | (c->connection->errorCode << 8);
 
-               error_cb(c, error, c->connection->errorStr);
-               return error;
-       }
+       error_cb(c, error, c->connection->errorStr);
+       return error;
+}
 
-       return 0;
+gint
+mpdclient_finish_command(mpdclient_t *c)
+{
+       mpd_finishCommand(c->connection);
+       return mpdclient_handle_error(c);
 }
 
 mpdclient_t *