diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-12-07 10:09:16 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-12-07 10:09:16 +0000 |
commit | f927b60a690d75b760017f82da0a58b28b95dad0 (patch) | |
tree | 4a93a9b624be95b1b5737f24d14558399e087644 /pjsip/src/pjsua-lib/pjsua_call.c | |
parent | f5de45f6ad1a4a15dd19a56e8b903e46ba91e5da (diff) |
Fixed ticket #38: misleading error message when destination URI is not valid when making outgoing call
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@847 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib/pjsua_call.c')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_call.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 679bc6fd..46abb1f7 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -218,6 +218,9 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id, /* Options must be zero for now */ PJ_ASSERT_RETURN(options == 0, PJ_EINVAL); + /* Check arguments */ + PJ_ASSERT_RETURN(dest_uri, PJ_EINVAL); + PJSUA_LOCK(); acc = &pjsua_var.acc[acc_id]; @@ -242,6 +245,35 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id, call = &pjsua_var.calls[call_id]; + /* Verify that destination URI is valid before calling + * pjsua_acc_create_uac_contact, or otherwise there + * a misleading "Invalid Contact URI" error will be printed + * when pjsua_acc_create_uac_contact() fails. + */ + if (1) { + pj_pool_t *pool; + pjsip_uri *uri; + pj_str_t dup; + + pool = pjsua_pool_create("tmp-uri", 4000, 4000); + if (!pool) { + pjsua_perror(THIS_FILE, "Unable to create pool", PJ_ENOMEM); + PJSUA_UNLOCK(); + return PJ_ENOMEM; + } + + pj_strdup_with_null(pool, &dup, dest_uri); + uri = pjsip_parse_uri(pool, dup.ptr, dup.slen, 0); + pj_pool_release(pool); + + if (uri == NULL) { + pjsua_perror(THIS_FILE, "Unable to make call", + PJSIP_EINVALIDREQURI); + PJSUA_UNLOCK(); + return PJSIP_EINVALIDREQURI; + } + } + PJ_LOG(4,(THIS_FILE, "Making call with acc #%d to %.*s", acc_id, (int)dest_uri->slen, dest_uri->ptr)); |