Changeset 2855 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_im.c
- Timestamp:
- Aug 5, 2009 6:41:23 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_im.c
r2651 r2855 510 510 pjsip_media_type media_type; 511 511 pjsua_im_data *im_data; 512 pjsua_acc *acc; 512 513 pj_str_t contact; 513 514 pj_status_t status; … … 515 516 /* To and message body must be specified. */ 516 517 PJ_ASSERT_RETURN(to && content, PJ_EINVAL); 518 519 acc = &pjsua_var.acc[acc_id]; 517 520 518 521 /* Create request. */ 519 522 status = pjsip_endpt_create_request(pjsua_var.endpt, 520 523 &pjsip_message_method, to, 521 & pjsua_var.acc[acc_id].cfg.id,524 &acc->cfg.id, 522 525 to, NULL, NULL, -1, NULL, &tdata); 523 526 if (status != PJ_SUCCESS) { … … 529 532 * the request. 530 533 */ 531 if ( pjsua_var.acc[acc_id].cfg.transport_id != PJSUA_INVALID_ID) {534 if (acc->cfg.transport_id != PJSUA_INVALID_ID) { 532 535 pjsip_tpselector tp_sel; 533 536 534 pjsua_init_tpselector( pjsua_var.acc[acc_id].cfg.transport_id, &tp_sel);537 pjsua_init_tpselector(acc->cfg.transport_id, &tp_sel); 535 538 pjsip_tx_data_set_transport(tdata, &tp_sel); 536 539 } … … 540 543 (pjsip_hdr*)pjsua_im_create_accept(tdata->pool)); 541 544 542 /* Add contact. */ 543 status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to); 544 if (status != PJ_SUCCESS) { 545 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 546 pjsip_tx_data_dec_ref(tdata); 547 return status; 545 /* Create suitable Contact header unless a Contact header has been 546 * set in the account. 547 */ 548 if (acc->contact.slen) { 549 contact = acc->contact; 550 } else { 551 status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to); 552 if (status != PJ_SUCCESS) { 553 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 554 pjsip_tx_data_dec_ref(tdata); 555 return status; 556 } 548 557 } 549 558 … … 585 594 586 595 /* Add route set */ 587 pjsua_set_msg_route_set(tdata, & pjsua_var.acc[acc_id].route_set);596 pjsua_set_msg_route_set(tdata, &acc->route_set); 588 597 589 598 /* Send request (statefully) */ … … 610 619 pjsua_im_data *im_data; 611 620 pjsip_tx_data *tdata; 621 pjsua_acc *acc; 612 622 pj_str_t contact; 613 623 pj_status_t status; 614 624 625 acc = &pjsua_var.acc[acc_id]; 626 615 627 /* Create request. */ 616 628 status = pjsip_endpt_create_request( pjsua_var.endpt, &pjsip_message_method, 617 to, & pjsua_var.acc[acc_id].cfg.id,629 to, &acc->cfg.id, 618 630 to, NULL, NULL, -1, NULL, &tdata); 619 631 if (status != PJ_SUCCESS) { … … 626 638 * the request. 627 639 */ 628 if ( pjsua_var.acc[acc_id].cfg.transport_id != PJSUA_INVALID_ID) {640 if (acc->cfg.transport_id != PJSUA_INVALID_ID) { 629 641 pjsip_tpselector tp_sel; 630 642 631 pjsua_init_tpselector( pjsua_var.acc[acc_id].cfg.transport_id, &tp_sel);643 pjsua_init_tpselector(acc->cfg.transport_id, &tp_sel); 632 644 pjsip_tx_data_set_transport(tdata, &tp_sel); 633 645 } … … 638 650 639 651 640 /* Add contact. */ 641 status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to); 642 if (status != PJ_SUCCESS) { 643 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 644 pjsip_tx_data_dec_ref(tdata); 645 return status; 652 /* Create suitable Contact header unless a Contact header has been 653 * set in the account. 654 */ 655 if (acc->contact.slen) { 656 contact = acc->contact; 657 } else { 658 status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to); 659 if (status != PJ_SUCCESS) { 660 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 661 pjsip_tx_data_dec_ref(tdata); 662 return status; 663 } 646 664 } 647 665 … … 659 677 660 678 /* Add route set */ 661 pjsua_set_msg_route_set(tdata, & pjsua_var.acc[acc_id].route_set);679 pjsua_set_msg_route_set(tdata, &acc->route_set); 662 680 663 681 /* Create data to reauthenticate */
Note: See TracChangeset
for help on using the changeset viewer.