Changeset 0da65d5 for protocols/jabber
- Timestamp:
- 2007-03-31T05:40:45Z (18 years ago)
- Branches:
- master
- Children:
- aef4828
- Parents:
- fa29d093
- Location:
- protocols/jabber
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/io.c
rfa29d093 r0da65d5 26 26 27 27 static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond ); 28 static gboolean jabber_write_queue( struct gaim_connection *gc );29 30 int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node )28 static gboolean jabber_write_queue( struct im_connection *ic ); 29 30 int jabber_write_packet( struct im_connection *ic, struct xt_node *node ) 31 31 { 32 32 char *buf; … … 34 34 35 35 buf = xt_to_string( node ); 36 st = jabber_write( gc, buf, strlen( buf ) );36 st = jabber_write( ic, buf, strlen( buf ) ); 37 37 g_free( buf ); 38 38 … … 40 40 } 41 41 42 int jabber_write( struct gaim_connection *gc, char *buf, int len )43 { 44 struct jabber_data *jd = gc->proto_data;42 int jabber_write( struct im_connection *ic, char *buf, int len ) 43 { 44 struct jabber_data *jd = ic->proto_data; 45 45 gboolean ret; 46 46 … … 54 54 it via the event handler. If not, add the handler. (In 55 55 most cases it probably won't be necessary.) */ 56 if( ( ret = jabber_write_queue( gc ) ) && jd->tx_len > 0 )57 jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, gc );56 if( ( ret = jabber_write_queue( ic ) ) && jd->tx_len > 0 ) 57 jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, ic ); 58 58 } 59 59 else … … 85 85 static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond ) 86 86 { 87 struct jabber_data *jd = ((struct gaim_connection *)data)->proto_data;87 struct jabber_data *jd = ((struct im_connection *)data)->proto_data; 88 88 89 89 return jd->fd != -1 && … … 92 92 } 93 93 94 static gboolean jabber_write_queue( struct gaim_connection *gc )95 { 96 struct jabber_data *jd = gc->proto_data;94 static gboolean jabber_write_queue( struct im_connection *ic ) 95 { 96 struct jabber_data *jd = ic->proto_data; 97 97 int st; 98 98 … … 117 117 jd->fd = -1; 118 118 119 hide_login_progress_error( gc, "Short write() to server" );120 signoff( gc );119 hide_login_progress_error( ic, "Short write() to server" ); 120 signoff( ic ); 121 121 return FALSE; 122 122 } … … 142 142 static gboolean jabber_read_callback( gpointer data, gint fd, b_input_condition cond ) 143 143 { 144 struct gaim_connection *gc = data;145 struct jabber_data *jd = gc->proto_data;144 struct im_connection *ic = data; 145 struct jabber_data *jd = ic->proto_data; 146 146 char buf[512]; 147 147 int st; … … 160 160 if( xt_feed( jd->xt, buf, st ) < 0 ) 161 161 { 162 hide_login_progress_error( gc, "XML stream error" );163 signoff( gc );162 hide_login_progress_error( ic, "XML stream error" ); 163 signoff( ic ); 164 164 return FALSE; 165 165 } … … 176 176 { 177 177 jd->flags &= ~JFLAG_STREAM_RESTART; 178 jabber_start_stream( gc );178 jabber_start_stream( ic ); 179 179 } 180 180 … … 196 196 this is an old server that can't do SASL 197 197 authentication. */ 198 if( !sasl_supported( gc ) )198 if( !sasl_supported( ic ) ) 199 199 { 200 200 /* If there's no version= tag, we suppose 201 201 this server does NOT implement: XMPP 1.0, 202 202 SASL and TLS. */ 203 if( set_getbool( & gc->acc->set, "tls" ) )203 if( set_getbool( &ic->acc->set, "tls" ) ) 204 204 { 205 hide_login_progress( gc, "TLS is turned on for this "205 hide_login_progress( ic, "TLS is turned on for this " 206 206 "account, but is not supported by this server" ); 207 signoff( gc );207 signoff( ic ); 208 208 return FALSE; 209 209 } 210 210 else 211 211 { 212 return jabber_init_iq_auth( gc );212 return jabber_init_iq_auth( ic ); 213 213 } 214 214 } … … 216 216 else 217 217 { 218 hide_login_progress( gc, "XML stream error" );219 signoff( gc );218 hide_login_progress( ic, "XML stream error" ); 219 signoff( ic ); 220 220 return FALSE; 221 221 } … … 227 227 jd->fd = -1; 228 228 229 hide_login_progress_error( gc, "Error while reading from server" );230 signoff( gc );229 hide_login_progress_error( ic, "Error while reading from server" ); 230 signoff( ic ); 231 231 return FALSE; 232 232 } … … 238 238 gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond ) 239 239 { 240 struct gaim_connection *gc = data;240 struct im_connection *ic = data; 241 241 242 242 if( source == -1 ) 243 243 { 244 hide_login_progress( gc, "Could not connect to server" );245 signoff( gc );244 hide_login_progress( ic, "Could not connect to server" ); 245 signoff( ic ); 246 246 return FALSE; 247 247 } 248 248 249 set_login_progress( gc, 1, "Connected to server, logging in" );250 251 return jabber_start_stream( gc );249 set_login_progress( ic, 1, "Connected to server, logging in" ); 250 251 return jabber_start_stream( ic ); 252 252 } 253 253 254 254 gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond ) 255 255 { 256 struct gaim_connection *gc = data;257 struct jabber_data *jd = gc->proto_data;256 struct im_connection *ic = data; 257 struct jabber_data *jd = ic->proto_data; 258 258 259 259 if( source == NULL ) … … 263 263 jd->ssl = NULL; 264 264 265 hide_login_progress( gc, "Could not connect to server" );266 signoff( gc );265 hide_login_progress( ic, "Could not connect to server" ); 266 signoff( ic ); 267 267 return FALSE; 268 268 } 269 269 270 set_login_progress( gc, 1, "Connected to server, logging in" );271 272 return jabber_start_stream( gc );270 set_login_progress( ic, 1, "Connected to server, logging in" ); 271 272 return jabber_start_stream( ic ); 273 273 } 274 274 … … 281 281 static xt_status jabber_pkt_features( struct xt_node *node, gpointer data ) 282 282 { 283 struct gaim_connection *gc = data;284 struct jabber_data *jd = gc->proto_data;283 struct im_connection *ic = data; 284 struct jabber_data *jd = ic->proto_data; 285 285 struct xt_node *c, *reply; 286 286 int trytls; 287 287 288 trytls = g_strcasecmp( set_getstr( & gc->acc->set, "tls" ), "try" ) == 0;288 trytls = g_strcasecmp( set_getstr( &ic->acc->set, "tls" ), "try" ) == 0; 289 289 c = xt_find_node( node->children, "starttls" ); 290 290 if( c && !jd->ssl ) … … 295 295 c = xt_find_node( c->children, "required" ); 296 296 297 if( c && ( !trytls && !set_getbool( & gc->acc->set, "tls" ) ) )298 { 299 hide_login_progress( gc, "Server requires TLS connections, but TLS is turned off for this account" );300 signoff( gc );297 if( c && ( !trytls && !set_getbool( &ic->acc->set, "tls" ) ) ) 298 { 299 hide_login_progress( ic, "Server requires TLS connections, but TLS is turned off for this account" ); 300 signoff( ic ); 301 301 302 302 return XT_ABORT; … … 304 304 305 305 /* Only run this if the tls setting is set to true or try: */ 306 if( ( trytls || set_getbool( & gc->acc->set, "tls" ) ) )306 if( ( trytls || set_getbool( &ic->acc->set, "tls" ) ) ) 307 307 { 308 308 reply = xt_new_node( "starttls", NULL, NULL ); 309 309 xt_add_attr( reply, "xmlns", XMLNS_TLS ); 310 if( !jabber_write_packet( gc, reply ) )310 if( !jabber_write_packet( ic, reply ) ) 311 311 { 312 312 xt_free_node( reply ); … … 325 325 using SSL/TLS. */ 326 326 327 if( !trytls && set_getbool( & gc->acc->set, "tls" ) )328 { 329 hide_login_progress( gc, "TLS is turned on for this account, but is not supported by this server" );330 signoff( gc );327 if( !trytls && set_getbool( &ic->acc->set, "tls" ) ) 328 { 329 hide_login_progress( ic, "TLS is turned on for this account, but is not supported by this server" ); 330 signoff( ic ); 331 331 332 332 return XT_ABORT; … … 346 346 other way. jabber.com doesn't seem to do SASL while it pretends 347 347 to be XMPP 1.0 compliant! */ 348 else if( !( jd->flags & JFLAG_AUTHENTICATED ) && sasl_supported( gc ) )349 { 350 if( !jabber_init_iq_auth( gc ) )348 else if( !( jd->flags & JFLAG_AUTHENTICATED ) && sasl_supported( ic ) ) 349 { 350 if( !jabber_init_iq_auth( ic ) ) 351 351 return XT_ABORT; 352 352 } … … 354 354 if( ( c = xt_find_node( node->children, "bind" ) ) ) 355 355 { 356 reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( & gc->acc->set, "resource" ), NULL ) );356 reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); 357 357 xt_add_attr( reply, "xmlns", XMLNS_BIND ); 358 358 reply = jabber_make_packet( "iq", "set", NULL, reply ); 359 jabber_cache_add( gc, reply, jabber_pkt_bind_sess );360 361 if( !jabber_write_packet( gc, reply ) )359 jabber_cache_add( ic, reply, jabber_pkt_bind_sess ); 360 361 if( !jabber_write_packet( ic, reply ) ) 362 362 return XT_ABORT; 363 363 … … 370 370 xt_add_attr( reply, "xmlns", XMLNS_SESSION ); 371 371 reply = jabber_make_packet( "iq", "set", NULL, reply ); 372 jabber_cache_add( gc, reply, jabber_pkt_bind_sess );373 374 if( !jabber_write_packet( gc, reply ) )372 jabber_cache_add( ic, reply, jabber_pkt_bind_sess ); 373 374 if( !jabber_write_packet( ic, reply ) ) 375 375 return XT_ABORT; 376 376 … … 383 383 if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) 384 384 { 385 if( !jabber_get_roster( gc ) )385 if( !jabber_get_roster( ic ) ) 386 386 return XT_ABORT; 387 387 } … … 392 392 static xt_status jabber_pkt_proceed_tls( struct xt_node *node, gpointer data ) 393 393 { 394 struct gaim_connection *gc = data;395 struct jabber_data *jd = gc->proto_data;394 struct im_connection *ic = data; 395 struct jabber_data *jd = ic->proto_data; 396 396 char *xmlns; 397 397 … … 417 417 jd->w_inpa = jd->r_inpa = 0; 418 418 419 set_login_progress( gc, 1, "Converting stream to TLS" );420 421 jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, gc );419 set_login_progress( ic, 1, "Converting stream to TLS" ); 420 421 jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, ic ); 422 422 423 423 return XT_HANDLED; … … 426 426 static xt_status jabber_pkt_stream_error( struct xt_node *node, gpointer data ) 427 427 { 428 struct gaim_connection *gc = data;428 struct im_connection *ic = data; 429 429 struct xt_node *c; 430 430 char *s, *type = NULL, *text = NULL; … … 452 452 if( type == NULL ) 453 453 { 454 hide_login_progress_error( gc, "Unknown stream error reported by server" );455 signoff( gc );454 hide_login_progress_error( ic, "Unknown stream error reported by server" ); 455 signoff( ic ); 456 456 return XT_ABORT; 457 457 } … … 462 462 if( strcmp( type, "conflict" ) == 0 ) 463 463 { 464 hide_login_progress( gc, "Account and resource used from a different location" );465 gc->wants_to_die = TRUE;464 hide_login_progress( ic, "Account and resource used from a different location" ); 465 ic->wants_to_die = TRUE; 466 466 } 467 467 else 468 468 { 469 469 s = g_strdup_printf( "Stream error: %s%s%s", type, text ? ": " : "", text ? text : "" ); 470 hide_login_progress_error( gc, s );470 hide_login_progress_error( ic, s ); 471 471 g_free( s ); 472 472 } 473 473 474 signoff( gc );474 signoff( ic ); 475 475 476 476 return XT_ABORT; … … 500 500 }; 501 501 502 gboolean jabber_start_stream( struct gaim_connection *gc )503 { 504 struct jabber_data *jd = gc->proto_data;502 gboolean jabber_start_stream( struct im_connection *ic ) 503 { 504 struct jabber_data *jd = ic->proto_data; 505 505 int st; 506 506 char *greet; … … 509 509 from the server too. */ 510 510 xt_free( jd->xt ); /* In case we're RE-starting. */ 511 jd->xt = xt_new( gc );511 jd->xt = xt_new( ic ); 512 512 jd->xt->handlers = (struct xt_handler_entry*) jabber_handlers; 513 513 514 514 if( jd->r_inpa <= 0 ) 515 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, gc );515 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, ic ); 516 516 517 517 greet = g_strdup_printf( "<?xml version='1.0' ?>" … … 519 519 "xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">", jd->server ); 520 520 521 st = jabber_write( gc, greet, strlen( greet ) );521 st = jabber_write( ic, greet, strlen( greet ) ); 522 522 523 523 g_free( greet ); … … 526 526 } 527 527 528 void jabber_end_stream( struct gaim_connection *gc )529 { 530 struct jabber_data *jd = gc->proto_data;528 void jabber_end_stream( struct im_connection *ic ) 529 { 530 struct jabber_data *jd = ic->proto_data; 531 531 532 532 /* Let's only do this if the queue is currently empty, otherwise it'd … … 538 538 int st = 1; 539 539 540 if( gc->flags & OPT_LOGGED_IN )540 if( ic->flags & OPT_LOGGED_IN ) 541 541 { 542 542 node = jabber_make_packet( "presence", "unavailable", NULL, NULL ); 543 st = jabber_write_packet( gc, node );543 st = jabber_write_packet( ic, node ); 544 544 xt_free_node( node ); 545 545 } 546 546 547 547 if( st ) 548 jabber_write( gc, eos, strlen( eos ) );549 } 550 } 548 jabber_write( ic, eos, strlen( eos ) ); 549 } 550 } -
protocols/jabber/iq.c
rfa29d093 r0da65d5 24 24 #include "jabber.h" 25 25 26 static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );27 static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );26 static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 27 static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 28 28 29 29 xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) 30 30 { 31 struct gaim_connection *gc = data;32 struct jabber_data *jd = gc->proto_data;31 struct im_connection *ic = data; 32 struct jabber_data *jd = ic->proto_data; 33 33 struct xt_node *c, *reply = NULL; 34 34 char *type, *s; … … 39 39 if( !type ) 40 40 { 41 hide_login_progress_error( gc, "Received IQ packet without type." );42 signoff( gc );41 hide_login_progress_error( ic, "Received IQ packet without type." ); 42 signoff( ic ); 43 43 return XT_ABORT; 44 44 } … … 60 60 61 61 if( entry == NULL ) 62 serv_got_crap( gc, "WARNING: Received IQ-%s packet with unknown/expired ID %s!", type, s );62 serv_got_crap( ic, "WARNING: Received IQ-%s packet with unknown/expired ID %s!", type, s ); 63 63 else if( entry->func ) 64 return entry->func( gc, node, entry->node );64 return entry->func( ic, node, entry->node ); 65 65 } 66 66 else if( strcmp( type, "get" ) == 0 ) … … 69 69 !( s = xt_find_attr( c, "xmlns" ) ) ) 70 70 { 71 serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type );71 serv_got_crap( ic, "WARNING: Received incomplete IQ-%s packet", type ); 72 72 return XT_HANDLED; 73 73 } … … 132 132 !( s = xt_find_attr( c, "xmlns" ) ) ) 133 133 { 134 serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type );134 serv_got_crap( ic, "WARNING: Received incomplete IQ-%s packet", type ); 135 135 return XT_HANDLED; 136 136 } … … 141 141 if( strcmp( s, XMLNS_ROSTER ) == 0 ) 142 142 { 143 int bare_len = strlen( gc->acc->user );143 int bare_len = strlen( ic->acc->user ); 144 144 145 145 if( ( s = xt_find_attr( node, "from" ) ) == NULL || 146 ( strncmp( s, gc->acc->user, bare_len ) == 0 &&146 ( strncmp( s, ic->acc->user, bare_len ) == 0 && 147 147 ( s[bare_len] == 0 || s[bare_len] == '/' ) ) ) 148 148 { 149 jabber_parse_roster( gc, node, NULL );149 jabber_parse_roster( ic, node, NULL ); 150 150 151 151 /* Should we generate a reply here? Don't think it's … … 154 154 else 155 155 { 156 serv_got_crap( gc, "WARNING: %s tried to fake a roster push!", s ? s : "(unknown)" );156 serv_got_crap( ic, "WARNING: %s tried to fake a roster push!", s ? s : "(unknown)" ); 157 157 158 158 xt_free_node( reply ); … … 182 182 } 183 183 184 st = jabber_write_packet( gc, reply );184 st = jabber_write_packet( ic, reply ); 185 185 xt_free_node( reply ); 186 186 if( !st ) … … 191 191 } 192 192 193 static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );194 static xt_status jabber_finish_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );195 196 int jabber_init_iq_auth( struct gaim_connection *gc )197 { 198 struct jabber_data *jd = gc->proto_data;193 static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 194 static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 195 196 int jabber_init_iq_auth( struct im_connection *ic ) 197 { 198 struct jabber_data *jd = ic->proto_data; 199 199 struct xt_node *node; 200 200 int st; … … 204 204 node = jabber_make_packet( "iq", "get", NULL, node ); 205 205 206 jabber_cache_add( gc, node, jabber_do_iq_auth );207 st = jabber_write_packet( gc, node );206 jabber_cache_add( ic, node, jabber_do_iq_auth ); 207 st = jabber_write_packet( ic, node ); 208 208 209 209 return st; 210 210 } 211 211 212 static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )213 { 214 struct jabber_data *jd = gc->proto_data;212 static xt_status jabber_do_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 213 { 214 struct jabber_data *jd = ic->proto_data; 215 215 struct xt_node *reply, *query; 216 216 xt_status st; … … 219 219 if( !( query = xt_find_node( node->children, "query" ) ) ) 220 220 { 221 serv_got_crap( gc, "WARNING: Received incomplete IQ packet while authenticating" );222 signoff( gc );221 serv_got_crap( ic, "WARNING: Received incomplete IQ packet while authenticating" ); 222 signoff( ic ); 223 223 return XT_HANDLED; 224 224 } … … 228 228 xt_add_attr( reply, "xmlns", XMLNS_AUTH ); 229 229 xt_add_child( reply, xt_new_node( "username", jd->username, NULL ) ); 230 xt_add_child( reply, xt_new_node( "resource", set_getstr( & gc->acc->set, "resource" ), NULL ) );230 xt_add_child( reply, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); 231 231 232 232 if( xt_find_node( query->children, "digest" ) && ( s = xt_find_attr( jd->xt->root, "id" ) ) ) … … 241 241 shaInit( &sha ); 242 242 shaUpdate( &sha, (unsigned char*) s, strlen( s ) ); 243 shaUpdate( &sha, (unsigned char*) gc->acc->pass, strlen( gc->acc->pass ) );243 shaUpdate( &sha, (unsigned char*) ic->acc->pass, strlen( ic->acc->pass ) ); 244 244 shaFinal( &sha, hash ); 245 245 … … 252 252 { 253 253 /* We'll have to stick with plaintext. Let's hope we're using SSL/TLS... */ 254 xt_add_child( reply, xt_new_node( "password", gc->acc->pass, NULL ) );254 xt_add_child( reply, xt_new_node( "password", ic->acc->pass, NULL ) ); 255 255 } 256 256 else … … 258 258 xt_free_node( reply ); 259 259 260 hide_login_progress( gc, "Can't find suitable authentication method" );261 signoff( gc );260 hide_login_progress( ic, "Can't find suitable authentication method" ); 261 signoff( ic ); 262 262 return XT_ABORT; 263 263 } 264 264 265 265 reply = jabber_make_packet( "iq", "set", NULL, reply ); 266 jabber_cache_add( gc, reply, jabber_finish_iq_auth );267 st = jabber_write_packet( gc, reply );266 jabber_cache_add( ic, reply, jabber_finish_iq_auth ); 267 st = jabber_write_packet( ic, reply ); 268 268 269 269 return st ? XT_HANDLED : XT_ABORT; 270 270 } 271 271 272 static xt_status jabber_finish_iq_auth( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )273 { 274 struct jabber_data *jd = gc->proto_data;272 static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 273 { 274 struct jabber_data *jd = ic->proto_data; 275 275 char *type; 276 276 277 277 if( !( type = xt_find_attr( node, "type" ) ) ) 278 278 { 279 serv_got_crap( gc, "WARNING: Received incomplete IQ packet while authenticating" );280 signoff( gc );279 serv_got_crap( ic, "WARNING: Received incomplete IQ packet while authenticating" ); 280 signoff( ic ); 281 281 return XT_HANDLED; 282 282 } … … 284 284 if( strcmp( type, "error" ) == 0 ) 285 285 { 286 hide_login_progress( gc, "Authentication failure" );287 signoff( gc );286 hide_login_progress( ic, "Authentication failure" ); 287 signoff( ic ); 288 288 return XT_ABORT; 289 289 } … … 293 293 old (non-SASL) way. */ 294 294 jd->flags |= JFLAG_AUTHENTICATED; 295 if( !jabber_get_roster( gc ) )295 if( !jabber_get_roster( ic ) ) 296 296 return XT_ABORT; 297 297 } … … 300 300 } 301 301 302 xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )303 { 304 struct jabber_data *jd = gc->proto_data;302 xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 303 { 304 struct jabber_data *jd = ic->proto_data; 305 305 struct xt_node *c; 306 306 char *s; … … 310 310 c = xt_find_node( c->children, "jid" ); 311 311 if( c && c->text_len && ( s = strchr( c->text, '/' ) ) && 312 strcmp( s + 1, set_getstr( & gc->acc->set, "resource" ) ) != 0 )313 serv_got_crap( gc, "Server changed session resource string to `%s'", s + 1 );312 strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 ) 313 serv_got_crap( ic, "Server changed session resource string to `%s'", s + 1 ); 314 314 315 315 jd->flags &= ~JFLAG_WAIT_BIND; … … 322 322 if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) 323 323 { 324 if( !jabber_get_roster( gc ) )324 if( !jabber_get_roster( ic ) ) 325 325 return XT_ABORT; 326 326 } … … 329 329 } 330 330 331 int jabber_get_roster( struct gaim_connection *gc )331 int jabber_get_roster( struct im_connection *ic ) 332 332 { 333 333 struct xt_node *node; 334 334 int st; 335 335 336 set_login_progress( gc, 1, "Authenticated, requesting buddy list" );336 set_login_progress( ic, 1, "Authenticated, requesting buddy list" ); 337 337 338 338 node = xt_new_node( "query", NULL, NULL ); … … 340 340 node = jabber_make_packet( "iq", "get", NULL, node ); 341 341 342 jabber_cache_add( gc, node, jabber_parse_roster );343 st = jabber_write_packet( gc, node );342 jabber_cache_add( ic, node, jabber_parse_roster ); 343 st = jabber_write_packet( ic, node ); 344 344 345 345 return st; 346 346 } 347 347 348 static xt_status jabber_parse_roster( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )348 static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 349 349 { 350 350 struct xt_node *query, *c; … … 353 353 if( !( query = xt_find_node( node->children, "query" ) ) ) 354 354 { 355 serv_got_crap( gc, "WARNING: Received NULL roster packet" );355 serv_got_crap( ic, "WARNING: Received NULL roster packet" ); 356 356 return XT_HANDLED; 357 357 } … … 371 371 { 372 372 if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) ) 373 add_buddy( gc, NULL, jid, name );373 add_buddy( ic, NULL, jid, name ); 374 374 } 375 375 else … … 378 378 if( ( strcmp( sub, "both" ) == 0 || strcmp( sub, "to" ) == 0 ) ) 379 379 { 380 if( find_buddy( gc, jid ) == NULL )381 add_buddy( gc, NULL, jid, name );380 if( find_buddy( ic, jid ) == NULL ) 381 add_buddy( ic, NULL, jid, name ); 382 382 else if( name ) 383 serv_buddy_rename( gc, jid, name );383 serv_buddy_rename( ic, jid, name ); 384 384 } 385 385 else if( strcmp( sub, "remove" ) == 0 ) … … 387 387 /* Don't have any API call for this yet! So let's 388 388 just try to handle this as well as we can. */ 389 jabber_buddy_remove_bare( gc, jid );390 serv_got_update( gc, jid, 0, 0, 0, 0, 0, 0 );389 jabber_buddy_remove_bare( ic, jid ); 390 serv_got_update( ic, jid, 0, 0, 0, 0, 0, 0 ); 391 391 /* FIXME! */ 392 392 } … … 397 397 398 398 if( initial ) 399 account_online( gc );399 account_online( ic ); 400 400 401 401 return XT_HANDLED; 402 402 } 403 403 404 int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid )404 int jabber_get_vcard( struct im_connection *ic, char *bare_jid ) 405 405 { 406 406 struct xt_node *node; … … 413 413 node = jabber_make_packet( "iq", "get", bare_jid, node ); 414 414 415 jabber_cache_add( gc, node, jabber_iq_display_vcard );416 return jabber_write_packet( gc, node );417 } 418 419 static xt_status jabber_iq_display_vcard( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig )420 { 421 struct xt_node *vc, *c, *sc; /* subchild, gc is already in use ;-) */415 jabber_cache_add( ic, node, jabber_iq_display_vcard ); 416 return jabber_write_packet( ic, node ); 417 } 418 419 static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ) 420 { 421 struct xt_node *vc, *c, *sc; /* subchild, ic is already in use ;-) */ 422 422 GString *reply; 423 423 char *s; … … 428 428 { 429 429 s = xt_find_attr( orig, "to" ); /* If this returns NULL something's wrong.. */ 430 serv_got_crap( gc, "Could not retrieve vCard of %s", s ? s : "(NULL)" );430 serv_got_crap( ic, "Could not retrieve vCard of %s", s ? s : "(NULL)" ); 431 431 return XT_HANDLED; 432 432 } … … 536 536 /* *sigh* */ 537 537 538 serv_got_crap( gc, reply->str );538 serv_got_crap( ic, reply->str ); 539 539 g_string_free( reply, TRUE ); 540 540 … … 542 542 } 543 543 544 int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name )544 int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name ) 545 545 { 546 546 struct xt_node *node; … … 558 558 node = jabber_make_packet( "iq", "set", NULL, node ); 559 559 560 st = jabber_write_packet( gc, node );560 st = jabber_write_packet( ic, node ); 561 561 562 562 xt_free_node( node ); … … 564 564 } 565 565 566 int jabber_remove_from_roster( struct gaim_connection *gc, char *handle )566 int jabber_remove_from_roster( struct im_connection *ic, char *handle ) 567 567 { 568 568 struct xt_node *node; … … 579 579 node = jabber_make_packet( "iq", "set", NULL, node ); 580 580 581 st = jabber_write_packet( gc, node );581 st = jabber_write_packet( ic, node ); 582 582 583 583 xt_free_node( node ); -
protocols/jabber/jabber.c
rfa29d093 r0da65d5 33 33 #include "jabber.h" 34 34 35 static void jabber_ acc_init( account_t *acc )35 static void jabber_init( account_t *acc ) 36 36 { 37 37 set_t *s; … … 59 59 static void jabber_login( account_t *acc ) 60 60 { 61 struct gaim_connection *gc = new_gaim_conn( acc );61 struct im_connection *ic = new_gaim_conn( acc ); 62 62 struct jabber_data *jd = g_new0( struct jabber_data, 1 ); 63 63 struct ns_srv_reply *srv = NULL; 64 64 char *connect_to, *s; 65 65 66 jd-> gc = gc;67 gc->proto_data = jd;66 jd->ic = ic; 67 ic->proto_data = jd; 68 68 69 69 jd->username = g_strdup( acc->user ); … … 72 72 if( jd->server == NULL ) 73 73 { 74 hide_login_progress( gc, "Incomplete account name (format it like <username@jabberserver.name>)" );75 signoff( gc );74 hide_login_progress( ic, "Incomplete account name (format it like <username@jabberserver.name>)" ); 75 signoff( ic ); 76 76 return; 77 77 } … … 159 159 connect_to = jd->server; 160 160 161 set_login_progress( gc, 0, "Connecting" );161 set_login_progress( ic, 0, "Connecting" ); 162 162 163 163 if( set_getint( &acc->set, "port" ) < JABBER_PORT_MIN || 164 164 set_getint( &acc->set, "port" ) > JABBER_PORT_MAX ) 165 165 { 166 serv_got_crap( gc, "Incorrect port number, must be in the %d-%d range",166 serv_got_crap( ic, "Incorrect port number, must be in the %d-%d range", 167 167 JABBER_PORT_MIN, JABBER_PORT_MAX ); 168 signoff( gc );168 signoff( ic ); 169 169 return; 170 170 } … … 175 175 if( set_getbool( &acc->set, "ssl" ) ) 176 176 { 177 jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), jabber_connected_ssl, gc );177 jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), jabber_connected_ssl, ic ); 178 178 jd->fd = jd->ssl ? ssl_getfd( jd->ssl ) : -1; 179 179 } 180 180 else 181 181 { 182 jd->fd = proxy_connect( connect_to, srv ? srv->port : set_getint( &acc->set, "port" ), jabber_connected_plain, gc );182 jd->fd = proxy_connect( connect_to, srv ? srv->port : set_getint( &acc->set, "port" ), jabber_connected_plain, ic ); 183 183 } 184 184 g_free( srv ); … … 186 186 if( jd->fd == -1 ) 187 187 { 188 hide_login_progress( gc, "Could not connect to server" );189 signoff( gc );190 } 191 } 192 193 static void jabber_ close( struct gaim_connection *gc )194 { 195 struct jabber_data *jd = gc->proto_data;196 197 jabber_end_stream( gc );188 hide_login_progress( ic, "Could not connect to server" ); 189 signoff( ic ); 190 } 191 } 192 193 static void jabber_logout( struct im_connection *ic ) 194 { 195 struct jabber_data *jd = ic->proto_data; 196 197 jabber_end_stream( ic ); 198 198 199 199 if( jd->r_inpa >= 0 ) … … 219 219 } 220 220 221 static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away)222 { 223 struct jabber_data *jd = gc->proto_data;221 static int jabber_send_im( struct im_connection *ic, char *who, char *message, int flags ) 222 { 223 struct jabber_data *jd = ic->proto_data; 224 224 struct jabber_buddy *bud; 225 225 struct xt_node *node; 226 226 int st; 227 227 228 bud = jabber_buddy_by_jid( gc, who, 0 );228 bud = jabber_buddy_by_jid( ic, who, 0 ); 229 229 230 230 node = xt_new_node( "body", message, NULL ); … … 251 251 } 252 252 253 st = jabber_write_packet( gc, node );253 st = jabber_write_packet( ic, node ); 254 254 xt_free_node( node ); 255 255 … … 257 257 } 258 258 259 static GList *jabber_away_states( struct gaim_connection *gc )259 static GList *jabber_away_states( struct im_connection *ic ) 260 260 { 261 261 static GList *l = NULL; … … 269 269 } 270 270 271 static void jabber_get_info( struct gaim_connection *gc, char *who )272 { 273 struct jabber_data *jd = gc->proto_data;271 static void jabber_get_info( struct im_connection *ic, char *who ) 272 { 273 struct jabber_data *jd = ic->proto_data; 274 274 struct jabber_buddy *bud; 275 275 276 276 if( strchr( who, '/' ) ) 277 bud = jabber_buddy_by_jid( gc, who, 0 );277 bud = jabber_buddy_by_jid( ic, who, 0 ); 278 278 else 279 279 { … … 285 285 while( bud ) 286 286 { 287 serv_got_crap( gc, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s",287 serv_got_crap( ic, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s", 288 288 bud->full_jid, bud->priority, 289 289 bud->away_state ? bud->away_state->full_name : "(none)", … … 292 292 } 293 293 294 jabber_get_vcard( gc, bud ? bud->full_jid : who );295 } 296 297 static void jabber_set_away( struct gaim_connection *gc, char *state_txt, char *message )298 { 299 struct jabber_data *jd = gc->proto_data;294 jabber_get_vcard( ic, bud ? bud->full_jid : who ); 295 } 296 297 static void jabber_set_away( struct im_connection *ic, char *state_txt, char *message ) 298 { 299 struct jabber_data *jd = ic->proto_data; 300 300 struct jabber_away_state *state; 301 301 … … 306 306 jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL; 307 307 308 presence_send_update( gc );309 } 310 311 static void jabber_add_buddy( struct gaim_connection *gc, char *who)312 { 313 if( jabber_add_to_roster( gc, who, NULL ) )314 presence_send_request( gc, who, "subscribe" );315 } 316 317 static void jabber_remove_buddy( struct gaim_connection *gc, char *who, char *group )308 presence_send_update( ic ); 309 } 310 311 static void jabber_add_buddy( struct im_connection *ic, char *who, char *group ) 312 { 313 if( jabber_add_to_roster( ic, who, NULL ) ) 314 presence_send_request( ic, who, "subscribe" ); 315 } 316 317 static void jabber_remove_buddy( struct im_connection *ic, char *who, char *group ) 318 318 { 319 319 /* We should always do this part. Clean up our administration a little bit. */ 320 jabber_buddy_remove_bare( gc, who );321 322 if( jabber_remove_from_roster( gc, who ) )323 presence_send_request( gc, who, "unsubscribe" );324 } 325 326 static void jabber_keepalive( struct gaim_connection *gc )320 jabber_buddy_remove_bare( ic, who ); 321 322 if( jabber_remove_from_roster( ic, who ) ) 323 presence_send_request( ic, who, "unsubscribe" ); 324 } 325 326 static void jabber_keepalive( struct im_connection *ic ) 327 327 { 328 328 /* Just any whitespace character is enough as a keepalive for XMPP sessions. */ 329 jabber_write( gc, "\n", 1 );329 jabber_write( ic, "\n", 1 ); 330 330 331 331 /* This runs the garbage collection every minute, which means every packet 332 332 is in the cache for about a minute (which should be enough AFAIK). */ 333 jabber_cache_clean( gc );334 } 335 336 static int jabber_send_typing( struct gaim_connection *gc, char *who, int typing )337 { 338 struct jabber_data *jd = gc->proto_data;333 jabber_cache_clean( ic ); 334 } 335 336 static int jabber_send_typing( struct im_connection *ic, char *who, int typing ) 337 { 338 struct jabber_data *jd = ic->proto_data; 339 339 struct jabber_buddy *bud; 340 340 … … 342 342 jd->flags |= JFLAG_WANT_TYPING; 343 343 344 if( ( bud = jabber_buddy_by_jid( gc, who, 0 ) ) == NULL )344 if( ( bud = jabber_buddy_by_jid( ic, who, 0 ) ) == NULL ) 345 345 { 346 346 /* Sending typing notifications to unknown buddies is … … 369 369 node = jabber_make_packet( "message", "chat", bud->full_jid, node ); 370 370 371 st = jabber_write_packet( gc, node );371 st = jabber_write_packet( ic, node ); 372 372 xt_free_node( node ); 373 373 … … 378 378 } 379 379 380 void jabber_init ()380 void jabber_initmodule() 381 381 { 382 382 struct prpl *ret = g_new0( struct prpl, 1 ); … … 384 384 ret->name = "jabber"; 385 385 ret->login = jabber_login; 386 ret-> acc_init = jabber_acc_init;387 ret-> close = jabber_close;386 ret->init = jabber_init; 387 ret->logout = jabber_logout; 388 388 ret->send_im = jabber_send_im; 389 389 ret->away_states = jabber_away_states; -
protocols/jabber/jabber.h
rfa29d093 r0da65d5 58 58 struct jabber_data 59 59 { 60 struct gaim_connection *gc;60 struct im_connection *ic; 61 61 62 62 int fd; … … 87 87 }; 88 88 89 typedef xt_status (*jabber_cache_event) ( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );89 typedef xt_status (*jabber_cache_event) ( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 90 90 91 91 struct jabber_cache_entry … … 137 137 /* iq.c */ 138 138 xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ); 139 int jabber_init_iq_auth( struct gaim_connection *gc );140 xt_status jabber_pkt_bind_sess( struct gaim_connection *gc, struct xt_node *node, struct xt_node *orig );141 int jabber_get_roster( struct gaim_connection *gc );142 int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid );143 int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name );144 int jabber_remove_from_roster( struct gaim_connection *gc, char *handle );139 int jabber_init_iq_auth( struct im_connection *ic ); 140 xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); 141 int jabber_get_roster( struct im_connection *ic ); 142 int jabber_get_vcard( struct im_connection *ic, char *bare_jid ); 143 int jabber_add_to_roster( struct im_connection *ic, char *handle, char *name ); 144 int jabber_remove_from_roster( struct im_connection *ic, char *handle ); 145 145 146 146 /* message.c */ … … 149 149 /* presence.c */ 150 150 xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ); 151 int presence_send_update( struct gaim_connection *gc );152 int presence_send_request( struct gaim_connection *gc, char *handle, char *request );151 int presence_send_update( struct im_connection *ic ); 152 int presence_send_request( struct im_connection *ic, char *handle, char *request ); 153 153 154 154 /* jabber_util.c */ … … 157 157 struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_node *children ); 158 158 struct xt_node *jabber_make_error_packet( struct xt_node *orig, char *err_cond, char *err_type ); 159 void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func );160 struct xt_node *jabber_cache_get( struct gaim_connection *gc, char *id );159 void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_cache_event func ); 160 struct xt_node *jabber_cache_get( struct im_connection *ic, char *id ); 161 161 void jabber_cache_entry_free( gpointer entry ); 162 void jabber_cache_clean( struct gaim_connection *gc );162 void jabber_cache_clean( struct im_connection *ic ); 163 163 const struct jabber_away_state *jabber_away_state_by_code( char *code ); 164 164 const struct jabber_away_state *jabber_away_state_by_name( char *name ); 165 void jabber_buddy_ask( struct gaim_connection *gc, char *handle );165 void jabber_buddy_ask( struct im_connection *ic, char *handle ); 166 166 char *jabber_normalize( char *orig ); 167 167 … … 172 172 } get_buddy_flags_t; 173 173 174 struct jabber_buddy *jabber_buddy_add( struct gaim_connection *gc, char *full_jid );175 struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid, get_buddy_flags_t flags );176 int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid );177 int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid );174 struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid ); 175 struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid, get_buddy_flags_t flags ); 176 int jabber_buddy_remove( struct im_connection *ic, char *full_jid ); 177 int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid ); 178 178 179 179 extern const struct jabber_away_state jabber_away_state_list[]; 180 180 181 181 /* io.c */ 182 int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node );183 int jabber_write( struct gaim_connection *gc, char *buf, int len );182 int jabber_write_packet( struct im_connection *ic, struct xt_node *node ); 183 int jabber_write( struct im_connection *ic, char *buf, int len ); 184 184 gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond ); 185 185 gboolean jabber_connected_ssl( gpointer data, void *source, b_input_condition cond ); 186 gboolean jabber_start_stream( struct gaim_connection *gc );187 void jabber_end_stream( struct gaim_connection *gc );186 gboolean jabber_start_stream( struct im_connection *ic ); 187 void jabber_end_stream( struct im_connection *ic ); 188 188 189 189 /* sasl.c */ … … 191 191 xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data ); 192 192 xt_status sasl_pkt_result( struct xt_node *node, gpointer data ); 193 gboolean sasl_supported( struct gaim_connection *gc );193 gboolean sasl_supported( struct im_connection *ic ); 194 194 195 195 #endif -
protocols/jabber/jabber_util.c
rfa29d093 r0da65d5 42 42 /* Only run this stuff if the account is online ATM, 43 43 and if the setting seems to be acceptable. */ 44 if( acc-> gc )44 if( acc->ic ) 45 45 { 46 46 /* Although set_eval functions usually are very nice and … … 58 58 /* (Yes, sorry, I prefer the hack. :-P) */ 59 59 60 presence_send_update( acc-> gc );60 presence_send_update( acc->ic ); 61 61 } 62 62 … … 130 130 them when you receive the response. Use this BEFORE sending the packet so 131 131 it'll get a new id= tag, and do NOT free() the packet after writing it! */ 132 void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func )133 { 134 struct jabber_data *jd = gc->proto_data;132 void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_cache_event func ) 133 { 134 struct jabber_data *jd = ic->proto_data; 135 135 char *id = g_strdup_printf( "%s%05x", JABBER_CACHED_ID, ( next_id++ ) & 0xfffff ); 136 136 struct jabber_cache_entry *entry = g_new0( struct jabber_cache_entry, 1 ); … … 159 159 node should be available in the cache for at least a minute (assuming the 160 160 function is indeed called every minute). */ 161 void jabber_cache_clean( struct gaim_connection *gc )162 { 163 struct jabber_data *jd = gc->proto_data;161 void jabber_cache_clean( struct im_connection *ic ) 162 { 163 struct jabber_data *jd = ic->proto_data; 164 164 165 165 g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, NULL ); … … 214 214 struct jabber_buddy_ask_data 215 215 { 216 struct gaim_connection *gc;216 struct im_connection *ic; 217 217 char *handle; 218 218 char *realname; … … 221 221 static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla ) 222 222 { 223 presence_send_request( bla-> gc, bla->handle, "subscribed" );224 225 if( find_buddy( bla-> gc, bla->handle ) == NULL )226 show_got_added( bla-> gc, bla->handle, NULL );223 presence_send_request( bla->ic, bla->handle, "subscribed" ); 224 225 if( find_buddy( bla->ic, bla->handle ) == NULL ) 226 show_got_added( bla->ic, bla->handle, NULL ); 227 227 228 228 g_free( bla->handle ); … … 232 232 static void jabber_buddy_ask_no( gpointer w, struct jabber_buddy_ask_data *bla ) 233 233 { 234 presence_send_request( bla-> gc, bla->handle, "subscribed" );234 presence_send_request( bla->ic, bla->handle, "subscribed" ); 235 235 236 236 g_free( bla->handle ); … … 238 238 } 239 239 240 void jabber_buddy_ask( struct gaim_connection *gc, char *handle )240 void jabber_buddy_ask( struct im_connection *ic, char *handle ) 241 241 { 242 242 struct jabber_buddy_ask_data *bla = g_new0( struct jabber_buddy_ask_data, 1 ); 243 243 char *buf; 244 244 245 bla-> gc = gc;245 bla->ic = ic; 246 246 bla->handle = g_strdup( handle ); 247 247 248 248 buf = g_strdup_printf( "The user %s wants to add you to his/her buddy list.", handle ); 249 do_ask_dialog( gc, buf, bla, jabber_buddy_ask_yes, jabber_buddy_ask_no );249 do_ask_dialog( ic, buf, bla, jabber_buddy_ask_yes, jabber_buddy_ask_no ); 250 250 g_free( buf ); 251 251 } … … 271 271 to deal with that properly. Set their ->resource property to NULL. Do *NOT* 272 272 allow to mix this stuff, though... */ 273 struct jabber_buddy *jabber_buddy_add( struct gaim_connection *gc, char *full_jid_ )274 { 275 struct jabber_data *jd = gc->proto_data;273 struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid_ ) 274 { 275 struct jabber_data *jd = ic->proto_data; 276 276 struct jabber_buddy *bud, *new, *bi; 277 277 char *s, *full_jid; … … 343 343 asked for a bare JID, it uses the "resource_select" setting to see which 344 344 resource to pick. */ 345 struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid_, get_buddy_flags_t flags )346 { 347 struct jabber_data *jd = gc->proto_data;345 struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, get_buddy_flags_t flags ) 346 { 347 struct jabber_data *jd = ic->proto_data; 348 348 struct jabber_buddy *bud; 349 349 char *s, *jid; … … 371 371 } 372 372 373 if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && find_buddy( gc, jid ) )373 if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && find_buddy( ic, jid ) ) 374 374 { 375 375 *s = '/'; 376 bud = jabber_buddy_add( gc, jid );376 bud = jabber_buddy_add( ic, jid ); 377 377 } 378 378 … … 391 391 if( bud == NULL ) 392 392 /* No match. Create it now? */ 393 return ( ( flags & GET_BUDDY_CREAT ) && find_buddy( gc, jid_ ) ) ?394 jabber_buddy_add( gc, jid_ ) : NULL;393 return ( ( flags & GET_BUDDY_CREAT ) && find_buddy( ic, jid_ ) ) ? 394 jabber_buddy_add( ic, jid_ ) : NULL; 395 395 else if( bud->resource && ( flags & GET_BUDDY_EXACT ) ) 396 396 /* We want an exact match, so in thise case there shouldn't be a /resource. */ … … 409 409 } 410 410 411 if( ( set = set_getstr( & gc->acc->set, "resource_select" ) ) == NULL )411 if( ( set = set_getstr( &ic->acc->set, "resource_select" ) ) == NULL ) 412 412 return NULL; 413 413 else if( strcmp( set, "activity" ) == 0 ) … … 421 421 off-line (because (s)he can still be online from a different location. 422 422 XXX: See above, we should accept bare JIDs too... */ 423 int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid_ )424 { 425 struct jabber_data *jd = gc->proto_data;423 int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ ) 424 { 425 struct jabber_data *jd = ic->proto_data; 426 426 struct jabber_buddy *bud, *prev, *bi; 427 427 char *s, *full_jid; … … 495 495 specified bare JID. Use this when removing someone from the contact 496 496 list, for example. */ 497 int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid_ )498 { 499 struct jabber_data *jd = gc->proto_data;497 int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid_ ) 498 { 499 struct jabber_data *jd = ic->proto_data; 500 500 struct jabber_buddy *bud, *next; 501 501 char *bare_jid; -
protocols/jabber/message.c
rfa29d093 r0da65d5 26 26 xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) 27 27 { 28 struct gaim_connection *gc = data;28 struct im_connection *ic = data; 29 29 char *from = xt_find_attr( node, "from" ); 30 30 char *type = xt_find_attr( node, "type" ); … … 47 47 if( ( s = strchr( from, '/' ) ) ) 48 48 { 49 if( ( bud = jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT ) ) )49 if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) ) ) 50 50 bud->last_act = time( NULL ); 51 51 else … … 76 76 77 77 if( fullmsg->len > 0 ) 78 serv_got_im( gc, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len );78 serv_got_im( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len ); 79 79 80 80 g_string_free( fullmsg, TRUE ); … … 84 84 { 85 85 bud->flags |= JBFLAG_DOES_XEP85; 86 serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 1 );86 serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 1 ); 87 87 } 88 88 /* No need to send a "stopped typing" signal when there's a message. */ … … 90 90 { 91 91 bud->flags |= JBFLAG_DOES_XEP85; 92 serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 0 );92 serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 0 ); 93 93 } 94 94 else if( xt_find_node( node->children, "paused" ) ) 95 95 { 96 96 bud->flags |= JBFLAG_DOES_XEP85; 97 serv_got_typing( gc, bud ? bud->bare_jid : from, 0, 2 );97 serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 2 ); 98 98 } 99 99 -
protocols/jabber/presence.c
rfa29d093 r0da65d5 26 26 xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) 27 27 { 28 struct gaim_connection *gc = data;28 struct im_connection *ic = data; 29 29 char *from = xt_find_attr( node, "from" ); 30 30 char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */ … … 38 38 if( type == NULL ) 39 39 { 40 if( !( bud = jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) )40 if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) ) 41 41 { 42 if( set_getbool( & gc->irc->set, "debug" ) )43 serv_got_crap( gc, "WARNING: Could not handle presence information from JID: %s", from );42 if( set_getbool( &ic->irc->set, "debug" ) ) 43 serv_got_crap( ic, "WARNING: Could not handle presence information from JID: %s", from ); 44 44 return XT_HANDLED; 45 45 } … … 66 66 bud->priority = 0; 67 67 68 serv_got_update( gc, bud->bare_jid, 1, 0, 0, 0,68 serv_got_update( ic, bud->bare_jid, 1, 0, 0, 0, 69 69 bud->away_state ? UC_UNAVAILABLE : 0, 0 ); 70 70 } 71 71 else if( strcmp( type, "unavailable" ) == 0 ) 72 72 { 73 if( jabber_buddy_by_jid( gc, from, GET_BUDDY_EXACT ) == NULL )73 if( jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) == NULL ) 74 74 { 75 if( set_getbool( & gc->irc->set, "debug" ) )76 serv_got_crap( gc, "WARNING: Received presence information from unknown JID: %s", from );75 if( set_getbool( &ic->irc->set, "debug" ) ) 76 serv_got_crap( ic, "WARNING: Received presence information from unknown JID: %s", from ); 77 77 return XT_HANDLED; 78 78 } 79 79 80 jabber_buddy_remove( gc, from );80 jabber_buddy_remove( ic, from ); 81 81 82 82 if( ( s = strchr( from, '/' ) ) ) … … 86 86 /* Only count this as offline if there's no other resource 87 87 available anymore. */ 88 if( jabber_buddy_by_jid( gc, from, 0 ) == NULL )89 serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );88 if( jabber_buddy_by_jid( ic, from, 0 ) == NULL ) 89 serv_got_update( ic, from, 0, 0, 0, 0, 0, 0 ); 90 90 91 91 *s = '/'; … … 93 93 else 94 94 { 95 serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );95 serv_got_update( ic, from, 0, 0, 0, 0, 0, 0 ); 96 96 } 97 97 } 98 98 else if( strcmp( type, "subscribe" ) == 0 ) 99 99 { 100 jabber_buddy_ask( gc, from );100 jabber_buddy_ask( ic, from ); 101 101 } 102 102 else if( strcmp( type, "subscribed" ) == 0 ) 103 103 { 104 104 /* Not sure about this one, actually... */ 105 serv_got_crap( gc, "%s just accepted your authorization request", from );105 serv_got_crap( ic, "%s just accepted your authorization request", from ); 106 106 } 107 107 else if( strcmp( type, "unsubscribe" ) == 0 || strcmp( type, "unsubscribed" ) == 0 ) … … 131 131 /* Whenever presence information is updated, call this function to inform the 132 132 server. */ 133 int presence_send_update( struct gaim_connection *gc )133 int presence_send_update( struct im_connection *ic ) 134 134 { 135 struct jabber_data *jd = gc->proto_data;135 struct jabber_data *jd = ic->proto_data; 136 136 struct xt_node *node; 137 137 char *show = jd->away_state->code; … … 140 140 141 141 node = jabber_make_packet( "presence", NULL, NULL, NULL ); 142 xt_add_child( node, xt_new_node( "priority", set_getstr( & gc->acc->set, "priority" ), NULL ) );142 xt_add_child( node, xt_new_node( "priority", set_getstr( &ic->acc->set, "priority" ), NULL ) ); 143 143 if( show && *show ) 144 144 xt_add_child( node, xt_new_node( "show", show, NULL ) ); … … 146 146 xt_add_child( node, xt_new_node( "status", status, NULL ) ); 147 147 148 st = jabber_write_packet( gc, node );148 st = jabber_write_packet( ic, node ); 149 149 150 150 xt_free_node( node ); … … 153 153 154 154 /* Send a subscribe/unsubscribe request to a buddy. */ 155 int presence_send_request( struct gaim_connection *gc, char *handle, char *request )155 int presence_send_request( struct im_connection *ic, char *handle, char *request ) 156 156 { 157 157 struct xt_node *node; … … 162 162 xt_add_attr( node, "type", request ); 163 163 164 st = jabber_write_packet( gc, node );164 st = jabber_write_packet( ic, node ); 165 165 166 166 xt_free_node( node ); -
protocols/jabber/sasl.c
rfa29d093 r0da65d5 27 27 xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data ) 28 28 { 29 struct gaim_connection *gc = data;30 struct jabber_data *jd = gc->proto_data;29 struct im_connection *ic = data; 30 struct jabber_data *jd = ic->proto_data; 31 31 struct xt_node *c, *reply; 32 32 char *s; 33 33 int sup_plain = 0, sup_digest = 0; 34 34 35 if( !sasl_supported( gc ) )35 if( !sasl_supported( ic ) ) 36 36 { 37 37 /* Should abort this now, since we should already be doing 38 38 IQ authentication. Strange things happen when you try 39 39 to do both... */ 40 serv_got_crap( gc, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" );40 serv_got_crap( ic, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" ); 41 41 return XT_HANDLED; 42 42 } … … 45 45 if( !s || strcmp( s, XMLNS_SASL ) != 0 ) 46 46 { 47 signoff( gc );47 signoff( ic ); 48 48 return XT_ABORT; 49 49 } … … 62 62 if( !sup_plain && !sup_digest ) 63 63 { 64 hide_login_progress( gc, "No known SASL authentication schemes supported" );65 signoff( gc );64 hide_login_progress( ic, "No known SASL authentication schemes supported" ); 65 signoff( ic ); 66 66 return XT_ABORT; 67 67 } … … 83 83 84 84 /* With SASL PLAIN in XMPP, the text should be b64(\0user\0pass) */ 85 len = strlen( jd->username ) + strlen( gc->acc->pass ) + 2;85 len = strlen( jd->username ) + strlen( ic->acc->pass ) + 2; 86 86 s = g_malloc( len + 1 ); 87 87 s[0] = 0; 88 88 strcpy( s + 1, jd->username ); 89 strcpy( s + 2 + strlen( jd->username ), gc->acc->pass );89 strcpy( s + 2 + strlen( jd->username ), ic->acc->pass ); 90 90 reply->text = base64_encode( s, len ); 91 91 reply->text_len = strlen( reply->text ); … … 93 93 } 94 94 95 if( !jabber_write_packet( gc, reply ) )95 if( !jabber_write_packet( ic, reply ) ) 96 96 { 97 97 xt_free_node( reply ); … … 181 181 xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data ) 182 182 { 183 struct gaim_connection *gc = data;184 struct jabber_data *jd = gc->proto_data;183 struct im_connection *ic = data; 184 struct jabber_data *jd = ic->proto_data; 185 185 struct xt_node *reply = NULL; 186 186 char *nonce = NULL, *realm = NULL, *cnonce = NULL, cnonce_bin[30]; … … 222 222 I decided to call it H. */ 223 223 md5_init( &H ); 224 s = g_strdup_printf( "%s:%s:%s", jd->username, realm, gc->acc->pass );224 s = g_strdup_printf( "%s:%s:%s", jd->username, realm, ic->acc->pass ); 225 225 md5_append( &H, (unsigned char *) s, strlen( s ) ); 226 226 g_free( s ); … … 272 272 xt_add_attr( reply, "xmlns", XMLNS_SASL ); 273 273 274 if( !jabber_write_packet( gc, reply ) )274 if( !jabber_write_packet( ic, reply ) ) 275 275 goto silent_error; 276 276 … … 279 279 280 280 error: 281 hide_login_progress( gc, "Incorrect SASL challenge received" );282 signoff( gc );281 hide_login_progress( ic, "Incorrect SASL challenge received" ); 282 signoff( ic ); 283 283 284 284 silent_error: … … 296 296 xt_status sasl_pkt_result( struct xt_node *node, gpointer data ) 297 297 { 298 struct gaim_connection *gc = data;299 struct jabber_data *jd = gc->proto_data;298 struct im_connection *ic = data; 299 struct jabber_data *jd = ic->proto_data; 300 300 char *s; 301 301 … … 303 303 if( !s || strcmp( s, XMLNS_SASL ) != 0 ) 304 304 { 305 signoff( gc );305 signoff( ic ); 306 306 return XT_ABORT; 307 307 } … … 309 309 if( strcmp( node->name, "success" ) == 0 ) 310 310 { 311 set_login_progress( gc, 1, "Authentication finished" );311 set_login_progress( ic, 1, "Authentication finished" ); 312 312 jd->flags |= JFLAG_AUTHENTICATED | JFLAG_STREAM_RESTART; 313 313 } 314 314 else if( strcmp( node->name, "failure" ) == 0 ) 315 315 { 316 hide_login_progress( gc, "Authentication failure" );317 signoff( gc );316 hide_login_progress( ic, "Authentication failure" ); 317 signoff( ic ); 318 318 return XT_ABORT; 319 319 } … … 325 325 It's done by checking if the <stream:stream> from the server has a 326 326 version attribute. I don't know if this is the right way though... */ 327 gboolean sasl_supported( struct gaim_connection *gc )328 { 329 struct jabber_data *jd = gc->proto_data;327 gboolean sasl_supported( struct im_connection *ic ) 328 { 329 struct jabber_data *jd = ic->proto_data; 330 330 331 331 return ( (void*) ( jd->xt && jd->xt->root && xt_find_attr( jd->xt->root, "version" ) ) ) != NULL;
Note: See TracChangeset
for help on using the changeset viewer.