Changeset 433

Show
Ignore:
Timestamp:
25/10/07 01:15:31 (14 months ago)
Author:
smoku
Message:

offline-status support

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/sm/pres.c

    r406 r433  
    9191                xhash_iter_get(sess->user->roster, NULL, (void *) &item); 
    9292 
    93                 /* Is the user local ? */ 
     93                /* Is the user local ? */ 
    9494                user_is_local = (item->jid->node[0] != '\0' && strcmp(pkt->sm->id, item->jid->domain) == 0); 
    9595                if (user_is_local) { 
     
    100100                /* if we're coming available, and we can see them, we need to probe them */ 
    101101                if(!sess->available && item->to) { 
    102  
    103                     /* Shortcut */ 
    104                     if ((!user_is_local) || (user_is_local && user_connected)) { 
    105                        log_debug(ZONE, "probing %s", jid_full(item->jid)); 
    106                        pkt_router(pkt_create(sess->user->sm, "presence", "probe", jid_full(item->jid), jid_user(sess->jid)));  
    107                     } else  
    108                        log_debug(ZONE, "skipping probe to local user %s - not connected", jid_full(item->jid)); 
     102                    log_debug(ZONE, "probing %s", jid_full(item->jid)); 
     103                    pkt_router(pkt_create(sess->user->sm, "presence", "probe", jid_full(item->jid), jid_user(sess->jid)));  
    109104 
    110105                    /* flag if we probed ourselves */ 
     
    115110                /* if they can see us, forward */ 
    116111                if(item->from && !jid_search(sess->E, item->jid)) { 
    117                     /* Shortcut: if the domain of this user's jid is the same as this sm, 
    118                         and the user has no active sessions, don't send presence update */ 
    119  
     112                    /* Shortcut: if the domain of this user's jid is the same as this sm, 
     113                       and the user has no active sessions, don't send presence update */ 
    120114                    if ((!user_is_local) || (user_is_local && user_connected)) { 
    121115                       log_debug(ZONE, "forwarding available to %s", jid_full(item->jid)); 
     
    167161                xhash_iter_get(sess->user->roster, NULL, (void *) &item); 
    168162 
    169                 /* Is the user local ? */ 
     163                /* Is the user local ? */ 
    170164                user_is_local = (strcmp(pkt->sm->id, item->jid->domain)==0); 
    171165                if (user_is_local) { 
     
    227221 
    228222        default: 
    229             log_debug(ZONE, "pres_update got packet type %d, this shouldn't happen", pkt->type); 
     223            log_debug(ZONE, "pres_update got packet type 0x%X, this shouldn't happen", pkt->type); 
    230224            pkt_free(pkt); 
    231225            return; 
     
    236230} 
    237231 
    238 /** presence updates from a remote jid */ 
     232/** presence updates from a remote jid - RFC 3921bis 4.3.2. */ 
    239233void pres_in(user_t user, pkt_t pkt) { 
    240234    sess_t scan; 
    241235 
    242     log_debug(ZONE, "type 0x%X presence packet from %s", pkt->type, jid_full(pkt->from)); 
     236    log_debug(ZONE, "\n\n===\n\ntype 0x%X presence packet from %s\n\n", pkt->type, jid_full(pkt->from)); 
     237 
     238    /* handle probes */ 
     239    if(pkt->type == pkt_PRESENCE_PROBE) { 
     240        /* unsubscribe untrusted users */ 
     241        if(!pres_trust(user, pkt->from)) { 
     242            log_debug(ZONE, "unsubscribing untrusted %s", jid_full(pkt->from)); 
     243            pkt_router(pkt_create(user->sm, "presence", "unsubscribe", jid_full(pkt->from), jid_full(pkt->to))); 
     244 
     245            pkt_free(pkt); 
     246            return; 
     247        } 
     248 
     249        /* respond with last unavailable presence if no available session */ 
     250        if(user->top == NULL) { 
     251            os_t os; 
     252            os_object_t o; 
     253            nad_t nad; 
     254            pkt_t pres; 
     255 
     256            /* get user last presence stanza */ 
     257            if(storage_get(user->sm->st, "status", jid_user(user->jid), NULL, &os) == st_SUCCESS && os_iter_first(os)) { 
     258                o = os_iter_object(os); 
     259                os_object_get_nad(os, o, "xml", &nad); 
     260                pres = pkt_new(pkt->sm, nad_copy(nad)); 
     261                pkt_router(pkt_dup(pres, jid_full(pkt->from), jid_user(user->jid))); 
     262                os_free(os); 
     263                pkt_free(pres); 
     264            } 
     265            pkt_free(pkt); 
     266            return; 
     267        } 
     268    } 
    243269 
    244270    /* loop over each session */ 
     
    256282            log_debug(ZONE, "probe from %s for %s", jid_full(pkt->from), jid_full(scan->jid)); 
    257283 
    258             /* B3: respond if in T */ 
    259             if(pres_trust(user, pkt->from)) { 
    260                 log_debug(ZONE, "responding with last presence update"); 
    261                 pkt_router(pkt_dup(scan->pres, jid_full(pkt->from), jid_full(scan->jid))); 
    262             } 
    263  
    264             else { 
    265                 log_debug(ZONE, "probe not authorised, ignoring"); 
    266             } 
     284            /* B3: respond (already checked for T) */ 
     285            log_debug(ZONE, "responding with last presence update"); 
     286            pkt_router(pkt_dup(scan->pres, jid_full(pkt->from), jid_full(scan->jid))); 
    267287 
    268288            /* remove from E */ 
  • trunk/UPGRADE

    r408 r433  
    11This file contains upgrade instructions between different versions of jabberd2. 
     2 
     3* 2.1.18 to 2.1.19 upgrade: 
     4 
     5What had change: 
     6- mod_status stores full last presence stanza 
     7- so called "offline status" support 
     8  (sending last unavailable presence stanza for unavailable users) 
     9 
     10You need to add "xml" column to "status" table: 
     11ALTER TABLE "status" ADD COLUMN "xml" TEXT; 
     12 
    213 
    314* 2.1.17 to 2.1.18 upgrade: