Ignore:
Timestamp:
Jul 18, 2006 2:39:40 PM (18 years ago)
Author:
bennylp
Message:

Small improvements: (1) pjsua now responds to incoming OPTIONS request, which means that some modules (evsub, invite) need to register their capabilities to the endpoint, (2) added command in pjsua to send arbitrary request

File:
1 edited

Legend:

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

    r597 r612  
    138138static void default_config(struct app_config *cfg) 
    139139{ 
     140    char tmp[80]; 
     141 
    140142    pjsua_config_default(&cfg->cfg); 
     143    pj_ansi_sprintf(tmp, "PJSUA v%s/%s", PJ_VERSION, PJ_OS_NAME); 
     144    pj_strdup2_with_null(app_config.pool, &cfg->cfg.user_agent, tmp); 
     145 
    141146    pjsua_logging_config_default(&cfg->log_cfg); 
    142147    pjsua_media_config_default(&cfg->media_cfg); 
     
    473478        case OPT_NEXT_ACCOUNT: /* Add more account. */ 
    474479            cfg->acc_cnt++; 
    475             cur_acc = &cfg->acc_cfg[cfg->acc_cnt - 1]; 
     480            cur_acc = &cfg->acc_cfg[cfg->acc_cnt]; 
    476481            break; 
    477482 
     
    665670    } 
    666671 
    667     if (cfg->acc_cfg[0].id.slen && cfg->acc_cnt==0) 
    668         cfg->acc_cnt = 1; 
     672    if (cfg->acc_cfg[cfg->acc_cnt].id.slen) 
     673        cfg->acc_cnt++; 
    669674 
    670675    for (i=0; i<cfg->acc_cnt; ++i) { 
     
    13071312    puts("|                              | cc  Connect port         | dd  Dump detailed |"); 
    13081313    puts("|                              | cd  Disconnect port      | dc  Dump config   |"); 
    1309     puts("|                              |                          |  f  Save config   |"); 
     1314    puts("|  S  Send arbitrary REQUEST   |                          |  f  Save config   |"); 
    13101315    puts("+------------------------------+--------------------------+-------------------+"); 
    13111316    puts("|  q  QUIT                                                                    |"); 
     
    14601465    } 
    14611466    puts(""); 
     1467} 
     1468 
     1469 
     1470/* 
     1471 * Send arbitrary request to remote host 
     1472 */ 
     1473static void send_request(char *cstr_method, const pj_str_t *dst_uri) 
     1474{ 
     1475    pj_str_t str_method; 
     1476    pjsip_method method; 
     1477    pjsip_tx_data *tdata; 
     1478    pjsua_acc_info acc_info; 
     1479    pjsip_endpoint *endpt; 
     1480    pj_status_t status; 
     1481 
     1482    endpt = pjsua_get_pjsip_endpt(); 
     1483 
     1484    str_method = pj_str(cstr_method); 
     1485    pjsip_method_init_np(&method, &str_method); 
     1486 
     1487    pjsua_acc_get_info(current_acc, &acc_info); 
     1488 
     1489    status = pjsip_endpt_create_request(endpt, &method, dst_uri,  
     1490                                        &acc_info.acc_uri, dst_uri, 
     1491                                        NULL, NULL, -1, NULL, &tdata); 
     1492    if (status != PJ_SUCCESS) { 
     1493        pjsua_perror(THIS_FILE, "Unable to create request", status); 
     1494        return; 
     1495    } 
     1496 
     1497    status = pjsip_endpt_send_request(endpt, tdata, -1, NULL, NULL); 
     1498    if (status != PJ_SUCCESS) { 
     1499        pjsua_perror(THIS_FILE, "Unable to send request", status); 
     1500        pjsip_tx_data_dec_ref(tdata); 
     1501        return; 
     1502    } 
    14621503} 
    14631504 
     
    18921933                } 
    18931934            } 
     1935            break; 
     1936 
     1937        case 'S': 
     1938            /* 
     1939             * Send arbitrary request 
     1940             */ 
     1941            if (pjsua_acc_get_count() == 0) { 
     1942                puts("Sorry, need at least one account configured"); 
     1943                break; 
     1944            } 
     1945 
     1946            puts("Send arbitrary request to remote host"); 
     1947 
     1948            /* Input METHOD */ 
     1949            if (!simple_input("Request method:",text,sizeof(text))) 
     1950                break; 
     1951 
     1952            /* Input destination URI */ 
     1953            uri = NULL; 
     1954            ui_input_url("Destination URI", buf, sizeof(buf), &result); 
     1955            if (result.nb_result != NO_NB) { 
     1956 
     1957                if (result.nb_result == -1 || result.nb_result == 0) { 
     1958                    puts("Sorry you can't do that!"); 
     1959                    continue; 
     1960                } else { 
     1961                    pjsua_buddy_info binfo; 
     1962                    pjsua_buddy_get_info(result.nb_result-1, &binfo); 
     1963                    uri = binfo.uri.ptr; 
     1964                } 
     1965 
     1966            } else if (result.uri_result) { 
     1967                uri = result.uri_result; 
     1968            } 
     1969             
     1970            tmp = pj_str(uri); 
     1971 
     1972            send_request(text, &tmp); 
    18941973            break; 
    18951974 
Note: See TracChangeset for help on using the changeset viewer.