fixed handling of UA un-register
This commit is contained in:
@ -24,6 +24,7 @@ class AccountActivity : AppCompatActivity() {
|
||||
|
||||
private var newCodecs = ArrayList<String>()
|
||||
private var save = false
|
||||
private var uaIndex= -1
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -31,6 +32,8 @@ class AccountActivity : AppCompatActivity() {
|
||||
|
||||
acc = Account.find(MainActivity.uas, intent.extras.getString("accp"))!!
|
||||
aor = acc.aor
|
||||
uaIndex = UserAgent.findAorIndex(MainActivity.uas, aor)!!
|
||||
|
||||
setTitle(aor.replace("sip:", ""))
|
||||
|
||||
displayName = findViewById(R.id.DisplayName) as EditText
|
||||
@ -207,10 +210,14 @@ class AccountActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
var newRegint = -1
|
||||
if (regCheck.isChecked)
|
||||
if (regCheck.isChecked) {
|
||||
if (acc.regint != 3600) newRegint = 3600
|
||||
else
|
||||
if (acc.regint != 0) newRegint = 0
|
||||
} else {
|
||||
if (acc.regint != 0) {
|
||||
UserAgent.ua_unregister(MainActivity.uas[uaIndex].uap)
|
||||
newRegint = 0
|
||||
}
|
||||
}
|
||||
if (newRegint != -1)
|
||||
if (account_set_regint(acc.accp, newRegint) == 0) {
|
||||
acc.regint = account_regint(acc.accp)
|
||||
@ -254,15 +261,10 @@ class AccountActivity : AppCompatActivity() {
|
||||
|
||||
if (save) {
|
||||
AccountsActivity.saveAccounts()
|
||||
val uaIndex = UserAgent.findAorIndex(MainActivity.uas, aor)
|
||||
if (uaIndex != null) {
|
||||
if (UserAgent.ua_update_account(MainActivity.uas[uaIndex].uap) != 0)
|
||||
Log.e("Baresip", "Failed to update UA with AoR $aor")
|
||||
else if (acc.regint > 0)
|
||||
UserAgent.ua_register(MainActivity.uas[uaIndex].uap)
|
||||
} else {
|
||||
Log.e("Baresip", "Did not find UA matching AoR $aor")
|
||||
}
|
||||
if (UserAgent.ua_update_account(MainActivity.uas[uaIndex].uap) != 0)
|
||||
Log.e("Baresip", "Failed to update UA with AoR $aor")
|
||||
if (newRegint > 0)
|
||||
UserAgent.ua_register(MainActivity.uas[uaIndex].uap)
|
||||
}
|
||||
|
||||
setResult(RESULT_OK, intent)
|
||||
|
||||
@ -205,7 +205,7 @@ class BaresipService: Service() {
|
||||
for (account_index in MainActivity.uas.indices) {
|
||||
if (MainActivity.uas[account_index].account.aor == aor) {
|
||||
when (event) {
|
||||
"registering", "unregistering" -> {
|
||||
"registering" -> {
|
||||
return
|
||||
}
|
||||
"registered" -> {
|
||||
@ -214,19 +214,23 @@ class BaresipService: Service() {
|
||||
else
|
||||
MainActivity.images[account_index] = R.drawable.dot_green
|
||||
updateNotification()
|
||||
if (!MainActivity.visible) return
|
||||
if (!Utils.isVisible()) return
|
||||
}
|
||||
"registering failed" -> {
|
||||
MainActivity.images[account_index] = R.drawable.dot_red
|
||||
updateNotification()
|
||||
if (!MainActivity.visible) return
|
||||
if (!Utils.isVisible()) return
|
||||
}
|
||||
"unregistering" -> {
|
||||
MainActivity.images[account_index] = R.drawable.dot_yellow
|
||||
updateNotification()
|
||||
if (!Utils.isVisible()) return
|
||||
}
|
||||
"call ringing" -> {
|
||||
return
|
||||
}
|
||||
"call incoming" -> {
|
||||
if (!Utils.isVisible()) {
|
||||
Log.d(LOG_TAG, "Baresip is NOT visible")
|
||||
nb.setVibrate(LongArray(0))
|
||||
val view = RemoteViews(getPackageName(), R.layout.notification)
|
||||
view.setTextViewText(R.id.incoming, "Call from ${Api.call_peeruri(callp)}")
|
||||
|
||||
@ -302,14 +302,9 @@ class MainActivity : AppCompatActivity() {
|
||||
uaAdapter.notifyDataSetChanged()
|
||||
if (aorSpinner.selectedItemPosition == -1) aorSpinner.setSelection(0)
|
||||
}
|
||||
"registered" -> {
|
||||
"registered", "registering failed", "unregistering" -> {
|
||||
uaAdapter.notifyDataSetChanged()
|
||||
}
|
||||
"registering failed" -> {
|
||||
uaAdapter.notifyDataSetChanged()
|
||||
}
|
||||
"call ringing" -> {
|
||||
}
|
||||
"call incoming" -> {
|
||||
val peer_uri = Api.call_peeruri(callp)
|
||||
val new_call = Call(callp, ua, peer_uri, "in", "Answer", null)
|
||||
@ -501,7 +496,7 @@ class MainActivity : AppCompatActivity() {
|
||||
layout.removeViews(view_index, 3 * remove_count)
|
||||
val callsIn = Call.uaCalls(calls, ua, "in")
|
||||
for (i in inIndex until callsIn.size) {
|
||||
this@MainActivity.addCallViews(ua, callsIn[i], (i + 1) * 10)
|
||||
addCallViews(ua, callsIn[i], (i + 1) * 10)
|
||||
}
|
||||
historyButton.visibility = View.VISIBLE
|
||||
}
|
||||
@ -615,7 +610,6 @@ class MainActivity : AppCompatActivity() {
|
||||
startService(baresipService)
|
||||
}
|
||||
finish()
|
||||
// System.exit(0)
|
||||
return true
|
||||
}
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
|
||||
Reference in New Issue
Block a user