- Timestamp:
- 2006-10-01T09:31:41Z (18 years ago)
- Branches:
- master
- Children:
- 0e2d97f
- Parents:
- 022df46
- Location:
- protocols/jabber
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/io.c
r022df46 r6baca2a 335 335 if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) 336 336 { 337 if( !jabber_get_roster( gc ) )337 if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ) ) 338 338 return XT_ABORT; 339 339 } -
protocols/jabber/iq.c
r022df46 r6baca2a 28 28 struct gaim_connection *gc = data; 29 29 struct jabber_data *jd = gc->proto_data; 30 struct xt_node *query, *reply = NULL, *orig = NULL ;30 struct xt_node *query, *reply = NULL, *orig = NULL, *c; 31 31 char *s, *type, *xmlns; 32 32 int st; … … 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 } 111 147 else if( strcmp( type, "result" ) == 0 && orig ) 112 148 { 113 149 struct xt_node *c; 114 115 150 if( !( jd->flags & JFLAG_AUTHENTICATED ) && 116 151 ( c = xt_find_node( orig->children, "query" ) ) && … … 121 156 the old (non-SASL) way. */ 122 157 jd->flags |= JFLAG_AUTHENTICATED; 123 if( !jabber_get_roster( gc ) )158 if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ) ) 124 159 return XT_ABORT; 125 160 } … … 145 180 if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) 146 181 { 147 if( !jabber_get_roster( gc ) )182 if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ) ) 148 183 return XT_ABORT; 149 184 } 150 185 } 186 else if( ( c = xt_find_node( orig->children, "query" ) ) && 187 ( c = xt_find_node( c->children, "active" ) ) ) 188 { 189 /* We just successfully activated a (different) 190 privacy list. Fetch it now. */ 191 g_free( jd->privacy_active ); 192 jd->privacy_active = g_strdup( xt_find_attr( c, "name" ) ); 193 194 if( !jabber_get_privacy( gc ) ) 195 return XT_ABORT; 196 } 151 197 } 152 198 else if( strcmp( type, "error" ) == 0 ) 153 199 { 154 if( !( jd->flags & JFLAG_AUTHENTICATED ) ) 200 if( !( jd->flags & JFLAG_AUTHENTICATED ) && 201 ( c = xt_find_node( orig->children, "query" ) ) && 202 ( c = xt_find_node( c->children, "username" ) ) && 203 c->text_len ) 155 204 { 156 205 hide_login_progress( gc, "Authentication failure" ); 157 206 signoff( gc ); 158 207 return XT_ABORT; 208 } 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" ); 159 214 } 160 215 } … … 238 293 return st; 239 294 } 295 296 /* Request the privacy list from the server. We need this, because every 297 time we remove/add something we have to send the whole new list to the 298 server again... If no privacy list is specified yet, this function will 299 first ask for the list of lists (XMPP supports multiple "privacy lists", 300 don't ask me why), later we can then fetch the list we want to use. */ 301 int jabber_get_privacy( struct gaim_connection *gc ) 302 { 303 struct jabber_data *jd = gc->proto_data; 304 struct xt_node *node = NULL; 305 char *name; 306 int st; 307 308 if( jd->privacy_active ) 309 { 310 /* If we know what is the active list right now, fetch it. */ 311 node = xt_new_node( "list", NULL, NULL ); 312 xt_add_attr( node, "name", jd->privacy_active ); 313 } 314 /* Okay, we don't know yet. If the user set a specific list, we'll 315 activate that one. Otherwise, we should figure out which list is 316 currently active. */ 317 else if( ( name = set_getstr( &gc->acc->set, "privacy_list" ) ) ) 318 { 319 return jabber_set_privacy( gc, name ); 320 } 321 /* else: sending this packet without a <list/> element will give 322 a list of available lists and information about the currently 323 active list. */ 324 325 node = xt_new_node( "query", NULL, node ); 326 xt_add_attr( node, "xmlns", "jabber:iq:privacy" ); 327 node = jabber_make_packet( "iq", "get", NULL, node ); 328 329 st = jabber_write_packet( gc, node ); 330 331 xt_free_node( node ); 332 return st; 333 } 334 335 int jabber_set_privacy( struct gaim_connection *gc, char *name ) 336 { 337 struct xt_node *node; 338 339 node = xt_new_node( "active", NULL, NULL ); 340 xt_add_attr( node, "name", name ); 341 node = xt_new_node( "query", NULL, node ); 342 xt_add_attr( node, "xmlns", "jabber:iq:privacy" ); 343 344 node = jabber_make_packet( "iq", "set", NULL, node ); 345 jabber_cache_packet( gc, node ); 346 347 return jabber_write_packet( gc, node ); 348 } -
protocols/jabber/jabber.c
r022df46 r6baca2a 42 42 s = set_add( &acc->set, "priority", "0", set_eval_priority, acc ); 43 43 44 s = set_add( &acc->set, "privacy_list", NULL, NULL, acc ); 45 /* TODO: Add evaluator. */ 46 44 47 s = set_add( &acc->set, "resource", "BitlBee", NULL, acc ); 45 48 s->flags |= ACC_SET_OFFLINE_ONLY; … … 81 84 if( set_getbool( &acc->set, "ssl" ) ) 82 85 { 83 jd->ssl = ssl_connect( jd->server, set_getint( &acc->set, "port" ), jabber_connected_ssl, gc );86 jd->ssl = ssl_connect( acc->server ? acc->server : jd->server, set_getint( &acc->set, "port" ), jabber_connected_ssl, gc ); 84 87 jd->fd = ssl_getfd( jd->ssl ); 85 88 } 86 89 else 87 90 { 88 jd->fd = proxy_connect( jd->server, set_getint( &acc->set, "port" ), jabber_connected_plain, gc );91 jd->fd = proxy_connect( acc->server ? acc->server : jd->server, set_getint( &acc->set, "port" ), jabber_connected_plain, gc ); 89 92 } 90 93 } … … 108 111 if( jd->tx_len ) 109 112 g_free( jd->txq ); 113 114 xt_free_node( jd->privacy_list ); 115 g_free( jd->privacy_active ); 110 116 111 117 xt_free_node( jd->node_cache ); -
protocols/jabber/jabber.h
r022df46 r6baca2a 60 60 char *away_message; 61 61 62 /* Updates to this one should be synchronized using jabber_privacy_update(). */ 63 struct xt_node *privacy_list; 64 char *privacy_active; 65 62 66 struct xt_node *node_cache; 63 67 }; … … 69 73 }; 70 74 75 #define DEFAULT_PRIVACY_LIST "simple_blocklist" 76 71 77 /* iq.c */ 72 78 xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ); … … 75 81 int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name ); 76 82 int jabber_remove_from_roster( struct gaim_connection *gc, char *handle ); 83 int jabber_get_privacy( struct gaim_connection *gc ); 84 int jabber_set_privacy( struct gaim_connection *gc, char *name ); 77 85 78 86 /* message.c */
Note: See TracChangeset
for help on using the changeset viewer.