- Account's laddr needs to be stored in ;extra param, since account_laddr()

may result in empty laddr.
This commit is contained in:
Juha Heinanen
2020-03-22 12:11:31 +02:00
parent 9bc7d0ecaf
commit 8d256da365
2 changed files with 11 additions and 7 deletions

View File

@ -8,7 +8,7 @@ class Account(val accp: String) {
var displayName = account_display_name(accp)
val aor = account_aor(accp)
var laddr = account_laddr(accp)
var laddr = ""
var authUser = account_auth_user(accp)
var authPass = account_auth_pass(accp)
var outbound = ArrayList<String>()
@ -60,6 +60,8 @@ class Account(val accp: String) {
}
val extra = account_extra(accp)
laddr = Utils.paramValue(extra,"laddr").replace("#", ";")
if (laddr == "") laddr = aor
preferIPv6Media = Utils.paramValue(extra,"prefer_ipv6_media") == "yes"
answerMode = Utils.paramValue(extra,"answer_mode")
if (answerMode == "") answerMode = "manual"
@ -114,7 +116,7 @@ class Account(val accp: String) {
res += ";ptime=20;regint=${regint};regq=0.5;pubint=0;call_transfer=yes"
var extra = ""
var extra = "laddr=" + laddr.replace(";", "#")
if (!callHistory)
extra += ";call_history=no"
@ -126,7 +128,7 @@ class Account(val accp: String) {
extra += ";prefer_ipv6_media=yes"
if (extra != "")
res += ";extra=\"" + extra.substringAfter(";") + "\""
res += ";extra=\"" + extra + "\""
return res
}

View File

@ -39,14 +39,16 @@ class AccountsActivity : AppCompatActivity() {
Utils.alertView(this, getString(R.string.notice),
String.format(getString(R.string.account_exists), aor.split(":")[0]))
} else {
val ua = UserAgent.uaAlloc("<sip:$aor>;stunserver=\"stun:stun.l.google.com:19302\";regq=0.5;pubint=0;regint=0")
val laddr = "sip:$aor"
val eladdr = laddr.replace(";", "#")
val ua = UserAgent.uaAlloc("<$laddr>;stunserver=\"stun:stun.l.google.com:19302\";regq=0.5;pubint=0;regint=0;extra=\"laddr=$eladdr\"")
if (ua == null) {
Log.e("Baresip", "Failed to allocate UA for $aor")
Utils.alertView(this, getString(R.string.notice),
getString(R.string.account_allocation_failure))
} else {
Log.d("Baresip", "Allocated UA ${ua.uap} for $aor")
ua.account.laddr = "sip:$aor"
ua.account.laddr = laddr
Log.d("Baresip", "Allocated UA ${ua.uap} for $laddr")
newAorView.setText("")
newAorView.hint = getString(R.string.user_domain)
newAorView.clearFocus()
@ -124,7 +126,7 @@ class AccountsActivity : AppCompatActivity() {
}
Utils.putFileContents(BaresipService.filesPath + "/accounts", accounts.toByteArray())
Log.d("Baresip", "Saved $count account(s) to '${BaresipService.filesPath}/accounts'")
// Log.d("Baresip", "Saved accounts '${accounts}' to '${BaresipService.filesPath}/accounts'")
Log.d("Baresip", "Saved accounts '${accounts}' to '${BaresipService.filesPath}/accounts'")
}
fun noAccounts(): Boolean {