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