Improved implementation of transport protocols and dns servers settings

This commit is contained in:
Juha Heinanen
2026-02-15 07:03:03 +02:00
parent 0058f778cc
commit b0d163bfa7
3 changed files with 17 additions and 20 deletions

View File

@ -18,13 +18,8 @@ class SettingsViewModel: ViewModel() {
val autoStart = MutableStateFlow(false)
val listenAddress = MutableStateFlow("")
val addressFamily = MutableStateFlow("")
val transportProtocols = MutableStateFlow("")
var oldTransportProtocols = ""
val dnsServers = MutableStateFlow("")
var oldDnsServers = ""
val tlsCertificateFile = MutableStateFlow(false)
val verifyServer = MutableStateFlow(false)
val caFile = MutableStateFlow(false)
@ -43,18 +38,8 @@ class SettingsViewModel: ViewModel() {
private var isLoaded = false
fun loadSettings(ctx: Context) {
if (isLoaded) return else isLoaded = true
oldTransportProtocols = Config.variable("sip_transports")
oldDnsServers = if (Config.variable("dyn_dns") == "yes")
""
else {
val servers = Config.variables("dns_server")
var serverList = ""
for (server in servers)
serverList += ", $server"
serverList.trimStart(',').trimStart(' ')
}
if (isLoaded) return else isLoaded = true
autoStart.value = Config.variable("auto_start") == "yes"
@ -65,9 +50,9 @@ class SettingsViewModel: ViewModel() {
mutableIntStateOf(familyValues.indexOf(Config.variable("net_af").lowercase()))
addressFamily.value = familyValues[itemPosition.intValue]
transportProtocols.value = oldTransportProtocols
transportProtocols.value = Config.variable("sip_transports")
dnsServers.value = oldDnsServers
dnsServers.value = Config.dnsServers()
tlsCertificateFile.value = File(BaresipService.filesPath + "/cert.pem").exists()