Updates and fixes to start up and updating process.

*Should* fix some of the crashes hopefully...
Updated installer with more uninstallation infos.
This commit is contained in:
Lorenz Cuno Klopfenstein 2010-09-09 00:53:01 +02:00
parent 3b219b69bd
commit 4b8c8ffcc2
9 changed files with 59 additions and 49 deletions

View file

@ -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

6
Installer/update.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<UpdateInformation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<latestVersion>3.1.0.0</latestVersion>
<latestVersionRelease>2010-09-09T00:00:00Z</latestVersionRelease>
<downloadPage>http://www.klopfenstein.net/lorenz.aspx/ontopreplica</downloadPage>
</UpdateInformation>

View file

@ -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;
//

View file

@ -127,7 +127,6 @@ namespace OnTopReplica {
//Update GUI
buttonUpdate.Visible = false;
progressBar1.Visible = true;
progressBar1.Value = 50;
_updateManager.CheckForUpdate();
}

View file

@ -4,6 +4,9 @@ using System.Text;
namespace OnTopReplica {
/// <summary>
/// Poor man's LINQ.
/// </summary>
static class EnumerationExtensions {
public static bool Contains<T>(IEnumerable<T> collection, T value){

View file

@ -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<UpdateCheckCompletedEventArgs>(UpdateManager_CheckCompleted);
_updateManager.CheckForUpdate();
}
protected override void OnClosing(CancelEventArgs e) {

View file

@ -44,11 +44,6 @@ namespace OnTopReplica {
Settings.Default.MustUpdate = false;
}
//Start update request
_updateManager = new UpdateManager();
_updateManager.UpdateCheckCompleted += new EventHandler<UpdateCheckCompletedEventArgs>(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);
}
}));
}
/// <summary>
/// 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.

View file

@ -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")]

View file

@ -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<UpdateCheckCompletedEventArgs> UpdateCheckCompleted;
@ -67,7 +64,7 @@ namespace OnTopReplica.Update {
/// Handles the results of an update check. Must be called from main GUI thread.
/// </summary>
/// <param name="information">The retrieved update information.</param>
/// <param name="verbose">Determines if the lack of updated should be notified to the user.</param>
/// <param name="verbose">Determines if the lack of updates should be notified to the user.</param>
public void HandleUpdateCheck(Form parent, UpdateInformation information, bool verbose) {
if (information == null)
return;