summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: db8a107)
raw | patch | inline | side by side (parent: db8a107)
author | Max Kellermann <max.kellermann@gmail.com> | |
Thu, 21 Sep 2017 06:51:19 +0000 (08:51 +0200) | ||
committer | Max Kellermann <max.kellermann@gmail.com> | |
Thu, 21 Sep 2017 06:51:19 +0000 (08:51 +0200) |
Closes #5
NEWS | patch | blob | history | |
src/mpdclient.c | patch | blob | history |
index 157b39dadf390e7f6ede7f383fd893cfafc290f7..43b713c749a9301ca6092e17d9d37ae5ed6d9122 100644 (file)
--- a/NEWS
+++ b/NEWS
* fix crash on lyrics screen
* fix memory leak
* hide the MPD password from the queue screen title
+* implement password for asynchronous connect
* build with Meson instead of autotools
ncmpc 0.27 - (2017-03-25)
diff --git a/src/mpdclient.c b/src/mpdclient.c
index ffa1a5d84408e86757b82d2dbde1617dbf07c583..6a81a0bd8ac20bd6cc2708f3438ad194a28ba643 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
mpdclient_aconnect_start(struct mpdclient *c,
const struct mpd_settings *settings);
+static const struct mpd_settings *
+mpdclient_get_settings(const struct mpdclient *c)
+{
+#ifndef WIN32
+ if (c->connecting2)
+ return c->settings2;
+#endif
+
+ return c->settings;
+}
+
static void
mpdclient_connect_success(struct mpd_connection *connection, void *ctx)
{
assert(c->async_connect != NULL);
c->async_connect = NULL;
+ const char *password =
+ mpd_settings_get_password(mpdclient_get_settings(c));
+ if (password != NULL && !mpd_run_password(connection, password)) {
+ mpdclient_error_callback(mpd_connection_get_error_message(connection));
+ mpd_connection_free(connection);
+ mpdclient_failed_callback();
+ return;
+ }
+
mpdclient_connected(c, connection);
}