diff --git a/modules/autotest/autotest.c b/modules/autotest/autotest.c index 82fe229..072e256 100644 --- a/modules/autotest/autotest.c +++ b/modules/autotest/autotest.c @@ -93,14 +93,16 @@ static void dial(void *arg) } -static void ua_event_handler(struct ua *ua, enum ua_event ev, - struct call *call, const char *prm, void *arg) +static void event_handler(enum ua_event ev, struct bevent *event, void *arg) { + struct ua *ua = bevent_get_ua(event); + struct call *call = bevent_get_call(event); + const char *txt = bevent_get_text(event); struct account *acc = ua_account(ua); (void) arg; info("autotest: [ ua=%s call=%s ] event: %s (%s)\n", - account_aor(acc), call_id(call), uag_event_str(ev), prm); + account_aor(acc), call_id(call), uag_event_str(ev), txt); switch (ev) { @@ -287,7 +289,7 @@ static int module_init(void) info("autotest: module init\n"); memset(&d, 0, sizeof(d)); - err = uag_event_register(ua_event_handler, NULL); + err = bevent_register(event_handler, NULL); if (err) return err; @@ -303,7 +305,7 @@ static int module_close(void) tmr_cancel(&d.tmr_hangup); tmr_cancel(&d.tmr_dial); cmd_unregister(baresip_commands(), cmdv); - uag_event_unregister(ua_event_handler); + bevent_unregister(event_handler); mem_deref(d.mbdial); mem_deref(d.mbhangup); return 0; diff --git a/modules/b2bua/b2bua.c b/modules/b2bua/b2bua.c index e9d5cab..73dbe42 100644 --- a/modules/b2bua/b2bua.c +++ b/modules/b2bua/b2bua.c @@ -132,12 +132,10 @@ static int new_session(struct call *call) } -static void ua_event_handler(struct ua *ua, enum ua_event ev, - struct call *call, const char *prm, void *arg) +static void event_handler(enum ua_event ev, struct bevent *event, void *arg) { + struct call *call = bevent_get_call(event); int err; - (void)ua; - (void)prm; (void)arg; switch (ev) { @@ -213,7 +211,7 @@ static int module_init(void) if (err) return err; - err = uag_event_register(ua_event_handler, NULL); + err = bevent_register(event_handler, NULL); if (err) return err; @@ -236,7 +234,7 @@ static int module_close(void) list_flush(&sessionl); } - uag_event_unregister(ua_event_handler); + bevent_unregister(event_handler); cmd_unregister(baresip_commands(), cmdv); return 0; diff --git a/modules/intercom/events.c b/modules/intercom/events.c index 7983c47..f9995f9 100644 --- a/modules/intercom/events.c +++ b/modules/intercom/events.c @@ -15,10 +15,9 @@ static int reject_call(struct call *call, uint16_t scode, const char *reason) { - struct ua *ua = call_get_ua(call); call_hangup(call, scode, reason); - ua_event(ua, UA_EVENT_CALL_CLOSED, call, reason); + bevent_call_emit(UA_EVENT_CALL_CLOSED, call, reason); return mem_deref_later(call); } @@ -310,13 +309,12 @@ static int established_handler(const struct pl *name, } -void ua_event_handler(struct ua *ua, enum ua_event ev, - struct call *call, const char *prm, void *arg) +void event_handler(enum ua_event ev, struct bevent *event, void *arg) { const struct list *hdrs; - (void)prm; + struct ua *ua = bevent_get_ua(event); + struct call *call = bevent_get_call(event); (void)arg; - (void)ua; if (call) { hdrs = call_get_custom_hdrs(call); diff --git a/modules/intercom/intercom.c b/modules/intercom/intercom.c index c50cb7e..a551839 100644 --- a/modules/intercom/intercom.c +++ b/modules/intercom/intercom.c @@ -360,7 +360,7 @@ static int module_init(void) st.met = ANSM_ALERTINFO; (void)conf_apply(conf_cur(), "iccustom", iccustom_handler, st.custom); - err |= uag_event_register(ua_event_handler, NULL); + err |= bevent_register(event_handler, NULL); err |= uag_add_xhdr_intercom(); err |= iccustom_init(); err |= ichidden_init(); @@ -377,7 +377,7 @@ static int module_close(void) mem_deref(st.custom); mem_deref(st.ansval); cmd_unregister(baresip_commands(), cmdv); - uag_event_unregister(ua_event_handler); + bevent_unregister(event_handler); iccustom_close(); ichidden_close(); diff --git a/modules/intercom/intercom.h b/modules/intercom/intercom.h index 5aabb1b..7f81b74 100644 --- a/modules/intercom/intercom.h +++ b/modules/intercom/intercom.h @@ -5,8 +5,7 @@ */ -void ua_event_handler(struct ua *ua, enum ua_event ev, - struct call *call, const char *prm, void *arg); +void event_handler(enum ua_event ev, struct bevent *event, void *arg); int mem_deref_later(void *arg); struct iccustom *iccustom_find(const struct pl *val); diff --git a/modules/kaoptions/kaoptions.c b/modules/kaoptions/kaoptions.c index 9914a20..3adce89 100644 --- a/modules/kaoptions/kaoptions.c +++ b/modules/kaoptions/kaoptions.c @@ -209,11 +209,9 @@ static int kaoptions_stop(struct ua *ua) } -static void ua_event_handler(struct ua *ua, enum ua_event ev, - struct call *call, const char *prm, void *arg) +static void event_handler(enum ua_event ev, struct bevent *event, void *arg) { - (void) call; - (void) prm; + struct ua *ua = bevent_get_ua(event); (void) arg; switch (ev) { @@ -237,7 +235,7 @@ static int module_init(void) { int err; - err = uag_event_register(ua_event_handler, NULL); + err = bevent_register(event_handler, NULL); info("kaoptions: init\n"); return err; @@ -246,7 +244,7 @@ static int module_init(void) static int module_close(void) { - uag_event_unregister(ua_event_handler); + bevent_unregister(event_handler); list_flush(&kao.ka_ual); return 0; diff --git a/modules/parcall/parcall.c b/modules/parcall/parcall.c index 02d52bb..c6bcd89 100644 --- a/modules/parcall/parcall.c +++ b/modules/parcall/parcall.c @@ -163,13 +163,11 @@ static bool parcall_debug(struct le *le, void *arg) } -static void ua_event_handler(struct ua *ua, enum ua_event ev, - struct call *call, const char *prm, void *arg) +static void event_handler(enum ua_event ev, struct bevent *event, void *arg) { struct le *le; + struct call *call = bevent_get_call(event); - (void)ua; - (void)prm; (void)arg; switch (ev) { @@ -490,7 +488,7 @@ static int module_init(void) if (err) return err; - err = uag_event_register(ua_event_handler, NULL); + err = bevent_register(event_handler, NULL); err |= cmd_register(baresip_commands(), cmdv, RE_ARRAY_SIZE(cmdv)); if (err) return err; @@ -502,7 +500,7 @@ static int module_init(void) static int module_close(void) { - uag_event_unregister(ua_event_handler); + bevent_unregister(event_handler); cmd_unregister(baresip_commands(), cmdv); hash_flush(d.pargroups); hash_flush(d.parcalls); diff --git a/modules/qualify/qualify.c b/modules/qualify/qualify.c index a570dfc..84180a6 100644 --- a/modules/qualify/qualify.c +++ b/modules/qualify/qualify.c @@ -249,13 +249,12 @@ static void qualle_stop_tmrs(struct qualle *qualle) } -static void ua_event_handler(struct ua *ua, enum ua_event ev, - struct call *call, const char *prm, void *arg) +static void event_handler(enum ua_event ev, struct bevent *event, void *arg) { + struct ua *ua = bevent_get_ua(event); + struct call *call = bevent_get_call(event); struct account *acc = ua_account(ua); struct qualle *qualle; - (void) call; - (void) prm; (void) arg; switch (ev) { @@ -293,7 +292,7 @@ static int module_init(void) info("qualify: init\n"); - err = uag_event_register(ua_event_handler, NULL); + err = bevent_register(event_handler, NULL); err |= hash_alloc(&q.qual_map, 32); return err; @@ -302,7 +301,7 @@ static int module_init(void) static int module_close(void) { - uag_event_unregister(ua_event_handler); + bevent_unregister(event_handler); hash_flush(q.qual_map); mem_deref(q.qual_map);