Changeset 236 for pjproject/trunk/pjsip/src/pjsua/pjsua_pres.c
- Timestamp:
- Feb 26, 2006 9:23:45 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua/pjsua_pres.c
r230 r236 80 80 static pj_bool_t pres_on_rx_request(pjsip_rx_data *rdata) 81 81 { 82 int acc_index; 82 83 pjsip_method *req_method = &rdata->msg_info.msg->line.req.method; 83 84 pjsua_srv_pres *uapres; … … 94 95 /* Incoming SUBSCRIBE: */ 95 96 97 /* Find which account for the incoming request. */ 98 acc_index = pjsua_find_account_for_incoming(rdata); 99 96 100 /* Create UAS dialog: */ 97 101 status = pjsip_dlg_create_uas( pjsip_ua_instance(), rdata, 98 &pjsua.contact_uri, &dlg); 102 &pjsua.acc[acc_index].contact_uri, 103 &dlg); 99 104 if (status != PJ_SUCCESS) { 100 105 pjsua_perror(THIS_FILE, … … 131 136 132 137 /* Add server subscription to the list: */ 133 pj_list_push_back(&pjsua. pres_srv_list, uapres);138 pj_list_push_back(&pjsua.acc[acc_index].pres_srv_list, uapres); 134 139 135 140 … … 147 152 pj_memset(&pres_status, 0, sizeof(pres_status)); 148 153 pres_status.info_cnt = 1; 149 pres_status.info[0].basic_open = pjsua. online_status;154 pres_status.info[0].basic_open = pjsua.acc[acc_index].online_status; 150 155 //Both pjsua.local_uri and pjsua.contact_uri are enclosed in "<" and ">" 151 156 //causing XML parsing to fail. … … 175 180 176 181 /* Refresh subscription (e.g. when our online status has changed) */ 177 static void refresh_server_subscription( )182 static void refresh_server_subscription(int acc_index) 178 183 { 179 184 pjsua_srv_pres *uapres; 180 185 181 uapres = pjsua. pres_srv_list.next;182 183 while (uapres != &pjsua. pres_srv_list) {186 uapres = pjsua.acc[acc_index].pres_srv_list.next; 187 188 while (uapres != &pjsua.acc[acc_index].pres_srv_list) { 184 189 185 190 pjsip_pres_status pres_status; … … 187 192 188 193 pjsip_pres_get_status(uapres->sub, &pres_status); 189 if (pres_status.info[0].basic_open != pjsua. online_status) {190 pres_status.info[0].basic_open = pjsua. online_status;194 if (pres_status.info[0].basic_open != pjsua.acc[acc_index].online_status) { 195 pres_status.info[0].basic_open = pjsua.acc[acc_index].online_status; 191 196 pjsip_pres_set_status(uapres->sub, &pres_status); 192 197 … … 299 304 static void subscribe_buddy_presence(unsigned index) 300 305 { 306 int acc_index; 301 307 pjsip_dialog *dlg; 302 308 pjsip_tx_data *tdata; 303 309 pj_status_t status; 304 310 311 acc_index = pjsua.buddies[index].acc_index; 312 305 313 status = pjsip_dlg_create_uac( pjsip_ua_instance(), 306 &pjsua. local_uri,307 &pjsua. contact_uri,314 &pjsua.acc[acc_index].local_uri, 315 &pjsua.acc[acc_index].contact_uri, 308 316 &pjsua.buddies[index].uri, 309 317 NULL, &dlg); … … 326 334 &pjsua.buddies[index]); 327 335 328 status = pjsip_pres_initiate(pjsua.buddies[index].sub, 60, &tdata);336 status = pjsip_pres_initiate(pjsua.buddies[index].sub, -1, &tdata); 329 337 if (status != PJ_SUCCESS) { 330 338 pjsua.buddies[index].sub = NULL; … … 382 390 static void refresh_client_subscription(void) 383 391 { 384 unsignedi;392 int i; 385 393 386 394 for (i=0; i<pjsua.buddy_cnt; ++i) { … … 416 424 * Refresh presence 417 425 */ 418 void pjsua_pres_refresh( void)426 void pjsua_pres_refresh(int acc_index) 419 427 { 420 428 refresh_client_subscription(); 421 refresh_server_subscription( );429 refresh_server_subscription(acc_index); 422 430 } 423 431 … … 428 436 void pjsua_pres_shutdown(void) 429 437 { 430 unsigned i; 431 432 pjsua.online_status = 0; 438 int acc_index; 439 int i; 440 441 for (acc_index=0; acc_index<pjsua.acc_cnt; ++acc_index) { 442 pjsua.acc[acc_index].online_status = 0; 443 } 444 433 445 for (i=0; i<pjsua.buddy_cnt; ++i) { 434 446 pjsua.buddies[i].monitor = 0; 435 447 } 436 pjsua_pres_refresh(); 448 449 for (acc_index=0; acc_index<pjsua.acc_cnt; ++acc_index) { 450 pjsua_pres_refresh(acc_index); 451 } 437 452 } 438 453 … … 442 457 void pjsua_pres_dump(void) 443 458 { 444 unsigned i; 459 int acc_index; 460 int i; 445 461 446 462 PJ_LOG(3,(THIS_FILE, "Dumping pjsua server subscriptions:")); 447 if (pj_list_empty(&pjsua.pres_srv_list)) { 448 PJ_LOG(3,(THIS_FILE, " - none - ")); 449 } else { 450 struct pjsua_srv_pres *uapres; 451 452 uapres = pjsua.pres_srv_list.next; 453 while (uapres != &pjsua.pres_srv_list) { 454 455 PJ_LOG(3,(THIS_FILE, " %10s %s", 456 pjsip_evsub_get_state_name(uapres->sub), 457 uapres->remote)); 458 459 uapres = uapres->next; 463 for (acc_index=0; acc_index < pjsua.acc_cnt; ++acc_index) { 464 465 PJ_LOG(3,(THIS_FILE, " %.*s", 466 (int)pjsua.acc[acc_index].local_uri.slen, 467 pjsua.acc[acc_index].local_uri.ptr)); 468 469 if (pj_list_empty(&pjsua.acc[acc_index].pres_srv_list)) { 470 PJ_LOG(3,(THIS_FILE, " - none - ")); 471 } else { 472 struct pjsua_srv_pres *uapres; 473 474 uapres = pjsua.acc[acc_index].pres_srv_list.next; 475 while (uapres != &pjsua.acc[acc_index].pres_srv_list) { 476 477 PJ_LOG(3,(THIS_FILE, " %10s %s", 478 pjsip_evsub_get_state_name(uapres->sub), 479 uapres->remote)); 480 481 uapres = uapres->next; 482 } 460 483 } 461 484 }
Note: See TracChangeset
for help on using the changeset viewer.