]> granicus.if.org Git - handbrake/commitdiff
WinGui: Use hb_presets_read_file_json to read the UI presets file. This allows us...
authorsr55 <sr55.hb@outlook.com>
Sat, 11 May 2019 19:39:00 +0000 (20:39 +0100)
committersr55 <sr55.hb@outlook.com>
Sat, 11 May 2019 19:39:00 +0000 (20:39 +0100)
13 files changed:
win/CS/HandBrake.Interop/HandBrake.Interop.csproj
win/CS/HandBrake.Interop/Interop/HandBrakePresetService.cs
win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs
win/CS/HandBrake.Interop/Interop/Json/Presets/PresetTransportContainer.cs
win/CS/HandBrake.Interop/Interop/Model/PresetVersion.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/Constants.cs
win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
win/CS/HandBrakeWPF/Properties/Resources.de.resx
win/CS/HandBrakeWPF/Properties/Resources.fr.resx
win/CS/HandBrakeWPF/Properties/Resources.resx
win/CS/HandBrakeWPF/Properties/Resources.zh.resx
win/CS/HandBrakeWPF/Services/Presets/Factories/JsonPresetFactory.cs
win/CS/HandBrakeWPF/Services/Presets/PresetService.cs

index a4aff67febb7c884a6e9c281f93519a60b1d42e0..733c81248e0bf070d34350d27a6e36879e433810 100644 (file)
     <Compile Include="Interop\Model\Encoding\Detelecine.cs" />
     <Compile Include="Interop\Model\Encoding\HBPresetTune.cs" />
     <Compile Include="Interop\Model\Encoding\Sharpen.cs" />
+    <Compile Include="Interop\Model\PresetVersion.cs" />
     <Compile Include="Interop\Model\Preview\RawPreviewData.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Interop\Json\Scan\SourceAudioTrack.cs" />
index a51a44fd1ee2cf29b3c9af113c34c68feb34d156..98eb6071b4a4a5e1cb648107f4dcaa3de592568b 100644 (file)
@@ -17,6 +17,7 @@ namespace HandBrake.Interop.Interop
     using HandBrake.Interop.Interop.HbLib;
     using HandBrake.Interop.Interop.Helpers;
     using HandBrake.Interop.Interop.Json.Presets;
+    using HandBrake.Interop.Interop.Model;
 
     using Newtonsoft.Json;
 
@@ -50,7 +51,7 @@ namespace HandBrake.Interop.Interop
         /// <returns>
         /// The <see cref="PresetCategory"/>.
         /// </returns>
-        public static PresetTransportContainer GetPresetFromFile(string filename)
+        public static PresetTransportContainer GetPresetsFromFile(string filename)
         {
             IntPtr presetStringPointer = HBFunctions.hb_presets_read_file_json(InteropUtilities.ToUtf8PtrFromString(filename));
             string presetJson = Marshal.PtrToStringAnsi(presetStringPointer);
@@ -88,5 +89,24 @@ namespace HandBrake.Interop.Interop
                 writer.Write(preset);
             }
         }
+
+        public static PresetVersion GetCurrentPresetVersion()
+        {
+            IntPtr major = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)));
+            IntPtr minor = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)));
+            IntPtr micro = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)));
+
+            HBFunctions.hb_presets_current_version(major, minor, micro);
+
+            int majorVersion = Marshal.ReadInt32(major);
+            int minorVersion = Marshal.ReadInt32(minor);
+            int microVersion = Marshal.ReadInt32(micro);
+
+            Marshal.FreeHGlobal(major);
+            Marshal.FreeHGlobal(minor);
+            Marshal.FreeHGlobal(micro);
+
+            return new PresetVersion(majorVersion, minorVersion, microVersion);
+        }
     }
 }
index 689ceb9379be3aba551b4b36d04ddbe09e183cc0..7fc1ed50084751537046f90fa64bc1fa80f41458 100644 (file)
@@ -469,5 +469,8 @@ namespace HandBrake.Interop.Interop.HbLib
         //     char       * hb_presets_read_file_json(const char *filename);
         [DllImport("hb", EntryPoint = "hb_presets_read_file_json", CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr hb_presets_read_file_json(IntPtr filename);
+
+        [DllImport("hb", EntryPoint = "hb_presets_current_version", CallingConvention = CallingConvention.Cdecl)]
+        public static extern IntPtr hb_presets_current_version(IntPtr major, IntPtr minor, IntPtr micro);
     }
 }
index 91ce48de5938597f9fff26574bd911404ca0f8b1..4d72e70ff231e5a23327a8842b500ae2b40581b1 100644 (file)
@@ -37,7 +37,7 @@ namespace HandBrake.Interop.Interop.Json.Presets
         /// <param name="versionMicro">
         /// The version micro.
         /// </param>
-        public PresetTransportContainer(string versionMajor, string versionMinor, string versionMicro)
+        public PresetTransportContainer(int versionMajor, int versionMinor, int versionMicro)
         {
             this.VersionMajor = versionMajor;
             this.VersionMicro = versionMicro;
@@ -52,16 +52,16 @@ namespace HandBrake.Interop.Interop.Json.Presets
         /// <summary>
         /// Gets or sets the version major.
         /// </summary>
-        public string VersionMajor { get; set; }
+        public int VersionMajor { get; set; }
 
         /// <summary>
         /// Gets or sets the version micro.
         /// </summary>
-        public string VersionMicro { get; set; }
+        public int VersionMicro { get; set; }
 
         /// <summary>
         /// Gets or sets the version minor.
         /// </summary>
-        public string VersionMinor { get; set; }
+        public int VersionMinor { get; set; }
     }
 }
diff --git a/win/CS/HandBrake.Interop/Interop/Model/PresetVersion.cs b/win/CS/HandBrake.Interop/Interop/Model/PresetVersion.cs
new file mode 100644 (file)
index 0000000..dbe5578
--- /dev/null
@@ -0,0 +1,25 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="PresetVersion.cs" company="HandBrake Project (http://handbrake.fr)">
+//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+//   Defines the PresetVersion type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrake.Interop.Interop.Model
+{
+    public class PresetVersion
+    {
+        public PresetVersion(int major, int minor, int micro)
+        {
+            this.Major = major;
+            this.Minor = minor;
+            this.Micro = micro;
+        }
+
+        public int Major { get; }
+        public int Minor { get; }
+        public int Micro { get; }
+    }
+}
index f4a65d7d2bd94160e854acc596de909be9a755ee..5ee22d03d8eebffaba5a3328cd43ff189d3ca116 100644 (file)
@@ -37,11 +37,6 @@ namespace HandBrakeWPF
         public const string SourcePath = "{source_path}";\r
         public const string SourceFolderName = "{source_folder_name}";\r
 \r
-        /* Preset Versions */\r
-        public const string PresetVersionMajor = "35";\r
-        public const string PresetVersionMinor = "0";\r
-        public const string PresetVersionMicro = "0";\r
-\r
         public const string FileScanMru = "FileScanMru";\r
         public const string FileSaveMru = "FileSaveMru";\r
     }\r
index a3583ef4ad8c8458aa1f8a1879c43eb85991755b..8c460eca0d7c1f34968c00d6a1e7d8ce15e5a9c0 100644 (file)
@@ -3737,17 +3737,6 @@ namespace HandBrakeWPF.Properties {
             }
         }
         
-        /// <summary>
-        ///   Looks up a localized string similar to HandBrake has detected your presets file is from an older version.
-        ///It will try and load the file anyway.
-        ///If it fails, it will archive off the old file and create a new one..
-        /// </summary>
-        public static string PresetService_PresetsOutOfDate {
-            get {
-                return ResourceManager.GetString("PresetService_PresetsOutOfDate", resourceCulture);
-            }
-        }
-        
         /// <summary>
         ///   Looks up a localized string similar to Unable to load presets..
         /// </summary>
index 5c330036f209109ecbe421e67693fc58c0064de7..e0d6029c869c792365b36dc73647e4ca589c1329 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <root>
   <!-- 
     Microsoft ResX Schema 
             : and then encoded with base64 encoding.
     -->
   <xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
-    <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
     <xsd:element name="root" msdata:IsDataSet="true">
       <xsd:complexType>
         <xsd:choice maxOccurs="unbounded">
           <xsd:element name="metadata">
             <xsd:complexType>
               <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0"/>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
               </xsd:sequence>
-              <xsd:attribute name="name" use="required" type="xsd:string"/>
-              <xsd:attribute name="type" type="xsd:string"/>
-              <xsd:attribute name="mimetype" type="xsd:string"/>
-              <xsd:attribute ref="xml:space"/>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="assembly">
             <xsd:complexType>
-              <xsd:attribute name="alias" type="xsd:string"/>
-              <xsd:attribute name="name" type="xsd:string"/>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="data">
             <xsd:complexType>
               <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"/>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1"/>
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3"/>
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"/>
-              <xsd:attribute ref="xml:space"/>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="resheader">
             <xsd:complexType>
               <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required"/>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
             </xsd:complexType>
           </xsd:element>
         </xsd:choice>
@@ -559,11 +559,6 @@ Bitte stellen Sie sicher, dass VLC installiert und der Pfad in den HandBrake-Ein
   <data name="PresetService_ArchiveFile" xml:space="preserve">
     <value>Archivierte Datei:</value>
   </data>
-  <data name="PresetService_PresetsOutOfDate" xml:space="preserve">
-    <value>HandBrake hat festgestellt, dass die Voreinstellungsdatei von einer älteren Version stammt.
-Es wird versucht die Datei trotzdem zu laden.
-Schlägt dies fehl, wird die Datei archiviert und eine neue erstellt.</value>
-  </data>
   <data name="PresetService_UnableToLoad" xml:space="preserve">
     <value>Laden der Voreinstellung fehlgeschlagen.</value>
   </data>
@@ -1964,4 +1959,4 @@ Nicht-Echtzeit Optionen: {date} {time} {creation-date} {creation-time} {quality}
   <data name="CollisionBehaviour_AppendNumber" xml:space="preserve">
     <value>Zahl anhängen</value>
   </data>
-</root>
+</root>
\ No newline at end of file
index ab85f89339ed5d5598031f89a9a7e64a91b85b8b..d8aa30d8f9e4d59e9fbe9320e654157b26c68feb 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <root>
   <!-- 
     Microsoft ResX Schema 
             : and then encoded with base64 encoding.
     -->
   <xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
-    <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
     <xsd:element name="root" msdata:IsDataSet="true">
       <xsd:complexType>
         <xsd:choice maxOccurs="unbounded">
           <xsd:element name="metadata">
             <xsd:complexType>
               <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0"/>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
               </xsd:sequence>
-              <xsd:attribute name="name" use="required" type="xsd:string"/>
-              <xsd:attribute name="type" type="xsd:string"/>
-              <xsd:attribute name="mimetype" type="xsd:string"/>
-              <xsd:attribute ref="xml:space"/>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="assembly">
             <xsd:complexType>
-              <xsd:attribute name="alias" type="xsd:string"/>
-              <xsd:attribute name="name" type="xsd:string"/>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="data">
             <xsd:complexType>
               <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"/>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1"/>
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3"/>
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"/>
-              <xsd:attribute ref="xml:space"/>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="resheader">
             <xsd:complexType>
               <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required"/>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
             </xsd:complexType>
           </xsd:element>
         </xsd:choice>
@@ -573,11 +573,6 @@ Assurez-vous que VLC est installé et que le répertoire spécifié dans les opt
   <data name="PresetService_ArchiveFile" xml:space="preserve">
     <value>Fichier archivé:</value>
   </data>
-  <data name="PresetService_PresetsOutOfDate" xml:space="preserve">
-    <value>HandBrake a détecté que votre fichier de préréglages provient d'une version antérieure.
-Il va quand même essayer de charger le fichier.
-Si cela échoue, il archivera l'ancien fichier et en créera un nouveau.</value>
-  </data>
   <data name="PresetService_UnableToLoad" xml:space="preserve">
     <value>Impossible de charger les préréglages.</value>
   </data>
@@ -1978,4 +1973,4 @@ Non-Live Options: {date} {time} {creation-date} {creation-time} {quality} {bitra
   <data name="CollisionBehaviour_AppendNumber" xml:space="preserve">
     <value>Append Number</value>
   </data>
-</root>
+</root>
\ No newline at end of file
index 66a4cf97f96bdf2793a5a4ce9f2ac535e741ff60..d7d5dedcbca77ad160d93dc363c6c343259d3467 100644 (file)
@@ -573,11 +573,6 @@ Please make sure VLC is installed and the directory specified in HandBrake's opt
   <data name="PresetService_ArchiveFile" xml:space="preserve">\r
     <value>Archived File:</value>\r
   </data>\r
-  <data name="PresetService_PresetsOutOfDate" xml:space="preserve">\r
-    <value>HandBrake has detected your presets file is from an older version.\r
-It will try and load the file anyway.\r
-If it fails, it will archive off the old file and create a new one.</value>\r
-  </data>\r
   <data name="PresetService_UnableToLoad" xml:space="preserve">\r
     <value>Unable to load presets.</value>\r
   </data>\r
index dda1f9d5b6b02d06a87ea903897a74cfb0ef6999..a9fbe443461dd1d75c631f75fc84f894ce1ee3ed 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <root>
   <!-- 
     Microsoft ResX Schema 
             : and then encoded with base64 encoding.
     -->
   <xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
-    <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
     <xsd:element name="root" msdata:IsDataSet="true">
       <xsd:complexType>
         <xsd:choice maxOccurs="unbounded">
           <xsd:element name="metadata">
             <xsd:complexType>
               <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0"/>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
               </xsd:sequence>
-              <xsd:attribute name="name" use="required" type="xsd:string"/>
-              <xsd:attribute name="type" type="xsd:string"/>
-              <xsd:attribute name="mimetype" type="xsd:string"/>
-              <xsd:attribute ref="xml:space"/>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="assembly">
             <xsd:complexType>
-              <xsd:attribute name="alias" type="xsd:string"/>
-              <xsd:attribute name="name" type="xsd:string"/>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="data">
             <xsd:complexType>
               <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"/>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1"/>
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3"/>
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"/>
-              <xsd:attribute ref="xml:space"/>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="resheader">
             <xsd:complexType>
               <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required"/>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
             </xsd:complexType>
           </xsd:element>
         </xsd:choice>
@@ -566,11 +566,6 @@ Foreign Audio Preferred, else First - 如果存在外语轨道,则会将其烧
   <data name="PresetService_ArchiveFile" xml:space="preserve">
     <value>存档的文件:</value>
   </data>
-  <data name="PresetService_PresetsOutOfDate" xml:space="preserve">
-    <value>HandBrake 检测到预设文件来自旧版本。
-它将尝试加载文件。
-如果失败,它将存档旧文件并创建新文件。</value>
-  </data>
   <data name="PresetService_UnableToLoad" xml:space="preserve">
     <value>无法加载预设。</value>
   </data>
@@ -1966,4 +1961,4 @@ Non-Live Options: {date} {time} {creation-date} {creation-time} {quality} {bitra
   <data name="CollisionBehaviour_AppendNumber" xml:space="preserve">
     <value>Append Number</value>
   </data>
-</root>
+</root>
\ No newline at end of file
index c6dd9595ea1f88f7a832e6d468c7067ea186d89d..91efcc7f93694a90820d984519fb39ca8f4b1311 100644 (file)
@@ -483,10 +483,8 @@ namespace HandBrakeWPF.Services.Presets.Factories
         /// </returns>\r
         public static PresetTransportContainer ExportPreset(Preset export, HBConfiguration config)\r
         {\r
-            PresetTransportContainer container = new PresetTransportContainer();\r
-            container.VersionMajor = Constants.PresetVersionMajor;\r
-            container.VersionMinor = Constants.PresetVersionMinor;\r
-            container.VersionMicro = Constants.PresetVersionMicro;\r
+            PresetVersion presetVersion = HandBrakePresetService.GetCurrentPresetVersion();\r
+            PresetTransportContainer container = new PresetTransportContainer(presetVersion.Major, presetVersion.Minor, presetVersion.Micro);\r
 \r
             container.PresetList = new List<object> { CreateHbPreset(export, config) };\r
 \r
@@ -501,10 +499,8 @@ namespace HandBrakeWPF.Services.Presets.Factories
         /// <returns>A list of JSON object presets.</returns>\r
         public static PresetTransportContainer ExportPresets(IEnumerable<Preset> exportList, HBConfiguration config)\r
         {\r
-            PresetTransportContainer container = new PresetTransportContainer();\r
-            container.VersionMajor = Constants.PresetVersionMajor;\r
-            container.VersionMinor = Constants.PresetVersionMinor;\r
-            container.VersionMicro = Constants.PresetVersionMicro;\r
+            PresetVersion presetVersion = HandBrakePresetService.GetCurrentPresetVersion();\r
+            PresetTransportContainer container = new PresetTransportContainer(presetVersion.Major, presetVersion.Minor, presetVersion.Micro);\r
 \r
             List<HBPreset> presets = exportList.Select(item => CreateHbPreset(item, config)).ToList();\r
 \r
index 52f1d5d7f92ba0434772b198e72b16c1d6eeece4..56bbbf8d0cb821507adbd7b090cce580aac3bbfc 100644 (file)
@@ -21,6 +21,7 @@ namespace HandBrakeWPF.Services.Presets
 \r
     using HandBrake.Interop.Interop;\r
     using HandBrake.Interop.Interop.Json.Presets;\r
+    using HandBrake.Interop.Interop.Model;\r
     using HandBrake.Interop.Model;\r
     using HandBrake.Interop.Utilities;\r
 \r
@@ -174,7 +175,7 @@ namespace HandBrakeWPF.Services.Presets
                 PresetTransportContainer container = null;\r
                 try\r
                 {\r
-                    container = HandBrakePresetService.GetPresetFromFile(filename);\r
+                    container = HandBrakePresetService.GetPresetsFromFile(filename);\r
                 }\r
                 catch (Exception exc)\r
                 {\r
@@ -681,16 +682,13 @@ namespace HandBrakeWPF.Services.Presets
 \r
                 // Otherwise, we already have a file, so lets try load it.\r
                 PresetTransportContainer container = null;\r
-                using (StreamReader reader = new StreamReader(this.presetFile))\r
+                try\r
                 {\r
-                    try\r
-                    {\r
-                        container = JsonConvert.DeserializeObject<PresetTransportContainer>(reader.ReadToEnd());\r
-                    }\r
-                    catch (Exception exc)\r
-                    {\r
-                        this.ServiceLogMessage("Corrupted Presets File Detected: " + Environment.NewLine + exc);\r
-                    }\r
+                    container = HandBrakePresetService.GetPresetsFromFile(this.presetFile);\r
+                }\r
+                catch (Exception exc)\r
+                {\r
+                    this.ServiceLogMessage("Corrupted Presets File Detected: " + Environment.NewLine + exc);\r
                 }\r
 \r
                 // Sanity Check. Did the container deserialise.\r
@@ -709,23 +707,6 @@ namespace HandBrakeWPF.Services.Presets
                     return; // Update built-in presets stores the presets locally, so just return.\r
                 }\r
 \r
-                // Version Check\r
-                // If we have old presets, or the container wasn't parseable, or we have a version mismatch, backup the user preset file \r
-                // incase something goes wrong and reset built-in presets, then re-save.\r
-                bool ignoreBuildIn = false;\r
-                if (container.VersionMajor != Constants.PresetVersionMajor || container.VersionMinor != Constants.PresetVersionMinor || container.VersionMicro != Constants.PresetVersionMicro)\r
-                {\r
-                    string fileName = this.ArchivePresetFile(this.presetFile);\r
-                    this.errorService.ShowMessageBox(\r
-                        Resources.PresetService_PresetsOutOfDate\r
-                        + Environment.NewLine + Environment.NewLine + Resources.PresetService_ArchiveFile + fileName,\r
-                        Resources.PresetService_UnableToLoad,\r
-                        MessageBoxButton.OK,\r
-                        MessageBoxImage.Information);\r
-                    this.UpdateBuiltInPresets(); // Update built-in presets stores the presets locally, so just return.\r
-                    ignoreBuildIn = true;\r
-                }\r
-\r
                 // Force Upgrade of presets\r
                 if (this.userSettingService.GetUserSetting<int>(UserSettingConstants.ForcePresetReset, typeof(int)) < ForcePresetReset)\r
                 {\r
@@ -742,7 +723,7 @@ namespace HandBrakeWPF.Services.Presets
                     return;\r
                 }\r
 \r
-                this.ProcessPresetList(container, ignoreBuildIn);\r
+                this.ProcessPresetList(container);\r
             }\r
             catch (Exception ex)\r
             {\r
@@ -752,7 +733,7 @@ namespace HandBrakeWPF.Services.Presets
             }\r
         }\r
 \r
-        private void ProcessPresetList(PresetTransportContainer container, bool ignoreOldBuiltIn)\r
+        private void ProcessPresetList(PresetTransportContainer container)\r
         {\r
             // The presets file loaded was OK, so process it.\r
             foreach (var item in container.PresetList)\r
@@ -767,11 +748,6 @@ namespace HandBrakeWPF.Services.Presets
                     {\r
                         Preset preset = JsonPresetFactory.ImportPreset(hbpreset);\r
 \r
-                        if (preset.IsBuildIn && ignoreOldBuiltIn)\r
-                        {\r
-                            continue;\r
-                        }\r
-\r
                         // Migration\r
                         preset.Category = category.PresetName == "User Presets" ? UserPresetCatgoryName : category.PresetName;\r
                         preset.IsBuildIn = hbpreset.Type == 0;\r
@@ -834,11 +810,9 @@ namespace HandBrakeWPF.Services.Presets
 \r
                 // Wrap the categories in a container. \r
                 JsonSerializerSettings settings = new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Ignore };\r
-                PresetTransportContainer container = new PresetTransportContainer(\r
-                                                             Constants.PresetVersionMajor,\r
-                                                             Constants.PresetVersionMinor,\r
-                                                             Constants.PresetVersionMicro)\r
-                                                         { PresetList = new List<object>() };\r
+\r
+                PresetVersion presetVersion = HandBrakePresetService.GetCurrentPresetVersion();\r
+                PresetTransportContainer container = new PresetTransportContainer(presetVersion.Major, presetVersion.Minor, presetVersion.Micro) { PresetList = new List<object>() };\r
                 container.PresetList.AddRange(presetCategories.Values);\r
                 container.PresetList.AddRange(uncategorisedPresets);\r
 \r