diff --git a/app/src/main/kotlin/com/tutpro/baresip/Account.kt b/app/src/main/kotlin/com/tutpro/baresip/Account.kt
index b2eff2eb..7a7fd54c 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/Account.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/Account.kt
@@ -40,6 +40,7 @@ class Account(val accp: Long) {
var telProvider = Utils.aorDomain(aor)
var resumeUri = ""
var numericKeypad = false
+ var customParams = ""
init {
@@ -80,6 +81,7 @@ class Account(val accp: Long) {
if (Utils.paramExists(extra, "tel_provider"))
telProvider = URLDecoder.decode(Utils.paramValue(extra, "tel_provider"), "UTF-8")
numericKeypad = Utils.paramExists(extra, "numeric_keypad")
+ customParams = extra.substringAfter("last=empty").substringAfter(";")
}
fun print() : String {
@@ -166,7 +168,8 @@ class Account(val accp: Long) {
if (blockUnknown)
extra += ";block_unknown=yes"
- extra += ";tel_provider=${URLEncoder.encode(telProvider, "UTF-8")}"
+ if (telProvider != "")
+ extra += ";tel_provider=${URLEncoder.encode(telProvider, "UTF-8")}"
if (countryCode != "")
extra += ";country_code=$countryCode"
@@ -177,8 +180,15 @@ class Account(val accp: Long) {
if (numericKeypad)
extra += ";numeric_keypad=yes"
- if (extra !="")
- res += ";extra=\"" + extra.substringAfter(";") + "\""
+ extra += ";last=empty"
+
+ if (customParams != "")
+ extra += ";$customParams"
+
+ res += ";extra=\"" + extra.substringAfter(";") + "\""
+
+ if (customParams != "")
+ res += ";$customParams"
return res
}
@@ -261,7 +271,7 @@ class Account(val accp: Long) {
BaresipService.filesPath + "/accounts",
accounts.toByteArray(Charsets.UTF_8)
)
- // Log.d(TAG, "Saved accounts '${accounts}' to '${BaresipService.filesPath}/accounts'")
+ Log.d(TAG, "Saved accounts '${accounts}' to '${BaresipService.filesPath}/accounts'")
}
fun ofAor(aor: String): Account? {
diff --git a/app/src/main/kotlin/com/tutpro/baresip/AccountScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/AccountScreen.kt
index d1ec53ab..ed35a6b6 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/AccountScreen.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/AccountScreen.kt
@@ -1194,6 +1194,35 @@ private fun AccountContent(
}
}
+ @Composable
+ fun CustomParams() {
+ val customParamsTitle = stringResource(R.string.custom_parameters)
+ val customParamsHelp = stringResource(R.string.custom_parameters_help)
+ val customParams by viewModel.customParams.collectAsState()
+ Row(
+ Modifier.fillMaxWidth().padding(top = 8.dp, end = 10.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ horizontalArrangement = Arrangement.Start
+ ) {
+ OutlinedTextField(
+ value = customParams,
+ placeholder = { Text(customParamsTitle) },
+ onValueChange = { viewModel.customParams.value = it },
+ modifier = Modifier
+ .fillMaxWidth()
+ .clickable {
+ alertTitle.value = customParamsTitle
+ alertMessage.value = customParamsHelp
+ showAlert.value = true
+ },
+ singleLine = true,
+ textStyle = TextStyle(fontSize = 18.sp),
+ label = { Text(customParamsTitle) },
+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text)
+ )
+ }
+ }
+
if (showAlert.value) {
AlertDialog(
showDialog = showAlert,
@@ -1248,6 +1277,7 @@ private fun AccountContent(
TelProvider()
NumericKeypad()
DefaultAccount()
+ CustomParams()
}
}
@@ -1615,6 +1645,12 @@ private fun checkOnClick(ctx: Context, viewModel: AccountViewModel, ua: UserAgen
Log.d(TAG, "New numericKeyboard is ${acc.numericKeypad}")
}
+ val newCustomParams = viewModel.customParams.value
+ if (newCustomParams != acc.customParams) {
+ acc.customParams = newCustomParams
+ Log.d(TAG, "New customParams is ${acc.customParams}")
+ }
+
if (viewModel.defaultAccount.value) ua.makeDefault()
Api.account_debug(acc.accp)
diff --git a/app/src/main/kotlin/com/tutpro/baresip/AccountViewModel.kt b/app/src/main/kotlin/com/tutpro/baresip/AccountViewModel.kt
index 907f1359..c4436578 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/AccountViewModel.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/AccountViewModel.kt
@@ -28,9 +28,11 @@ class AccountViewModel: ViewModel() {
val vmUri = MutableStateFlow("")
val countryCode = MutableStateFlow("")
val telProvider = MutableStateFlow("")
- val defaultAccount = MutableStateFlow(false)
val numericKeypad = MutableStateFlow(false)
+ val defaultAccount = MutableStateFlow(false)
+ val customParams = MutableStateFlow("")
+
private var isLoaded = false
fun loadAccount(acc: Account) {
@@ -63,5 +65,6 @@ class AccountViewModel: ViewModel() {
telProvider.value = acc.telProvider
numericKeypad.value = acc.numericKeypad
defaultAccount.value = UserAgent.findAorIndex(acc.aor)!! == 0
+ customParams.value = acc.customParams
}
}
diff --git a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt
index 272b674e..1a488777 100644
--- a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt
+++ b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt
@@ -328,6 +328,11 @@ object Utils {
return false
}
+ fun customParams(params: String): String {
+ return params.substringAfter("last=empty")
+
+ }
+
fun checkHostPortParams(hpp: String) : Boolean {
val restParams = hpp.split(";", limit = 2)
return if (restParams.size == 1)
diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml
index 3a9bacc3..01d7ea78 100644
--- a/app/src/main/res/values-fi/strings.xml
+++ b/app/src/main/res/values-fi/strings.xml
@@ -240,6 +240,9 @@
Jos merkitty, niin tämä tili on
valittuna, kun baresip käynnistetään.
+ Räätälöidyt parametrit
+ Puolipisteellä toisistaan eroteltu lista
+ räätälöityjä tilin parametrejä
Tilit
Uuden tilin SIP URI
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c7da948d..aaf08402 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -229,6 +229,8 @@
Default Account
If checked, this account is selected when baresip is started.
+ Custom Parameters
+ Semicolor separeted list of custom account parameters
Accounts
SIP URI of New Account