Skip to content

Commit

Permalink
Fixed moving channels between number groups in SVDRP's MOVC command a…
Browse files Browse the repository at this point in the history
…nd the Channels menu, in case a channel is moved to a higher number and into a numbered group
  • Loading branch information
Klaus Schmidinger committed Apr 11, 2020
1 parent f63a066 commit 6e0f528
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -2918,6 2918,7 @@ Manuel Reimer <[email protected]>
order to avoid discontinuities
for setting the environment variables HOME, USER, LOGNAME and SHELL accordingly
when switching to a less privileged user id
for reporting a bug in moving channels between number groups in SVDRP's MOVC command

Rene van den Braken <[email protected]>
for reporting a bug in writing the PCR pid into the PMT in
Expand Down
6 changes: 6 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -9419,3 9419,9 @@ Video Disk Recorder Revision History
the call is now automatically forwarded to QueueMessage().
- Fixed handling the S2SatelliteDeliverySystemDescriptor for transponders broadcasting
in "backwards compatibility mode" according to ETSI EN 300 468 (thanks to Onur Sent�rk).

2020-04-11:

- Fixed moving channels between number groups in SVDRP's MOVC command and the Channels
menu, in case a channel is moved to a higher number and into a numbered group
(reported by Manuel Reimer).
21 changes: 20 additions & 1 deletion channels.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: channels.c 4.5 2017/06/10 15:08:56 kls Exp $
* $Id: channels.c 4.6 2020/04/11 09:22:05 kls Exp $
*/

#include "channels.h"
Expand Down Expand Up @@ -946,6 946,25 @@ void cChannels::ReNumber(void)
}
}

bool cChannels::MoveNeedsDecrement(cChannel *From, cChannel *To)
{
int Number = From->Number();
if (Number < To->Number()) {
for (cChannel *Channel = Next(From); Channel; Channel = Next(Channel)) {
if (Channel == To)
break;
if (Channel->GroupSep()) {
if (Channel->Number() > Number)
Number = Channel->Number();
}
else
Number ;
}
return Number == To->Number();
}
return false;
}

void cChannels::Del(cChannel *Channel)
{
UnhashChannel(Channel);
Expand Down
3 changes: 2 additions & 1 deletion channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: channels.h 4.3 2017/06/10 15:06:40 kls Exp $
* $Id: channels.h 4.4 2020/04/11 09:22:05 kls Exp $
*/

#ifndef __CHANNELS_H
Expand Down Expand Up @@ -230,6 230,7 @@ class cChannels : public cConfig<cChannel> {
int GetNextNormal(int Idx) const; ///< Get next normal channel (not group)
int GetPrevNormal(int Idx) const; ///< Get previous normal channel (not group)
void ReNumber(void); ///< Recalculate 'number' based on channel type
bool MoveNeedsDecrement(cChannel *From, cChannel *To); // Detect special case when moving a channel (closely related to Renumber())
void Del(cChannel *Channel); ///< Delete the given Channel from the list
const cChannel *GetByNumber(int Number, int SkipGap = 0) const;
cChannel *GetByNumber(int Number, int SkipGap = 0) { return const_cast<cChannel *>(static_cast<const cChannels *>(this)->GetByNumber(Number, SkipGap)); }
Expand Down
9 changes: 6 additions & 3 deletions menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: menu.c 4.80 2019/05/28 15:24:43 kls Exp $
* $Id: menu.c 4.81 2020/04/11 09:22:05 kls Exp $
*/

#include "menu.h"
Expand Down Expand Up @@ -516,7 516,6 @@ eOSState cMenuChannels::Delete(void)
Channels->Del(Channel);
cOsdMenu::Del(Index);
Propagate(Channels);
Channels->SetModifiedByUser();
isyslog("channel %d deleted", DeletedChannel);
Deleted = true;
if (CurrentChannel && CurrentChannel->Number() != CurrentChannelNr) {
Expand All @@ -541,10 540,14 @@ void cMenuChannels::Move(int From, int To)
if (FromChannel && ToChannel) {
int FromNumber = FromChannel->Number();
int ToNumber = ToChannel->Number();
if (Channels->MoveNeedsDecrement(FromChannel, ToChannel)) {
ToChannel = Channels->Prev(ToChannel); // cListBase::Move() doesn't know about the channel list's numbered groups!
To--;
}
Channels->Move(FromChannel, ToChannel);
cOsdMenu::Move(From, To);
SetCurrent(Get(To));
Propagate(Channels);
Channels->SetModifiedByUser();
isyslog("channel %d moved to %d", FromNumber, ToNumber);
if (CurrentChannel && CurrentChannel->Number() != CurrentChannelNr) {
if (!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring())
Expand Down
4 changes: 3 additions & 1 deletion svdrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 10,7 @@
* and interact with the Video Disk Recorder - or write a full featured
* graphical interface that sits on top of an SVDRP connection.
*
* $Id: svdrp.c 4.39 2019/05/06 15:11:15 kls Exp $
* $Id: svdrp.c 4.40 2020/04/11 09:22:05 kls Exp $
*/

#include "svdrp.h"
Expand Down Expand Up @@ -2087,6 2087,8 @@ void cSVDRPServer::CmdMOVC(const char *Option)
int FromNumber = FromChannel->Number();
int ToNumber = ToChannel->Number();
if (FromNumber != ToNumber) {
if (Channels->MoveNeedsDecrement(FromChannel, ToChannel))
ToChannel = Channels->Prev(ToChannel); // cListBase::Move() doesn't know about the channel list's numbered groups!
Channels->Move(FromChannel, ToChannel);
Channels->ReNumber();
Channels->SetModifiedByUser();
Expand Down

0 comments on commit 6e0f528

Please sign in to comment.