mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-01-17 22:19:08 +00:00
Customize block on passphrase input cancellation
Do not delete .ovpn file when importing from iTunes.
This commit is contained in:
parent
8f0e28e315
commit
f3e6c34bd1
@ -101,7 +101,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
|
||||
let passphraseBlock = { (passphrase) in
|
||||
_ = self.tryParseURL(url, passphrase: passphrase, target: target)
|
||||
}
|
||||
guard let parsingResult = ConfigurationParser.ParsingResult.from(url, withErrorAlertIn: target, passphrase: passphrase, passphraseBlock: passphraseBlock) else {
|
||||
let passphraseCancelBlock = {
|
||||
_ = try? FileManager.default.removeItem(at: url)
|
||||
}
|
||||
guard let parsingResult = ConfigurationParser.ParsingResult.from(url, withErrorAlertIn: target, passphrase: passphrase, passphraseBlock: passphraseBlock, passphraseCancelBlock: passphraseCancelBlock) else {
|
||||
return true
|
||||
}
|
||||
if let warning = parsingResult.warning {
|
||||
|
@ -32,7 +32,9 @@ import Passepartout_Core
|
||||
private let log = SwiftyBeaver.self
|
||||
|
||||
extension ConfigurationParser.ParsingResult {
|
||||
static func from(_ url: URL, withErrorAlertIn viewController: UIViewController, passphrase: String?, passphraseBlock: @escaping (String) -> Void) -> ConfigurationParser.ParsingResult? {
|
||||
static func from(_ url: URL, withErrorAlertIn viewController: UIViewController, passphrase: String?,
|
||||
passphraseBlock: @escaping (String) -> Void, passphraseCancelBlock: (() -> Void)?) -> ConfigurationParser.ParsingResult? {
|
||||
|
||||
let result: ConfigurationParser.ParsingResult
|
||||
let fm = FileManager.default
|
||||
|
||||
@ -51,7 +53,7 @@ extension ConfigurationParser.ParsingResult {
|
||||
passphraseBlock(passphrase)
|
||||
}
|
||||
alert.addCancelAction(L10n.Global.cancel) {
|
||||
try? fm.removeItem(at: url)
|
||||
passphraseCancelBlock?()
|
||||
}
|
||||
viewController.present(alert, animated: true, completion: nil)
|
||||
|
||||
|
@ -88,7 +88,7 @@ class ImportedHostsViewController: UITableViewController {
|
||||
}
|
||||
self.perform(segue: StoryboardSegue.Organizer.importHostSegueIdentifier, sender: cell)
|
||||
}
|
||||
guard let parsingResult = ConfigurationParser.ParsingResult.from(url, withErrorAlertIn: self, passphrase: passphrase, passphraseBlock: passphraseBlock) else {
|
||||
guard let parsingResult = ConfigurationParser.ParsingResult.from(url, withErrorAlertIn: self, passphrase: passphrase, passphraseBlock: passphraseBlock, passphraseCancelBlock: nil) else {
|
||||
deselectSelectedRow()
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user