diff --git a/SparkleShare/SparkleAboutController.cs b/SparkleShare/SparkleAboutController.cs index 506e1712..02af0167 100755 --- a/SparkleShare/SparkleAboutController.cs +++ b/SparkleShare/SparkleAboutController.cs @@ -19,8 +19,6 @@ using System; using System.Net; using System.Threading; -using SparkleLib; - namespace SparkleShare { public class SparkleAboutController { @@ -40,7 +38,7 @@ namespace SparkleShare { public string RunningVersion { get { - return SparkleBackend.Version; + return SparkleLib.SparkleBackend.Version; } } @@ -49,7 +47,7 @@ namespace SparkleShare { { Program.Controller.ShowAboutWindowEvent += delegate { ShowWindowEvent (); - CheckForNewVersion (); + new Thread (() => CheckForNewVersion ()).Start (); }; } @@ -63,72 +61,20 @@ namespace SparkleShare { private void CheckForNewVersion () { CheckingForNewVersionEvent (); + Thread.Sleep (500); WebClient web_client = new WebClient (); Uri uri = new Uri ("http://www.sparkleshare.org/version"); - web_client.DownloadStringCompleted += delegate (object o, DownloadStringCompletedEventArgs args) { - if (args.Error != null) - return; - - string latest_version_string = args.Result.Trim (); - Thread.Sleep (750); - - if (UpdateRequired (RunningVersion, latest_version_string)) - NewVersionEvent (latest_version_string); + try { + string latest_version = web_client.DownloadString (uri); + + if (new Version (latest_version) > new Version (RunningVersion)) + NewVersionEvent (latest_version); else - VersionUpToDateEvent (); - }; - - web_client.DownloadStringAsync (uri); - } - - - private bool UpdateRequired (string running_version_string, string latest_version_string) - { - if (running_version_string == null) - throw new ArgumentNullException ("running_version_string"); - - if (string.IsNullOrWhiteSpace (running_version_string)) - throw new ArgumentException ("running_version_string"); - - if (latest_version_string == null) - throw new ArgumentNullException ("latest_version_string"); - - if (string.IsNullOrWhiteSpace (latest_version_string)) - throw new ArgumentException ("latest_version_string"); - - int running_major; - int running_minor; - int running_micro; - try { - string [] running_split = running_version_string.Split ('.'); - running_major = int.Parse (running_split [0]); - running_minor = int.Parse (running_split [1]); - running_micro = int.Parse (running_split [2]); - - } catch (Exception e) { - throw new FormatException ("running_version_string", e); + VersionUpToDateEvent (); + } catch { } - - int latest_major; - int latest_minor; - int latest_micro; - try { - string [] latest_split = latest_version_string.Split ('.'); - latest_major = int.Parse (latest_split [0]); - latest_minor = int.Parse (latest_split [1]); - latest_micro = int.Parse (latest_split [2]); - - } catch (Exception e) { - throw new FormatException ("latest_version_string", e); - } - - bool higher_major = latest_major > running_major; - bool higher_minor = latest_major == running_major && latest_minor > running_minor; - bool higher_micro = latest_major == running_major && latest_minor == running_minor && latest_micro > running_micro; - - return (higher_major || higher_minor || higher_micro); } } }