From ab189025b971c6419e56700d86140acd8c7a6d3f Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 28 Jun 2019 10:53:24 +0200 Subject: [PATCH 1/5] Move ProfileNetworkChoices to Core --- .../Scenes/NetworkSettingsViewController.swift | 13 +------------ Submodules/Core | 2 +- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift b/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift index 30f18a8d..3c426bca 100644 --- a/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift +++ b/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift @@ -48,21 +48,10 @@ private struct Offsets { static let proxyBypass = 2 } -// FIXME: init networkSettings with HOST profile.sessionConfiguration -// FIXME: omit "Client" for PROVIDER - class NetworkSettingsViewController: UITableViewController { var profile: ConnectionProfile? - private lazy var networkChoices: ProfileNetworkChoices = { - if let choices = profile?.networkChoices { - return choices - } - if let _ = profile as? ProviderConnectionProfile { - return ProfileNetworkChoices(choice: .server) - } - return ProfileNetworkChoices(choice: .client) - }() + private lazy var networkChoices = ProfileNetworkChoices.with(profile: profile) private let networkSettings = ProfileNetworkSettings() diff --git a/Submodules/Core b/Submodules/Core index 2d5f1f6f..2b5b2e54 160000 --- a/Submodules/Core +++ b/Submodules/Core @@ -1 +1 @@ -Subproject commit 2d5f1f6f0d4d8d8353543da547d6b531beab1894 +Subproject commit 2b5b2e547384886d3fb04ada7e926c618c443629 From b45479a733a9fefc1aa19abdecabff07c189531d Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 28 Jun 2019 12:01:00 +0200 Subject: [PATCH 2/5] Commit network settings in separate method --- .../NetworkSettingsViewController.swift | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift b/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift index 3c426bca..a147ea18 100644 --- a/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift +++ b/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift @@ -53,10 +53,10 @@ class NetworkSettingsViewController: UITableViewController { private lazy var networkChoices = ProfileNetworkChoices.with(profile: profile) - private let networkSettings = ProfileNetworkSettings() - private lazy var clientNetworkSettings = profile?.clientNetworkSettings + private let networkSettings = ProfileNetworkSettings() + // MARK: TableModelHost let model: TableModel = TableModel() @@ -124,23 +124,8 @@ class NetworkSettingsViewController: UITableViewController { override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) - - profile?.networkChoices = networkChoices - if networkChoices.gateway == .manual { - let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings() - settings.copyGateway(from: networkSettings) - profile?.manualNetworkSettings = settings - } - if networkChoices.dns == .manual { - let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings() - settings.copyDNS(from: networkSettings) - profile?.manualNetworkSettings = settings - } - if networkChoices.proxy == .manual { - let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings() - settings.copyProxy(from: networkSettings) - profile?.manualNetworkSettings = settings - } + + commitChanges() } // MARK: Actions @@ -220,6 +205,25 @@ class NetworkSettingsViewController: UITableViewController { log.debug("Network settings: \(networkSettings)") } + + private func commitChanges() { + profile?.networkChoices = networkChoices + if networkChoices.gateway == .manual { + let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings() + settings.copyGateway(from: networkSettings) + profile?.manualNetworkSettings = settings + } + if networkChoices.dns == .manual { + let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings() + settings.copyDNS(from: networkSettings) + profile?.manualNetworkSettings = settings + } + if networkChoices.proxy == .manual { + let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings() + settings.copyProxy(from: networkSettings) + profile?.manualNetworkSettings = settings + } + } } // MARK: - From 60b60646d4aca5fdfc8e2a98a1018556f49ed085 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 28 Jun 2019 19:10:42 +0200 Subject: [PATCH 3/5] Move available providers to Core --- .../Scenes/Organizer/OrganizerViewController.swift | 14 ++------------ Submodules/Core | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift index fa00011a..97020af1 100644 --- a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift @@ -183,16 +183,7 @@ class OrganizerViewController: UITableViewController, TableModelHost { } private func addNewProvider() { - var names = Set(InfrastructureFactory.shared.allNames) - var createdNames: [Infrastructure.Name] = [] - providers.forEach { - guard let name = Infrastructure.Name(rawValue: $0) else { - return - } - createdNames.append(name) - } - names.formSymmetricDifference(createdNames) - + let names = service.availableProviderNames() guard !names.isEmpty else { let alert = Macros.alert( L10n.Core.Organizer.Sections.Providers.header, @@ -202,8 +193,7 @@ class OrganizerViewController: UITableViewController, TableModelHost { present(alert, animated: true, completion: nil) return } - - availableProviderNames = names.sorted() + availableProviderNames = names perform(segue: StoryboardSegue.Organizer.addProviderSegueIdentifier) } diff --git a/Submodules/Core b/Submodules/Core index 2b5b2e54..a651c693 160000 --- a/Submodules/Core +++ b/Submodules/Core @@ -1 +1 @@ -Subproject commit 2b5b2e547384886d3fb04ada7e926c618c443629 +Subproject commit a651c693a66ca0ca3c6bb796a023ebd390d5cb3a From 1bead621fc3be8e7d74b9d74d80a12966d86f1b5 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Wed, 3 Jul 2019 17:58:14 +0200 Subject: [PATCH 4/5] Simplify commit of network settings --- .../Scenes/NetworkSettingsViewController.swift | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift b/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift index a147ea18..ff649981 100644 --- a/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift +++ b/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift @@ -207,22 +207,18 @@ class NetworkSettingsViewController: UITableViewController { } private func commitChanges() { + let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings() profile?.networkChoices = networkChoices if networkChoices.gateway == .manual { - let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings() settings.copyGateway(from: networkSettings) - profile?.manualNetworkSettings = settings } if networkChoices.dns == .manual { - let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings() settings.copyDNS(from: networkSettings) - profile?.manualNetworkSettings = settings } if networkChoices.proxy == .manual { - let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings() settings.copyProxy(from: networkSettings) - profile?.manualNetworkSettings = settings } + profile?.manualNetworkSettings = settings } } From 74e798605ec29094bec3f1e0255e604737417051 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 4 Jul 2019 10:12:28 +0200 Subject: [PATCH 5/5] Update Core --- Submodules/Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Submodules/Core b/Submodules/Core index a651c693..7f4dd3c8 160000 --- a/Submodules/Core +++ b/Submodules/Core @@ -1 +1 @@ -Subproject commit a651c693a66ca0ca3c6bb796a023ebd390d5cb3a +Subproject commit 7f4dd3c8cd031ebe536665871f5e76b15d36287e