Code

list_window: convert comments to doxygen
[ncmpc.git] / src / screen_client.c
index b5b31b5256b475e058d99b70e496be9d106e8183..c70257fe7020891658a4f727d65b74c7a5e267da 100644 (file)
@@ -1,5 +1,5 @@
 /* ncmpc (Ncurses MPD Client)
- * (c) 2004-2009 The Music Player Daemon Project
+ * (c) 2004-2017 The Music Player Daemon Project
  * Project homepage: http://musicpd.org
  *
  * This program is free software; you can redistribute it and/or modify
  */
 
 #include "screen_client.h"
-#include "screen_utils.h"
-#include "screen.h"
+#include "screen_status.h"
 #include "mpdclient.h"
 #include "i18n.h"
 #include "charset.h"
 
-static bool
-_screen_auth(struct mpdclient *c, gint recursion)
-{
-       char *password;
-
-       mpd_connection_clear_error(c->connection);
-       if (recursion > 2)
-               return false;
-
-       password = screen_read_password(NULL, NULL);
-       if (password == NULL)
-               return false;
-
-       mpd_send_password(c->connection, password);
-       g_free(password);
-
-       mpd_response_finish(c->connection);
-       mpdclient_update(c);
-
-       if (mpd_connection_get_error(c->connection) == MPD_ERROR_SERVER &&
-           mpd_connection_get_server_error(c->connection) == MPD_SERVER_ERROR_PASSWORD)
-               return  _screen_auth(c, ++recursion);
-
-       return true;
-}
-
-bool
-screen_auth(struct mpdclient *c)
-{
-       return _screen_auth(c, 0);
-}
-
 void
 screen_database_update(struct mpdclient *c, const char *path)
 {
        assert(c != NULL);
-       assert(c->connection != NULL);
-       assert(c->status != NULL);
+       assert(mpdclient_is_connected(c));
 
-       if (mpd_status_get_update_id(c->status) != 0) {
-               screen_status_printf(_("Database update running..."));
+       struct mpd_connection *connection = mpdclient_get_connection(c);
+       if (connection == NULL)
                return;
-       }
 
-       if (mpdclient_cmd_db_update(c, path) != 0)
+       unsigned id = mpd_run_update(connection, path);
+       if (id == 0) {
+               if (mpd_connection_get_error(connection) == MPD_ERROR_SERVER &&
+                   mpd_connection_get_server_error(connection) == MPD_SERVER_ERROR_UPDATE_ALREADY &&
+                   mpd_connection_clear_error(connection))
+                       screen_status_printf(_("Database update running..."));
+               else
+                       mpdclient_handle_error(c);
                return;
+       }
 
        if (path != NULL && *path != 0) {
                char *path_locale = utf8_to_locale(path);