make changes from 7b6521a3 compatible with <mpd-0.14
This commit is contained in:
@@ -101,6 +101,11 @@ void Connection::Disconnect()
|
||||
ClearQueue();
|
||||
}
|
||||
|
||||
float Connection::Version() const
|
||||
{
|
||||
return itsConnection ? itsConnection->version[1] + itsConnection->version[2]*0.1 : 0;
|
||||
}
|
||||
|
||||
void Connection::SetHostname(const string &host)
|
||||
{
|
||||
size_t at = host.find("@");
|
||||
|
||||
44
src/mpdpp.h
44
src/mpdpp.h
@@ -80,27 +80,29 @@ namespace MPD
|
||||
public:
|
||||
Connection();
|
||||
~Connection();
|
||||
|
||||
|
||||
bool Connect();
|
||||
bool Connected() const;
|
||||
void Disconnect();
|
||||
|
||||
|
||||
const std::string & GetHostname() { return itsHost; }
|
||||
int GetPort() { return itsPort; }
|
||||
|
||||
|
||||
float Version() const;
|
||||
|
||||
void SetHostname(const std::string &);
|
||||
void SetPort(int port) { itsPort = port; }
|
||||
void SetTimeout(int timeout) { itsTimeout = timeout; }
|
||||
void SetPassword(const std::string &password) { itsPassword = password; }
|
||||
void SendPassword() const;
|
||||
|
||||
|
||||
void SetStatusUpdater(StatusUpdater, void *);
|
||||
void SetErrorHandler(ErrorHandler, void *);
|
||||
void UpdateStatus();
|
||||
void UpdateDirectory(const std::string &) const;
|
||||
|
||||
|
||||
void Execute(const std::string &) const;
|
||||
|
||||
|
||||
void Play() const;
|
||||
void Play(int) const;
|
||||
void PlayID(int) const;
|
||||
@@ -112,7 +114,7 @@ namespace MPD
|
||||
void Seek(int) const;
|
||||
void Shuffle() const;
|
||||
void ClearPlaylist() const;
|
||||
|
||||
|
||||
PlayerState GetState() const { return isConnected && itsCurrentStatus ? (PlayerState)itsCurrentStatus->state : psUnknown; }
|
||||
bool GetRepeat() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->repeat : 0; }
|
||||
bool GetRandom() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->random : 0; }
|
||||
@@ -122,24 +124,24 @@ namespace MPD
|
||||
long long GetPlaylistID() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->playlist : -1; }
|
||||
long long GetOldPlaylistID() const { return isConnected && itsOldStatus ? itsOldStatus->playlist : -1; }
|
||||
int GetElapsedTime() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->elapsedTime : -1; }
|
||||
|
||||
|
||||
size_t GetMaxPlaylistLength() const { return itsMaxPlaylistLength; }
|
||||
size_t GetPlaylistLength() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->playlistLength : 0; }
|
||||
void GetPlaylistChanges(long long, SongList &) const;
|
||||
|
||||
|
||||
const std::string & GetErrorMessage() const { return itsErrorMessage; }
|
||||
int GetErrorCode() const { return itsErrorCode; }
|
||||
|
||||
|
||||
Song GetCurrentSong() const;
|
||||
int GetCurrentSongPos() const;
|
||||
Song GetSong(const std::string &) const;
|
||||
void GetPlaylistContent(const std::string &, SongList &) const;
|
||||
|
||||
|
||||
void SetRepeat(bool) const;
|
||||
void SetRandom(bool) const;
|
||||
void SetVolume(int) const;
|
||||
void SetCrossfade(int) const;
|
||||
|
||||
|
||||
int AddSong(const std::string &); // returns id of added song
|
||||
int AddSong(const Song &); // returns id of added song
|
||||
void QueueAddSong(const std::string &);
|
||||
@@ -152,7 +154,7 @@ namespace MPD
|
||||
void QueueMove(const std::string &, int, int);
|
||||
void QueueDeleteFromPlaylist(const std::string &, int);
|
||||
bool CommitQueue();
|
||||
|
||||
|
||||
void DeletePlaylist(const std::string &) const;
|
||||
bool SavePlaylist(const std::string &) const;
|
||||
void ClearPlaylist(const std::string &) const;
|
||||
@@ -160,13 +162,13 @@ namespace MPD
|
||||
void AddToPlaylist(const std::string &, const std::string &) const;
|
||||
void Move(const std::string &, int, int) const;
|
||||
void Rename(const std::string &, const std::string &) const;
|
||||
|
||||
|
||||
void StartSearch(bool) const;
|
||||
void StartFieldSearch(mpd_TagItems);
|
||||
void AddSearch(mpd_TagItems, const std::string &) const;
|
||||
void CommitSearch(SongList &) const;
|
||||
void CommitSearch(TagList &) const;
|
||||
|
||||
|
||||
void GetPlaylists(TagList &) const;
|
||||
void GetList(TagList &, mpd_TagItems) const;
|
||||
void GetArtists(TagList &) const;
|
||||
@@ -175,23 +177,23 @@ namespace MPD
|
||||
void GetDirectoryRecursive(const std::string &, SongList &) const;
|
||||
void GetSongs(const std::string &, SongList &) const;
|
||||
void GetDirectories(const std::string &, TagList &) const;
|
||||
|
||||
|
||||
private:
|
||||
void ClearQueue();
|
||||
int CheckForErrors();
|
||||
|
||||
|
||||
mpd_Connection *itsConnection;
|
||||
bool isConnected;
|
||||
|
||||
|
||||
std::string itsErrorMessage;
|
||||
int itsErrorCode;
|
||||
size_t itsMaxPlaylistLength;
|
||||
|
||||
|
||||
std::string itsHost;
|
||||
int itsPort;
|
||||
int itsTimeout;
|
||||
std::string itsPassword;
|
||||
|
||||
|
||||
mpd_Stats *itsOldStats;
|
||||
mpd_Stats *itsCurrentStats;
|
||||
mpd_Status *itsCurrentStatus;
|
||||
@@ -203,7 +205,7 @@ namespace MPD
|
||||
void *itsStatusUpdaterUserdata;
|
||||
ErrorHandler itsErrorHandler;
|
||||
void *itsErrorHandlerUserdata;
|
||||
|
||||
|
||||
mpd_TagItems itsSearchedField;
|
||||
std::vector<QueueCommand *> itsQueue;
|
||||
};
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
mLibAlbums->Display(); \
|
||||
mvvline(main_start_y, right_col_startx-1, 0, main_height); \
|
||||
mLibSongs->Display(); \
|
||||
if (mLibAlbums->Empty()) \
|
||||
{ \
|
||||
mLibAlbums->WriteXY(0, 0, 0, "No albums found."); \
|
||||
mLibAlbums->Refresh(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define REFRESH_PLAYLIST_EDITOR_SCREEN \
|
||||
@@ -530,15 +535,18 @@ int main(int argc, char *argv[])
|
||||
Mpd->CommitSearch(list);
|
||||
}
|
||||
|
||||
// check if there are songs without album tag
|
||||
SongList noalbum_list;
|
||||
Mpd->StartSearch(1);
|
||||
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->Current());
|
||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, "");
|
||||
Mpd->CommitSearch(noalbum_list);
|
||||
if (!noalbum_list.empty())
|
||||
mLibAlbums->AddOption(make_pair("<no album>", ""));
|
||||
FreeSongList(noalbum_list);
|
||||
// <mpd-0.14 doesn't support searching for empty tag
|
||||
if (Mpd->Version() > 13)
|
||||
{
|
||||
SongList noalbum_list;
|
||||
Mpd->StartSearch(1);
|
||||
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->Current());
|
||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, "");
|
||||
Mpd->CommitSearch(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++)
|
||||
{
|
||||
@@ -576,8 +584,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
mLibSongs->Clear(0);
|
||||
Mpd->StartSearch(1);
|
||||
Mpd->AddSearch(Config.media_lib_primary_tag, mLibArtists->Current());
|
||||
Mpd->AddSearch(MPD_TAG_ITEM_ALBUM, locale_to_utf_cpy(mLibAlbums->Current().second));
|
||||
Mpd->AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(mLibArtists->Current()));
|
||||
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);
|
||||
|
||||
sort(list.begin(), list.end(), SortSongsByTrack);
|
||||
@@ -1966,8 +1980,10 @@ int main(int argc, char *argv[])
|
||||
wCurrent->Refresh();
|
||||
wCurrent = mLibAlbums;
|
||||
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);
|
||||
wCurrent->Refresh();
|
||||
@@ -2020,8 +2036,10 @@ int main(int argc, char *argv[])
|
||||
wCurrent->Refresh();
|
||||
wCurrent = mLibAlbums;
|
||||
mLibAlbums->HighlightColor(Config.active_column_color);
|
||||
if (!mLibAlbums->Empty())
|
||||
continue;
|
||||
}
|
||||
else if (wCurrent == mLibAlbums)
|
||||
if (wCurrent == mLibAlbums)
|
||||
{
|
||||
mLibAlbums->HighlightColor(Config.main_highlight_color);
|
||||
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 *)
|
||||
|
||||
Reference in New Issue
Block a user