Changeset 2762
- Timestamp:
- Jun 15, 2009 4:03:40 PM (15 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip-simple/presence.h
r2394 r2762 90 90 pj_str_t id; /**< Tuple id. */ 91 91 pj_str_t contact; /**< Optional contact address. */ 92 93 pj_xml_node *tuple_node; /**< Pointer to tuple XML node of 94 parsed PIDF body received from 95 remote agent. Only valid for 96 client subscription. If the 97 last received NOTIFY request 98 does not contain any PIDF body, 99 this valud will be set to NULL */ 92 100 93 101 } info[PJSIP_PRES_STATUS_MAX_INFO]; /**< Array of info. */ -
pjproject/trunk/pjsip/include/pjsip/sip_config.h
r2756 r2762 873 873 874 874 875 /** 876 * Add "timestamp" information in generated PIDF document for both server 877 * subscription and presence publication. 878 * 879 * Default: 1 (yes) 880 */ 881 #ifndef PJSIP_PRES_PIDF_ADD_TIMESTAMP 882 # define PJSIP_PRES_PIDF_ADD_TIMESTAMP 1 883 #endif 884 885 875 886 PJ_END_DECL 876 887 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r2738 r2762 2908 2908 2909 2909 /** 2910 * Extended presence info. 2911 */ 2912 pjsip_pres_status pres_status; 2913 2914 /** 2910 2915 * Internal buffer. 2911 2916 */ -
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 */ -
pjproject/trunk/pjsip/src/pjsip-simple/presence_body.c
r2394 r2762 101 101 pjpidf_status_set_basic_open(pidf_status, 102 102 status->info[i].basic_open); 103 104 /* Add <timestamp> if configured */ 105 #if defined(PJSIP_PRES_PIDF_ADD_TIMESTAMP) && PJSIP_PRES_PIDF_ADD_TIMESTAMP 106 if (PJSIP_PRES_PIDF_ADD_TIMESTAMP) { 107 char buf[50]; 108 int tslen = 0; 109 pj_time_val tv; 110 pj_parsed_time pt; 111 112 pj_gettimeofday(&tv); 113 /* TODO: convert time to GMT! (unsupported by pjlib) */ 114 pj_time_decode( &tv, &pt); 115 116 tslen = pj_ansi_snprintf(buf, sizeof(buf), 117 "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 118 pt.year, pt.mon, pt.day, 119 pt.hour, pt.min, pt.sec, pt.msec); 120 if (tslen > 0 && tslen < sizeof(buf)) { 121 pj_str_t time = pj_str(buf); 122 pjpidf_tuple_set_timestamp(pool, pidf_tuple, &time); 123 } 124 } 125 #endif 103 126 } 104 127 … … 180 203 181 204 pidf_tuple = pjpidf_pres_get_first_tuple(pidf); 182 while (pidf_tuple ) {205 while (pidf_tuple && pres_status->info_cnt < PJSIP_PRES_STATUS_MAX_INFO) { 183 206 pjpidf_status *pidf_status; 207 208 pres_status->info[pres_status->info_cnt].tuple_node = 209 pj_xml_clone(pool, pidf_tuple); 184 210 185 211 pj_strdup(pool, … … 232 258 pres_status->info[0].basic_open = pjxpidf_get_status(xpidf); 233 259 pres_status->info[0].id.slen = 0; 260 pres_status->info[0].tuple_node = NULL; 234 261 235 262 return PJ_SUCCESS; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
r2661 r2762 167 167 total += info->contact.slen; 168 168 169 /* Presence status */ 170 pj_memcpy(&info->pres_status, &buddy->status, sizeof(pjsip_pres_status)); 171 169 172 /* status and status text */ 170 173 if (buddy->sub == NULL || buddy->status.info_cnt==0) {
Note: See TracChangeset
for help on using the changeset viewer.