diff --git a/setup.c b/setup.c index acca6c5..70b26b6 100644 --- a/setup.c +++ b/setup.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: setup.c,v 1.14 2007/09/29 18:15:31 rahrenbe Exp $ + * $Id: setup.c,v 1.15 2007/09/30 17:34:13 ajhseppa Exp $ */ #include @@ -204,7 +204,50 @@ eOSState cIptvMenuEditChannel::ProcessKey(eKeys Key) if (Key == kOk) { cChannel newchannel; SetChannelData(&newchannel); - if (Channels.HasUniqueChannelID(&newchannel, channel)) { + + bool uniquityFailed = false; + + // Search for identical channels as these will be ignored by vdr + for (cChannel *iteratorChannel = Channels.First(); iteratorChannel; + iteratorChannel = Channels.Next(iteratorChannel)) { + + // This is one of the channels cause the uniquity check to fail + if (!iteratorChannel->GroupSep() && iteratorChannel != channel + && iteratorChannel->GetChannelID() == newchannel.GetChannelID()) { + + // See if it has unique Plugin param. If yes then increment + // the corresponding Rid until it is unique + if (strcmp(iteratorChannel->PluginParam(), + newchannel.PluginParam())) { + + // If the channel RID is already at maximum, then fail the + // channel modification + if (iteratorChannel->Rid() >= 8192) { + debug("Cannot increment RID over maximum value\n"); + uniquityFailed = true; + break; + } + + debug("Incrementing conflicting channel RID\n"); + iteratorChannel->SetId(iteratorChannel->Nid(), + iteratorChannel->Tid(), + iteratorChannel->Sid(), + iteratorChannel->Rid() + 1); + + // Re-set the search and start again + iteratorChannel = Channels.First(); + continue; + + // Cannot work around by incrementing rid because channels + // are actually copies of each other + } else { + uniquityFailed = true; + break; + } + } + } + + if (!uniquityFailed) { if (channel) { SetChannelData(channel); isyslog("edited channel %d %s", channel->Number(), *channel->ToText()); @@ -219,9 +262,9 @@ eOSState cIptvMenuEditChannel::ProcessKey(eKeys Key) state = osUser1; } Channels.SetModified(true); - } + } else { - Skins.Message(mtError, trVDR("Channel settings are not unique!")); + Skins.Message(mtError, trVDR("Cannot find unique channel settings!")); state = osContinue; } }