]> granicus.if.org Git - handbrake/commitdiff
WinGui: Remove the CLI Check Helper. Using LibHB to determine version information...
authorsr55 <sr55.hb@outlook.com>
Fri, 28 Nov 2014 22:20:42 +0000 (22:20 +0000)
committersr55 <sr55.hb@outlook.com>
Fri, 28 Nov 2014 22:20:42 +0000 (22:20 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6564 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs
win/CS/HandBrakeWPF/HandBrakeWPF.csproj
win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs [deleted file]
win/CS/HandBrakeWPF/Services/UpdateService.cs
win/CS/HandBrakeWPF/UserSettingConstants.cs
win/CS/HandBrakeWPF/ViewModels/InstantViewModel.cs
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
win/CS/HandBrakeWPF/defaultsettings.xml

index 03150d1e8e162942a4ed279d71725e539e131246..0a82fb980c93bee3e1915f4973d21a1f755f1188 100644 (file)
@@ -70,6 +70,29 @@ namespace HandBrake.Interop
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Gets the HandBrake version string.\r
+        /// </summary>\r
+        public static string Version\r
+        {\r
+            get\r
+            {\r
+                var versionPtr = HBFunctions.hb_get_version(IntPtr.Zero); // Pointer isn't actually used.\r
+                return Marshal.PtrToStringAnsi(versionPtr);\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Gets the HandBrake build number.\r
+        /// </summary>\r
+        public static int Build\r
+        {\r
+            get\r
+            {\r
+                return HBFunctions.hb_get_build(IntPtr.Zero);\r
+            }\r
+        }\r
+\r
         /// <summary>\r
         /// Ensures the HB global initialize method has been called.\r
         /// </summary>\r
index cee9ac57e6542a3945ffd1d993ddce4571e7f55a..3ca004790f5a494ba6dafc243869823bfd05ba2a 100644 (file)
     <Compile Include="Converters\FullPathToFileNameConverter.cs" />\r
     <Compile Include="Helpers\AdvancedChoicesHelper.cs" />\r
     <Compile Include="Helpers\AutoNameHelper.cs" />\r
-    <Compile Include="Helpers\CliCheckHelper.cs" />\r
     <Compile Include="Helpers\ListBoxHelper.cs" />\r
     <Compile Include="Helpers\QueueRecoveryHelper.cs" />\r
     <Compile Include="Model\AdvancedChoice.cs" />\r
diff --git a/win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs b/win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs
deleted file mode 100644 (file)
index 302611e..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="CliCheckHelper.cs" company="HandBrake Project (http://handbrake.fr)">\r
-//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
-// </copyright>\r
-// <summary>\r
-//   Defines the CliCheckHelper type.\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrakeWPF.Helpers\r
-{\r
-    using System;\r
-    using System.Diagnostics;\r
-    using System.IO;\r
-    using System.Security.Cryptography;\r
-    using System.Text.RegularExpressions;\r
-    using System.Windows.Forms;\r
-\r
-    using Caliburn.Micro;\r
-\r
-    using HandBrakeWPF.Services.Interfaces;\r
-\r
-    /// <summary>\r
-    /// The cli check helper.\r
-    /// </summary>\r
-    public class CliCheckHelper\r
-    {\r
-        /// <summary>\r
-        /// The check cli version.\r
-        /// </summary>\r
-        public static void CheckCLIVersion()\r
-        {\r
-            IErrorService errorService = IoC.Get<IErrorService>();\r
-\r
-            IUserSettingService userSettingService = IoC.Get<IUserSettingService>();\r
-\r
-            string line;\r
-\r
-            // 0 = SVN Build / Version\r
-            // 1 = Build Date\r
-\r
-            // Get the SHA1 Hash of HandBrakeCLI\r
-            byte[] hash;\r
-            using (Stream stream = File.OpenRead(Path.Combine(Application.StartupPath, "HandBrakeCLI.exe")))\r
-            {\r
-                hash = SHA1.Create().ComputeHash(stream);\r
-            }\r
-\r
-            string base64Hash = Convert.ToBase64String(hash);\r
-\r
-            // Compare the hash with the last known hash. If it's the same, return.\r
-            if (userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeExeHash) == base64Hash)\r
-            {\r
-                return;\r
-            }\r
-\r
-            // It's not the same, so start the CLI to get it's version data.\r
-            Process cliProcess = new Process();\r
-            ProcessStartInfo handBrakeCli = new ProcessStartInfo(Path.Combine(Application.StartupPath, "HandBrakeCLI.exe"), " -u -v0")\r
-                {\r
-                    UseShellExecute = false,\r
-                    RedirectStandardError = true,\r
-                    RedirectStandardOutput = true,\r
-                    CreateNoWindow = true\r
-                };\r
-            cliProcess.StartInfo = handBrakeCli;\r
-\r
-            try\r
-            {\r
-                cliProcess.Start();\r
-\r
-                // Retrieve standard output and report back to parent thread until the process is complete\r
-                bool success = false;\r
-                TextReader stdOutput = cliProcess.StandardError;\r
-                while ((line = stdOutput.ReadLine()) != null)\r
-                {\r
-                    Match m = Regex.Match(line, @"HandBrake ([svnM0-9.]*) \(([0-9]*)\)");\r
-                    if (m.Success)\r
-                    {\r
-                        string build = m.Groups[2].Success ? m.Groups[2].Value : string.Empty;\r
-\r
-                        int buildValue;\r
-                        int.TryParse(build, out buildValue);\r
-\r
-                        userSettingService.SetUserSetting(UserSettingConstants.HandBrakeBuild, buildValue);\r
-                        success = true;\r
-                    }\r
-                }\r
-\r
-                while (!cliProcess.HasExited)\r
-                {\r
-                    if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.\r
-                    {\r
-                        Process cli = Process.GetProcessById(cliProcess.Id);\r
-                        if (!cli.HasExited)\r
-                        {\r
-                            cli.Kill();\r
-                        }\r
-                    }\r
-                }\r
-\r
-                if (success)\r
-                {\r
-                    userSettingService.SetUserSetting(UserSettingConstants.HandBrakeExeHash, base64Hash);\r
-                }\r
-            }\r
-            catch (Exception e)\r
-            {\r
-                userSettingService.SetUserSetting(UserSettingConstants.HandBrakeBuild, 0);\r
-                userSettingService.SetUserSetting(UserSettingConstants.HandBrakeExeHash, string.Empty);\r
-\r
-                errorService.ShowError(\r
-                    "Unable to Initialise HandBrake. This error is unrecoverable.", " Try restarting.", e);\r
-            }\r
-        }\r
-    }\r
-}\r
index 85b1f4ab064527f6a263be5aaa3aa27adb580bb2..67220c0e384c01bb2b260929a4ce363cfda529f2 100644 (file)
@@ -15,6 +15,7 @@ namespace HandBrakeWPF.Services
     using System.Threading;\r
 \r
     using HandBrake.ApplicationServices.Utilities;\r
+    using HandBrake.Interop;\r
 \r
     using HandBrakeWPF.Model;\r
     using HandBrakeWPF.Services.Interfaces;\r
@@ -96,11 +97,9 @@ namespace HandBrakeWPF.Services
                                 ? Constants.AppcastUnstable64\r
                                 : Constants.AppcastUnstable32;\r
                         }\r
-                        \r
-                        var currentBuild =\r
-                            this.userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild);\r
-                        var skipBuild = this.userSettingService.GetUserSetting<int>(\r
-                            UserSettingConstants.Skipversion);\r
+\r
+                        var currentBuild = HandBrakeUtils.Build;\r
+                        var skipBuild = this.userSettingService.GetUserSetting<int>(UserSettingConstants.Skipversion);\r
 \r
                         // Initialize variables\r
                         WebRequest request = WebRequest.Create(url);\r
index 80bebe4b3624f2789f047107f846884aca9b7a41..18a410bb3204a3c7aa77e4fd35a1069a05fee377 100644 (file)
@@ -16,11 +16,6 @@ namespace HandBrakeWPF
     {\r
         #region Constants and Fields\r
 \r
-        /// <summary>\r
-        /// HandBrakes build\r
-        /// </summary>\r
-        public const string HandBrakeBuild = "HandBrakeBuild";\r
-\r
         /// <summary>\r
         /// Auto name format\r
         /// </summary>\r
@@ -126,11 +121,6 @@ namespace HandBrakeWPF
         /// </summary>\r
         public const string GrowlQueue = "GrowlQueue";\r
 \r
-        /// <summary>\r
-        /// HandBrakes CLI Exe SHA1 Hash\r
-        /// </summary>\r
-        public const string HandBrakeExeHash = "HandBrakeExeHash";\r
-\r
         /// <summary>\r
         /// The Instance Id\r
         /// </summary>\r
index 6e0d5e8eb3cb80e7726e4ebaad756fd030f4fafc..1eddfd83e1177a2bd7ca4def43c1c3b446aeb855 100644 (file)
@@ -555,9 +555,6 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public override void OnLoad()\r
         {\r
-            // Check the CLI Executable.\r
-            CliCheckHelper.CheckCLIVersion();\r
-\r
             // Perform an update check if required\r
             // this.updateService.PerformStartupUpdateCheck(this.HandleUpdateCheckResults);\r
 \r
index c6f44e4c634b0c942b2eb4aa3d08f4cfb44de77d..b7e78739d0df7829b64ac72c05ab71d62120bc60 100644 (file)
@@ -28,6 +28,7 @@ namespace HandBrakeWPF.ViewModels
     using HandBrake.ApplicationServices.Parsing;\r
     using HandBrake.ApplicationServices.Services.Interfaces;\r
     using HandBrake.ApplicationServices.Utilities;\r
+    using HandBrake.Interop;\r
 \r
     using HandBrakeWPF.Commands;\r
     using HandBrakeWPF.Factories;\r
@@ -1039,9 +1040,6 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public override void OnLoad()\r
         {\r
-            // Check the CLI Executable.\r
-            CliCheckHelper.CheckCLIVersion();\r
-\r
             // Perform an update check if required\r
             this.updateService.PerformStartupUpdateCheck(this.HandleUpdateCheckResults);\r
 \r
@@ -1675,7 +1673,7 @@ namespace HandBrakeWPF.ViewModels
                     return;\r
                 }\r
 \r
-                if (buildNumber != userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild).ToString(CultureInfo.InvariantCulture))\r
+                if (buildNumber != HandBrakeUtils.Build.ToString(CultureInfo.InvariantCulture))\r
                 {\r
                     MessageBoxResult result = MessageBox.Show(\r
                         Resources.Preset_OldVersion_Message,\r
@@ -1748,7 +1746,7 @@ namespace HandBrakeWPF.ViewModels
                     PlistUtility.Export(\r
                         savefiledialog.FileName,\r
                         this.selectedPreset,\r
-                        this.userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild).ToString(CultureInfo.InvariantCulture));\r
+                        HandBrakeUtils.Build.ToString(CultureInfo.InvariantCulture));\r
                 }\r
             }\r
             else\r
index d2c3ef7b996240326c4e6519d6bd790b0b074ed2..80fee8569b609433f07e699691badba8946c5e51 100644 (file)
       <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:int" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">10</anyType>\r
     </value>\r
   </item>\r
-  <item>\r
-    <key>\r
-      <string>HandBrakeBuild</string>\r
-    </key>\r
-    <value>\r
-      <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:int" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">00010101</anyType>\r
-    </value>\r
-  </item>\r
   <item>\r
     <key>\r
       <string>updateStatus</string>\r
       <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:int" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">255</anyType>\r
     </value>\r
   </item>\r
-  <item>\r
-    <key>\r
-      <string>CliExeHash</string>\r
-    </key>\r
-    <value>\r
-      <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:string" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance" />\r
-    </value>\r
-  </item>\r
   <item>\r
     <key>\r
       <string>previewScanCount</string>\r
       <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:int" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">10</anyType>\r
     </value>\r
   </item>\r
-  <item>\r
-    <key>\r
-      <string>HandBrakeExeHash</string>\r
-    </key>\r
-    <value>\r
-      <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:string" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">RQuM6TVXbXkdih1PmGTf+h178Ho=</anyType>\r
-    </value>\r
-  </item>\r
   <item>\r
     <key>\r
       <string>ShowAdvancedAudioPassthruOpts</string>\r