From a6a7eadb0fac51895c3be9c2eab22040e83393c5 Mon Sep 17 00:00:00 2001 From: hbeham Date: Thu, 27 Jun 2013 20:21:56 +0200 Subject: [PATCH] - fixed channel lists for panasonic - LG file cleanup now also cleans up empty sat blocks --- ChanSort.Loader.LG/TllFileSerializer.cs | 18 +++++++++++----- ChanSort.Loader.Panasonic/DbChannel.cs | 7 ++----- ChanSort.Loader.Panasonic/Serializer.cs | 28 ++++++++++++++----------- ChanSort/MainForm.cs | 2 +- readme.txt | 7 +++++-- 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/ChanSort.Loader.LG/TllFileSerializer.cs b/ChanSort.Loader.LG/TllFileSerializer.cs index a91dc4f..f07adac 100644 --- a/ChanSort.Loader.LG/TllFileSerializer.cs +++ b/ChanSort.Loader.LG/TllFileSerializer.cs @@ -621,15 +621,23 @@ namespace ChanSort.Loader.LG } // copy temp data back to fileContent and clear remainder - if (originalChannelCount != 0) // even if there's 0 channels, channel[0] must contain valid data + if (originalChannelCount == 0) + { + // even if there's 0 channels, channel[0] must contain valid data + Tools.MemSet(this.fileContent, + this.dvbsBlockOffset + satConfig.ChannelListOffset + 1 * satConfig.dvbsChannelLength, + 0xFF, + (satConfig.dvbsMaxChannelCount - 1) * satConfig.dvbsChannelLength); + } + else { Tools.MemCopy(sortedChannels, 0, - this.fileContent, this.dvbsBlockOffset + satConfig.ChannelListOffset, - channelCounter*satConfig.dvbsChannelLength); + this.fileContent, this.dvbsBlockOffset + satConfig.ChannelListOffset, + channelCounter * satConfig.dvbsChannelLength); Tools.MemSet(this.fileContent, - this.dvbsBlockOffset + satConfig.ChannelListOffset + channelCounter*satConfig.dvbsChannelLength, + this.dvbsBlockOffset + satConfig.ChannelListOffset + channelCounter * satConfig.dvbsChannelLength, 0xFF, - (satConfig.dvbsMaxChannelCount - channelCounter)*satConfig.dvbsChannelLength); + (satConfig.dvbsMaxChannelCount - channelCounter) * satConfig.dvbsChannelLength); } UpdateChannelAllocationBitmap(channelCounter); UpdateChannelLinkedList(channelCounter); diff --git a/ChanSort.Loader.Panasonic/DbChannel.cs b/ChanSort.Loader.Panasonic/DbChannel.cs index 9e09310..bc918c1 100644 --- a/ChanSort.Loader.Panasonic/DbChannel.cs +++ b/ChanSort.Loader.Panasonic/DbChannel.cs @@ -14,6 +14,7 @@ namespace ChanSort.Loader.Panasonic { this.RecordIndex = r.GetInt32(field["rowid"]); this.RecordOrder = r.GetInt32(field["major_channel"]); + this.OldProgramNr = r.GetInt32(field["major_channel"]); int ntype = r.GetInt32(field["ntype"]); if (ntype == 1) this.SignalSource |= SignalSource.DvbS; @@ -22,7 +23,7 @@ namespace ChanSort.Loader.Panasonic else if (ntype == 3) this.SignalSource |= SignalSource.DvbC; else if (ntype == 10) - this.SignalSource |= SignalSource.AnalogC | SignalSource.Tv; + this.SignalSource |= SignalSource.AnalogCT|SignalSource.Tv; byte[] buffer = new byte[1000]; var len = r.GetBytes(field["delivery"], 0, buffer, 0, 1000); @@ -37,10 +38,6 @@ namespace ChanSort.Loader.Panasonic this.ReadAnalogData(r, field); else this.ReadDvbData(r, field, dataRoot, buffer); - - var list = dataRoot.GetChannelList(this.SignalSource); - if (list != null) - this.OldProgramNr = ntype == 10 ? list.Count : list.Count + 1; } #endregion diff --git a/ChanSort.Loader.Panasonic/Serializer.cs b/ChanSort.Loader.Panasonic/Serializer.cs index 00a2032..db02d2f 100644 --- a/ChanSort.Loader.Panasonic/Serializer.cs +++ b/ChanSort.Loader.Panasonic/Serializer.cs @@ -12,9 +12,10 @@ namespace ChanSort.Loader.Panasonic { private static readonly string ERR_FileFormatOrEncryption = "File uses an unknown format or encryption"; private static readonly int[] headerCypherTable; - private readonly ChannelList atvChannels = new ChannelList(SignalSource.AnalogCT | SignalSource.Tv, "Analog TV"); - private readonly ChannelList dtvTvChannels = new ChannelList(SignalSource.DvbCT | SignalSource.DvbS | SignalSource.Tv, "Digital TV"); - private readonly ChannelList dtvRadioChannels = new ChannelList(SignalSource.DvbCT | SignalSource.DvbS | SignalSource.Radio, "Radio"); + private readonly ChannelList atvChannels = new ChannelList(SignalSource.AnalogCT | SignalSource.Tv | SignalSource.Radio, "Analog"); + private readonly ChannelList dvbtChannels = new ChannelList(SignalSource.DvbT | SignalSource.Tv | SignalSource.Radio, "DVB-T"); + private readonly ChannelList dvbcChannels = new ChannelList(SignalSource.DvbC | SignalSource.Tv | SignalSource.Radio, "DVB-C"); + private readonly ChannelList dvbsChannels = new ChannelList(SignalSource.DvbS | SignalSource.Tv | SignalSource.Radio, "DVB-S"); private string workFile; private CypherMode cypherMode; @@ -299,8 +300,9 @@ namespace ChanSort.Loader.Panasonic public Serializer(string inputFile) : base(inputFile) { this.DataRoot.AddChannelList(this.atvChannels); - this.DataRoot.AddChannelList(this.dtvTvChannels); - this.DataRoot.AddChannelList(this.dtvRadioChannels); + this.DataRoot.AddChannelList(this.dvbtChannels); + this.DataRoot.AddChannelList(this.dvbcChannels); + this.DataRoot.AddChannelList(this.dvbsChannels); } #endregion @@ -499,10 +501,10 @@ order by s.ntype,major_channel { using (var trans = conn.BeginTransaction()) { - int[] channelIndex = new int[5]; - this.WriteChannels(cmd, this.atvChannels, channelIndex); - this.WriteChannels(cmd, this.dtvTvChannels, channelIndex); - this.WriteChannels(cmd, this.dtvRadioChannels, channelIndex); + this.WriteChannels(cmd, this.atvChannels); + this.WriteChannels(cmd, this.dvbtChannels); + this.WriteChannels(cmd, this.dvbcChannels); + this.WriteChannels(cmd, this.dvbsChannels); trans.Commit(); } } @@ -513,8 +515,10 @@ order by s.ntype,major_channel #endregion #region WriteChannels() - private void WriteChannels(SQLiteCommand cmd, ChannelList channelList, int[] channelIndex) + private void WriteChannels(SQLiteCommand cmd, ChannelList channelList) { + int[] favIndex = new int[4]; + cmd.CommandText = "update SVL set major_channel=@progNr, sname=@name, profile1index=@fav1, profile2index=@fav2, profile3index=@fav3, profile4index=@fav4, child_lock=@lock, skip=@skip where rowid=@rowid"; cmd.Parameters.Clear(); cmd.Parameters.Add(new SQLiteParameter("@rowid", DbType.Int32)); @@ -533,9 +537,9 @@ order by s.ntype,major_channel continue; channel.UpdateRawData(); cmd.Parameters["@rowid"].Value = channel.RecordIndex; - cmd.Parameters["@progNr"].Value = ++channelIndex[0]; // channel.NewProgramNr; + cmd.Parameters["@progNr"].Value = channel.NewProgramNr; for (int fav = 0; fav < 4; fav++) - cmd.Parameters["@fav" + (fav + 1)].Value = ((int) channel.Favorites & (1<