Use new UA_EVENT_CREATE to create UserAgents
This commit is contained in:
@ -173,6 +173,9 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
||||
LOGD("ua event (%s) %s\n", uag_event_str(ev), prm);
|
||||
|
||||
switch (ev) {
|
||||
case UA_EVENT_CREATE:
|
||||
len = re_snprintf(event_buf, sizeof event_buf, "create");
|
||||
break;
|
||||
case UA_EVENT_REGISTERING:
|
||||
case UA_EVENT_UNREGISTERING:
|
||||
case UA_EVENT_REGISTER_OK:
|
||||
@ -526,15 +529,6 @@ Java_com_tutpro_baresip_BaresipService_baresipStart(JNIEnv *env, jobject instanc
|
||||
goto out;
|
||||
}
|
||||
|
||||
char ua_buf[32];
|
||||
struct ua *ua;
|
||||
for (le = list_head(uag_list()); le != NULL; le = le->next) {
|
||||
ua = le->data;
|
||||
LOGD("adding UA for AoR %s/%ld\n", account_aor(ua_account(ua)), (long)ua);
|
||||
jmethodID uaAddId = (*env)->GetMethodID(env, g_ctx.mainActivityClz, "uaAdd", "(J)V");
|
||||
(*env)->CallVoidMethod(env, g_ctx.mainActivityObj, uaAddId, (long)ua);
|
||||
}
|
||||
|
||||
err = mqueue_alloc(&mq, mqueue_handler, NULL);
|
||||
if (err) {
|
||||
LOGW("mqueue_alloc failed (%d)\n", err);
|
||||
@ -542,9 +536,6 @@ Java_com_tutpro_baresip_BaresipService_baresipStart(JNIEnv *env, jobject instanc
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (le = list_head(uag_list()); le != NULL; le = le->next)
|
||||
ua_print_status_log(le->data);
|
||||
|
||||
jmethodID startedId = (*env)->GetMethodID(env, g_ctx.mainActivityClz, "started", "()V");
|
||||
(*env)->CallVoidMethod(env, g_ctx.mainActivityObj, startedId);
|
||||
|
||||
|
||||
@ -527,36 +527,31 @@ class BaresipService: Service() {
|
||||
}
|
||||
}
|
||||
|
||||
@Keep
|
||||
fun uaAdd(uap: Long) {
|
||||
val ua = UserAgent(uap)
|
||||
ua.status = if (Api.ua_isregistered(uap)) {
|
||||
Log.d(TAG, "Ua ${ua.account.aor} is registered")
|
||||
R.drawable.dot_green
|
||||
} else {
|
||||
Log.d(TAG, "Ua ${ua.account.aor} is NOT registered")
|
||||
if (ua.account.regint == 0)
|
||||
R.drawable.dot_white
|
||||
else
|
||||
R.drawable.dot_yellow
|
||||
}
|
||||
Log.d(TAG, "uaAdd ${ua.account.aor} at BaresipService")
|
||||
uas.add(ua)
|
||||
}
|
||||
|
||||
@SuppressLint("UnspecifiedImmutableFlag")
|
||||
@Keep
|
||||
fun uaEvent(event: String, uap: Long, callp: Long) {
|
||||
|
||||
if (!isServiceRunning) return
|
||||
|
||||
val ev = event.split(",")
|
||||
|
||||
if (ev[0] == "create") {
|
||||
val ua = UserAgent(uap)
|
||||
ua.status = if (ua.account.regint == 0)
|
||||
R.drawable.dot_white
|
||||
else
|
||||
R.drawable.dot_yellow
|
||||
uas.add(UserAgent(uap))
|
||||
return;
|
||||
}
|
||||
|
||||
val ua = UserAgent.ofUap(uap)
|
||||
if (ua == null) {
|
||||
Log.w(TAG, "uaEvent $event did not find ua $uap")
|
||||
return
|
||||
}
|
||||
|
||||
val ev = event.split(",")
|
||||
|
||||
val aor = ua.account.aor
|
||||
|
||||
Log.d(TAG, "got uaEvent $event/$aor/$callp")
|
||||
|
||||
Reference in New Issue
Block a user