Changeset 1271


Ignore:
Timestamp:
May 14, 2007 4:37:47 PM (17 years ago)
Author:
bennylp
Message:

Ticket #272: the From parameter on_pager() callback contains Contact instead (thanks Nicholas Xu), and also allow non-text/plain IM messages

Location:
pjproject/branches/pjproject-0.5-stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/pjproject-0.5-stable/pjsip-apps/src/pjsua/pjsua_app.c

    r1223 r1271  
    17411741    PJ_UNUSED_ARG(mime_type); 
    17421742 
    1743     PJ_LOG(3,(THIS_FILE,"MESSAGE from %.*s: %.*s", 
     1743    PJ_LOG(3,(THIS_FILE,"MESSAGE from %.*s: %.*s (%.*s)", 
    17441744              (int)from->slen, from->ptr, 
    1745               (int)text->slen, text->ptr)); 
     1745              (int)text->slen, text->ptr, 
     1746              (int)mime_type->slen, mime_type->ptr)); 
    17461747} 
    17471748 
  • pjproject/branches/pjproject-0.5-stable/pjsip/src/pjsua-lib/pjsua_im.c

    r1147 r1271  
    7373 
    7474/* Check if content type is acceptable */ 
     75#if 0 
    7576static pj_bool_t acceptable_message(const pjsip_media_type *mime) 
    7677{ 
     
    8182            pj_stricmp(&mime->subtype, &STR_MIME_ISCOMPOSING)==0); 
    8283} 
    83  
     84#endif 
    8485 
    8586/** 
     
    105106                                pjsip_accept_hdr **p_accept_hdr) 
    106107{ 
     108    /* Some UA sends text/html, so this check will break */ 
     109#if 0 
    107110    pjsip_ctype_hdr *ctype; 
    108111    pjsip_msg *msg; 
     
    123126        return PJ_FALSE; 
    124127    } 
     128#else 
     129    PJ_UNUSED_ARG(rdata); 
     130    PJ_UNUSED_ARG(p_accept_hdr); 
     131#endif 
    125132 
    126133    return PJ_TRUE; 
     
    155162    } 
    156163 
    157  
    158     if (pj_stricmp(&body->content_type.type, &STR_MIME_TEXT)==0 && 
    159         pj_stricmp(&body->content_type.subtype, &STR_MIME_PLAIN)==0) 
     164    if (pj_stricmp(&body->content_type.type, &STR_MIME_APP)==0 && 
     165        pj_stricmp(&body->content_type.subtype, &STR_MIME_ISCOMPOSING)==0) 
    160166    { 
    161         const pj_str_t mime_text_plain = pj_str("text/plain"); 
    162         pj_str_t text_body; 
    163          
    164         /* Save text body */ 
    165         text_body.ptr = rdata->msg_info.msg->body->data; 
    166         text_body.slen = rdata->msg_info.msg->body->len; 
    167  
    168         if (pjsua_var.ua_cfg.cb.on_pager) { 
    169             (*pjsua_var.ua_cfg.cb.on_pager)(call_id, from, to, &contact,  
    170                                             &mime_text_plain, &text_body); 
    171         } 
    172  
    173     } else { 
    174167        /* Expecting typing indication */ 
    175168        pj_status_t status; 
     
    188181                                             is_typing); 
    189182        } 
     183 
     184    } else { 
     185        pj_str_t mime_type; 
     186        char buf[256]; 
     187        pjsip_media_type *m; 
     188        pj_str_t text_body; 
     189         
     190        /* Save text body */ 
     191        text_body.ptr = rdata->msg_info.msg->body->data; 
     192        text_body.slen = rdata->msg_info.msg->body->len; 
     193 
     194        /* Get mime type */ 
     195        m = &rdata->msg_info.msg->body->content_type; 
     196        mime_type.ptr = buf; 
     197        mime_type.slen = pj_ansi_snprintf(buf, sizeof(buf), 
     198                                          "%.*s/%.*s", 
     199                                          (int)m->type.slen, 
     200                                          m->type.ptr, 
     201                                          (int)m->subtype.slen, 
     202                                          m->subtype.ptr); 
     203        if (mime_type.slen < 1) 
     204            mime_type.slen = 0; 
     205 
     206        if (pjsua_var.ua_cfg.cb.on_pager) { 
     207            (*pjsua_var.ua_cfg.cb.on_pager)(call_id, from, to, &contact,  
     208                                            &mime_type, &text_body); 
     209        } 
    190210    } 
    191211 
     
    200220    pj_str_t from, to; 
    201221    pjsip_accept_hdr *accept_hdr; 
    202     pjsip_contact_hdr *contact_hdr; 
    203222    pjsip_msg *msg; 
    204223    pj_status_t status; 
     
    242261     */ 
    243262    from.ptr = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE); 
    244     contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, 
    245                                      PJSIP_H_CONTACT, NULL); 
    246     if (contact_hdr) { 
    247         from.slen = pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, 
    248                                     contact_hdr->uri,  
    249                                     from.ptr, PJSIP_MAX_URL_SIZE); 
    250     } else { 
    251         from.slen = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR,  
    252                                     rdata->msg_info.from->uri, 
    253                                     from.ptr, PJSIP_MAX_URL_SIZE); 
    254     } 
     263    from.slen = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR,  
     264                                rdata->msg_info.from->uri, 
     265                                from.ptr, PJSIP_MAX_URL_SIZE); 
    255266 
    256267    if (from.slen < 1) 
Note: See TracChangeset for help on using the changeset viewer.