mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-01-18 22:49:10 +00:00
Move trust actions to separate functions
This commit is contained in:
parent
302e281399
commit
1d7cdc7f19
@ -346,6 +346,15 @@ class ServiceViewController: UIViewController, StrongTableHost {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func trustMobileNetwork(cell: ToggleTableViewCell) {
|
||||||
|
if #available(iOS 12, *) {
|
||||||
|
IntentDispatcher.donateTrustCellularNetwork()
|
||||||
|
IntentDispatcher.donateUntrustCellularNetwork()
|
||||||
|
}
|
||||||
|
|
||||||
|
trustedNetworks.setMobile(cell.isOn)
|
||||||
|
}
|
||||||
|
|
||||||
private func trustCurrentWiFi() {
|
private func trustCurrentWiFi() {
|
||||||
if #available(iOS 13, *) {
|
if #available(iOS 13, *) {
|
||||||
let auth = CLLocationManager.authorizationStatus()
|
let auth = CLLocationManager.authorizationStatus()
|
||||||
@ -390,6 +399,14 @@ class ServiceViewController: UIViewController, StrongTableHost {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func toggleTrustWiFi(cell: ToggleTableViewCell, at row: Int) {
|
||||||
|
if cell.isOn {
|
||||||
|
trustedNetworks.enableWifi(at: row)
|
||||||
|
} else {
|
||||||
|
trustedNetworks.disableWifi(at: row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func toggleTrustedConnectionPolicy(_ isOn: Bool, sender: ToggleTableViewCell) {
|
private func toggleTrustedConnectionPolicy(_ isOn: Bool, sender: ToggleTableViewCell) {
|
||||||
let completionHandler: () -> Void = {
|
let completionHandler: () -> Void = {
|
||||||
self.service.preferences.trustPolicy = isOn ? .disconnect : .ignore
|
self.service.preferences.trustPolicy = isOn ? .disconnect : .ignore
|
||||||
@ -1071,22 +1088,13 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
|
|||||||
toggleDisconnectsOnSleep(cell.isOn)
|
toggleDisconnectsOnSleep(cell.isOn)
|
||||||
|
|
||||||
case .trustedMobile:
|
case .trustedMobile:
|
||||||
if #available(iOS 12, *) {
|
trustMobileNetwork(cell: cell)
|
||||||
IntentDispatcher.donateTrustCellularNetwork()
|
|
||||||
IntentDispatcher.donateUntrustCellularNetwork()
|
|
||||||
}
|
|
||||||
|
|
||||||
trustedNetworks.setMobile(cell.isOn)
|
|
||||||
|
|
||||||
case .trustedWiFi:
|
case .trustedWiFi:
|
||||||
guard let indexPath = tableView.indexPath(for: cell) else {
|
guard let indexPath = tableView.indexPath(for: cell) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if cell.isOn {
|
toggleTrustWiFi(cell: cell, at: indexPath.row)
|
||||||
trustedNetworks.enableWifi(at: indexPath.row)
|
|
||||||
} else {
|
|
||||||
trustedNetworks.disableWifi(at: indexPath.row)
|
|
||||||
}
|
|
||||||
|
|
||||||
case .trustedPolicy:
|
case .trustedPolicy:
|
||||||
toggleTrustedConnectionPolicy(cell.isOn, sender: cell)
|
toggleTrustedConnectionPolicy(cell.isOn, sender: cell)
|
||||||
|
Loading…
Reference in New Issue
Block a user