diff --git a/src/helpers.cpp b/src/helpers.cpp index 1408610f..124e6a43 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -372,6 +372,12 @@ std::string ExtractTopName(const std::string &s) return slash != std::string::npos ? s.substr(++slash) : s; } +std::string PathGoDownOneLevel(const std::string &path) +{ + size_t i = path.rfind('/'); + return i == std::string::npos ? "/" : path.substr(0, i); +} + std::basic_string Scroller(const std::basic_string &str, size_t &pos, size_t width) { std::basic_string s(str); diff --git a/src/helpers.h b/src/helpers.h index bb320c5d..b9ef7f94 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -213,6 +213,7 @@ std::string FindSharedDir(const MPD::SongList &); #endif // HAVE_TAGLIB_H std::string FindSharedDir(const std::string &, const std::string &); std::string ExtractTopName(const std::string &); +std::string PathGoDownOneLevel(const std::string &path); std::string GetLineValue(std::string &, char = '"', char = '"', bool = 0); diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp index f215115e..f054d28b 100644 --- a/src/mpdpp.cpp +++ b/src/mpdpp.cpp @@ -191,7 +191,13 @@ void MPD::Connection::UpdateStatus() } } + // if CheckForErrors() invokes callback, it can do some communication with mpd. + // the problem is, we *have* to be out from idle mode here and issuing commands + // will enter it again, which certainly is not desired, so let's block it for + // a while. + BlockIdle(true); CheckForErrors(); + BlockIdle(false); if (!itsConnection) return; diff --git a/src/status.cpp b/src/status.cpp index 098c753c..889208ba 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -205,6 +205,11 @@ void NcmpcppErrorCallback(MPD::Connection *, int errorid, const char *msg, void ShowMessage("Password accepted!"); wFooter->SetGetStringHelper(StatusbarGetStringHelper); } + else if ((errorid >> 8) == MPD_SERVER_ERROR_NO_EXIST && myScreen == myBrowser) + { + myBrowser->GetDirectory(PathGoDownOneLevel(myBrowser->CurrentDir())); + myBrowser->Refresh(); + } else ShowMessage("%s", msg); }