OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 26 Nov 2008 19:32:53 +0000 (19:32 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 26 Nov 2008 19:32:53 +0000 (19:32 +0000)
- The Queue Recovery, inport/export features now use an XML based file system rather than text file.
- Queue now uses class based Queue Items for storing data rather than an arraylist.
- Fixes an issue where the source and/or destination would not show up in the list of queue items.
- Queue progress meter will now update correctly if a user adds more items to the queue after starting the queue.

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

win/C#/Functions/Encode.cs
win/C#/Functions/Main.cs
win/C#/Functions/QueryParser.cs
win/C#/HandBrakeCS.csproj
win/C#/Queue/QueueHandler.cs [moved from win/C#/Functions/Queue.cs with 61% similarity]
win/C#/Queue/QueueItem.cs [new file with mode: 0644]
win/C#/frmMain.cs
win/C#/frmQueue.cs

index 0445392..471acb5 100644 (file)
@@ -133,7 +133,7 @@ namespace Handbrake.Functions
         /// if this feature is enabled in options.\r
         /// </summary>\r
         /// <param name="query"></param>\r
-        public void copyLog(string query)\r
+        public void copyLog(string query, string destination)\r
         {\r
             // The user may wish to do something with the log.\r
             if (Properties.Settings.Default.saveLog == "Checked")\r
@@ -143,7 +143,7 @@ namespace Handbrake.Functions
 \r
                 if (Properties.Settings.Default.saveLogWithVideo == "Checked")\r
                 {\r
-                    string[] destName = parsed.Destination.Split('\\');\r
+                    string[] destName = destination.Split('\\');\r
                     string destinationFile = "";\r
                     for (int i = 0; i < destName.Length - 1; i++)\r
                     {\r
@@ -156,7 +156,7 @@ namespace Handbrake.Functions
                 }\r
                 else if (Properties.Settings.Default.saveLogPath != String.Empty)\r
                 {\r
-                    string[] destName = parsed.Destination.Split('\\');\r
+                    string[] destName = destination.Split('\\');\r
                     string dest = destName[destName.Length - 1];\r
                     string filename = DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + " " + dest + ".txt";\r
                     string useDefinedLogPath = Path.Combine(Properties.Settings.Default.saveLogPath, filename);\r
index f8600d3..0a202b1 100644 (file)
@@ -13,11 +13,16 @@ using System.IO;
 using System.Drawing;\r
 using System.Diagnostics;\r
 using System.Text.RegularExpressions;\r
+using System.Collections.Generic;\r
+using System.Xml.Serialization;\r
 \r
 namespace Handbrake.Functions\r
 {\r
     class Main\r
     {\r
+        // Private Variables\r
+        private static XmlSerializer ser = new XmlSerializer(typeof(List<Queue.QueueItem>));\r
+\r
         /// <summary>\r
         /// Calculate the duration of the selected title and chapters\r
         /// </summary>\r
@@ -361,28 +366,21 @@ namespace Handbrake.Functions
         {\r
             try\r
             {\r
-                string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat");\r
-                using (StreamReader reader = new StreamReader(tempPath))\r
+                string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
+                if (File.Exists(tempPath))\r
                 {\r
-                    string queue_item = reader.ReadLine();\r
-                    if (queue_item == null)\r
-                    {\r
-                        reader.Close();\r
-                        reader.Dispose();\r
-                        return false;\r
-                    }\r
-                    else // There exists an item in the recovery queue file, so try and recovr it.\r
+                    using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))\r
                     {\r
-                        reader.Close();\r
-                        reader.Dispose();\r
-                        return true;\r
+                        List<Queue.QueueItem> list = ser.Deserialize(strm) as List<Queue.QueueItem>;\r
+                        if (list.Count != 0)\r
+                            return true;\r
                     }\r
                 }\r
+                return false;\r
             }\r
             catch (Exception)\r
             {\r
-                // Keep quiet about the error.\r
-                return false;\r
+                return false; // Keep quiet about the error.\r
             }\r
         }\r
 \r
index 3e8b18e..b2d2ee6 100644 (file)
@@ -19,20 +19,6 @@ namespace Handbrake.Functions
         #region Varibles\r
 \r
         #region Source\r
-\r
-        private string q_source;\r
-        /// <summary>\r
-        /// Returns a String \r
-        /// Full path of the source.\r
-        /// </summary>\r
-        public string Source\r
-        {\r
-            get\r
-            {\r
-                return this.q_source;\r
-            }\r
-        }\r
-\r
         private int q_dvdTitle;\r
         /// <summary>\r
         /// Returns an Integer\r
@@ -74,20 +60,6 @@ namespace Handbrake.Functions
 #endregion\r
 \r
         #region Destination\r
-\r
-        private string q_destination;\r
-        /// <summary>\r
-        /// Returns a String \r
-        /// Full path of the destination.\r
-        /// </summary>\r
-        public string Destination\r
-        {\r
-            get\r
-            {\r
-                return this.q_destination;\r
-            }\r
-        }\r
-\r
         private string q_format;\r
         /// <summary>\r
         /// Returns a String \r
@@ -811,16 +783,16 @@ namespace Handbrake.Functions
             QueryParser thisQuery = new QueryParser();\r
 \r
             #region Regular Expressions\r
+            // Useful Destination Finder\r
+            //Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9?';!^%&*()_\-:\\\s\.]+)(?:\"")");\r
+            //Match source = r1.Match(input.Replace('"', '\"'));\r
+\r
             //Source\r
-            Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9_\-:\\\s\.]+)(?:\"")");\r
-            Match source = r1.Match(input.Replace('"', '\"'));\r
             Match title = Regex.Match(input, @"-t ([0-9]*)");\r
             Match chapters = Regex.Match(input, @"-c ([0-9-]*)");\r
             Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");\r
 \r
             //Destination\r
-            Regex r2 = new Regex(@"(-o)(?:\s\"")([a-zA-Z0-9_\-:\\\s\.]+)(?:\"")");\r
-            Match destination = r2.Match(input.Replace('"', '\"'));\r
             Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");\r
 \r
             //Picture Settings Tab\r
@@ -896,12 +868,9 @@ namespace Handbrake.Functions
             #region Set Varibles\r
             try\r
             {\r
-      \r
                 #region Source Tab\r
-\r
-                thisQuery.q_source = source.ToString().Replace("-i ", "").Replace("\"", "");\r
                 if (title.Success != false)\r
-                    thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));\r
+                           thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));\r
 \r
                 if (chapters.Success != false)\r
                 {\r
@@ -923,11 +892,8 @@ namespace Handbrake.Functions
                 #endregion\r
 \r
                 #region Destination\r
-                thisQuery.q_destination = destination.ToString().Replace("-o ", "").Replace("\"", "");\r
-\r
-                string videoEncoderConvertion;\r
 \r
-                videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");\r
+                string videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");\r
                 switch (videoEncoderConvertion)\r
                 {\r
                     case "ffmpeg":\r
index df5258c..64d5d69 100644 (file)
     <PlatformTarget>x86</PlatformTarget>\r
   </PropertyGroup>\r
   <ItemGroup>\r
-    <Reference Include="PresentationCore">\r
-      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
-    </Reference>\r
-    <Reference Include="PresentationFramework">\r
-      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
-    </Reference>\r
     <Reference Include="System" />\r
     <Reference Include="System.Data" />\r
     <Reference Include="System.Deployment" />\r
     <Reference Include="System.Drawing" />\r
     <Reference Include="System.Messaging" />\r
     <Reference Include="System.Windows.Forms" />\r
-    <Reference Include="System.Xml" />\r
-    <Reference Include="UIAutomationProvider">\r
-      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
-    </Reference>\r
-    <Reference Include="WindowsBase">\r
-      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
-    </Reference>\r
+    <Reference Include="System.XML" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <Compile Include="frmActivityWindow.cs">\r
     <Compile Include="Functions\Main.cs" />\r
     <Compile Include="Presets\preset.cs" />\r
     <Compile Include="Presets\PresetsHandler.cs" />\r
-    <Compile Include="Functions\Queue.cs" />\r
+    <Compile Include="Queue\QueueHandler.cs" />\r
     <Compile Include="Functions\AppcastReader.cs" />\r
     <Compile Include="Functions\Encode.cs" />\r
     <Compile Include="Functions\QueryParser.cs" />\r
     <Compile Include="frmSplashScreen.Designer.cs">\r
       <DependentUpon>frmSplashScreen.cs</DependentUpon>\r
     </Compile>\r
+    <Compile Include="Queue\QueueItem.cs" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <Content Include="handbrakepineapple.ico" />\r
similarity index 61%
rename from win/C#/Functions/Queue.cs
rename to win/C#/Queue/QueueHandler.cs
index 3afca7d..6810dec 100644 (file)
@@ -4,16 +4,18 @@ using System.Text;
 using System.Collections;\r
 using System.IO;\r
 using System.Windows.Forms;\r
+using System.Xml.Serialization;\r
 \r
-namespace Handbrake.Functions\r
+namespace Handbrake.Queue\r
 {\r
     public class Queue\r
     {\r
-        ArrayList queue = new ArrayList();\r
-        ArrayList lastQuery;\r
+        private static XmlSerializer ser = new XmlSerializer(typeof(List<QueueItem>));\r
+        List<QueueItem> queue = new List<QueueItem>();\r
         int id = 0; // Unique identifer number for each job\r
+        private QueueItem lastItem;\r
 \r
-        public ArrayList getQueue()\r
+        public List<QueueItem> getQueue()\r
         {\r
              return queue;\r
         }\r
@@ -22,24 +24,35 @@ namespace Handbrake.Functions
         /// Get's the next CLI query for encoding\r
         /// </summary>\r
         /// <returns>String</returns>\r
-        public String getNextItemForEncoding()\r
+        public string getNextItemForEncoding()\r
         {\r
-            Object query = queue[0];\r
-            lastQuery = (ArrayList)query;\r
+            QueueItem job = queue[0];\r
+            String query = job.Query;\r
+            lastItem = job;\r
             remove(0);    // Remove the item which we are about to pass out.\r
-            return lastQuery[1].ToString();\r
+            return query;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get the last query that was returned by getNextItemForEncoding()\r
+        /// </summary>\r
+        /// <returns></returns>\r
+        public QueueItem getLastQuery()\r
+        {\r
+            return lastItem;\r
         }\r
 \r
         /// <summary>\r
         /// Add's a new item to the queue\r
         /// </summary>\r
         /// <param name="query">String</param>\r
-        public void add(string query)\r
+        public void add(string query, string source, string destination)\r
         {\r
-            // Creates a new job with a unique identifer and cli query\r
-            ArrayList newJob = new ArrayList();\r
-            newJob.Add(id);\r
-            newJob.Add(query);\r
+            QueueItem newJob = new QueueItem();\r
+            newJob.Id = id;\r
+            newJob.Query = query;\r
+            newJob.Source = source;\r
+            newJob.Destination = destination;\r
             id++;\r
 \r
             // Adds the job to the queue\r
@@ -67,15 +80,6 @@ namespace Handbrake.Functions
         }\r
 \r
         /// <summary>\r
-        /// Get's the last query to be selected for encoding by getNextItemForEncoding()\r
-        /// </summary>\r
-        /// <returns>String</returns>\r
-        public string getLastQuery()\r
-        {\r
-            return lastQuery[1].ToString();\r
-        }\r
-\r
-        /// <summary>\r
         /// Move an item with an index x, up in the queue\r
         /// </summary>\r
         /// <param name="index">Int</param>\r
@@ -83,7 +87,7 @@ namespace Handbrake.Functions
         {\r
             if (index != 0)\r
             {\r
-                ArrayList item = (ArrayList)queue[index];\r
+                QueueItem item = (QueueItem)queue[index];\r
 \r
                 queue.Insert((index - 1), item);\r
                 queue.RemoveAt((index + 1));\r
@@ -98,7 +102,7 @@ namespace Handbrake.Functions
         {\r
             if (index != queue.Count - 1)\r
             {\r
-                ArrayList item = (ArrayList)queue[index];\r
+                QueueItem item = (QueueItem)queue[index];\r
 \r
                 queue.Insert((index + 2), item);\r
                 queue.RemoveAt((index));\r
@@ -106,31 +110,30 @@ namespace Handbrake.Functions
         }\r
 \r
         /// <summary>\r
-        /// Writes the current queue to disk. hb_queue_recovery.dat\r
+        /// Writes the current queue to disk. hb_queue_recovery.xml\r
         /// This function is called after getNextItemForEncoding()\r
         /// </summary>\r
         public void write2disk(string file)\r
         {\r
+            string tempPath = "";\r
+            if (file == "hb_queue_recovery.xml")\r
+                tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
+            else\r
+                tempPath = file;\r
+\r
             try\r
             {\r
-                string tempPath = "";\r
-                if (file == "hb_queue_recovery.dat")\r
-                    tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat");\r
-                else\r
-                    tempPath = file;\r
-                using (StreamWriter writer = new StreamWriter(tempPath))\r
+                using (FileStream strm = new FileStream(tempPath, FileMode.Create, FileAccess.Write))\r
                 {\r
-                    foreach (ArrayList item in queue)\r
-                    {\r
-                        writer.WriteLine(item[1].ToString());\r
-                    }\r
-                    writer.Close();\r
-                    writer.Dispose();\r
+                    ser.Serialize(strm, queue);\r
+                    strm.Close();\r
+                    strm.Dispose();\r
                 }\r
             }\r
             catch (Exception)\r
             {\r
-                // Any Errors will be out of diskspace/permissions problems. Don't report them as they'll annoy the user.\r
+                // Any Errors will be out of diskspace/permissions problems. \r
+                // Don't report them as they'll annoy the user.\r
             }\r
         }\r
 \r
@@ -141,9 +144,9 @@ namespace Handbrake.Functions
         public void writeBatchScript(string file)\r
         {\r
             string queries = "";\r
-            foreach (ArrayList queue_item in queue)\r
+            foreach (QueueItem queue_item in queue)\r
             {\r
-                string q_item = queue_item[1].ToString();\r
+                string q_item = queue_item.Query;\r
                 string fullQuery = '"' + Application.StartupPath.ToString() + "\\HandBrakeCLI.exe" + '"' + q_item;\r
 \r
                 if (queries == string.Empty)\r
@@ -174,33 +177,29 @@ namespace Handbrake.Functions
         }\r
 \r
         /// <summary>\r
-        /// Recover the queue from hb_queue_recovery.dat\r
+        /// Recover the queue from hb_queue_recovery.xml\r
         /// </summary>\r
         public void recoverQueue(string file)\r
         {\r
-            try\r
+            string tempPath = "";\r
+            if (file == "hb_queue_recovery.xml")\r
+                tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
+            else\r
+                tempPath = file;\r
+\r
+            if (File.Exists(tempPath))\r
             {\r
-                string tempPath = "";\r
-                if (file == "hb_queue_recovery.dat")\r
-                    tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat");\r
-                else\r
-                    tempPath = file;\r
-                using (StreamReader reader = new StreamReader(tempPath))\r
+                using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))\r
                 {\r
-                    string queue_item = reader.ReadLine();\r
-\r
-                    while (queue_item != null)\r
+                    if (strm.Length != 0)\r
                     {\r
-                        this.add(queue_item);\r
-                        queue_item = reader.ReadLine();\r
+                        List<QueueItem> list = ser.Deserialize(strm) as List<QueueItem>;\r
+\r
+                        foreach (QueueItem item in list)\r
+                            queue.Add(item);\r
                     }\r
                 }\r
             }\r
-            catch (Exception exc)\r
-            {\r
-                MessageBox.Show("HandBrake was unable to recover the queue. \nError Information:" + exc.ToString(), "Queue Recovery Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-            }\r
         }\r
-\r
     }\r
 }\r
diff --git a/win/C#/Queue/QueueItem.cs b/win/C#/Queue/QueueItem.cs
new file mode 100644 (file)
index 0000000..1639b16
--- /dev/null
@@ -0,0 +1,50 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Handbrake.Queue\r
+{\r
+    public class QueueItem\r
+    {\r
+        private int id;\r
+        private string query;\r
+        private string source;\r
+        private string destination;\r
+\r
+        /// <summary>\r
+        /// Get or Set the job id.\r
+        /// </summary>\r
+        public int Id\r
+        {\r
+            get { return id; }\r
+            set { this.id = value; }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get or Set the query string.\r
+        /// </summary>\r
+        public string Query\r
+        {\r
+            get { return query; }\r
+            set { this.query = value; }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get or set the source file of encoding\r
+        /// </summary>\r
+        public string Source\r
+        {\r
+            get { return source; }\r
+            set { this.source = value; }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get or set the destination for the file to be encoded.\r
+        /// </summary>\r
+        public string Destination\r
+        {\r
+            get { return destination; }\r
+            set { this.destination = value; }\r
+        }\r
+    }\r
+}\r
index 1496646..59ae27b 100644 (file)
@@ -25,7 +25,7 @@ namespace Handbrake
         // Objects which may be used by one or more other objects\r
         Functions.Main hb_common_func = new Functions.Main();\r
         Functions.Encode cliObj = new Functions.Encode();\r
-        Functions.Queue encodeQueue = new Functions.Queue();\r
+        Queue.Queue encodeQueue = new Queue.Queue();\r
         Presets.PresetsHandler presetHandler = new Presets.PresetsHandler();\r
         Parsing.Title selectedTitle;\r
 \r
@@ -184,11 +184,11 @@ namespace Handbrake
                 DialogResult result = MessageBox.Show("HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?", "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
 \r
                 if (result == DialogResult.Yes)\r
-                    encodeQueue.recoverQueue("hb_queue_recovery.dat"); // Start Recovery\r
+                    encodeQueue.recoverQueue("hb_queue_recovery.xml"); // Start Recovery\r
                 else\r
                 {\r
                     // Remove the Queue recovery file if the user doesn't want to recovery the last queue.\r
-                    string queuePath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat");\r
+                    string queuePath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
                     if (File.Exists(queuePath))\r
                         File.Delete(queuePath);\r
                 }\r
@@ -397,8 +397,8 @@ namespace Handbrake
                 if (rtf_query.Text != "")\r
                     query = rtf_query.Text;\r
 \r
-                encodeQueue.add(query);\r
-                encodeQueue.write2disk("hb_queue_recovery.dat"); // Writes the queue to the recovery file, just incase the GUI crashes.\r
+                encodeQueue.add(query, text_source.Text, text_destination.Text);\r
+                encodeQueue.write2disk("hb_queue_recovery.xml"); // Writes the queue to the recovery file, just incase the GUI crashes.\r
 \r
                 queueWindow.setQueue(encodeQueue);\r
                 queueWindow.Show();\r
@@ -1919,7 +1919,7 @@ namespace Handbrake
 \r
                 // After the encode is done, we may want to shutdown, suspend etc.\r
                 cliObj.addCLIQueryToLog((string)state);\r
-                cliObj.copyLog((string)state); // Make a copy of the log in the users desired location if necessary\r
+                cliObj.copyLog((string)state, text_destination.Text); // Make a copy of the log in the users desired location if necessary\r
                 cliObj.afterEncodeAction();\r
             }\r
         }\r
index 88acf24..765c940 100644 (file)
@@ -26,7 +26,7 @@ namespace Handbrake
         Functions.Encode cliObj = new Functions.Encode();\r
         Boolean cancel = false;\r
         Process hbProc = null;\r
-        Functions.Queue queue;\r
+        Queue.Queue queue;\r
         frmMain mainWindow = null;\r
 \r
         public frmQueue(frmMain main)\r
@@ -39,11 +39,20 @@ namespace Handbrake
         /// Initializes the Queue list with the Arraylist from the Queue class\r
         /// </summary>\r
         /// <param name="qw"></param>\r
-        public void setQueue(Functions.Queue qw)\r
+        public void setQueue(Queue.Queue qw)\r
         {\r
             queue = qw;\r
             redrawQueue();\r
             lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";\r
+\r
+            // Recalculate the progress bar, but only if the queue has already started.       \r
+            if (progressBar.Value != 0)\r
+            {\r
+                progressBar.Value = 0;\r
+                progressBar.Step = 100 / queue.count();\r
+                progressBar.PerformStep();\r
+                lbl_progressValue.Text = string.Format("{0} %", progressBar.Value);\r
+            }\r
         }\r
 \r
         /// <summary>\r
@@ -62,10 +71,10 @@ namespace Handbrake
         private void redrawQueue()\r
         {\r
             list_queue.Items.Clear();\r
-            ArrayList theQueue = queue.getQueue();\r
-            foreach (ArrayList queue_item in theQueue)\r
+            List<Queue.QueueItem> theQueue = queue.getQueue();\r
+            foreach (Queue.QueueItem queue_item in theQueue)\r
             {\r
-                string q_item = queue_item[1].ToString();\r
+                string q_item = queue_item.Query;\r
                 Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item);\r
 \r
                 // Get the DVD Title\r
@@ -89,8 +98,8 @@ namespace Handbrake
                 ListViewItem item = new ListViewItem();\r
                 item.Text = title; // Title\r
                 item.SubItems.Add(chapters); // Chapters\r
-                item.SubItems.Add(parsed.Source); // Source\r
-                item.SubItems.Add(parsed.Destination); // Destination\r
+                item.SubItems.Add(queue_item.Source); // Source\r
+                item.SubItems.Add(queue_item.Destination); // Destination\r
                 item.SubItems.Add(parsed.VideoEncoder); // Video\r
                 item.SubItems.Add(parsed.AudioEncoder1); // Audio\r
 \r
@@ -139,7 +148,7 @@ namespace Handbrake
                 while (queue.count() != 0)\r
                 {\r
                     string query = queue.getNextItemForEncoding();\r
-                    queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file\r
+                    queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
 \r
                     setEncValue();\r
                     updateUIElements();\r
@@ -148,7 +157,7 @@ namespace Handbrake
 \r
                     hbProc.WaitForExit();\r
                     cliObj.addCLIQueryToLog(query);\r
-                    cliObj.copyLog(query);\r
+                    cliObj.copyLog(query, queue.getLastQuery().Destination);\r
 \r
                     hbProc.Close();\r
                     hbProc.Dispose();\r
@@ -255,9 +264,9 @@ namespace Handbrake
                 }\r
 \r
                 // found query is a global varible\r
-                Functions.QueryParser parsed = Functions.QueryParser.Parse(queue.getLastQuery());\r
-                lbl_source.Text = parsed.Source;\r
-                lbl_dest.Text = parsed.Destination;\r
+                Functions.QueryParser parsed = Functions.QueryParser.Parse(queue.getLastQuery().Query);\r
+                lbl_source.Text = queue.getLastQuery().Source;\r
+                lbl_dest.Text = queue.getLastQuery().Destination;\r
 \r
 \r
                 if (parsed.DVDTitle == 0)\r
@@ -295,7 +304,7 @@ namespace Handbrake
                 int selected = list_queue.SelectedIndices[0];\r
 \r
                 queue.moveUp(selected);\r
-                queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file\r
+                queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
                 redrawQueue();\r
 \r
                 if (selected - 1 > 0) \r
@@ -313,7 +322,7 @@ namespace Handbrake
                 int selected = list_queue.SelectedIndices[0];\r
 \r
                 queue.moveDown(list_queue.SelectedIndices[0]);\r
-                queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file\r
+                queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
                 redrawQueue();\r
 \r
                 if (selected +1 < list_queue.Items.Count) \r
@@ -329,7 +338,7 @@ namespace Handbrake
             if (list_queue.SelectedIndices.Count != 0)\r
             {\r
                 queue.remove(list_queue.SelectedIndices[0]);\r
-                queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file\r
+                queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
                 redrawQueue();\r
                 lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";\r
             }\r
@@ -373,7 +382,7 @@ namespace Handbrake
                 if (list_queue.SelectedIndices.Count != 0)\r
                 {\r
                     queue.remove(list_queue.SelectedIndices[0]);\r
-                    queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file\r
+                    queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file\r
                     redrawQueue();\r
                 }\r
             }\r
@@ -393,6 +402,5 @@ namespace Handbrake
             base.OnClosing(e);\r
         }\r
 \r
-\r
     }\r
 }
\ No newline at end of file