From ca023df6b2119d7bf29ade5c07f644fdf2de8731 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 30 Jun 2012 14:07:50 +0000 Subject: WinGui: Refactor the Update service and add a new options tab to deal with updates. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4799 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Services/UpdateService.cs | 107 --------------------- 1 file changed, 107 deletions(-) delete mode 100644 win/CS/HandBrake.ApplicationServices/Services/UpdateService.cs (limited to 'win/CS/HandBrake.ApplicationServices/Services') diff --git a/win/CS/HandBrake.ApplicationServices/Services/UpdateService.cs b/win/CS/HandBrake.ApplicationServices/Services/UpdateService.cs deleted file mode 100644 index 899a953c4..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/UpdateService.cs +++ /dev/null @@ -1,107 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. -// -// -// The Update Service -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace HandBrake.ApplicationServices.Services -{ - using System; - using System.IO; - using System.Net; - using System.Threading; - - using HandBrake.ApplicationServices.Model.General; - using HandBrake.ApplicationServices.Utilities; - - /// - /// The Update Service - /// - public class UpdateService - { - /* - * TODO: Refactor this to use Caliburn Invocation - */ - - /// - /// Begins checking for an update to HandBrake. - /// - /// - /// The method that will be called when the check is finished. - /// - /// - /// Whether or not to execute this in debug mode. - /// - /// - /// The url. - /// - /// - /// The current Build. - /// - /// - /// The skip Build. - /// - public static void BeginCheckForUpdates(AsyncCallback callback, bool debug, string url, int currentBuild, int skipBuild) - { - ThreadPool.QueueUserWorkItem(delegate - { - try - { - // Initialize variables - WebRequest request = WebRequest.Create(url); - WebResponse response = request.GetResponse(); - AppcastReader reader = new AppcastReader(); - - // Get the data, convert it to a string, and parse it into the AppcastReader - reader.GetUpdateInfo(new StreamReader(response.GetResponseStream()).ReadToEnd()); - - // Further parse the information - string build = reader.Build; - - int latest = int.Parse(build); - int current = currentBuild; - int skip = skipBuild; - - // If the user wanted to skip this version, don't report the update - if (latest == skip) - { - UpdateCheckInformation info = new UpdateCheckInformation { NewVersionAvailable = false }; - callback(new UpdateCheckResult(debug, info)); - return; - } - - UpdateCheckInformation info2 = new UpdateCheckInformation - { - NewVersionAvailable = latest > current, - DescriptionUrl = reader.DescriptionUrl, - DownloadFile = reader.DownloadFile, - Build = reader.Build, - Version = reader.Version, - }; - callback(new UpdateCheckResult(debug, info2)); - } - catch (Exception exc) - { - callback(new UpdateCheckResult(debug, new UpdateCheckInformation { Error = exc })); - } - }); - } - - /// - /// End Check for Updates - /// - /// - /// The result. - /// - /// - /// Update Check information - /// - public static UpdateCheckInformation EndCheckForUpdates(IAsyncResult result) - { - return ((UpdateCheckResult)result).Result; - } - } -} -- cgit v1.2.3