Пример #1
0
        /// <summary>
        /// Handle Update Check Results
        /// </summary>
        /// <param name="information">
        /// The information.
        /// </param>
        private void HandleManualUpdateCheckResults(UpdateCheckInformation information)
        {
            if (information.NewVersionAvailable)
            {
                MessageBox.Show("A New Version is available. Goto Tools Menu > Options to Install or visit http://handbrake.fr for details.", "Update Available", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show("There is no new updates at this time.", "No Update Available", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            this.ProgramStatusLabel = "Ready";
        }
Пример #2
0
 /// <summary>
 /// Handle Update Check Results
 /// </summary>
 /// <param name="information">
 /// The information.
 /// </param>
 private void HandleUpdateCheckResults(UpdateCheckInformation information)
 {
     if (information.NewVersionAvailable)
     {
         this.ProgramStatusLabel = "A New Update is Available. Goto Tools Menu > Options to Install";
     }
 }
Пример #3
0
 /// <summary>
 /// Update Check Complete
 /// </summary>
 /// <param name="info">
 /// The info.
 /// </param>
 private void UpdateCheckComplete(UpdateCheckInformation info)
 {
     this.updateInfo = info;
     if (info.NewVersionAvailable)
     {
         this.UpdateMessage = "A New Update is Available!";
         this.UpdateAvailable = true;
     }
     else
     {
         this.UpdateMessage = "There are no new updates at this time.";
         this.UpdateAvailable = false;
     }
 }
        /// <summary>
        /// Check for Updates
        /// </summary>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void CheckForUpdates(Action<UpdateCheckInformation> callback)
        {
            ThreadPool.QueueUserWorkItem(
                delegate
                {
                    try
                    {
                        string url =
                            VersionHelper.Is64Bit()
                                ? Constants.Appcast64
                                : Constants.Appcast32;

                        var currentBuild =
                            this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild);
                        var skipBuild = this.userSettingService.GetUserSetting<int>(
                            UserSettingConstants.Skipversion);

                        // Initialize variables
                        WebRequest request = WebRequest.Create(url);
                        WebResponse response = request.GetResponse();
                        var 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)
                        {
                            var info = new UpdateCheckInformation { NewVersionAvailable = false };
                            callback(info);
                            return;
                        }

                        var info2 = new UpdateCheckInformation
                            {
                                NewVersionAvailable = latest > current,
                                DescriptionUrl = reader.DescriptionUrl,
                                DownloadFile = reader.DownloadFile,
                                Build = reader.Build,
                                Version = reader.Version,
                            };

                        callback(info2);
                    }
                    catch (Exception exc)
                    {
                        callback(new UpdateCheckInformation { NewVersionAvailable = false, Error = exc });
                    }
                });
        }
Пример #5
0
 /// <summary>
 /// Update Check Complete
 /// </summary>
 /// <param name="info">
 /// The info.
 /// </param>
 private void UpdateCheckComplete(UpdateCheckInformation info)
 {
     this.updateInfo = info;
     if (info.NewVersionAvailable)
     {
         this.UpdateMessage = Resources.OptionsViewModel_NewUpdate;
         this.UpdateAvailable = true;
     }
     else if (Environment.Is64BitOperatingSystem && !System.Environment.Is64BitProcess)
     {
         this.UpdateMessage = Resources.OptionsViewModel_64bitAvailable;
         this.UpdateAvailable = true;
     }
     else
     {
         this.UpdateMessage = Resources.OptionsViewModel_NoNewUpdates;
         this.UpdateAvailable = false;
     }
 }
Пример #6
0
        /// <summary>
        /// Check for Updates
        /// </summary>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void CheckForUpdates(Action<UpdateCheckInformation> callback)
        {
            ThreadPool.QueueUserWorkItem(
                delegate
                {
                    try
                    {
                        string url =
                            VersionHelper.Is64Bit() || Environment.Is64BitOperatingSystem
                                ? Constants.Appcast64
                                : Constants.Appcast32;

                        if (VersionHelper.IsNightly())
                        {
                            url =
                            VersionHelper.Is64Bit() || Environment.Is64BitOperatingSystem
                                ? Constants.AppcastUnstable64
                                : Constants.AppcastUnstable32;
                        }

                        var currentBuild = HandBrakeUtils.Build;

                        // Initialize variables
                        WebRequest request = WebRequest.Create(url);
                        WebResponse response = request.GetResponse();
                        var 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;

                        var info2 = new UpdateCheckInformation
                            {
                                NewVersionAvailable = latest > current,
                                DescriptionUrl = reader.DescriptionUrl,
                                DownloadFile = reader.DownloadFile,
                                Build = reader.Build,
                                Version = reader.Version,
                                Signature = reader.Hash
                            };

                        callback(info2);
                    }
                    catch (Exception exc)
                    {
                        callback(new UpdateCheckInformation { NewVersionAvailable = false, Error = exc });
                    }
                });
        }
Пример #7
0
 /// <summary>
 /// Handle Update Check Results
 /// </summary>
 /// <param name="information">
 /// The information.
 /// </param>
 private void HandleUpdateCheckResults(UpdateCheckInformation information)
 {
     if (information.NewVersionAvailable)
     {
         this.ProgramStatusLabel = Resources.Main_NewUpdate;
     }
 }
 /// <summary>
 /// Update Check Complete
 /// </summary>
 /// <param name="info">
 /// The info.
 /// </param>
 private void UpdateCheckComplete(UpdateCheckInformation info)
 {
     this.updateInfo = info;
     if (info.NewVersionAvailable)
     {
         this.UpdateMessage = "A New Update is Available!";
         this.UpdateAvailable = true;
     }
     else if (Environment.Is64BitOperatingSystem && !System.Environment.Is64BitProcess)
     {
         this.UpdateMessage = "Your system supports the 64bit version of HandBrake! This offers performance and stability improvements over this 32bit version.";
         this.UpdateAvailable = true;
     }
     else
     {
         this.UpdateMessage = "There are no new updates at this time.";
         this.UpdateAvailable = false;
     }
 }
        /// <summary>
        /// Check for Updates
        /// </summary>
        /// <param name="callback">
        /// The callback.
        /// </param>
        public void CheckForUpdates(Action<UpdateCheckInformation> callback)
        {
            ThreadPool.QueueUserWorkItem(
                delegate
                {
                    try
                    {
                        // Figure out which appcast we want to read.
                        string url =
                            VersionHelper.Is64Bit() || Environment.Is64BitOperatingSystem
                                ? Constants.Appcast64
                                : Constants.Appcast32;

                        if (VersionHelper.IsNightly())
                        {
                            url =
                            VersionHelper.Is64Bit() || Environment.Is64BitOperatingSystem
                                ? Constants.AppcastUnstable64
                                : Constants.AppcastUnstable32;
                        }

                        var currentBuild = HandBrakeUtils.Build;

                        // Fetch the Appcast from our server.
                        HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
                        request.AllowAutoRedirect = false; // We will never do this.
                        WebResponse response = request.GetResponse();

                        // Parse the data with the AppcastReader
                        var reader = new AppcastReader();
                        reader.GetUpdateInfo(new StreamReader(response.GetResponseStream()).ReadToEnd());

                        // Further parse the information
                        string build = reader.Build;
                        int latest = int.Parse(build);
                        int current = currentBuild;

                        // Security Check
                        // Verify the download URL is for handbrake.fr and served over https.
                        // This prevents a compromised appcast download tricking the GUI into downloading a file, or accessing another website or local network resource.
                        Uri uriResult;
                        bool result = Uri.TryCreate(reader.DownloadFile, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttps;
                        if (!result || (uriResult.Host != "handbrake.fr" && uriResult.Host != "download.handbrake.fr"))
                        {
                            callback(new UpdateCheckInformation { NewVersionAvailable = false, Error = new Exception("The HandBrake update service is currently unavailable.") });
                            return;
                        }

                        // Validate the URL from the appcast is ours.
                        var info2 = new UpdateCheckInformation
                            {
                                NewVersionAvailable = latest > current,
                                DescriptionUrl = reader.DescriptionUrl,
                                DownloadFile = reader.DownloadFile,
                                Build = reader.Build,
                                Version = reader.Version,
                                Signature = reader.Hash
                            };

                        callback(info2);
                    }
                    catch (Exception exc)
                    {
                        callback(new UpdateCheckInformation { NewVersionAvailable = false, Error = exc });
                    }
                });
        }