add MPD::Connection::Toggle() and throw away MPD::Connection::Execute()

This commit is contained in:
Andrzej Rybczak
2009-09-23 05:47:51 +02:00
parent d2f516d15c
commit 0d9f6fab7d
4 changed files with 14 additions and 28 deletions

View File

@@ -163,24 +163,12 @@ void ParseArgv(int argc, char **argv)
}
else if (!strcmp(argv[i], "pause"))
{
Mpd.Execute("pause \"1\"\n");
Mpd.Pause(1);
quit = 1;
}
else if (!strcmp(argv[i], "toggle"))
{
Mpd.UpdateStatus();
switch (Mpd.GetState())
{
case psPause:
case psPlay:
Mpd.Pause();
break;
case psStop:
Mpd.Play();
break;
default:
break;
}
Mpd.Toggle();
quit = 1;
}
else if (!strcmp(argv[i], "stop"))

View File

@@ -204,14 +204,6 @@ bool Connection::UpdateDirectory(const std::string &path)
return true;
}
bool Connection::Execute(const std::string &command) const
{
if (!isConnected)
return false;
mpd_send_command(itsConnection, command.c_str());
return isCommandsListEnabled || mpd_response_finish(itsConnection);
}
void Connection::Play() const
{
if (!isConnected)
@@ -233,7 +225,14 @@ void Connection::PlayID(int id) const
(isCommandsListEnabled ? mpd_send_play_id : mpd_run_play_id)(itsConnection, id);
}
void Connection::Pause() const
void Connection::Pause(bool state) const
{
if (!isConnected)
return;
(isCommandsListEnabled ? mpd_send_pause : mpd_run_pause)(itsConnection, state);
}
void Connection::Toggle() const
{
if (!isConnected)
return;

View File

@@ -103,12 +103,11 @@ namespace MPD
void UpdateStatus();
bool UpdateDirectory(const std::string &);
bool Execute(const std::string &) const;
void Play() const;
void Play(int) const;
void PlayID(int) const;
void Pause() const;
void Pause(bool) const;
void Toggle() const;
void Stop() const;
void Next() const;
void Prev() const;

View File

@@ -395,7 +395,7 @@ int main(int argc, char *argv[])
&& mouse_event.y == (Config.new_design ? 1 : LINES-1) && mouse_event.x < 9
) // playing/paused
{
Mpd.Pause();
Mpd.Toggle();
UpdateStatusImmediately = 1;
}
else if ((mouse_event.bstate & BUTTON2_PRESSED || mouse_event.bstate & BUTTON4_PRESSED)
@@ -722,7 +722,7 @@ int main(int argc, char *argv[])
}
else if (Keypressed(input, Key.Pause))
{
Mpd.Pause();
Mpd.Toggle();
UpdateStatusImmediately = 1;
}
else if (Keypressed(input, Key.SavePlaylist))