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 "callbacks.h"
21 #include "screen_utils.h"
22 #include "screen_status.h"
23 #include "mpdclient.h"
26 _mpdclient_auth_callback(struct mpdclient
*c
, gint recursion
)
28 struct mpd_connection
*connection
= mpdclient_get_connection(c
);
29 if (connection
== NULL
)
32 mpd_connection_clear_error(connection
);
36 char *password
= screen_read_password(NULL
);
40 mpd_send_password(connection
, password
);
43 mpd_response_finish(connection
);
46 if (mpd_connection_get_error(connection
) == MPD_ERROR_SERVER
&&
47 mpd_connection_get_server_error(connection
) == MPD_SERVER_ERROR_PASSWORD
)
48 return _mpdclient_auth_callback(c
, ++recursion
);
54 mpdclient_auth_callback(struct mpdclient
*c
)
56 return _mpdclient_auth_callback(c
, 0);
60 mpdclient_error_callback(const char *message
)
62 screen_status_message(message
);