Ignore:
Timestamp:
2006-10-02T17:46:57Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
6266fca
Parents:
501b4e0
Message:

Added some error handling for the (not very complete yet) privacy list code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    r501b4e0 r995913b  
    148148        {
    149149                struct xt_node *c;
     150               
    150151                if( !( jd->flags & JFLAG_AUTHENTICATED ) &&
    151152                    ( c = xt_find_node( orig->children, "query" ) ) &&
     
    199200        {
    200201                if( !( jd->flags & JFLAG_AUTHENTICATED ) &&
     202                      orig &&
    201203                    ( c = xt_find_node( orig->children, "query" ) ) &&
    202204                    ( c = xt_find_node( c->children, "username" ) ) &&
     
    207209                        return XT_ABORT;
    208210                }
    209                 else if( orig &&
    210                          ( c = xt_find_node( orig->children, "query" ) ) &&
    211                          ( c = xt_find_node( c->children, "active" ) ) )
    212                 {
    213                         serv_got_crap( gc, "Error while activating privacy list, maybe it doesn't exist" );
     211                else if( ( xmlns && strcmp( xmlns, "jabber:iq:privacy" ) == 0 ) ||
     212                         ( orig &&
     213                           ( c = xt_find_node( orig->children, "query" ) ) &&
     214                           ( s = xt_find_attr( c, "xmlns" ) ) &&
     215                           strcmp( s, "jabber:iq:privacy" ) == 0 ) )
     216                {
     217                        /* All errors related to privacy lists. */
     218                        if( ( c = xt_find_node( node->children, "error" ) ) == NULL )
     219                        {
     220                                hide_login_progress_error( gc, "Received malformed error packet" );
     221                                signoff( gc );
     222                                return XT_ABORT;
     223                        }
     224                       
     225                        if( xt_find_node( c->children, "item-not-found" ) )
     226                        {
     227                                serv_got_crap( gc, "Error while activating privacy list, maybe it doesn't exist" );
     228                                /* Should I do anything else here? */
     229                        }
     230                        else if( xt_find_node( c->children, "feature-not-implemented" ) )
     231                        {
     232                                jd->flags |= JFLAG_PRIVACY_BROKEN;
     233                                /* Probably there's no need to inform the user.
     234                                   We can do that if the user ever tries to use
     235                                   the block/allow commands. */
     236                        }
    214237                }
    215238        }
     
    327350        node = jabber_make_packet( "iq", "get", NULL, node );
    328351       
    329         st = jabber_write_packet( gc, node );
    330        
    331         xt_free_node( node );
     352        jabber_cache_packet( gc, node );
     353        st = jabber_write_packet( gc, node );
     354       
    332355        return st;
    333356}
     
    347370        return jabber_write_packet( gc, node );
    348371}
     372
     373char *set_eval_privacy_list( set_t *set, char *value )
     374{
     375        account_t *acc = set->data;
     376        struct jabber_data *jd = acc->gc->proto_data;
     377       
     378        if( jd->flags & JFLAG_PRIVACY_BROKEN )
     379        {
     380                serv_got_crap( acc->gc, "Privacy lists not supported by this server" );
     381                return NULL;
     382        }
     383       
     384        /* If we're on-line, return NULL and let the server decide if the
     385           chosen list is valid. If we're off-line, just accept it and we'll
     386           see later (when we connect). */
     387        if( acc->gc )
     388                jabber_set_privacy( acc->gc, value );
     389       
     390        return acc->gc ? NULL : value;
     391}
Note: See TracChangeset for help on using the changeset viewer.