From 4b8c8ffcc27dc5c368dc0a191a2adbd6a93fea1e Mon Sep 17 00:00:00 2001 From: Lorenz Cuno Klopfenstein Date: Thu, 9 Sep 2010 00:53:01 +0200 Subject: [PATCH] Updates and fixes to start up and updating process. *Should* fix some of the crashes hopefully... Updated installer with more uninstallation infos. --- Installer/script.nsi | 13 ++++++-- Installer/update.xml | 6 ++++ OnTopReplica/AboutForm.Designer.cs | 1 + OnTopReplica/AboutForm.cs | 1 - OnTopReplica/EnumerationExtensions.cs | 3 ++ OnTopReplica/MainForm.cs | 18 +++++++++++ OnTopReplica/Program.cs | 21 ------------- OnTopReplica/Properties/AssemblyInfo.cs | 4 +-- OnTopReplica/Update/UpdateManager.cs | 41 ++++++++++++------------- 9 files changed, 59 insertions(+), 49 deletions(-) create mode 100644 Installer/update.xml diff --git a/Installer/script.nsi b/Installer/script.nsi index dce754e..2a5aa56 100644 --- a/Installer/script.nsi +++ b/Installer/script.nsi @@ -14,6 +14,7 @@ RequestExecutionLevel user !define START_LINK_RUN "$STARTMENU\Programs\OnTopReplica\OnTopReplica.lnk" !define START_LINK_UNINSTALLER "$STARTMENU\Programs\OnTopReplica\Uninstall OnTopReplica.lnk" !define UNINSTALLER_NAME "OnTopReplica-Uninstall.exe" +!define WEBSITE_LINK "http://www.klopfenstein.net/lorenz.aspx/ontopreplica" # GRAPHICS !define MUI_ICON "..\OnTopReplica\Assets\icon-new.ico" @@ -51,12 +52,18 @@ RequestExecutionLevel user Function RegisterApplication ;Register uninstaller into Add/Remove panel (for local user only) WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayName" "OnTopReplica" - WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayIcon" "$INSTDIR\${UNINSTALLER_NAME}" + WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayIcon" "$\"$INSTDIR\OnTopReplica.exe$\"" WriteRegStr HKCU "${REG_UNINSTALL}" "Publisher" "Lorenz Cuno Klopfenstein" - WriteRegStr HKCU "${REG_UNINSTALL}" "InstallSource" "$EXEDIR\" + WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayVersion" "3.1.0.0" + WriteRegDWord HKCU "${REG_UNINSTALL}" "EstimatedSize" 800 ;KB + WriteRegStr HKCU "${REG_UNINSTALL}" "HelpLink" "${WEBSITE_LINK}" + WriteRegStr HKCU "${REG_UNINSTALL}" "URLInfoAbout" "${WEBSITE_LINK}" + WriteRegStr HKCU "${REG_UNINSTALL}" "InstallLocation" "$\"$INSTDIR$\"" + WriteRegStr HKCU "${REG_UNINSTALL}" "InstallSource" "$\"$EXEDIR$\"" WriteRegDWord HKCU "${REG_UNINSTALL}" "NoModify" 1 WriteRegDWord HKCU "${REG_UNINSTALL}" "NoRepair" 1 - WriteRegStr HKCU "${REG_UNINSTALL}" "UninstallString" "$INSTDIR\${UNINSTALLER_NAME}" + WriteRegStr HKCU "${REG_UNINSTALL}" "UninstallString" "$\"$INSTDIR\${UNINSTALLER_NAME}$\"" + WriteRegStr HKCU "${REG_UNINSTALL}" "Comments" "Uninstalls OnTopReplica." ;Links SetShellVarContext current diff --git a/Installer/update.xml b/Installer/update.xml new file mode 100644 index 0000000..dd2bd9d --- /dev/null +++ b/Installer/update.xml @@ -0,0 +1,6 @@ + + + 3.1.0.0 + 2010-09-09T00:00:00Z + http://www.klopfenstein.net/lorenz.aspx/ontopreplica + \ No newline at end of file diff --git a/OnTopReplica/AboutForm.Designer.cs b/OnTopReplica/AboutForm.Designer.cs index ce5ffd9..5c3fb42 100644 --- a/OnTopReplica/AboutForm.Designer.cs +++ b/OnTopReplica/AboutForm.Designer.cs @@ -100,6 +100,7 @@ this.progressBar1.Location = new System.Drawing.Point(235, 79); this.progressBar1.Name = "progressBar1"; this.progressBar1.Size = new System.Drawing.Size(102, 23); + this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee; this.progressBar1.TabIndex = 3; this.progressBar1.Visible = false; // diff --git a/OnTopReplica/AboutForm.cs b/OnTopReplica/AboutForm.cs index f5c2490..9121ad0 100644 --- a/OnTopReplica/AboutForm.cs +++ b/OnTopReplica/AboutForm.cs @@ -127,7 +127,6 @@ namespace OnTopReplica { //Update GUI buttonUpdate.Visible = false; progressBar1.Visible = true; - progressBar1.Value = 50; _updateManager.CheckForUpdate(); } diff --git a/OnTopReplica/EnumerationExtensions.cs b/OnTopReplica/EnumerationExtensions.cs index 20c3478..a7cc169 100644 --- a/OnTopReplica/EnumerationExtensions.cs +++ b/OnTopReplica/EnumerationExtensions.cs @@ -4,6 +4,9 @@ using System.Text; namespace OnTopReplica { + /// + /// Poor man's LINQ. + /// static class EnumerationExtensions { public static bool Contains(IEnumerable collection, T value){ diff --git a/OnTopReplica/MainForm.cs b/OnTopReplica/MainForm.cs index b17df10..ddaa736 100644 --- a/OnTopReplica/MainForm.cs +++ b/OnTopReplica/MainForm.cs @@ -21,6 +21,7 @@ namespace OnTopReplica { //Managers WindowManager _windowManager = new WindowManager(); MessagePumpManager _msgPumpManager = new MessagePumpManager(); + UpdateManager _updateManager = new UpdateManager(); FormBorderStyle _defaultBorderStyle; @@ -72,6 +73,19 @@ namespace OnTopReplica { this.KeyPreview = true; } + delegate void GuiAction(); + + void UpdateManager_CheckCompleted(object sender, UpdateCheckCompletedEventArgs e) { + this.Invoke(new GuiAction(() => { + if (e.Success) { + _updateManager.HandleUpdateCheck(this, e.Information, false); + } + else { + Console.WriteLine("Failed to check for updates: {0}", e.Error); + } + })); + } + #region Event override protected override CreateParams CreateParams { @@ -92,6 +106,10 @@ namespace OnTopReplica { //Glassify window GlassEnabled = true; + + //Check for updates + _updateManager.UpdateCheckCompleted += new EventHandler(UpdateManager_CheckCompleted); + _updateManager.CheckForUpdate(); } protected override void OnClosing(CancelEventArgs e) { diff --git a/OnTopReplica/Program.cs b/OnTopReplica/Program.cs index 7a2e645..86abd11 100644 --- a/OnTopReplica/Program.cs +++ b/OnTopReplica/Program.cs @@ -44,11 +44,6 @@ namespace OnTopReplica { Settings.Default.MustUpdate = false; } - //Start update request - _updateManager = new UpdateManager(); - _updateManager.UpdateCheckCompleted += new EventHandler(UpdateCheckCompleted); - _updateManager.CheckForUpdate(); - bool mustReloadForm = false; Point reloadLocation = new Point(); Size reloadSize = new Size(); @@ -78,22 +73,6 @@ namespace OnTopReplica { Settings.Default.Save(); } - delegate void GuiAction(); - - static void UpdateCheckCompleted(object sender, UpdateCheckCompletedEventArgs e) { - //Budy waiting for form (ugly) - while (_mainForm == null || !_mainForm.IsHandleCreated) ; - - _mainForm.Invoke(new GuiAction(() => { - if (e.Success) { - _updateManager.HandleUpdateCheck(_mainForm, e.Information, false); - } - else { - Console.Error.WriteLine("Failed to check for updates: {0}", e.Error); - } - })); - } - /// /// Forces a global language change. As soon as the main form is closed, the change is performed /// and the form is reopened using the new language. diff --git a/OnTopReplica/Properties/AssemblyInfo.cs b/OnTopReplica/Properties/AssemblyInfo.cs index 7a7740f..46e3969 100644 --- a/OnTopReplica/Properties/AssemblyInfo.cs +++ b/OnTopReplica/Properties/AssemblyInfo.cs @@ -33,5 +33,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.0.2.0")] -[assembly: AssemblyFileVersion("3.0.2.0")] +[assembly: AssemblyVersion("3.1.0.0")] +[assembly: AssemblyFileVersion("3.1.0.0")] diff --git a/OnTopReplica/Update/UpdateManager.cs b/OnTopReplica/Update/UpdateManager.cs index b114b83..bb2a5b5 100644 --- a/OnTopReplica/Update/UpdateManager.cs +++ b/OnTopReplica/Update/UpdateManager.cs @@ -8,6 +8,7 @@ using System.Reflection; using VistaControls.TaskDialog; using System.Diagnostics; using System.Windows.Forms; +using System.Threading; namespace OnTopReplica.Update { @@ -16,29 +17,25 @@ namespace OnTopReplica.Update { const string UpdateManifestUrl = "http://www.klopfenstein.net/public/Uploads/ontopreplica/update.xml"; public void CheckForUpdate() { - //Build web request - var request = (HttpWebRequest)HttpWebRequest.Create(UpdateManifestUrl); - request.AllowAutoRedirect = true; - request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; - request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache); + ThreadPool.QueueUserWorkItem(new WaitCallback(o => { + //Build web request + var request = (HttpWebRequest)HttpWebRequest.Create(UpdateManifestUrl); + request.AllowAutoRedirect = true; + request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; + request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache); - //Begin async request... - request.BeginGetResponse(new AsyncCallback(EndCheckForUpdate), request); - } + try { + //Begin request + var response = request.GetResponse(); + var info = UpdateInformation.Deserialize(response.GetResponseStream()); - private void EndCheckForUpdate(IAsyncResult result) { - HttpWebRequest request = (HttpWebRequest)result.AsyncState; - - try { - var response = request.EndGetResponse(result); - var info = UpdateInformation.Deserialize(response.GetResponseStream()); - - OnUpdateCheckSuccess(info); - } - catch (Exception ex) { - OnUpdateCheckError(ex); - return; - } + OnUpdateCheckSuccess(info); + } + catch (Exception ex) { + OnUpdateCheckError(ex); + return; + } + })); } public event EventHandler UpdateCheckCompleted; @@ -67,7 +64,7 @@ namespace OnTopReplica.Update { /// Handles the results of an update check. Must be called from main GUI thread. /// /// The retrieved update information. - /// Determines if the lack of updated should be notified to the user. + /// Determines if the lack of updates should be notified to the user. public void HandleUpdateCheck(Form parent, UpdateInformation information, bool verbose) { if (information == null) return;