fix error codes handling

MPD_ERROR_* and MPD_SERVER_ERROR_* flags can have the same
value, so we need to store it separately in error_code.
This commit is contained in:
Andrzej Rybczak
2010-03-23 22:56:14 +01:00
parent 08e9b0ee3d
commit 6b396bfbf2
2 changed files with 8 additions and 3 deletions

View File

@@ -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))

View File

@@ -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: ";