- Unregister and destroy UA when account is deleted.

This commit is contained in:
Juha Heinanen
2019-04-01 19:04:32 +03:00
parent f3c46feff7
commit 23c2d90496
2 changed files with 3 additions and 0 deletions
+1
View File
@@ -948,6 +948,7 @@ Java_com_tutpro_baresip_Api_ua_1destroy(JNIEnv *env, jobject thiz, jstring javaU
{ {
const char *native_ua = (*env)->GetStringUTFChars(env, javaUA, 0); const char *native_ua = (*env)->GetStringUTFChars(env, javaUA, 0);
struct ua *ua = (struct ua *)strtoul(native_ua, NULL, 10); struct ua *ua = (struct ua *)strtoul(native_ua, NULL, 10);
LOGD("destroying ua %s\n", native_ua);
(*env)->ReleaseStringUTFChars(env, javaUA, native_ua); (*env)->ReleaseStringUTFChars(env, javaUA, native_ua);
mem_deref(ua); mem_deref(ua);
} }
@@ -41,6 +41,8 @@ class AccountListAdapter(private val cxt: Context, private val rows: ArrayList<A
val deleteDialog = AlertDialog.Builder(cxt) val deleteDialog = AlertDialog.Builder(cxt)
deleteDialog.setMessage("Do you want to delete account ${ua.account.aor}?") deleteDialog.setMessage("Do you want to delete account ${ua.account.aor}?")
deleteDialog.setPositiveButton("Delete") { dialog, _ -> deleteDialog.setPositiveButton("Delete") { dialog, _ ->
if (Api.ua_isregistered(ua.uap)) Api.ua_unregister(ua.uap)
Api.ua_destroy(ua.uap)
UserAgent.remove(ua) UserAgent.remove(ua)
AccountsActivity.generateAccounts() AccountsActivity.generateAccounts()
AccountsActivity.saveAccounts() AccountsActivity.saveAccounts()