private void pageCredentials_Commit(object sender, WizardPageConfirmEventArgs e) { _server.Username = textBoxUsername.Text; _server.Password = textBoxPassword.Text; try { using (var handler = new DialogTaskHandler(this)) handler.RunTask(new SimpleTask(Text, CheckCredentials)); } #region Error handling catch (WebException ex) { Log.Warn(ex); Msg.Inform(this, ex.Message, MsgSeverity.Warn); e.Cancel = true; return; } catch (OperationCanceledException) { e.Cancel = true; return; } #endregion pageCredentials.NextPage = _existingAccount ? pageExistingCryptoKey : pageNewCryptoKey; }
private void pageExistingCryptoKey_Commit(object sender, WizardPageConfirmEventArgs e) { _cryptoKey = textBoxCryptoKey.Text; try { using (var handler = new DialogTaskHandler(this)) handler.RunTask(new SimpleTask(Text, CheckCryptoKey)); } #region Error handling catch (WebException ex) { Log.Warn(ex); Msg.Inform(this, ex.Message, MsgSeverity.Warn); e.Cancel = true; } catch (InvalidDataException ex) { Log.Warn(ex); Msg.Inform(this, ex.Message, MsgSeverity.Warn); e.Cancel = true; } catch (OperationCanceledException) { e.Cancel = true; } #endregion pageExistingCryptoKey.NextPage = _troubleshooting ? pageChangeCryptoKey : pageSetupFinished; }
private void buttonVerify_Click(object sender, EventArgs e) { try { using (var handler = new DialogTaskHandler(this)) { foreach (var entry in _treeView.CheckedEntries.Select(x => x.BackingNode).OfType<ImplementationNode>()) entry.Verify(handler); } } #region Error handling catch (OperationCanceledException) {} catch (IOException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Warn); } catch (UnauthorizedAccessException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Warn); } #endregion RefreshList(); }
/// <summary> /// Signs a number of <see cref="Feed"/>s with a single <see cref="OpenPgpSecretKey"/>. /// </summary> /// <param name="secretKey">The private key to use for signing the files.</param> /// <param name="passphrase">The passphrase to use to unlock the key.</param> /// <exception cref="IOException">The feed file could not be read or written.</exception> /// <exception cref="UnauthorizedAccessException">Read or write access to the feed file is not permitted.</exception> private void SignFiles(OpenPgpSecretKey secretKey, string passphrase) { var task = ForEachTask.Create("Signing feeds", _files, file => { SignedFeed signedFeed; try { signedFeed = SignedFeed.Load(file.FullName); } #region Error handling catch (UnauthorizedAccessException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } catch (InvalidDataException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message + (ex.InnerException == null ? "" : Environment.NewLine + ex.InnerException.Message), ex); } #endregion signedFeed.SecretKey = secretKey; try { signedFeed.Save(file.FullName, passphrase); } #region Error handling catch (UnauthorizedAccessException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } catch (KeyNotFoundException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } catch (WrongPassphraseException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } #endregion }); using (var handler = new DialogTaskHandler(this)) handler.RunTask(task); Msg.Inform(this, "Successfully signed files.", MsgSeverity.Info); }
private void buttonCreateArchive_Click(object sender, EventArgs e) { try { using (var handler = new DialogTaskHandler(this)) _installerCapture.CaptureSession.CollectFiles(textBoxArchivePath.Text, textBoxUploadUrl.Uri, handler); } #region Error handling catch (OperationCanceledException) { return; } catch (IOException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Warn); return; } catch (UnauthorizedAccessException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); return; } #endregion wizardControl.NextPage(pageEntryPoint); }
private void buttonRemove_Click(object sender, EventArgs e) { if (Msg.YesNo(this, string.Format(Resources.DeleteCheckedEntries, _treeView.CheckedEntries.Count), MsgSeverity.Warn)) { try { using (var handler = new DialogTaskHandler(this)) { foreach (var node in _treeView.CheckedEntries.Select(x => x.BackingNode).ToList()) node.Delete(handler); } } #region Error handling catch (OperationCanceledException) {} catch (KeyNotFoundException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); } catch (IOException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Warn); } catch (UnauthorizedAccessException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Warn); } #endregion finally { RefreshList(); } } }
private void buttonSkipCapture_Click(object sender, EventArgs e) { if (!Msg.YesNo(this, Resources.AskSkipCapture, MsgSeverity.Info)) return; try { using (var handler = new DialogTaskHandler(this)) _installerCapture.ExtractInstallerAsArchive(_feedBuilder, handler); } #region Error handling catch (OperationCanceledException) { return; } catch (IOException ex) { Msg.Inform(this, Resources.InstallerExtractFailed + Environment.NewLine + ex.Message, MsgSeverity.Warn); return; } catch (UnauthorizedAccessException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); return; } #endregion wizardControl.NextPage(pageArchiveExtract, skipCommit: true); }
private void pageInstallerCaptureDiff_Commit(object sender, WizardPageConfirmEventArgs e) { var session = _installerCapture.CaptureSession; if (session == null) return; try { session.InstallationDir = textBoxInstallationDir.Text; using (var handler = new DialogTaskHandler(this)) session.Diff(handler); } #region Error handling catch (InvalidOperationException ex) { e.Cancel = true; Msg.Inform(this, ex.Message, MsgSeverity.Warn); return; } catch (IOException ex) { e.Cancel = true; Msg.Inform(this, ex.Message, MsgSeverity.Warn); return; } catch (UnauthorizedAccessException ex) { e.Cancel = true; Msg.Inform(this, ex.Message, MsgSeverity.Warn); return; } #endregion try { using (var handler = new DialogTaskHandler(this)) _installerCapture.ExtractInstallerAsArchive(_feedBuilder, handler); pageInstallerCaptureDiff.NextPage = pageArchiveExtract; } catch (IOException) { Msg.Inform(this, Resources.InstallerExtractFailed + Environment.NewLine + Resources.InstallerNeedAltSource, MsgSeverity.Info); pageInstallerCaptureDiff.NextPage = pageInstallerCollectFiles; } #region Error handling catch (OperationCanceledException) { e.Cancel = true; } catch (UnauthorizedAccessException ex) { e.Cancel = true; Msg.Inform(this, ex.Message, MsgSeverity.Error); } #endregion }
private void pageArchiveExtract_Commit(object sender, WizardPageConfirmEventArgs e) { using (var handler = new DialogTaskHandler(this)) { if (FileUtils.IsBreakoutPath(listBoxExtract.Text)) { e.Cancel = true; Msg.Inform(this, Resources.ArchiveBreakoutPath, MsgSeverity.Error); return; } _archive.Extract = listBoxExtract.Text ?? ""; _feedBuilder.ImplementationDirectory = Path.Combine(_feedBuilder.TemporaryDirectory, FileUtils.UnifySlashes(_archive.Extract)); try { // Candidate detection is handled differently when capturing an installer if (_installerCapture.CaptureSession == null) _feedBuilder.DetectCandidates(handler); _feedBuilder.CalculateDigest(handler); } #region Error handling catch (OperationCanceledException) { e.Cancel = true; return; } catch (ArgumentException ex) { e.Cancel = true; Msg.Inform(this, ex.Message, MsgSeverity.Warn); return; } catch (IOException ex) { e.Cancel = true; Msg.Inform(this, ex.Message, MsgSeverity.Warn); return; } catch (UnauthorizedAccessException ex) { e.Cancel = true; Msg.Inform(this, ex.Message, MsgSeverity.Error); return; } #endregion } if (_feedBuilder.ManifestDigest.PartialEquals(ManifestDigest.Empty)) { Msg.Inform(this, Resources.EmptyImplementation, MsgSeverity.Warn); e.Cancel = true; } if (_feedBuilder.MainCandidate == null) { Msg.Inform(this, Resources.NoEntryPointsFound, MsgSeverity.Warn); e.Cancel = true; } }
private void pageInstallerCaptureStart_Commit(object sender, WizardPageConfirmEventArgs e) { try { var captureSession = CaptureSession.Start(_feedBuilder); using (var handler = new DialogTaskHandler(this)) _installerCapture.RunInstaller(handler); _installerCapture.CaptureSession = captureSession; } #region Error handling catch (OperationCanceledException) { e.Cancel = true; } catch (IOException ex) { e.Cancel = true; Msg.Inform(this, ex.Message, MsgSeverity.Warn); } catch (UnauthorizedAccessException ex) { e.Cancel = true; Msg.Inform(this, ex.Message, MsgSeverity.Warn); } catch (InvalidOperationException ex) { e.Cancel = true; Msg.Inform(this, ex.Message, MsgSeverity.Error); } #endregion }
private void Retrieve(DownloadRetrievalMethod retrievalMethod, string localPath) { _feedBuilder.RetrievalMethod = retrievalMethod; using (var handler = new DialogTaskHandler(this)) { _feedBuilder.TemporaryDirectory = (localPath == null) ? retrievalMethod.DownloadAndApply(handler) : retrievalMethod.LocalApply(localPath, handler); } }
private void OnInstaller() { if (checkLocalCopy.Checked) _installerCapture.SetLocal(textBoxDownloadUrl.Uri, textBoxLocalPath.Text); else { using (var handler = new DialogTaskHandler(this)) _installerCapture.Download(textBoxDownloadUrl.Uri, handler); } pageDownload.NextPage = pageIstallerCaptureStart; }
private void OnSingleFile() { Retrieve( new SingleFile {Href = textBoxDownloadUrl.Uri}, checkLocalCopy.Checked ? textBoxLocalPath.Text : null); _feedBuilder.ImplementationDirectory = _feedBuilder.TemporaryDirectory; using (var handler = new DialogTaskHandler(this)) { _feedBuilder.DetectCandidates(handler); _feedBuilder.CalculateDigest(handler); } if (_feedBuilder.MainCandidate == null) throw new NotSupportedException(Resources.NoEntryPointsFound); else { _feedBuilder.GenerateCommands(); pageDownload.NextPage = pageDetails; } }
/// <summary> /// Adds a feed to the list of custom feeds. /// </summary> private void AddCustomFeed(string input) { FeedUri feedUri; try { feedUri = new FeedUri(input); } catch (UriFormatException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); return; } if (_interfaceUri.IsFile) { if (!File.Exists(_interfaceUri.LocalPath)) { Msg.Inform(this, string.Format(Resources.FileOrDirNotFound, _interfaceUri.LocalPath), MsgSeverity.Warn); return; } } else { Feed feed = null; try { using (var handler = new DialogTaskHandler(this)) { handler.RunTask(new SimpleTask(Resources.CheckingFeed, delegate { using (var webClient = new WebClientTimeout()) feed = XmlStorage.FromXmlString<Feed>(webClient.DownloadString(feedUri)); })); } } #region Error handling catch (OperationCanceledException) { return; } catch (IOException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); return; } catch (InvalidDataException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); return; } catch (WebException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); return; } catch (UnauthorizedAccessException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); return; } #endregion // Ensure a matching <feed-for> is present for online feeds if (feed.FeedFor.All(entry => entry.Target != _interfaceUri)) if (!Msg.YesNo(this, Resources.IgnoreMissingFeedFor, MsgSeverity.Warn)) return; } var reference = new FeedReference {Source = feedUri}; if (_interfacePreferences.Feeds.Contains(reference)) return; _interfacePreferences.Feeds.Add(reference); listBoxFeeds.Items.Add(reference); }
private void AddCatalogSource(string input) { try { var uri = new FeedUri(input); if (listBoxCatalogSources.Items.Contains(uri)) return; using (var handler = new DialogTaskHandler(this)) { var services = new ServiceLocator(handler); services.CatalogManager.DownloadCatalog(uri); } listBoxCatalogSources.Items.Add(uri); // Trusted keys may have changed as a side-effect LoadTrust(); } #region Error handling catch (OperationCanceledException) {} catch (UriFormatException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); } catch (WebException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); } catch (SignatureException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); } catch (IOException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); } catch (InvalidDataException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); } #endregion }