diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp index 30d715a7..e32061a7 100644 --- a/src/mpdpp.cpp +++ b/src/mpdpp.cpp @@ -124,6 +124,7 @@ void MPD::Connection::SetHostname(const std::string &host) bool MPD::Connection::SendPassword() { + assert(itsConnection); GoBusy(); assert(!isCommandsListEnabled); mpd_run_password(itsConnection, itsPassword.c_str()); @@ -1297,8 +1298,8 @@ int MPD::Connection::CheckForErrors() { // this is to avoid setting too small max size as we check it before fetching current status // setting real max playlist length is in UpdateStatus() - error_code = mpd_connection_get_server_error(itsConnection); - if (error_code == MPD_SERVER_ERROR_PLAYLIST_MAX && itsMaxPlaylistLength == size_t(-1)) + error_code |= (mpd_connection_get_server_error(itsConnection) << 8); + if ((error_code >> 8) == MPD_SERVER_ERROR_PLAYLIST_MAX && itsMaxPlaylistLength == size_t(-1)) itsMaxPlaylistLength = 0; } if (!mpd_connection_clear_error(itsConnection)) diff --git a/src/status.cpp b/src/status.cpp index e7a68cc0..74d92773 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -191,7 +191,11 @@ void TraceMpdStatus() void NcmpcppErrorCallback(MPD::Connection *, int errorid, const char *msg, void *) { - if (errorid == MPD_SERVER_ERROR_PERMISSION) + // for errorid: + // - 0-7 bits define MPD_ERROR_* codes, compare them with (0xff & errorid) + // - 8-15 bits define MPD_SERVER_ERROR_* codes, compare them with (errorid >> 8) + + if ((errorid >> 8) == MPD_SERVER_ERROR_PERMISSION) { wFooter->SetGetStringHelper(0); Statusbar() << "Password: ";