From 457b0d6cc6ade0a1c40b8712b30bd4abe2cd42ee Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Tue, 12 Oct 2010 11:35:55 +0000 Subject: Closed #1146: support for multipart message bodies in incoming NOTIFY requests git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3337 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip-simple/presence.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'pjsip/src/pjsip-simple/presence.c') diff --git a/pjsip/src/pjsip-simple/presence.c b/pjsip/src/pjsip-simple/presence.c index 24049359..b2f48262 100644 --- a/pjsip/src/pjsip-simple/presence.c +++ b/pjsip/src/pjsip-simple/presence.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -682,6 +683,7 @@ static pj_status_t pres_process_rx_notify( pjsip_pres *pres, pj_str_t **p_st_text, pjsip_hdr *res_hdr) { + const pj_str_t STR_MULTIPART = { "multipart", 9 }; pjsip_ctype_hdr *ctype_hdr; pj_status_t status; @@ -707,7 +709,36 @@ static pj_status_t pres_process_rx_notify( pjsip_pres *pres, } /* Parse content. */ + if (pj_stricmp(&ctype_hdr->media.type, &STR_MULTIPART)==0) { + pjsip_multipart_part *mpart; + pjsip_media_type ctype; + + pjsip_media_type_init(&ctype, (pj_str_t*)&STR_APPLICATION, + (pj_str_t*)&STR_PIDF_XML); + mpart = pjsip_multipart_find_part(rdata->msg_info.msg->body, + &ctype, NULL); + if (mpart) { + status = pjsip_pres_parse_pidf2((char*)mpart->body->data, + mpart->body->len, pres->tmp_pool, + &pres->tmp_status); + } + if (mpart==NULL) { + pjsip_media_type_init(&ctype, (pj_str_t*)&STR_APPLICATION, + (pj_str_t*)&STR_XPIDF_XML); + mpart = pjsip_multipart_find_part(rdata->msg_info.msg->body, + &ctype, NULL); + if (mpart) { + status = pjsip_pres_parse_xpidf2((char*)mpart->body->data, + mpart->body->len, + pres->tmp_pool, + &pres->tmp_status); + } else { + status = PJSIP_SIMPLE_EBADCONTENT; + } + } + } + else if (pj_stricmp(&ctype_hdr->media.type, &STR_APPLICATION)==0 && pj_stricmp(&ctype_hdr->media.subtype, &STR_PIDF_XML)==0) { -- cgit v1.2.3