--- /dev/null
+/* Logging.cs $\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Functions\r
+{\r
+ using System;\r
+ using System.IO;\r
+ using System.Text;\r
+ using System.Windows.Forms;\r
+\r
+ using HandBrake.ApplicationServices.Model;\r
+\r
+ /// <summary>\r
+ /// The System Information.\r
+ /// </summary>\r
+ public class Logging\r
+ {\r
+ /// <summary>\r
+ /// Add the CLI Query to the Log File.\r
+ /// </summary>\r
+ /// <param name="encJob">\r
+ /// The Encode Job Object\r
+ /// </param>\r
+ public static string CreateCliLogHeader(Job encJob)\r
+ {\r
+ StringBuilder logHeader = new StringBuilder();\r
+\r
+ logHeader.AppendLine(String.Format("# {0}", Init.HandBrakeGuiVersionString));\r
+ logHeader.AppendLine(String.Format("# Running: {0}", Environment.OSVersion));\r
+ logHeader.AppendLine(String.Format("# CPU: {0}", SystemInfo.GetCpuCount));\r
+ logHeader.AppendLine(String.Format("# Ram: {0} MB", SystemInfo.TotalPhysicalMemory));\r
+ logHeader.AppendLine(String.Format("# Screen: {0}x{1}", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));\r
+ logHeader.AppendLine(String.Format("# Temp Dir: {0}", Path.GetTempPath()));\r
+ logHeader.AppendLine(String.Format("# Install Dir: {0}", Application.StartupPath));\r
+ logHeader.AppendLine(String.Format("# Data Dir: {0}\n", Application.UserAppDataPath));\r
+\r
+ if (encJob != null)\r
+ {\r
+ logHeader.AppendLine(String.Format("# CLI Query: {0}", encJob.Query));\r
+ logHeader.AppendLine(String.Format("# User Query: {0}", encJob.CustomQuery));\r
+ }\r
+ logHeader.AppendLine("-------------------------------------------");\r
+\r
+ return logHeader.ToString();\r
+ }\r
+ }\r
+}
\ No newline at end of file
Homepage: <http://handbrake.fr>.\r
It may be used under the terms of the GNU General Public License. */\r
\r
-namespace Handbrake.Functions\r
+namespace HandBrake.ApplicationServices.Functions\r
{\r
using System.Windows.Forms;\r
+\r
using Microsoft.Win32;\r
\r
/// <summary>\r
<Compile Include="frmExceptionWindow.Designer.cs">\r
<DependentUpon>frmExceptionWindow.cs</DependentUpon>\r
</Compile>\r
+ <Compile Include="Functions\Logging.cs" />\r
<Compile Include="Functions\GrowlCommunicator.cs" />\r
<Compile Include="Functions\Main.cs" />\r
+ <Compile Include="Functions\System.cs" />\r
<Compile Include="Functions\Win32.cs" />\r
<Compile Include="Functions\Win7.cs" />\r
<Compile Include="Init.cs" />\r
/// <summary>\r
/// Setup the Settings used by the applicaiton with this library\r
/// </summary>\r
+ /// <param name="versionString">\r
+ /// The version / name of the application that's using this DLL.\r
+ /// </param>\r
/// <param name="instanceId">\r
/// The Instance ID\r
/// </param>\r
/// <param name="preventSleep">\r
/// Prevent the system from sleeping\r
/// </param>\r
- public static void SetupSettings(int instanceId, string completionOption, bool disableDvdNav,\r
+ public static void SetupSettings(string versionString, int instanceId, string completionOption, bool disableDvdNav,\r
bool growlEncode, bool growlQueue, string processPriority, string saveLogPath, bool saveLogToSpecifiedPath,\r
bool saveLogWithVideo, bool showCliForInGuiEncodeStatus, bool preventSleep)\r
{\r
InstanceId = instanceId;\r
+ HandBrakeGuiVersionString = versionString;\r
Properties.Settings.Default.CompletionOption = completionOption;\r
Properties.Settings.Default.disableDvdNav = disableDvdNav;\r
Properties.Settings.Default.growlEncode = growlEncode;\r
return Assembly.GetExecutingAssembly().GetName().Version;\r
}\r
\r
+ /// <summary>\r
+ /// The instance ID used by the Main Applicaiton\r
+ /// </summary>\r
public static int InstanceId;\r
+\r
+ /// <summary>\r
+ /// The Applicaiton that uses this DLL can pass in it's version string.\r
+ /// </summary>\r
+ public static string HandBrakeGuiVersionString;\r
}\r
}\r
/// <summary>\r
/// The job.\r
/// </summary>\r
- public struct Job\r
+ public class Job\r
{\r
/// <summary>\r
/// Gets or sets the job ID.\r
\r
/* Helpers */\r
/// <summary>\r
- /// Add the CLI Query to the Log File.\r
- /// </summary>\r
- /// <param name="encJob">\r
- /// The Encode Job Object\r
- /// </param>\r
- private static string CreateCliLogHeader(Job encJob)\r
- {\r
- StringBuilder logHeader = new StringBuilder();\r
- logHeader.AppendLine("# CLI Query: " + encJob.Query);\r
- logHeader.AppendLine("# User Query: " + encJob.CustomQuery);\r
- logHeader.AppendLine("-------------------------------------------");\r
-\r
- return logHeader.ToString();\r
- }\r
-\r
- /// <summary>\r
/// Save a copy of the log to the users desired location or a default location\r
/// if this feature is enabled in options.\r
/// </summary>\r
\r
fileWriter = new StreamWriter(logFile) { AutoFlush = true };\r
\r
- fileWriter.WriteLine(CreateCliLogHeader(encodeJob));\r
- logBuffer.AppendLine(CreateCliLogHeader(encodeJob));\r
+ fileWriter.WriteLine(Logging.CreateCliLogHeader(encodeJob));\r
+ logBuffer.AppendLine(Logging.CreateCliLogHeader(encodeJob));\r
}\r
catch (Exception exc)\r
{\r
\r
// Write the Buffer out to file.\r
StreamWriter scanLog = new StreamWriter(dvdInfoPath);\r
+ scanLog.WriteLine(Logging.CreateCliLogHeader(null));\r
scanLog.Write(this.readData.Buffer);\r
scanLog.Flush();\r
scanLog.Close();\r
- logBuffer = readData.Buffer;\r
+ logBuffer.AppendLine(this.readData.Buffer.ToString());\r
\r
IsScanning = false;\r
\r
{\r
logFilePosition = 0;\r
logBuffer = new StringBuilder();\r
+ logBuffer.AppendLine(Logging.CreateCliLogHeader(null));\r
}\r
\r
/// <summary>\r
<Compile Include="Functions\PresetLoader.cs" />\r
<Compile Include="Functions\QueryGenerator.cs" />\r
<Compile Include="Functions\Main.cs" />\r
- <Compile Include="Functions\System.cs" />\r
<Compile Include="Functions\UpdateCheckInformation.cs" />\r
<Compile Include="Functions\Win32.cs" />\r
<Compile Include="frmActivityWindow.cs">\r
/// </summary>\r
private static void InitializeApplicationServices()\r
{\r
- Init.SetupSettings(InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
+ string versionId = String.Format("Windows GUI {1} {0}", Settings.Default.hb_build, Settings.Default.hb_version);\r
+ Init.SetupSettings(versionId, InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
Settings.Default.growlEncode, Settings.Default.growlQueue,\r
Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath,\r
Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep);\r
using System.Text;\r
using System.Threading;\r
using System.Windows.Forms;\r
- using Functions;\r
\r
using HandBrake.ApplicationServices.Services.Interfaces;\r
\r
appendText.AppendFormat("Waiting for the log to be generated ...\n");\r
position = 0;\r
ClearWindowText();\r
- PrintLogHeader();\r
return appendText;\r
}\r
\r
appendText.AppendFormat("Waiting for the log to be generated ...\n");\r
position = 0;\r
ClearWindowText();\r
- PrintLogHeader();\r
return appendText;\r
}\r
\r
}\r
\r
/// <summary>\r
- /// Display the log header\r
- /// </summary>\r
- private void PrintLogHeader()\r
- {\r
- try\r
- {\r
- if (IsHandleCreated)\r
- {\r
- if (rtf_actLog.InvokeRequired)\r
- {\r
- IAsyncResult invoked = BeginInvoke(new SetTextClearCallback(PrintLogHeader));\r
- EndInvoke(invoked);\r
- }\r
- else\r
- {\r
- lock (rtf_actLog)\r
- {\r
- // Print the log header. This function will be re-implimented later. Do not delete.\r
- StringBuilder header = new StringBuilder();\r
-\r
- header.Append(String.Format("### Windows GUI {1} {0} \n", Properties.Settings.Default.hb_build, Properties.Settings.Default.hb_version));\r
- header.Append(String.Format("### Running: {0} \n###\n", Environment.OSVersion));\r
- header.Append(String.Format("### CPU: {0} \n", SystemInfo.GetCpuCount));\r
- header.Append(String.Format("### Ram: {0} MB \n", SystemInfo.TotalPhysicalMemory));\r
- header.Append(String.Format("### Screen: {0}x{1} \n", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));\r
- header.Append(String.Format("### Temp Dir: {0} \n", Path.GetTempPath()));\r
- header.Append(String.Format("### Install Dir: {0} \n", Application.StartupPath));\r
- header.Append(String.Format("### Data Dir: {0} \n", Application.UserAppDataPath));\r
- header.Append("#########################################\n\n");\r
-\r
- rtf_actLog.AppendText(header.ToString());\r
- }\r
- }\r
- }\r
- }\r
- catch (Exception)\r
- {\r
- return;\r
- }\r
- }\r
-\r
- /// <summary>\r
/// Reset Everything\r
/// </summary>\r
private void Reset()\r
windowTimer.Dispose();\r
position = 0;\r
ClearWindowText();\r
- PrintLogHeader();\r
windowTimer = new Timer(new TimerCallback(LogMonitor), null, 1000, 1000);\r
}\r
\r
/// </summary>\r
private static void UpdateApplicationServicesSettings()\r
{\r
- Init.SetupSettings(Program.InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
+ string versionId = String.Format("Windows GUI {1} {0}", Settings.Default.hb_build, Settings.Default.hb_version);\r
+ Init.SetupSettings(versionId, Program.InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
Settings.Default.growlEncode, Settings.Default.growlQueue,\r
Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath,\r
Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep);\r