Changeset 995913b for protocols/jabber


Ignore:
Timestamp:
2006-10-02T17:46:57Z (17 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.

Location:
protocols/jabber
Files:
3 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}
  • protocols/jabber/jabber.c

    r501b4e0 r995913b  
    4242        s = set_add( &acc->set, "priority", "0", set_eval_priority, acc );
    4343       
    44         s = set_add( &acc->set, "privacy_list", NULL, NULL, acc );
    45         /* TODO: Add evaluator. */
     44        s = set_add( &acc->set, "privacy_list", NULL, set_eval_privacy_list, acc );
    4645       
    4746        s = set_add( &acc->set, "resource", "BitlBee", NULL, acc );
     
    232231static void jabber_add_permit( struct gaim_connection *gc, char *who )
    233232{
    234         presence_send_request( gc, who, "subscribed" );
     233        struct jabber_data *jd = gc->proto_data;
     234       
     235        if( jd->flags & JFLAG_PRIVACY_BROKEN )
     236        {
     237                serv_got_crap( gc, "Privacy lists not supported by this server" );
     238                return;
     239        }
    235240}
    236241
    237242static void jabber_rem_permit( struct gaim_connection *gc, char *who )
    238243{
    239         presence_send_request( gc, who, "unsubscribed" );
     244        struct jabber_data *jd = gc->proto_data;
     245       
     246        if( jd->flags & JFLAG_PRIVACY_BROKEN )
     247        {
     248                serv_got_crap( gc, "Privacy lists not supported by this server" );
     249                return;
     250        }
    240251}
    241252
  • protocols/jabber/jabber.h

    r501b4e0 r995913b  
    3737        JFLAG_WAIT_SESSION = 8,         /* Set if we sent a <session> tag and need a reply before we continue. */
    3838        JFLAG_WAIT_BIND = 16,           /* ... for <bind> tag. */
     39        JFLAG_PRIVACY_BROKEN = 32,      /* Or just not supported, actually. */
    3940} jabber_flags_t;
    4041
     
    8384int jabber_get_privacy( struct gaim_connection *gc );
    8485int jabber_set_privacy( struct gaim_connection *gc, char *name );
     86char *set_eval_privacy_list( set_t *set, char *value );
    8587
    8688/* message.c */
Note: See TracChangeset for help on using the changeset viewer.