summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 821b680)
raw | patch | inline | side by side (parent: 821b680)
author | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 18:36:05 +0000 (20:36 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 18:36:05 +0000 (20:36 +0200) |
screen_client.c is a new library for MPD specific screen functions.
Makefile.am | patch | blob | history | |
src/mpdclient.c | patch | blob | history | |
src/screen_client.c | [new file with mode: 0644] | patch | blob |
src/screen_client.h | [new file with mode: 0644] | patch | blob |
src/screen_utils.c | patch | blob | history | |
src/screen_utils.h | patch | blob | history |
diff --git a/Makefile.am b/Makefile.am
index a39d435dfaa7bcc6e77a64eeff159f16c5071b8d..995d01f9bd8a8bb602bc47629e1de3a07373cdaf 100644 (file)
--- a/Makefile.am
+++ b/Makefile.am
src/screen_list.h \
src/screen_play.h \
src/screen_utils.h \
+ src/screen_client.h \
src/list_window.h \
src/colors.h \
src/hscroll.h \
src/screen.c \
src/screen_list.c \
src/screen_utils.c \
+ src/screen_client.c \
src/screen_play.c \
src/screen_browser.c \
src/screen_file.c \
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 1728303c52e4c97595971fff9a7a1876b74c04fb..1434d172acd62f926c1acd630d455a3f2d62a6d0 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
#include "mpdclient.h"
#include "filelist.h"
-#include "screen_utils.h"
+#include "screen_client.h"
#include "config.h"
#include "options.h"
#include "strfsong.h"
diff --git a/src/screen_client.c b/src/screen_client.c
--- /dev/null
+++ b/src/screen_client.c
@@ -0,0 +1,56 @@
+/* ncmpc (Ncurses MPD Client)
+ * (c) 2004-2009 The Music Player Daemon Project
+ * Project homepage: http://musicpd.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "screen_client.h"
+#include "screen_utils.h"
+#include "mpdclient.h"
+
+static gint
+_screen_auth(struct mpdclient *c, gint recursion)
+{
+ char *password;
+
+ mpd_connection_clear_error(c->connection);
+ if (recursion > 2)
+ return 1;
+
+ password = screen_read_password(NULL, NULL);
+ if (password == NULL)
+ return 1;
+
+ 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 0;
+}
+
+gint
+screen_auth(struct mpdclient *c)
+{
+ gint ret = _screen_auth(c, 0);
+ mpdclient_update(c);
+ curs_set(0);
+ return ret;
+}
diff --git a/src/screen_client.h b/src/screen_client.h
--- /dev/null
+++ b/src/screen_client.h
@@ -0,0 +1,30 @@
+/* ncmpc (Ncurses MPD Client)
+ * (c) 2004-2009 The Music Player Daemon Project
+ * Project homepage: http://musicpd.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef NCMPC_SCREEN_CLIENT_H
+#define NCMPC_SCREEN_CLIENT_H
+
+#include <glib.h>
+
+struct mpdclient;
+
+gint
+screen_auth(struct mpdclient *c);
+
+#endif
diff --git a/src/screen_utils.c b/src/screen_utils.c
index d8e56df5821671114f9ffadd35dd19b663991924..9b70369fc60a9257ffdb8bcff05bb00d637123fb 100644 (file)
--- a/src/screen_utils.c
+++ b/src/screen_utils.c
return screen_readln(w, prompt, NULL, NULL, NULL);
}
-static char *
+char *
screen_read_password(WINDOW *w, const char *prompt)
{
char *ret;
return ret;
}
-static gint
-_screen_auth(struct mpdclient *c, gint recursion)
-{
- char *password;
-
- mpd_connection_clear_error(c->connection);
- if (recursion > 2)
- return 1;
-
- password = screen_read_password(NULL, NULL);
- if (password == NULL)
- return 1;
-
- 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 0;
-}
-
-gint
-screen_auth(struct mpdclient *c)
-{
- gint ret = _screen_auth(c, 0);
- mpdclient_update(c);
- curs_set(0);
- return ret;
-}
-
/* query user for a string and find it in a list window */
int
screen_find(list_window_t *lw,
diff --git a/src/screen_utils.h b/src/screen_utils.h
index 6aacd5d62f7f37702146959e29a284aac3fd28ff..c87827339abc2d405408188015780d98c77e5dad 100644 (file)
--- a/src/screen_utils.h
+++ b/src/screen_utils.h
/* read a string from the status window */
char *screen_getstr(WINDOW *w, const char *prompt);
+
+char *
+screen_read_password(WINDOW *w, const char *prompt);
+
char *screen_readln(WINDOW *w, const char *prompt, const char *value,
GList **history, GCompletion *gcmp);
char *screen_readln_masked(WINDOW *w, const char *prompt);
list_window_callback_fn_t callback_fn,
void *callback_data);
-gint screen_auth(struct mpdclient *c);
-
void screen_display_completion_list(GList *list);
#ifndef NCMPC_MINI