Files
Termind/Frameworks/TermindPersistence/TermindSchemaV53HostModels.swift

99 lines
4.3 KiB
Swift

// SPDX-FileCopyrightText: 2026 Kaede Akino
// SPDX-License-Identifier: GPL-3.0-only
import Foundation
import SwiftData
import TermindDomain
import struct TermindDomain.Host
public enum TermindSchemaV53HostModels {
@Model
public final class PersistentHost {
@Attribute(.unique) public var id: UUID = UUID()
public var name = ""
public var address = ""
public var sshEnabled = true
public var port = 22
public var identityID: UUID?
public var charset = RemoteCharset.utf8.rawValue
public var telnetEnabled = false
public var telnetPort = 23
public var telnetIdentityID: UUID?
public var telnetCharset = RemoteCharset.utf8.rawValue
public var telnetProxyProtocol: String?
public var telnetProxyHostname = ""
public var telnetProxyPort = 0
public var telnetProxyUsername = ""
public var telnetProxyIdentityID: UUID?
public var jumpHostID: UUID?
public var proxyProtocol: String?
public var proxyHostname = ""
public var proxyPort = 0
public var proxyUsername = ""
public var proxyIdentityID: UUID?
public var sftpSessionInitialPath = ""
public var groupID: UUID?
public var tags: [String] = []
public var colorTag = TagColor.none.rawValue
public var shellIntegrationMode = HostShellIntegrationMode.followGlobalSettings.rawValue
public var sessionPersistenceEnabled = false
public var sessionPersistenceBackend = "tmux"
public var sessionPersistenceOnConnect = "ask"
public var agentForwardingEnabled = false
public var startupSnippetID: UUID?
public var environmentVariableNames: [String] = []
public var environmentVariableValues: [String] = []
public var portForwardingMaxConnections: Int? = Host.defaultPortForwardingMaxConnections
public var detectedDistributionID: String?
public var detectedDistributionLikeIDs: [String] = []
public var sortIndex = 0.0
public init(_ value: Host) {
id = value.id
apply(value)
}
public func apply(_ value: Host) {
name = value.name
address = value.host
sshEnabled = value.sshEnabled
port = value.sshPort
identityID = value.sshIdentityID
charset = value.sshCharset.rawValue
telnetEnabled = value.telnetEnabled
telnetPort = value.telnetPort
telnetIdentityID = value.telnetIdentityID
telnetCharset = value.telnetCharset.rawValue
telnetProxyProtocol = value.telnetProxy?.kind.rawValue
telnetProxyHostname = value.telnetProxy?.hostname ?? ""
telnetProxyPort = value.telnetProxy?.port ?? 0
telnetProxyUsername = value.telnetProxy?.username ?? ""
telnetProxyIdentityID = value.telnetProxy?.identityID
jumpHostID = value.jumpHostID
proxyProtocol = value.proxy?.kind.rawValue
proxyHostname = value.proxy?.hostname ?? ""
proxyPort = value.proxy?.port ?? 0
proxyUsername = value.proxy?.username ?? ""
proxyIdentityID = value.proxy?.identityID
sftpSessionInitialPath = value.sftpChannelInitialPath
groupID = value.groupID
tags = value.tags
colorTag = value.colorTag.rawValue
shellIntegrationMode = value.shellIntegrationMode.rawValue
startupSnippetID = value.startupSnippetID
agentForwardingEnabled = value.agentForwardingEnabled
sessionPersistenceEnabled = value.sessionPersistence.enabled
sessionPersistenceBackend = value.sessionPersistence.backend.rawValue
sessionPersistenceOnConnect = value.sessionPersistence.onConnect.rawValue
environmentVariableNames = value.environmentVariables.map(\.variable)
environmentVariableValues = value.environmentVariables.map(\.value)
portForwardingMaxConnections = Host.normalizedPortForwardingMaxConnections(
value.portForwardingMaxConnections)
detectedDistributionID = value.detectedDistribution?.id
detectedDistributionLikeIDs = value.detectedDistribution?.likeIDs ?? []
sortIndex = value.sortIndex
}
}
}