summaryrefslogtreecommitdiffstats
path: root/win/C#/HandBrake.ApplicationServices/Services/Queue.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2010-07-15 20:15:08 +0000
committersr55 <[email protected]>2010-07-15 20:15:08 +0000
commit6c9b4d2c4cf5928bb2b472beca76c2edc4c41f03 (patch)
tree85ba020472dfb475f4db0424ed139da20fa6b64e /win/C#/HandBrake.ApplicationServices/Services/Queue.cs
parent5c8cab7ea3c07e36b74bcb8c8198f8ef796e1530 (diff)
WinGui:
- Multiple instance support. Each instance has a unique id. id = 0 will use the standard log/queue files. id = 1,2...n will use standard file names but with the instance id added to the end. This means that each instance will have it's own queue. Queue is not shared between Instances If multiple queue files are found when starting up, it will offer to load them all in. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3440 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/HandBrake.ApplicationServices/Services/Queue.cs')
-rw-r--r--win/C#/HandBrake.ApplicationServices/Services/Queue.cs37
1 files changed, 23 insertions, 14 deletions
diff --git a/win/C#/HandBrake.ApplicationServices/Services/Queue.cs b/win/C#/HandBrake.ApplicationServices/Services/Queue.cs
index da32d2503..7ba1d9d31 100644
--- a/win/C#/HandBrake.ApplicationServices/Services/Queue.cs
+++ b/win/C#/HandBrake.ApplicationServices/Services/Queue.cs
@@ -104,7 +104,7 @@ namespace HandBrake.ApplicationServices.Services
this.LastEncode = job;
this.Remove(0); // Remove the item which we are about to pass out.
- this.WriteQueueStateToFile("hb_queue_recovery.xml");
+ this.SaveQueue();
return job;
}
@@ -140,7 +140,7 @@ namespace HandBrake.ApplicationServices.Services
};
this.queue.Add(newJob);
- this.WriteQueueStateToFile("hb_queue_recovery.xml");
+ this.SaveQueue();
if (this.QueueListChanged != null)
this.QueueListChanged(this, new EventArgs());
@@ -153,7 +153,7 @@ namespace HandBrake.ApplicationServices.Services
public void Remove(int index)
{
this.queue.RemoveAt(index);
- this.WriteQueueStateToFile("hb_queue_recovery.xml");
+ this.SaveQueue();
if (this.QueueListChanged != null)
this.QueueListChanged(this, new EventArgs());
@@ -186,7 +186,7 @@ namespace HandBrake.ApplicationServices.Services
queue.Insert((index - 1), item);
}
- WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file
+ this.SaveQueue(); // Update the queue recovery file
if (this.QueueListChanged != null)
this.QueueListChanged(this, new EventArgs());
@@ -206,11 +206,22 @@ namespace HandBrake.ApplicationServices.Services
this.queue.Insert((index + 1), item);
}
- this.WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file
+ this.SaveQueue(); // Update the queue recovery file
if (this.QueueListChanged != null)
this.QueueListChanged(this, new EventArgs());
}
+
+ /// <summary>
+ /// Save any updates to the main queue file.
+ /// </summary>
+ public void SaveQueue()
+ {
+ string file = Init.InstanceId == 0
+ ? "hb_queue_recovery.xml"
+ : string.Format("hb_queue_recovery{0}.xml", Init.InstanceId);
+ this.WriteQueueStateToFile(file);
+ }
/// <summary>
/// Writes the current state of the queue to a file.
@@ -218,9 +229,8 @@ namespace HandBrake.ApplicationServices.Services
/// <param name="file">The location of the file to write the queue to.</param>
public void WriteQueueStateToFile(string file)
{
- string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
- @"HandBrake\hb_queue_recovery.xml");
- string tempPath = file == "hb_queue_recovery.xml" ? appDataPath : file;
+ string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
+ string tempPath = file.Contains("hb_queue_recovery") ? appDataPath + file : file;
try
{
@@ -285,9 +295,8 @@ namespace HandBrake.ApplicationServices.Services
/// <param name="file">The location of the file to read the queue from.</param>
public void LoadQueueFromFile(string file)
{
- string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
- @"HandBrake\hb_queue_recovery.xml");
- string tempPath = file == "hb_queue_recovery.xml" ? appDataPath : file;
+ string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
+ string tempPath = file.Contains("hb_queue_recovery") ? appDataPath + file : file;
if (File.Exists(tempPath))
{
@@ -304,8 +313,8 @@ namespace HandBrake.ApplicationServices.Services
foreach (Job item in list)
this.queue.Add(item);
- if (file != "hb_queue_recovery.xml")
- this.WriteQueueStateToFile("hb_queue_recovery.xml");
+ if (!file.Contains("hb_queue_recovery"))
+ this.SaveQueue();
if (this.QueueListChanged != null)
this.QueueListChanged(this, new EventArgs());
@@ -378,7 +387,7 @@ namespace HandBrake.ApplicationServices.Services
while (this.Count != 0)
{
Job encJob = this.GetNextJob();
- this.WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file
+ this.SaveQueue(); // Update the queue recovery file
Run(encJob, true);