2017-01-19 21:15:47 +08:00
|
|
|
//
|
|
|
|
|
// SettingsTableViewController.swift
|
|
|
|
|
// pass
|
|
|
|
|
//
|
|
|
|
|
// Created by Mingshen Sun on 18/1/2017.
|
|
|
|
|
// Copyright © 2017 Bob Sun. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import CoreData
|
2017-06-13 11:42:49 +08:00
|
|
|
import passKit
|
2020-06-28 21:25:40 +02:00
|
|
|
import SVProgressHUD
|
|
|
|
|
import UIKit
|
2023-03-12 16:10:29 -07:00
|
|
|
import YubiKit
|
2017-01-19 21:15:47 +08:00
|
|
|
|
2018-01-16 20:26:41 -08:00
|
|
|
class SettingsTableViewController: UITableViewController, UITabBarControllerDelegate {
|
2020-06-28 21:25:40 +02:00
|
|
|
@IBOutlet var pgpKeyTableViewCell: UITableViewCell!
|
|
|
|
|
@IBOutlet var passcodeTableViewCell: UITableViewCell!
|
|
|
|
|
@IBOutlet var passwordRepositoryTableViewCell: UITableViewCell!
|
2018-01-29 03:23:34 +08:00
|
|
|
var setPasscodeLockAlert: UIAlertController?
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2019-09-08 23:00:46 +02:00
|
|
|
let keychain = AppKeychain.shared
|
2018-01-29 03:23:34 +08:00
|
|
|
var passcodeLock = PasscodeLock.shared
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2020-06-28 21:25:40 +02:00
|
|
|
func tabBarController(_: UITabBarController, didSelect _: UIViewController) {
|
2018-01-16 20:26:41 -08:00
|
|
|
navigationController?.popViewController(animated: true)
|
|
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2020-06-28 21:25:40 +02:00
|
|
|
@IBAction
|
2020-07-05 22:49:53 +02:00
|
|
|
private func savePGPKey(segue: UIStoryboardSegue) {
|
2020-02-10 21:59:56 +01:00
|
|
|
guard let sourceController = segue.source as? PGPKeyImporter, sourceController.isReadyToUse() else {
|
2020-02-08 13:31:49 +01:00
|
|
|
return
|
2017-01-19 21:15:47 +08:00
|
|
|
}
|
2020-02-08 13:31:49 +01:00
|
|
|
savePGPKey(using: sourceController)
|
2017-01-19 21:15:47 +08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2020-02-08 13:31:49 +01:00
|
|
|
private func savePGPKey(using keyImporter: PGPKeyImporter) {
|
2017-06-07 21:11:01 +08:00
|
|
|
SVProgressHUD.setDefaultMaskType(.black)
|
|
|
|
|
SVProgressHUD.setDefaultStyle(.light)
|
2019-01-14 20:57:45 +01:00
|
|
|
SVProgressHUD.show(withStatus: "FetchingPgpKey".localize())
|
2017-06-07 21:11:01 +08:00
|
|
|
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
|
2020-02-09 22:39:59 +01:00
|
|
|
Defaults.pgpKeySource = type(of: keyImporter).keySource
|
2017-06-07 21:11:01 +08:00
|
|
|
do {
|
2020-04-14 11:55:18 -07:00
|
|
|
// Remove exiting passphrase
|
|
|
|
|
AppKeychain.shared.removeAllContent(withPrefix: Globals.pgpKeyPassphrase)
|
2020-02-08 13:31:49 +01:00
|
|
|
try keyImporter.importKeys()
|
2019-09-08 23:00:46 +02:00
|
|
|
try PGPAgent.shared.initKeys()
|
2017-06-07 21:11:01 +08:00
|
|
|
DispatchQueue.main.async {
|
2019-10-01 01:19:41 +08:00
|
|
|
self.setPGPKeyTableViewCellDetailText()
|
2020-02-08 13:31:49 +01:00
|
|
|
SVProgressHUD.showSuccess(withStatus: "Success".localize())
|
2017-06-07 21:11:01 +08:00
|
|
|
SVProgressHUD.dismiss(withDelay: 1)
|
2020-02-08 13:31:49 +01:00
|
|
|
keyImporter.doAfterImport()
|
2017-06-07 21:11:01 +08:00
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
DispatchQueue.main.async {
|
2019-01-14 20:57:45 +01:00
|
|
|
self.pgpKeyTableViewCell.detailTextLabel?.text = "NotSet".localize()
|
|
|
|
|
Utils.alert(title: "Error".localize(), message: error.localizedDescription, controller: self, completion: nil)
|
2017-06-07 21:11:01 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2020-06-28 21:25:40 +02:00
|
|
|
@IBAction
|
2020-07-05 22:49:53 +02:00
|
|
|
private func saveGitServerSetting(segue _: UIStoryboardSegue) {
|
2020-06-28 21:25:40 +02:00
|
|
|
passwordRepositoryTableViewCell.detailTextLabel?.text = Defaults.gitURL.host
|
2017-02-21 13:07:14 +08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2017-01-19 21:15:47 +08:00
|
|
|
override func viewDidLoad() {
|
|
|
|
|
super.viewDidLoad()
|
2021-10-03 05:46:07 +02:00
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(actOnPasswordStoreErasedNotification), name: .passwordStoreErased, object: nil)
|
2020-06-28 21:25:40 +02:00
|
|
|
passwordRepositoryTableViewCell.detailTextLabel?.text = Defaults.gitURL.host
|
2017-02-26 20:59:27 +08:00
|
|
|
setPGPKeyTableViewCellDetailText()
|
2018-01-29 03:23:34 +08:00
|
|
|
setPasscodeLockCell()
|
2017-02-26 20:59:27 +08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2020-06-28 21:25:40 +02:00
|
|
|
override func viewWillAppear(_: Bool) {
|
2018-01-16 21:54:00 -08:00
|
|
|
super.viewWillAppear(true)
|
|
|
|
|
tabBarController!.delegate = self
|
2019-12-01 00:25:24 -08:00
|
|
|
setPasswordRepositoryTableViewCellDetailText()
|
2018-01-16 21:54:00 -08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2018-01-29 03:23:34 +08:00
|
|
|
private func setPasscodeLockCell() {
|
|
|
|
|
if passcodeLock.hasPasscode {
|
2020-06-28 21:25:40 +02:00
|
|
|
passcodeTableViewCell.detailTextLabel?.text = "On".localize()
|
2017-02-26 20:59:27 +08:00
|
|
|
} else {
|
2020-06-28 21:25:40 +02:00
|
|
|
passcodeTableViewCell.detailTextLabel?.text = "Off".localize()
|
2017-02-26 20:59:27 +08:00
|
|
|
}
|
|
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2017-02-26 20:59:27 +08:00
|
|
|
private func setPGPKeyTableViewCellDetailText() {
|
2020-04-13 19:15:52 -07:00
|
|
|
var label = "NotSet".localize()
|
2022-01-09 21:38:39 -08:00
|
|
|
|
2026-03-11 16:16:50 +01:00
|
|
|
var keyIDs = Set<String>((try? PGPAgent.shared.getShortKeyIDs(type: .PRIVATE)) ?? [])
|
|
|
|
|
keyIDs.formUnion((try? PGPAgent.shared.getShortKeyIDs(type: .PUBLIC)) ?? [])
|
|
|
|
|
|
|
|
|
|
if keyIDs.count == 1 {
|
|
|
|
|
label = keyIDs.first ?? ""
|
|
|
|
|
} else if keyIDs.count > 1 {
|
2020-04-13 19:15:52 -07:00
|
|
|
label = "Multiple"
|
|
|
|
|
}
|
2022-01-09 21:38:39 -08:00
|
|
|
if Defaults.isYubiKeyEnabled {
|
|
|
|
|
label += "+YubiKey"
|
|
|
|
|
}
|
2020-04-13 19:15:52 -07:00
|
|
|
pgpKeyTableViewCell.detailTextLabel?.text = label
|
2017-02-26 20:59:27 +08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2017-02-26 20:59:27 +08:00
|
|
|
private func setPasswordRepositoryTableViewCellDetailText() {
|
2019-11-30 15:11:28 -08:00
|
|
|
let host: String? = {
|
2020-01-02 00:48:00 +01:00
|
|
|
let gitURL = Defaults.gitURL
|
2019-11-30 15:11:28 -08:00
|
|
|
if gitURL.scheme == nil {
|
|
|
|
|
return URL(string: "scheme://" + gitURL.absoluteString)?.host
|
|
|
|
|
}
|
2021-01-31 13:34:37 +01:00
|
|
|
return gitURL.host
|
2019-11-30 15:11:28 -08:00
|
|
|
}()
|
|
|
|
|
passwordRepositoryTableViewCell.detailTextLabel?.text = host
|
2017-02-26 20:59:27 +08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2020-06-28 21:25:40 +02:00
|
|
|
@objc
|
|
|
|
|
func actOnPasswordStoreErasedNotification() {
|
2017-02-26 20:59:27 +08:00
|
|
|
setPGPKeyTableViewCellDetailText()
|
|
|
|
|
setPasswordRepositoryTableViewCellDetailText()
|
2018-01-29 03:23:34 +08:00
|
|
|
setPasscodeLockCell()
|
2017-02-09 11:31:49 +08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2019-11-17 20:29:22 -08:00
|
|
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
|
|
let cell = super.tableView(tableView, cellForRowAt: indexPath)
|
|
|
|
|
cell.textLabel?.font = UIFont.preferredFont(forTextStyle: .body)
|
2019-11-18 18:13:48 -08:00
|
|
|
cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .body)
|
2019-11-17 20:29:22 -08:00
|
|
|
cell.textLabel?.adjustsFontForContentSizeCategory = true
|
|
|
|
|
cell.detailTextLabel?.adjustsFontForContentSizeCategory = true
|
|
|
|
|
return cell
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-07 17:56:31 +08:00
|
|
|
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
2019-11-17 17:52:31 -08:00
|
|
|
let cell = tableView.cellForRow(at: indexPath)
|
|
|
|
|
|
|
|
|
|
if cell == passcodeTableViewCell {
|
2019-07-10 21:57:15 +02:00
|
|
|
if passcodeLock.hasPasscode {
|
2017-02-07 20:24:58 +08:00
|
|
|
showPasscodeActionSheet()
|
|
|
|
|
} else {
|
|
|
|
|
setPasscodeLock()
|
|
|
|
|
}
|
2019-11-17 17:52:31 -08:00
|
|
|
} else if cell == pgpKeyTableViewCell {
|
2017-02-17 13:44:25 +08:00
|
|
|
showPGPKeyActionSheet()
|
2017-02-07 17:56:31 +08:00
|
|
|
}
|
2017-02-17 13:44:25 +08:00
|
|
|
tableView.deselectRow(at: indexPath, animated: true)
|
2017-02-07 16:45:14 +08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2021-01-31 13:17:37 +01:00
|
|
|
override func tableView(_: UITableView, heightForRowAt _: IndexPath) -> CGFloat {
|
2021-01-05 23:27:35 -08:00
|
|
|
UITableView.automaticDimension
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-31 13:17:37 +01:00
|
|
|
override func tableView(_: UITableView, estimatedHeightForRowAt _: IndexPath) -> CGFloat {
|
2021-01-05 23:27:35 -08:00
|
|
|
UITableView.automaticDimension
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 13:44:25 +08:00
|
|
|
func showPGPKeyActionSheet() {
|
|
|
|
|
let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
2020-07-05 00:16:22 +02:00
|
|
|
optionMenu.addAction(
|
2021-12-28 02:57:11 +01:00
|
|
|
UIAlertAction(title: PGPKeyURLImportTableViewController.menuLabel, style: .default) { _ in
|
2020-07-05 00:16:22 +02:00
|
|
|
self.performSegue(withIdentifier: "setPGPKeyByURLSegue", sender: self)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
optionMenu.addAction(
|
|
|
|
|
UIAlertAction(title: PGPKeyArmorImportTableViewController.menuLabel, style: .default) { _ in
|
|
|
|
|
self.performSegue(withIdentifier: "setPGPKeyByASCIISegue", sender: self)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
optionMenu.addAction(
|
|
|
|
|
UIAlertAction(title: PGPKeyFileImportTableViewController.menuLabel, style: .default) { _ in
|
|
|
|
|
self.performSegue(withIdentifier: "setPGPKeyByFileSegue", sender: self)
|
|
|
|
|
}
|
|
|
|
|
)
|
2020-02-08 13:31:49 +01:00
|
|
|
|
|
|
|
|
if isReadyToUse() {
|
2020-07-05 00:16:22 +02:00
|
|
|
optionMenu.addAction(
|
|
|
|
|
UIAlertAction(title: "\(Self.menuLabel) (\("Import".localize()))", style: .default) { _ in
|
|
|
|
|
self.saveImportedKeys()
|
|
|
|
|
}
|
|
|
|
|
)
|
2017-06-07 16:54:54 +08:00
|
|
|
} else {
|
2020-07-05 00:16:22 +02:00
|
|
|
optionMenu.addAction(
|
|
|
|
|
UIAlertAction(title: "\(Self.menuLabel) (\("Tips".localize()))", style: .default) { _ in
|
|
|
|
|
let title = "Tips".localize()
|
|
|
|
|
let message = "PgpCopyPublicAndPrivateKeyToPass.".localize()
|
|
|
|
|
Utils.alert(title: title, message: message, controller: self)
|
|
|
|
|
}
|
|
|
|
|
)
|
2017-02-24 17:59:04 +03:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2023-03-17 22:20:50 -07:00
|
|
|
if YubiKitDeviceCapabilities.supportsISO7816NFCTags {
|
2023-03-12 16:10:29 -07:00
|
|
|
optionMenu.addAction(
|
|
|
|
|
UIAlertAction(title: Defaults.isYubiKeyEnabled ? "✓ YubiKey" : "YubiKey", style: .default) { _ in
|
|
|
|
|
Defaults.isYubiKeyEnabled.toggle()
|
|
|
|
|
self.setPGPKeyTableViewCellDetailText()
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
2022-01-09 21:38:39 -08:00
|
|
|
|
2020-01-02 00:48:00 +01:00
|
|
|
if Defaults.pgpKeySource != nil {
|
2020-07-05 00:16:22 +02:00
|
|
|
optionMenu.addAction(
|
|
|
|
|
UIAlertAction(title: "RemovePgpKeys".localize(), style: .destructive) { _ in
|
2021-12-29 16:19:12 -08:00
|
|
|
let alert = UIAlertController.removeConfirmationAlert(title: "RemovePgpKeys".localize(), message: "") { _ in
|
|
|
|
|
self.keychain.removeContent(for: PGPKey.PUBLIC.getKeychainKey())
|
|
|
|
|
self.keychain.removeContent(for: PGPKey.PRIVATE.getKeychainKey())
|
|
|
|
|
PGPAgent.shared.uninitKeys()
|
|
|
|
|
self.pgpKeyTableViewCell.detailTextLabel?.text = "NotSet".localize()
|
|
|
|
|
Defaults.pgpKeySource = nil
|
|
|
|
|
}
|
|
|
|
|
self.present(alert, animated: true, completion: nil)
|
2020-07-05 00:16:22 +02:00
|
|
|
}
|
|
|
|
|
)
|
2017-02-17 13:44:25 +08:00
|
|
|
}
|
2020-04-17 23:56:14 -07:00
|
|
|
optionMenu.addAction(UIAlertAction.cancel())
|
2017-02-22 18:18:59 +08:00
|
|
|
optionMenu.popoverPresentationController?.sourceView = pgpKeyTableViewCell
|
|
|
|
|
optionMenu.popoverPresentationController?.sourceRect = pgpKeyTableViewCell.bounds
|
2020-02-15 18:12:58 +01:00
|
|
|
present(optionMenu, animated: true)
|
2017-02-17 13:44:25 +08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2017-02-07 17:56:31 +08:00
|
|
|
func showPasscodeActionSheet() {
|
|
|
|
|
let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
2018-01-29 03:23:34 +08:00
|
|
|
let passcodeRemoveViewController = PasscodeLockViewController()
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2019-01-14 20:57:45 +01:00
|
|
|
let removePasscodeAction = UIAlertAction(title: "RemovePasscode".localize(), style: .destructive) { [weak self] _ in
|
2020-06-28 21:25:40 +02:00
|
|
|
passcodeRemoveViewController.successCallback = {
|
2018-01-29 03:23:34 +08:00
|
|
|
self?.passcodeLock.delete()
|
|
|
|
|
self?.setPasscodeLockCell()
|
2017-02-07 20:24:58 +08:00
|
|
|
}
|
2017-02-10 00:56:12 +08:00
|
|
|
self?.present(passcodeRemoveViewController, animated: true, completion: nil)
|
2017-02-07 20:24:58 +08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2019-01-14 20:57:45 +01:00
|
|
|
let changePasscodeAction = UIAlertAction(title: "ChangePasscode".localize(), style: .default) { [weak self] _ in
|
2018-01-29 03:23:34 +08:00
|
|
|
self?.setPasscodeLock()
|
2017-02-07 20:24:58 +08:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2017-02-07 17:56:31 +08:00
|
|
|
optionMenu.addAction(removePasscodeAction)
|
|
|
|
|
optionMenu.addAction(changePasscodeAction)
|
2020-04-17 23:56:14 -07:00
|
|
|
optionMenu.addAction(UIAlertAction.cancel())
|
2017-02-22 18:18:59 +08:00
|
|
|
optionMenu.popoverPresentationController?.sourceView = passcodeTableViewCell
|
|
|
|
|
optionMenu.popoverPresentationController?.sourceRect = passcodeTableViewCell.bounds
|
2020-06-28 21:25:40 +02:00
|
|
|
present(optionMenu, animated: true, completion: nil)
|
2017-02-07 17:56:31 +08:00
|
|
|
}
|
2018-01-29 03:23:34 +08:00
|
|
|
|
2020-06-28 21:25:40 +02:00
|
|
|
@objc
|
|
|
|
|
func alertTextFieldDidChange(_ sender: UITextField) {
|
2018-01-29 03:23:34 +08:00
|
|
|
// check whether we should enable the Save button in setPasscodeLockAlert
|
2023-04-23 22:01:37 +02:00
|
|
|
if let setPasscodeLockAlert,
|
2020-11-07 12:06:28 +01:00
|
|
|
let setPasscodeLockAlertTextFields0 = setPasscodeLockAlert.textFields?[0],
|
|
|
|
|
let setPasscodeLockAlertTextFields1 = setPasscodeLockAlert.textFields?[1] {
|
2018-01-29 03:23:34 +08:00
|
|
|
if sender == setPasscodeLockAlertTextFields0 || sender == setPasscodeLockAlertTextFields1 {
|
|
|
|
|
// two passwords should be the same, and length >= 4
|
|
|
|
|
let passcodeText = setPasscodeLockAlertTextFields0.text!
|
|
|
|
|
let passcodeConfirmationText = setPasscodeLockAlertTextFields1.text!
|
|
|
|
|
setPasscodeLockAlert.actions[0].isEnabled = passcodeText == passcodeConfirmationText && passcodeText.count >= 4
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2017-02-07 20:24:58 +08:00
|
|
|
func setPasscodeLock() {
|
2018-01-29 03:23:34 +08:00
|
|
|
// prepare the alert for setting the passcode
|
2019-01-14 20:57:45 +01:00
|
|
|
setPasscodeLockAlert = UIAlertController(title: "SetPasscode".localize(), message: "FillInAppPasscode.".localize(), preferredStyle: .alert)
|
2021-12-28 02:57:11 +01:00
|
|
|
setPasscodeLockAlert?.addTextField { textField in
|
2019-02-13 21:31:40 +01:00
|
|
|
textField.placeholder = "Passcode".localize()
|
2018-01-29 03:23:34 +08:00
|
|
|
textField.isSecureTextEntry = true
|
2021-10-03 05:46:07 +02:00
|
|
|
textField.addTarget(self, action: #selector(self.alertTextFieldDidChange), for: UIControl.Event.editingChanged)
|
2020-07-05 00:16:22 +02:00
|
|
|
}
|
2021-12-28 02:57:11 +01:00
|
|
|
setPasscodeLockAlert?.addTextField { textField in
|
2019-01-14 20:57:45 +01:00
|
|
|
textField.placeholder = "PasswordConfirmation".localize()
|
2018-01-29 03:23:34 +08:00
|
|
|
textField.isSecureTextEntry = true
|
2021-10-03 05:46:07 +02:00
|
|
|
textField.addTarget(self, action: #selector(self.alertTextFieldDidChange), for: UIControl.Event.editingChanged)
|
2020-07-05 00:16:22 +02:00
|
|
|
}
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2018-01-29 03:23:34 +08:00
|
|
|
// save action
|
2021-12-28 02:57:11 +01:00
|
|
|
let saveAction = UIAlertAction(title: "Save".localize(), style: .default) { (_: UIAlertAction) in
|
2018-01-29 03:23:34 +08:00
|
|
|
let passcode: String = self.setPasscodeLockAlert!.textFields![0].text!
|
|
|
|
|
self.passcodeLock.save(passcode: passcode)
|
|
|
|
|
// refresh the passcode lock cell ("On")
|
|
|
|
|
self.setPasscodeLockCell()
|
2017-02-07 20:24:58 +08:00
|
|
|
}
|
2020-06-28 21:25:40 +02:00
|
|
|
saveAction.isEnabled = false // disable the Save button by default
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2018-01-29 03:23:34 +08:00
|
|
|
// cancel action
|
2020-04-17 23:56:14 -07:00
|
|
|
let cancelAction = UIAlertAction.cancel()
|
2018-12-09 16:59:07 -08:00
|
|
|
|
2018-01-29 03:23:34 +08:00
|
|
|
// present
|
|
|
|
|
setPasscodeLockAlert?.addAction(saveAction)
|
|
|
|
|
setPasscodeLockAlert?.addAction(cancelAction)
|
2020-06-28 21:25:40 +02:00
|
|
|
present(setPasscodeLockAlert!, animated: true, completion: nil)
|
2017-02-07 20:24:58 +08:00
|
|
|
}
|
2017-01-19 21:15:47 +08:00
|
|
|
}
|
2020-02-08 13:31:49 +01:00
|
|
|
|
|
|
|
|
extension SettingsTableViewController: PGPKeyImporter {
|
2020-02-15 18:12:58 +01:00
|
|
|
static let keySource = KeySource.itunes
|
2020-02-08 13:31:49 +01:00
|
|
|
static let label = "ITunesFileSharing".localize()
|
|
|
|
|
|
|
|
|
|
func isReadyToUse() -> Bool {
|
2021-12-28 02:57:11 +01:00
|
|
|
KeyFileManager.PublicPGP.doesKeyFileExist() && KeyFileManager.PrivatePGP.doesKeyFileExist()
|
2020-02-08 13:31:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func importKeys() throws {
|
2021-12-28 02:57:11 +01:00
|
|
|
try KeyFileManager.PublicPGP.importKeyFromFileSharing()
|
|
|
|
|
try KeyFileManager.PrivatePGP.importKeyFromFileSharing()
|
2020-02-08 13:31:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func saveImportedKeys() {
|
2020-02-15 18:12:58 +01:00
|
|
|
savePGPKey(using: self)
|
2020-02-08 13:31:49 +01:00
|
|
|
}
|
|
|
|
|
}
|