private void Initialise(IHelper aHelper, string aUpdateFeedLocation, int aUpdateInterval, EReleaseQuality aDesiredQuality, string aApplicationName, string aApplicationTarget, uint aUpdateVersion, EReleaseQuality aApplicationQuality) { iHelper = aHelper; iApplicationQuality = aApplicationQuality; iUpdateFolder = Path.Combine(iHelper.DataPath.FullName, "Updates"); try { if (!Directory.Exists(iUpdateFolder)) { Directory.CreateDirectory(iUpdateFolder); } } catch (Exception ex) { UserLog.WriteLine("Failed to create update folder: " + ex.ToString()); } iApplicationName = aApplicationName; iApplicationTarget = aApplicationTarget; DesiredQuality = aDesiredQuality; iUpdateVersion = aUpdateVersion; iUpdateFeedLocation = aUpdateFeedLocation; iUpdateInterval = aUpdateInterval; CleanupTemporaryFiles(); // do some housekeeping }
public AutoUpdateInfo(string aName, string aVersion, Uri aHistory, Uri aUri, EReleaseQuality aQuality, bool aIsCompatibilityFamilyUpgrade) { Name = aName; Version = aVersion; History = aHistory; Uri = aUri; Quality = aQuality; IsCompatibilityFamilyUpgrade = aIsCompatibilityFamilyUpgrade; }
public AutoUpdate(IHelper aHelper, string aUpdateFeedLocation, int aUpdateInterval, EReleaseQuality aDesiredQuality, uint aUpdateVersion) { EReleaseQuality currentQuality = EReleaseQuality.Stable; if (aHelper.Title.ToLowerInvariant().Contains("nightly")) { currentQuality = EReleaseQuality.Nightly; } else if (aHelper.Title.ToLowerInvariant().Contains("beta")) { currentQuality = EReleaseQuality.Beta; } else if (aHelper.Title.ToLowerInvariant().Contains("development")) { currentQuality = EReleaseQuality.Development; } else if (aHelper.Title.ToLowerInvariant().Contains("developer")) { currentQuality = EReleaseQuality.Developer; } string applicationTarget = string.Empty; switch (SystemInfo.Platform) { case PlatformId.Win32NT: case PlatformId.Win32S: case PlatformId.Win32Windows: applicationTarget = kTargetWindows; break; case PlatformId.MacOSX: applicationTarget = kTargetMacOsX; break; case PlatformId.IOS: applicationTarget = kTargetIos; break; case PlatformId.WinCE: applicationTarget = kTargetWindowsCe; break; default: Assert.Check(false); break; } Initialise(aHelper, aUpdateFeedLocation, aUpdateInterval, aDesiredQuality, aHelper.Product, applicationTarget, aUpdateVersion, currentQuality); }
private void SetUpdateTypes() { iAutoUpdateType = EReleaseQuality.Stable; if (iOptionPageUpdates.BetaVersions) { iAutoUpdateType |= EReleaseQuality.Beta; } if (iOptionPageUpdates.DevelopmentVersions) { iAutoUpdateType |= EReleaseQuality.Development; } if (iOptionPageUpdates.NightlyBuilds) { iAutoUpdateType |= EReleaseQuality.Nightly; } if (iAutoUpdate != null) { iAutoUpdate.DesiredQuality = iAutoUpdateType; } }
public IReleaseJson CheckForUpdate(string aCurrentVersion, EReleaseQuality aCurrentQuality, string aCurrentPlatform, string aCurrentPlatformVersion, EReleaseQuality aDesiredQuality) { // select all releases that // - are for this platform // - have a min platform version that is less than or equal to this platform version // - have a quality that matches the desired quality var releases = Json.Releases.Where(r => r.Platform == aCurrentPlatform) .Where(r => VersionSupport.ComparePartialVersions(aCurrentPlatformVersion, r.PlatformMinVersion) >= 0) .Where(r => (r.Quality() & aDesiredQuality) == r.Quality()); // select the release with the highest version for each release quality // - group by quality // - order releases in each group by ascending version // - select the last release in each group releases = releases.GroupBy(r => r.Quality()) .Select(g => g.OrderBy(r => r.Version, new VersionComparer()).Last()); // pick the release with the highest version number and the highest quality (priority to version number) var release = releases.OrderBy(r => r.Version, new VersionComparer()) .ThenBy(r => r.Quality()) .LastOrDefault(); if (release == null) { return(null); } // this version is a valid update if // - its version is greater than the current app version // - its version is the same as the current app version but its quality is greater than the current app quality // - its version is less than the current app version and the current app quality is not in the desired quality if (VersionSupport.ComparePartialVersions(release.Version, aCurrentVersion) > 0 || (VersionSupport.ComparePartialVersions(release.Version, aCurrentVersion) == 0 && release.Quality() > aCurrentQuality) || (VersionSupport.ComparePartialVersions(release.Version, aCurrentVersion) < 0 && (aCurrentQuality & aDesiredQuality) != aCurrentQuality)) { return(release); } return(null); }
private void LoadStack(bool aCreatedNew) { iWindowLoaded.WaitOne(); Linn.Kinsky.Model model = new Linn.Kinsky.Model(iViewMaster, iPlaySupport); iMediator = new Mediator(iHelper, model); Dispatcher.Invoke((Action) delegate() { iSystrayForm = new SystrayForm(this); iSystrayForm.EventClosed += window_Closed; iSystrayForm.Text = this.Title; }); // create the drop converter for the browser views DropConverter browseDropConverter = new DropConverter(); browseDropConverter.Add(new DropConverterInternal()); browseDropConverter.Add(new DropConverterUri()); browseDropConverter.Add(new DropConverterFileDrop(iHttpServer, false)); browseDropConverter.Add(new DropConverterText()); // create the drop converter for the other views DropConverter viewDropConverter = new DropConverter(); viewDropConverter.Add(new DropConverterInternal()); viewDropConverter.Add(new DropConverterUri()); viewDropConverter.Add(new DropConverterFileDrop(iHttpServer, true)); viewDropConverter.Add(new DropConverterText()); Dispatcher.Invoke((Action) delegate() { if (!aCreatedNew) { double newX = iUIOptions.WindowLocation.X + 10; double newY = iUIOptions.WindowLocation.Y + 10; Point midpoint = new Point(newX + (Width / 2), newY + (Height / 2)); if (PointToScreen(midpoint).X >= SystemParameters.VirtualScreenWidth) { newX = 0; } if (PointToScreen(midpoint).Y >= SystemParameters.VirtualScreenHeight) { newY = 0; } Left = newX; Top = newY; //iUIOptions.WindowLocation = new Point(Left, Top); } iSystrayForm.Initialise(iViewMaster); viewKinsky.Initialise(this, iHelper, iLocator, iViewSaveSupport, iPlaySupport, browseDropConverter, viewDropConverter, iViewMaster, iUIOptions, iGroupPlaylistOption, iHelper.Senders); SetThemeOverrides(); kompactMenuItem.IsChecked = iUIOptions.MiniMode; mainWindowChrome.MiniModeActiveChanged += new EventHandler(mainWindowChrome_MiniModeActiveChanged); }); EReleaseQuality currentBuildType = EReleaseQuality.Stable; if (iHelper.Title.ToLowerInvariant().Contains("nightly")) { currentBuildType = EReleaseQuality.Nightly; } else if (iHelper.Title.ToLowerInvariant().Contains("beta")) { currentBuildType = EReleaseQuality.Beta; } else if (iHelper.Title.ToLowerInvariant().Contains("development")) { currentBuildType = EReleaseQuality.Development; } else if (iHelper.Title.ToLowerInvariant().Contains("developer")) { currentBuildType = EReleaseQuality.Developer; } var appName = iHelper.Product; iAutoUpdate = new AutoUpdate(iHelper, AutoUpdate.DefaultFeedLocation(appName, "Windows"), 1000 * 60 * 60, iAutoUpdateType, appName, kApplicationTarget, kUpdateVersion, currentBuildType); iAutoUpdate.EventUpdateFound += iAutoUpdate_EventUpdateFound; iHelper.SetStackExtender(this); iHelper.Stack.SetStatusHandler(new StackStatusHandlerWpf(iHelper.Title, iSystrayForm.NotifyIcon)); Dispatcher.BeginInvoke((Action) delegate() { HwndSource source = PresentationSource.FromVisual(this) as HwndSource; source.AddHook(HandleSessionEvents); if (!WTSRegisterSessionNotification((new WindowInteropHelper(this)).Handle, NOTIFY_FOR_THIS_SESSION)) { UserLog.WriteLine("Could not register for user session changes."); } iInitialSessionId = System.Diagnostics.Process.GetCurrentProcess().SessionId; iSessionConnected = true; iSessionHookAdded = true; StartStack(); }); // show the options dialog if specified by the user if (iHelper.Stack.StatusHandler.ShowOptions) { Dispatcher.BeginInvoke((Action) delegate() { ShowOptionsDialog(true); }); } }
public AutoUpdate(IHelper aHelper, string aUpdateFeedLocation, int aUpdateInterval, EReleaseQuality aDesiredQuality, string aApplicationName, string aApplicationTarget, uint aUpdateVersion, EReleaseQuality aApplicationQuality) { Initialise(aHelper, aUpdateFeedLocation, aUpdateInterval, aDesiredQuality, aApplicationName, aApplicationTarget, aUpdateVersion, aApplicationQuality); }