diff options
Diffstat (limited to 'win/CS')
-rw-r--r-- | win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs | 23 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs | 117 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/UpdateService.cs | 9 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/UserSettingConstants.cs | 10 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/InstantViewModel.cs | 3 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 8 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/defaultsettings.xml | 24 |
8 files changed, 30 insertions, 165 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs index 03150d1e8..0a82fb980 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeUtils.cs @@ -71,6 +71,29 @@ namespace HandBrake.Interop }
/// <summary>
+ /// Gets the HandBrake version string.
+ /// </summary>
+ public static string Version
+ {
+ get
+ {
+ var versionPtr = HBFunctions.hb_get_version(IntPtr.Zero); // Pointer isn't actually used.
+ return Marshal.PtrToStringAnsi(versionPtr);
+ }
+ }
+
+ /// <summary>
+ /// Gets the HandBrake build number.
+ /// </summary>
+ public static int Build
+ {
+ get
+ {
+ return HBFunctions.hb_get_build(IntPtr.Zero);
+ }
+ }
+
+ /// <summary>
/// Ensures the HB global initialize method has been called.
/// </summary>
public static void EnsureGlobalInit()
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index cee9ac57e..3ca004790 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -258,7 +258,6 @@ <Compile Include="Converters\FullPathToFileNameConverter.cs" />
<Compile Include="Helpers\AdvancedChoicesHelper.cs" />
<Compile Include="Helpers\AutoNameHelper.cs" />
- <Compile Include="Helpers\CliCheckHelper.cs" />
<Compile Include="Helpers\ListBoxHelper.cs" />
<Compile Include="Helpers\QueueRecoveryHelper.cs" />
<Compile Include="Model\AdvancedChoice.cs" />
diff --git a/win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs b/win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs deleted file mode 100644 index 302611e1e..000000000 --- a/win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs +++ /dev/null @@ -1,117 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="CliCheckHelper.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 CliCheckHelper type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.Helpers
-{
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Security.Cryptography;
- using System.Text.RegularExpressions;
- using System.Windows.Forms;
-
- using Caliburn.Micro;
-
- using HandBrakeWPF.Services.Interfaces;
-
- /// <summary>
- /// The cli check helper.
- /// </summary>
- public class CliCheckHelper
- {
- /// <summary>
- /// The check cli version.
- /// </summary>
- public static void CheckCLIVersion()
- {
- IErrorService errorService = IoC.Get<IErrorService>();
-
- IUserSettingService userSettingService = IoC.Get<IUserSettingService>();
-
- string line;
-
- // 0 = SVN Build / Version
- // 1 = Build Date
-
- // Get the SHA1 Hash of HandBrakeCLI
- byte[] hash;
- using (Stream stream = File.OpenRead(Path.Combine(Application.StartupPath, "HandBrakeCLI.exe")))
- {
- hash = SHA1.Create().ComputeHash(stream);
- }
-
- string base64Hash = Convert.ToBase64String(hash);
-
- // Compare the hash with the last known hash. If it's the same, return.
- if (userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeExeHash) == base64Hash)
- {
- return;
- }
-
- // It's not the same, so start the CLI to get it's version data.
- Process cliProcess = new Process();
- ProcessStartInfo handBrakeCli = new ProcessStartInfo(Path.Combine(Application.StartupPath, "HandBrakeCLI.exe"), " -u -v0")
- {
- UseShellExecute = false,
- RedirectStandardError = true,
- RedirectStandardOutput = true,
- CreateNoWindow = true
- };
- cliProcess.StartInfo = handBrakeCli;
-
- try
- {
- cliProcess.Start();
-
- // Retrieve standard output and report back to parent thread until the process is complete
- bool success = false;
- TextReader stdOutput = cliProcess.StandardError;
- while ((line = stdOutput.ReadLine()) != null)
- {
- Match m = Regex.Match(line, @"HandBrake ([svnM0-9.]*) \(([0-9]*)\)");
- if (m.Success)
- {
- string build = m.Groups[2].Success ? m.Groups[2].Value : string.Empty;
-
- int buildValue;
- int.TryParse(build, out buildValue);
-
- userSettingService.SetUserSetting(UserSettingConstants.HandBrakeBuild, buildValue);
- success = true;
- }
- }
-
- while (!cliProcess.HasExited)
- {
- if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.
- {
- Process cli = Process.GetProcessById(cliProcess.Id);
- if (!cli.HasExited)
- {
- cli.Kill();
- }
- }
- }
-
- if (success)
- {
- userSettingService.SetUserSetting(UserSettingConstants.HandBrakeExeHash, base64Hash);
- }
- }
- catch (Exception e)
- {
- userSettingService.SetUserSetting(UserSettingConstants.HandBrakeBuild, 0);
- userSettingService.SetUserSetting(UserSettingConstants.HandBrakeExeHash, string.Empty);
-
- errorService.ShowError(
- "Unable to Initialise HandBrake. This error is unrecoverable.", " Try restarting.", e);
- }
- }
- }
-}
diff --git a/win/CS/HandBrakeWPF/Services/UpdateService.cs b/win/CS/HandBrakeWPF/Services/UpdateService.cs index 85b1f4ab0..67220c0e3 100644 --- a/win/CS/HandBrakeWPF/Services/UpdateService.cs +++ b/win/CS/HandBrakeWPF/Services/UpdateService.cs @@ -15,6 +15,7 @@ namespace HandBrakeWPF.Services using System.Threading;
using HandBrake.ApplicationServices.Utilities;
+ using HandBrake.Interop;
using HandBrakeWPF.Model;
using HandBrakeWPF.Services.Interfaces;
@@ -96,11 +97,9 @@ namespace HandBrakeWPF.Services ? Constants.AppcastUnstable64
: Constants.AppcastUnstable32;
}
-
- var currentBuild =
- this.userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild);
- var skipBuild = this.userSettingService.GetUserSetting<int>(
- UserSettingConstants.Skipversion);
+
+ var currentBuild = HandBrakeUtils.Build;
+ var skipBuild = this.userSettingService.GetUserSetting<int>(UserSettingConstants.Skipversion);
// Initialize variables
WebRequest request = WebRequest.Create(url);
diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index 80bebe4b3..18a410bb3 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -17,11 +17,6 @@ namespace HandBrakeWPF #region Constants and Fields
/// <summary>
- /// HandBrakes build
- /// </summary>
- public const string HandBrakeBuild = "HandBrakeBuild";
-
- /// <summary>
/// Auto name format
/// </summary>
public const string AutoNameFormat = "autoNameFormat";
@@ -127,11 +122,6 @@ namespace HandBrakeWPF public const string GrowlQueue = "GrowlQueue";
/// <summary>
- /// HandBrakes CLI Exe SHA1 Hash
- /// </summary>
- public const string HandBrakeExeHash = "HandBrakeExeHash";
-
- /// <summary>
/// The Instance Id
/// </summary>
public const string InstanceId = "InstanceId";
diff --git a/win/CS/HandBrakeWPF/ViewModels/InstantViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/InstantViewModel.cs index 6e0d5e8eb..1eddfd83e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/InstantViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/InstantViewModel.cs @@ -555,9 +555,6 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public override void OnLoad()
{
- // Check the CLI Executable.
- CliCheckHelper.CheckCLIVersion();
-
// Perform an update check if required
// this.updateService.PerformStartupUpdateCheck(this.HandleUpdateCheckResults);
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index c6f44e4c6..b7e78739d 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -28,6 +28,7 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices.Parsing;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.ApplicationServices.Utilities;
+ using HandBrake.Interop;
using HandBrakeWPF.Commands;
using HandBrakeWPF.Factories;
@@ -1039,9 +1040,6 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public override void OnLoad()
{
- // Check the CLI Executable.
- CliCheckHelper.CheckCLIVersion();
-
// Perform an update check if required
this.updateService.PerformStartupUpdateCheck(this.HandleUpdateCheckResults);
@@ -1675,7 +1673,7 @@ namespace HandBrakeWPF.ViewModels return;
}
- if (buildNumber != userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild).ToString(CultureInfo.InvariantCulture))
+ if (buildNumber != HandBrakeUtils.Build.ToString(CultureInfo.InvariantCulture))
{
MessageBoxResult result = MessageBox.Show(
Resources.Preset_OldVersion_Message,
@@ -1748,7 +1746,7 @@ namespace HandBrakeWPF.ViewModels PlistUtility.Export(
savefiledialog.FileName,
this.selectedPreset,
- this.userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild).ToString(CultureInfo.InvariantCulture));
+ HandBrakeUtils.Build.ToString(CultureInfo.InvariantCulture));
}
}
else
diff --git a/win/CS/HandBrakeWPF/defaultsettings.xml b/win/CS/HandBrakeWPF/defaultsettings.xml index d2c3ef7b9..80fee8569 100644 --- a/win/CS/HandBrakeWPF/defaultsettings.xml +++ b/win/CS/HandBrakeWPF/defaultsettings.xml @@ -106,14 +106,6 @@ </item>
<item>
<key>
- <string>HandBrakeBuild</string>
- </key>
- <value>
- <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:int" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">00010101</anyType>
- </value>
- </item>
- <item>
- <key>
<string>updateStatus</string>
</key>
<value>
@@ -250,14 +242,6 @@ </item>
<item>
<key>
- <string>CliExeHash</string>
- </key>
- <value>
- <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:string" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance" />
- </value>
- </item>
- <item>
- <key>
<string>previewScanCount</string>
</key>
<value>
@@ -370,14 +354,6 @@ </item>
<item>
<key>
- <string>HandBrakeExeHash</string>
- </key>
- <value>
- <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>
- </value>
- </item>
- <item>
- <key>
<string>ShowAdvancedAudioPassthruOpts</string>
</key>
<value>
|