summaryrefslogtreecommitdiff
path: root/pjsip/src/pjsip-simple
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2011-02-11 07:39:14 +0000
committerLiong Sauw Ming <ming@teluu.com>2011-02-11 07:39:14 +0000
commit4477551db5dbf220762db3e1dc8afa2a4d75e46f (patch)
treefa80697f341d7c4f7a2e8c6c857eb80a73edf99c /pjsip/src/pjsip-simple
parent6f8cdb0b445e9f94dc3a0bb35586b0b69c756b99 (diff)
Re #1161: Support for adding custom presence subscription headers.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3412 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsip-simple')
-rw-r--r--pjsip/src/pjsip-simple/evsub.c36
-rw-r--r--pjsip/src/pjsip-simple/presence.c10
2 files changed, 45 insertions, 1 deletions
diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c
index c55d3b47..bf26a3db 100644
--- a/pjsip/src/pjsip-simple/evsub.c
+++ b/pjsip/src/pjsip-simple/evsub.c
@@ -227,6 +227,7 @@ struct pjsip_evsub
pjsip_event_hdr *event; /**< Event description. */
pjsip_expires_hdr *expires; /**< Expires header */
pjsip_accept_hdr *accept; /**< Local Accept header. */
+ pjsip_hdr sub_hdr_list; /**< User-defined header. */
pj_time_val refresh_time; /**< Time to refresh. */
pj_timer_entry timer; /**< Internal timer. */
@@ -723,6 +724,7 @@ static pj_status_t evsub_create( pjsip_dialog *dlg,
sub->expires = pjsip_expires_hdr_create(sub->pool, pkg->pkg_expires);
sub->accept = (pjsip_accept_hdr*)
pjsip_hdr_clone(sub->pool, pkg->pkg_accept);
+ pj_list_init(&sub->sub_hdr_list);
sub->timer.user_data = sub;
sub->timer.cb = &on_timer;
@@ -1027,7 +1029,18 @@ PJ_DEF(pj_status_t) pjsip_evsub_initiate( pjsip_evsub *sub,
pjsip_hdr_shallow_clone(tdata->pool,
mod_evsub.allow_events_hdr));
-
+
+ /* Add custom headers */
+ {
+ const pjsip_hdr *hdr = sub->sub_hdr_list.next;
+ while (hdr != &sub->sub_hdr_list) {
+ pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
+ pjsip_hdr_shallow_clone(tdata->pool, hdr));
+ hdr = hdr->next;
+ }
+ }
+
+
*p_tdata = tdata;
@@ -1039,6 +1052,27 @@ on_return:
/*
+ * Add custom headers.
+ */
+PJ_DEF(pj_status_t) pjsip_evsub_add_header( pjsip_evsub *sub,
+ const pjsip_hdr *hdr_list )
+{
+ const pjsip_hdr *hdr;
+
+ PJ_ASSERT_RETURN(sub && hdr_list, PJ_EINVAL);
+
+ hdr = hdr_list->next;
+ while (hdr != hdr_list) {
+ pj_list_push_back(&sub->sub_hdr_list, (pjsip_hdr*)
+ pjsip_hdr_clone(sub->pool, hdr));
+ hdr = hdr->next;
+ }
+
+ return PJ_SUCCESS;
+}
+
+
+/*
* Accept incoming subscription request.
*/
PJ_DEF(pj_status_t) pjsip_evsub_accept( pjsip_evsub *sub,
diff --git a/pjsip/src/pjsip-simple/presence.c b/pjsip/src/pjsip-simple/presence.c
index 59a6bc8b..ac344fd9 100644
--- a/pjsip/src/pjsip-simple/presence.c
+++ b/pjsip/src/pjsip-simple/presence.c
@@ -356,6 +356,16 @@ PJ_DEF(pj_status_t) pjsip_pres_initiate( pjsip_evsub *sub,
/*
+ * Add custom headers.
+ */
+PJ_DEF(pj_status_t) pjsip_pres_add_header( pjsip_evsub *sub,
+ const pjsip_hdr *hdr_list )
+{
+ return pjsip_evsub_add_header( sub, hdr_list );
+}
+
+
+/*
* Accept incoming subscription.
*/
PJ_DEF(pj_status_t) pjsip_pres_accept( pjsip_evsub *sub,