- Timestamp:
- Apr 28, 2009 10:19:49 PM (16 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip-simple/publish.h
r2394 r2661 79 79 pj_str_t reason; /**< SIP reason phrase received. */ 80 80 pjsip_rx_data *rdata; /**< The complete received response. */ 81 int expiration;/**< Next expiration interval. */ 81 int expiration;/**< Next expiration interval. If the 82 value is -1, it means the session 83 will not renew itself. */ 82 84 }; 83 85 … … 191 193 192 194 /** 195 * Set list of headers to be added to each PUBLISH request generated by 196 * the client publication session. Note that application can also add 197 * the headers to the request after calling #pjsip_publishc_publish() 198 * or #pjsip_publishc_unpublish(), but the benefit of this function is 199 * the headers will also be added to requests generated internally by 200 * the session, such as during session renewal/refresh. 201 * 202 * Note that calling this function will clear the previously added list 203 * of headers. 204 * 205 * @param pubc The client publication structure. 206 * @param hdr_list The list of headers. 207 * 208 * @return PJ_SUCCESS on success. 209 */ 210 PJ_DECL(pj_status_t) pjsip_publishc_set_headers(pjsip_publishc *pubc, 211 const pjsip_hdr *hdr_list); 212 213 /** 193 214 * Create PUBLISH request for the specified client publication structure. 194 215 * Application can use this function to both create initial publication -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r2506 r2661 2038 2038 */ 2039 2039 #ifndef PJSUA_PUBLISH_EXPIRATION 2040 # define PJSUA_PUBLISH_EXPIRATION 6002040 # define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED 2041 2041 #endif 2042 2042 … … 3494 3494 /** 3495 3495 * This specifies how long the library should retry resending SUBSCRIBE 3496 * if the previous SUBSCRIBE failed. 3496 * if the previous SUBSCRIBE failed. This also controls the duration 3497 * before failed PUBLISH request will be retried. 3497 3498 * 3498 3499 * Default: 300 seconds -
pjproject/trunk/pjsip/src/pjsip-simple/publishc.c
r2394 r2661 82 82 pj_uint32_t expires; 83 83 pjsip_route_hdr route_set; 84 pjsip_hdr usr_hdr; 84 85 85 86 /* Authorization sessions. */ … … 158 159 159 160 pj_list_init(&pubc->route_set); 161 pj_list_init(&pubc->usr_hdr); 160 162 161 163 /* Done */ … … 187 189 static void set_expires( pjsip_publishc *pubc, pj_uint32_t expires) 188 190 { 189 if (expires != pubc->expires) { 191 if (expires != pubc->expires && 192 expires != PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED) 193 { 190 194 pubc->expires_hdr = pjsip_expires_hdr_create(pubc->pool, expires); 191 195 } else { … … 277 281 pj_list_push_back(&pubc->route_set, pjsip_hdr_clone(pubc->pool, chdr)); 278 282 chdr = chdr->next; 283 } 284 285 return PJ_SUCCESS; 286 } 287 288 PJ_DEF(pj_status_t) pjsip_publishc_set_headers( pjsip_publishc *pubc, 289 const pjsip_hdr *hdr_list) 290 { 291 const pjsip_hdr *h; 292 293 PJ_ASSERT_RETURN(pubc && hdr_list, PJ_EINVAL); 294 295 pj_list_init(&pubc->usr_hdr); 296 h = hdr_list->next; 297 while (h != hdr_list) { 298 pj_list_push_back(&pubc->usr_hdr, pjsip_hdr_clone(pubc->pool, h)); 299 h = h->next; 279 300 } 280 301 … … 346 367 } 347 368 369 /* Add user headers */ 370 if (!pj_list_empty(&pubc->usr_hdr)) { 371 const pjsip_hdr *hdr; 372 373 hdr = pubc->usr_hdr.next; 374 while (hdr != &pubc->usr_hdr) { 375 pjsip_hdr *new_hdr = (pjsip_hdr*) 376 pjsip_hdr_shallow_clone(tdata->pool, hdr); 377 pjsip_msg_add_hdr(tdata->msg, new_hdr); 378 hdr = hdr->next; 379 } 380 } 381 348 382 349 383 /* Done. */ … … 531 565 pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES, NULL); 532 566 533 if ( expires)567 if (pubc->auto_refresh && expires) 534 568 expiration = expires->ivalue; 535 569 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
r2596 r2661 962 962 963 963 if (param->code/100 != 2 || param->status != PJ_SUCCESS) { 964 965 pjsip_publishc_destroy(param->pubc); 966 acc->publish_sess = NULL; 967 964 968 if (param->status != PJ_SUCCESS) { 965 969 char errmsg[PJ_ERR_MSG_SIZE]; … … 969 973 "Client publication (PUBLISH) failed, status=%d, msg=%s", 970 974 param->status, errmsg)); 975 } else if (param->code == 412) { 976 /* 412 (Conditional Request Failed) 977 * The PUBLISH refresh has failed, retry with new one. 978 */ 979 pjsua_pres_init_publish_acc(acc->index); 980 971 981 } else { 972 982 PJ_LOG(1,(THIS_FILE, … … 976 986 } 977 987 978 pjsip_publishc_destroy(param->pubc); 979 acc->publish_sess = NULL; 988 } else { 989 if (param->expiration == -1) { 990 /* Could happen if server "forgot" to include Expires header 991 * in the response. We will not renew, so destroy the pubc. 992 */ 993 pjsip_publishc_destroy(param->pubc); 994 acc->publish_sess = NULL; 995 } 980 996 } 981 997 } … … 1092 1108 &acc_cfg->id, &acc_cfg->id, 1093 1109 &acc_cfg->id, 1094 PJSUA_P RES_TIMER);1110 PJSUA_PUBLISH_EXPIRATION); 1095 1111 if (status != PJ_SUCCESS) { 1096 1112 acc->publish_sess = NULL; … … 1607 1623 pj_timer_entry *entry) 1608 1624 { 1625 unsigned i; 1609 1626 pj_time_val delay = { PJSUA_PRES_TIMER, 0 }; 1627 1628 /* Retry failed PUBLISH requests */ 1629 for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 1630 pjsua_acc *acc = &pjsua_var.acc[i]; 1631 if (acc->cfg.publish_enabled && acc->publish_sess==NULL) 1632 pjsua_pres_init_publish_acc(acc->index); 1633 } 1610 1634 1611 1635 entry->id = PJ_FALSE;
Note: See TracChangeset
for help on using the changeset viewer.