diff options
-rw-r--r-- | doc/keys | 2 | ||||
-rw-r--r-- | src/help.cpp | 1 | ||||
-rw-r--r-- | src/libmpdclient.c | 12 | ||||
-rw-r--r-- | src/libmpdclient.h | 4 | ||||
-rw-r--r-- | src/mpdpp.cpp | 14 | ||||
-rw-r--r-- | src/mpdpp.h | 5 | ||||
-rw-r--r-- | src/ncmpcpp.cpp | 5 | ||||
-rw-r--r-- | src/settings.cpp | 4 | ||||
-rw-r--r-- | src/settings.h | 1 | ||||
-rw-r--r-- | src/status.cpp | 8 |
10 files changed, 54 insertions, 2 deletions
@@ -74,6 +74,8 @@ # #key_toggle_single = 'y' # +#key_toggle_consume = 'R' +# #key_shuffle = 'Z' # #key_toggle_crossfade = 'x' diff --git a/src/help.cpp b/src/help.cpp index 2bdea736..80089277 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -163,6 +163,7 @@ void Help::GetKeybindings() *w << DisplayKeys(Key.ToggleRepeat) << "Toggle repeat mode\n"; *w << DisplayKeys(Key.ToggleRandom) << "Toggle random mode\n"; *w << DisplayKeys(Key.ToggleSingle) << "Toggle single mode\n"; + *w << DisplayKeys(Key.ToggleConsume) << "Toggle consume mode\n"; *w << DisplayKeys(Key.Shuffle) << "Shuffle playlist\n"; *w << DisplayKeys(Key.ToggleCrossfade) << "Toggle crossfade mode\n"; *w << DisplayKeys(Key.SetCrossfade) << "Set crossfade\n"; diff --git a/src/libmpdclient.c b/src/libmpdclient.c index a0593599..b8b6998f 100644 --- a/src/libmpdclient.c +++ b/src/libmpdclient.c @@ -740,6 +740,7 @@ mpd_Status * mpd_getStatus(mpd_Connection * connection) { status->repeat = 0; status->random = 0; status->single = 0; + status->consume = 0; status->playlist = -1; status->playlistLength = -1; status->state = -1; @@ -773,6 +774,9 @@ mpd_Status * mpd_getStatus(mpd_Connection * connection) { else if(strcmp(re->name,"single")==0) { status->single = atoi(re->value); } + else if(strcmp(re->name,"consume")==0) { + status->consume = atoi(re->value); + } else if(strcmp(re->name,"playlist")==0) { status->playlist = strtol(re->value,NULL,10); } @@ -1704,6 +1708,14 @@ void mpd_sendSingleCommand(mpd_Connection * connection, int singleMode) { free(string); } +void mpd_sendConsumeCommand(mpd_Connection * connection, int consumeMode) { + int len = strlen("consume")+2+INTLEN+3; + char *string = malloc(len); + snprintf(string, len, "consume \"%i\"\n", consumeMode); + mpd_executeCommand(connection,string); + free(string); +} + void mpd_sendSetvolCommand(mpd_Connection * connection, int volumeChange) { int len = strlen("setvol")+2+INTLEN+3; char *string = malloc(len); diff --git a/src/libmpdclient.h b/src/libmpdclient.h index d1266d14..9e805c3d 100644 --- a/src/libmpdclient.h +++ b/src/libmpdclient.h @@ -175,6 +175,8 @@ typedef struct mpd_Status { int random; /* 1 if single mode is on, 0 otherwise */ int single; + /* 1 if consume mode is on, 0 otherwise */ + int consume; /* playlist length */ int playlistLength; /* playlist, use this to determine when the playlist has changed */ @@ -524,6 +526,8 @@ void mpd_sendRandomCommand(mpd_Connection * connection, int randomMode); void mpd_sendSingleCommand(mpd_Connection * connection, int singleMode); +void mpd_sendConsumeCommand(mpd_Connection * connection, int consumeMode); + void mpd_sendSetvolCommand(mpd_Connection * connection, int volumeChange); /* WARNING: don't use volume command, its depreacted */ diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp index f82a4ac1..6a679e02 100644 --- a/src/mpdpp.cpp +++ b/src/mpdpp.cpp @@ -165,6 +165,7 @@ void Connection::UpdateStatus() itsChanges.Random = 1; itsChanges.Repeat = 1; itsChanges.Single = 1; + itsChanges.Consume = 1; itsChanges.PlayerState = 1; itsChanges.StatusFlags = 1; } @@ -180,8 +181,9 @@ void Connection::UpdateStatus() itsChanges.Random = itsOldStatus->random != itsCurrentStatus->random; itsChanges.Repeat = itsOldStatus->repeat != itsCurrentStatus->repeat; itsChanges.Single = itsOldStatus->single != itsCurrentStatus->single; + itsChanges.Consume = itsOldStatus->consume != itsCurrentStatus->consume; itsChanges.PlayerState = itsOldStatus->state != itsCurrentStatus->state; - itsChanges.StatusFlags = itsChanges.Repeat || itsChanges.Random || itsChanges.Single || itsChanges.Crossfade || itsChanges.DBUpdating; + itsChanges.StatusFlags = itsChanges.Repeat || itsChanges.Random || itsChanges.Single || itsChanges.Consume || itsChanges.Crossfade || itsChanges.DBUpdating; } itsUpdater(this, itsChanges, itsErrorHandlerUserdata); } @@ -495,6 +497,16 @@ void Connection::SetSingle(bool mode) const } } +void Connection::SetConsume(bool mode) const +{ + if (isConnected) + { + mpd_sendConsumeCommand(itsConnection, mode); + if (!isCommandsListEnabled) + mpd_finishCommand(itsConnection); + } +} + void Connection::SetVolume(int vol) { if (isConnected) diff --git a/src/mpdpp.h b/src/mpdpp.h index 8710de71..d31b0e00 100644 --- a/src/mpdpp.h +++ b/src/mpdpp.h @@ -48,7 +48,7 @@ namespace MPD struct StatusChanges { - StatusChanges() : Playlist(0), SongID(0), Database(0), DBUpdating(0), Volume(0), ElapsedTime(0), Crossfade(0), Random(0), Repeat(0), Single(0), PlayerState(0), StatusFlags(0) { } + StatusChanges() : Playlist(0), SongID(0), Database(0), DBUpdating(0), Volume(0), ElapsedTime(0), Crossfade(0), Random(0), Repeat(0), Single(0), Consume(0), PlayerState(0), StatusFlags(0) { } bool Playlist:1; bool SongID:1; bool Database:1; @@ -59,6 +59,7 @@ namespace MPD bool Random:1; bool Repeat:1; bool Single:1; + bool Consume:1; bool PlayerState:1; bool StatusFlags:1; }; @@ -118,6 +119,7 @@ namespace MPD bool GetRepeat() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->repeat : 0; } bool GetRandom() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->random : 0; } bool GetSingle() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->single : 0; } + bool GetConsume() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->consume : 0; } bool GetDBIsUpdating() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->updatingDb : 0; } int GetVolume() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->volume : -1; } int GetCrossfade() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->crossfade : -1; } @@ -140,6 +142,7 @@ namespace MPD void SetRepeat(bool) const; void SetRandom(bool) const; void SetSingle(bool) const; + void SetConsume(bool) const; void SetCrossfade(int) const; void SetVolume(int); diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 93e55058..9941ba42 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1109,6 +1109,11 @@ int main(int argc, char *argv[]) Mpd->UpdateStatus(); } } + else if (Keypressed(input, Key.ToggleConsume)) + { + Mpd->SetConsume(!Mpd->GetConsume()); + Mpd->UpdateStatus(); + } else if (Keypressed(input, Key.ToggleCrossfade)) { Mpd->SetCrossfade(Mpd->GetCrossfade() ? 0 : Config.crossfade_time); diff --git a/src/settings.cpp b/src/settings.cpp index 62a8e377..c0b20809 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -119,6 +119,7 @@ void DefaultKeys(ncmpcpp_keys &keys) keys.ToggleRepeat[0] = 'r'; keys.ToggleRandom[0] = 'z'; keys.ToggleSingle[0] = 'y'; + keys.ToggleConsume[0] = 'R'; keys.ToggleSpaceMode[0] = 't'; keys.ToggleAddMode[0] = 'T'; keys.Shuffle[0] = 'Z'; @@ -185,6 +186,7 @@ void DefaultKeys(ncmpcpp_keys &keys) keys.ToggleRepeat[1] = null_key; keys.ToggleRandom[1] = null_key; keys.ToggleSingle[1] = null_key; + keys.ToggleConsume[1] = null_key; keys.ToggleSpaceMode[1] = null_key; keys.ToggleAddMode[1] = null_key; keys.Shuffle[1] = null_key; @@ -357,6 +359,8 @@ void ReadKeys(ncmpcpp_keys &keys) GetKeys(key, keys.ToggleRandom); else if (key.find("key_toggle_single ") != string::npos) GetKeys(key, keys.ToggleSingle); + else if (key.find("key_toggle_consume ") != string::npos) + GetKeys(key, keys.ToggleConsume); else if (key.find("key_toggle_space_mode ") != string::npos) GetKeys(key, keys.ToggleSpaceMode); else if (key.find("key_toggle_add_mode ") != string::npos) diff --git a/src/settings.h b/src/settings.h index 413d81b1..5bbce102 100644 --- a/src/settings.h +++ b/src/settings.h @@ -66,6 +66,7 @@ struct ncmpcpp_keys int ToggleRepeat[2]; int ToggleRandom[2]; int ToggleSingle[2]; + int ToggleConsume[2]; int ToggleSpaceMode[2]; int ToggleAddMode[2]; int Shuffle[2]; diff --git a/src/status.cpp b/src/status.cpp index b5de8fa1..175a9fa9 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -416,6 +416,7 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) static char mpd_repeat; static char mpd_random; static char mpd_single; + static char mpd_consume; static char mpd_crossfade; static char mpd_db_updating; @@ -434,6 +435,11 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) mpd_single = Mpd->GetSingle() ? 's' : 0; ShowMessage("Single mode is %s", !mpd_single ? "off" : "on"); } + if (changed.Consume) + { + mpd_consume = Mpd->GetConsume() ? 'c' : 0; + ShowMessage("Consume mode is %s", !mpd_consume ? "off" : "on"); + } if (changed.Crossfade) { int crossfade = Mpd->GetCrossfade(); @@ -456,6 +462,8 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) switch_state += mpd_random; if (mpd_single) switch_state += mpd_single; + if (mpd_consume) + switch_state += mpd_consume; if (mpd_crossfade) switch_state += mpd_crossfade; if (mpd_db_updating) |