VPN: Tunnel container shall provide direct access to the configuration object

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2018-10-24 17:21:39 +05:30
parent 06c84a22ca
commit 6cddb9e34b
3 changed files with 7 additions and 4 deletions

View File

@ -25,7 +25,7 @@ class TunnelDetailTableViewController: UITableViewController {
init(tunnelsManager tm: TunnelsManager, tunnel t: TunnelContainer) { init(tunnelsManager tm: TunnelsManager, tunnel t: TunnelContainer) {
tunnelsManager = tm tunnelsManager = tm
tunnel = t tunnel = t
tunnelViewModel = TunnelViewModel(tunnelConfiguration: t.tunnelProvider.tunnelConfiguration) tunnelViewModel = TunnelViewModel(tunnelConfiguration: t.tunnelConfiguration)
super.init(style: .grouped) super.init(style: .grouped)
} }
@ -55,7 +55,7 @@ class TunnelDetailTableViewController: UITableViewController {
extension TunnelDetailTableViewController: TunnelEditTableViewControllerDelegate { extension TunnelDetailTableViewController: TunnelEditTableViewControllerDelegate {
func saved(tunnel: TunnelContainer) { func saved(tunnel: TunnelContainer) {
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelProvider.tunnelConfiguration) tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
self.tableView.reloadData() self.tableView.reloadData()
} }
} }

View File

@ -32,7 +32,7 @@ class TunnelEditTableViewController: UITableViewController {
init(tunnelsManager tm: TunnelsManager, tunnel t: TunnelContainer? = nil) { init(tunnelsManager tm: TunnelsManager, tunnel t: TunnelContainer? = nil) {
tunnelsManager = tm tunnelsManager = tm
tunnel = t tunnel = t
tunnelViewModel = TunnelViewModel(tunnelConfiguration: t?.tunnelProvider.tunnelConfiguration) tunnelViewModel = TunnelViewModel(tunnelConfiguration: t?.tunnelConfiguration)
super.init(style: .grouped) super.init(style: .grouped)
self.modalPresentationStyle = .formSheet self.modalPresentationStyle = .formSheet
} }

View File

@ -6,7 +6,7 @@ import Foundation
class TunnelProviderManager { class TunnelProviderManager {
// Mock of NETunnelProviderManager // Mock of NETunnelProviderManager
var name: String var name: String
var tunnelConfiguration: TunnelConfiguration fileprivate var tunnelConfiguration: TunnelConfiguration
init(tunnelConfiguration: TunnelConfiguration) { init(tunnelConfiguration: TunnelConfiguration) {
self.name = tunnelConfiguration.interface.name self.name = tunnelConfiguration.interface.name
self.tunnelConfiguration = tunnelConfiguration self.tunnelConfiguration = tunnelConfiguration
@ -16,6 +16,9 @@ class TunnelProviderManager {
class TunnelContainer { class TunnelContainer {
var name: String { return tunnelProvider.name } var name: String { return tunnelProvider.name }
let tunnelProvider: TunnelProviderManager let tunnelProvider: TunnelProviderManager
var tunnelConfiguration: TunnelConfiguration {
get { return tunnelProvider.tunnelConfiguration }
}
var index: Int var index: Int
init(tunnel: TunnelProviderManager, index: Int) { init(tunnel: TunnelProviderManager, index: Int) {
self.tunnelProvider = tunnel self.tunnelProvider = tunnel