OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 22 Jan 2011 18:02:19 +0000 (18:02 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 22 Jan 2011 18:02:19 +0000 (18:02 +0000)
- Refactored some more code out of the UI project into the Services Project.
- Added support for showing bluray drives to the "Source" dropdown menu

git-svn-id: svn://localhost/HandBrake/trunk@3764 b64f7644-9d1e-0410-96f1-a4d463321fa5

30 files changed:
win/C#/Functions/Main.cs
win/C#/HandBrake.ApplicationServices/Functions/Converters.cs
win/C#/HandBrake.ApplicationServices/Functions/EnumHelper.cs
win/C#/HandBrake.ApplicationServices/Functions/Logging.cs [deleted file]
win/C#/HandBrake.ApplicationServices/Functions/Main.cs [deleted file]
win/C#/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/C#/HandBrake.ApplicationServices/Model/DriveInformation.cs [moved from win/C#/Model/DriveInformation.cs with 77% similarity]
win/C#/HandBrake.ApplicationServices/Model/EncodeTask.cs
win/C#/HandBrake.ApplicationServices/Model/Encoding/Anamorphic.cs
win/C#/HandBrake.ApplicationServices/Model/Encoding/AudioEncoder.cs
win/C#/HandBrake.ApplicationServices/Model/Encoding/Decomb.cs
win/C#/HandBrake.ApplicationServices/Model/Encoding/Deinterlace.cs
win/C#/HandBrake.ApplicationServices/Model/Encoding/Denoise.cs
win/C#/HandBrake.ApplicationServices/Model/Encoding/Detelecine.cs
win/C#/HandBrake.ApplicationServices/Model/Encoding/Mixdown.cs
win/C#/HandBrake.ApplicationServices/Model/Encoding/OutputFormat.cs
win/C#/HandBrake.ApplicationServices/Model/Encoding/PointToPointMode.cs
win/C#/HandBrake.ApplicationServices/Model/Encoding/SubtitleTrack.cs
win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeMode.cs [new file with mode: 0644]
win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeRateType.cs [deleted file]
win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncoder.cs
win/C#/HandBrake.ApplicationServices/Model/QueueTask.cs
win/C#/HandBrake.ApplicationServices/Parsing/Title.cs
win/C#/HandBrake.ApplicationServices/Services/Encode.cs
win/C#/HandBrake.ApplicationServices/Services/ScanService.cs [moved from win/C#/HandBrake.ApplicationServices/Services/Scan.cs with 95% similarity]
win/C#/HandBrake.ApplicationServices/Services/UtilityService.cs [new file with mode: 0644]
win/C#/HandBrake10.5.1.ReSharper
win/C#/HandBrakeCS.csproj
win/C#/frmMain.cs
win/C#/frmOptions.cs

index d2d7ff5..578d2e8 100644 (file)
@@ -472,46 +472,6 @@ namespace Handbrake.Functions
         }\r
 \r
         /// <summary>\r
-        ///  Clear all the encode log files.\r
-        /// </summary>\r
-        public static void ClearLogs()\r
-        {\r
-            string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
-            if (Directory.Exists(logDir))\r
-            {\r
-                DirectoryInfo info = new DirectoryInfo(logDir);\r
-                FileInfo[] logFiles = info.GetFiles("*.txt");\r
-                foreach (FileInfo file in logFiles)\r
-                {\r
-                    if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log"))\r
-                        File.Delete(file.FullName);\r
-                }\r
-            }\r
-        }\r
-\r
-        /// <summary>\r
-        /// Clear old log files x days in the past\r
-        /// </summary>\r
-        public static void ClearOldLogs()\r
-        {\r
-            string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
-            if (Directory.Exists(logDir))\r
-            {\r
-                DirectoryInfo info = new DirectoryInfo(logDir);\r
-                FileInfo[] logFiles = info.GetFiles("*.txt");\r
-\r
-                foreach (FileInfo file in logFiles)\r
-                {\r
-                    if (file.LastWriteTime < DateTime.Now.AddDays(-30))\r
-                    {\r
-                        if (!file.Name.Contains("last_scan_log.txt") && !file.Name.Contains("last_encode_log.txt"))\r
-                            File.Delete(file.FullName);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-\r
-        /// <summary>\r
         /// Map languages and their iso639_2 value into a IDictionary\r
         /// </summary>\r
         /// <returns>A Dictionary containing the language and iso code</returns>\r
@@ -710,32 +670,6 @@ namespace Handbrake.Functions
         }\r
 \r
         /// <summary>\r
-        /// Get a list of available DVD drives which are ready and contain DVD content.\r
-        /// </summary>\r
-        /// <returns>A List of Drives with their details</returns>\r
-        public static List<DriveInformation> GetDrives()\r
-        {\r
-            List<DriveInformation> drives = new List<DriveInformation>();\r
-            DriveInfo[] theCollectionOfDrives = DriveInfo.GetDrives();\r
-            int id = 0;\r
-            foreach (DriveInfo curDrive in theCollectionOfDrives)\r
-            {\r
-                if (curDrive.DriveType == DriveType.CDRom && curDrive.IsReady &&\r
-                    File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO"))\r
-                {\r
-                    drives.Add(new DriveInformation\r
-                                   {\r
-                                       Id = id,\r
-                                       VolumeLabel = curDrive.VolumeLabel,\r
-                                       RootDirectory = curDrive.RootDirectory + "VIDEO_TS"\r
-                                   });\r
-                    id++;\r
-                }\r
-            }\r
-            return drives;\r
-        }\r
-\r
-        /// <summary>\r
         /// Change a string to Title Case/\r
         /// </summary>\r
         /// <param name="input">\r
index c4ba59f..84df3da 100644 (file)
@@ -1,7 +1,11 @@
-namespace HandBrake.ApplicationServices.Functions\r
+/*  Converters.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.Collections.Generic;\r
     using System.Text.RegularExpressions;\r
 \r
     /// <summary>\r
 \r
             return converted;\r
         }\r
-\r
-        /// <summary>\r
-        /// Video Framerate Converter\r
-        /// </summary>\r
-        private static readonly Dictionary<double, int> vrates = new Dictionary<double, int>\r
-        {\r
-           {5, 5400000},\r
-           {10, 2700000},\r
-           {12, 2250000},\r
-           {15, 1800000},\r
-           {23.976, 1126125},\r
-           {24, 1125000},\r
-           {25, 1080000},\r
-           {29.97, 900900}\r
-        };\r
-\r
-        /// <summary>\r
-        /// Convert the desired framerate to the video rate.\r
-        /// </summary>\r
-        /// <param name="framerate">\r
-        /// The framerate.\r
-        /// </param>\r
-        /// <returns>\r
-        /// The Video Rate.\r
-        /// </returns>\r
-        /// <exception cref="ArgumentException">\r
-        /// </exception>\r
-        public static int FramerateToVrate(double framerate)\r
-        {\r
-            if (!vrates.ContainsKey(framerate))\r
-            {\r
-                throw new ArgumentException("Framerate not recognized.", "framerate");\r
-            }\r
-\r
-            return vrates[framerate];\r
-        }\r
     }\r
 }\r
index 6cf7342..0bbc746 100644 (file)
@@ -5,9 +5,9 @@
 \r
 namespace HandBrake.ApplicationServices.Functions\r
 {\r
+    using System;\r
     using System.ComponentModel;\r
     using System.Reflection;\r
-    using System;\r
 \r
     /// <summary>\r
     /// Enum Helpers\r
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Logging.cs b/win/C#/HandBrake.ApplicationServices/Functions/Logging.cs
deleted file mode 100644 (file)
index 1bb08cd..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*  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
-        /// <returns>\r
-        /// The create cli log header.\r
-        /// </returns>\r
-        public static string CreateCliLogHeader(QueueTask 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
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Main.cs b/win/C#/HandBrake.ApplicationServices/Functions/Main.cs
deleted file mode 100644 (file)
index 368065d..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*  Main.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.Diagnostics;\r
-\r
-    /// <summary>\r
-    /// Useful functions which various screens can use.\r
-    /// </summary>\r
-    public static class Main\r
-    {\r
-        /// <summary>\r
-        /// Get the Process ID of HandBrakeCLI for the current instance.\r
-        /// </summary>\r
-        /// <returns>A list of processes</returns>\r
-        public static Process[] GetCliProcess()\r
-        {\r
-            return Process.GetProcessesByName("HandBrakeCLI");\r
-        }\r
-    }\r
-}
\ No newline at end of file
index 12b5bc6..57c3ca4 100644 (file)
     <Compile Include="EventArgs\ScanProgressEventArgs.cs" />\r
     <Compile Include="Functions\Converters.cs" />\r
     <Compile Include="Functions\EnumHelper.cs" />\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
+    <Compile Include="Model\DriveInformation.cs" />\r
     <Compile Include="Model\Encoding\AudioTrack.cs" />\r
     <Compile Include="Model\Encoding\Anamorphic.cs" />\r
     <Compile Include="Model\Encoding\AudioEncoder.cs" />\r
     <Compile Include="Model\Encoding\OutputFormat.cs" />\r
     <Compile Include="Model\Encoding\SubtitleTrack.cs" />\r
     <Compile Include="Model\Encoding\VideoEncoder.cs" />\r
-    <Compile Include="Model\Encoding\VideoEncodeRateType.cs" />\r
+    <Compile Include="Model\Encoding\VideoEncodeMode.cs" />\r
     <Compile Include="Model\QueueTask.cs" />\r
     <Compile Include="Model\Encoding\SubtitleType.cs" />\r
     <Compile Include="Parsing\AudioTrack.cs" />\r
     <Compile Include="Services\LibScan.cs" />\r
     <Compile Include="Services\QueueManager.cs" />\r
     <Compile Include="Services\QueueProcessor.cs" />\r
-    <Compile Include="Services\Scan.cs" />\r
+    <Compile Include="Services\ScanService.cs" />\r
+    <Compile Include="Services\UtilityService.cs" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <None Include="app.config" />\r
@@ -3,7 +3,7 @@
     Homepage: <http://handbrake.fr>.\r
     It may be used under the terms of the GNU General Public License. */\r
 \r
-namespace Handbrake.Model\r
+namespace HandBrake.ApplicationServices.Model\r
 {\r
     /// <summary>\r
     /// Information about a DVD drive\r
@@ -26,6 +26,11 @@ namespace Handbrake.Model
         public string RootDirectory { get; set; }\r
 \r
         /// <summary>\r
+        /// Gets or sets a value indicating whether this is a BluRay Drive.\r
+        /// </summary>\r
+        public bool IsBluRay { get; set; }\r
+\r
+        /// <summary>\r
         /// Returns  "Drive" + Id  (e.g  Drive2)\r
         /// </summary>\r
         /// <returns>\r
@@ -33,7 +38,7 @@ namespace Handbrake.Model
         /// </returns>\r
         public override string ToString()\r
         {\r
-            return "Drive" + Id;\r
+            return "Drive" + this.Id;\r
         }\r
     }\r
 }
\ No newline at end of file
index b10168a..dfc0fbf 100644 (file)
@@ -200,7 +200,7 @@ namespace HandBrake.ApplicationServices.Model
         /// <summary>\r
         /// Gets or sets VideoEncodeRateType.\r
         /// </summary>\r
-        public VideoEncodeRateType VideoEncodeRateType { get; set; }\r
+        public VideoEncodeMode VideoEncodeRateType { get; set; }\r
 \r
         /// <summary>\r
         /// Gets or sets Quality.\r
index b3b524c..c958b77 100644 (file)
@@ -1,4 +1,9 @@
-namespace HandBrake.ApplicationServices.Model.Encoding\r
+/*  Anamorphic.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.Model.Encoding\r
 {\r
     using System.ComponentModel;\r
 \r
index d98b120..c6f838e 100644 (file)
@@ -1,4 +1,9 @@
-namespace HandBrake.ApplicationServices.Model.Encoding\r
+/*  AudioEncoder.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.Model.Encoding\r
 {\r
     using System.ComponentModel;\r
 \r
index c09c5b9..ae8b8a3 100644 (file)
@@ -1,4 +1,9 @@
-namespace HandBrake.ApplicationServices.Model.Encoding\r
+/*  Decomb.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.Model.Encoding\r
 {\r
     /// <summary>\r
     /// Decomb Mode\r
index 308b025..1544289 100644 (file)
@@ -1,5 +1,13 @@
-namespace HandBrake.ApplicationServices.Model.Encoding\r
+/*  Deinterlace.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.Model.Encoding\r
 {\r
+    /// <summary>\r
+    /// The Deinterlace Filter\r
+    /// </summary>\r
     public enum Deinterlace\r
     {\r
         Off = 0,\r
index 6698e77..fc81e9f 100644 (file)
@@ -1,5 +1,13 @@
-namespace HandBrake.ApplicationServices.Model.Encoding\r
+/*  Denoise.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.Model.Encoding\r
 {\r
+    /// <summary>\r
+    /// The Denose Filters\r
+    /// </summary>\r
     public enum Denoise\r
     {\r
         Off = 0,\r
index 1961497..09c948d 100644 (file)
@@ -1,5 +1,13 @@
-namespace HandBrake.ApplicationServices.Model.Encoding\r
+/*  Detelecine.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.Model.Encoding\r
 {\r
+    /// <summary>\r
+    /// Detelecine Filter\r
+    /// </summary>\r
     public enum Detelecine\r
     {\r
         Off = 0,\r
index 373ee6b..12611b4 100644 (file)
@@ -1,4 +1,9 @@
-namespace HandBrake.ApplicationServices.Model.Encoding\r
+/*  Mixdown.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.Model.Encoding\r
 {\r
     using System.ComponentModel;\r
 \r
index c556591..fa5c322 100644 (file)
@@ -1,4 +1,9 @@
-namespace HandBrake.ApplicationServices.Model.Encoding\r
+/*  OutputFormat.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.Model.Encoding\r
 {\r
     using System.ComponentModel;\r
 \r
index 8c58aa4..dcee4ca 100644 (file)
@@ -1,4 +1,9 @@
-namespace HandBrake.ApplicationServices.Model.Encoding\r
+/*  PointToPoint.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.Model.Encoding\r
 {\r
     /// <summary>\r
     /// Point to Point Mode\r
index 5a36356..f69abed 100644 (file)
@@ -1,4 +1,4 @@
-/*  Subtitle.cs $\r
+/*  SubtitleTrack.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
diff --git a/win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeMode.cs b/win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeMode.cs
new file mode 100644 (file)
index 0000000..cf42f3c
--- /dev/null
@@ -0,0 +1,17 @@
+/*  VideoEncoderMode.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.Model.Encoding\r
+{\r
+    /// <summary>\r
+    /// The Mode of Video Encoding. Bitrate, Filesize or Quality\r
+    /// </summary>\r
+    public enum VideoEncodeMode\r
+    {\r
+        TargetSize = 0,\r
+        AverageBitrate,\r
+        ConstantQuality\r
+    }\r
+}\r
diff --git a/win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeRateType.cs b/win/C#/HandBrake.ApplicationServices/Model/Encoding/VideoEncodeRateType.cs
deleted file mode 100644 (file)
index b128fdb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace HandBrake.ApplicationServices.Model.Encoding\r
-{\r
-    public enum VideoEncodeRateType\r
-    {\r
-        TargetSize = 0,\r
-        AverageBitrate,\r
-        ConstantQuality\r
-    }\r
-}\r
index 4eddbf4..b5a2556 100644 (file)
@@ -1,7 +1,15 @@
-namespace HandBrake.ApplicationServices.Model.Encoding\r
+/*  VideoEncoder.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.Model.Encoding\r
 {\r
     using System.ComponentModel;\r
 \r
+    /// <summary>\r
+    /// The Video Encoder\r
+    /// </summary>\r
     public enum VideoEncoder\r
     {\r
         [Description("H.264 (x264)")]\r
index 9f92ec6..83948a1 100644 (file)
@@ -1,4 +1,4 @@
-/*  QueueItem.cs $\r
+/*  QueueTask.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
@@ -6,7 +6,7 @@
 namespace HandBrake.ApplicationServices.Model\r
 {\r
     /// <summary>\r
-    /// The job.\r
+    /// The QueueTask.\r
     /// </summary>\r
     public class QueueTask\r
     {\r
index e726620..3a9e6a5 100644 (file)
@@ -30,9 +30,9 @@ namespace HandBrake.ApplicationServices.Parsing
         /// </summary>\r
         public Title()\r
         {\r
-            AudioTracks = new List<AudioTrack>();\r
-            Chapters = new List<Chapter>();\r
-            Subtitles = new List<Subtitle>();\r
+            this.AudioTracks = new List<AudioTrack>();\r
+            this.Chapters = new List<Chapter>();\r
+            this.Subtitles = new List<Subtitle>();\r
         }\r
 \r
         #region Properties\r
@@ -112,8 +112,8 @@ namespace HandBrake.ApplicationServices.Parsing
         /// <summary>\r
         /// Parse the Title Information\r
         /// </summary>\r
-        /// <param name="output">A stingreader of output data</param>\r
-        /// <returns>A Title</returns>\r
+        /// <param name="output">A StringReader of output data</param>\r
+        /// <returns>A Title Object</returns>\r
         public static Title Parse(StringReader output)\r
         {\r
             var thisTitle = new Title();\r
index bc5220e..9d3f7bb 100644 (file)
@@ -446,8 +446,8 @@ namespace HandBrake.ApplicationServices.Services
 \r
                 fileWriter = new StreamWriter(logFile) { AutoFlush = true };\r
 \r
-                fileWriter.WriteLine(Logging.CreateCliLogHeader(encodeQueueTask));\r
-                logBuffer.AppendLine(Logging.CreateCliLogHeader(encodeQueueTask));\r
+                fileWriter.WriteLine(UtilityService.CreateCliLogHeader(encodeQueueTask));\r
+                logBuffer.AppendLine(UtilityService.CreateCliLogHeader(encodeQueueTask));\r
             }\r
             catch (Exception)\r
             {\r
@@ -13,7 +13,6 @@ namespace HandBrake.ApplicationServices.Services
     using System.Windows.Forms;\r
 \r
     using HandBrake.ApplicationServices.EventArgs;\r
-    using HandBrake.ApplicationServices.Functions;\r
     using HandBrake.ApplicationServices.Parsing;\r
     using HandBrake.ApplicationServices.Services.Interfaces;\r
 \r
@@ -236,7 +235,7 @@ namespace HandBrake.ApplicationServices.Services
                     // Only write the log file to disk if it's less than 100MB.\r
                     if (this.readData.Buffer.Length < 100000000)\r
                     {\r
-                        scanLog.WriteLine(Logging.CreateCliLogHeader(null));\r
+                        scanLog.WriteLine(UtilityService.CreateCliLogHeader(null));\r
                         scanLog.Write(this.readData.Buffer);\r
                         logBuffer.AppendLine(this.readData.Buffer.ToString());\r
                     }\r
@@ -327,7 +326,7 @@ namespace HandBrake.ApplicationServices.Services
             logFilePosition = 0;\r
             logBuffer = new StringBuilder();\r
             if (addHeader)\r
-                logBuffer.AppendLine(Logging.CreateCliLogHeader(null));\r
+                logBuffer.AppendLine(UtilityService.CreateCliLogHeader(null));\r
         }\r
 \r
         /// <summary>\r
diff --git a/win/C#/HandBrake.ApplicationServices/Services/UtilityService.cs b/win/C#/HandBrake.ApplicationServices/Services/UtilityService.cs
new file mode 100644 (file)
index 0000000..b705cb8
--- /dev/null
@@ -0,0 +1,131 @@
+/*  UtilityService.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.Services\r
+{\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Diagnostics;\r
+    using System.IO;\r
+    using System.Text;\r
+    using System.Windows.Forms;\r
+\r
+    using HandBrake.ApplicationServices.Functions;\r
+    using HandBrake.ApplicationServices.Model;\r
+\r
+    /// <summary>\r
+    /// A Set of Static Utilites\r
+    /// </summary>\r
+    public class UtilityService\r
+    {\r
+        /// <summary>\r
+        /// The Default Log Directory\r
+        /// </summary>\r
+        private static readonly string LogDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
+\r
+        /// <summary>\r
+        /// Clear all the log files older than 30 Days\r
+        /// </summary>\r
+        /// <param name="daysToKeep">\r
+        /// The Number of Days to Keep\r
+        /// </param>\r
+        public static void ClearLogFiles(int daysToKeep)\r
+        {\r
+            if (Directory.Exists(LogDir))\r
+            {\r
+                // Get all the log files\r
+                DirectoryInfo info = new DirectoryInfo(LogDir);\r
+                FileInfo[] logFiles = info.GetFiles("*.txt");\r
+\r
+                // Delete Them\r
+                foreach (FileInfo file in logFiles)\r
+                {\r
+                    if (file.LastWriteTime < DateTime.Now.AddDays(-daysToKeep))\r
+                    {\r
+                        if (!file.Name.Contains("last_scan_log.txt") && !file.Name.Contains("last_encode_log.txt"))\r
+                        {\r
+                            File.Delete(file.FullName);\r
+                        }\r
+                        else if (file.Length > 104857600)\r
+                        {\r
+                            File.Delete(file.FullName);\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get a list of available DVD drives which are ready and contain DVD content.\r
+        /// </summary>\r
+        /// <returns>A List of Drives with their details</returns>\r
+        public static List<DriveInformation> GetDrives()\r
+        {\r
+            List<DriveInformation> drives = new List<DriveInformation>();\r
+            DriveInfo[] theCollectionOfDrives = DriveInfo.GetDrives();\r
+            int id = 0;\r
+            foreach (DriveInfo curDrive in theCollectionOfDrives)\r
+            {\r
+                if (curDrive.DriveType == DriveType.CDRom && curDrive.IsReady)\r
+                {\r
+                    if (Directory.Exists(curDrive.RootDirectory + "VIDEO_TS") || Directory.Exists(curDrive.RootDirectory + "BDMV"))\r
+                    {\r
+                        drives.Add(\r
+                            new DriveInformation\r
+                                {\r
+                                    Id = id,\r
+                                    VolumeLabel = curDrive.VolumeLabel,\r
+                                    RootDirectory = curDrive.RootDirectory.ToString()\r
+                                });\r
+                        id++;\r
+                    }\r
+                }\r
+            }\r
+\r
+            return drives;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get the Process ID of HandBrakeCLI for the current instance.\r
+        /// </summary>\r
+        /// <returns>A list of processes</returns>\r
+        public static Process[] GetCliProcess()\r
+        {\r
+            return Process.GetProcessesByName("HandBrakeCLI");\r
+        }\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
+        /// <returns>\r
+        /// The create cli log header.\r
+        /// </returns>\r
+        public static string CreateCliLogHeader(QueueTask 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
+}\r
index 9d75ad0..70de471 100644 (file)
@@ -88,6 +88,7 @@
         <Abbreviation Text="SRT" />\r
         <Abbreviation Text="CLI" />\r
         <Abbreviation Text="MP" />\r
+        <Abbreviation Text="II" />\r
       </Naming2>\r
       <CustomMemberReorderingPatterns><![CDATA[<?xml version="1.0" encoding="utf-8"?>\r
 <Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns">\r
index a847110..0eb720f 100644 (file)
     <Compile Include="frmActivityWindow.Designer.cs">\r
       <DependentUpon>frmActivityWindow.cs</DependentUpon>\r
     </Compile>\r
-    <Compile Include="Model\DriveInformation.cs" />\r
     <Compile Include="Model\SourceType.cs" />\r
     <Compile Include="Presets\PlistPresetHandler.cs" />\r
     <Compile Include="Presets\Preset.cs" />\r
index fa85b47..b4feee8 100644 (file)
@@ -88,7 +88,7 @@ namespace Handbrake
                 // We have a drive, selected as a folder.\r
                 if (this.sourcePath.EndsWith("\\"))\r
                 {\r
-                    drives = Main.GetDrives();\r
+                    drives = UtilityService.GetDrives();\r
                     foreach (DriveInformation item in drives)\r
                     {\r
                         if (item.RootDirectory.Contains(this.sourcePath))\r
@@ -148,7 +148,7 @@ namespace Handbrake
             // Clear the log files in the background\r
             if (Settings.Default.clearOldLogs)\r
             {\r
-                Thread clearLog = new Thread(Main.ClearOldLogs);\r
+                Thread clearLog = new Thread(() => UtilityService.ClearLogFiles(30));\r
                 clearLog.Start();\r
             }\r
 \r
@@ -2470,7 +2470,7 @@ namespace Handbrake
                     return;\r
                 }\r
 \r
-                drives = Main.GetDrives();\r
+                drives = UtilityService.GetDrives();\r
 \r
                 List<ToolStripMenuItem> menuItems = new List<ToolStripMenuItem>();\r
                 foreach (DriveInformation drive in drives)\r
index 11034f9..89c5aae 100644 (file)
@@ -12,6 +12,7 @@ namespace Handbrake
     using System.Windows.Forms;\r
 \r
     using HandBrake.ApplicationServices;\r
+    using HandBrake.ApplicationServices.Services;\r
 \r
     using Handbrake.Functions;\r
     using Handbrake.Model;\r
@@ -406,7 +407,7 @@ namespace Handbrake
                                                   MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);\r
             if (result == DialogResult.Yes)\r
             {\r
-                Main.ClearLogs();\r
+                UtilityService.ClearLogFiles(30);\r
                 MessageBox.Show(this, "HandBrake's Log file directory has been cleared!", "Notice", MessageBoxButtons.OK,\r
                                 MessageBoxIcon.Information);\r
             }\r