Changeset 090f1cb for protocols


Ignore:
Timestamp:
2006-10-07T13:01:02Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
36e9f62
Parents:
101d84f
Message:

Never mind about those privacy lists, they're horrible and not supported
by any client I know of. Also, they're already working on a (probably
completely incompatible) standard: JEP-191. Maybe BitlBee will implement
it too some day...

Location:
protocols/jabber
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    r101d84f r090f1cb  
    386386        if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
    387387        {
    388                 if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ) )
     388                if( !jabber_get_roster( gc ) )
    389389                        return XT_ABORT;
    390390        }
  • protocols/jabber/iq.c

    r101d84f r090f1cb  
    109109                account_online( gc );
    110110        }
    111         if( strcmp( type, "result" ) == 0 && xmlns && strcmp( xmlns, "jabber:iq:privacy" ) == 0 )
    112         {
    113                 struct xt_node *node;
    114                
    115                 /* When receiving a list of lists: */
    116                 if( ( node = xt_find_node( query->children, "active" ) ) )
    117                 {
    118                         if( ( s = xt_find_attr( node, "name" ) ) )
    119                         {
    120                                 set_t *set;
    121                                
    122                                 g_free( jd->privacy_active );
    123                                 jd->privacy_active = g_strdup( s );
    124                                
    125                                 /* Save it so the user can see it. */
    126                                 if( ( set = set_find( &gc->acc->set, "privacy_list" ) ) )
    127                                 {
    128                                         g_free( set->value );
    129                                         set->value = g_strdup( s );
    130                                 }
    131                                
    132                                 if( !jabber_get_privacy( gc ) )
    133                                         return XT_ABORT;
    134                         }
    135                 }
    136                 /* When receiving an actual list: */
    137                 else if( ( node = xt_find_node( query->children, "list" ) ) )
    138                 {
    139                         xt_free_node( jd->privacy_list );
    140                         jd->privacy_list = xt_dup( node );
    141                 }
    142                 else if( query->children == NULL )
    143                 {
    144                         /* What to do here if there is no privacy list defined yet... */
    145                 }
    146         }
    147111        else if( strcmp( type, "result" ) == 0 && orig )
    148112        {
     
    157121                           the old (non-SASL) way. */
    158122                        jd->flags |= JFLAG_AUTHENTICATED;
    159                         if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ) )
     123                        if( !jabber_get_roster( gc ) )
    160124                                return XT_ABORT;
    161125                }
     
    181145                        if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
    182146                        {
    183                                 if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ) )
     147                                if( !jabber_get_roster( gc ) )
    184148                                        return XT_ABORT;
    185149                        }
    186                 }
    187                 else if( ( c = xt_find_node( orig->children, "query" ) ) &&
    188                          ( c = xt_find_node( c->children, "active" ) ) )
    189                 {
    190                         /* We just successfully activated a (different)
    191                            privacy list. Fetch it now. */
    192                         g_free( jd->privacy_active );
    193                         jd->privacy_active = g_strdup( xt_find_attr( c, "name" ) );
    194                        
    195                         if( !jabber_get_privacy( gc ) )
    196                                 return XT_ABORT;
    197150                }
    198151        }
     
    209162                        return XT_ABORT;
    210163                }
    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                         }
    237                 }
    238164        }
    239165       
     
    316242        return st;
    317243}
    318 
    319 /* Request the privacy list from the server. We need this, because every
    320    time we remove/add something we have to send the whole new list to the
    321    server again... If no privacy list is specified yet, this function will
    322    first ask for the list of lists (XMPP supports multiple "privacy lists",
    323    don't ask me why), later we can then fetch the list we want to use. */
    324 int jabber_get_privacy( struct gaim_connection *gc )
    325 {
    326         struct jabber_data *jd = gc->proto_data;
    327         struct xt_node *node = NULL;
    328         char *name;
    329         int st;
    330        
    331         if( jd->privacy_active )
    332         {
    333                 /* If we know what is the active list right now, fetch it. */
    334                 node = xt_new_node( "list", NULL, NULL );
    335                 xt_add_attr( node, "name", jd->privacy_active );
    336         }
    337         /* Okay, we don't know yet. If the user set a specific list, we'll
    338            activate that one. Otherwise, we should figure out which list is
    339            currently active. */
    340         else if( ( name = set_getstr( &gc->acc->set, "privacy_list" ) ) )
    341         {
    342                 return jabber_set_privacy( gc, name );
    343         }
    344         /* else: sending this packet without a <list/> element will give
    345            a list of available lists and information about the currently
    346            active list. */
    347        
    348         node = xt_new_node( "query", NULL, node );
    349         xt_add_attr( node, "xmlns", "jabber:iq:privacy" );
    350         node = jabber_make_packet( "iq", "get", NULL, node );
    351        
    352         jabber_cache_packet( gc, node );
    353         st = jabber_write_packet( gc, node );
    354        
    355         return st;
    356 }
    357 
    358 int jabber_set_privacy( struct gaim_connection *gc, char *name )
    359 {
    360         struct xt_node *node;
    361        
    362         node = xt_new_node( "active", NULL, NULL );
    363         xt_add_attr( node, "name", name );
    364         node = xt_new_node( "query", NULL, node );
    365         xt_add_attr( node, "xmlns", "jabber:iq:privacy" );
    366        
    367         node = jabber_make_packet( "iq", "set", NULL, node );
    368         jabber_cache_packet( gc, node );
    369        
    370         return jabber_write_packet( gc, node );
    371 }
    372 
    373 char *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

    r101d84f r090f1cb  
    4242        s = set_add( &acc->set, "priority", "0", set_eval_priority, acc );
    4343       
    44         s = set_add( &acc->set, "privacy_list", NULL, set_eval_privacy_list, acc );
    45        
    4644        s = set_add( &acc->set, "resource", "BitlBee", NULL, acc );
    4745        s->flags |= ACC_SET_OFFLINE_ONLY;
     
    110108        if( jd->tx_len )
    111109                g_free( jd->txq );
    112        
    113         xt_free_node( jd->privacy_list );
    114         g_free( jd->privacy_active );
    115110       
    116111        xt_free_node( jd->node_cache );
     
    227222                c->flags |= XT_SEEN;
    228223        }
    229 }
    230 
    231 static void jabber_add_permit( struct gaim_connection *gc, char *who )
    232 {
    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         }
    240 }
    241 
    242 static void jabber_rem_permit( struct gaim_connection *gc, char *who )
    243 {
    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         }
    251 }
    252 
    253 /* XMPP doesn't have both a block- and and allow-list, so these two functions
    254    will be no-ops: */
    255 static void jabber_add_deny( struct gaim_connection *gc, char *who )
    256 {
    257 }
    258 
    259 static void jabber_rem_deny( struct gaim_connection *gc, char *who )
    260 {
    261224}
    262225
     
    282245//      ret->chat_open = jabber_chat_open;
    283246        ret->keepalive = jabber_keepalive;
    284         ret->add_permit = jabber_add_permit;
    285         ret->rem_permit = jabber_rem_permit;
    286         ret->add_deny = jabber_add_deny;
    287         ret->rem_deny = jabber_rem_deny;
    288247//      ret->send_typing = jabber_send_typing;
    289248        ret->handle_cmp = g_strcasecmp;
  • protocols/jabber/jabber.h

    r101d84f r090f1cb  
    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. */
    4039} jabber_flags_t;
    4140
     
    6160        char *away_message;
    6261       
    63         /* Updates to this one should be synchronized using jabber_privacy_update(). */
    64         struct xt_node *privacy_list;
    65         char *privacy_active;
    66        
    6762        struct xt_node *node_cache;
    6863};
     
    7469};
    7570
    76 #define DEFAULT_PRIVACY_LIST "simple_blocklist"
    77 
    7871/* iq.c */
    7972xt_status jabber_pkt_iq( struct xt_node *node, gpointer data );
     
    8275int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name );
    8376int jabber_remove_from_roster( struct gaim_connection *gc, char *handle );
    84 int jabber_get_privacy( struct gaim_connection *gc );
    85 int jabber_set_privacy( struct gaim_connection *gc, char *name );
    86 char *set_eval_privacy_list( set_t *set, char *value );
    8777
    8878/* message.c */
  • protocols/jabber/xmltree.c

    r101d84f r090f1cb  
    528528        int i;
    529529       
    530         for( i = 0; node->attr[i].key; i ++ );
    531         node->attr = g_renew( struct xt_attr, node->attr, i + 2 );
    532         node->attr[i].key = g_strdup( key );
     530        /* Now actually it'd be nice if we can also change existing attributes
     531           (which actually means this function doesn't have the right name).
     532           So let's find out if we have this attribute already... */
     533        for( i = 0; node->attr[i].key; i ++ )
     534                if( strcmp( node->attr[i].key, key ) == 0 )
     535                        break;
     536       
     537        if( node->attr[i].key == NULL )
     538        {
     539                /* If not, allocate space for a new attribute. */
     540                node->attr = g_renew( struct xt_attr, node->attr, i + 2 );
     541                node->attr[i].key = g_strdup( key );
     542                node->attr[i+1].key = NULL;
     543        }
     544        else
     545        {
     546                /* Otherwise, free the old value before setting the new one. */
     547                g_free( node->attr[i].value );
     548        }
     549       
    533550        node->attr[i].value = g_strdup( value );
    534         node->attr[i+1].key = NULL;
    535 }
     551}
Note: See TracChangeset for help on using the changeset viewer.