diff options
Diffstat (limited to 'modules/mwi/mwi.c')
-rw-r--r-- | modules/mwi/mwi.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/modules/mwi/mwi.c b/modules/mwi/mwi.c index 21aca08..cfc6d9f 100644 --- a/modules/mwi/mwi.c +++ b/modules/mwi/mwi.c @@ -102,6 +102,25 @@ static int mwi_subscribe(struct ua *ua) } +static void ua_event_handler(struct ua *ua, + enum ua_event ev, + struct call *call, + const char *prm, + void *arg ) +{ + (void)call; + (void)prm; + + if (ua != (struct ua *)arg) + return; + + if (ev == UA_EVENT_REGISTER_OK) { + uag_event_unregister(ua_event_handler); + mwi_subscribe(ua); + } +} + + static void tmr_handler(void *arg) { struct le *le; @@ -110,7 +129,11 @@ static void tmr_handler(void *arg) for (le = list_head(uag_list()); le; le = le->next) { struct ua *ua = le->data; - mwi_subscribe(ua); + struct account *acc = ua_account(ua); + if (account_regint(acc) > 0) + uag_event_register(ua_event_handler, ua); + else + mwi_subscribe(ua); } } @@ -118,7 +141,7 @@ static void tmr_handler(void *arg) static int module_init(void) { list_init(&mwil); - tmr_start(&tmr, 10, tmr_handler, 0); + tmr_start(&tmr, 1, tmr_handler, 0); return 0; } |