Changeset 090f1cb for protocols/jabber
- Timestamp:
- 2006-10-07T13:01:02Z (18 years ago)
- Branches:
- master
- Children:
- 36e9f62
- Parents:
- 101d84f
- Location:
- protocols/jabber
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/io.c
r101d84f r090f1cb 386 386 if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) 387 387 { 388 if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ))388 if( !jabber_get_roster( gc ) ) 389 389 return XT_ABORT; 390 390 } -
protocols/jabber/iq.c
r101d84f r090f1cb 109 109 account_online( gc ); 110 110 } 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 }147 111 else if( strcmp( type, "result" ) == 0 && orig ) 148 112 { … … 157 121 the old (non-SASL) way. */ 158 122 jd->flags |= JFLAG_AUTHENTICATED; 159 if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ))123 if( !jabber_get_roster( gc ) ) 160 124 return XT_ABORT; 161 125 } … … 181 145 if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) 182 146 { 183 if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ))147 if( !jabber_get_roster( gc ) ) 184 148 return XT_ABORT; 185 149 } 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;197 150 } 198 151 } … … 209 162 return XT_ABORT; 210 163 } 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 use235 the block/allow commands. */236 }237 }238 164 } 239 165 … … 316 242 return st; 317 243 } 318 319 /* Request the privacy list from the server. We need this, because every320 time we remove/add something we have to send the whole new list to the321 server again... If no privacy list is specified yet, this function will322 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'll338 activate that one. Otherwise, we should figure out which list is339 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 give345 a list of available lists and information about the currently346 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 the385 chosen list is valid. If we're off-line, just accept it and we'll386 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 42 42 s = set_add( &acc->set, "priority", "0", set_eval_priority, acc ); 43 43 44 s = set_add( &acc->set, "privacy_list", NULL, set_eval_privacy_list, acc );45 46 44 s = set_add( &acc->set, "resource", "BitlBee", NULL, acc ); 47 45 s->flags |= ACC_SET_OFFLINE_ONLY; … … 110 108 if( jd->tx_len ) 111 109 g_free( jd->txq ); 112 113 xt_free_node( jd->privacy_list );114 g_free( jd->privacy_active );115 110 116 111 xt_free_node( jd->node_cache ); … … 227 222 c->flags |= XT_SEEN; 228 223 } 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 functions254 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 {261 224 } 262 225 … … 282 245 // ret->chat_open = jabber_chat_open; 283 246 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;288 247 // ret->send_typing = jabber_send_typing; 289 248 ret->handle_cmp = g_strcasecmp; -
protocols/jabber/jabber.h
r101d84f r090f1cb 37 37 JFLAG_WAIT_SESSION = 8, /* Set if we sent a <session> tag and need a reply before we continue. */ 38 38 JFLAG_WAIT_BIND = 16, /* ... for <bind> tag. */ 39 JFLAG_PRIVACY_BROKEN = 32, /* Or just not supported, actually. */40 39 } jabber_flags_t; 41 40 … … 61 60 char *away_message; 62 61 63 /* Updates to this one should be synchronized using jabber_privacy_update(). */64 struct xt_node *privacy_list;65 char *privacy_active;66 67 62 struct xt_node *node_cache; 68 63 }; … … 74 69 }; 75 70 76 #define DEFAULT_PRIVACY_LIST "simple_blocklist"77 78 71 /* iq.c */ 79 72 xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ); … … 82 75 int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name ); 83 76 int 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 );87 77 88 78 /* message.c */ -
protocols/jabber/xmltree.c
r101d84f r090f1cb 528 528 int i; 529 529 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 533 550 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.