diff options
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
6 files changed, 65 insertions, 111 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs index 0600de5d0..e05e37aa9 100644 --- a/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs +++ b/win/CS/HandBrake.ApplicationServices/ASUserSettingConstants.cs @@ -119,5 +119,10 @@ namespace HandBrake.ApplicationServices /// Preview Scan Count
/// </summary>
public const string PreviewScanCount = "previewScanCount";
+
+ /// <summary>
+ /// Clear completed items from the queue automatically.
+ /// </summary>
+ public const string ClearCompletedFromQueue = "ClearCompletedFromQueue";
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs b/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs index f0514805c..6848ce3ab 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/QueueTask.cs @@ -51,38 +51,11 @@ namespace HandBrake.ApplicationServices.Model public bool CustomQuery { get; set; }
/// <summary>
- /// Gets or sets Destination.
- /// </summary>
- public string Destination { get; set; }
-
- /// <summary>
- /// Gets or sets the job ID.
- /// </summary>
- public int Id { get; set; }
-
- /// <summary>
- /// Gets a value indicating whether or not this instance is empty.
- /// </summary>
- public bool IsEmpty
- {
- get
- {
- return this.Id == 0 && string.IsNullOrEmpty(this.Query) && string.IsNullOrEmpty(this.Task.Source) &&
- string.IsNullOrEmpty(this.Task.Destination);
- }
- }
-
- /// <summary>
/// Gets or sets the query string.
/// </summary>
public string Query { get; set; }
/// <summary>
- /// Gets or sets Source.
- /// </summary>
- public string Source { get; set; }
-
- /// <summary>
/// Gets or sets Status.
/// </summary>
public QueueItemStatus Status
@@ -104,11 +77,6 @@ namespace HandBrake.ApplicationServices.Model /// </summary>
public EncodeTask Task { get; set; }
- /// <summary>
- /// Gets or sets Title.
- /// </summary>
- public int Title { get; set; }
-
#endregion
}
}
\ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs index e2eacce72..d57f3a51f 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs @@ -366,7 +366,7 @@ namespace HandBrake.ApplicationServices.Services.Base // Make sure the path exists, attempt to create it if it doesn't
try
{
- string path = Directory.GetParent(task.Destination ?? task.Task.Destination).ToString();
+ string path = Directory.GetParent(task.Task.Destination).ToString();
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs index 7c60d1e86..1ce362449 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs @@ -154,8 +154,6 @@ namespace HandBrake.ApplicationServices.Services {
lock (QueueLock)
{
- // Tag the job with an ID
- job.Id = lastJobId++;
queue.Add(job);
InvokeQueueChanged(EventArgs.Empty);
}
@@ -366,7 +364,7 @@ namespace HandBrake.ApplicationServices.Services /// <returns>Whether or not the supplied destination is already in the queue.</returns>
public bool CheckForDestinationPathDuplicates(string destination)
{
- return this.queue.Any(checkItem => checkItem.Destination.Contains(destination.Replace("\\\\", "\\")));
+ return this.queue.Any(checkItem => checkItem.Task.Destination.Contains(destination.Replace("\\\\", "\\")));
}
/// <summary>
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs index ce3a756ed..1deeb0d44 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs @@ -201,6 +201,12 @@ namespace HandBrake.ApplicationServices.Services {
this.QueueManager.LastProcessedJob.Status = QueueItemStatus.Completed;
+ // Clear the completed item of the queue if the setting is set.
+ if (userSettingService.GetUserSetting<bool>(ASUserSettingConstants.ClearCompletedFromQueue))
+ {
+ this.QueueManager.ClearCompleted();
+ }
+
// Growl
if (userSettingService.GetUserSetting<bool>(ASUserSettingConstants.GrowlEncode))
GrowlCommunicator.Notify("Encode Completed",
@@ -218,12 +224,12 @@ namespace HandBrake.ApplicationServices.Services }
// Handling Log Data
- this.EncodeService.ProcessLogs(this.QueueManager.LastProcessedJob.Destination);
+ this.EncodeService.ProcessLogs(this.QueueManager.LastProcessedJob.Task.Destination);
// Post-Processing
if (e.Successful)
{
- SendToApplication(this.QueueManager.LastProcessedJob.Destination);
+ SendToApplication(this.QueueManager.LastProcessedJob.Task.Destination);
}
// Move onto the next job.
diff --git a/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs b/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs index d8e537bdc..c36b5ec49 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs @@ -6,9 +6,9 @@ namespace HandBrake.ApplicationServices.Services
{
using System;
- using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
+ using System.Linq;
using System.Windows.Forms;
using System.Xml.Serialization;
@@ -44,7 +44,7 @@ namespace HandBrake.ApplicationServices.Services this.Load();
if (userSettings == null || userSettings.Count == 0)
{
- this.LoadDefaults();
+ this.userSettings = this.GetDefaults();
}
}
@@ -104,15 +104,25 @@ namespace HandBrake.ApplicationServices.Services /// </summary>
private void Save()
{
- string directory = Path.GetDirectoryName(this.settingsFile);
- if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
+ try
{
- Directory.CreateDirectory(directory);
- }
+ string directory = Path.GetDirectoryName(this.settingsFile);
+ if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
+ {
+ Directory.CreateDirectory(directory);
+ }
- using (FileStream strm = new FileStream(this.settingsFile, FileMode.Create, FileAccess.Write))
+ using (FileStream strm = new FileStream(this.settingsFile, FileMode.Create, FileAccess.Write))
+ {
+ serializer.Serialize(strm, this.userSettings);
+ }
+ }
+ catch (Exception exc)
{
- serializer.Serialize(strm, this.userSettings);
+ throw new GeneralApplicationException(
+ "A problem occured when trying to save your preferences.",
+ "Any settings you changed may need to be reset the next time HandBrake launches.",
+ exc);
}
}
@@ -129,7 +139,16 @@ namespace HandBrake.ApplicationServices.Services {
SerializableDictionary<string, object> data = (SerializableDictionary<string, object>)serializer.Deserialize(reader);
this.userSettings = data;
+
+ // Add any new settings
+ SerializableDictionary<string, object> defaults = this.GetDefaults();
+ foreach (var item in defaults.Where(item => !this.userSettings.Keys.Contains(item.Key)))
+ {
+ this.userSettings.Add(item.Key, item.Value);
+ }
}
+
+ this.Save();
}
}
catch (Exception exc)
@@ -144,76 +163,34 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// Load Default Settings
/// </summary>
- private void LoadDefaults()
+ /// <returns>
+ /// The get defaults.
+ /// </returns>
+ private SerializableDictionary<string, object> GetDefaults()
{
- string defaults = Path.Combine(Application.StartupPath, "defaultsettings.xml");
- if (File.Exists(defaults))
+ try
{
- using (StreamReader reader = new StreamReader(defaults))
+ string defaults = Path.Combine(Application.StartupPath, "defaultsettings.xml");
+ if (File.Exists(defaults))
{
- SerializableDictionary<string, object> data = (SerializableDictionary<string, object>)serializer.Deserialize(reader);
- this.userSettings = data;
+ using (StreamReader reader = new StreamReader(defaults))
+ {
+ return (SerializableDictionary<string, object>)serializer.Deserialize(reader);
+ }
}
- }
- }
- /// <summary>
- /// This is just a utility method for creating a defaults xml file. Don't use this!!!
- /// </summary>
- private void SetAllDefaults()
- {
- userSettings = new SerializableDictionary<string, object>();
- userSettings[ASUserSettingConstants.X264Step] = 0.25;
- userSettings[ASUserSettingConstants.Verbosity] = 1;
- userSettings[ASUserSettingConstants.WhenCompleteAction] = "Do Nothing";
- userSettings[ASUserSettingConstants.GrowlEncode] = false;
- userSettings[ASUserSettingConstants.GrowlQueue] = false;
- userSettings[ASUserSettingConstants.ProcessPriority] = "Below Normal";
- userSettings[ASUserSettingConstants.PreventSleep] = true;
- userSettings[ASUserSettingConstants.ShowCLI] = false;
- userSettings[ASUserSettingConstants.SaveLogToCopyDirectory] = false;
- userSettings[ASUserSettingConstants.SaveLogWithVideo] = false;
- userSettings[ASUserSettingConstants.DisableLibDvdNav] = false;
- userSettings[ASUserSettingConstants.SendFile] = false;
- userSettings[ASUserSettingConstants.MinScanDuration] = 10;
- userSettings[ASUserSettingConstants.HandBrakeBuild] = 0;
- userSettings[ASUserSettingConstants.HandBrakeVersion] = string.Empty;
- userSettings["updateStatus"] = true;
- userSettings["tooltipEnable"] = true;
- userSettings["defaultPreset"] = string.Empty;
- userSettings["skipversion"] = 0;
- userSettings["autoNaming"] = true;
- userSettings["autoNamePath"] = string.Empty;
- userSettings["appcast_i686"] = "http://handbrake.fr/appcast.i386.xml";
- userSettings["appcast_x64"] = "http://handbrake.fr/appcast_unstable.x86_64.xml";
- userSettings["autoNameFormat"] = "{source}-{title}";
- userSettings["VLC_Path"] = "C:\\Program Files\\VideoLAN\\vlc\\vlc.exe";
- userSettings["MainWindowMinimize"] = true;
- userSettings["QueryEditorTab"] = false;
- userSettings["presetNotification"] = false;
- userSettings["trayIconAlerts"] = true;
- userSettings["lastUpdateCheckDate"] = DateTime.Today;
- userSettings["daysBetweenUpdateCheck"] = 7;
- userSettings["useM4v"] = 0;
- userSettings["PromptOnUnmatchingQueries"] = true;
- userSettings["NativeLanguage"] = "Any";
- userSettings["DubMode"] = 255;
- userSettings["HandBrakeExeHash"] = string.Empty;
- userSettings["previewScanCount"] = 10;
- userSettings["clearOldLogs"] = true;
- userSettings["AutoNameTitleCase"] = true;
- userSettings["AutoNameRemoveUnderscore"] = true;
- userSettings["ActivityWindowLastMode"] = 0;
- userSettings["useClosedCaption"] = false;
- userSettings["batchMinDuration"] = "00:18:00";
- userSettings["batchMaxDuration"] = "02:30:00";
- userSettings["defaultPlayer"] = false;
- userSettings["SelectedLanguages"] = new StringCollection();
- userSettings["DubModeAudio"] = 0;
- userSettings["DubModeSubtitle"] = 0;
- userSettings["addOnlyOneAudioPerLanguage"] = true;
- userSettings["MinTitleLength"] = 10;
- userSettings["ShowAdvancedAudioPassthruOpts"] = false;
+ throw new GeneralApplicationException(
+ "User default settings file is missing. This install of HandBrake may be corrupted.",
+ "Try re-installing HandBrake.",
+ null);
+ }
+ catch (Exception exc)
+ {
+ throw new GeneralApplicationException(
+ "User default settings file is missing or inaccessible. This install of HandBrake may be corrupted.",
+ "Try re-installing HandBrake.",
+ exc);
+ }
}
}
}
|