Changeset 268
- Timestamp:
- Mar 2, 2006 9:18:58 PM (19 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 3 added
- 11 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/build/pjsip_simple.dsp
r261 r268 98 98 # Begin Source File 99 99 100 SOURCE="..\src\pjsip-simple\iscomposing.c" 101 # End Source File 102 # Begin Source File 103 100 104 SOURCE="..\src\pjsip-simple\pidf.c" 101 105 # End Source File … … 126 130 # Begin Source File 127 131 132 SOURCE="..\include\pjsip-simple\iscomposing.h" 133 # End Source File 134 # Begin Source File 135 128 136 SOURCE="..\include\pjsip-simple\pidf.h" 129 137 # End Source File -
pjproject/trunk/pjsip/build/pjsua_lib.dsp
r238 r268 66 66 # PROP Target_Dir "" 67 67 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjmedia/include" /I "../../pjlib-util/include" /I "../../pjlib/include" /D "_DEBUG" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "WIN32" /D "_MBCS" /D "_LIB" /F D /GZ /c68 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjmedia/include" /I "../../pjlib-util/include" /I "../../pjlib/include" /D "_DEBUG" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "WIN32" /D "_MBCS" /D "_LIB" /FR /FD /GZ /c 69 69 # SUBTRACT CPP /YX 70 70 # ADD BASE RSC /l 0x409 /d "_DEBUG" … … 100 100 # Begin Source File 101 101 102 SOURCE="..\src\pjsua-lib\pjsua_ opt.c"102 SOURCE="..\src\pjsua-lib\pjsua_im.c" 103 103 # End Source File 104 104 # Begin Source File … … 109 109 110 110 SOURCE="..\src\pjsua-lib\pjsua_reg.c" 111 # End Source File 112 # Begin Source File 113 114 SOURCE="..\src\pjsua-lib\pjsua_settings.c" 111 115 # End Source File 112 116 # End Group -
pjproject/trunk/pjsip/include/pjsip-simple/errno.h
r212 r268 29 29 30 30 31 /************************************************************ 32 * EVENT PACKAGE ERRORS 33 ***********************************************************/ 31 34 /** 32 35 * @hideinitializer … … 41 44 42 45 46 /************************************************************ 47 * PRESENCE ERROR 48 ***********************************************************/ 43 49 /** 44 50 * @hideinitializer … … 73 79 74 80 81 /************************************************************ 82 * ISCOMPOSING ERRORS 83 ***********************************************************/ 84 /** 85 * @hideinitializer 86 * Bad isComposing XML message. 87 */ 88 #define PJSIP_SIMPLE_EBADISCOMPOSE (PJSIP_SIMPLE_ERRNO_START+40) /*270040*/ 89 75 90 76 91 #endif /* __PJSIP_SIMPLE_ERRNO_H__ */ -
pjproject/trunk/pjsip/include/pjsip_simple.h
r197 r268 35 35 36 36 #include <pjsip-simple/evsub.h> 37 #include <pjsip-simple/iscomposing.h> 37 38 #include <pjsip-simple/presence.h> 38 39 #include <pjsip-simple/pidf.h> -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r255 r268 355 355 356 356 /** 357 * Send instant messaging inside INVITE session. 358 */ 359 void pjsua_call_send_im(int call_index, const char *text); 360 361 362 /** 363 * Send IM typing indication inside INVITE session. 364 */ 365 void pjsua_call_typing(int call_index, pj_bool_t is_typing); 366 367 /** 357 368 * Terminate all calls. 358 369 */ … … 406 417 407 418 /***************************************************************************** 419 * PJSUA Instant Messaging (pjsua_im.c) 420 */ 421 422 /** 423 * The MESSAGE method (defined in pjsua_im.c) 424 */ 425 extern const pjsip_method pjsip_message_method; 426 427 428 /** 429 * Init IM module handler to handle incoming MESSAGE outside dialog. 430 */ 431 pj_status_t pjsua_im_init(); 432 433 434 /** 435 * Create Accept header for MESSAGE. 436 */ 437 pjsip_accept_hdr* pjsua_im_create_accept(pj_pool_t *pool); 438 439 /** 440 * Send IM outside dialog. 441 */ 442 pj_status_t pjsua_im_send(int acc_index, const char *dst_uri, 443 const char *text); 444 445 446 /** 447 * Send typing indication outside dialog. 448 */ 449 pj_status_t pjsua_im_typing(int acc_index, const char *dst_uri, 450 pj_bool_t is_typing); 451 452 453 /** 454 * Private: check if we can accept the message. 455 * If not, then p_accept header will be filled with a valid 456 * Accept header. 457 */ 458 pj_bool_t pjsua_im_accept_pager(pjsip_rx_data *rdata, 459 const pjsip_accept_hdr **p_accept_hdr); 460 461 /** 462 * Private: process pager message. 463 * This may trigger pjsua_ui_on_pager() or pjsua_ui_on_typing(). 464 */ 465 void pjsua_im_process_pager(int call_id, const pj_str_t *from, 466 const pj_str_t *to, pjsip_rx_data *rdata); 467 468 469 /***************************************************************************** 408 470 * User Interface API. 409 471 * … … 415 477 * Notify UI when invite state has changed. 416 478 */ 417 void pjsua_ui_ inv_on_state_changed(int call_index, pjsip_event *e);479 void pjsua_ui_on_call_state(int call_index, pjsip_event *e); 418 480 419 481 /** 420 482 * Notify UI when registration status has changed. 421 483 */ 422 void pjsua_ui_regc_on_state_changed(int acc_index); 484 void pjsua_ui_on_reg_state(int acc_index); 485 486 /** 487 * Notify UI on incoming pager (i.e. MESSAGE request). 488 * Argument call_index will be -1 if MESSAGE request is not related to an 489 * existing call. 490 */ 491 void pjsua_ui_on_pager(int call_index, const pj_str_t *from, 492 const pj_str_t *to, const pj_str_t *txt); 493 494 495 /** 496 * Notify UI about typing indication. 497 */ 498 void pjsua_ui_on_typing(int call_index, const pj_str_t *from, 499 const pj_str_t *to, pj_bool_t is_typing); 423 500 424 501 -
pjproject/trunk/pjsip/src/pjsip-simple/errno.c
r212 r268 30 30 } err_str[] = 31 31 { 32 /* Event errors */ 32 33 { PJSIP_SIMPLE_ENOPKG, "No SIP event package with the specified name" }, 33 34 { PJSIP_SIMPLE_EPKGEXISTS, "SIP event package already exist" }, 34 35 36 /* Presence errors */ 35 37 { PJSIP_SIMPLE_ENOTSUBSCRIBE, "Expecting SUBSCRIBE request" }, 36 38 { PJSIP_SIMPLE_ENOPRESENCE, "No presence associated with the subscription" }, … … 39 41 { PJSIP_SIMPLE_EBADPIDF, "Bad PIDF content for presence" }, 40 42 { PJSIP_SIMPLE_EBADXPIDF, "Bad XPIDF content for presence" }, 43 44 /* isComposing errors. */ 45 { PJSIP_SIMPLE_EBADISCOMPOSE, "Bad isComposing indication/XML message" }, 41 46 }; 42 47 -
pjproject/trunk/pjsip/src/pjsip-simple/evsub.c
r230 r268 957 957 pjsip_hdr_shallow_clone(tdata->pool, sub->expires)); 958 958 959 /* Add additional header, if any. */ 960 if (hdr_list) { 961 const pjsip_hdr *hdr = hdr_list->next; 962 while (hdr != hdr_list) { 963 pjsip_msg_add_hdr( tdata->msg, 964 pjsip_hdr_clone(tdata->pool, hdr)); 965 hdr = hdr->next; 966 } 967 } 959 968 960 969 /* Send the response: */ … … 1325 1334 /* Add msg body, if any */ 1326 1335 if (body) { 1327 tdata->msg->body = pj_pool_zalloc(tdata->pool, 1328 sizeof(pjsip_msg_body)); 1329 status = pjsip_msg_body_clone(tdata->pool, 1330 tdata->msg->body, 1331 body); 1332 if (status != PJ_SUCCESS) { 1333 tdata->msg->body = NULL; 1336 tdata->msg->body = pjsip_msg_body_clone(tdata->pool, body); 1337 if (tdata->msg->body == NULL) { 1338 1339 PJ_LOG(4,(THIS_FILE, "Error: unable to clone msg body")); 1340 1334 1341 /* Ignore */ 1335 1342 return PJ_SUCCESS; -
pjproject/trunk/pjsip/src/pjsip-simple/presence.c
r230 r268 787 787 788 788 /* 789 * Process the content of incoming NOTIFY request and update temporary 790 * status. 791 * 792 * return PJ_SUCCESS if incoming request is acceptable. If return value 793 * is not PJ_SUCCESS, res_hdr may be added with Warning header. 794 */ 795 static pj_status_t pres_process_rx_notify( pjsip_pres *pres, 796 pjsip_rx_data *rdata, 797 int *p_st_code, 798 pj_str_t **p_st_text, 799 pjsip_hdr *res_hdr) 800 { 801 pjsip_ctype_hdr *ctype_hdr; 802 pj_status_t status; 803 804 *p_st_text = NULL; 805 806 /* Check Content-Type and msg body are present. */ 807 ctype_hdr = rdata->msg_info.ctype; 808 809 if (ctype_hdr==NULL || rdata->msg_info.msg->body==NULL) { 810 811 pjsip_warning_hdr *warn_hdr; 812 pj_str_t warn_text; 813 814 *p_st_code = PJSIP_SC_BAD_REQUEST; 815 816 warn_text = pj_str("Message body is not present"); 817 warn_hdr = pjsip_warning_hdr_create(rdata->tp_info.pool, 399, 818 pjsip_endpt_name(pres->dlg->endpt), 819 &warn_text); 820 pj_list_push_back(res_hdr, warn_hdr); 821 822 return PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_BAD_REQUEST); 823 } 824 825 /* Parse content. */ 826 827 if (pj_stricmp(&ctype_hdr->media.type, &STR_APPLICATION)==0 && 828 pj_stricmp(&ctype_hdr->media.subtype, &STR_PIDF_XML)==0) 829 { 830 status = pres_parse_pidf( pres, rdata, &pres->tmp_status); 831 } 832 else 833 if (pj_stricmp(&ctype_hdr->media.type, &STR_APPLICATION)==0 && 834 pj_stricmp(&ctype_hdr->media.subtype, &STR_XPIDF_XML)==0) 835 { 836 status = pres_parse_xpidf( pres, rdata, &pres->tmp_status); 837 } 838 else 839 { 840 status = PJSIP_SIMPLE_EBADCONTENT; 841 } 842 843 if (status != PJ_SUCCESS) { 844 /* Unsupported or bad Content-Type */ 845 pjsip_accept_hdr *accept_hdr; 846 pjsip_warning_hdr *warn_hdr; 847 848 *p_st_code = PJSIP_SC_NOT_ACCEPTABLE_HERE; 849 850 /* Add Accept header */ 851 accept_hdr = pjsip_accept_hdr_create(rdata->tp_info.pool); 852 accept_hdr->values[accept_hdr->count++] = STR_APP_PIDF_XML; 853 accept_hdr->values[accept_hdr->count++] = STR_APP_XPIDF_XML; 854 pj_list_push_back(res_hdr, accept_hdr); 855 856 /* Add Warning header */ 857 warn_hdr = pjsip_warning_hdr_create_from_status( 858 rdata->tp_info.pool, 859 pjsip_endpt_name(pres->dlg->endpt), 860 status); 861 pj_list_push_back(res_hdr, warn_hdr); 862 863 return status; 864 } 865 866 /* If application calls pres_get_status(), redirect the call to 867 * retrieve the temporary status. 868 */ 869 pres->tmp_status._is_valid = PJ_TRUE; 870 871 return PJ_SUCCESS; 872 } 873 874 875 /* 789 876 * Called when NOTIFY is received. 790 877 */ … … 796 883 pjsip_msg_body **p_body) 797 884 { 798 pjsip_ctype_hdr *ctype_hdr;799 885 pjsip_pres *pres; 800 886 pj_status_t status; … … 803 889 PJ_ASSERT_ON_FAIL(pres!=NULL, {return;}); 804 890 805 /* Check Content-Type and msg body are present. */ 806 ctype_hdr = rdata->msg_info.ctype; 807 808 if (ctype_hdr==NULL || rdata->msg_info.msg->body==NULL) { 809 810 pjsip_warning_hdr *warn_hdr; 811 pj_str_t warn_text; 812 813 *p_st_code = PJSIP_SC_BAD_REQUEST; 814 815 warn_text = pj_str("Message body is not present"); 816 warn_hdr = pjsip_warning_hdr_create(rdata->tp_info.pool, 399, 817 pjsip_endpt_name(pres->dlg->endpt), 818 &warn_text); 819 pj_list_push_back(res_hdr, warn_hdr); 820 821 return; 822 } 823 824 /* Parse content. */ 825 826 if (pj_stricmp(&ctype_hdr->media.type, &STR_APPLICATION)==0 && 827 pj_stricmp(&ctype_hdr->media.subtype, &STR_PIDF_XML)==0) 828 { 829 status = pres_parse_pidf( pres, rdata, &pres->tmp_status); 830 } 831 else 832 if (pj_stricmp(&ctype_hdr->media.type, &STR_APPLICATION)==0 && 833 pj_stricmp(&ctype_hdr->media.subtype, &STR_XPIDF_XML)==0) 834 { 835 status = pres_parse_xpidf( pres, rdata, &pres->tmp_status); 836 } 837 else 838 { 839 status = PJSIP_SIMPLE_EBADCONTENT; 840 } 841 842 if (status != PJ_SUCCESS) { 843 /* Unsupported or bad Content-Type */ 844 pjsip_accept_hdr *accept_hdr; 845 pjsip_warning_hdr *warn_hdr; 846 847 *p_st_code = PJSIP_SC_NOT_ACCEPTABLE_HERE; 848 849 /* Add Accept header */ 850 accept_hdr = pjsip_accept_hdr_create(rdata->tp_info.pool); 851 accept_hdr->values[accept_hdr->count++] = STR_APP_PIDF_XML; 852 accept_hdr->values[accept_hdr->count++] = STR_APP_XPIDF_XML; 853 pj_list_push_back(res_hdr, accept_hdr); 854 855 /* Add Warning header */ 856 warn_hdr = pjsip_warning_hdr_create_from_status( 857 rdata->tp_info.pool, 858 pjsip_endpt_name(pres->dlg->endpt), 859 status); 860 pj_list_push_back(res_hdr, warn_hdr); 861 862 return; 863 } 864 865 /* If application calls pres_get_status(), redirect the call to 866 * retrieve the temporary status. 891 /* Only process the message body if it exists, otherwise treat as 892 * presence status is closed. 867 893 */ 868 pres->tmp_status._is_valid = PJ_TRUE; 894 if (rdata->msg_info.msg->body) { 895 status = pres_process_rx_notify( pres, rdata, p_st_code, p_st_text, 896 res_hdr ); 897 if (status != PJ_SUCCESS) 898 return; 899 900 } else { 901 unsigned i; 902 903 /* Subscription is terminated. Consider contact is offline */ 904 pres->tmp_status._is_valid = PJ_TRUE; 905 for (i=0; i<pres->tmp_status.info_cnt; ++i) 906 pres->tmp_status.info[i].basic_open = PJ_FALSE; 907 } 869 908 870 909 /* Notify application. */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r255 r268 22 22 23 23 /* 24 * pjsua_ inv.c24 * pjsua_call.c 25 25 * 26 * Invite session specific functionalities.26 * Call (INVITE) related stuffs. 27 27 */ 28 28 … … 260 260 if (status != PJ_SUCCESS) { 261 261 262 pjsip_dlg_respond(dlg, rdata, 500, NULL );262 pjsip_dlg_respond(dlg, rdata, 500, NULL, NULL, NULL); 263 263 264 264 // TODO: Need to delete dialog … … 286 286 pjsua_perror(THIS_FILE, "Unable to create 100 response", status); 287 287 288 pjsip_dlg_respond(dlg, rdata, 500, NULL );288 pjsip_dlg_respond(dlg, rdata, 500, NULL, NULL, NULL); 289 289 290 290 // TODO: Need to delete dialog … … 386 386 387 387 388 pjsua_ui_ inv_on_state_changed(call->index, e);388 pjsua_ui_on_call_state(call->index, e); 389 389 390 390 /* call->inv may be NULL now */ … … 464 464 */ 465 465 PJ_LOG(4,(THIS_FILE, "Received REFER without Refer-To header!")); 466 pjsip_dlg_respond( inv->dlg, rdata, 400, NULL );466 pjsip_dlg_respond( inv->dlg, rdata, 400, NULL, NULL, NULL); 467 467 return; 468 468 } … … 482 482 if (status != PJ_SUCCESS) { 483 483 pjsua_perror(THIS_FILE, "Unable to create xfer uas", status); 484 pjsip_dlg_respond( inv->dlg, rdata, 500, NULL );484 pjsip_dlg_respond( inv->dlg, rdata, 500, NULL, NULL, NULL); 485 485 return; 486 486 } … … 546 546 /* 547 547 * This callback is called when transaction state has changed in INVITE 548 * session. We use this to trap incoming REFER request. 548 * session. We use this to trap: 549 * - incoming REFER request. 550 * - incoming MESSAGE request. 549 551 */ 550 552 static void pjsua_call_on_tsx_state_changed(pjsip_inv_session *inv, … … 562 564 */ 563 565 on_call_transfered(call->inv, e->body.tsx_state.src.rdata); 564 } 566 567 } 568 else if (tsx->role==PJSIP_ROLE_UAS && 569 tsx->state==PJSIP_TSX_STATE_TRYING && 570 pjsip_method_cmp(&tsx->method, &pjsip_message_method)==0) 571 { 572 /* 573 * Incoming MESSAGE request! 574 */ 575 pjsip_rx_data *rdata; 576 pjsip_msg *msg; 577 pjsip_accept_hdr *accept_hdr; 578 pj_status_t status; 579 580 rdata = e->body.tsx_state.src.rdata; 581 msg = rdata->msg_info.msg; 582 583 /* Request MUST have message body, with Content-Type equal to 584 * "text/plain". 585 */ 586 if (pjsua_im_accept_pager(rdata, &accept_hdr) == PJ_FALSE) { 587 588 pjsip_hdr hdr_list; 589 590 pj_list_init(&hdr_list); 591 pj_list_push_back(&hdr_list, accept_hdr); 592 593 pjsip_dlg_respond( inv->dlg, rdata, PJSIP_SC_NOT_ACCEPTABLE_HERE, 594 NULL, &hdr_list, NULL ); 595 return; 596 } 597 598 /* Respond with 200 first, so that remote doesn't retransmit in case 599 * the UI takes too long to process the message. 600 */ 601 status = pjsip_dlg_respond( inv->dlg, rdata, 200, NULL, NULL, NULL); 602 603 /* Process MESSAGE request */ 604 pjsua_im_process_pager(call->index, &inv->dlg->remote.info_str, 605 &inv->dlg->local.info_str, rdata); 606 } 607 565 608 } 566 609 … … 1046 1089 1047 1090 1091 /** 1092 * Send instant messaging inside INVITE session. 1093 */ 1094 void pjsua_call_send_im(int call_index, const char *str) 1095 { 1096 pjsua_call *call; 1097 const pj_str_t mime_text = pj_str("text"); 1098 const pj_str_t mime_plain = pj_str("plain"); 1099 pj_str_t text; 1100 pjsip_tx_data *tdata; 1101 pj_status_t status; 1102 1103 call = &pjsua.calls[call_index]; 1104 1105 if (!call->inv) { 1106 PJ_LOG(3,(THIS_FILE,"Call has been disconnected")); 1107 return; 1108 } 1109 1110 /* Lock dialog. */ 1111 pjsip_dlg_inc_lock(call->inv->dlg); 1112 1113 /* Create request message. */ 1114 status = pjsip_dlg_create_request( call->inv->dlg, &pjsip_message_method, 1115 -1, &tdata); 1116 if (status != PJ_SUCCESS) { 1117 pjsua_perror(THIS_FILE, "Unable to create MESSAGE request", status); 1118 goto on_return; 1119 } 1120 1121 /* Add accept header. */ 1122 pjsip_msg_add_hdr( tdata->msg, 1123 (pjsip_hdr*)pjsua_im_create_accept(tdata->pool)); 1124 1125 /* Create "text/plain" message body. */ 1126 tdata->msg->body = pjsip_msg_body_create( tdata->pool, &mime_text, 1127 &mime_plain, 1128 pj_cstr(&text, str)); 1129 if (tdata->msg->body == NULL) { 1130 pjsua_perror(THIS_FILE, "Unable to create msg body", PJ_ENOMEM); 1131 pjsip_tx_data_dec_ref(tdata); 1132 goto on_return; 1133 } 1134 1135 /* Send the request. */ 1136 status = pjsip_dlg_send_request( call->inv->dlg, tdata, NULL); 1137 if (status != PJ_SUCCESS) { 1138 pjsua_perror(THIS_FILE, "Unable to send MESSAGE request", status); 1139 goto on_return; 1140 } 1141 1142 on_return: 1143 pjsip_dlg_dec_lock(call->inv->dlg); 1144 } 1145 1146 1147 /** 1148 * Send IM typing indication inside INVITE session. 1149 */ 1150 void pjsua_call_typing(int call_index, pj_bool_t is_typing) 1151 { 1152 pjsua_call *call; 1153 pjsip_tx_data *tdata; 1154 pj_status_t status; 1155 1156 call = &pjsua.calls[call_index]; 1157 1158 if (!call->inv) { 1159 PJ_LOG(3,(THIS_FILE,"Call has been disconnected")); 1160 return; 1161 } 1162 1163 /* Lock dialog. */ 1164 pjsip_dlg_inc_lock(call->inv->dlg); 1165 1166 /* Create request message. */ 1167 status = pjsip_dlg_create_request( call->inv->dlg, &pjsip_message_method, 1168 -1, &tdata); 1169 if (status != PJ_SUCCESS) { 1170 pjsua_perror(THIS_FILE, "Unable to create MESSAGE request", status); 1171 goto on_return; 1172 } 1173 1174 /* Create "application/im-iscomposing+xml" msg body. */ 1175 tdata->msg->body = pjsip_iscomposing_create_body(tdata->pool, is_typing, 1176 NULL, NULL, -1); 1177 1178 /* Send the request. */ 1179 status = pjsip_dlg_send_request( call->inv->dlg, tdata, NULL); 1180 if (status != PJ_SUCCESS) { 1181 pjsua_perror(THIS_FILE, "Unable to send MESSAGE request", status); 1182 goto on_return; 1183 } 1184 1185 on_return: 1186 pjsip_dlg_dec_lock(call->inv->dlg);} 1187 1188 1048 1189 /* 1049 1190 * Terminate all calls. -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r255 r268 510 510 pjsua_pres_init(); 511 511 512 /* Init out-of-dialog MESSAGE request handler. */ 513 514 pjsua_im_init(); 515 512 516 513 517 /* Init media endpoint: */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_reg.c
r253 r268 78 78 acc->reg_last_code = param->code; 79 79 80 pjsua_ui_ regc_on_state_changed(acc->index);80 pjsua_ui_on_reg_state(acc->index); 81 81 } 82 82 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c
r255 r268 19 19 #include <pjsua-lib/pjsua.h> 20 20 #include <pjsua-lib/getopt.h> 21 22 /* 23 * pjsua_settings.c 24 * 25 * Anything to do with configuration and state dump. 26 */ 21 27 22 28 #define THIS_FILE "pjsua_opt.c"
Note: See TracChangeset
for help on using the changeset viewer.