Changeset 612 for pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
- Timestamp:
- Jul 18, 2006 2:39:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r597 r612 138 138 static void default_config(struct app_config *cfg) 139 139 { 140 char tmp[80]; 141 140 142 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 141 146 pjsua_logging_config_default(&cfg->log_cfg); 142 147 pjsua_media_config_default(&cfg->media_cfg); … … 473 478 case OPT_NEXT_ACCOUNT: /* Add more account. */ 474 479 cfg->acc_cnt++; 475 cur_acc = &cfg->acc_cfg[cfg->acc_cnt - 1];480 cur_acc = &cfg->acc_cfg[cfg->acc_cnt]; 476 481 break; 477 482 … … 665 670 } 666 671 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++; 669 674 670 675 for (i=0; i<cfg->acc_cnt; ++i) { … … 1307 1312 puts("| | cc Connect port | dd Dump detailed |"); 1308 1313 puts("| | cd Disconnect port | dc Dump config |"); 1309 puts("| 1314 puts("| S Send arbitrary REQUEST | | f Save config |"); 1310 1315 puts("+------------------------------+--------------------------+-------------------+"); 1311 1316 puts("| q QUIT |"); … … 1460 1465 } 1461 1466 puts(""); 1467 } 1468 1469 1470 /* 1471 * Send arbitrary request to remote host 1472 */ 1473 static 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 } 1462 1503 } 1463 1504 … … 1892 1933 } 1893 1934 } 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); 1894 1973 break; 1895 1974
Note: See TracChangeset
for help on using the changeset viewer.