remove some hacky shit
This commit is contained in:
@@ -76,7 +76,7 @@ std::basic_string<my_char_t> Help::Title()
|
||||
return U("Help");
|
||||
}
|
||||
|
||||
std::string Help::DisplayKeys2(const ActionType at)
|
||||
std::string Help::DisplayKeys(const ActionType at)
|
||||
{
|
||||
bool backspace = true;
|
||||
std::string result;
|
||||
@@ -144,7 +144,7 @@ void Help::Section(const char *type, const char *title)
|
||||
|
||||
void Help::KeyDesc(const ActionType at, const char *desc)
|
||||
{
|
||||
*w << " " << DisplayKeys2(at) << " : " << desc << "\n";
|
||||
*w << " " << DisplayKeys(at) << " : " << desc << "\n";
|
||||
}
|
||||
|
||||
void Help::MouseDesc(std::string action, const char *desc, bool indent)
|
||||
@@ -221,6 +221,7 @@ void Help::GetKeybindings()
|
||||
KeyDesc(aDeselectItems, "Deselect items");
|
||||
KeyDesc(aSelectAlbum, "Select songs of album around the cursor");
|
||||
KeyDesc(aAddSelectedItems, "Add selected items to playlist");
|
||||
KeyDesc(aAddRandomItems, "Add random items to playlist");
|
||||
*w << "\n";
|
||||
KeyDesc(aToggleRepeat, "Toggle repeat mode");
|
||||
KeyDesc(aToggleRandom, "Toggle random mode");
|
||||
@@ -265,7 +266,6 @@ void Help::GetKeybindings()
|
||||
|
||||
KeysSection("Playlist");
|
||||
KeyDesc(aPressEnter, "Play selected item");
|
||||
KeyDesc(aAddRandomItems, "Add random items to playlist");
|
||||
KeyDesc(aDelete, "Delete selected item(s) from playlist");
|
||||
KeyDesc(aClearMainPlaylist, "Clear playlist");
|
||||
KeyDesc(aCropMainPlaylist, "Clear playlist except playing/selected items");
|
||||
|
||||
@@ -54,7 +54,7 @@ class Help : public Screen<Scrollpad>
|
||||
void MouseDesc(std::string action, const char *desc, bool indent = false);
|
||||
void MouseColumn(const char *column);
|
||||
|
||||
std::string DisplayKeys2(const ActionType at);
|
||||
std::string DisplayKeys(const ActionType at);
|
||||
void GetKeybindings();
|
||||
};
|
||||
|
||||
|
||||
@@ -28,12 +28,8 @@
|
||||
|
||||
MPD::Connection Mpd;
|
||||
|
||||
const char *MPD::Message::PartOfSongsAdded = "Only part of requested songs' list added to playlist!";
|
||||
const char *MPD::Message::FullPlaylist = "Playlist is full!";
|
||||
|
||||
MPD::Connection::Connection() : itsConnection(0),
|
||||
isCommandsListEnabled(0),
|
||||
itsMaxPlaylistLength(-1),
|
||||
isIdle(0),
|
||||
supportsIdle(0),
|
||||
itsHost("localhost"),
|
||||
@@ -98,7 +94,6 @@ void MPD::Connection::Disconnect()
|
||||
itsOldStatus = 0;
|
||||
itsStats = 0;
|
||||
isCommandsListEnabled = 0;
|
||||
itsMaxPlaylistLength = -1;
|
||||
}
|
||||
|
||||
unsigned MPD::Connection::Version() const
|
||||
@@ -209,9 +204,6 @@ void MPD::Connection::UpdateStatus()
|
||||
|
||||
itsCurrentStatus = mpd_run_status(itsConnection);
|
||||
|
||||
if (!itsMaxPlaylistLength)
|
||||
itsMaxPlaylistLength = GetPlaylistLength();
|
||||
|
||||
if (CheckForErrors())
|
||||
return;
|
||||
|
||||
@@ -851,27 +843,22 @@ int MPD::Connection::AddSong(const std::string &path, int pos)
|
||||
{
|
||||
if (!itsConnection)
|
||||
return -1;
|
||||
int id = -1;
|
||||
if (GetPlaylistLength() < itsMaxPlaylistLength)
|
||||
int id;
|
||||
if (!isCommandsListEnabled)
|
||||
GoBusy();
|
||||
else
|
||||
assert(!isIdle);
|
||||
if (pos < 0)
|
||||
mpd_send_add_id(itsConnection, path.c_str());
|
||||
else
|
||||
mpd_send_add_id_to(itsConnection, path.c_str(), pos);
|
||||
if (!isCommandsListEnabled)
|
||||
{
|
||||
if (!isCommandsListEnabled)
|
||||
GoBusy();
|
||||
else
|
||||
assert(!isIdle);
|
||||
if (pos < 0)
|
||||
mpd_send_add_id(itsConnection, path.c_str());
|
||||
else
|
||||
mpd_send_add_id_to(itsConnection, path.c_str(), pos);
|
||||
if (!isCommandsListEnabled)
|
||||
{
|
||||
id = mpd_recv_song_id(itsConnection);
|
||||
mpd_response_finish(itsConnection);
|
||||
}
|
||||
else
|
||||
id = 0;
|
||||
id = mpd_recv_song_id(itsConnection);
|
||||
mpd_response_finish(itsConnection);
|
||||
}
|
||||
else if (itsErrorHandler)
|
||||
itsErrorHandler(this, MPD_SERVER_ERROR_PLAYLIST_MAX, Message::FullPlaylist, itsErrorHandlerUserdata);
|
||||
else
|
||||
id = 0;
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -1030,11 +1017,6 @@ bool MPD::Connection::CommitCommandsList()
|
||||
mpd_command_list_end(itsConnection);
|
||||
isCommandsListEnabled = 0;
|
||||
return mpd_response_finish(itsConnection);
|
||||
if (GetPlaylistLength() == itsMaxPlaylistLength && itsErrorHandler)
|
||||
itsErrorHandler(this, MPD_SERVER_ERROR_PLAYLIST_MAX, Message::FullPlaylist, itsErrorHandlerUserdata);
|
||||
bool result = !CheckForErrors();
|
||||
UpdateStatus();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool MPD::Connection::DeletePlaylist(const std::string &name)
|
||||
@@ -1339,13 +1321,7 @@ int MPD::Connection::CheckForErrors()
|
||||
{
|
||||
itsErrorMessage = mpd_connection_get_error_message(itsConnection);
|
||||
if (error_code == MPD_ERROR_SERVER)
|
||||
{
|
||||
// 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) << 8);
|
||||
if ((error_code >> 8) == MPD_SERVER_ERROR_PLAYLIST_MAX && itsMaxPlaylistLength == size_t(-1))
|
||||
itsMaxPlaylistLength = 0;
|
||||
}
|
||||
if (!mpd_connection_clear_error(itsConnection))
|
||||
{
|
||||
Disconnect();
|
||||
|
||||
@@ -151,7 +151,6 @@ namespace MPD
|
||||
unsigned long PlayTime() const { return itsStats ? mpd_stats_get_play_time(itsStats) : 0; }
|
||||
unsigned long DBPlayTime() const { return itsStats ? mpd_stats_get_db_play_time(itsStats) : 0; }
|
||||
|
||||
size_t GetMaxPlaylistLength() const { return itsMaxPlaylistLength; }
|
||||
size_t GetPlaylistLength() const { return itsCurrentStatus ? mpd_status_get_queue_length(itsCurrentStatus) : 0; }
|
||||
void GetPlaylistChanges(unsigned, SongList &);
|
||||
|
||||
@@ -227,7 +226,6 @@ namespace MPD
|
||||
bool isCommandsListEnabled;
|
||||
|
||||
std::string itsErrorMessage;
|
||||
size_t itsMaxPlaylistLength;
|
||||
|
||||
int itsFD;
|
||||
bool isIdle;
|
||||
|
||||
@@ -290,7 +290,7 @@ bool Playlist::isFiltered()
|
||||
{
|
||||
if (Items->isFiltered())
|
||||
{
|
||||
ShowMessage("Function disabled due to enabled filtering in playlist");
|
||||
ShowMessage("Function currently unavailable due to filtered playlist");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -599,19 +599,12 @@ bool Playlist::Add(const MPD::SongList &l, bool play, int position)
|
||||
if (Mpd.AddSong(**j, position) < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!Mpd.CommitCommandsList())
|
||||
return false;
|
||||
|
||||
if (play && old_playlist_size < Items->Size())
|
||||
Mpd.Play(old_playlist_size);
|
||||
|
||||
if (position < 0 && Items->Back().GetHash() != l.back()->GetHash())
|
||||
{
|
||||
if (it != l.begin())
|
||||
ShowMessage("%s", MPD::Message::PartOfSongsAdded);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user