release v0.26
[ncmpc.git] / src / screen_client.c
blobc70257fe7020891658a4f727d65b74c7a5e267da
1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2017 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "screen_client.h"
21 #include "screen_status.h"
22 #include "mpdclient.h"
23 #include "i18n.h"
24 #include "charset.h"
26 void
27 screen_database_update(struct mpdclient *c, const char *path)
29 assert(c != NULL);
30 assert(mpdclient_is_connected(c));
32 struct mpd_connection *connection = mpdclient_get_connection(c);
33 if (connection == NULL)
34 return;
36 unsigned id = mpd_run_update(connection, path);
37 if (id == 0) {
38 if (mpd_connection_get_error(connection) == MPD_ERROR_SERVER &&
39 mpd_connection_get_server_error(connection) == MPD_SERVER_ERROR_UPDATE_ALREADY &&
40 mpd_connection_clear_error(connection))
41 screen_status_printf(_("Database update running..."));
42 else
43 mpdclient_handle_error(c);
44 return;
47 if (path != NULL && *path != 0) {
48 char *path_locale = utf8_to_locale(path);
49 screen_status_printf(_("Database update of %s started"), path);
50 g_free(path_locale);
51 } else
52 screen_status_message(_("Database update started"));