Changeset 3323 for pjproject/trunk


Ignore:
Timestamp:
Sep 28, 2010 7:43:18 AM (14 years ago)
Author:
bennylp
Message:

Closed #1139 (Support for tel: URI in PJSUA-LIB):

  • added new PJSUA API: pjsua_verify_url() which can be used for tel: URI
  • modified and tested according to spec
  • added new PJSIP error code, PJSIP_ENOROUTESET, to indicate that route set is needed to send to tel: URI
  • added couple of unit tests (we can't cover the whole tel: URI scenario yet)
Location:
pjproject/trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r3318 r3323  
    920920 
    921921        case OPT_ID:   /* id */ 
    922             if (pjsua_verify_sip_url(pj_optarg) != 0) { 
     922            if (pjsua_verify_url(pj_optarg) != 0) { 
    923923                PJ_LOG(1,(THIS_FILE,  
    924924                          "Error: invalid SIP URL '%s' " 
     
    10381038 
    10391039        case OPT_ADD_BUDDY: /* Add to buddy list. */ 
    1040             if (pjsua_verify_sip_url(pj_optarg) != 0) { 
     1040            if (pjsua_verify_url(pj_optarg) != 0) { 
    10411041                PJ_LOG(1,(THIS_FILE,  
    10421042                          "Error: invalid URL '%s' in " 
     
    14221422        pj_str_t uri_arg; 
    14231423 
    1424         if (pjsua_verify_sip_url(argv[pj_optind]) != PJ_SUCCESS) { 
     1424        if (pjsua_verify_url(argv[pj_optind]) != PJ_SUCCESS) { 
    14251425            PJ_LOG(1,(THIS_FILE, "Invalid SIP URI %s", argv[pj_optind])); 
    14261426            return -1; 
     
    32773277        pj_status_t status; 
    32783278 
    3279         if ((status=pjsua_verify_sip_url(buf)) != PJ_SUCCESS) { 
     3279        if ((status=pjsua_verify_url(buf)) != PJ_SUCCESS) { 
    32803280            pjsua_perror(THIS_FILE, "Invalid URL", status); 
    32813281            return; 
     
    38123812                    break; 
    38133813 
    3814                 if (pjsua_verify_sip_url(buf) != PJ_SUCCESS) { 
    3815                     printf("Invalid SIP URI '%s'\n", buf); 
     3814                if (pjsua_verify_url(buf) != PJ_SUCCESS) { 
     3815                    printf("Invalid URI '%s'\n", buf); 
    38163816                    break; 
    38173817                } 
  • pjproject/trunk/pjsip-apps/src/samples/simple_pjsua.c

    r2408 r3323  
    118118    /* If argument is specified, it's got to be a valid SIP URL */ 
    119119    if (argc > 1) { 
    120         status = pjsua_verify_sip_url(argv[1]); 
     120        status = pjsua_verify_url(argv[1]); 
    121121        if (status != PJ_SUCCESS) error_exit("Invalid URL in argv", status); 
    122122    } 
  • pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp

    r3253 r3323  
    734734        } 
    735735 
    736         if (pjsua_verify_sip_url(SIP_DST_URI) == PJ_SUCCESS) { 
     736        if (pjsua_verify_url(SIP_DST_URI) == PJ_SUCCESS) { 
    737737                pj_str_t dst = pj_str(SIP_DST_URI); 
    738738                pjsua_call_make_call(g_acc_id, &dst, 0, NULL, 
  • pjproject/trunk/pjsip-apps/src/symbian_ua_gui/src/symbian_ua.cpp

    r3106 r3323  
    483483int symbian_ua_makecall(const char* dest_url) 
    484484{ 
    485     if (pjsua_verify_sip_url(dest_url) == PJ_SUCCESS) { 
     485    if (pjsua_verify_url(dest_url) == PJ_SUCCESS) { 
    486486            pj_str_t dst = pj_str((char*)dest_url); 
    487487            pjsua_call_make_call(g_acc_id, &dst, 0, NULL, 
  • pjproject/trunk/pjsip/include/pjsip/sip_errno.h

    r3110 r3323  
    9797 */ 
    9898#define PJSIP_ENOTINITIALIZED   (PJSIP_ERRNO_START_PJSIP + 4)   /* 171004 */ 
     99/** 
     100 * @hideinitializer 
     101 * Missing route set (for tel: URI) 
     102 */ 
     103#define PJSIP_ENOROUTESET       (PJSIP_ERRNO_START_PJSIP + 5)   /* 171005 */ 
    99104 
    100105 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r3322 r3323  
    15411541/** 
    15421542 * This is a utility function to verify that valid SIP url is given. If the 
    1543  * URL is valid, PJ_SUCCESS will be returned. 
     1543 * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned. 
    15441544 * 
    15451545 * @param url           The URL, as NULL terminated string. 
    15461546 * 
    15471547 * @return              PJ_SUCCESS on success, or the appropriate error code. 
     1548 * 
     1549 * @see pjsua_verify_url() 
    15481550 */ 
    15491551PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url); 
     1552 
     1553 
     1554/** 
     1555 * This is a utility function to verify that valid URI is given. Unlike 
     1556 * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI 
     1557 * is given. 
     1558 * 
     1559 * @param url           The URL, as NULL terminated string. 
     1560 * 
     1561 * @return              PJ_SUCCESS on success, or the appropriate error code. 
     1562 * 
     1563 * @see pjsua_verify_sip_url() 
     1564 */ 
     1565PJ_DECL(pj_status_t) pjsua_verify_url(const char *url); 
    15501566 
    15511567 
  • pjproject/trunk/pjsip/src/pjsip/sip_errno.c

    r3110 r3323  
    4040    PJ_BUILD_ERR( PJSIP_ESHUTDOWN,      "SIP stack shutting down" ), 
    4141    PJ_BUILD_ERR( PJSIP_ENOTINITIALIZED,"SIP object is not initialized." ), 
     42    PJ_BUILD_ERR( PJSIP_ENOROUTESET,    "Missing route set (for tel: URI)" ), 
    4243 
    4344    /* Messaging errors */ 
  • pjproject/trunk/pjsip/src/pjsip/sip_util.c

    r3260 r3323  
    836836            pjsip_transport_get_flag_from_type(dest_info->type); 
    837837    } else { 
     838        /* Should have never reached here; app should have configured route 
     839         * set when sending to tel: URI 
    838840        pj_assert(!"Unsupported URI scheme!"); 
     841         */ 
    839842        PJ_TODO(SUPPORT_REQUEST_ADDR_RESOLUTION_FOR_TEL_URI); 
    840         return PJSIP_EINVALIDSCHEME; 
     843        return PJSIP_ENOROUTESET; 
    841844    } 
    842845 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c

    r3322 r3323  
    120120    pjsua_acc *acc = &pjsua_var.acc[acc_id]; 
    121121    pjsip_name_addr *name_addr; 
    122     pjsip_sip_uri *sip_uri, *sip_reg_uri; 
     122    pjsip_sip_uri *sip_reg_uri; 
    123123    pj_status_t status; 
    124124    unsigned i; 
     
    137137 
    138138    /* Local URI MUST be a SIP or SIPS: */ 
    139  
    140139    if (!PJSIP_URI_SCHEME_IS_SIP(name_addr) &&  
    141140        !PJSIP_URI_SCHEME_IS_SIPS(name_addr))  
    142141    { 
    143         pjsua_perror(THIS_FILE, "Invalid local URI",  
    144                      PJSIP_EINVALIDSCHEME); 
    145         return PJSIP_EINVALIDSCHEME; 
    146     } 
    147  
    148  
    149     /* Get the SIP URI object: */ 
    150     sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri(name_addr); 
     142        acc->display = name_addr->display; 
     143        acc->user_part = name_addr->display; 
     144        acc->srv_domain = pj_str(""); 
     145        acc->srv_port = 0; 
     146    } else { 
     147        pjsip_sip_uri *sip_uri; 
     148 
     149        /* Get the SIP URI object: */ 
     150        sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri(name_addr); 
     151 
     152        /* Save the user and domain part. These will be used when finding an 
     153         * account for incoming requests. 
     154         */ 
     155        acc->display = name_addr->display; 
     156        acc->user_part = sip_uri->user; 
     157        acc->srv_domain = sip_uri->host; 
     158        acc->srv_port = 0; 
     159    } 
    151160 
    152161 
     
    177186        sip_reg_uri = NULL; 
    178187    } 
    179  
    180     /* Save the user and domain part. These will be used when finding an  
    181      * account for incoming requests. 
    182      */ 
    183     acc->display = name_addr->display; 
    184     acc->user_part = sip_uri->user; 
    185     acc->srv_domain = sip_uri->host; 
    186     acc->srv_port = 0; 
    187188 
    188189    if (sip_reg_uri) { 
     
    21612162        /* For non-SIP scheme, route set should be configured */ 
    21622163        if (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri)) 
    2163             return PJSIP_EINVALIDREQURI; 
     2164            return PJSIP_ENOROUTESET; 
    21642165 
    21652166        sip_uri = (pjsip_sip_uri*)pjsip_uri_get_uri(uri); 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r3313 r3323  
    24052405} 
    24062406 
    2407  
    2408 /* 
    2409  * Verify that valid SIP url is given. 
    2410  */ 
    2411 PJ_DEF(pj_status_t) pjsua_verify_sip_url(const char *c_url) 
     2407/* 
     2408 * Verify that valid url is given. 
     2409 */ 
     2410PJ_DEF(pj_status_t) pjsua_verify_url(const char *c_url) 
    24122411{ 
    24132412    pjsip_uri *p; 
     
    24162415    int len = (c_url ? pj_ansi_strlen(c_url) : 0); 
    24172416 
    2418     if (!len) return -1; 
     2417    if (!len) return PJSIP_EINVALIDURI; 
    24192418 
    24202419    pool = pj_pool_create(&pjsua_var.cp.factory, "check%p", 1024, 0, NULL); 
    2421     if (!pool) return -1; 
     2420    if (!pool) return PJ_ENOMEM; 
     2421 
     2422    url = (char*) pj_pool_alloc(pool, len+1); 
     2423    pj_ansi_strcpy(url, c_url); 
     2424 
     2425    p = pjsip_parse_uri(pool, url, len, 0); 
     2426 
     2427    pj_pool_release(pool); 
     2428    return p ? 0 : PJSIP_EINVALIDURI; 
     2429} 
     2430 
     2431/* 
     2432 * Verify that valid SIP url is given. 
     2433 */ 
     2434PJ_DEF(pj_status_t) pjsua_verify_sip_url(const char *c_url) 
     2435{ 
     2436    pjsip_uri *p; 
     2437    pj_pool_t *pool; 
     2438    char *url; 
     2439    int len = (c_url ? pj_ansi_strlen(c_url) : 0); 
     2440 
     2441    if (!len) return PJSIP_EINVALIDURI; 
     2442 
     2443    pool = pj_pool_create(&pjsua_var.cp.factory, "check%p", 1024, 0, NULL); 
     2444    if (!pool) return PJ_ENOMEM; 
    24222445 
    24232446    url = (char*) pj_pool_alloc(pool, len+1); 
     
    24322455 
    24332456    pj_pool_release(pool); 
    2434     return p ? 0 : -1; 
     2457    return p ? 0 : PJSIP_EINVALIDURI; 
    24352458} 
    24362459 
Note: See TracChangeset for help on using the changeset viewer.