Ignore:
Timestamp:
Aug 25, 2007 1:36:15 PM (15 years ago)
Author:
bennylp
Message:

Implement ticket #336: custom presence status in NOTIFY/PUBLISH, supporting subset of RPID elements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c

    r1423 r1424  
    114114    } else if (pjsua_var.buddy[buddy_id].status.info[0].basic_open) { 
    115115        info->status = PJSUA_BUDDY_STATUS_ONLINE; 
    116         info->status_text = pj_str("Online"); 
     116 
     117        /* copy RPID information */ 
     118        info->rpid = buddy->status.info[0].rpid; 
     119 
     120        if (info->rpid.note.slen) 
     121            info->status_text = info->rpid.note; 
     122        else 
     123            info->status_text = pj_str("Online"); 
     124 
    117125    } else { 
    118126        info->status = PJSUA_BUDDY_STATUS_OFFLINE; 
     
    653661        pres_status.info[0].basic_open = acc->online_status; 
    654662        pres_status.info[0].id = acc->cfg.pidf_tuple_id; 
     663        /* .. including RPID information */ 
     664        pj_memcpy(&pres_status.info[0].rpid, &acc->rpid,  
     665                  sizeof(pjrpid_element)); 
    655666 
    656667        /* Be careful not to send PIDF with presence entity ID containing 
     
    822833 
    823834 
    824 /* Refresh subscription (e.g. when our online status has changed) */ 
    825 static void refresh_server_subscription(int acc_id) 
     835/* Update server subscription (e.g. when our online status has changed) */ 
     836void pjsua_pres_update_acc(int acc_id, pj_bool_t force) 
    826837{ 
    827838    pjsua_acc *acc = &pjsua_var.acc[acc_id]; 
     
    837848 
    838849        pjsip_pres_get_status(uapres->sub, &pres_status); 
    839         if (pres_status.info[0].basic_open != acc->online_status) { 
     850        if (force || pres_status.info[0].basic_open != acc->online_status) { 
     851 
    840852            pres_status.info[0].basic_open = acc->online_status; 
     853            pj_memcpy(&pres_status.info[0].rpid, &acc->rpid,  
     854                      sizeof(pjrpid_element)); 
     855 
    841856            pjsip_pres_set_status(uapres->sub, &pres_status); 
    842857 
     
    856871     */ 
    857872    if (acc_cfg->publish_enabled && acc->publish_sess) { 
    858         if (acc->publish_state != acc->online_status) { 
     873        if (force || acc->publish_state != acc->online_status) { 
    859874            send_publish(acc_id, PJ_TRUE); 
    860875        } 
     
    12521267    for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 
    12531268        if (pjsua_var.acc[i].valid) 
    1254             refresh_server_subscription(i); 
     1269            pjsua_pres_update_acc(i, PJ_FALSE); 
    12551270    } 
    12561271} 
Note: See TracChangeset for help on using the changeset viewer.