summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsip-simple/presence.c
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-07-17 13:53:41 +0000
committerBenny Prijono <bennylp@teluu.com>2008-07-17 13:53:41 +0000
commitd6f361a21e8709fe8b18d8a3bd673f830f3920e9 (patch)
tree11cdbd74af4c6a48b610e2e850a15e646bf2db89 /pjsip/src/pjsip-simple/presence.c
parent01b9c5d12e4ae6e7c633b28936581e9a0e0a18dd (diff)
Ticket #574: Add new API to know why the outgoing subscription request is terminated and added support for delaying subscription acceptance
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2149 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsip-simple/presence.c')
-rw-r--r--pjsip/src/pjsip-simple/presence.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/pjsip/src/pjsip-simple/presence.c b/pjsip/src/pjsip-simple/presence.c
index 842e0a6a..b3fb85d2 100644
--- a/pjsip/src/pjsip-simple/presence.c
+++ b/pjsip/src/pjsip-simple/presence.c
@@ -461,8 +461,13 @@ PJ_DEF(pj_status_t) pjsip_pres_notify( pjsip_evsub *sub,
pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
PJ_ASSERT_RETURN(pres != NULL, PJSIP_SIMPLE_ENOPRESENCE);
- /* Must have at least one presence info. */
- PJ_ASSERT_RETURN(pres->status.info_cnt > 0, PJSIP_SIMPLE_ENOPRESENCEINFO);
+ /* Must have at least one presence info, unless state is
+ * PJSIP_EVSUB_STATE_TERMINATED. This could happen if subscription
+ * has not been active (e.g. we're waiting for user authorization)
+ * and remote cancels the subscription.
+ */
+ PJ_ASSERT_RETURN(state==PJSIP_EVSUB_STATE_TERMINATED ||
+ pres->status.info_cnt > 0, PJSIP_SIMPLE_ENOPRESENCEINFO);
/* Lock object. */
@@ -474,11 +479,14 @@ PJ_DEF(pj_status_t) pjsip_pres_notify( pjsip_evsub *sub,
goto on_return;
- /* Create message body to reflect the presence status. */
- status = pres_create_msg_body( pres, tdata );
- if (status != PJ_SUCCESS)
- goto on_return;
-
+ /* Create message body to reflect the presence status.
+ * Only do this if we have presence status info to send (see above).
+ */
+ if (pres->status.info_cnt > 0) {
+ status = pres_create_msg_body( pres, tdata );
+ if (status != PJ_SUCCESS)
+ goto on_return;
+ }
/* Done. */
*p_tdata = tdata;
@@ -507,8 +515,11 @@ PJ_DEF(pj_status_t) pjsip_pres_current_notify( pjsip_evsub *sub,
pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
PJ_ASSERT_RETURN(pres != NULL, PJSIP_SIMPLE_ENOPRESENCE);
- /* Must have at least one presence info. */
- PJ_ASSERT_RETURN(pres->status.info_cnt > 0, PJSIP_SIMPLE_ENOPRESENCEINFO);
+ /* We may not have a presence info yet, e.g. when we receive SUBSCRIBE
+ * to refresh subscription while we're waiting for user authorization.
+ */
+ //PJ_ASSERT_RETURN(pres->status.info_cnt > 0,
+ // PJSIP_SIMPLE_ENOPRESENCEINFO);
/* Lock object. */
@@ -521,10 +532,11 @@ PJ_DEF(pj_status_t) pjsip_pres_current_notify( pjsip_evsub *sub,
/* Create message body to reflect the presence status. */
- status = pres_create_msg_body( pres, tdata );
- if (status != PJ_SUCCESS)
- goto on_return;
-
+ if (pres->status.info_cnt > 0) {
+ status = pres_create_msg_body( pres, tdata );
+ if (status != PJ_SUCCESS)
+ goto on_return;
+ }
/* Done. */
*p_tdata = tdata;