Changeset 3337


Ignore:
Timestamp:
Oct 12, 2010 11:35:55 AM (13 years ago)
Author:
bennylp
Message:

Closed #1146: support for multipart message bodies in incoming NOTIFY requests

Location:
pjproject/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip-simple/presence.h

    r2762 r3337  
    329329 * 
    330330 * @return              PJ_SUCCESS on success. 
     331 * 
     332 * @see pjsip_pres_parse_pidf2() 
    331333 */ 
    332334PJ_DECL(pj_status_t) pjsip_pres_parse_pidf(pjsip_rx_data *rdata, 
     
    334336                                           pjsip_pres_status *status); 
    335337 
     338/** 
     339 * This is a utility function to parse PIDF body into PJSIP presence status. 
     340 * 
     341 * @param body          Text body, with one extra space at the end to place 
     342 *                      NULL character temporarily during parsing. 
     343 * @param body_len      Length of the body, not including the NULL termination 
     344 *                      character. 
     345 * @param pool          Pool to allocate memory to copy the strings into 
     346 *                      the presence status structure. 
     347 * @param status        The presence status to be initialized. 
     348 * 
     349 * @return              PJ_SUCCESS on success. 
     350 * 
     351 * @see pjsip_pres_parse_pidf() 
     352 */ 
     353PJ_DECL(pj_status_t) pjsip_pres_parse_pidf2(char *body, unsigned body_len, 
     354                                            pj_pool_t *pool, 
     355                                            pjsip_pres_status *status); 
    336356 
    337357 
     
    345365 * 
    346366 * @return              PJ_SUCCESS on success. 
     367 * 
     368 * @see pjsip_pres_parse_xpidf2() 
    347369 */ 
    348370PJ_DECL(pj_status_t) pjsip_pres_parse_xpidf(pjsip_rx_data *rdata, 
     
    351373 
    352374 
     375/** 
     376 * This is a utility function to parse X-PIDF body into PJSIP presence status. 
     377 * 
     378 * @param body          Text body, with one extra space at the end to place 
     379 *                      NULL character temporarily during parsing. 
     380 * @param body_len      Length of the body, not including the NULL termination 
     381 *                      character. 
     382 * @param pool          Pool to allocate memory to copy the strings into 
     383 *                      the presence status structure. 
     384 * @param status        The presence status to be initialized. 
     385 * 
     386 * @return              PJ_SUCCESS on success. 
     387 * 
     388 * @see pjsip_pres_parse_xpidf() 
     389 */ 
     390PJ_DECL(pj_status_t) pjsip_pres_parse_xpidf2(char *body, unsigned body_len, 
     391                                             pj_pool_t *pool, 
     392                                             pjsip_pres_status *status); 
     393 
     394 
    353395 
    354396/** 
  • pjproject/trunk/pjsip/src/pjsip-simple/presence.c

    r2762 r3337  
    2222#include <pjsip-simple/evsub_msg.h> 
    2323#include <pjsip/sip_module.h> 
     24#include <pjsip/sip_multipart.h> 
    2425#include <pjsip/sip_endpoint.h> 
    2526#include <pjsip/sip_dialog.h> 
     
    683684                                           pjsip_hdr *res_hdr) 
    684685{ 
     686    const pj_str_t STR_MULTIPART = { "multipart", 9 }; 
    685687    pjsip_ctype_hdr *ctype_hdr; 
    686688    pj_status_t status; 
     
    708710 
    709711    /* Parse content. */ 
    710  
     712    if (pj_stricmp(&ctype_hdr->media.type, &STR_MULTIPART)==0) { 
     713        pjsip_multipart_part *mpart; 
     714        pjsip_media_type ctype; 
     715 
     716        pjsip_media_type_init(&ctype, (pj_str_t*)&STR_APPLICATION, 
     717                              (pj_str_t*)&STR_PIDF_XML); 
     718        mpart = pjsip_multipart_find_part(rdata->msg_info.msg->body, 
     719                                          &ctype, NULL); 
     720        if (mpart) { 
     721            status = pjsip_pres_parse_pidf2((char*)mpart->body->data, 
     722                                            mpart->body->len, pres->tmp_pool, 
     723                                            &pres->tmp_status); 
     724        } 
     725 
     726        if (mpart==NULL) { 
     727            pjsip_media_type_init(&ctype, (pj_str_t*)&STR_APPLICATION, 
     728                                  (pj_str_t*)&STR_XPIDF_XML); 
     729            mpart = pjsip_multipart_find_part(rdata->msg_info.msg->body, 
     730                                              &ctype, NULL); 
     731            if (mpart) { 
     732                status = pjsip_pres_parse_xpidf2((char*)mpart->body->data, 
     733                                                 mpart->body->len, 
     734                                                 pres->tmp_pool, 
     735                                                 &pres->tmp_status); 
     736            } else { 
     737                status = PJSIP_SIMPLE_EBADCONTENT; 
     738            } 
     739        } 
     740    } 
     741    else 
    711742    if (pj_stricmp(&ctype_hdr->media.type, &STR_APPLICATION)==0 && 
    712743        pj_stricmp(&ctype_hdr->media.subtype, &STR_PIDF_XML)==0) 
  • pjproject/trunk/pjsip/src/pjsip-simple/presence_body.c

    r3255 r3337  
    200200                                           pjsip_pres_status *pres_status) 
    201201{ 
     202    return pjsip_pres_parse_pidf2((char*)rdata->msg_info.msg->body->data, 
     203                                  rdata->msg_info.msg->body->len, 
     204                                  pool, pres_status); 
     205} 
     206 
     207PJ_DEF(pj_status_t) pjsip_pres_parse_pidf2(char *body, unsigned body_len, 
     208                                           pj_pool_t *pool, 
     209                                           pjsip_pres_status *pres_status) 
     210{ 
    202211    pjpidf_pres *pidf; 
    203212    pjpidf_tuple *pidf_tuple; 
    204213 
    205     pidf = pjpidf_parse(rdata->tp_info.pool,  
    206                         (char*)rdata->msg_info.msg->body->data, 
    207                         rdata->msg_info.msg->body->len); 
     214    pidf = pjpidf_parse(pool, body, body_len); 
    208215    if (pidf == NULL) 
    209216        return PJSIP_SIMPLE_EBADPIDF; 
     
    252259                                           pjsip_pres_status *pres_status) 
    253260{ 
     261    return pjsip_pres_parse_xpidf2((char*)rdata->msg_info.msg->body->data, 
     262                                   rdata->msg_info.msg->body->len, 
     263                                   pool, pres_status); 
     264} 
     265 
     266PJ_DEF(pj_status_t) pjsip_pres_parse_xpidf2(char *body, unsigned body_len, 
     267                                            pj_pool_t *pool, 
     268                                            pjsip_pres_status *pres_status) 
     269{ 
    254270    pjxpidf_pres *xpidf; 
    255271 
    256     xpidf = pjxpidf_parse(rdata->tp_info.pool,  
    257                           (char*)rdata->msg_info.msg->body->data, 
    258                           rdata->msg_info.msg->body->len); 
     272    xpidf = pjxpidf_parse(pool, body, body_len); 
    259273    if (xpidf == NULL) 
    260274        return PJSIP_SIMPLE_EBADXPIDF; 
Note: See TracChangeset for help on using the changeset viewer.