OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 15 Jan 2011 17:42:32 +0000 (17:42 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 15 Jan 2011 17:42:32 +0000 (17:42 +0000)
- Some updates to the new queue processing code. (still not active)

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

win/C#/HandBrake.ApplicationServices/Services/Encode.cs
win/C#/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs
win/C#/HandBrake.ApplicationServices/Services/QueueManager.cs
win/C#/HandBrake.ApplicationServices/Services/QueueProcessor.cs

index 90c224a..e2046da 100644 (file)
@@ -288,10 +288,6 @@ namespace HandBrake.ApplicationServices.Services
             //}*/\r
         }\r
 \r
-        #endregion\r
-\r
-        #region Private Helper Methods\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
@@ -299,7 +295,7 @@ namespace HandBrake.ApplicationServices.Services
         /// <param name="destination">\r
         /// The Destination File Path\r
         /// </param>\r
-        protected void CopyLog(string destination)\r
+        public void ProcessLogs(string destination)\r
         {\r
             try\r
             {\r
@@ -334,6 +330,10 @@ namespace HandBrake.ApplicationServices.Services
             }\r
         }\r
 \r
+        #endregion\r
+\r
+        #region Private Helper Methods\r
+\r
         /// <summary>\r
         /// The HandBrakeCLI process has exited.\r
         /// </summary>\r
index 399afde..7ba7396 100644 (file)
@@ -84,5 +84,13 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
         /// Note: http://www.cygwin.com/ml/cygwin/2006-03/msg00330.html\r
         /// </summary>\r
         void SafelyStop();\r
+\r
+        /// <summary>\r
+        /// Copy the log file to the desired destinations\r
+        /// </summary>\r
+        /// <param name="destination">\r
+        /// The destination.\r
+        /// </param>\r
+        void ProcessLogs(string destination);\r
     }\r
 }
\ No newline at end of file
index 05602f1..5edbf39 100644 (file)
     {\r
         /*\r
          * TODO\r
-         * - Multi HandBrake Instance Support for Queue Saving.\r
          * - Rewrite the batch script generator. \r
          */\r
 \r
         #region Private Variables\r
 \r
         /// <summary>\r
-        /// HandBrakes Queue file with a place holder for an extra string.\r
-        /// Use this with String.Format()\r
-        /// </summary>\r
-        private const string QueueFile = "hb_queue_recovery{0}.xml";\r
-\r
-        /// <summary>\r
         /// A Lock object to maintain thread safety\r
         /// </summary>\r
         static readonly object QueueLock = new object();\r
         private readonly List<QueueTask> queue = new List<QueueTask>();\r
 \r
         /// <summary>\r
+        /// HandBrakes Queue file with a place holder for an extra string.\r
+        /// </summary>\r
+        private readonly string queueFile;\r
+\r
+        /// <summary>\r
         /// The ID of the job last added\r
         /// </summary>\r
         private int lastJobId;\r
@@ -64,6 +62,9 @@
         public QueueManager(int instanceId)\r
         {\r
             this.instanceId = instanceId;\r
+\r
+            // If this is the first instance, just use the main queue file, otherwise add the instance id to the filename.\r
+            this.queueFile = instanceId == 0 ? "hb_queue_recovery.xml" : string.Format("hb_queue_recovery{0}.xml", instanceId);\r
         }\r
 \r
         #region Events\r
         public void BackupQueue(string exportPath)\r
         {\r
             string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
-            string tempPath = !string.IsNullOrEmpty(exportPath) ? exportPath : appDataPath + string.Format(QueueFile, string.Empty);\r
+            string tempPath = !string.IsNullOrEmpty(exportPath) ? exportPath : appDataPath + string.Format(this.queueFile, string.Empty);\r
 \r
             if (File.Exists(tempPath))\r
             {\r
         public void RestoreQueue(string importPath)\r
         {\r
             string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
-            string tempPath = !string.IsNullOrEmpty(importPath) ? importPath : (appDataPath + string.Format(QueueFile, string.Empty));\r
+            string tempPath = !string.IsNullOrEmpty(importPath) ? importPath : (appDataPath + string.Format(this.queueFile, string.Empty));\r
 \r
             if (File.Exists(tempPath))\r
             {\r
index d49d437..1625271 100644 (file)
@@ -19,12 +19,6 @@ namespace HandBrake.ApplicationServices.Services
     /// </summary>\r
     public class QueueProcessor : IQueueProcessor\r
     {\r
-        /*\r
-         * TODO\r
-         * - Hookup the logging to write to disk\r
-         * \r
-         */\r
-\r
         /// <summary>\r
         /// Initializes a new instance of the <see cref="QueueProcessor"/> class.\r
         /// </summary>\r
@@ -204,7 +198,7 @@ namespace HandBrake.ApplicationServices.Services
                                          "Put down that cocktail...\nyour Handbrake encode is done.");\r
 \r
             // Handling Log Data \r
-            // TODO - Still need to re-write this using CopyLog()\r
+            this.EncodeService.ProcessLogs(this.QueueManager.LastProcessedJob.Destination);\r
 \r
             // Move onto the next job.\r
             this.ProcessNextJob();\r