diff options
author | Juha Heinanen <jh@tutpro.com> | 2014-09-22 10:33:42 +0300 |
---|---|---|
committer | Juha Heinanen <jh@tutpro.com> | 2014-09-22 10:33:42 +0300 |
commit | dc56c28f8e4680834c2024096d8132a1b80ea9b0 (patch) | |
tree | 320bac49223c8505445dece7342b833b0ec45b32 /modules | |
parent | d0ae75c37e100f39013d9bf9aff2a36ee22ca12d (diff) |
modules/mwi: subscribe to mwi after registration has succeeded
Diffstat (limited to 'modules')
-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; } |