Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bevent new api #54

Merged
merged 6 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions modules/autotest/autotest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions modules/b2bua/b2bua.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions modules/intercom/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions modules/intercom/intercom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();

Expand Down
3 changes: 1 addition & 2 deletions modules/intercom/intercom.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 4 additions & 6 deletions modules/kaoptions/kaoptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions modules/parcall/parcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
11 changes: 5 additions & 6 deletions modules/qualify/qualify.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand Down
Loading