Add cells to disclose server settings

TODO: server network.
This commit is contained in:
Davide De Rosa 2019-10-23 10:17:56 +02:00
parent 343fb69ae3
commit 458041bdc8
3 changed files with 69 additions and 2 deletions

View File

@ -712,6 +712,10 @@ internal enum L10n {
/// Reconnect
internal static let reconnect = L10n.tr("Core", "service.alerts.buttons.reconnect")
}
internal enum Configuration {
/// Configuration unavailable, make sure you are connected to the VPN.
internal static let disconnected = L10n.tr("Core", "service.alerts.configuration.disconnected")
}
internal enum CredentialsNeeded {
/// You need to enter account credentials first.
internal static let message = L10n.tr("Core", "service.alerts.credentials_needed.message")
@ -808,6 +812,14 @@ internal enum L10n {
/// Report connectivity issue
internal static let caption = L10n.tr("Core", "service.cells.report_issue.caption")
}
internal enum ServerConfiguration {
/// Server configuration
internal static let caption = L10n.tr("Core", "service.cells.server_configuration.caption")
}
internal enum ServerNetwork {
/// Server network
internal static let caption = L10n.tr("Core", "service.cells.server_network.caption")
}
internal enum TestConnectivity {
/// Test connectivity
internal static let caption = L10n.tr("Core", "service.cells.test_connectivity.caption")

View File

@ -476,6 +476,41 @@ class ServiceViewController: UIViewController, StrongTableHost {
// }
// }
private func discloseServerConfiguration() {
let caption = L10n.Core.Service.Cells.ServerConfiguration.caption
tryRequestServerConfiguration(withCaption: caption) { [weak self] in
let vc = StoryboardScene.Main.configurationIdentifier.instantiate()
vc.title = caption
vc.initialConfiguration = $0
self?.navigationController?.pushViewController(vc, animated: true)
}
}
private func discloseServerNetwork() {
let caption = L10n.Core.Service.Cells.ServerNetwork.caption
tryRequestServerConfiguration(withCaption: caption) { [weak self] in
let vc = StoryboardScene.Main.configurationIdentifier.instantiate()
vc.title = caption
vc.initialConfiguration = $0
self?.navigationController?.pushViewController(vc, animated: true)
}
}
private func tryRequestServerConfiguration(withCaption caption: String, completionHandler: @escaping (OpenVPN.Configuration) -> Void) {
vpn.requestServerConfiguration { [weak self] in
guard let cfg = $0 as? OpenVPN.Configuration else {
let alert = UIAlertController.asAlert(
caption,
L10n.Core.Service.Alerts.Configuration.disconnected
)
alert.addCancelAction(L10n.Core.Global.ok)
self?.present(alert, animated: true, completion: nil)
return
}
completionHandler(cfg)
}
}
private func togglePrivateDataMasking(cell: ToggleTableViewCell) {
let handler = {
TransientStore.masksPrivateData = cell.isOn
@ -658,6 +693,10 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
case dataCount
case serverConfiguration
case serverNetwork
case debugLog
case masksPrivateData
@ -884,6 +923,16 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
cell.accessoryType = .none
cell.isTappable = false
return cell
case .serverConfiguration:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.Core.Service.Cells.ServerConfiguration.caption
return cell
case .serverNetwork:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.Core.Service.Cells.ServerNetwork.caption
return cell
case .debugLog:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
@ -987,6 +1036,12 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
// case .dataCount:
// displayDataCount()
case .serverConfiguration:
discloseServerConfiguration()
case .serverNetwork:
discloseServerNetwork()
case .debugLog:
perform(segue: StoryboardSegue.Main.debugLogSegueIdentifier, sender: cell)
@ -1125,7 +1180,7 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
}
model.set([.vpnSurvivesSleep], forSection: .vpnSurvivesSleep)
model.set([.trustedPolicy], forSection: .trustedPolicy)
model.set([.dataCount, .debugLog, .masksPrivateData], forSection: .diagnostics)
model.set([.dataCount, .serverConfiguration, .serverNetwork, .debugLog, .masksPrivateData], forSection: .diagnostics)
model.set([.reportIssue], forSection: .feedback)
}

@ -1 +1 @@
Subproject commit 7fabb48cee5189bd3c0d65c3af30cf458f69a1e3
Subproject commit 8c09f2c3c70da0478cc1b6e94837b1aeb3a0ddde