make changes from 7b6521a3 compatible with <mpd-0.14
This commit is contained in:
@@ -101,6 +101,11 @@ void Connection::Disconnect()
|
|||||||
ClearQueue();
|
ClearQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Connection::Version() const
|
||||||
|
{
|
||||||
|
return itsConnection ? itsConnection->version[1] + itsConnection->version[2]*0.1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Connection::SetHostname(const string &host)
|
void Connection::SetHostname(const string &host)
|
||||||
{
|
{
|
||||||
size_t at = host.find("@");
|
size_t at = host.find("@");
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ namespace MPD
|
|||||||
const std::string & GetHostname() { return itsHost; }
|
const std::string & GetHostname() { return itsHost; }
|
||||||
int GetPort() { return itsPort; }
|
int GetPort() { return itsPort; }
|
||||||
|
|
||||||
|
float Version() const;
|
||||||
|
|
||||||
void SetHostname(const std::string &);
|
void SetHostname(const std::string &);
|
||||||
void SetPort(int port) { itsPort = port; }
|
void SetPort(int port) { itsPort = port; }
|
||||||
void SetTimeout(int timeout) { itsTimeout = timeout; }
|
void SetTimeout(int timeout) { itsTimeout = timeout; }
|
||||||
|
|||||||
@@ -55,6 +55,11 @@
|
|||||||
mLibAlbums->Display(); \
|
mLibAlbums->Display(); \
|
||||||
mvvline(main_start_y, right_col_startx-1, 0, main_height); \
|
mvvline(main_start_y, right_col_startx-1, 0, main_height); \
|
||||||
mLibSongs->Display(); \
|
mLibSongs->Display(); \
|
||||||
|
if (mLibAlbums->Empty()) \
|
||||||
|
{ \
|
||||||
|
mLibAlbums->WriteXY(0, 0, 0, "No albums found."); \
|
||||||
|
mLibAlbums->Refresh(); \
|
||||||
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define REFRESH_PLAYLIST_EDITOR_SCREEN \
|
#define REFRESH_PLAYLIST_EDITOR_SCREEN \
|
||||||
@@ -530,15 +535,18 @@ int main(int argc, char *argv[])
|
|||||||
Mpd->CommitSearch(list);
|
Mpd->CommitSearch(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if there are songs without album tag
|
// <mpd-0.14 doesn't support searching for empty tag
|
||||||
SongList noalbum_list;
|
if (Mpd->Version() > 13)
|
||||||
Mpd->StartSearch(1);
|
{
|
||||||
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->Current());
|
SongList noalbum_list;
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, "");
|
Mpd->StartSearch(1);
|
||||||
Mpd->CommitSearch(noalbum_list);
|
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->Current());
|
||||||
if (!noalbum_list.empty())
|
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, "");
|
||||||
mLibAlbums->AddOption(make_pair("<no album>", ""));
|
Mpd->CommitSearch(noalbum_list);
|
||||||
FreeSongList(noalbum_list);
|
if (!noalbum_list.empty())
|
||||||
|
mLibAlbums->AddOption(make_pair("<no album>", ""));
|
||||||
|
FreeSongList(noalbum_list);
|
||||||
|
}
|
||||||
|
|
||||||
for (TagList::iterator it = list.begin(); it != list.end(); it++)
|
for (TagList::iterator it = list.begin(); it != list.end(); it++)
|
||||||
{
|
{
|
||||||
@@ -576,8 +584,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
mLibSongs->Clear(0);
|
mLibSongs->Clear(0);
|
||||||
Mpd->StartSearch(1);
|
Mpd->StartSearch(1);
|
||||||
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->Current());
|
Mpd->AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(mLibArtists->Current()));
|
||||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, locale_to_utf_cpy(mLibAlbums->Current().second));
|
if (mLibAlbums->Empty()) // left for compatibility with <mpd-0.14
|
||||||
|
{
|
||||||
|
mLibAlbums->WriteXY(0, 0, 0, "No albums found.");
|
||||||
|
mLibAlbums->Refresh();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, locale_to_utf_cpy(mLibAlbums->Current().second));
|
||||||
Mpd->CommitSearch(list);
|
Mpd->CommitSearch(list);
|
||||||
|
|
||||||
sort(list.begin(), list.end(), SortSongsByTrack);
|
sort(list.begin(), list.end(), SortSongsByTrack);
|
||||||
@@ -1966,8 +1980,10 @@ int main(int argc, char *argv[])
|
|||||||
wCurrent->Refresh();
|
wCurrent->Refresh();
|
||||||
wCurrent = mLibAlbums;
|
wCurrent = mLibAlbums;
|
||||||
mLibAlbums->HighlightColor(Config.active_column_color);
|
mLibAlbums->HighlightColor(Config.active_column_color);
|
||||||
|
if (!mLibAlbums->Empty())
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (wCurrent == mLibAlbums && !mLibSongs->Empty())
|
if (wCurrent == mLibAlbums && !mLibSongs->Empty())
|
||||||
{
|
{
|
||||||
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||||
wCurrent->Refresh();
|
wCurrent->Refresh();
|
||||||
@@ -2020,8 +2036,10 @@ int main(int argc, char *argv[])
|
|||||||
wCurrent->Refresh();
|
wCurrent->Refresh();
|
||||||
wCurrent = mLibAlbums;
|
wCurrent = mLibAlbums;
|
||||||
mLibAlbums->HighlightColor(Config.active_column_color);
|
mLibAlbums->HighlightColor(Config.active_column_color);
|
||||||
|
if (!mLibAlbums->Empty())
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (wCurrent == mLibAlbums)
|
if (wCurrent == mLibAlbums)
|
||||||
{
|
{
|
||||||
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||||
wCurrent->Refresh();
|
wCurrent->Refresh();
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ void TraceMpdStatus()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//wHeader->WriteXY(0,1, IntoStr(now_playing), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NcmpcppErrorCallback(Connection *Mpd, int errorid, const char *msg, void *)
|
void NcmpcppErrorCallback(Connection *Mpd, int errorid, const char *msg, void *)
|
||||||
|
|||||||
Reference in New Issue
Block a user