public static SUUpdateAlert CreateAlert(SUHost host, SUAppcastItem item) { SUUpdateAlertWindow window = new SUUpdateAlertWindow(); SUUpdateAlert alert = new SUUpdateAlert(window, host, item); return(alert); }
public SUUpdateAlert(Window window, SUHost host, SUAppcastItem item) : base(window) { Window.TaskbarItemInfo = new System.Windows.Shell.TaskbarItemInfo(); Window.Closing += WindowShouldClose; Window.Icon = host.Icon; Window.Topmost = true; status = WindowStatus.WaitingForInitialAction; mainViewController = new SUUpdateAlertWindowViewController(new SUUpdateAlertWindowView()); ViewController = mainViewController; buttons = new SUUpdateAlertActionButtonsViewController(new SUUpdateAlertActionButtonsView()); buttons.InstallButton.Click += DownloadButtonClicked; buttons.RemindLaterButton.Click += RemindLaterButtonClicked; buttons.SkipVersionButton.Click += SkipVersionButtonClicked; downloadingViewController = new SUUpdateAlertDownloadProgressViewController(new SUUpdateAlertDownloadProgressView()); downloadingViewController.CancelButton.Click += CancelDownloadClicked; indeterminateViewController = new SUUpdateAlertIndeterminateProgressViewController(new SUUpdateAlertIndeterminateProgressView()); readyToInstallViewController = new SUUpdateAlertReadyToInstallViewController(new SUUpdateAlertReadyToInstallView()); readyToInstallViewController.InstallButton.Click += InstallButtonClicked; mainViewController.ActionViewController = buttons; mainViewController.Host = host; mainViewController.Item = item; }
public override void Start(SUAppcastItem item, string path) { BackgroundWorker unzipper = new BackgroundWorker(); unzipper.DoWork += UnzipFile; unzipper.RunWorkerCompleted += UnzipCompleted; unzipper.RunWorkerAsync(path); }
public bool HostSupportsItem(SUAppcastItem item) { if (String.IsNullOrEmpty(item.MinimumSystemVersion)) { return(true); } else { return(SUStandardVersionComparator.SharedComparator().CompareVersionToVersion(item.MinimumSystemVersion, Host.SystemVersionString) < 1); } }
public override void Start(SUAppcastItem item, string path) { // This is a bit of a hack - SparkleDotNET expects to have // to extract everything it downloads. This isn't the case // for .exe files. if (Delegate != null) { Delegate.UnarchiverDidFinish(this, path); } }
public bool ItemContainsSkippedVersion(SUAppcastItem item) { string skippedVersion = (string)Host.ObjectForUserDefaultsKey(SUConstants.SUSkippedVersionKey); if (!Helpers.StringIsNullOrWhiteSpace(skippedVersion)) { return(VersionComparator().CompareVersionToVersion(item.VersionString, skippedVersion) <= 0); } else { return(false); } }
public override bool BeginInstallationOfItemFromPath(SUAppcastItem item, string path) { if (Helpers.StringIsNullOrWhiteSpace(path) || item == null || !File.Exists(path)) { return(false); } FileAttributes attr = File.GetAttributes(path); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { if (!Helpers.StringIsNullOrWhiteSpace(item.PrimaryInstallationFile) && File.Exists(Path.Combine(path, item.PrimaryInstallationFile))) { path = Path.Combine(path, item.PrimaryInstallationFile); } path = Path.Combine(path, FirstExecutableNameInDirectory(path)); } if (!File.Exists(path)) { return(false); } string switches = ""; if (!Helpers.StringIsNullOrWhiteSpace(item.ExecutableType)) { if (item.ExecutableType.Equals("InstallShieldSetup")) { switches = "/S /v/qb"; } else if (item.ExecutableType.Equals("InnoSetup")) { switches = "/SILENT /SP-"; } } Process installerProcess = new Process(); installerProcess.StartInfo.FileName = path; installerProcess.StartInfo.Arguments = switches; try { return(installerProcess.Start()); } catch { return(false); } }
public void AppcastDidFinishLoading(SUAppcast anAppcast) { if (Updater.Delegate != null) { Updater.Delegate.UpdaterDidFinishLoadingAppcast(Updater, anAppcast); } SUAppcastItem item = null; if (Updater.Delegate != null) { item = Updater.Delegate.BestValidUpdateInAppcastForUpdater(anAppcast, Updater); } foreach (SUAppcastItem potentialItem in anAppcast.Items) { if (HostSupportsItem(potentialItem)) { item = potentialItem; break; } } updateItem = item; if (updateItem == null) { DidNotFindUpdate(); return; } if (ItemContainsValidUpdate(updateItem)) { DidFindValidUpdate(); } else { DidNotFindUpdate(); } }
public override bool BeginInstallationOfItemFromPath(SUAppcastItem item, string path) { if (Helpers.StringIsNullOrWhiteSpace(path) || item == null || !File.Exists(path)) { return(false); } FileAttributes attr = File.GetAttributes(path); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { if (!Helpers.StringIsNullOrWhiteSpace(item.PrimaryInstallationFile) && File.Exists(Path.Combine(path, item.PrimaryInstallationFile))) { path = Path.Combine(path, item.PrimaryInstallationFile); } path = Path.Combine(path, FirstMSINameInDirectory(path)); } if (!File.Exists(path)) { return(false); } Process installerProcess = new Process(); installerProcess.StartInfo.FileName = "msiexec.exe"; installerProcess.StartInfo.Arguments = String.Format("/i \"{0}\" /qb", path); try { return(installerProcess.Start()); } catch { return(false); } }
private void AppcastWasDownloaded(Object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) { ReportError(e.Error); } else { XmlNodeList xmlItems = null; try { XmlDocument doc = new XmlDocument(); doc.LoadXml(e.Result); xmlItems = doc.SelectNodes("/rss/channel/item"); } catch (Exception ex) { ReportError(ex); return; } List <SUAppcastItem> appcastItems = new List <SUAppcastItem>(); foreach (XmlNode node in xmlItems) { Dictionary <string, ArrayList> nodesDict = new Dictionary <string, ArrayList>(); Dictionary <string, Object> itemDescription = new Dictionary <string, object>(); // Create a dictionary of nodes for each name present, // so we can parse by xml:lang later. foreach (XmlNode childNode in node.ChildNodes) { string nodeName = childNode.Name; ArrayList nodesForName = null; if (!nodesDict.TryGetValue(nodeName, out nodesForName)) { nodesForName = new ArrayList(); nodesDict.Add(nodeName, nodesForName); } nodesForName.Add(childNode); } foreach (string itemKey in nodesDict.Keys) { ArrayList nodes = null; nodesDict.TryGetValue(itemKey, out nodes); XmlNode bestNodeForKey = BestNodeInNodes(nodes); if (bestNodeForKey.Name.Equals("enclosure")) { // enclosure is flattened as a separate dictionary for some reason Dictionary <string, string> enclosureDict = new Dictionary <string, string>(); foreach (XmlAttribute attribute in bestNodeForKey.Attributes) { enclosureDict.SetValueForKey(attribute.InnerText, attribute.Name); } itemDescription.SetValueForKey(enclosureDict, "enclosure"); } else if (bestNodeForKey.Name.Equals("pubDate")) { try { DateTime date = DateTime.Parse(bestNodeForKey.InnerText); itemDescription.SetValueForKey(date, bestNodeForKey.Name); } catch { // Nothing } } else { itemDescription.SetValueForKey(bestNodeForKey.InnerText.Trim(), bestNodeForKey.Name); } } try { SUAppcastItem item = new SUAppcastItem(itemDescription); appcastItems.Add(item); } catch { } } appcastItems.Sort(); appcastItems.Reverse(); // new to old Items = appcastItems; if (Delegate != null) { Delegate.AppcastDidFinishLoading(this); } } }
public virtual void Start(SUAppcastItem item, string path) { }
public bool ItemContainsValidUpdate(SUAppcastItem item) { return(HostSupportsItem(item) && IsItemNewer(item) && !ItemContainsSkippedVersion(item)); }
// --- public bool IsItemNewer(SUAppcastItem item) { return(VersionComparator().CompareVersionToVersion(Host.Version, item.VersionString) < 0); }
public virtual bool BeginInstallationOfItemFromPath(SUAppcastItem item, string path) { return(false); }