diff options
Diffstat (limited to 'modules/presence/publisher.c')
-rw-r--r-- | modules/presence/publisher.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/modules/presence/publisher.c b/modules/presence/publisher.c index 883ffd7..b00096e 100644 --- a/modules/presence/publisher.c +++ b/modules/presence/publisher.c @@ -189,10 +189,11 @@ static void tmr_handler(void *arg) { struct publisher *pub = arg; - if (publish(pub)) { + if (publish(pub)) tmr_start(&pub->tmr, wait_fail(++pub->failc) * 1000, tmr_handler, pub); - } + else + pub->failc = 0; } @@ -235,7 +236,7 @@ static int publisher_alloc(struct ua *ua) pub->expires = account_pubint(ua_account(ua)); tmr_init(&pub->tmr); - tmr_start(&pub->tmr, 100, tmr_handler, pub); + tmr_start(&pub->tmr, 10, tmr_handler, pub); list_append(&publ, &pub->le, pub); @@ -243,11 +244,35 @@ static int publisher_alloc(struct ua *ua) } +static void pub_ua_event_handler(struct ua *ua, + enum ua_event ev, + struct call *call, + const char *prm, + void *arg ) +{ + (void)call; + (void)prm; + (void)arg; + + if (account_pubint(ua_account(ua)) == 0) + return; + + if (ev == UA_EVENT_REGISTER_OK) { + if (ua_presence_status(ua) == PRESENCE_UNKNOWN) { + ua_presence_status_set(ua, PRESENCE_OPEN); + publisher_update_status(ua); + } + } +} + + int publisher_init(void) { struct le *le; int err = 0; + uag_event_register(pub_ua_event_handler, NULL); + for (le = list_head(uag_list()); le; le = le->next) { struct ua *ua = le->data; @@ -270,6 +295,8 @@ void publisher_close(void) { struct le *le; + uag_event_unregister(pub_ua_event_handler); + for (le = list_head(&publ); le; le = le->next) { struct publisher *pub = le->data; |