Changeset 090f1cb for protocols/jabber/iq.c
- Timestamp:
- 2006-10-07T13:01:02Z (18 years ago)
- Branches:
- master
- Children:
- 36e9f62
- Parents:
- 101d84f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.