protected virtual bool CheckRegistry(RemoteAppcast appcast) { if (IsThisFirstRun) { EnsureNotFirstRun(); _logger.Log("App is running for the first time. Skipping further checks."); return false; } _logger.Log("This is not app's first run. Continuing with other registry checks."); var skipVersion = SkipVersion; if (!string.IsNullOrWhiteSpace(skipVersion)) { Version ver; if (Version.TryParse(skipVersion, out ver) && appcast.Version == ver) { _logger.Log(string.Format("User has asked to skip version: {0}. Skipping further checks.", ver)); return false; } } _logger.Log("Seems like user doesn\'t want to skip this version. Continuing with other registry checks."); var lastCheckDate = LastCheckDate; if (DateTime.Now.Subtract(lastCheckDate).TotalDays < 1) { _logger.Log("Last check was done less than a day ago. Skipping further checks"); return false; } _logger.Log(string.Format("Last check was done on: {0}", lastCheckDate.ToShortDateString())); return true; }
internal async Task StartAsync(RemoteAppcast appcast) { InitializeCommands(appcast); Title = string.Format("A NEW VERSION OF {0} IS AVAILABLE", appcast.Title).ToUpperInvariant(); OldVersion = new AssemblyAccessor().Version; NewVersion = appcast.Version.ToString(); ReleaseNotes = await FetchReleaseNotesAsync(appcast.ReleaseNotesUrl).ConfigureAwait(false); }
internal async Task StartAsync(RemoteAppcast appcast) { InitializeCommands(appcast); Title = string.Format(Resources.NewVersionAvailable, appcast.Title).ToUpperInvariant(); OldVersion = GetOldVersion(); NewVersion = appcast.Version.ToString(); ReleaseNotes = await FetchReleaseNotesAsync(appcast.ReleaseNotesUrl).ConfigureAwait(false); }
private async Task DownloadArtifact(RemoteAppcast appcast, string destinationPath) { _logger.Log("Starting to download artifact"); using (var client = new WebClient()) { client.DownloadProgressChanged += (sender, args) => { ProgressPercent = args.ProgressPercentage; }; await _contentDownloader.DownloadFile(appcast.ArtifactUrl, destinationPath, client).ConfigureAwait(false); _logger.Log(string.Format("Artifact downloaded to {0}", destinationPath)); } }
protected virtual async void ShowUpdateWindow(RemoteAppcast appcast) { var viewModel = new MainWindowViewModel(_appInfo, _logger, RemoteContentDownloader); await viewModel.StartAsync(appcast).ConfigureAwait(true); var window = new MainWindow { DataContext = viewModel }; viewModel.ContinueUpdateCommand = new DelegateCommand(e => { _logger.Log("Continuing with downloading the artifact"); window.Close(); ShowDownloadWindow(appcast); }); SetOwner(window); window.ShowDialog(); }
protected virtual void ShowDownloadWindow(RemoteAppcast appcast) { var viewModel = new DownloadWindowViewModel(_appInfo, _logger, RemoteContentDownloader); var destinationPath = CreateTempPath(appcast.ArtifactUrl); var window = new DownloadWindow { DataContext = viewModel }; viewModel.ContinueCommand = new DelegateCommand(e => { _logger.Log("Continue after downloading artifact"); OnArtifactDownloadedEvent(new SingleEventArgs<string>(destinationPath)); window.Close(); OpenArtifact(destinationPath); }); SetOwner(window); viewModel.StartAsync(appcast, destinationPath); window.ShowDialog(); }
internal bool ShouldUpdate(RemoteAppcast appcast, bool shouldIgnoreRegistryChecks = false) { if (!shouldIgnoreRegistryChecks) { _logger.Log("Checking registry entries for updates."); if (!CheckRegistry(appcast)) { _logger.Log("Registry entries says not to tell if there is an update available."); return false; } _logger.Log("Registry entries says go and tell if there is an update available."); } else { _logger.Log("Skipping registry checks. This probably means we are doing forced update checks."); } UpdateCheckDate(); var higherVersion = CheckVersion(appcast); return higherVersion; }
protected virtual bool CheckVersion(RemoteAppcast appcast) { var curVer = Assembly.GetEntryAssembly().GetName().Version; var isHigherVersionAvailable = appcast.Version.IsHigherThan(curVer); _logger.Log(string.Format("Higher version of app is {0}available", isHigherVersionAvailable ? "" : "not ")); return isHigherVersionAvailable; }
protected virtual bool VerifyArtifact(RemoteAppcast appcast, string artifactPath) { var verifer = new SignatureVerifier(_appInfo.PublicSignatureFilename); return verifer.VerifyDSASignature(appcast.DSASignature, artifactPath); }
private bool ShouldOpenArtifact(RemoteAppcast appcast, string artifactPath) { if (string.IsNullOrEmpty(appcast.DSASignature)) { _logger.Log("No DSASignature provided. Skipping signature verification"); return true; } _logger.Log("DSASignature provided. Verifying artifact's signature"); if (VerifyArtifact(appcast, artifactPath)) { _logger.Log("Successfully verified artifact's signature"); return true; } _logger.Log("Couldn't verify artifact's signature. The artifact will now be deleted."); var signatureWindowViewModel = new SignatureVerificationWindowViewModel(_appInfo, appcast); var signatureWindow = new SignatureVerificationWindow {DataContext = signatureWindowViewModel}; signatureWindowViewModel.ContinueCommand = new DelegateCommand(e=> {signatureWindow.Close();}); SetOwner(signatureWindow); signatureWindow.ShowDialog(); return false; }
protected virtual void ShowDownloadWindow(RemoteAppcast appcast) { var viewModel = new DownloadWindowViewModel(_appInfo, _logger, RemoteContentDownloader); var artifactPath = CreateTempPath(appcast.ArtifactUrl); var window = new DownloadWindow { DataContext = viewModel }; viewModel.ContinueWithInstallationCommand = new DelegateCommand(e => { _logger.Log("Continue after downloading artifact"); _analyticsLogger.LogContinueWithInstallation(); OnArtifactDownloadedEvent(new SingleEventArgs<string>(artifactPath)); window.Close(); if (ShouldOpenArtifact(appcast, artifactPath)) { OpenArtifact(artifactPath); _logger.Log("Opened artifact"); } }); SetOwner(window); viewModel.StartAsync(appcast, artifactPath); window.ShowDialog(); }
protected override void ShowUpdateWindow(RemoteAppcast appcast) { // can't do in tests }
protected override void OnRemoteAppcastAvailableEvent(SingleEventArgs<RemoteAppcast> args) { RemoteAppcast = args.Payload; base.OnRemoteAppcastAvailableEvent(args); }
private void InitializeCommands(RemoteAppcast appcast) { _remoteVersion = appcast.Version.ToString(); SkipThisVersionCommand = new DelegateCommand(SkipThisVersionCommandHandler); RemindMeLaterCommand = new DelegateCommand(RemindMeLaterCommandHandler); }
internal async void StartAsync(RemoteAppcast appcast, string destinationPath) { Title = string.Format("Downloading {0} Installer...", appcast.Title); await DownloadArtifact(appcast, destinationPath).ConfigureAwait(true); }
public SignatureVerificationWindowViewModel(AppInfo appInfo, RemoteAppcast appcast) { AppIconPath = appInfo.AppIconPath; Title = string.Format(Properties.Resources.SignatureErrorTitle, appcast.Title); }
internal async void StartAsync(RemoteAppcast appcast, string destinationPath) { Title = string.Format(Properties.Resources.DownloadingInstaller, appcast.Title); await DownloadArtifact(appcast, destinationPath).ConfigureAwait(true); }