summaryrefslogtreecommitdiffstats
path: root/win/C#/HandBrake.ApplicationServices
diff options
context:
space:
mode:
Diffstat (limited to 'win/C#/HandBrake.ApplicationServices')
-rw-r--r--win/C#/HandBrake.ApplicationServices/Functions/Logging.cs49
-rw-r--r--win/C#/HandBrake.ApplicationServices/Functions/System.cs58
-rw-r--r--win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj2
-rw-r--r--win/C#/HandBrake.ApplicationServices/Init.cs14
-rw-r--r--win/C#/HandBrake.ApplicationServices/Model/Job.cs2
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Encode.cs20
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Scan.cs4
7 files changed, 128 insertions, 21 deletions
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Logging.cs b/win/C#/HandBrake.ApplicationServices/Functions/Logging.cs
new file mode 100644
index 000000000..aba92dbbe
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/Functions/Logging.cs
@@ -0,0 +1,49 @@
+/* Logging.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrake.ApplicationServices.Functions
+{
+ using System;
+ using System.IO;
+ using System.Text;
+ using System.Windows.Forms;
+
+ using HandBrake.ApplicationServices.Model;
+
+ /// <summary>
+ /// The System Information.
+ /// </summary>
+ public class Logging
+ {
+ /// <summary>
+ /// Add the CLI Query to the Log File.
+ /// </summary>
+ /// <param name="encJob">
+ /// The Encode Job Object
+ /// </param>
+ public static string CreateCliLogHeader(Job encJob)
+ {
+ StringBuilder logHeader = new StringBuilder();
+
+ logHeader.AppendLine(String.Format("# {0}", Init.HandBrakeGuiVersionString));
+ logHeader.AppendLine(String.Format("# Running: {0}", Environment.OSVersion));
+ logHeader.AppendLine(String.Format("# CPU: {0}", SystemInfo.GetCpuCount));
+ logHeader.AppendLine(String.Format("# Ram: {0} MB", SystemInfo.TotalPhysicalMemory));
+ logHeader.AppendLine(String.Format("# Screen: {0}x{1}", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));
+ logHeader.AppendLine(String.Format("# Temp Dir: {0}", Path.GetTempPath()));
+ logHeader.AppendLine(String.Format("# Install Dir: {0}", Application.StartupPath));
+ logHeader.AppendLine(String.Format("# Data Dir: {0}\n", Application.UserAppDataPath));
+
+ if (encJob != null)
+ {
+ logHeader.AppendLine(String.Format("# CLI Query: {0}", encJob.Query));
+ logHeader.AppendLine(String.Format("# User Query: {0}", encJob.CustomQuery));
+ }
+ logHeader.AppendLine("-------------------------------------------");
+
+ return logHeader.ToString();
+ }
+ }
+} \ No newline at end of file
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/System.cs b/win/C#/HandBrake.ApplicationServices/Functions/System.cs
new file mode 100644
index 000000000..b2ee6edfe
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/Functions/System.cs
@@ -0,0 +1,58 @@
+/* System.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrake.ApplicationServices.Functions
+{
+ using System.Windows.Forms;
+
+ using Microsoft.Win32;
+
+ /// <summary>
+ /// The System Information.
+ /// </summary>
+ public class SystemInfo
+ {
+ /// <summary>
+ /// Gets the total physical ram in a system
+ /// </summary>
+ /// <returns>The total memory in the system</returns>
+ public static uint TotalPhysicalMemory
+ {
+ get
+ {
+ Win32.MEMORYSTATUS memStatus = new Win32.MEMORYSTATUS();
+ Win32.GlobalMemoryStatus(ref memStatus);
+
+ uint memoryInfo = memStatus.dwTotalPhys;
+ memoryInfo = memoryInfo / 1024 / 1024;
+
+ return memoryInfo;
+ }
+ }
+
+ /// <summary>
+ /// Gets the number of CPU Cores
+ /// </summary>
+ /// <returns>Object</returns>
+ public static object GetCpuCount
+ {
+ get
+ {
+ RegistryKey regKey = Registry.LocalMachine;
+ regKey = regKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
+ return regKey == null ? 0 : regKey.GetValue("ProcessorNameString");
+ }
+ }
+
+ /// <summary>
+ /// Gets the System screen size information.
+ /// </summary>
+ /// <returns>System.Windows.Forms.Scree</returns>
+ public static Screen ScreenBounds
+ {
+ get { return Screen.PrimaryScreen; }
+ }
+ }
+} \ No newline at end of file
diff --git a/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index 148ba78db..bc6c04db0 100644
--- a/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -78,8 +78,10 @@
<Compile Include="frmExceptionWindow.Designer.cs">
<DependentUpon>frmExceptionWindow.cs</DependentUpon>
</Compile>
+ <Compile Include="Functions\Logging.cs" />
<Compile Include="Functions\GrowlCommunicator.cs" />
<Compile Include="Functions\Main.cs" />
+ <Compile Include="Functions\System.cs" />
<Compile Include="Functions\Win32.cs" />
<Compile Include="Functions\Win7.cs" />
<Compile Include="Init.cs" />
diff --git a/win/C#/HandBrake.ApplicationServices/Init.cs b/win/C#/HandBrake.ApplicationServices/Init.cs
index 7f1e1ed72..d279a0b11 100644
--- a/win/C#/HandBrake.ApplicationServices/Init.cs
+++ b/win/C#/HandBrake.ApplicationServices/Init.cs
@@ -16,6 +16,9 @@ namespace HandBrake.ApplicationServices
/// <summary>
/// Setup the Settings used by the applicaiton with this library
/// </summary>
+ /// <param name="versionString">
+ /// The version / name of the application that's using this DLL.
+ /// </param>
/// <param name="instanceId">
/// The Instance ID
/// </param>
@@ -49,11 +52,12 @@ namespace HandBrake.ApplicationServices
/// <param name="preventSleep">
/// Prevent the system from sleeping
/// </param>
- public static void SetupSettings(int instanceId, string completionOption, bool disableDvdNav,
+ public static void SetupSettings(string versionString, int instanceId, string completionOption, bool disableDvdNav,
bool growlEncode, bool growlQueue, string processPriority, string saveLogPath, bool saveLogToSpecifiedPath,
bool saveLogWithVideo, bool showCliForInGuiEncodeStatus, bool preventSleep)
{
InstanceId = instanceId;
+ HandBrakeGuiVersionString = versionString;
Properties.Settings.Default.CompletionOption = completionOption;
Properties.Settings.Default.disableDvdNav = disableDvdNav;
Properties.Settings.Default.growlEncode = growlEncode;
@@ -79,6 +83,14 @@ namespace HandBrake.ApplicationServices
return Assembly.GetExecutingAssembly().GetName().Version;
}
+ /// <summary>
+ /// The instance ID used by the Main Applicaiton
+ /// </summary>
public static int InstanceId;
+
+ /// <summary>
+ /// The Applicaiton that uses this DLL can pass in it's version string.
+ /// </summary>
+ public static string HandBrakeGuiVersionString;
}
}
diff --git a/win/C#/HandBrake.ApplicationServices/Model/Job.cs b/win/C#/HandBrake.ApplicationServices/Model/Job.cs
index 9d4b37510..536069153 100644
--- a/win/C#/HandBrake.ApplicationServices/Model/Job.cs
+++ b/win/C#/HandBrake.ApplicationServices/Model/Job.cs
@@ -8,7 +8,7 @@ namespace HandBrake.ApplicationServices.Model
/// <summary>
/// The job.
/// </summary>
- public struct Job
+ public class Job
{
/// <summary>
/// Gets or sets the job ID.
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs
index 9ef1b2c9c..c21d83722 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/Encode.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/Encode.cs
@@ -261,22 +261,6 @@ namespace HandBrake.ApplicationServices.Services
/* Helpers */
/// <summary>
- /// Add the CLI Query to the Log File.
- /// </summary>
- /// <param name="encJob">
- /// The Encode Job Object
- /// </param>
- private static string CreateCliLogHeader(Job encJob)
- {
- StringBuilder logHeader = new StringBuilder();
- logHeader.AppendLine("# CLI Query: " + encJob.Query);
- logHeader.AppendLine("# User Query: " + encJob.CustomQuery);
- logHeader.AppendLine("-------------------------------------------");
-
- return logHeader.ToString();
- }
-
- /// <summary>
/// Save a copy of the log to the users desired location or a default location
/// if this feature is enabled in options.
/// </summary>
@@ -430,8 +414,8 @@ namespace HandBrake.ApplicationServices.Services
fileWriter = new StreamWriter(logFile) { AutoFlush = true };
- fileWriter.WriteLine(CreateCliLogHeader(encodeJob));
- logBuffer.AppendLine(CreateCliLogHeader(encodeJob));
+ fileWriter.WriteLine(Logging.CreateCliLogHeader(encodeJob));
+ logBuffer.AppendLine(Logging.CreateCliLogHeader(encodeJob));
}
catch (Exception exc)
{
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Scan.cs b/win/C#/HandBrake.ApplicationServices/Services/Scan.cs
index 039cb3f3d..04c35e36f 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/Scan.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/Scan.cs
@@ -191,10 +191,11 @@ namespace HandBrake.ApplicationServices.Services
// Write the Buffer out to file.
StreamWriter scanLog = new StreamWriter(dvdInfoPath);
+ scanLog.WriteLine(Logging.CreateCliLogHeader(null));
scanLog.Write(this.readData.Buffer);
scanLog.Flush();
scanLog.Close();
- logBuffer = readData.Buffer;
+ logBuffer.AppendLine(this.readData.Buffer.ToString());
IsScanning = false;
@@ -268,6 +269,7 @@ namespace HandBrake.ApplicationServices.Services
{
logFilePosition = 0;
logBuffer = new StringBuilder();
+ logBuffer.AppendLine(Logging.CreateCliLogHeader(null));
}
/// <summary>