Logo Search packages:      
Sourcecode: jabberd2 version File versions  Download package

void pres_in ( user_t  user,
pkt_t  pkt 
)

presence updates from a remote jid

Definition at line 277 of file pres.c.

References sess_st::A, sess_st::available, sess_st::E, pkt_st::from, sess_st::invisible, sess_st::jid, sess_st::next, pkt_dup(), pkt_PRESENCE_PROBE, sess_st::pres, pres_trust(), user_st::sessions, user_st::sm, and pkt_st::type.

Referenced by _presence_pkt_user().

                                     {
    sess_t scan;

    log_debug(ZONE, "type %d presence packet from %s", pkt->type, jid_full(pkt->from));

    /* loop over each session */
    for(scan = user->sessions; scan != NULL; scan = scan->next) {
        /* don't deliver to unavailable sessions: B5(a) */
        if(!scan->available)
            continue;

        /* don't deliver to ourselves, lest we presence-bomb ourselves ;) */
        if(jid_compare_full(pkt->from, scan->jid) == 0)
            continue;

        /* handle probes */
        if(pkt->type == pkt_PRESENCE_PROBE) {
            log_debug(ZONE, "probe from %s for %s", jid_full(pkt->from), jid_full(scan->jid));

            /* B4(a): respond if in T and I clear */
            if(!scan->invisible && pres_trust(user, pkt->from)) {
                log_debug(ZONE, "responding with last presence update");
                pkt_router(pkt_dup(scan->pres, jid_full(pkt->from), jid_full(scan->jid)));
            }

            /* B4(b): respond if in T and in A and I set */
            else if(scan->invisible && pres_trust(user, pkt->from) && jid_search(scan->A, pkt->from)) {
                log_debug(ZONE, "we're invisible, responding with raw available");
                pkt_router(pkt_create(user->sm, "presence", NULL, jid_full(pkt->from), jid_full(scan->jid)));
            }

            else {
                log_debug(ZONE, "probe not authorised, ignoring");
            }

            /* remove from E */
            scan->E = jid_zap(scan->E, pkt->from);

            continue;
        }

        /* deliver to session: B5(b) */
        log_debug(ZONE, "forwarding to %s", jid_full(scan->jid));
        pkt_sess(pkt_dup(pkt, jid_full(scan->jid), jid_full(pkt->from)), scan);
    }

    pkt_free(pkt);
}


Generated by  Doxygen 1.6.0   Back to index