From c0ad015d6ef51b4edf229d98803d35c781e8b67f Mon Sep 17 00:00:00 2001 From: sr55 Date: Thu, 22 Aug 2013 17:02:19 +0000 Subject: WinGui: Strip out legacy CLI scan code. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5732 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrake.ApplicationServices.csproj | 4 - .../Isolation/BackgroundServiceConnector.cs | 35 -- .../Isolation/IsolatedScanService.cs | 216 ------------ .../HandBrake.ApplicationServices/Parsing/Audio.cs | 5 + .../Parsing/AudioHelper.cs | 95 ----- .../Parsing/Chapter.cs | 63 +--- .../Parsing/Parser.cs | 134 ------- .../Parsing/Source.cs | 30 -- .../Parsing/Subtitle.cs | 90 +---- .../HandBrake.ApplicationServices/Parsing/Title.cs | 135 ------- .../Services/Interfaces/IHbServiceCallback.cs | 24 -- .../Services/Interfaces/IServerService.cs | 46 --- .../Services/ScanService.cs | 389 --------------------- .../Services/ServerService.cs | 161 +-------- 14 files changed, 11 insertions(+), 1416 deletions(-) delete mode 100644 win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs delete mode 100644 win/CS/HandBrake.ApplicationServices/Parsing/AudioHelper.cs delete mode 100644 win/CS/HandBrake.ApplicationServices/Parsing/Parser.cs delete mode 100644 win/CS/HandBrake.ApplicationServices/Services/ScanService.cs diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 42952d432..d884131d0 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -95,7 +95,6 @@ - @@ -126,10 +125,8 @@ - - @@ -149,7 +146,6 @@ - diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs b/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs index 4044e8a61..c92946bc1 100644 --- a/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs +++ b/win/CS/HandBrake.ApplicationServices/Isolation/BackgroundServiceConnector.cs @@ -139,8 +139,6 @@ namespace HandBrake.ApplicationServices.Isolation #region Implemented Interfaces - #region IDisposable - /// /// The dispose. /// @@ -149,37 +147,6 @@ namespace HandBrake.ApplicationServices.Isolation this.Service.Unsubscribe(); } - #endregion - - #region IHbServiceCallback - - /// - /// The scan completed. - /// - /// - /// The event args. - /// - public virtual void ScanCompletedCallback(ScanCompletedEventArgs eventArgs) - { - } - - /// - /// The scan progress. - /// - /// - /// The event args. - /// - public virtual void ScanProgressCallback(ScanProgressEventArgs eventArgs) - { - } - - /// - /// The scan started callback. - /// - public virtual void ScanStartedCallback() - { - } - /// /// The encode progress callback. /// @@ -208,7 +175,5 @@ namespace HandBrake.ApplicationServices.Isolation } #endregion - - #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs deleted file mode 100644 index dcef0cc44..000000000 --- a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedScanService.cs +++ /dev/null @@ -1,216 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// Isolated Scan Service -// This is an implementation of the IScan implementation that runs scans on a seperate process -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Isolation -{ - using System; - using System.Threading; - - using HandBrake.ApplicationServices.EventArgs; - using HandBrake.ApplicationServices.Exceptions; - using HandBrake.ApplicationServices.Parsing; - using HandBrake.ApplicationServices.Services.Interfaces; - - /// - /// Isolated Scan Service. - /// This is an implementation of the IScan implementation that runs scans on a seperate process - /// - public class IsolatedScanService : BackgroundServiceConnector, IScan - { - #region Constants and Fields - - /// - /// The post action. - /// - private Action postScanAction; - - #endregion - - #region Events - - /// - /// The scan completed. - /// - public event ScanCompletedStatus ScanCompleted; - - /// - /// The scan stared. - /// - public event EventHandler ScanStared; - - /// - /// The scan status changed. - /// - public event ScanProgessStatus ScanStatusChanged; - - #endregion - - /// - /// Initializes a new instance of the class. - /// - /// - /// The port. - /// - public IsolatedScanService(string port) - { - try - { - if (this.CanConnect()) - { - this.Connect(port); - } - } - catch (Exception exception) - { - throw new GeneralApplicationException("Unable to connect to scan worker process.", "Try restarting HandBrake", exception); - } - } - - #region Properties - - /// - /// Gets ActivityLog. - /// - public string ActivityLog - { - get - { - return this.Service.ScanActivityLog; - } - } - - /// - /// Gets a value indicating whether IsScanning. - /// - public bool IsScanning - { - get - { - return this.Service.IsScanning; - } - } - - /// - /// Gets the Souce Data. - /// - public Source SouceData - { - get - { - return this.Service.SouceData; - } - } - - #endregion - - #region Public Methods - - /// - /// The scan completed callback. - /// - /// - /// The event args. - /// - public override void ScanCompletedCallback(ScanCompletedEventArgs eventArgs) - { - if (this.postScanAction != null) - { - this.postScanAction(true); - } - - if (this.ScanCompleted != null) - { - ThreadPool.QueueUserWorkItem(delegate { this.ScanCompleted(this, eventArgs); }); - } - - base.ScanCompletedCallback(eventArgs); - } - - /// - /// The scan progress callback. - /// - /// - /// The event args. - /// - public override void ScanProgressCallback(ScanProgressEventArgs eventArgs) - { - if (this.ScanStatusChanged != null) - { - ThreadPool.QueueUserWorkItem(delegate { this.ScanStatusChanged(this, eventArgs); }); - } - - base.ScanProgressCallback(eventArgs); - } - - /// - /// The scan started callback. - /// - public override void ScanStartedCallback() - { - if (this.ScanStared != null) - { - ThreadPool.QueueUserWorkItem(delegate { this.ScanStared(this, EventArgs.Empty); }); - } - - base.ScanStartedCallback(); - } - - #endregion - - #region Implemented Interfaces - - #region IScan - - /// - /// Take a Scan Log file, and process it as if it were from the CLI. - /// - /// - /// The path to the log file. - /// - public void DebugScanLog(string path) - { - throw new NotImplementedException("Not available in process isolation mode!"); - } - - /// - /// Scan a Source Path. - /// Title 0: scan all - /// - /// - /// Path to the file to scan - /// - /// - /// int title number. 0 for scan all - /// - /// - /// The preview Count. - /// - /// - /// The post Action. - /// - public void Scan(string sourcePath, int title, int previewCount, Action postAction) - { - this.postScanAction = postAction; - this.Service.ScanSource(sourcePath, title, previewCount); - } - - /// - /// Kill the scan - /// - public void Stop() - { - this.Service.StopScan(); - } - - #endregion - - #endregion - } -} \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs index b78ca5ad8..d925d2d3a 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Audio.cs @@ -128,10 +128,12 @@ namespace HandBrake.ApplicationServices.Parsing { return false; } + if (ReferenceEquals(this, other)) { return true; } + return other.TrackNumber == this.TrackNumber && object.Equals(other.Language, this.Language) && object.Equals(other.LanguageCode, this.LanguageCode) && object.Equals(other.Format, this.Format); } @@ -148,14 +150,17 @@ namespace HandBrake.ApplicationServices.Parsing { return false; } + if (ReferenceEquals(this, obj)) { return true; } + if (obj.GetType() != typeof(Audio)) { return false; } + return Equals((Audio)obj); } diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/AudioHelper.cs b/win/CS/HandBrake.ApplicationServices/Parsing/AudioHelper.cs deleted file mode 100644 index 43c331337..000000000 --- a/win/CS/HandBrake.ApplicationServices/Parsing/AudioHelper.cs +++ /dev/null @@ -1,95 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// An Audio Helper Class -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Parsing -{ - using System.Collections.Generic; - using System.IO; - using System.Text.RegularExpressions; - - /// - /// An Audio Helper Class - /// - public class AudioHelper - { - /// - /// Gets A Dummy Not Found Track - /// - public static Audio NoneFound - { - get - { - return new Audio { Description = "None Found" }; - } - } - - /// - /// Parse the CLI input to an Audio Track object - /// - /// - /// The output. - /// - /// - /// An Audio Track obkect - /// - public static Audio Parse(StringReader output) - { - string audioTrack = output.ReadLine(); - Match m = Regex.Match(audioTrack, @"^ \+ ([0-9]*), ([A-Za-z0-9,\s]*) \((.*)\) \((.*)\)"); - Match track = Regex.Match(audioTrack, @"^ \+ ([0-9]*), ([A-Za-z0-9,\s]*) \((.*)\)"); // ID and Language - Match iso639_2 = Regex.Match(audioTrack, @"iso639-2: ([a-zA-Z]*)\)"); - Match samplerate = Regex.Match(audioTrack, @"([0-9]*)Hz"); - Match bitrate = Regex.Match(audioTrack, @"([0-9]*)bps"); - - string subformat = m.Groups[4].Value.Trim().Contains("iso639") ? null : m.Groups[4].Value; - string samplerateVal = samplerate.Success ? samplerate.Groups[0].Value.Replace("Hz", string.Empty).Trim() : "0"; - string bitrateVal = bitrate.Success ? bitrate.Groups[0].Value.Replace("bps", string.Empty).Trim() : "0"; - - if (track.Success) - { - Audio thisTrack = new Audio - { - TrackNumber = int.Parse(track.Groups[1].Value.Trim()), - Language = track.Groups[2].Value, - Format = m.Groups[3].Value, - Description = subformat, - SampleRate = int.Parse(samplerateVal), - Bitrate = int.Parse(bitrateVal), - LanguageCode = iso639_2.Value.Replace("iso639-2: ", string.Empty).Replace(")", string.Empty) - }; - return thisTrack; - } - - return null; - } - - /// - /// Pase a list of audio tracks - /// - /// - /// The output. - /// - /// - /// An array of audio tracks - /// - public static Audio[] ParseList(StringReader output) - { - var tracks = new List