Changeset 2762 for pjproject/trunk/pjsip/src/pjsip-simple/presence.c
- Timestamp:
- Jun 15, 2009 4:03:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-simple/presence.c
r2730 r2762 74 74 pjsip_dialog *dlg; /**< The dialog. */ 75 75 content_type_e content_type; /**< Content-Type. */ 76 pj_pool_t *status_pool; /**< Pool for pres_status */ 76 77 pjsip_pres_status status; /**< Presence status. */ 78 pj_pool_t *tmp_pool; /**< Pool for tmp_status */ 77 79 pjsip_pres_status tmp_status; /**< Temp, before NOTIFY is answred.*/ 78 80 pjsip_evsub_user user_cb; /**< The user callback. */ … … 186 188 pj_status_t status; 187 189 pjsip_pres *pres; 190 char obj_name[PJ_MAX_OBJ_NAME]; 188 191 pjsip_evsub *sub; 189 192 … … 205 208 pj_memcpy(&pres->user_cb, user_cb, sizeof(pjsip_evsub_user)); 206 209 210 pj_ansi_snprintf(obj_name, PJ_MAX_OBJ_NAME, "pres%p", dlg->pool); 211 pres->status_pool = pj_pool_create(dlg->pool->factory, obj_name, 212 512, 512, NULL); 213 pj_ansi_snprintf(obj_name, PJ_MAX_OBJ_NAME, "tmpres%p", dlg->pool); 214 pres->tmp_pool = pj_pool_create(dlg->pool->factory, obj_name, 215 512, 512, NULL); 216 207 217 /* Attach to evsub */ 208 218 pjsip_evsub_set_mod_data(sub, mod_presence.id, pres); … … 229 239 pjsip_evsub *sub; 230 240 pjsip_pres *pres; 241 char obj_name[PJ_MAX_OBJ_NAME]; 231 242 pj_status_t status; 232 243 … … 298 309 pj_memcpy(&pres->user_cb, user_cb, sizeof(pjsip_evsub_user)); 299 310 311 pj_ansi_snprintf(obj_name, PJ_MAX_OBJ_NAME, "pres%p", dlg->pool); 312 pres->status_pool = pj_pool_create(dlg->pool->factory, obj_name, 313 512, 512, NULL); 314 pj_ansi_snprintf(obj_name, PJ_MAX_OBJ_NAME, "tmpres%p", dlg->pool); 315 pres->tmp_pool = pj_pool_create(dlg->pool->factory, obj_name, 316 512, 512, NULL); 317 300 318 /* Attach to evsub */ 301 319 pjsip_evsub_set_mod_data(sub, mod_presence.id, pres); … … 356 374 PJ_ASSERT_RETURN(pres!=NULL, PJSIP_SIMPLE_ENOPRESENCE); 357 375 358 if (pres->tmp_status._is_valid) 376 if (pres->tmp_status._is_valid) { 377 PJ_ASSERT_RETURN(pres->tmp_pool!=NULL, PJSIP_SIMPLE_ENOPRESENCE); 359 378 pj_memcpy(status, &pres->tmp_status, sizeof(pjsip_pres_status)); 360 else 379 } else { 380 PJ_ASSERT_RETURN(pres->status_pool!=NULL, PJSIP_SIMPLE_ENOPRESENCE); 361 381 pj_memcpy(status, &pres->status, sizeof(pjsip_pres_status)); 382 } 362 383 363 384 return PJ_SUCCESS; … … 372 393 { 373 394 unsigned i; 395 pj_pool_t *tmp; 374 396 pjsip_pres *pres; 375 397 … … 381 403 for (i=0; i<status->info_cnt; ++i) { 382 404 pres->status.info[i].basic_open = status->info[i].basic_open; 383 if (status->info[i].id.slen == 0) { 405 if (pres->status.info[i].id.slen) { 406 /* Id already set */ 407 } else if (status->info[i].id.slen == 0) { 384 408 pj_create_unique_string(pres->dlg->pool, 385 409 &pres->status.info[i].id); … … 389 413 &status->info[i].id); 390 414 } 391 pj_strdup(pres-> dlg->pool,415 pj_strdup(pres->tmp_pool, 392 416 &pres->status.info[i].contact, 393 417 &status->info[i].contact); … … 396 420 pres->status.info[i].rpid.activity = 397 421 status->info[i].rpid.activity; 398 pj_strdup(pres-> dlg->pool,422 pj_strdup(pres->tmp_pool, 399 423 &pres->status.info[i].rpid.id, 400 424 &status->info[i].rpid.id); 401 pj_strdup(pres-> dlg->pool,425 pj_strdup(pres->tmp_pool, 402 426 &pres->status.info[i].rpid.note, 403 427 &status->info[i].rpid.note); … … 406 430 407 431 pres->status.info_cnt = status->info_cnt; 432 433 /* Swap pools */ 434 tmp = pres->tmp_pool; 435 pres->tmp_pool = pres->status_pool; 436 pres->status_pool = tmp; 437 pj_pool_reset(pres->tmp_pool); 408 438 409 439 return PJ_SUCCESS; … … 573 603 if (pres->user_cb.on_evsub_state) 574 604 (*pres->user_cb.on_evsub_state)(sub, event); 605 606 if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED) { 607 if (pres->status_pool) { 608 pj_pool_release(pres->status_pool); 609 pres->status_pool = NULL; 610 } 611 if (pres->tmp_pool) { 612 pj_pool_release(pres->tmp_pool); 613 pres->tmp_pool = NULL; 614 } 615 } 575 616 } 576 617 … … 671 712 pj_stricmp(&ctype_hdr->media.subtype, &STR_PIDF_XML)==0) 672 713 { 673 status = pjsip_pres_parse_pidf( rdata, pres-> dlg->pool,714 status = pjsip_pres_parse_pidf( rdata, pres->tmp_pool, 674 715 &pres->tmp_status); 675 716 } … … 678 719 pj_stricmp(&ctype_hdr->media.subtype, &STR_XPIDF_XML)==0) 679 720 { 680 status = pjsip_pres_parse_xpidf( rdata, pres-> dlg->pool,721 status = pjsip_pres_parse_xpidf( rdata, pres->tmp_pool, 681 722 &pres->tmp_status); 682 723 } … … 741 782 742 783 } else { 784 #if 1 785 /* This is the newest change, http://trac.pjsip.org/repos/ticket/873 786 * Some app want to be notified about the empty NOTIFY, e.g. to 787 * decide whether it should consider the buddy as offline. 788 * In this case, leave the buddy state unchanged, but set the 789 * "tuple_node" in pjsip_pres_status to NULL. 790 */ 791 unsigned i; 792 for (i=0; i<pres->status.info_cnt; ++i) { 793 pres->status.info[i].tuple_node = NULL; 794 } 795 796 #elif 0 743 797 /* This has just been changed. Previously, we treat incoming NOTIFY 744 798 * with no message body as having the presence subscription closed. 745 799 * Now we treat it as no change in presence status (ref: EyeBeam). 746 800 */ 747 #if 1748 801 *p_st_code = 200; 749 802 return; … … 768 821 */ 769 822 if ((*p_st_code)/100 == 2) { 823 pj_pool_t *tmp; 824 770 825 pj_memcpy(&pres->status, &pres->tmp_status, sizeof(pjsip_pres_status)); 826 827 /* Swap the pool */ 828 tmp = pres->tmp_pool; 829 pres->tmp_pool = pres->status_pool; 830 pres->status_pool = tmp; 771 831 } 772 832 773 833 pres->tmp_status._is_valid = PJ_FALSE; 834 pj_pool_reset(pres->tmp_pool); 774 835 775 836 /* Done */
Note: See TracChangeset
for help on using the changeset viewer.