From 97a88523f2b6352847d705cbf527fd5ee0f5247b Mon Sep 17 00:00:00 2001 From: sr55 Date: Tue, 19 Mar 2013 21:48:51 +0000 Subject: WinGui: Part 1: Fix numerous issues around app versioning. Hopefully the GUI and CLI will no longer be out of sync. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5350 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../ASUserSettingConstants.cs | 5 -- .../HandBrake.ApplicationServices.csproj | 2 + .../Properties/AssemblyInfo.cs.Nightly.tmpl | 42 ++++++++++++++++ .../Services/Base/EncodeBase.cs | 4 +- .../Services/LibScan.cs | 9 +--- .../Services/PresetService.cs | 4 +- .../Services/ScanService.cs | 4 +- .../Services/ServerService.cs | 4 +- .../Utilities/GeneralUtilities.cs | 10 +--- .../Utilities/VersionHelper.cs | 57 ++++++++++++++++++++++ 10 files changed, 111 insertions(+), 30 deletions(-) create mode 100644 win/CS/HandBrake.ApplicationServices/Properties/AssemblyInfo.cs.Nightly.tmpl create mode 100644 win/CS/HandBrake.ApplicationServices/Utilities/VersionHelper.cs (limited to 'win/CS/HandBrake.ApplicationServices') diff --git a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs index 2a4aa18c0..7e3ee4583 100644 --- a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs +++ b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs @@ -49,11 +49,6 @@ namespace HandBrake.ApplicationServices /// public const string SaveLogCopyDirectory = "SaveLogCopyDirectory"; - /// - /// HandBrakes version - /// - public const string HandBrakeVersion = "HandBrakeVersion"; - /// /// HandBrakes build /// diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index efeeffb47..445b09c36 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -106,6 +106,7 @@ + @@ -160,6 +161,7 @@ + diff --git a/win/CS/HandBrake.ApplicationServices/Properties/AssemblyInfo.cs.Nightly.tmpl b/win/CS/HandBrake.ApplicationServices/Properties/AssemblyInfo.cs.Nightly.tmpl new file mode 100644 index 000000000..faa879725 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Properties/AssemblyInfo.cs.Nightly.tmpl @@ -0,0 +1,42 @@ +/* AssemblyInfo.cs $ + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ + +using System.Reflection; +using System.Resources; +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("HandBrake")] +[assembly: AssemblyDescription("HandBrake is a GPL-licensed, multiplatform, multithreaded video transcoder.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HandBrake Team")] +[assembly: AssemblyProduct("HandBrake")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[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("5e4e3f97-5252-41f6-aae9-3846f62cbc66")] + +// 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("0.0.0.$WCREV$")] +[assembly: NeutralResourcesLanguage("")] diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs index 555b004f2..db4ef3abd 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs @@ -66,9 +66,7 @@ namespace HandBrake.ApplicationServices.Services.Base this.userSettingService = userSettingService; this.logBuffer = new StringBuilder(); header = - GeneralUtilities.CreateCliLogHeader( - userSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeVersion), - userSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeBuild)); + GeneralUtilities.CreateCliLogHeader(); this.LogIndex = 0; } diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs index 850c3b860..55aefd7ea 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs @@ -71,19 +71,14 @@ namespace HandBrake.ApplicationServices.Services /// /// Initializes a new instance of the class. /// - /// - /// The user Setting Service. - /// /// /// The hand Brake Instance. /// - public LibScan(IUserSettingService userSettingService, IHandBrakeInstance handBrakeInstance) + public LibScan(IHandBrakeInstance handBrakeInstance) { logging = new StringBuilder(); - header = GeneralUtilities.CreateCliLogHeader( - userSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeVersion), - userSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeBuild)); + header = GeneralUtilities.CreateCliLogHeader(); instance = handBrakeInstance; instance.Initialize(1); diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs index 5edfb4e1e..5e7d461f5 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs @@ -306,7 +306,7 @@ namespace HandBrake.ApplicationServices.Services { Category = category, Name = presetName[0].Replace("+", string.Empty).Trim(), - Version = this.userSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeVersion), + Version = VersionHelper.GetVersion(), Description = string.Empty, // Maybe one day we will populate this. IsBuildIn = true, UsePictureFilters = true, @@ -354,7 +354,7 @@ namespace HandBrake.ApplicationServices.Services List preset = this.presets.Where(p => p.IsBuildIn).ToList(); if (preset.Count > 0) { - if (preset[0].Version != this.userSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeVersion)) + if (preset[0].Version != VersionHelper.GetVersion()) { this.UpdateBuiltInPresets(); return true; diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs index 40329f14d..1ad531dfe 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs @@ -74,9 +74,7 @@ namespace HandBrake.ApplicationServices.Services this.userSettingService = userSettingService; this.logBuffer = new StringBuilder(); - header = GeneralUtilities.CreateCliLogHeader( - userSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeVersion), - userSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeBuild)); + header = GeneralUtilities.CreateCliLogHeader(); } #region Events diff --git a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs index d8966c192..199e371a9 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ServerService.cs @@ -173,8 +173,8 @@ namespace HandBrake.ApplicationServices.Services // Setup the services we are going to use. IHandBrakeInstance instance = new HandBrakeInstance(); - scanService = new LibScan(new UserSettingService(), instance); // TODO this needs wired up with castle - encodeService = new LibEncode(new UserSettingService(), instance); + scanService = new LibScan(instance); + encodeService = new LibEncode(new UserSettingService(), instance); // TODO this needs wired up with castle shutdownFlag = new ManualResetEvent(false); shutdownFlag.WaitOne(); diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs index 378898c05..097663f9c 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs @@ -84,20 +84,14 @@ namespace HandBrake.ApplicationServices.Utilities /// /// Add the CLI Query to the Log File. /// - /// - /// The version. - /// - /// - /// The build. - /// /// /// The create cli log header. /// - public static StringBuilder CreateCliLogHeader(string version, int build) + public static StringBuilder CreateCliLogHeader() { var logHeader = new StringBuilder(); - logHeader.AppendLine(String.Format("HandBrake {0} {1}", version, build)); + logHeader.AppendLine(String.Format("HandBrake {0} - {1}", VersionHelper.GetVersion(), VersionHelper.GetPlatformBitnessVersion())); logHeader.AppendLine(String.Format("OS: {0}", Environment.OSVersion)); logHeader.AppendLine(String.Format("CPU: {0}", SystemInfo.GetCpuCount)); logHeader.Append(String.Format("Ram: {0} MB, ", SystemInfo.TotalPhysicalMemory)); diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/VersionHelper.cs b/win/CS/HandBrake.ApplicationServices/Utilities/VersionHelper.cs new file mode 100644 index 000000000..a8860f5ee --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Utilities/VersionHelper.cs @@ -0,0 +1,57 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Version Utility +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrake.ApplicationServices.Utilities +{ + using System; + using System.Reflection; + + /// + /// Version Utility + /// + public class VersionHelper + { + /// + /// The get build. + /// + /// + /// The . + /// + public static string GetVersion() + { + Version version = Assembly.GetEntryAssembly().GetName().Version; + return IsNightly() ? string.Format("svn{0} (Nightly Build)", version.Revision) : string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision); + } + + /// + /// The is nightly. + /// + /// + /// The . + /// + public static bool IsNightly() + { + Version version = Assembly.GetEntryAssembly().GetName().Version; + + // The MSBuild.xml script sets 0.0.0 for nightly builds. + return version.Major == 0 && version.Minor == 0 && version.Build == 0; + } + + /// + /// The get platform bitness. + /// + /// + /// The . + /// + public static string GetPlatformBitnessVersion() + { + return System.Environment.Is64BitProcess ? "64bit Version" : "32bit Version"; + } + } +} -- cgit v1.2.3