summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9f08e1a)
raw | patch | inline | side by side (parent: 9f08e1a)
author | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 18:57:27 +0000 (20:57 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 18:57:27 +0000 (20:57 +0200) |
Moved code from screen_file.c and player_command.c.
src/player_command.c | patch | blob | history | |
src/screen_client.c | patch | blob | history | |
src/screen_client.h | patch | blob | history | |
src/screen_file.c | patch | blob | history |
diff --git a/src/player_command.c b/src/player_command.c
index dab3d525def6462bea0943296843f58a1dd5969c..678d13a07343232d380ee004dd891ebefa6351fc 100644 (file)
--- a/src/player_command.c
+++ b/src/player_command.c
#include "options.h"
#include "screen.h"
#include "i18n.h"
+#include "screen_client.h"
#define IS_PLAYING(s) (s==MPD_STATE_PLAY)
#define IS_PAUSED(s) (s==MPD_STATE_PAUSE)
mpdclient_cmd_crossfade(c, options.crossfade_time);
break;
case CMD_DB_UPDATE:
- if (!mpd_status_get_update_id(c->status)) {
- if( mpdclient_cmd_db_update(c,NULL)==0 )
- screen_status_printf(_("Database update started"));
- } else
- screen_status_printf(_("Database update running..."));
+ screen_database_update(c, NULL);
break;
case CMD_VOLUME_UP:
mpdclient_cmd_volume_up(c);
diff --git a/src/screen_client.c b/src/screen_client.c
index 7583e8a15e476d434a6f1c62dd507ee483acdf48..b5b31b5256b475e058d99b70e496be9d106e8183 100644 (file)
--- a/src/screen_client.c
+++ b/src/screen_client.c
#include "screen_client.h"
#include "screen_utils.h"
+#include "screen.h"
#include "mpdclient.h"
+#include "i18n.h"
+#include "charset.h"
static bool
_screen_auth(struct mpdclient *c, gint recursion)
{
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);
+
+ if (mpd_status_get_update_id(c->status) != 0) {
+ screen_status_printf(_("Database update running..."));
+ return;
+ }
+
+ if (mpdclient_cmd_db_update(c, path) != 0)
+ return;
+
+ if (path != NULL && *path != 0) {
+ char *path_locale = utf8_to_locale(path);
+ screen_status_printf(_("Database update of %s started"), path);
+ g_free(path_locale);
+ } else
+ screen_status_message(_("Database update started"));
+}
diff --git a/src/screen_client.h b/src/screen_client.h
index 9b419d148e175ddf84b86de383e56f95217cab9b..e98f7721777c90f165ed1d75a86a54039244e113 100644 (file)
--- a/src/screen_client.h
+++ b/src/screen_client.h
bool
screen_auth(struct mpdclient *c);
+/**
+ * Starts a (server-side) database update and displays a status
+ * message.
+ */
+void
+screen_database_update(struct mpdclient *c, const char *path);
+
#endif
diff --git a/src/screen_file.c b/src/screen_file.c
index ed3d26a2610bba51ed1364fab640da84792566e1..a9d5e6a7ad3346e6939c3aae61345a1b2efc1237 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
#include "screen_utils.h"
#include "screen_browser.h"
#include "screen_play.h"
+#include "screen_client.h"
#include <mpd/client.h>
if (c->status == NULL)
return true;
- if (mpd_status_get_update_id(c->status) == 0) {
- if (mpdclient_cmd_db_update(c, current_path) == 0) {
- if (strcmp(current_path, "")) {
- char *path_locale =
- utf8_to_locale(current_path);
- screen_status_printf(_("Database update of %s started"),
- path_locale);
- g_free(path_locale);
- } else
- screen_status_printf(_("Database update started"));
- }
- } else
- screen_status_printf(_("Database update running..."));
+ screen_database_update(c, current_path);
return true;
default: