From dc003cba89199bcb96515d52ee9599f5d4b520a2 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 23 Mar 2011 10:59:42 +0000 Subject: [PATCH] [about] some version check work --- SparkleShare/SparkleAbout.cs | 60 +++++++++++++++++++++++++++++-- SparkleShare/SparkleStatusIcon.cs | 4 +-- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/SparkleShare/SparkleAbout.cs b/SparkleShare/SparkleAbout.cs index d2ef2a3d..6f9ef684 100644 --- a/SparkleShare/SparkleAbout.cs +++ b/SparkleShare/SparkleAbout.cs @@ -17,6 +17,8 @@ using System; using System.Diagnostics; +using System.IO; +using System.Net; using Gtk; using SparkleLib; @@ -24,7 +26,10 @@ using Mono.Unix; namespace SparkleShare { - public class SparkleDialog : Window { + public class SparkleAbout : Window { + + private Label Version; + // Short alias for the translations public static string _(string s) @@ -33,7 +38,7 @@ namespace SparkleShare { } - public SparkleDialog () : base ("") + public SparkleAbout () : base ("") { DefaultSize = new Gdk.Size (360, 260); @@ -62,6 +67,13 @@ namespace SparkleShare { box.Add (header); + Version = new Label () { + Markup = "Checking for updates...", + Xalign = 0, + Xpad = 18, + Ypad = 22, + }; + Label license = new Label () { Xalign = 0, Xpad = 18, @@ -115,6 +127,7 @@ namespace SparkleShare { button_bar.Add (credits_button); vbox.PackStart (box, true, true, 0); + vbox.PackStart (Version, false, false, 0); vbox.PackStart (license, true, true, 0); vbox.PackStart (button_bar, false, false, 0); @@ -122,6 +135,49 @@ namespace SparkleShare { } + + // TODO: Move to controller + private void CheckForNewVersion () + { + + string new_version_file_path = System.IO.Path.Combine (SparklePaths.SparkleTmpPath, + "version"); + + if (File.Exists (new_version_file_path)) + File.Delete (new_version_file_path); + + WebClient web_client = new WebClient (); + Uri uri = new Uri ("http://www.sparkleshare.org/version"); + + web_client.DownloadFileCompleted += delegate { + + if (new FileInfo (new_version_file_path).Length > 0) { + + StreamReader reader = new StreamReader (new_version_file_path); + string downloaded_version_number = reader.ReadToEnd ().Trim (); + + if (!Defines.VERSION.Equals (downloaded_version_number)) { + + Application.Invoke (delegate { + + + + }); + + } else { + + + + } + + } + + }; + + web_client.DownloadFileAsync (uri, new_version_file_path); + + } + } } diff --git a/SparkleShare/SparkleStatusIcon.cs b/SparkleShare/SparkleStatusIcon.cs index df047f86..0c8d22f8 100644 --- a/SparkleShare/SparkleStatusIcon.cs +++ b/SparkleShare/SparkleStatusIcon.cs @@ -244,8 +244,8 @@ namespace SparkleShare { about_item.Activated += delegate { - SparkleDialog dialog = new SparkleDialog (); - dialog.ShowAll (); + SparkleAbout about = new SparkleAbout (); + about.ShowAll (); };