summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Services/Queue
diff options
context:
space:
mode:
authorsr55 <[email protected]>2018-07-08 14:17:17 +0100
committersr55 <[email protected]>2018-07-08 14:17:17 +0100
commit80fa15a3901017253e35bb2df064133258edcd2a (patch)
treeeb1d63cc3441bb9c7b94ad464011689b9c21c520 /win/CS/HandBrakeWPF/Services/Queue
parent325cb484bfeccb2fa371c7af010c4eb4839c5f37 (diff)
WinGui: Initial work to refactor the queue infrastructure to use the same JSON format as the CLI + extensions.
Diffstat (limited to 'win/CS/HandBrakeWPF/Services/Queue')
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs8
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs34
2 files changed, 32 insertions, 10 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs
index c907f3758..33dc42fe2 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/Interfaces/IQueueProcessor.cs
@@ -107,6 +107,14 @@ namespace HandBrakeWPF.Services.Queue.Interfaces
/// The export path.
/// </param>
void ExportJson(string exportPath);
+
+ /// <summary>
+ /// Restore a JSON queue file.
+ /// </summary>
+ /// <param name="path">
+ /// Path to the file the user wishes to import.
+ /// </param>
+ void ImportJson(string path);
/// <summary>
/// Checks the current queue for an existing instance of the specified destination.
diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
index 5a701045f..aa17ea5b0 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
@@ -16,6 +16,7 @@ namespace HandBrakeWPF.Services.Queue
using System.Linq;
using System.Xml.Serialization;
+ using HandBrake.Interop.Interop.Json.Queue;
using HandBrake.Interop.Model;
using HandBrake.Interop.Utilities;
@@ -43,10 +44,6 @@ namespace HandBrakeWPF.Services.Queue
public class QueueProcessor : Interfaces.IQueueProcessor
{
#region Constants and Fields
-
- /// <summary>
- /// A Lock object to maintain thread safety
- /// </summary>
private static readonly object QueueLock = new object();
private readonly IUserSettingService userSettingService;
private readonly BindingList<QueueTask> queue = new BindingList<QueueTask>();
@@ -228,12 +225,6 @@ namespace HandBrakeWPF.Services.Queue
}
}
- /// <summary>
- /// Export the Queue the standardised JSON format.
- /// </summary>
- /// <param name="exportPath">
- /// The export Path.
- /// </param>
public void ExportJson(string exportPath)
{
List<QueueTask> jobs = this.queue.Where(item => item.Status != QueueItemStatus.Completed).ToList();
@@ -250,6 +241,29 @@ namespace HandBrakeWPF.Services.Queue
}
}
+ public void ImportJson(string path)
+ {
+ List<Task> tasks;
+ using (StreamReader reader = new StreamReader(path))
+ {
+ string fileContent = reader.ReadToEnd();
+ tasks = QueueFactory.GetQueue(fileContent);
+
+ if (tasks != null)
+ {
+ foreach (Task task in tasks)
+ {
+ // TODO flesh out.
+ EncodeTask encodeTask = EncodeTaskImportFactory.Create(task.Job);
+ QueueTask queueTask = new QueueTask();
+ queueTask.Task = encodeTask;
+
+ this.queue.Add(queueTask);
+ }
+ }
+ }
+ }
+
/// <summary>
/// Checks the current queue for an existing instance of the specified destination.
/// </summary>