}\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
<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
+++ /dev/null
-// --------------------------------------------------------------------------------------------------------------------\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
using System.Threading;\r
\r
using HandBrake.ApplicationServices.Utilities;\r
+ using HandBrake.Interop;\r
\r
using HandBrakeWPF.Model;\r
using HandBrakeWPF.Services.Interfaces;\r
? 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
{\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
/// </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
/// </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
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
/// </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
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
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
<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