Changeset 688 for pjproject/trunk
- Timestamp:
- Aug 20, 2006 9:12:19 AM (18 years ago)
- Location:
- pjproject/trunk/pjsip/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-simple/publishc.c
r685 r688 41 41 42 42 43 /* Let's define this enum, so that it'll trigger compilation error 44 * when somebody define the same enum in sip_msg.h 45 */ 46 enum 47 { 48 PJSIP_PUBLISH_METHOD = PJSIP_OTHER_METHOD, 49 }; 50 43 51 const pjsip_method pjsip_publish_method = 44 52 { 45 PJSIP_ OTHER_METHOD,53 PJSIP_PUBLISH_METHOD, 46 54 { "PUBLISH", 7 } 47 55 }; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r660 r688 95 95 pjsip_inv_callback inv_cb; 96 96 unsigned i; 97 const pj_str_t str_norefersub = { "norefersub", 10 }; 97 98 pj_status_t status; 98 99 … … 116 117 status = pjsip_inv_usage_init(pjsua_var.endpt, &inv_cb); 117 118 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 119 120 /* Add "norefersub" in Supported header */ 121 pjsip_endpt_add_capability(pjsua_var.endpt, NULL, PJSIP_H_SUPPORTED, 122 NULL, 1, &str_norefersub); 118 123 119 124 return status; … … 2125 2130 int new_call; 2126 2131 const pj_str_t str_refer_to = { "Refer-To", 8}; 2132 const pj_str_t str_refer_sub = { "Refer-Sub", 9 }; 2127 2133 pjsip_generic_string_hdr *refer_to; 2134 pjsip_generic_string_hdr *refer_sub; 2135 pj_bool_t no_refer_sub = PJ_FALSE; 2128 2136 char *uri; 2129 2137 pj_str_t tmp; 2130 struct pjsip_evsub_user xfer_cb;2131 2138 pjsip_status_code code; 2132 2139 pjsip_evsub *sub; … … 2147 2154 } 2148 2155 2156 /* Find optional Refer-Sub header */ 2157 refer_sub = (pjsip_generic_string_hdr*) 2158 pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_refer_sub, NULL); 2159 2160 if (refer_sub) { 2161 if (!pj_strnicmp2(&refer_sub->hvalue, "true", 4)==0) 2162 no_refer_sub = PJ_TRUE; 2163 } 2164 2165 2149 2166 /* Notify callback */ 2150 2167 code = PJSIP_SC_OK; … … 2167 2184 refer_to->hvalue.ptr)); 2168 2185 2169 /* Init callback */ 2170 pj_bzero(&xfer_cb, sizeof(xfer_cb)); 2171 xfer_cb.on_evsub_state = &xfer_on_evsub_state; 2172 2173 /* Create transferee event subscription */ 2174 status = pjsip_xfer_create_uas( inv->dlg, &xfer_cb, rdata, &sub); 2175 if (status != PJ_SUCCESS) { 2176 pjsua_perror(THIS_FILE, "Unable to create xfer uas", status); 2177 pjsip_dlg_respond( inv->dlg, rdata, 500, NULL, NULL, NULL); 2178 return; 2179 } 2180 2181 /* Accept the REFER request, send 200 (OK). */ 2182 pjsip_xfer_accept(sub, rdata, code, NULL); 2183 2184 /* Create initial NOTIFY request */ 2185 status = pjsip_xfer_notify( sub, PJSIP_EVSUB_STATE_ACTIVE, 2186 100, NULL, &tdata); 2187 if (status != PJ_SUCCESS) { 2188 pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER", status); 2189 return; 2190 } 2191 2192 /* Send initial NOTIFY request */ 2193 status = pjsip_xfer_send_request( sub, tdata); 2194 if (status != PJ_SUCCESS) { 2195 pjsua_perror(THIS_FILE, "Unable to send NOTIFY to REFER", status); 2196 return; 2186 if (no_refer_sub) { 2187 /* 2188 * Always answer with 200. 2189 */ 2190 pjsip_tx_data *tdata; 2191 const pj_str_t str_false = { "false", 5}; 2192 pjsip_hdr *hdr; 2193 2194 status = pjsip_dlg_create_response(inv->dlg, rdata, 200, NULL, &tdata); 2195 if (status != PJ_SUCCESS) { 2196 pjsua_perror(THIS_FILE, "Unable to create 200 response to REFER", 2197 status); 2198 return; 2199 } 2200 2201 /* Add Refer-Sub header */ 2202 hdr = (pjsip_hdr*) 2203 pjsip_generic_string_hdr_create(tdata->pool, &str_refer_sub, 2204 &str_false); 2205 pjsip_msg_add_hdr(tdata->msg, hdr); 2206 2207 2208 /* Send answer */ 2209 status = pjsip_dlg_send_response(inv->dlg, pjsip_rdata_get_tsx(rdata), 2210 tdata); 2211 if (status != PJ_SUCCESS) { 2212 pjsua_perror(THIS_FILE, "Unable to create 200 response to REFER", 2213 status); 2214 return; 2215 } 2216 2217 /* Don't have subscription */ 2218 sub = NULL; 2219 2220 } else { 2221 struct pjsip_evsub_user xfer_cb; 2222 pjsip_hdr hdr_list; 2223 2224 /* Init callback */ 2225 pj_bzero(&xfer_cb, sizeof(xfer_cb)); 2226 xfer_cb.on_evsub_state = &xfer_on_evsub_state; 2227 2228 /* Init additional header list to be sent with REFER response */ 2229 pj_list_init(&hdr_list); 2230 2231 /* Create transferee event subscription */ 2232 status = pjsip_xfer_create_uas( inv->dlg, &xfer_cb, rdata, &sub); 2233 if (status != PJ_SUCCESS) { 2234 pjsua_perror(THIS_FILE, "Unable to create xfer uas", status); 2235 pjsip_dlg_respond( inv->dlg, rdata, 500, NULL, NULL, NULL); 2236 return; 2237 } 2238 2239 /* If there's Refer-Sub header and the value is "true", send back 2240 * Refer-Sub in the response with value "true" too. 2241 */ 2242 if (refer_sub) { 2243 const pj_str_t str_true = { "true", 4 }; 2244 pjsip_hdr *hdr; 2245 2246 hdr = (pjsip_hdr*) 2247 pjsip_generic_string_hdr_create(inv->dlg->pool, 2248 &str_refer_sub, 2249 &str_true); 2250 pj_list_push_back(&hdr_list, hdr); 2251 2252 } 2253 2254 /* Accept the REFER request, send 200 (OK). */ 2255 pjsip_xfer_accept(sub, rdata, code, &hdr_list); 2256 2257 /* Create initial NOTIFY request */ 2258 status = pjsip_xfer_notify( sub, PJSIP_EVSUB_STATE_ACTIVE, 2259 100, NULL, &tdata); 2260 if (status != PJ_SUCCESS) { 2261 pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER", 2262 status); 2263 return; 2264 } 2265 2266 /* Send initial NOTIFY request */ 2267 status = pjsip_xfer_send_request( sub, tdata); 2268 if (status != PJ_SUCCESS) { 2269 pjsua_perror(THIS_FILE, "Unable to send NOTIFY to REFER", status); 2270 return; 2271 } 2197 2272 } 2198 2273 … … 2212 2287 if (status != PJ_SUCCESS) { 2213 2288 2214 /* Notify xferer about the error */ 2215 status = pjsip_xfer_notify(sub, PJSIP_EVSUB_STATE_TERMINATED, 2216 500, NULL, &tdata); 2217 if (status != PJ_SUCCESS) { 2218 pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER", 2219 status); 2220 return; 2221 } 2222 status = pjsip_xfer_send_request(sub, tdata); 2223 if (status != PJ_SUCCESS) { 2224 pjsua_perror(THIS_FILE, "Unable to send NOTIFY to REFER", 2225 status); 2226 return; 2289 /* Notify xferer about the error (if we have subscription) */ 2290 if (sub) { 2291 status = pjsip_xfer_notify(sub, PJSIP_EVSUB_STATE_TERMINATED, 2292 500, NULL, &tdata); 2293 if (status != PJ_SUCCESS) { 2294 pjsua_perror(THIS_FILE, "Unable to create NOTIFY to REFER", 2295 status); 2296 return; 2297 } 2298 status = pjsip_xfer_send_request(sub, tdata); 2299 if (status != PJ_SUCCESS) { 2300 pjsua_perror(THIS_FILE, "Unable to send NOTIFY to REFER", 2301 status); 2302 return; 2303 } 2227 2304 } 2228 2305 return; 2229 2306 } 2230 2307 2231 /* Put the server subscription in inv_data. 2232 * Subsequent state changed in pjsua_inv_on_state_changed() will be 2233 * reported back to the server subscription. 2234 */ 2235 pjsua_var.calls[new_call].xfer_sub = sub; 2236 2237 /* Put the invite_data in the subscription. */ 2238 pjsip_evsub_set_mod_data(sub, pjsua_var.mod.id, 2239 &pjsua_var.calls[new_call]); 2308 if (sub) { 2309 /* Put the server subscription in inv_data. 2310 * Subsequent state changed in pjsua_inv_on_state_changed() will be 2311 * reported back to the server subscription. 2312 */ 2313 pjsua_var.calls[new_call].xfer_sub = sub; 2314 2315 /* Put the invite_data in the subscription. */ 2316 pjsip_evsub_set_mod_data(sub, pjsua_var.mod.id, 2317 &pjsua_var.calls[new_call]); 2318 } 2240 2319 } 2241 2320 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r685 r688 335 335 } 336 336 337 /* Unregister OPTIONS handler if it's previously registered */338 if (pjsua_options_handler.id >= 0) {339 pjsip_endpt_unregister_module(pjsua_var.endpt, &pjsua_options_handler);340 pjsua_options_handler.id = -1;341 }342 343 337 /* Unregister msg logging if it's previously registered */ 344 338 if (pjsua_msg_logger.id >= 0) { … … 350 344 if (pjsua_var.log_cfg.msg_logging) 351 345 pjsip_endpt_register_module(pjsua_var.endpt, &pjsua_msg_logger); 352 353 /* Register OPTIONS handler */354 pjsip_endpt_register_module(pjsua_var.endpt, &pjsua_options_handler);355 346 356 347 return PJ_SUCCESS; … … 444 435 pjsua_config default_cfg; 445 436 pjsua_media_config default_media_cfg; 437 const pj_str_t STR_OPTIONS = { "OPTIONS", 7 }; 446 438 pj_status_t status; 447 439 … … 542 534 goto on_error; 543 535 536 /* Register OPTIONS handler */ 537 pjsip_endpt_register_module(pjsua_var.endpt, &pjsua_options_handler); 538 539 /* Add OPTIONS in Allow header */ 540 pjsip_endpt_add_capability(pjsua_var.endpt, NULL, PJSIP_H_ALLOW, 541 NULL, 1, &STR_OPTIONS); 542 544 543 /* Start worker thread if needed. */ 545 544 if (pjsua_var.ua_cfg.thread_cnt) { -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_im.c
r611 r688 568 568 { 569 569 const pj_str_t msg_tag = { "MESSAGE", 7 }; 570 const pj_str_t STR_MIME_TEXT_PLAIN = { "text/plain", 10 }; 571 const pj_str_t STR_MIME_APP_ISCOMPOSING = 572 { "application/im-iscomposing+xml", 30 }; 570 573 pj_status_t status; 571 574 … … 579 582 NULL, 1, &msg_tag); 580 583 584 /* Register support for "application/im-iscomposing+xml" content */ 585 pjsip_endpt_add_capability( pjsua_var.endpt, &mod_pjsua_im, PJSIP_H_ACCEPT, 586 NULL, 1, &STR_MIME_APP_ISCOMPOSING); 587 588 /* Register support for "text/plain" content */ 589 pjsip_endpt_add_capability( pjsua_var.endpt, &mod_pjsua_im, PJSIP_H_ACCEPT, 590 NULL, 1, &STR_MIME_TEXT_PLAIN); 591 581 592 return PJ_SUCCESS; 582 593 }
Note: See TracChangeset
for help on using the changeset viewer.