diff --git a/PassepartoutLibrary/Sources/PassepartoutCore/Models/Network.swift b/PassepartoutLibrary/Sources/PassepartoutCore/Models/Network.swift index 93cfb2de..a1f4e642 100644 --- a/PassepartoutLibrary/Sources/PassepartoutCore/Models/Network.swift +++ b/PassepartoutLibrary/Sources/PassepartoutCore/Models/Network.swift @@ -25,7 +25,6 @@ import Foundation import TunnelKitCore -import NetworkExtension public enum Network { } diff --git a/PassepartoutLibrary/Sources/PassepartoutCore/Models/VPNConfiguration.swift b/PassepartoutLibrary/Sources/PassepartoutCore/Models/VPNConfiguration.swift deleted file mode 100644 index bc0b721d..00000000 --- a/PassepartoutLibrary/Sources/PassepartoutCore/Models/VPNConfiguration.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// VPNConfiguration.swift -// Passepartout -// -// Created by Davide De Rosa on 3/7/22. -// Copyright (c) 2022 Davide De Rosa. All rights reserved. -// -// https://github.com/passepartoutvpn -// -// This file is part of Passepartout. -// -// Passepartout is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Passepartout is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Passepartout. If not, see . -// - -import Foundation -import TunnelKitManager -import NetworkExtension - -public typealias VPNConfiguration = (neConfiguration: NetworkExtensionConfiguration, neExtra: NetworkExtensionExtra?) diff --git a/PassepartoutLibrary/Sources/PassepartoutCore/Models/WrappedProfile.swift b/PassepartoutLibrary/Sources/PassepartoutCore/Models/WrappedProfile.swift deleted file mode 100644 index 17627c43..00000000 --- a/PassepartoutLibrary/Sources/PassepartoutCore/Models/WrappedProfile.swift +++ /dev/null @@ -1,41 +0,0 @@ -// -// WrappedProfile.swift -// Passepartout -// -// Created by Davide De Rosa on 3/27/22. -// Copyright (c) 2022 Davide De Rosa. All rights reserved. -// -// https://github.com/passepartoutvpn -// -// This file is part of Passepartout. -// -// Passepartout is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Passepartout is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Passepartout. If not, see . -// - -import Foundation - -public protocol WrappedProfile { - var isLoading: Bool { get } - - var value: Profile { get } -} - -extension WrappedProfile { - public var name: String { - guard !isLoading && !value.isPlaceholder else { - return "" - } - return value.header.name - } -} diff --git a/PassepartoutLibrary/Sources/PassepartoutCore/Models/WrappedVPNState.swift b/PassepartoutLibrary/Sources/PassepartoutCore/Models/WrappedVPNState.swift deleted file mode 100644 index 9e3fc36c..00000000 --- a/PassepartoutLibrary/Sources/PassepartoutCore/Models/WrappedVPNState.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// WrappedVPNState.swift -// Passepartout -// -// Created by Davide De Rosa on 6/21/22. -// Copyright (c) 2022 Davide De Rosa. All rights reserved. -// -// https://github.com/passepartoutvpn -// -// This file is part of Passepartout. -// -// Passepartout is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Passepartout is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Passepartout. If not, see . -// - -import Foundation -import TunnelKitCore -import TunnelKitManager - -public protocol WrappedVPNState { - var isEnabled: Bool { get } - - var vpnStatus: VPNStatus { get } - - var lastError: Error? { get } - - var dataCount: DataCount? { get } -} diff --git a/PassepartoutLibrary/Sources/PassepartoutProfiles/Models/ObservableProfile.swift b/PassepartoutLibrary/Sources/PassepartoutProfiles/Models/ObservableProfile.swift index 098b067f..3efc066f 100644 --- a/PassepartoutLibrary/Sources/PassepartoutProfiles/Models/ObservableProfile.swift +++ b/PassepartoutLibrary/Sources/PassepartoutProfiles/Models/ObservableProfile.swift @@ -27,7 +27,7 @@ import Foundation import PassepartoutCore import PassepartoutUtils -public class ObservableProfile: WrappedProfile, ValueHolder, ObservableObject { +public class ObservableProfile: ValueHolder, ObservableObject { @Published public internal(set) var isLoading = false @Published public var value: Profile @@ -36,3 +36,12 @@ public class ObservableProfile: WrappedProfile, ValueHolder, ObservableObject { value = .placeholder } } + +extension ObservableProfile { + public var name: String { + guard !isLoading && !value.isPlaceholder else { + return "" + } + return value.header.name + } +} diff --git a/PassepartoutLibrary/Sources/PassepartoutVPN/Models/ObservableVPNState.swift b/PassepartoutLibrary/Sources/PassepartoutVPN/Models/ObservableVPNState.swift index cb2a4ef0..24d5d00c 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPN/Models/ObservableVPNState.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPN/Models/ObservableVPNState.swift @@ -26,10 +26,9 @@ import Foundation import TunnelKitCore import TunnelKitManager -import PassepartoutCore import PassepartoutUtils -public class ObservableVPNState: WrappedVPNState, ObservableObject { +public class ObservableVPNState: ObservableObject { @Published public internal(set) var isEnabled = false { didSet { pp_log.debug("VPN enabled -> \(isEnabled)") diff --git a/PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNConfigurationParameters.swift b/PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNConfiguration.swift similarity index 94% rename from PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNConfigurationParameters.swift rename to PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNConfiguration.swift index 1baa720a..8def710d 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNConfigurationParameters.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNConfiguration.swift @@ -28,6 +28,12 @@ import TunnelKitManager import NetworkExtension import PassepartoutCore +public typealias VPNConfiguration = (neConfiguration: NetworkExtensionConfiguration, neExtra: NetworkExtensionExtra) + +protocol VPNConfigurationProviding { + func vpnConfiguration(_ parameters: VPNConfigurationParameters) throws -> VPNConfiguration +} + struct VPNConfigurationParameters { let title: String @@ -63,7 +69,3 @@ struct VPNConfigurationParameters { onDemandRules = profile.onDemandRules(withCustomRules: withCustomRules) } } - -protocol VPNConfigurationProviding { - func vpnConfiguration(_ parameters: VPNConfigurationParameters) throws -> VPNConfiguration -} diff --git a/PassepartoutLibrary/Sources/PassepartoutCore/Models/VPNConfigurationError.swift b/PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNConfigurationError.swift similarity index 97% rename from PassepartoutLibrary/Sources/PassepartoutCore/Models/VPNConfigurationError.swift rename to PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNConfigurationError.swift index b0938394..c2f2b590 100644 --- a/PassepartoutLibrary/Sources/PassepartoutCore/Models/VPNConfigurationError.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNConfigurationError.swift @@ -24,5 +24,6 @@ // import Foundation +import PassepartoutCore public typealias VPNConfigurationError = (profile: Profile, error: Error)