--- channels.c.newchannels 2007-07-21 16:55:01.000000000 +0200 +++ channels.c 2007-08-29 18:58:04.648179000 +0200 @@ -568,6 +568,11 @@ refChannel = RefChannel; } +void cChannel::SetGroupSep(bool Sep) +{ + groupSep = Sep; +} + static int PrintParameter(char *p, char Name, int Value) { return Value >= 0 && Value != 999 ? sprintf(p, "%c%d", Name, Value) : 0; @@ -1019,6 +1024,16 @@ return NULL; } +cChannel *cChannels::GetByName(char *Name) +{ + for (cChannel *channel = First(); channel; channel = Next(channel)) + { + if (strcmp(channel->Name(), Name)==0) + return channel; + } + return NULL; +} + bool cChannels::HasUniqueChannelID(cChannel *NewChannel, cChannel *OldChannel) { tChannelID NewChannelID = NewChannel->GetChannelID(); @@ -1055,7 +1070,33 @@ NewChannel->CopyTransponderData(Transponder); NewChannel->SetId(Nid, Tid, Sid, Rid); NewChannel->SetName(Name, ShortName, Provider); +#if 0 Add(NewChannel); +#else + /* find group separator for the source of this channel */ + { + char buffer[64]; + snprintf(buffer, sizeof(buffer), "New Channels @ %s", + *cSource::ToString(NewChannel->Source()) ); + cChannel *groupSep = GetByName(buffer); + if(!groupSep) // group separator for this source doesn't exist, so lets create it + { + groupSep = new cChannel(); + groupSep->SetName(buffer, "", ""); + groupSep->SetGroupSep(true); + Add(groupSep); + } else // find next separator or last channel + { + cChannel *nextChannel=Next(groupSep); + while (nextChannel && !nextChannel->GroupSep()) + { + groupSep=nextChannel; + nextChannel=Next(nextChannel); + } + } + Add(NewChannel, groupSep); + } +#endif ReNumber(); return NewChannel; } --- channels.h.newchannels 2007-07-21 16:58:36.000000000 +0200 +++ channels.h 2007-08-29 18:59:08.608179000 +0200 @@ -217,6 +217,7 @@ void SetCaDescriptors(int Level); void SetLinkChannels(cLinkChannels *LinkChannels); void SetRefChannel(cChannel *RefChannel); + void SetGroupSep(bool Sep = true); }; class cChannels : public cRwLock, public cConfig { @@ -240,6 +241,7 @@ cChannel *GetByServiceID(int Source, int Transponder, unsigned short ServiceID); cChannel *GetByChannelID(tChannelID ChannelID, bool TryWithoutRid = false, bool TryWithoutPolarization = false); cChannel *GetByTransponderID(tChannelID ChannelID); + cChannel *GetByName(char *Name); int BeingEdited(void) { return beingEdited; } void IncBeingEdited(void) { beingEdited++; } void DecBeingEdited(void) { beingEdited--; }