From 166d502e3aef98bbf1129c01e2c222e6d07cdc10 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Wed, 10 Feb 2010 14:24:48 +0000 Subject: [PATCH] Ticket #995: Send un-PUBLISH when pjsua_acc_set_registration(FALSE) is called (thanks Johan Lantz for the suggestion) - in this implementation, when pjsua_acc_set_registration(FALSE) is called, the un-REGISTER request will be sent immediately after un-PUBLISH, unlike the process during shutdown where the un-REGISTER request will be sent only after un-PUBLISH transaction is complete git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@3096 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsua-lib/pjsua_internal.h | 5 ++++ pjsip/src/pjsua-lib/pjsua_acc.c | 3 +++ pjsip/src/pjsua-lib/pjsua_pres.c | 33 ++++++++++++++---------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h index c90da124d..caba46aa9 100644 --- a/pjsip/include/pjsua-lib/pjsua_internal.h +++ b/pjsip/include/pjsua-lib/pjsua_internal.h @@ -443,6 +443,11 @@ pj_status_t pjsua_pres_init_acc(int acc_id); */ pj_status_t pjsua_pres_init_publish_acc(int acc_id); +/** + * Send un-PUBLISH + */ +void pjsua_pres_unpublish(pjsua_acc *acc); + /** * Terminate server subscription for the account */ diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c index 965ead0e7..18096629f 100644 --- a/pjsip/src/pjsua-lib/pjsua_acc.c +++ b/pjsip/src/pjsua-lib/pjsua_acc.c @@ -1264,6 +1264,9 @@ PJ_DEF(pj_status_t) pjsua_acc_set_registration( pjsua_acc_id acc_id, status = PJ_EINVALIDOP; goto on_return; } + + pjsua_pres_unpublish(&pjsua_var.acc[acc_id]); + status = pjsip_regc_unregister(pjsua_var.acc[acc_id].regc, &tdata); } diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c index e74ee4068..620c7cd7a 100644 --- a/pjsip/src/pjsua-lib/pjsua_pres.c +++ b/pjsip/src/pjsua-lib/pjsua_pres.c @@ -1275,11 +1275,29 @@ pj_status_t pjsua_pres_init_acc(int acc_id) } +/* Unpublish presence publication */ +void pjsua_pres_unpublish(pjsua_acc *acc) +{ + if (acc->publish_sess) { + pjsua_acc_config *acc_cfg = &acc->cfg; + + acc->online_status = PJ_FALSE; + send_publish(acc->index, PJ_FALSE); + /* By ticket #364, don't destroy the session yet (let the callback + destroy it) + if (acc->publish_sess) { + pjsip_publishc_destroy(acc->publish_sess); + acc->publish_sess = NULL; + } + */ + acc_cfg->publish_enabled = PJ_FALSE; + } +} + /* Terminate server subscription for the account */ void pjsua_pres_delete_acc(int acc_id) { pjsua_acc *acc = &pjsua_var.acc[acc_id]; - pjsua_acc_config *acc_cfg = &pjsua_var.acc[acc_id].cfg; pjsua_srv_pres *uapres; uapres = pjsua_var.acc[acc_id].pres_srv_list.next; @@ -1314,18 +1332,7 @@ void pjsua_pres_delete_acc(int acc_id) pj_list_init(&acc->pres_srv_list); /* Terminate presence publication, if any */ - if (acc->publish_sess) { - acc->online_status = PJ_FALSE; - send_publish(acc_id, PJ_FALSE); - /* By ticket #364, don't destroy the session yet (let the callback - destroy it) - if (acc->publish_sess) { - pjsip_publishc_destroy(acc->publish_sess); - acc->publish_sess = NULL; - } - */ - acc_cfg->publish_enabled = PJ_FALSE; - } + pjsua_pres_unpublish(acc); }