diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift index a673bd39..274ef0e5 100644 --- a/Passepartout-iOS/Scenes/ServiceViewController.swift +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -190,10 +190,10 @@ class ServiceViewController: UIViewController, TableModelHost { private func toggleVpnService(cell: ToggleTableViewCell) { if cell.isOn { - guard service.canActivate(uncheckedProfile) else { + guard !service.needsCredentials(for: uncheckedProfile) else { let alert = Macros.alert( L10n.Service.Sections.Vpn.header, - L10n.Service.Alerts.ConfigurationNeeded.message + L10n.Service.Alerts.CredentialsNeeded.message ) alert.addCancelAction(L10n.Global.ok) { cell.setOn(false, animated: true) @@ -522,7 +522,7 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog cell.applyVPN(Theme.current, with: vpn.isEnabled ? vpn.status : nil) cell.leftText = L10n.Service.Cells.ConnectionStatus.caption cell.accessoryType = .none - cell.isTappable = service.canActivate(uncheckedProfile) && vpn.isEnabled + cell.isTappable = !service.needsCredentials(for: uncheckedProfile) && vpn.isEnabled return cell case .useProfile: diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index d5705010..d40146be 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -98,7 +98,7 @@ "service.cells.data_count.caption" = "Exchanged bytes count"; "service.cells.debug_log.caption" = "Debug log"; -"service.alerts.configuration_needed.message" = "You need to finish configuration first."; +"service.alerts.credentials_needed.message" = "You need to enter account credentials first."; "service.alerts.reconnect_vpn.message" = "Do you want to reconnect to the VPN?"; "service.alerts.trusted.no_network.message" = "You are not connected to any Wi-Fi network."; "service.alerts.trusted.will_disconnect_trusted.message" = "By trusting this network, the VPN may be disconnected. Continue?"; diff --git a/Passepartout/Sources/Model/ConnectionProfile.swift b/Passepartout/Sources/Model/ConnectionProfile.swift index 5aa7c3b3..53777d7a 100644 --- a/Passepartout/Sources/Model/ConnectionProfile.swift +++ b/Passepartout/Sources/Model/ConnectionProfile.swift @@ -34,7 +34,7 @@ protocol ConnectionProfile: class, EndpointDataSource { var username: String? { get set } - var isConfigured: Bool { get } + var requiresCredentials: Bool { get } func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration } diff --git a/Passepartout/Sources/Model/ConnectionService.swift b/Passepartout/Sources/Model/ConnectionService.swift index e4734bdf..f16ed007 100644 --- a/Passepartout/Sources/Model/ConnectionService.swift +++ b/Passepartout/Sources/Model/ConnectionService.swift @@ -180,21 +180,20 @@ class ConnectionService: Codable { return profile.id == activeProfileId } - func canActivate(_ profile: ConnectionProfile) -> Bool { - return profile.isConfigured && hasCredentials(for: profile) - } - func activateProfile(_ profile: ConnectionProfile) { activeProfileId = profile.id } // MARK: Credentials - func hasCredentials(for profile: ConnectionProfile) -> Bool { - guard let creds = credentials(for: profile) else { + func needsCredentials(for profile: ConnectionProfile) -> Bool { + guard profile.requiresCredentials else { return false } - return !creds.isEmpty + guard let creds = credentials(for: profile) else { + return true + } + return creds.isEmpty } func credentials(for profile: ConnectionProfile) -> Credentials? { diff --git a/Passepartout/Sources/Model/Profiles/HostConnectionProfile.swift b/Passepartout/Sources/Model/Profiles/HostConnectionProfile.swift index 3c47e54f..130cb08a 100644 --- a/Passepartout/Sources/Model/Profiles/HostConnectionProfile.swift +++ b/Passepartout/Sources/Model/Profiles/HostConnectionProfile.swift @@ -47,8 +47,8 @@ class HostConnectionProfile: ConnectionProfile, Codable, Equatable { var username: String? - var isConfigured: Bool { - return !parameters.endpointProtocols.isEmpty + var requiresCredentials: Bool { + return false } func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration { diff --git a/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift b/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift index 1f66a73c..22c28c9b 100644 --- a/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift +++ b/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift @@ -101,10 +101,10 @@ class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable { var username: String? - var isConfigured: Bool { - return (pool != nil) && (preset != nil) + var requiresCredentials: Bool { + return true } - + func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration { guard let pool = pool else { throw ApplicationError.providerPool diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index f0495143..1042013a 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -423,9 +423,9 @@ internal enum L10n { internal enum Alerts { - internal enum ConfigurationNeeded { - /// You need to finish configuration first. - internal static let message = L10n.tr("Localizable", "service.alerts.configuration_needed.message") + internal enum CredentialsNeeded { + /// You need to enter account credentials first. + internal static let message = L10n.tr("Localizable", "service.alerts.credentials_needed.message") } internal enum DataCount { diff --git a/Podfile.lock b/Podfile.lock index f64e2f08..19040e0d 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -40,4 +40,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: f6888fe9e046f88d139af75dd5308916c5be8b7b -COCOAPODS: 1.6.0.beta.1 +COCOAPODS: 1.6.0.beta.2