public CheckForUpdateCompleteEventArgs(Manifest manifest, string currentVersion, bool userInitiated, UpdateErrorEventArgs errorArgs) { this.manifest = manifest; this.currentVersion = currentVersion; this.userInitiated = userInitiated; this.errorArgs = errorArgs; }
public void LaunchUpdater(Manifest manifest, bool updateAvailable, UpdateErrorEventArgs args) { if (this.updater != null) { if (args != null) { this.updater_UpdateError(this.updater, args); } else if (updateAvailable) { this.NoButton.Visible = true; this.YesButton.Visible = true; this.progressBar1.Visible = false; this.OKButton.Visible = false; this.InfoLabel.Text = String.Format(Properties.Resources.Updater_UpdateAvailable, manifest.Version, this.updater.CurrentVersion); } else { this.NoButton.Visible = false; this.YesButton.Visible = false; this.progressBar1.Visible = false; this.OKButton.Visible = true; this.InfoLabel.Text = String.Format(Properties.Resources.Updater_GrowlIsUpToDate, this.updater.CurrentVersion, this.updater.CurrentVersion); } this.Show(); this.Activate(); } }
void checker_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (!e.Cancelled) { CheckForUpdateCompleteEventArgs args = null; bool userInitiated = (bool)e.UserState; if (e.Error == null) { this.updatedManifest = Manifest.Parse(e.Result); if (this.updatedManifest != null) { args = new CheckForUpdateCompleteEventArgs(this.updatedManifest, this.currentVersion, userInitiated, null); this.updateAvailable = args.UpdateAvailable; } } // this could be because e.Error != null or because the Manifest.Parse() failed if(args == null) { UpdateErrorEventArgs errorArgs = new UpdateErrorEventArgs(e.Error, "Growl was unable to determine if a newer version is available. Please try again later."); args = new CheckForUpdateCompleteEventArgs(null, this.currentVersion, userInitiated, errorArgs); } this.OnCheckForUpdateComplete(args); } }
public static Manifest Parse(string data) { Manifest manifest = null; try { XmlDocument xml = new XmlDocument(); xml.LoadXml(data); XmlElement root = xml.DocumentElement; XmlElement versionNode = root["version"]; XmlElement requiredNode = root["required"]; XmlElement updateLocationNode = root["updateLocation"]; XmlElement installerLocationNode = root["installerLocation"]; string version = versionNode.InnerText; bool required = Convert.ToBoolean(requiredNode.InnerText); string updateLocation = updateLocationNode.InnerText; string installerLocation = installerLocationNode.InnerText; manifest = new Manifest(version, required, updateLocation, installerLocation); } catch { // this handles malformed xml (including times when html is returned instead, such as 404 or 500 errors) } return manifest; }