From 01f29b04e3ea9ab8f7aacba0c8777fd84ba3edb1 Mon Sep 17 00:00:00 2001 From: Horst Beham Date: Tue, 3 Jan 2023 09:43:02 +0100 Subject: [PATCH] - unlocking read-only/predefined lists in the UI removes the ChannelList.ReadOnly flag and allows saving - added dummy-loader to handle known unsupported formats --- .../ChanSort.Loader.Unsupported.csproj | 54 ++++++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++++++ .../UnsupportedPlugin.cs | 72 +++++++++++++++++++ source/ChanSort.sln | 32 +++++++++ source/ChanSort/ChanSort.csproj | 4 ++ source/ChanSort/MainForm.cs | 13 +++- source/changelog.md | 4 ++ 7 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 source/ChanSort.Loader.Unsupported/ChanSort.Loader.Unsupported.csproj create mode 100644 source/ChanSort.Loader.Unsupported/Properties/AssemblyInfo.cs create mode 100644 source/ChanSort.Loader.Unsupported/UnsupportedPlugin.cs diff --git a/source/ChanSort.Loader.Unsupported/ChanSort.Loader.Unsupported.csproj b/source/ChanSort.Loader.Unsupported/ChanSort.Loader.Unsupported.csproj new file mode 100644 index 0000000..d04fbb4 --- /dev/null +++ b/source/ChanSort.Loader.Unsupported/ChanSort.Loader.Unsupported.csproj @@ -0,0 +1,54 @@ + + + + + Debug + AnyCPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5} + Library + Properties + ChanSort.Loader.Unsupported + ChanSort.Loader.Unsupported + v4.8 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + {dccffa08-472b-4d17-bb90-8f513fc01392} + ChanSort.Api + + + + \ No newline at end of file diff --git a/source/ChanSort.Loader.Unsupported/Properties/AssemblyInfo.cs b/source/ChanSort.Loader.Unsupported/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7416181 --- /dev/null +++ b/source/ChanSort.Loader.Unsupported/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ChanSort.Loader.Unsupported")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ChanSort.Loader.Unsupported")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d7c32dae-5d77-46a0-bc16-c95d9c7efdd5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/source/ChanSort.Loader.Unsupported/UnsupportedPlugin.cs b/source/ChanSort.Loader.Unsupported/UnsupportedPlugin.cs new file mode 100644 index 0000000..5283003 --- /dev/null +++ b/source/ChanSort.Loader.Unsupported/UnsupportedPlugin.cs @@ -0,0 +1,72 @@ +using System.IO; +using System.Linq; +using ChanSort.Api; + +namespace ChanSort.Loader.Unsupported +{ + // This Loader handles known unsupported file formats and informs users about the fact and that there is probably no need to ask for adding support + + public class UnsupportedPlugin : ISerializerPlugin + { + public string DllName { get; set; } + public string PluginName => "Unsupported"; + public string FileFilter => "*"; + + private string dir; + private string name; + private string ext; + + public SerializerBase CreateSerializer(string inputFile) + { + dir = Path.GetDirectoryName(inputFile); + name = Path.GetFileName(inputFile).ToLowerInvariant(); + ext = Path.GetExtension(name); + + CheckForMediaTekAndroidBin(); + CheckForVestelEncryptedDb(); + + throw LoaderException.TryNext("File is not on the list of explicitly unsupported formats"); + } + + #region CheckForMediaTekAndroidBin() + /// + /// Many different TV brands seem to use the same underlying hardware/firmware platform for their Android models. + /// It is unclear how much the brands can customize the exported TV list, but many seem to use the default. + /// In that configuration there is a .bin file, a .bin.crc, a .xml file and often a _sub.bin file on the USB stick. + /// The .bin is a compressed archive with undocumented compression algorithm and file format. + /// The .bin.crc does not use any of the standard CRC32 configurations. + /// The .xml is contains only rudimentary and crippled data, that makes it useless. + /// + /// Known manufacturers using such lists: Grundig, Nokia, Panasonic, Philips, Sharp, Xiaomi + /// + private void CheckForMediaTekAndroidBin() + { + if (ext == ".bin" || ext == ".xml" || ext == ".crc") + { + var fname = Path.GetFileNameWithoutExtension(name); + if (fname.EndsWith("_sub")) + fname = fname.Substring(0, fname.Length - 4); + var checkExt = new[] { ".bin", ".bin.crc", ".xml" }; + var hasAll = checkExt.All(ce => File.Exists(Path.Combine(dir, fname + ce))); + if (hasAll) + throw LoaderException.Fail( + @"Encrypted MediaTek Android channel lists (used by many TV brands) can't be read/modified with ChanSort."); + } + } + #endregion + + #region CheckForVestelEncryptedDb + /// + /// At some point Vestel firmware started to export encrypted settingsDB_enc.db instead of settingsDB.db. + /// This seems to have affected many brands using the Vestel platform without their knowledge, including + /// Panasonic, Nabo, Toshiba + /// + private void CheckForVestelEncryptedDb() + { + if (name.EndsWith("_enc") && ext == ".db") + throw LoaderException.Fail(@"Encrypted Vestel channel lists (used by many TV brands) can't be read/modified with ChanSort."); + } + #endregion + + } +} diff --git a/source/ChanSort.sln b/source/ChanSort.sln index d35a418..e7bfe65 100644 --- a/source/ChanSort.sln +++ b/source/ChanSort.sln @@ -98,6 +98,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.Loewe", "Ch EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.Loader.CmdbBin", "Test.Loader.CmdbBin\Test.Loader.CmdbBin.csproj", "{3B7C25DF-645B-4ACF-8528-27EF40FAF91F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChanSort.Loader.Unsupported", "ChanSort.Loader.Unsupported\ChanSort.Loader.Unsupported.csproj", "{D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All_Debug|Any CPU = All_Debug|Any CPU @@ -1195,6 +1197,36 @@ Global {3B7C25DF-645B-4ACF-8528-27EF40FAF91F}.Release|Mixed Platforms.Build.0 = Release|Any CPU {3B7C25DF-645B-4ACF-8528-27EF40FAF91F}.Release|x86.ActiveCfg = Release|Any CPU {3B7C25DF-645B-4ACF-8528-27EF40FAF91F}.Release|x86.Build.0 = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Debug|Any CPU.Build.0 = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Debug|x86.ActiveCfg = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Debug|x86.Build.0 = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Release|Any CPU.ActiveCfg = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Release|Any CPU.Build.0 = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Release|Mixed Platforms.Build.0 = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Release|x86.ActiveCfg = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.All_Release|x86.Build.0 = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Debug|x86.ActiveCfg = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Debug|x86.Build.0 = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.NoDevExpress_Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.NoDevExpress_Debug|Any CPU.Build.0 = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.NoDevExpress_Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.NoDevExpress_Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.NoDevExpress_Debug|x86.ActiveCfg = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.NoDevExpress_Debug|x86.Build.0 = Debug|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Release|Any CPU.Build.0 = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Release|x86.ActiveCfg = Release|Any CPU + {D7C32DAE-5D77-46A0-BC16-C95D9C7EFDD5}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/source/ChanSort/ChanSort.csproj b/source/ChanSort/ChanSort.csproj index 22fc654..c700bc7 100644 --- a/source/ChanSort/ChanSort.csproj +++ b/source/ChanSort/ChanSort.csproj @@ -594,6 +594,10 @@ {f6f02792-07f1-48d5-9af3-f945ca5e3931} ChanSort.Loader.Toshiba + + {d7c32dae-5d77-46a0-bc16-c95d9c7efdd5} + ChanSort.Loader.Unsupported + {74a18c6f-09ff-413e-90d9-827066fa5b36} ChanSort.Loader.VDR diff --git a/source/ChanSort/MainForm.cs b/source/ChanSort/MainForm.cs index e4753ee..fe7a79f 100644 --- a/source/ChanSort/MainForm.cs +++ b/source/ChanSort/MainForm.cs @@ -648,6 +648,7 @@ namespace ChanSort.Ui this.currentPlugin = plugin; this.currentTvSerializer = serializer; this.DataRoot = serializer.DataRoot; + this.ApplyReadOnlyOverride(); this.AddFileToMruList(serializer.FileName); this.UpdateMruMenu(); @@ -2210,7 +2211,16 @@ namespace ChanSort.Ui } #endregion - + #region ApplyReadOnlyOverride() + private void ApplyReadOnlyOverride() + { + if (this.miAllowEditPredefinedLists.Down) + { + foreach (var list in this.DataRoot.ChannelLists) + list.ReadOnly = false; + } + } + #endregion // UI events @@ -3078,6 +3088,7 @@ namespace ChanSort.Ui { TryExecute(() => { + this.ApplyReadOnlyOverride(); this.UpdateGridReadOnly(); this.UpdateMenu(); }); diff --git a/source/changelog.md b/source/changelog.md index 87be1d3..f26bf0b 100644 --- a/source/changelog.md +++ b/source/changelog.md @@ -1,6 +1,10 @@ ChanSort Change Log =================== +TBA +- fixed: menu "settings / allow editing predefined lists (DANGEROUS)" unlocked the edit functions + in the user interface, but changes to those lists were not saved to disk. + 2022-12-04 - fixed: various .xml file formats could not be loaded anymore - channels can also be swapped now be directly selecting two rows and clicking on "swap"