Cleaner checking of new account AoR
This commit is contained in:
@@ -43,18 +43,22 @@ class AccountsActivity : AppCompatActivity() {
|
||||
Log.d("Baresip", "Invalid Address of Record $aor")
|
||||
Utils.alertView(this, getString(R.string.notice),
|
||||
String.format(getString(R.string.invalid_aor), aor))
|
||||
} else if (Account.ofAor(aor) != null) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (Account.ofAor("sip:$aor") != null) {
|
||||
Log.d("Baresip", "Account $aor already exists")
|
||||
Utils.alertView(this, getString(R.string.notice),
|
||||
String.format(getString(R.string.account_exists), aor.split(":")[0]))
|
||||
} else {
|
||||
return@setOnClickListener
|
||||
}
|
||||
val laddr = "sip:$aor"
|
||||
val ua = UserAgent.uaAlloc("<$laddr>;stunserver=\"stun:stun.l.google.com:19302\";regq=0.5;pubint=0;regint=0;mwi=no")
|
||||
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 {
|
||||
return@setOnClickListener
|
||||
}
|
||||
// Api.account_debug(ua.account.accp)
|
||||
Log.d("Baresip", "Allocated UA ${ua.uap} for ${Api.account_luri(ua.account.accp)}")
|
||||
newAorView.setText("")
|
||||
@@ -71,8 +75,6 @@ class AccountsActivity : AppCompatActivity() {
|
||||
i.putExtras(b)
|
||||
startActivityForResult(i, MainActivity.ACCOUNT_CODE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user