Update library with provider entities (#978)
This commit is contained in:
parent
d4543b49ac
commit
355974292e
|
@ -41,7 +41,7 @@
|
|||
"kind" : "remoteSourceControl",
|
||||
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source",
|
||||
"state" : {
|
||||
"revision" : "97f2662bcfa8dff6983fe19320c85611047ab73d"
|
||||
"revision" : "51288509f90b0d4dd2c4ceee2af5cfb36e6319f1"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -52,7 +52,7 @@ let package = Package(
|
|||
],
|
||||
dependencies: [
|
||||
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.12.0"),
|
||||
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "97f2662bcfa8dff6983fe19320c85611047ab73d"),
|
||||
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "51288509f90b0d4dd2c4ceee2af5cfb36e6319f1"),
|
||||
// .package(path: "../../passepartoutkit-source"),
|
||||
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "0.9.1"),
|
||||
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"),
|
||||
|
|
|
@ -39,7 +39,7 @@ final class CDVPNProviderServerRepositoryV3: VPNProviderServerRepository {
|
|||
self.providerId = providerId
|
||||
}
|
||||
|
||||
func availableOptions<Configuration>(for configurationType: Configuration.Type) async throws -> VPNFilterOptions where Configuration: ProviderConfigurationIdentifiable {
|
||||
func availableOptions<Configuration>(for configurationType: Configuration.Type) async throws -> VPNFilterOptions where Configuration: ConfigurationIdentifiable {
|
||||
try await context.perform {
|
||||
let mapper = DomainMapper()
|
||||
|
||||
|
@ -69,7 +69,7 @@ final class CDVPNProviderServerRepositoryV3: VPNProviderServerRepository {
|
|||
let presetsRequest = CDVPNPresetV3.fetchRequest()
|
||||
presetsRequest.predicate = NSPredicate(
|
||||
format: "providerId == %@ AND configurationId == %@", self.providerId.rawValue,
|
||||
Configuration.providerConfigurationIdentifier
|
||||
Configuration.configurationIdentifier
|
||||
)
|
||||
let presetsResults = try presetsRequest.execute()
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ private struct ProvidersSubmenu: View {
|
|||
var editable = EditableProfile()
|
||||
editable.name = provider.description
|
||||
let newModule = moduleType.newModule(with: registry, providerId: provider.id)
|
||||
if let providerBuilder = newModule as? any ProviderBuilder {
|
||||
if let providerBuilder = newModule as? any ProviderSelecting {
|
||||
assert(providerBuilder.providerId == provider.id)
|
||||
}
|
||||
editable.modules.append(newModule)
|
||||
|
|
|
@ -218,7 +218,6 @@ private extension OpenVPNView {
|
|||
VPNProviderServerView(
|
||||
moduleId: module.id,
|
||||
providerId: $0.id,
|
||||
configurationType: OpenVPN.Configuration.self,
|
||||
selectedEntity: $0.entity,
|
||||
filtersWithSelection: true,
|
||||
onSelect: onSelectServer
|
||||
|
|
|
@ -115,7 +115,6 @@ private extension WireGuardView {
|
|||
VPNProviderServerView(
|
||||
moduleId: module.id,
|
||||
providerId: $0.id,
|
||||
configurationType: WireGuard.Configuration.self,
|
||||
selectedEntity: $0.entity,
|
||||
filtersWithSelection: true,
|
||||
onSelect: onSelectServer
|
||||
|
|
|
@ -122,7 +122,7 @@ private extension ProviderContentModifier {
|
|||
providerManager
|
||||
.providers
|
||||
.filter {
|
||||
$0.supports(Entity.ConfigurationType.self)
|
||||
$0.supports(Entity.Template.self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import CommonLibrary
|
|||
import PassepartoutKit
|
||||
import SwiftUI
|
||||
|
||||
struct VPNProviderContentModifier<Configuration, ProviderRows>: ViewModifier where Configuration: ProviderConfigurationIdentifiable, ProviderRows: View {
|
||||
struct VPNProviderContentModifier<Configuration, ProviderRows>: ViewModifier where Configuration: ConfigurationIdentifiable, ProviderRows: View {
|
||||
var apis: [APIMapper] = API.shared
|
||||
|
||||
@Binding
|
||||
|
|
|
@ -27,7 +27,7 @@ import CommonUtils
|
|||
import PassepartoutKit
|
||||
import SwiftUI
|
||||
|
||||
struct VPNProviderServerCoordinator<Configuration>: View where Configuration: ProviderConfigurationIdentifiable {
|
||||
struct VPNProviderServerCoordinator<Configuration>: View where Configuration: ConfigurationIdentifiable {
|
||||
|
||||
@Environment(\.dismiss)
|
||||
private var dismiss
|
||||
|
@ -47,7 +47,6 @@ struct VPNProviderServerCoordinator<Configuration>: View where Configuration: Pr
|
|||
VPNProviderServerView(
|
||||
moduleId: moduleId,
|
||||
providerId: providerId,
|
||||
configurationType: Configuration.self,
|
||||
selectedEntity: selectedEntity,
|
||||
filtersWithSelection: false,
|
||||
selectTitle: Strings.Global.Actions.connect,
|
||||
|
|
|
@ -29,7 +29,7 @@ import CommonUtils
|
|||
import PassepartoutKit
|
||||
import SwiftUI
|
||||
|
||||
struct VPNProviderServerView<Configuration>: View where Configuration: ProviderConfigurationIdentifiable {
|
||||
struct VPNProviderServerView<Configuration>: View where Configuration: ConfigurationIdentifiable {
|
||||
|
||||
@EnvironmentObject
|
||||
private var providerManager: ProviderManager
|
||||
|
@ -40,8 +40,6 @@ struct VPNProviderServerView<Configuration>: View where Configuration: ProviderC
|
|||
|
||||
let providerId: ProviderID
|
||||
|
||||
let configurationType: Configuration.Type
|
||||
|
||||
let selectedEntity: VPNEntity<Configuration>?
|
||||
|
||||
let filtersWithSelection: Bool
|
||||
|
@ -202,7 +200,7 @@ private extension VPNProviderServerView {
|
|||
func onSelectServer(_ server: VPNServer) {
|
||||
guard let preset = compatiblePreset(with: server) else {
|
||||
pp_log(.app, .error, "Unable to find a compatible preset. Supported IDs: \(server.provider.supportedPresetIds ?? [])")
|
||||
assertionFailure("No compatible presets for server \(server.serverId) (provider=\(vpnManager.providerId), configuration=\(Configuration.providerConfigurationIdentifier), supported=\(server.provider.supportedPresetIds ?? []))")
|
||||
assertionFailure("No compatible presets for server \(server.serverId) (provider=\(vpnManager.providerId), configuration=\(Configuration.configurationIdentifier), supported=\(server.provider.supportedPresetIds ?? []))")
|
||||
return
|
||||
}
|
||||
onSelect(server, preset)
|
||||
|
@ -217,8 +215,7 @@ private extension VPNProviderServerView {
|
|||
apis: [API.bundled],
|
||||
moduleId: UUID(),
|
||||
providerId: .protonvpn,
|
||||
configurationType: OpenVPN.Configuration.self,
|
||||
selectedEntity: nil,
|
||||
selectedEntity: nil as VPNEntity<OpenVPN.Configuration>?,
|
||||
filtersWithSelection: false,
|
||||
selectTitle: "Select",
|
||||
onSelect: { _, _ in }
|
||||
|
|
|
@ -34,7 +34,7 @@ extension ModuleDraftEditing {
|
|||
}
|
||||
|
||||
@MainActor
|
||||
extension ModuleDraftEditing where Draft: ProviderBuilder {
|
||||
extension ModuleDraftEditing where Draft: MutableProviderSelecting {
|
||||
public var providerId: Binding<ProviderID?> {
|
||||
Binding {
|
||||
draft.providerId.wrappedValue
|
||||
|
@ -43,7 +43,7 @@ extension ModuleDraftEditing where Draft: ProviderBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
public var providerEntity: Binding<Draft.SelectionType.EntityType?> {
|
||||
public var providerEntity: Binding<Draft.CustomSelectionType.EntityType?> {
|
||||
Binding {
|
||||
draft.providerEntity.wrappedValue
|
||||
} set: {
|
||||
|
@ -51,7 +51,7 @@ extension ModuleDraftEditing where Draft: ProviderBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
public var providerOptions: Binding<Set<Draft.SelectionType.OptionType>?> {
|
||||
public var providerOptions: Binding<Set<Draft.CustomSelectionType.OptionType>?> {
|
||||
Binding {
|
||||
draft.providerOptions.wrappedValue
|
||||
} set: {
|
||||
|
|
|
@ -49,7 +49,7 @@ extension ProfileManager {
|
|||
var moduleBuilder = moduleType.newModule(with: registry, providerId: parameters.providerId)
|
||||
|
||||
if moduleBuilder.buildsConnectionModule {
|
||||
assert((moduleBuilder as? any ProviderBuilder)?.providerId == parameters.providerId)
|
||||
assert((moduleBuilder as? any ProviderSelecting)?.providerId == parameters.providerId)
|
||||
}
|
||||
|
||||
if parameters.name == "Hide.me",
|
||||
|
|
Loading…
Reference in New Issue