- Timestamp:
- 2007-03-31T05:40:45Z (18 years ago)
- Branches:
- master
- Children:
- aef4828
- Parents:
- fa29d093
- Location:
- protocols
- Files:
-
- 20 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; -
protocols/msn/msn.c
rfa29d093 r0da65d5 29 29 static char *msn_set_display_name( set_t *set, char *value ); 30 30 31 static void msn_ acc_init( account_t *acc )31 static void msn_init( account_t *acc ) 32 32 { 33 33 set_t *s; … … 39 39 static void msn_login( account_t *acc ) 40 40 { 41 struct gaim_connection *gc = new_gaim_conn( acc );41 struct im_connection *ic = new_gaim_conn( acc ); 42 42 struct msn_data *md = g_new0( struct msn_data, 1 ); 43 43 44 gc->proto_data = md;44 ic->proto_data = md; 45 45 md->fd = -1; 46 46 47 47 if( strchr( acc->user, '@' ) == NULL ) 48 48 { 49 hide_login_progress( gc, "Invalid account name" );50 signoff( gc );49 hide_login_progress( ic, "Invalid account name" ); 50 signoff( ic ); 51 51 return; 52 52 } 53 53 54 set_login_progress( gc, 1, "Connecting" );55 56 md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, gc );54 set_login_progress( ic, 1, "Connecting" ); 55 56 md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, ic ); 57 57 if( md->fd < 0 ) 58 58 { 59 hide_login_progress( gc, "Could not connect to server" );60 signoff( gc );59 hide_login_progress( ic, "Could not connect to server" ); 60 signoff( ic ); 61 61 return; 62 62 } 63 63 64 md-> gc = gc;64 md->ic = ic; 65 65 md->away_state = msn_away_state_list; 66 66 67 msn_connections = g_slist_append( msn_connections, gc );68 } 69 70 static void msn_ close( struct gaim_connection *gc )71 { 72 struct msn_data *md = gc->proto_data;67 msn_connections = g_slist_append( msn_connections, ic ); 68 } 69 70 static void msn_logout( struct im_connection *ic ) 71 { 72 struct msn_data *md = ic->proto_data; 73 73 GSList *l; 74 74 … … 96 96 m = l->data; 97 97 98 serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who );98 serv_got_crap( ic, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who ); 99 99 g_free( m->who ); 100 100 g_free( m->text ); … … 111 111 } 112 112 113 for( l = gc->permit; l; l = l->next )113 for( l = ic->permit; l; l = l->next ) 114 114 g_free( l->data ); 115 g_slist_free( gc->permit );116 117 for( l = gc->deny; l; l = l->next )115 g_slist_free( ic->permit ); 116 117 for( l = ic->deny; l; l = l->next ) 118 118 g_free( l->data ); 119 g_slist_free( gc->deny );120 121 msn_connections = g_slist_remove( msn_connections, gc );122 } 123 124 static int msn_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )119 g_slist_free( ic->deny ); 120 121 msn_connections = g_slist_remove( msn_connections, ic ); 122 } 123 124 static int msn_send_im( struct im_connection *ic, char *who, char *message, int away ) 125 125 { 126 126 struct msn_switchboard *sb; 127 struct msn_data *md = gc->proto_data;128 129 if( ( sb = msn_sb_by_handle( gc, who ) ) )127 struct msn_data *md = ic->proto_data; 128 129 if( ( sb = msn_sb_by_handle( ic, who ) ) ) 130 130 { 131 131 return( msn_sb_sendmessage( sb, message ) ); … … 142 142 143 143 /* FIXME: *CHECK* the reliability of using spare sb's! */ 144 if( ( sb = msn_sb_spare( gc ) ) )144 if( ( sb = msn_sb_spare( ic ) ) ) 145 145 { 146 146 debug( "Trying to use a spare switchboard to message %s", who ); … … 160 160 /* If we reach this line, there was no spare switchboard, so let's make one. */ 161 161 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 162 if( !msn_write( gc, buf, strlen( buf ) ) )162 if( !msn_write( ic, buf, strlen( buf ) ) ) 163 163 { 164 164 g_free( m->who ); … … 180 180 } 181 181 182 static GList *msn_away_states( struct gaim_connection *gc )182 static GList *msn_away_states( struct im_connection *ic ) 183 183 { 184 184 static GList *l = NULL; … … 192 192 } 193 193 194 static char *msn_get_status_string( struct gaim_connection *gc, int number )194 static char *msn_get_status_string( struct im_connection *ic, int number ) 195 195 { 196 196 const struct msn_away_state *st = msn_away_state_by_number( number ); … … 202 202 } 203 203 204 static void msn_set_away( struct gaim_connection *gc, char *state, char *message )204 static void msn_set_away( struct im_connection *ic, char *state, char *message ) 205 205 { 206 206 char buf[1024]; 207 struct msn_data *md = gc->proto_data;207 struct msn_data *md = ic->proto_data; 208 208 const struct msn_away_state *st; 209 209 … … 217 217 218 218 g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code ); 219 msn_write( gc, buf, strlen( buf ) );220 } 221 222 static void msn_set_ info( struct gaim_connection *gc, char *info )223 { 224 msn_set_display_name( set_find( & gc->acc->set, "display_name" ), info );225 } 226 227 static void msn_get_info(struct gaim_connection *gc, char *who)219 msn_write( ic, buf, strlen( buf ) ); 220 } 221 222 static void msn_set_my_name( struct im_connection *ic, char *info ) 223 { 224 msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info ); 225 } 226 227 static void msn_get_info(struct im_connection *ic, char *who) 228 228 { 229 229 /* Just make an URL and let the user fetch the info */ 230 serv_got_crap( gc, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who );231 } 232 233 static void msn_add_buddy( struct gaim_connection *gc, char *who)234 { 235 msn_buddy_list_add( gc, "FL", who, who );236 } 237 238 static void msn_remove_buddy( struct gaim_connection *gc, char *who, char *group )239 { 240 msn_buddy_list_remove( gc, "FL", who );241 } 242 243 static int msn_chat_send( struct conversation *c, char *message)230 serv_got_crap( ic, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who ); 231 } 232 233 static void msn_add_buddy( struct im_connection *ic, char *who, char *group ) 234 { 235 msn_buddy_list_add( ic, "FL", who, who ); 236 } 237 238 static void msn_remove_buddy( struct im_connection *ic, char *who, char *group ) 239 { 240 msn_buddy_list_remove( ic, "FL", who ); 241 } 242 243 static void msn_chat_send( struct groupchat *c, char *message, int flags ) 244 244 { 245 245 struct msn_switchboard *sb = msn_sb_by_chat( c ); 246 246 247 247 if( sb ) 248 return( msn_sb_sendmessage( sb, message ));249 else250 return( 0 );251 } 252 253 static void msn_chat_invite( struct conversation*c, char *msg, char *who )248 msn_sb_sendmessage( sb, message ); 249 /* FIXME: Error handling (although this can't happen unless something's 250 already severely broken) disappeared here! */ 251 } 252 253 static void msn_chat_invite( struct groupchat *c, char *msg, char *who ) 254 254 { 255 255 struct msn_switchboard *sb = msn_sb_by_chat( c ); … … 263 263 } 264 264 265 static void msn_chat_leave( struct conversation*c )265 static void msn_chat_leave( struct groupchat *c ) 266 266 { 267 267 struct msn_switchboard *sb = msn_sb_by_chat( c ); … … 271 271 } 272 272 273 static struct conversation *msn_chat_open( struct gaim_connection *gc, char *who )273 static struct groupchat *msn_chat_with( struct im_connection *ic, char *who ) 274 274 { 275 275 struct msn_switchboard *sb; 276 struct msn_data *md = gc->proto_data;276 struct msn_data *md = ic->proto_data; 277 277 char buf[1024]; 278 278 279 if( ( sb = msn_sb_by_handle( gc, who ) ) )279 if( ( sb = msn_sb_by_handle( ic, who ) ) ) 280 280 { 281 281 debug( "Converting existing switchboard to %s to a groupchat", who ); … … 286 286 struct msn_message *m; 287 287 288 if( ( sb = msn_sb_spare( gc ) ) )288 if( ( sb = msn_sb_spare( ic ) ) ) 289 289 { 290 290 debug( "Trying to reuse an existing switchboard as a groupchat with %s", who ); … … 299 299 /* Request a new switchboard. */ 300 300 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 301 if( !msn_write( gc, buf, strlen( buf ) ) )301 if( !msn_write( ic, buf, strlen( buf ) ) ) 302 302 return( 0 ); 303 303 … … 317 317 } 318 318 319 static void msn_keepalive( struct gaim_connection *gc )320 { 321 msn_write( gc, "PNG\r\n", strlen( "PNG\r\n" ) );322 } 323 324 static void msn_add_permit( struct gaim_connection *gc, char *who )325 { 326 msn_buddy_list_add( gc, "AL", who, who );327 } 328 329 static void msn_rem_permit( struct gaim_connection *gc, char *who )330 { 331 msn_buddy_list_remove( gc, "AL", who );332 } 333 334 static void msn_add_deny( struct gaim_connection *gc, char *who )319 static void msn_keepalive( struct im_connection *ic ) 320 { 321 msn_write( ic, "PNG\r\n", strlen( "PNG\r\n" ) ); 322 } 323 324 static void msn_add_permit( struct im_connection *ic, char *who ) 325 { 326 msn_buddy_list_add( ic, "AL", who, who ); 327 } 328 329 static void msn_rem_permit( struct im_connection *ic, char *who ) 330 { 331 msn_buddy_list_remove( ic, "AL", who ); 332 } 333 334 static void msn_add_deny( struct im_connection *ic, char *who ) 335 335 { 336 336 struct msn_switchboard *sb; 337 337 338 msn_buddy_list_add( gc, "BL", who, who );338 msn_buddy_list_add( ic, "BL", who, who ); 339 339 340 340 /* If there's still a conversation with this person, close it. */ 341 if( ( sb = msn_sb_by_handle( gc, who ) ) )341 if( ( sb = msn_sb_by_handle( ic, who ) ) ) 342 342 { 343 343 msn_sb_destroy( sb ); … … 345 345 } 346 346 347 static void msn_rem_deny( struct gaim_connection *gc, char *who )348 { 349 msn_buddy_list_remove( gc, "BL", who );350 } 351 352 static int msn_send_typing( struct gaim_connection *gc, char *who, int typing )347 static void msn_rem_deny( struct im_connection *ic, char *who ) 348 { 349 msn_buddy_list_remove( ic, "BL", who ); 350 } 351 352 static int msn_send_typing( struct im_connection *ic, char *who, int typing ) 353 353 { 354 354 if( typing ) 355 return( msn_send_im( gc, who, TYPING_NOTIFICATION_MESSAGE, strlen( TYPING_NOTIFICATION_MESSAGE ), 0 ) );355 return( msn_send_im( ic, who, TYPING_NOTIFICATION_MESSAGE, 0 ) ); 356 356 else 357 357 return( 1 ); … … 361 361 { 362 362 account_t *acc = set->data; 363 struct gaim_connection *gc = acc->gc;363 struct im_connection *ic = acc->ic; 364 364 struct msn_data *md; 365 365 char buf[1024], *fn; 366 366 367 367 /* Double-check. */ 368 if( gc == NULL )368 if( ic == NULL ) 369 369 return NULL; 370 370 371 md = gc->proto_data;371 md = ic->proto_data; 372 372 373 373 if( strlen( value ) > 129 ) 374 374 { 375 serv_got_crap( gc, "Maximum name length exceeded" );375 serv_got_crap( ic, "Maximum name length exceeded" ); 376 376 return NULL; 377 377 } … … 379 379 fn = msn_http_encode( value ); 380 380 381 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn );382 msn_write( gc, buf, strlen( buf ) );381 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->username, fn ); 382 msn_write( ic, buf, strlen( buf ) ); 383 383 g_free( fn ); 384 384 … … 389 389 } 390 390 391 void msn_init ()391 void msn_initmodule() 392 392 { 393 393 struct prpl *ret = g_new0(struct prpl, 1); … … 395 395 ret->name = "msn"; 396 396 ret->login = msn_login; 397 ret-> acc_init = msn_acc_init;398 ret-> close = msn_close;397 ret->init = msn_init; 398 ret->logout = msn_logout; 399 399 ret->send_im = msn_send_im; 400 400 ret->away_states = msn_away_states; 401 401 ret->get_status_string = msn_get_status_string; 402 402 ret->set_away = msn_set_away; 403 ret->set_info = msn_set_info;404 403 ret->get_info = msn_get_info; 404 ret->set_my_name = msn_set_my_name; 405 405 ret->add_buddy = msn_add_buddy; 406 406 ret->remove_buddy = msn_remove_buddy; … … 408 408 ret->chat_invite = msn_chat_invite; 409 409 ret->chat_leave = msn_chat_leave; 410 ret->chat_ open = msn_chat_open;410 ret->chat_with = msn_chat_with; 411 411 ret->keepalive = msn_keepalive; 412 412 ret->add_permit = msn_add_permit; -
protocols/msn/msn.h
rfa29d093 r0da65d5 57 57 struct msn_data 58 58 { 59 struct gaim_connection *gc;59 struct im_connection *ic; 60 60 61 61 int fd; … … 75 75 struct msn_switchboard 76 76 { 77 struct gaim_connection *gc;77 struct im_connection *ic; 78 78 79 79 int fd; … … 89 89 GSList *msgq; 90 90 char *who; 91 struct conversation*chat;91 struct groupchat *chat; 92 92 }; 93 93 … … 149 149 150 150 /* msn_util.c */ 151 int msn_write( struct gaim_connection *gc, char *s, int len );152 int msn_logged_in( struct gaim_connection *gc );153 int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char *realname );154 int msn_buddy_list_remove( struct gaim_connection *gc, char *list, char *who );155 void msn_buddy_ask( struct gaim_connection *gc, char *handle, char *realname );151 int msn_write( struct im_connection *ic, char *s, int len ); 152 int msn_logged_in( struct im_connection *ic ); 153 int msn_buddy_list_add( struct im_connection *ic, char *list, char *who, char *realname ); 154 int msn_buddy_list_remove( struct im_connection *ic, char *list, char *who ); 155 void msn_buddy_ask( struct im_connection *ic, char *handle, char *realname ); 156 156 char *msn_findheader( char *text, char *header, int len ); 157 157 char **msn_linesplit( char *line ); … … 167 167 /* sb.c */ 168 168 int msn_sb_write( struct msn_switchboard *sb, char *s, int len ); 169 struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, int port, char *key, int session );170 struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *handle );171 struct msn_switchboard *msn_sb_by_chat( struct conversation*c );172 struct msn_switchboard *msn_sb_spare( struct gaim_connection *gc );169 struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session ); 170 struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle ); 171 struct msn_switchboard *msn_sb_by_chat( struct groupchat *c ); 172 struct msn_switchboard *msn_sb_spare( struct im_connection *ic ); 173 173 int msn_sb_sendmessage( struct msn_switchboard *sb, char *text ); 174 struct conversation*msn_sb_to_chat( struct msn_switchboard *sb );174 struct groupchat *msn_sb_to_chat( struct msn_switchboard *sb ); 175 175 void msn_sb_destroy( struct msn_switchboard *sb ); 176 176 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); -
protocols/msn/msn_util.c
rfa29d093 r0da65d5 28 28 #include <ctype.h> 29 29 30 int msn_write( struct gaim_connection *gc, char *s, int len )31 { 32 struct msn_data *md = gc->proto_data;30 int msn_write( struct im_connection *ic, char *s, int len ) 31 { 32 struct msn_data *md = ic->proto_data; 33 33 int st; 34 34 … … 36 36 if( st != len ) 37 37 { 38 hide_login_progress_error( gc, "Short write() to main server" );39 signoff( gc );38 hide_login_progress_error( ic, "Short write() to main server" ); 39 signoff( ic ); 40 40 return( 0 ); 41 41 } … … 44 44 } 45 45 46 int msn_logged_in( struct gaim_connection *gc )47 { 48 account_online( gc );46 int msn_logged_in( struct im_connection *ic ) 47 { 48 account_online( ic ); 49 49 50 50 return( 0 ); 51 51 } 52 52 53 int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char *realname_ )54 { 55 struct msn_data *md = gc->proto_data;53 int msn_buddy_list_add( struct im_connection *ic, char *list, char *who, char *realname_ ) 54 { 55 struct msn_data *md = ic->proto_data; 56 56 char buf[1024], *realname; 57 57 … … 59 59 60 60 g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s\r\n", ++md->trId, list, who, realname ); 61 if( msn_write( gc, buf, strlen( buf ) ) )61 if( msn_write( ic, buf, strlen( buf ) ) ) 62 62 { 63 63 g_free( realname ); … … 71 71 } 72 72 73 int msn_buddy_list_remove( struct gaim_connection *gc, char *list, char *who )74 { 75 struct msn_data *md = gc->proto_data;73 int msn_buddy_list_remove( struct im_connection *ic, char *list, char *who ) 74 { 75 struct msn_data *md = ic->proto_data; 76 76 char buf[1024]; 77 77 78 78 g_snprintf( buf, sizeof( buf ), "REM %d %s %s\r\n", ++md->trId, list, who ); 79 if( msn_write( gc, buf, strlen( buf ) ) )79 if( msn_write( ic, buf, strlen( buf ) ) ) 80 80 return( 1 ); 81 81 … … 85 85 struct msn_buddy_ask_data 86 86 { 87 struct gaim_connection *gc;87 struct im_connection *ic; 88 88 char *handle; 89 89 char *realname; … … 92 92 static void msn_buddy_ask_yes( gpointer w, struct msn_buddy_ask_data *bla ) 93 93 { 94 msn_buddy_list_add( bla-> gc, "AL", bla->handle, bla->realname );95 96 if( find_buddy( bla-> gc, bla->handle ) == NULL )97 show_got_added( bla-> gc, bla->handle, NULL );94 msn_buddy_list_add( bla->ic, "AL", bla->handle, bla->realname ); 95 96 if( find_buddy( bla->ic, bla->handle ) == NULL ) 97 show_got_added( bla->ic, bla->handle, NULL ); 98 98 99 99 g_free( bla->handle ); … … 104 104 static void msn_buddy_ask_no( gpointer w, struct msn_buddy_ask_data *bla ) 105 105 { 106 msn_buddy_list_add( bla-> gc, "BL", bla->handle, bla->realname );106 msn_buddy_list_add( bla->ic, "BL", bla->handle, bla->realname ); 107 107 108 108 g_free( bla->handle ); … … 111 111 } 112 112 113 void msn_buddy_ask( struct gaim_connection *gc, char *handle, char *realname )113 void msn_buddy_ask( struct im_connection *ic, char *handle, char *realname ) 114 114 { 115 115 struct msn_buddy_ask_data *bla = g_new0( struct msn_buddy_ask_data, 1 ); 116 116 char buf[1024]; 117 117 118 bla-> gc = gc;118 bla->ic = ic; 119 119 bla->handle = g_strdup( handle ); 120 120 bla->realname = g_strdup( realname ); … … 123 123 "The user %s (%s) wants to add you to his/her buddy list.", 124 124 handle, realname ); 125 do_ask_dialog( gc, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no );125 do_ask_dialog( ic, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no ); 126 126 } 127 127 -
protocols/msn/ns.c
rfa29d093 r0da65d5 38 38 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) 39 39 { 40 struct gaim_connection *gc = data;40 struct im_connection *ic = data; 41 41 struct msn_data *md; 42 42 char s[1024]; 43 43 44 if( !g_slist_find( msn_connections, gc ) )44 if( !g_slist_find( msn_connections, ic ) ) 45 45 return FALSE; 46 46 47 47 if( source == -1 ) 48 48 { 49 hide_login_progress( gc, "Could not connect to server" );50 signoff( gc );49 hide_login_progress( ic, "Could not connect to server" ); 50 signoff( ic ); 51 51 return FALSE; 52 52 } 53 53 54 md = gc->proto_data;54 md = ic->proto_data; 55 55 56 56 if( !md->handler ) 57 57 { 58 58 md->handler = g_new0( struct msn_handler_data, 1 ); 59 md->handler->data = gc;59 md->handler->data = ic; 60 60 md->handler->exec_command = msn_ns_command; 61 61 md->handler->exec_message = msn_ns_message; … … 73 73 74 74 g_snprintf( s, sizeof( s ), "VER %d MSNP8 CVR0\r\n", ++md->trId ); 75 if( msn_write( gc, s, strlen( s ) ) )76 { 77 gc->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, gc );78 set_login_progress( gc, 1, "Connected to server, waiting for reply" );75 if( msn_write( ic, s, strlen( s ) ) ) 76 { 77 ic->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, ic ); 78 set_login_progress( ic, 1, "Connected to server, waiting for reply" ); 79 79 } 80 80 … … 84 84 static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond ) 85 85 { 86 struct gaim_connection *gc = data;87 struct msn_data *md = gc->proto_data;86 struct im_connection *ic = data; 87 struct msn_data *md = ic->proto_data; 88 88 89 89 if( msn_handler( md->handler ) == -1 ) /* Don't do this on ret == 0, it's already done then. */ 90 90 { 91 hide_login_progress( gc, "Error while reading from server" );92 signoff( gc );91 hide_login_progress( ic, "Error while reading from server" ); 92 signoff( ic ); 93 93 94 94 return FALSE; … … 100 100 static int msn_ns_command( gpointer data, char **cmd, int num_parts ) 101 101 { 102 struct gaim_connection *gc = data;103 struct msn_data *md = gc->proto_data;102 struct im_connection *ic = data; 103 struct msn_data *md = ic->proto_data; 104 104 char buf[1024]; 105 105 … … 114 114 if( cmd[2] && strncmp( cmd[2], "MSNP8", 5 ) != 0 ) 115 115 { 116 hide_login_progress( gc, "Unsupported protocol" );117 signoff( gc );116 hide_login_progress( ic, "Unsupported protocol" ); 117 signoff( ic ); 118 118 return( 0 ); 119 119 } 120 120 121 121 g_snprintf( buf, sizeof( buf ), "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s\r\n", 122 ++md->trId, gc->username );123 return( msn_write( gc, buf, strlen( buf ) ) );122 ++md->trId, ic->username ); 123 return( msn_write( ic, buf, strlen( buf ) ) ); 124 124 } 125 125 else if( strcmp( cmd[0], "CVR" ) == 0 ) 126 126 { 127 127 /* We don't give a damn about the information we just received */ 128 g_snprintf( buf, sizeof( buf ), "USR %d TWN I %s\r\n", ++md->trId, gc->username );129 return( msn_write( gc, buf, strlen( buf ) ) );128 g_snprintf( buf, sizeof( buf ), "USR %d TWN I %s\r\n", ++md->trId, ic->username ); 129 return( msn_write( ic, buf, strlen( buf ) ) ); 130 130 } 131 131 else if( strcmp( cmd[0], "XFR" ) == 0 ) … … 136 136 if( num_parts == 6 && strcmp( cmd[2], "NS" ) == 0 ) 137 137 { 138 b_event_remove( gc->inpa );139 gc->inpa = 0;138 b_event_remove( ic->inpa ); 139 ic->inpa = 0; 140 140 closesocket( md->fd ); 141 141 … … 143 143 if( !server ) 144 144 { 145 hide_login_progress_error( gc, "Syntax error" );146 signoff( gc );145 hide_login_progress_error( ic, "Syntax error" ); 146 signoff( ic ); 147 147 return( 0 ); 148 148 } … … 151 151 server = cmd[3]; 152 152 153 set_login_progress( gc, 1, "Transferring to other server" );154 155 md->fd = proxy_connect( server, port, msn_ns_connected, gc );153 set_login_progress( ic, 1, "Transferring to other server" ); 154 155 md->fd = proxy_connect( server, port, msn_ns_connected, ic ); 156 156 } 157 157 else if( num_parts == 6 && strcmp( cmd[2], "SB" ) == 0 ) … … 162 162 if( !server ) 163 163 { 164 hide_login_progress_error( gc, "Syntax error" );165 signoff( gc );164 hide_login_progress_error( ic, "Syntax error" ); 165 signoff( ic ); 166 166 return( 0 ); 167 167 } … … 172 172 if( strcmp( cmd[4], "CKI" ) != 0 ) 173 173 { 174 hide_login_progress_error( gc, "Unknown authentication method for switchboard" );175 signoff( gc );174 hide_login_progress_error( ic, "Unknown authentication method for switchboard" ); 175 signoff( ic ); 176 176 return( 0 ); 177 177 } 178 178 179 179 debug( "Connecting to a new switchboard with key %s", cmd[5] ); 180 sb = msn_sb_create( gc, server, port, cmd[5], MSN_SB_NEW );180 sb = msn_sb_create( ic, server, port, cmd[5], MSN_SB_NEW ); 181 181 182 182 if( md->msgq ) … … 204 204 else 205 205 { 206 hide_login_progress_error( gc, "Syntax error" );207 signoff( gc );206 hide_login_progress_error( ic, "Syntax error" ); 207 signoff( ic ); 208 208 return( 0 ); 209 209 } … … 214 214 { 215 215 /* Time for some Passport black magic... */ 216 if( !passport_get_id( msn_auth_got_passport_id, gc, gc->username, gc->password, cmd[4] ) )217 { 218 hide_login_progress_error( gc, "Error while contacting Passport server" );219 signoff( gc );216 if( !passport_get_id( msn_auth_got_passport_id, ic, ic->username, ic->password, cmd[4] ) ) 217 { 218 hide_login_progress_error( ic, "Error while contacting Passport server" ); 219 signoff( ic ); 220 220 return( 0 ); 221 221 } … … 227 227 http_decode( cmd[4] ); 228 228 229 strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) );230 gc->displayname[sizeof(gc->displayname)-1] = 0;231 232 if( ( s = set_find( & gc->acc->set, "display_name" ) ) )229 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); 230 ic->displayname[sizeof(ic->displayname)-1] = 0; 231 232 if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) 233 233 { 234 234 g_free( s->value ); … … 236 236 } 237 237 238 set_login_progress( gc, 1, "Authenticated, getting buddy list" );238 set_login_progress( ic, 1, "Authenticated, getting buddy list" ); 239 239 240 240 g_snprintf( buf, sizeof( buf ), "SYN %d 0\r\n", ++md->trId ); 241 return( msn_write( gc, buf, strlen( buf ) ) );241 return( msn_write( ic, buf, strlen( buf ) ) ); 242 242 } 243 243 else 244 244 { 245 hide_login_progress( gc, "Unknown authentication type" );246 signoff( gc );245 hide_login_progress( ic, "Unknown authentication type" ); 246 signoff( ic ); 247 247 return( 0 ); 248 248 } … … 252 252 if( num_parts != 4 ) 253 253 { 254 hide_login_progress_error( gc, "Syntax error" );255 signoff( gc );254 hide_login_progress_error( ic, "Syntax error" ); 255 signoff( ic ); 256 256 return( 0 ); 257 257 } … … 261 261 if( md->handler->msglen <= 0 ) 262 262 { 263 hide_login_progress_error( gc, "Syntax error" );264 signoff( gc );263 hide_login_progress_error( ic, "Syntax error" ); 264 signoff( ic ); 265 265 return( 0 ); 266 266 } … … 276 276 277 277 if( !*cmd[3] || md->buddycount == 0 ) 278 msn_logged_in( gc );278 msn_logged_in( ic ); 279 279 } 280 280 else … … 283 283 Let's assume everything is okay. */ 284 284 285 msn_logged_in( gc );285 msn_logged_in( ic ); 286 286 } 287 287 } … … 292 292 if( num_parts != 4 && num_parts != 5 ) 293 293 { 294 hide_login_progress( gc, "Syntax error" );295 signoff( gc );294 hide_login_progress( ic, "Syntax error" ); 295 signoff( ic ); 296 296 return( 0 ); 297 297 } … … 308 308 group = md->grouplist[num]; 309 309 310 add_buddy( gc, group, cmd[1], cmd[2] );310 add_buddy( ic, group, cmd[1], cmd[2] ); 311 311 } 312 312 if( list & 2 ) /* AL */ 313 313 { 314 gc->permit = g_slist_append( gc->permit, g_strdup( cmd[1] ) );314 ic->permit = g_slist_append( ic->permit, g_strdup( cmd[1] ) ); 315 315 } 316 316 if( list & 4 ) /* BL */ 317 317 { 318 gc->deny = g_slist_append( gc->deny, g_strdup( cmd[1] ) );318 ic->deny = g_slist_append( ic->deny, g_strdup( cmd[1] ) ); 319 319 } 320 320 if( list & 8 ) /* RL */ 321 321 { 322 322 if( ( list & 6 ) == 0 ) 323 msn_buddy_ask( gc, cmd[1], cmd[2] );323 msn_buddy_ask( ic, cmd[1], cmd[2] ); 324 324 } 325 325 326 326 if( --md->buddycount == 0 ) 327 327 { 328 if( gc->flags & OPT_LOGGED_IN )329 { 330 serv_got_crap( gc, "Successfully transferred to different server" );328 if( ic->flags & OPT_LOGGED_IN ) 329 { 330 serv_got_crap( ic, "Successfully transferred to different server" ); 331 331 g_snprintf( buf, sizeof( buf ), "CHG %d %s %d\r\n", ++md->trId, md->away_state->code, 0 ); 332 return( msn_write( gc, buf, strlen( buf ) ) );332 return( msn_write( ic, buf, strlen( buf ) ) ); 333 333 } 334 334 else 335 335 { 336 msn_logged_in( gc );336 msn_logged_in( ic ); 337 337 } 338 338 } … … 344 344 if( num_parts != 4 ) 345 345 { 346 hide_login_progress_error( gc, "Syntax error" );347 signoff( gc );346 hide_login_progress_error( ic, "Syntax error" ); 347 signoff( ic ); 348 348 return( 0 ); 349 349 } … … 363 363 if( num_parts != 3 ) 364 364 { 365 hide_login_progress_error( gc, "Syntax error" );366 signoff( gc );365 hide_login_progress_error( ic, "Syntax error" ); 366 signoff( ic ); 367 367 return( 0 ); 368 368 } … … 377 377 g_snprintf( buf + strlen( buf ), 3, "%02x", digest[i] ); 378 378 379 return( msn_write( gc, buf, strlen( buf ) ) );379 return( msn_write( ic, buf, strlen( buf ) ) ); 380 380 } 381 381 else if( strcmp( cmd[0], "ILN" ) == 0 ) … … 385 385 if( num_parts != 6 ) 386 386 { 387 hide_login_progress_error( gc, "Syntax error" );388 signoff( gc );387 hide_login_progress_error( ic, "Syntax error" ); 388 signoff( ic ); 389 389 return( 0 ); 390 390 } 391 391 392 392 http_decode( cmd[4] ); 393 serv_buddy_rename( gc, cmd[3], cmd[4] );393 serv_buddy_rename( ic, cmd[3], cmd[4] ); 394 394 395 395 st = msn_away_state_by_code( cmd[2] ); … … 400 400 } 401 401 402 serv_got_update( gc, cmd[3], 1, 0, 0, 0, st->number, 0 );402 serv_got_update( ic, cmd[3], 1, 0, 0, 0, st->number, 0 ); 403 403 } 404 404 else if( strcmp( cmd[0], "FLN" ) == 0 ) 405 405 { 406 406 if( cmd[1] ) 407 serv_got_update( gc, cmd[1], 0, 0, 0, 0, 0, 0 );407 serv_got_update( ic, cmd[1], 0, 0, 0, 0, 0, 0 ); 408 408 } 409 409 else if( strcmp( cmd[0], "NLN" ) == 0 ) … … 413 413 if( num_parts != 5 ) 414 414 { 415 hide_login_progress_error( gc, "Syntax error" );416 signoff( gc );415 hide_login_progress_error( ic, "Syntax error" ); 416 signoff( ic ); 417 417 return( 0 ); 418 418 } 419 419 420 420 http_decode( cmd[3] ); 421 serv_buddy_rename( gc, cmd[2], cmd[3] );421 serv_buddy_rename( ic, cmd[2], cmd[3] ); 422 422 423 423 st = msn_away_state_by_code( cmd[1] ); … … 428 428 } 429 429 430 serv_got_update( gc, cmd[2], 1, 0, 0, 0, st->number, 0 );430 serv_got_update( ic, cmd[2], 1, 0, 0, 0, st->number, 0 ); 431 431 } 432 432 else if( strcmp( cmd[0], "RNG" ) == 0 ) … … 438 438 if( num_parts != 7 ) 439 439 { 440 hide_login_progress_error( gc, "Syntax error" );441 signoff( gc );440 hide_login_progress_error( ic, "Syntax error" ); 441 signoff( ic ); 442 442 return( 0 ); 443 443 } … … 448 448 if( !server ) 449 449 { 450 hide_login_progress_error( gc, "Syntax error" );451 signoff( gc );450 hide_login_progress_error( ic, "Syntax error" ); 451 signoff( ic ); 452 452 return( 0 ); 453 453 } … … 458 458 if( strcmp( cmd[3], "CKI" ) != 0 ) 459 459 { 460 hide_login_progress_error( gc, "Unknown authentication method for switchboard" );461 signoff( gc );460 hide_login_progress_error( ic, "Unknown authentication method for switchboard" ); 461 signoff( ic ); 462 462 return( 0 ); 463 463 } … … 465 465 debug( "Got a call from %s (session %d). Key = %s", cmd[5], session, cmd[4] ); 466 466 467 sb = msn_sb_create( gc, server, port, cmd[4], session );467 sb = msn_sb_create( ic, server, port, cmd[4], session ); 468 468 sb->who = g_strdup( cmd[5] ); 469 469 } … … 478 478 if( strchr( cmd[4], '@' ) == NULL ) 479 479 { 480 hide_login_progress_error( gc, "Syntax error" );481 signoff( gc );480 hide_login_progress_error( ic, "Syntax error" ); 481 signoff( ic ); 482 482 return( 0 ); 483 483 } 484 484 485 485 /* We got added by someone. If we don't have this person in permit/deny yet, inform the user. */ 486 for( l = gc->permit; l; l = l->next )486 for( l = ic->permit; l; l = l->next ) 487 487 if( g_strcasecmp( l->data, cmd[4] ) == 0 ) 488 488 return( 1 ); 489 489 490 for( l = gc->deny; l; l = l->next )490 for( l = ic->deny; l; l = l->next ) 491 491 if( g_strcasecmp( l->data, cmd[4] ) == 0 ) 492 492 return( 1 ); 493 493 494 msn_buddy_ask( gc, cmd[4], cmd[5] );494 msn_buddy_ask( ic, cmd[4], cmd[5] ); 495 495 } 496 496 } … … 499 499 if( cmd[1] && strcmp( cmd[1], "OTH" ) == 0 ) 500 500 { 501 hide_login_progress_error( gc, "Someone else logged in with your account" );502 gc->wants_to_die = 1;501 hide_login_progress_error( ic, "Someone else logged in with your account" ); 502 ic->wants_to_die = 1; 503 503 } 504 504 else if( cmd[1] && strcmp( cmd[1], "SSD" ) == 0 ) 505 505 { 506 hide_login_progress_error( gc, "Terminating session because of server shutdown" );506 hide_login_progress_error( ic, "Terminating session because of server shutdown" ); 507 507 } 508 508 else 509 509 { 510 hide_login_progress_error( gc, "Session terminated by remote server (reason unknown)" );511 } 512 513 signoff( gc );510 hide_login_progress_error( ic, "Session terminated by remote server (reason unknown)" ); 511 } 512 513 signoff( ic ); 514 514 return( 0 ); 515 515 } … … 518 518 if( num_parts != 5 ) 519 519 { 520 hide_login_progress_error( gc, "Syntax error" );521 signoff( gc );522 return( 0 ); 523 } 524 525 if( g_strcasecmp( cmd[3], gc->username ) == 0 )520 hide_login_progress_error( ic, "Syntax error" ); 521 signoff( ic ); 522 return( 0 ); 523 } 524 525 if( g_strcasecmp( cmd[3], ic->username ) == 0 ) 526 526 { 527 527 set_t *s; 528 528 529 529 http_decode( cmd[4] ); 530 strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) );531 gc->displayname[sizeof(gc->displayname)-1] = 0;532 533 if( ( s = set_find( & gc->acc->set, "display_name" ) ) )530 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); 531 ic->displayname[sizeof(ic->displayname)-1] = 0; 532 533 if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) 534 534 { 535 535 g_free( s->value ); … … 541 541 /* This is not supposed to happen, but let's handle it anyway... */ 542 542 http_decode( cmd[4] ); 543 serv_buddy_rename( gc, cmd[3], cmd[4] );543 serv_buddy_rename( ic, cmd[3], cmd[4] ); 544 544 } 545 545 } 546 546 else if( strcmp( cmd[0], "IPG" ) == 0 ) 547 547 { 548 do_error_dialog( gc, "Received IPG command, we don't handle them yet.", "MSN" );548 do_error_dialog( ic, "Received IPG command, we don't handle them yet.", "MSN" ); 549 549 550 550 md->handler->msglen = atoi( cmd[1] ); … … 552 552 if( md->handler->msglen <= 0 ) 553 553 { 554 hide_login_progress_error( gc, "Syntax error" );555 signoff( gc );554 hide_login_progress_error( ic, "Syntax error" ); 555 signoff( ic ); 556 556 return( 0 ); 557 557 } … … 563 563 564 564 g_snprintf( buf, sizeof( buf ), "Error reported by MSN server: %s", err->text ); 565 do_error_dialog( gc, buf, "MSN" );565 do_error_dialog( ic, buf, "MSN" ); 566 566 567 567 if( err->flags & STATUS_FATAL ) 568 568 { 569 signoff( gc );569 signoff( ic ); 570 570 return( 0 ); 571 571 } … … 581 581 static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts ) 582 582 { 583 struct gaim_connection *gc = data;583 struct im_connection *ic = data; 584 584 char *body; 585 585 int blen = 0; … … 617 617 { 618 618 if( arg1 ) 619 serv_got_crap( gc, "The server is going down for maintenance in %s minutes.", arg1 );619 serv_got_crap( ic, "The server is going down for maintenance in %s minutes.", arg1 ); 620 620 } 621 621 … … 634 634 if( inbox && folders ) 635 635 { 636 serv_got_crap( gc, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );636 serv_got_crap( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); 637 637 } 638 638 } … … 644 644 if( from && fromname ) 645 645 { 646 serv_got_crap( gc, "Received an e-mail message from %s <%s>.", fromname, from );646 serv_got_crap( ic, "Received an e-mail message from %s <%s>.", fromname, from ); 647 647 } 648 648 } … … 665 665 static void msn_auth_got_passport_id( struct passport_reply *rep ) 666 666 { 667 struct gaim_connection *gc = rep->data;668 struct msn_data *md = gc->proto_data;667 struct im_connection *ic = rep->data; 668 struct msn_data *md = ic->proto_data; 669 669 char *key = rep->result; 670 670 char buf[1024]; … … 677 677 rep->error_string ? rep->error_string : "Unknown error" ); 678 678 679 hide_login_progress( gc, err );680 signoff( gc );679 hide_login_progress( ic, err ); 680 signoff( ic ); 681 681 682 682 g_free( err ); … … 685 685 { 686 686 g_snprintf( buf, sizeof( buf ), "USR %d TWN S %s\r\n", ++md->trId, key ); 687 msn_write( gc, buf, strlen( buf ) );687 msn_write( ic, buf, strlen( buf ) ); 688 688 } 689 689 } -
protocols/msn/sb.c
rfa29d093 r0da65d5 48 48 } 49 49 50 struct msn_switchboard *msn_sb_create( struct gaim_connection *gc, char *host, int port, char *key, int session )51 { 52 struct msn_data *md = gc->proto_data;50 struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session ) 51 { 52 struct msn_data *md = ic->proto_data; 53 53 struct msn_switchboard *sb = g_new0( struct msn_switchboard, 1 ); 54 54 … … 60 60 } 61 61 62 sb-> gc = gc;62 sb->ic = ic; 63 63 sb->key = g_strdup( key ); 64 64 sb->session = session; … … 70 70 } 71 71 72 struct msn_switchboard *msn_sb_by_handle( struct gaim_connection *gc, char *handle )73 { 74 struct msn_data *md = gc->proto_data;72 struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle ) 73 { 74 struct msn_data *md = ic->proto_data; 75 75 struct msn_switchboard *sb; 76 76 GSList *l; … … 86 86 } 87 87 88 struct msn_switchboard *msn_sb_by_chat( struct conversation*c )89 { 90 struct msn_data *md = c-> gc->proto_data;88 struct msn_switchboard *msn_sb_by_chat( struct groupchat *c ) 89 { 90 struct msn_data *md = c->ic->proto_data; 91 91 struct msn_switchboard *sb; 92 92 GSList *l; … … 102 102 } 103 103 104 struct msn_switchboard *msn_sb_spare( struct gaim_connection *gc )105 { 106 struct msn_data *md = gc->proto_data;104 struct msn_switchboard *msn_sb_spare( struct im_connection *ic ) 105 { 106 struct msn_data *md = ic->proto_data; 107 107 struct msn_switchboard *sb; 108 108 GSList *l; … … 142 142 else 143 143 { 144 i = strlen( MSN_TYPING_HEADERS ) + strlen( sb-> gc->username );144 i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->ic->username ); 145 145 buf = g_new0( char, i ); 146 i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb-> gc->username );146 i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->username ); 147 147 } 148 148 … … 177 177 } 178 178 179 struct conversation*msn_sb_to_chat( struct msn_switchboard *sb )180 { 181 struct gaim_connection *gc = sb->gc;179 struct groupchat *msn_sb_to_chat( struct msn_switchboard *sb ) 180 { 181 struct im_connection *ic = sb->ic; 182 182 char buf[1024]; 183 183 184 184 /* Create the groupchat structure. */ 185 185 g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); 186 sb->chat = serv_got_joined_chat( gc, buf );186 sb->chat = serv_got_joined_chat( ic, buf ); 187 187 188 188 /* Populate the channel. */ 189 189 if( sb->who ) add_chat_buddy( sb->chat, sb->who ); 190 add_chat_buddy( sb->chat, gc->username );190 add_chat_buddy( sb->chat, ic->username ); 191 191 192 192 /* And make sure the switchboard doesn't look like a regular chat anymore. */ … … 202 202 void msn_sb_destroy( struct msn_switchboard *sb ) 203 203 { 204 struct gaim_connection *gc = sb->gc;205 struct msn_data *md = gc->proto_data;204 struct im_connection *ic = sb->ic; 205 struct msn_data *md = ic->proto_data; 206 206 207 207 debug( "Destroying switchboard: %s", sb->who ? sb->who : sb->key ? sb->key : "" ); … … 222 222 g_slist_free( sb->msgq ); 223 223 224 serv_got_crap( gc, "Warning: Closing down MSN switchboard connection with "224 serv_got_crap( ic, "Warning: Closing down MSN switchboard connection with " 225 225 "unsent message to %s, you'll have to resend it.", 226 226 sb->who ? sb->who : "(unknown)" ); … … 253 253 { 254 254 struct msn_switchboard *sb = data; 255 struct gaim_connection *gc;255 struct im_connection *ic; 256 256 struct msn_data *md; 257 257 char buf[1024]; … … 261 261 return FALSE; 262 262 263 gc = sb->gc;264 md = gc->proto_data;263 ic = sb->ic; 264 md = ic->proto_data; 265 265 266 266 if( source != sb->fd ) … … 280 280 281 281 if( sb->session == MSN_SB_NEW ) 282 g_snprintf( buf, sizeof( buf ), "USR %d %s %s\r\n", ++sb->trId, gc->username, sb->key );282 g_snprintf( buf, sizeof( buf ), "USR %d %s %s\r\n", ++sb->trId, ic->username, sb->key ); 283 283 else 284 g_snprintf( buf, sizeof( buf ), "ANS %d %s %s %d\r\n", ++sb->trId, gc->username, sb->key, sb->session );284 g_snprintf( buf, sizeof( buf ), "ANS %d %s %s %d\r\n", ++sb->trId, ic->username, sb->key, sb->session ); 285 285 286 286 if( msn_sb_write( sb, buf, strlen( buf ) ) ) … … 310 310 { 311 311 struct msn_switchboard *sb = data; 312 struct gaim_connection *gc = sb->gc;312 struct im_connection *ic = sb->ic; 313 313 char buf[1024]; 314 314 … … 321 321 if( strcmp( cmd[0], "XFR" ) == 0 ) 322 322 { 323 hide_login_progress_error( gc, "Received an XFR from a switchboard server, unable to comply! This is likely to be a bug, please report it!" );324 signoff( gc );323 hide_login_progress_error( ic, "Received an XFR from a switchboard server, unable to comply! This is likely to be a bug, please report it!" ); 324 signoff( ic ); 325 325 return( 0 ); 326 326 } … … 374 374 { 375 375 g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); 376 sb->chat = serv_got_joined_chat( gc, buf );376 sb->chat = serv_got_joined_chat( ic, buf ); 377 377 378 378 g_free( sb->who ); … … 384 384 if( num == tot ) 385 385 { 386 add_chat_buddy( sb->chat, gc->username );386 add_chat_buddy( sb->chat, ic->username ); 387 387 } 388 388 } … … 529 529 530 530 g_snprintf( buf, sizeof( buf ), "Error reported by switchboard server: %s", err->text ); 531 do_error_dialog( gc, buf, "MSN" );531 do_error_dialog( ic, buf, "MSN" ); 532 532 533 533 if( err->flags & STATUS_SB_FATAL ) … … 538 538 else if( err->flags & STATUS_FATAL ) 539 539 { 540 signoff( gc );540 signoff( ic ); 541 541 return 0; 542 542 } … … 579 579 { 580 580 struct msn_switchboard *sb = data; 581 struct gaim_connection *gc = sb->gc;581 struct im_connection *ic = sb->ic; 582 582 char *body; 583 583 int blen = 0; … … 608 608 if( sb->who ) 609 609 { 610 serv_got_im( gc, cmd[1], body, 0, 0, blen );610 serv_got_im( ic, cmd[1], body, 0, 0, blen ); 611 611 } 612 612 else if( sb->chat ) … … 667 667 if( sb->who ) 668 668 { 669 serv_got_im( gc, cmd[1], buf, 0, 0, strlen( buf ) );669 serv_got_im( ic, cmd[1], buf, 0, 0, strlen( buf ) ); 670 670 } 671 671 else if( sb->chat ) … … 684 684 if( who ) 685 685 { 686 serv_got_typing( gc, who, 5, 1 );686 serv_got_typing( ic, who, 5, 1 ); 687 687 g_free( who ); 688 688 } -
protocols/nogaim.c
rfa29d093 r0da65d5 36 36 #include <ctype.h> 37 37 38 static int remove_chat_buddy_silent( struct conversation*b, char *handle );38 static int remove_chat_buddy_silent( struct groupchat *b, char *handle ); 39 39 40 40 GSList *connections; … … 115 115 void nogaim_init() 116 116 { 117 extern void msn_init ();118 extern void oscar_init ();119 extern void byahoo_init ();120 extern void jabber_init ();117 extern void msn_initmodule(); 118 extern void oscar_initmodule(); 119 extern void byahoo_initmodule(); 120 extern void jabber_initmodule(); 121 121 122 122 #ifdef WITH_MSN 123 msn_init ();123 msn_initmodule(); 124 124 #endif 125 125 126 126 #ifdef WITH_OSCAR 127 oscar_init ();127 oscar_initmodule(); 128 128 #endif 129 129 130 130 #ifdef WITH_YAHOO 131 byahoo_init ();131 byahoo_initmodule(); 132 132 #endif 133 133 134 134 #ifdef WITH_JABBER 135 jabber_init ();135 jabber_initmodule(); 136 136 #endif 137 137 … … 145 145 /* multi.c */ 146 146 147 struct gaim_connection *new_gaim_conn( account_t *acc )148 { 149 struct gaim_connection *gc;150 151 gc = g_new0( struct gaim_connection, 1 );147 struct im_connection *new_gaim_conn( account_t *acc ) 148 { 149 struct im_connection *ic; 150 151 ic = g_new0( struct im_connection, 1 ); 152 152 153 153 /* Maybe we should get rid of this memory waste later. ;-) */ 154 g_snprintf( gc->username, sizeof( gc->username ), "%s", acc->user );155 g_snprintf( gc->password, sizeof( gc->password ), "%s", acc->pass );156 157 gc->irc = acc->irc;158 gc->acc = acc;159 acc-> gc = gc;160 161 connections = g_slist_append( connections, gc );162 163 return( gc );164 } 165 166 void destroy_gaim_conn( struct gaim_connection *gc )154 g_snprintf( ic->username, sizeof( ic->username ), "%s", acc->user ); 155 g_snprintf( ic->password, sizeof( ic->password ), "%s", acc->pass ); 156 157 ic->irc = acc->irc; 158 ic->acc = acc; 159 acc->ic = ic; 160 161 connections = g_slist_append( connections, ic ); 162 163 return( ic ); 164 } 165 166 void destroy_gaim_conn( struct im_connection *ic ) 167 167 { 168 168 account_t *a; 169 169 170 170 /* Destroy the pointer to this connection from the account list */ 171 for( a = gc->irc->accounts; a; a = a->next )172 if( a-> gc == gc )173 { 174 a-> gc = NULL;171 for( a = ic->irc->accounts; a; a = a->next ) 172 if( a->ic == ic ) 173 { 174 a->ic = NULL; 175 175 break; 176 176 } 177 177 178 connections = g_slist_remove( connections, gc );179 g_free( gc );180 } 181 182 void set_login_progress( struct gaim_connection *gc, int step, char *msg )183 { 184 serv_got_crap( gc, "Logging in: %s", msg );178 connections = g_slist_remove( connections, ic ); 179 g_free( ic ); 180 } 181 182 void set_login_progress( struct im_connection *ic, int step, char *msg ) 183 { 184 serv_got_crap( ic, "Logging in: %s", msg ); 185 185 } 186 186 187 187 /* Errors *while* logging in */ 188 void hide_login_progress( struct gaim_connection *gc, char *msg )189 { 190 serv_got_crap( gc, "Login error: %s", msg );188 void hide_login_progress( struct im_connection *ic, char *msg ) 189 { 190 serv_got_crap( ic, "Login error: %s", msg ); 191 191 } 192 192 193 193 /* Errors *after* logging in */ 194 void hide_login_progress_error( struct gaim_connection *gc, char *msg )195 { 196 serv_got_crap( gc, "Logged out: %s", msg );197 } 198 199 void serv_got_crap( struct gaim_connection *gc, char *format, ... )194 void hide_login_progress_error( struct im_connection *ic, char *msg ) 195 { 196 serv_got_crap( ic, "Logged out: %s", msg ); 197 } 198 199 void serv_got_crap( struct im_connection *ic, char *format, ... ) 200 200 { 201 201 va_list params; … … 207 207 va_end( params ); 208 208 209 if( ( g_strcasecmp( set_getstr( & gc->irc->set, "strip_html" ), "always" ) == 0 ) ||210 ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )209 if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || 210 ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 211 211 strip_html( text ); 212 212 213 213 /* Try to find a different connection on the same protocol. */ 214 for( a = gc->irc->accounts; a; a = a->next )215 if( a->prpl == gc->acc->prpl && a->gc != gc )214 for( a = ic->irc->accounts; a; a = a->next ) 215 if( a->prpl == ic->acc->prpl && a->ic != ic ) 216 216 break; 217 217 218 218 /* If we found one, include the screenname in the message. */ 219 219 if( a ) 220 irc_usermsg( gc->irc, "%s(%s) - %s", gc->acc->prpl->name, gc->username, text );220 irc_usermsg( ic->irc, "%s(%s) - %s", ic->acc->prpl->name, ic->username, text ); 221 221 else 222 irc_usermsg( gc->irc, "%s - %s", gc->acc->prpl->name, text );222 irc_usermsg( ic->irc, "%s - %s", ic->acc->prpl->name, text ); 223 223 224 224 g_free( text ); … … 227 227 static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond ) 228 228 { 229 struct gaim_connection *gc = d;230 231 if( gc->acc->prpl->keepalive )232 gc->acc->prpl->keepalive( gc );229 struct im_connection *ic = d; 230 231 if( ic->acc->prpl->keepalive ) 232 ic->acc->prpl->keepalive( ic ); 233 233 234 234 return TRUE; 235 235 } 236 236 237 void account_online( struct gaim_connection *gc )237 void account_online( struct im_connection *ic ) 238 238 { 239 239 user_t *u; … … 242 242 the whole login sequence again, so these "late" calls to this 243 243 function should be handled correctly. (IOW, ignored) */ 244 if( gc->flags & OPT_LOGGED_IN )244 if( ic->flags & OPT_LOGGED_IN ) 245 245 return; 246 246 247 u = user_find( gc->irc, gc->irc->nick );248 249 serv_got_crap( gc, "Logged in" );250 251 gc->keepalive = b_timeout_add( 60000, send_keepalive, gc );252 gc->flags |= OPT_LOGGED_IN;247 u = user_find( ic->irc, ic->irc->nick ); 248 249 serv_got_crap( ic, "Logged in" ); 250 251 ic->keepalive = b_timeout_add( 60000, send_keepalive, ic ); 252 ic->flags |= OPT_LOGGED_IN; 253 253 254 254 /* Also necessary when we're not away, at least for some of the 255 255 protocols. */ 256 bim_set_away( gc, u->away );256 bim_set_away( ic, u->away ); 257 257 } 258 258 … … 274 274 } 275 275 276 void signoff( struct gaim_connection *gc )277 { 278 irc_t *irc = gc->irc;276 void signoff( struct im_connection *ic ) 277 { 278 irc_t *irc = ic->irc; 279 279 user_t *t, *u = irc->users; 280 280 account_t *a; … … 282 282 /* Nested calls might happen sometimes, this is probably the best 283 283 place to catch them. */ 284 if( gc->flags & OPT_LOGGING_OUT )284 if( ic->flags & OPT_LOGGING_OUT ) 285 285 return; 286 286 else 287 gc->flags |= OPT_LOGGING_OUT;288 289 serv_got_crap( gc, "Signing off.." );290 291 b_event_remove( gc->keepalive );292 gc->keepalive = 0;293 gc->acc->prpl->close( gc );294 b_event_remove( gc->inpa );287 ic->flags |= OPT_LOGGING_OUT; 288 289 serv_got_crap( ic, "Signing off.." ); 290 291 b_event_remove( ic->keepalive ); 292 ic->keepalive = 0; 293 ic->acc->prpl->logout( ic ); 294 b_event_remove( ic->inpa ); 295 295 296 296 while( u ) 297 297 { 298 if( u-> gc == gc )298 if( u->ic == ic ) 299 299 { 300 300 t = u->next; … … 306 306 } 307 307 308 query_del_by_ gc( gc->irc, gc );308 query_del_by_conn( ic->irc, ic ); 309 309 310 310 for( a = irc->accounts; a; a = a->next ) 311 if( a-> gc == gc )311 if( a->ic == ic ) 312 312 break; 313 313 … … 316 316 /* Uhm... This is very sick. */ 317 317 } 318 else if( ! gc->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) &&318 else if( !ic->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) && 319 319 set_getbool( &a->set, "auto_reconnect" ) ) 320 320 { 321 321 int delay = set_getint( &irc->set, "auto_reconnect_delay" ); 322 322 323 serv_got_crap( gc, "Reconnecting in %d seconds..", delay );323 serv_got_crap( ic, "Reconnecting in %d seconds..", delay ); 324 324 a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a ); 325 325 } 326 326 327 destroy_gaim_conn( gc );327 destroy_gaim_conn( ic ); 328 328 } 329 329 … … 331 331 /* dialogs.c */ 332 332 333 void do_error_dialog( struct gaim_connection *gc, char *msg, char *title )333 void do_error_dialog( struct im_connection *ic, char *msg, char *title ) 334 334 { 335 335 if( msg && title ) 336 serv_got_crap( gc, "Error: %s: %s", title, msg );336 serv_got_crap( ic, "Error: %s: %s", title, msg ); 337 337 else if( msg ) 338 serv_got_crap( gc, "Error: %s", msg );338 serv_got_crap( ic, "Error: %s", msg ); 339 339 else if( title ) 340 serv_got_crap( gc, "Error: %s", title );340 serv_got_crap( ic, "Error: %s", title ); 341 341 else 342 serv_got_crap( gc, "Error" );343 } 344 345 void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont )346 { 347 query_add( gc->irc, gc, msg, doit, dont, data );342 serv_got_crap( ic, "Error" ); 343 } 344 345 void do_ask_dialog( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ) 346 { 347 query_add( ic->irc, ic, msg, doit, dont, data ); 348 348 } 349 349 … … 351 351 /* list.c */ 352 352 353 void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname )353 void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname ) 354 354 { 355 355 user_t *u; 356 356 char nick[MAX_NICK_LENGTH+1]; 357 357 char *s; 358 irc_t *irc = gc->irc;358 irc_t *irc = ic->irc; 359 359 360 360 if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */ 361 serv_got_crap( gc, "Receiving user add from handle: %s", handle );362 363 if( user_findhandle( gc, handle ) )361 serv_got_crap( ic, "Receiving user add from handle: %s", handle ); 362 363 if( user_findhandle( ic, handle ) ) 364 364 { 365 365 if( set_getbool( &irc->set, "debug" ) ) 366 serv_got_crap( gc, "User already exists, ignoring add request: %s", handle );366 serv_got_crap( ic, "User already exists, ignoring add request: %s", handle ); 367 367 368 368 return; … … 372 372 373 373 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 374 strcpy( nick, nick_get( gc->acc, handle, realname ) );375 376 u = user_add( gc->irc, nick );374 strcpy( nick, nick_get( ic->acc, handle, realname ) ); 375 376 u = user_add( ic->irc, nick ); 377 377 378 378 if( !realname || !*realname ) realname = nick; … … 384 384 u->user = g_strndup( handle, s - handle ); 385 385 } 386 else if( gc->acc->server )386 else if( ic->acc->server ) 387 387 { 388 388 char *colon; 389 389 390 if( ( colon = strchr( gc->acc->server, ':' ) ) )391 u->host = g_strndup( gc->acc->server,392 colon - gc->acc->server );390 if( ( colon = strchr( ic->acc->server, ':' ) ) ) 391 u->host = g_strndup( ic->acc->server, 392 colon - ic->acc->server ); 393 393 else 394 u->host = g_strdup( gc->acc->server );394 u->host = g_strdup( ic->acc->server ); 395 395 396 396 u->user = g_strdup( handle ); … … 403 403 else 404 404 { 405 u->host = g_strdup( gc->acc->prpl->name );405 u->host = g_strdup( ic->acc->prpl->name ); 406 406 u->user = g_strdup( handle ); 407 407 } 408 408 409 u-> gc = gc;409 u->ic = ic; 410 410 u->handle = g_strdup( handle ); 411 411 if( group ) u->group = g_strdup( group ); … … 414 414 } 415 415 416 struct buddy *find_buddy( struct gaim_connection *gc, char *handle )416 struct buddy *find_buddy( struct im_connection *ic, char *handle ) 417 417 { 418 418 static struct buddy b[1]; 419 419 user_t *u; 420 420 421 u = user_findhandle( gc, handle );421 u = user_findhandle( ic, handle ); 422 422 423 423 if( !u ) … … 428 428 strncpy( b->show, u->realname, BUDDY_ALIAS_MAXLEN ); 429 429 b->present = u->online; 430 b-> gc = u->gc;430 b->ic = u->ic; 431 431 432 432 return( b ); 433 433 } 434 434 435 void signoff_blocked( struct gaim_connection *gc )435 void signoff_blocked( struct im_connection *ic ) 436 436 { 437 437 return; /* Make all blocked users look invisible (TODO?) */ … … 439 439 440 440 441 void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname )442 { 443 user_t *u = user_findhandle( gc, handle );441 void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ) 442 { 443 user_t *u = user_findhandle( ic, handle ); 444 444 445 445 if( !u ) return; … … 451 451 u->realname = g_strdup( realname ); 452 452 453 if( ( gc->flags & OPT_LOGGED_IN ) && set_getbool( &gc->irc->set, "display_namechanges" ) )454 serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname );453 if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) ) 454 serv_got_crap( ic, "User `%s' changed name to `%s'", u->nick, u->realname ); 455 455 } 456 456 } … … 461 461 struct show_got_added_data 462 462 { 463 struct gaim_connection *gc;463 struct im_connection *ic; 464 464 char *handle; 465 465 }; … … 473 473 void show_got_added_yes( gpointer w, struct show_got_added_data *data ) 474 474 { 475 data-> gc->acc->prpl->add_buddy( data->gc, data->handle);476 add_buddy( data-> gc, NULL, data->handle, data->handle );475 data->ic->acc->prpl->add_buddy( data->ic, data->handle, NULL ); 476 add_buddy( data->ic, NULL, data->handle, data->handle ); 477 477 478 478 return show_got_added_no( w, data ); 479 479 } 480 480 481 void show_got_added( struct gaim_connection *gc, char *handle, const char *realname )481 void show_got_added( struct im_connection *ic, char *handle, const char *realname ) 482 482 { 483 483 struct show_got_added_data *data = g_new0( struct show_got_added_data, 1 ); … … 485 485 486 486 /* TODO: Make a setting for this! */ 487 if( user_findhandle( gc, handle ) != NULL )487 if( user_findhandle( ic, handle ) != NULL ) 488 488 return; 489 489 490 490 s = g_strdup_printf( "The user %s is not in your buddy list yet. Do you want to add him/her now?", handle ); 491 491 492 data-> gc = gc;492 data->ic = ic; 493 493 data->handle = g_strdup( handle ); 494 query_add( gc->irc, gc, s, show_got_added_yes, show_got_added_no, data );494 query_add( ic->irc, ic, s, show_got_added_yes, show_got_added_no, data ); 495 495 } 496 496 … … 498 498 /* server.c */ 499 499 500 void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps )500 void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps ) 501 501 { 502 502 user_t *u; 503 503 int oa, oo; 504 504 505 u = user_findhandle( gc, handle );505 u = user_findhandle( ic, handle ); 506 506 507 507 if( !u ) 508 508 { 509 if( g_strcasecmp( set_getstr( & gc->irc->set, "handle_unknown" ), "add" ) == 0 )510 { 511 add_buddy( gc, NULL, handle, NULL );512 u = user_findhandle( gc, handle );509 if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 ) 510 { 511 add_buddy( ic, NULL, handle, NULL ); 512 u = user_findhandle( ic, handle ); 513 513 } 514 514 else 515 515 { 516 if( set_getbool( & gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 )516 if( set_getbool( &ic->irc->set, "debug" ) || g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "ignore" ) != 0 ) 517 517 { 518 serv_got_crap( gc, "serv_got_update() for handle %s:", handle );519 serv_got_crap( gc, "loggedin = %d, type = %d", loggedin, type );518 serv_got_crap( ic, "serv_got_update() for handle %s:", handle ); 519 serv_got_crap( ic, "loggedin = %d, type = %d", loggedin, type ); 520 520 } 521 521 … … 537 537 if( loggedin && !u->online ) 538 538 { 539 irc_spawn( gc->irc, u );539 irc_spawn( ic->irc, u ); 540 540 u->online = 1; 541 541 } 542 542 else if( !loggedin && u->online ) 543 543 { 544 struct conversation*c;545 546 irc_kill( gc->irc, u );544 struct groupchat *c; 545 546 irc_kill( ic->irc, u ); 547 547 u->online = 0; 548 548 549 549 /* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */ 550 for( c = gc->conversations; c; c = c->next )550 for( c = ic->conversations; c; c = c->next ) 551 551 remove_chat_buddy_silent( c, handle ); 552 552 } 553 553 554 if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "oscar" ) == 0 || strcmp( gc->acc->prpl->name, "icq" ) == 0 ) )554 if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "oscar" ) == 0 || strcmp( ic->acc->prpl->name, "icq" ) == 0 ) ) 555 555 { 556 556 u->away = g_strdup( "Away" ); 557 557 } 558 else if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "jabber" ) == 0 ) )558 else if( ( type & UC_UNAVAILABLE ) && ( strcmp( ic->acc->prpl->name, "jabber" ) == 0 ) ) 559 559 { 560 560 if( type & UC_DND ) … … 565 565 u->away = g_strdup( "Away" ); 566 566 } 567 else if( ( type & UC_UNAVAILABLE ) && gc->acc->prpl->get_status_string )568 { 569 u->away = g_strdup( gc->acc->prpl->get_status_string( gc, type ) );567 else if( ( type & UC_UNAVAILABLE ) && ic->acc->prpl->get_status_string ) 568 { 569 u->away = g_strdup( ic->acc->prpl->get_status_string( ic, type ) ); 570 570 } 571 571 else … … 573 573 574 574 /* LISPy... */ 575 if( ( set_getbool( & gc->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */575 if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ 576 576 ( u->online ) && /* Don't touch offline people */ 577 577 ( ( ( u->online != oo ) && !u->away ) || /* Voice joining people */ 578 578 ( ( u->online == oo ) && ( oa == !u->away ) ) ) ) /* (De)voice people changing state */ 579 579 { 580 irc_write( gc->irc, ":%s MODE %s %cv %s", gc->irc->myhost,581 gc->irc->channel, u->away?'-':'+', u->nick );582 } 583 } 584 585 void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len )586 { 587 irc_t *irc = gc->irc;580 irc_write( ic->irc, ":%s MODE %s %cv %s", ic->irc->myhost, 581 ic->irc->channel, u->away?'-':'+', u->nick ); 582 } 583 } 584 585 void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len ) 586 { 587 irc_t *irc = ic->irc; 588 588 user_t *u; 589 589 590 u = user_findhandle( gc, handle );590 u = user_findhandle( ic, handle ); 591 591 592 592 if( !u ) … … 597 597 { 598 598 if( set_getbool( &irc->set, "debug" ) ) 599 serv_got_crap( gc, "Ignoring message from unknown handle %s", handle );599 serv_got_crap( ic, "Ignoring message from unknown handle %s", handle ); 600 600 601 601 return; … … 613 613 } 614 614 615 add_buddy( gc, NULL, handle, NULL );616 u = user_findhandle( gc, handle );615 add_buddy( ic, NULL, handle, NULL ); 616 u = user_findhandle( ic, handle ); 617 617 u->is_private = private; 618 618 } 619 619 else 620 620 { 621 serv_got_crap( gc, "Message from unknown handle %s:", handle );621 serv_got_crap( ic, "Message from unknown handle %s:", handle ); 622 622 u = user_find( irc, irc->mynick ); 623 623 } 624 624 } 625 625 626 if( ( g_strcasecmp( set_getstr( & gc->irc->set, "strip_html" ), "always" ) == 0 ) ||627 ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )626 if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || 627 ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 628 628 strip_html( msg ); 629 629 … … 661 661 } 662 662 663 void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type )663 void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type ) 664 664 { 665 665 user_t *u; 666 666 667 if( !set_getbool( & gc->irc->set, "typing_notice" ) )667 if( !set_getbool( &ic->irc->set, "typing_notice" ) ) 668 668 return; 669 669 670 if( ( u = user_findhandle( gc, handle ) ) ) {670 if( ( u = user_findhandle( ic, handle ) ) ) { 671 671 /* If type is: 672 672 * 0: user has stopped typing … … 677 677 char buf[256]; 678 678 g_snprintf(buf, 256, "\1TYPING %d\1", type); 679 irc_privmsg( gc->irc, u, "PRIVMSG", gc->irc->nick, NULL, buf );680 } 681 } 682 } 683 684 void serv_got_chat_left( struct conversation*c )685 { 686 struct gaim_connection *gc = c->gc;687 struct conversation*l = NULL;679 irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf ); 680 } 681 } 682 } 683 684 void serv_got_chat_left( struct groupchat *c ) 685 { 686 struct im_connection *ic = c->ic; 687 struct groupchat *l = NULL; 688 688 GList *ir; 689 689 690 if( set_getbool( & gc->irc->set, "debug" ) )691 serv_got_crap( gc, "You were removed from conversation 0x%x", (int) c );690 if( set_getbool( &ic->irc->set, "debug" ) ) 691 serv_got_crap( ic, "You were removed from conversation 0x%x", (int) c ); 692 692 693 693 if( c ) … … 697 697 user_t *u, *r; 698 698 699 r = user_find( gc->irc, gc->irc->mynick );700 irc_privmsg( gc->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" );699 r = user_find( ic->irc, ic->irc->mynick ); 700 irc_privmsg( ic->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" ); 701 701 702 u = user_find( gc->irc, gc->irc->nick );703 irc_kick( gc->irc, u, c->channel, r );704 /* irc_part( gc->irc, u, c->channel ); */702 u = user_find( ic->irc, ic->irc->nick ); 703 irc_kick( ic->irc, u, c->channel, r ); 704 /* irc_part( ic->irc, u, c->channel ); */ 705 705 } 706 706 … … 708 708 l->next = c->next; 709 709 else 710 gc->conversations = c->next;710 ic->conversations = c->next; 711 711 712 712 for( ir = c->in_room; ir; ir = ir->next ) … … 719 719 } 720 720 721 void serv_got_chat_in( struct conversation*c, char *who, int whisper, char *msg, time_t mtime )722 { 723 struct gaim_connection *gc = c->gc;721 void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime ) 722 { 723 struct im_connection *ic = c->ic; 724 724 user_t *u; 725 725 726 726 /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */ 727 if( g_strcasecmp( who, gc->username ) == 0 )727 if( g_strcasecmp( who, ic->username ) == 0 ) 728 728 return; 729 729 730 u = user_findhandle( gc, who );731 732 if( ( g_strcasecmp( set_getstr( & gc->irc->set, "strip_html" ), "always" ) == 0 ) ||733 ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )730 u = user_findhandle( ic, who ); 731 732 if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) || 733 ( ( ic->flags & OPT_CONN_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) ) 734 734 strip_html( msg ); 735 735 736 736 if( c && u ) 737 irc_privmsg( gc->irc, u, "PRIVMSG", c->channel, "", msg );737 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", msg ); 738 738 else 739 serv_got_crap( gc, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg );740 } 741 742 struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle )743 { 744 struct conversation*c;739 serv_got_crap( ic, "Message from/to conversation %s@0x%x (unknown conv/user): %s", who, (int) c, msg ); 740 } 741 742 struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ) 743 { 744 struct groupchat *c; 745 745 746 746 /* This one just creates the conversation structure, user won't see anything yet */ 747 747 748 if( gc->conversations )749 { 750 for( c = gc->conversations; c->next; c = c->next );751 c = c->next = g_new0( struct conversation, 1 );748 if( ic->conversations ) 749 { 750 for( c = ic->conversations; c->next; c = c->next ); 751 c = c->next = g_new0( struct groupchat, 1 ); 752 752 } 753 753 else 754 gc->conversations = c = g_new0( struct conversation, 1 );755 756 c-> gc = gc;754 ic->conversations = c = g_new0( struct groupchat, 1 ); 755 756 c->ic = ic; 757 757 c->title = g_strdup( handle ); 758 c->channel = g_strdup_printf( "&chat_%03d", gc->irc->c_id++ );759 760 if( set_getbool( & gc->irc->set, "debug" ) )761 serv_got_crap( gc, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle );758 c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); 759 760 if( set_getbool( &ic->irc->set, "debug" ) ) 761 serv_got_crap( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle ); 762 762 763 763 return c; … … 767 767 /* buddy_chat.c */ 768 768 769 void add_chat_buddy( struct conversation*b, char *handle )770 { 771 user_t *u = user_findhandle( b-> gc, handle );769 void add_chat_buddy( struct groupchat *b, char *handle ) 770 { 771 user_t *u = user_findhandle( b->ic, handle ); 772 772 int me = 0; 773 773 774 if( set_getbool( &b-> gc->irc->set, "debug" ) )775 serv_got_crap( b-> gc, "User %s added to conversation 0x%x", handle, (int) b );774 if( set_getbool( &b->ic->irc->set, "debug" ) ) 775 serv_got_crap( b->ic, "User %s added to conversation 0x%x", handle, (int) b ); 776 776 777 777 /* It might be yourself! */ 778 if( b-> gc->acc->prpl->handle_cmp( handle, b->gc->username ) == 0 )779 { 780 u = user_find( b-> gc->irc, b->gc->irc->nick );778 if( b->ic->acc->prpl->handle_cmp( handle, b->ic->username ) == 0 ) 779 { 780 u = user_find( b->ic->irc, b->ic->irc->nick ); 781 781 if( !b->joined ) 782 irc_join( b-> gc->irc, u, b->channel );782 irc_join( b->ic->irc, u, b->channel ); 783 783 b->joined = me = 1; 784 784 } … … 788 788 if( !u ) 789 789 { 790 add_buddy( b-> gc, NULL, handle, NULL );791 u = user_findhandle( b-> gc, handle );790 add_buddy( b->ic, NULL, handle, NULL ); 791 u = user_findhandle( b->ic, handle ); 792 792 } 793 793 … … 796 796 { 797 797 if( b->joined ) 798 irc_join( b-> gc->irc, u, b->channel );798 irc_join( b->ic->irc, u, b->channel ); 799 799 b->in_room = g_list_append( b->in_room, g_strdup( handle ) ); 800 800 } 801 801 } 802 802 803 void remove_chat_buddy( struct conversation*b, char *handle, char *reason )803 void remove_chat_buddy( struct groupchat *b, char *handle, char *reason ) 804 804 { 805 805 user_t *u; 806 806 int me = 0; 807 807 808 if( set_getbool( &b-> gc->irc->set, "debug" ) )809 serv_got_crap( b-> gc, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" );808 if( set_getbool( &b->ic->irc->set, "debug" ) ) 809 serv_got_crap( b->ic, "User %s removed from conversation 0x%x (%s)", handle, (int) b, reason ? reason : "" ); 810 810 811 811 /* It might be yourself! */ 812 if( g_strcasecmp( handle, b-> gc->username ) == 0 )813 { 814 u = user_find( b-> gc->irc, b->gc->irc->nick );812 if( g_strcasecmp( handle, b->ic->username ) == 0 ) 813 { 814 u = user_find( b->ic->irc, b->ic->irc->nick ); 815 815 b->joined = 0; 816 816 me = 1; … … 818 818 else 819 819 { 820 u = user_findhandle( b-> gc, handle );820 u = user_findhandle( b->ic, handle ); 821 821 } 822 822 823 823 if( remove_chat_buddy_silent( b, handle ) ) 824 824 if( ( b->joined || me ) && u ) 825 irc_part( b-> gc->irc, u, b->channel );826 } 827 828 static int remove_chat_buddy_silent( struct conversation*b, char *handle )825 irc_part( b->ic->irc, u, b->channel ); 826 } 827 828 static int remove_chat_buddy_silent( struct groupchat *b, char *handle ) 829 829 { 830 830 GList *i; … … 850 850 /* Misc. BitlBee stuff which shouldn't really be here */ 851 851 852 struct conversation*chat_by_channel( char *channel )853 { 854 struct gaim_connection *gc;855 struct conversation*c;852 struct groupchat *chat_by_channel( char *channel ) 853 { 854 struct im_connection *ic; 855 struct groupchat *c; 856 856 GSList *l; 857 857 … … 859 859 for( l = connections; l; l = l->next ) 860 860 { 861 gc = l->data;862 for( c = gc->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next );861 ic = l->data; 862 for( c = ic->conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next ); 863 863 if( c ) 864 864 return c; … … 899 899 while( u ) 900 900 { 901 if( u-> gc && u->online && !u->away )901 if( u->ic && u->online && !u->away ) 902 902 { 903 903 if( ( strlen( list ) + strlen( u->nick ) ) >= 79 ) … … 933 933 them all from some wrappers. We'll start to define some down here: */ 934 934 935 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags )935 int bim_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags ) 936 936 { 937 937 char *buf = NULL; 938 938 int st; 939 939 940 if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )940 if( ( ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 941 941 { 942 942 buf = escape_html( msg ); … … 944 944 } 945 945 946 st = gc->acc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );946 st = ic->acc->prpl->send_im( ic, handle, msg, flags ); 947 947 g_free( buf ); 948 948 … … 950 950 } 951 951 952 int bim_chat_msg( struct conversation *c, char *msg)952 int bim_chat_msg( struct groupchat *c, char *msg, int flags ) 953 953 { 954 954 char *buf = NULL; 955 955 int st; 956 956 957 if( ( c-> gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )957 if( ( c->ic->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 958 958 { 959 959 buf = escape_html( msg ); … … 961 961 } 962 962 963 st = c->gc->acc->prpl->chat_send( c, msg);963 c->ic->acc->prpl->chat_send( c, msg, flags ); 964 964 g_free( buf ); 965 965 966 return st;966 return 1; 967 967 } 968 968 969 969 static char *bim_away_alias_find( GList *gcm, char *away ); 970 970 971 int bim_set_away( struct gaim_connection *gc, char *away )971 int bim_set_away( struct im_connection *ic, char *away ) 972 972 { 973 973 GList *m, *ms; … … 975 975 976 976 if( !away ) away = ""; 977 ms = m = gc->acc->prpl->away_states( gc );977 ms = m = ic->acc->prpl->away_states( ic ); 978 978 979 979 while( m ) … … 996 996 if( m ) 997 997 { 998 gc->acc->prpl->set_away( gc, m->data, *away ? away : NULL );998 ic->acc->prpl->set_away( ic, m->data, *away ? away : NULL ); 999 999 } 1000 1000 else … … 1003 1003 if( s ) 1004 1004 { 1005 gc->acc->prpl->set_away( gc, s, away );1006 if( set_getbool( & gc->irc->set, "debug" ) )1007 serv_got_crap( gc, "Setting away state to %s", s );1005 ic->acc->prpl->set_away( ic, s, away ); 1006 if( set_getbool( &ic->irc->set, "debug" ) ) 1007 serv_got_crap( ic, "Setting away state to %s", s ); 1008 1008 } 1009 1009 else 1010 gc->acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );1010 ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away ); 1011 1011 } 1012 1012 … … 1056 1056 } 1057 1057 1058 void bim_add_allow( struct gaim_connection *gc, char *handle )1059 { 1060 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL )1061 { 1062 gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) );1063 } 1064 1065 gc->acc->prpl->add_permit( gc, handle );1066 } 1067 1068 void bim_rem_allow( struct gaim_connection *gc, char *handle )1058 void bim_add_allow( struct im_connection *ic, char *handle ) 1059 { 1060 if( g_slist_find_custom( ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL ) 1061 { 1062 ic->permit = g_slist_prepend( ic->permit, g_strdup( handle ) ); 1063 } 1064 1065 ic->acc->prpl->add_permit( ic, handle ); 1066 } 1067 1068 void bim_rem_allow( struct im_connection *ic, char *handle ) 1069 1069 { 1070 1070 GSList *l; 1071 1071 1072 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) )1072 if( ( l = g_slist_find_custom( ic->permit, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) ) ) 1073 1073 { 1074 1074 g_free( l->data ); 1075 gc->permit = g_slist_delete_link( gc->permit, l );1076 } 1077 1078 gc->acc->prpl->rem_permit( gc, handle );1079 } 1080 1081 void bim_add_block( struct gaim_connection *gc, char *handle )1082 { 1083 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL )1084 { 1085 gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) );1086 } 1087 1088 gc->acc->prpl->add_deny( gc, handle );1089 } 1090 1091 void bim_rem_block( struct gaim_connection *gc, char *handle )1075 ic->permit = g_slist_delete_link( ic->permit, l ); 1076 } 1077 1078 ic->acc->prpl->rem_permit( ic, handle ); 1079 } 1080 1081 void bim_add_block( struct im_connection *ic, char *handle ) 1082 { 1083 if( g_slist_find_custom( ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) == NULL ) 1084 { 1085 ic->deny = g_slist_prepend( ic->deny, g_strdup( handle ) ); 1086 } 1087 1088 ic->acc->prpl->add_deny( ic, handle ); 1089 } 1090 1091 void bim_rem_block( struct im_connection *ic, char *handle ) 1092 1092 { 1093 1093 GSList *l; 1094 1094 1095 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) )1095 if( ( l = g_slist_find_custom( ic->deny, handle, (GCompareFunc) ic->acc->prpl->handle_cmp ) ) ) 1096 1096 { 1097 1097 g_free( l->data ); 1098 gc->deny = g_slist_delete_link( gc->deny, l );1099 } 1100 1101 gc->acc->prpl->rem_deny( gc, handle );1102 } 1098 ic->deny = g_slist_delete_link( ic->deny, l ); 1099 } 1100 1101 ic->acc->prpl->rem_deny( ic, handle ); 1102 } -
protocols/nogaim.h
rfa29d093 r0da65d5 62 62 63 63 /* ok. now the fun begins. first we create a connection structure */ 64 struct gaim_connection64 struct im_connection 65 65 { 66 66 account_t *acc; … … 92 92 irc_t *irc; 93 93 94 struct conversation*conversations;94 struct groupchat *conversations; 95 95 }; 96 96 97 97 /* struct buddy_chat went away and got merged with this. */ 98 struct conversation{99 struct gaim_connection *gc;98 struct groupchat { 99 struct im_connection *ic; 100 100 101 101 /* stuff used just for chat */ … … 104 104 105 105 /* BitlBee */ 106 struct conversation*next;106 struct groupchat *next; 107 107 char *channel; 108 108 char *title; … … 121 121 guint caps; /* woohoo! */ 122 122 void *proto_data; /* what a hack */ 123 struct gaim_connection *gc; /* the connection it belongs to */123 struct im_connection *ic; /* the connection it belongs to */ 124 124 }; 125 125 … … 128 128 const char *name; 129 129 130 void (* acc_init) (account_t *); 130 /* Added this one to be able to add per-account settings, don't think 131 it should be used for anything else. */ 132 void (* init) (account_t *); 133 /* These should all be pretty obvious. */ 131 134 void (* login) (account_t *); 132 void (* keepalive) (struct gaim_connection *); 133 void (* close) (struct gaim_connection *); 134 135 int (* send_im) (struct gaim_connection *, char *who, char *message, int len, int away); 136 void (* set_away) (struct gaim_connection *, char *state, char *message); 137 void (* get_away) (struct gaim_connection *, char *who); 138 int (* send_typing) (struct gaim_connection *, char *who, int typing); 139 140 void (* add_buddy) (struct gaim_connection *, char *name); 141 void (* group_buddy) (struct gaim_connection *, char *who, char *old_group, char *new_group); 142 void (* remove_buddy) (struct gaim_connection *, char *name, char *group); 143 void (* add_permit) (struct gaim_connection *, char *name); 144 void (* add_deny) (struct gaim_connection *, char *name); 145 void (* rem_permit) (struct gaim_connection *, char *name); 146 void (* rem_deny) (struct gaim_connection *, char *name); 147 void (* set_permit_deny)(struct gaim_connection *); 148 149 void (* set_info) (struct gaim_connection *, char *info); 150 void (* get_info) (struct gaim_connection *, char *who); 151 void (* alias_buddy) (struct gaim_connection *, char *who); /* save/store buddy's alias on server list/roster */ 135 void (* keepalive) (struct im_connection *); 136 void (* logout) (struct im_connection *); 137 138 int (* send_im) (struct im_connection *, char *to, char *message, int flags); 139 void (* set_away) (struct im_connection *, char *state, char *message); 140 void (* get_away) (struct im_connection *, char *who); 141 int (* send_typing) (struct im_connection *, char *who, int typing); 142 143 /* For now BitlBee doesn't really handle groups, just set it to NULL. */ 144 void (* add_buddy) (struct im_connection *, char *name, char *group); 145 void (* remove_buddy) (struct im_connection *, char *name, char *group); 146 147 /* Block list stuff. */ 148 void (* add_permit) (struct im_connection *, char *who); 149 void (* add_deny) (struct im_connection *, char *who); 150 void (* rem_permit) (struct im_connection *, char *who); 151 void (* rem_deny) (struct im_connection *, char *who); 152 /* Doesn't actually have UI hooks. */ 153 void (* set_permit_deny)(struct im_connection *); 154 155 /* Request profile info. Free-formatted stuff, the IM module gives back 156 this info via imc_log(). */ 157 void (* get_info) (struct im_connection *, char *who); 158 void (* set_my_name) (struct im_connection *, char *name); 159 void (* set_name) (struct im_connection *, char *who, char *name); 152 160 153 161 /* Group chat stuff. */ 154 void (* chat_invite) (struct conversation*, char *who, char *message);155 void (* chat_leave) (struct conversation*);156 int (* chat_send) (struct conversation *, char *message);157 struct conversation*158 (* chat_ open) (struct gaim_connection *, char *who);159 struct conversation*160 (* chat_join) (struct gaim_connection *, char *chat, char *nick, char *password);162 void (* chat_invite) (struct groupchat *, char *who, char *message); 163 void (* chat_leave) (struct groupchat *); 164 void (* chat_send) (struct groupchat *, char *message, int flags); 165 struct groupchat * 166 (* chat_with) (struct im_connection *, char *who); 167 struct groupchat * 168 (* chat_join) (struct im_connection *, char *chat, char *nick, char *password); 161 169 162 170 /* DIE! */ 163 char *(* get_status_string) (struct gaim_connection *gc, int stat);164 165 GList *(* away_states)(struct gaim_connection *gc);171 char *(* get_status_string) (struct im_connection *ic, int stat); 172 173 GList *(* away_states)(struct im_connection *ic); 166 174 167 175 /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */ … … 182 190 183 191 /* nogaim.c */ 184 int bim_set_away( struct gaim_connection *gc, char *away );185 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags );186 int bim_chat_msg( struct conversation *c, char *msg);187 188 void bim_add_allow( struct gaim_connection *gc, char *handle );189 void bim_rem_allow( struct gaim_connection *gc, char *handle );190 void bim_add_block( struct gaim_connection *gc, char *handle );191 void bim_rem_block( struct gaim_connection *gc, char *handle );192 int bim_set_away( struct im_connection *ic, char *away ); 193 int bim_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags ); 194 int bim_chat_msg( struct groupchat *c, char *msg, int flags ); 195 196 void bim_add_allow( struct im_connection *ic, char *handle ); 197 void bim_rem_allow( struct im_connection *ic, char *handle ); 198 void bim_add_block( struct im_connection *ic, char *handle ); 199 void bim_rem_block( struct im_connection *ic, char *handle ); 192 200 193 201 void nogaim_init(); … … 198 206 199 207 /* multi.c */ 200 G_MODULE_EXPORT struct gaim_connection *new_gaim_conn( account_t *acc );201 G_MODULE_EXPORT void destroy_gaim_conn( struct gaim_connection *gc );202 G_MODULE_EXPORT void set_login_progress( struct gaim_connection *gc, int step, char *msg );203 G_MODULE_EXPORT void hide_login_progress( struct gaim_connection *gc, char *msg );204 G_MODULE_EXPORT void hide_login_progress_error( struct gaim_connection *gc, char *msg );205 G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ) G_GNUC_PRINTF( 2, 3 );206 G_MODULE_EXPORT void account_online( struct gaim_connection *gc );207 G_MODULE_EXPORT void signoff( struct gaim_connection *gc );208 G_MODULE_EXPORT struct im_connection *new_gaim_conn( account_t *acc ); 209 G_MODULE_EXPORT void destroy_gaim_conn( struct im_connection *ic ); 210 G_MODULE_EXPORT void set_login_progress( struct im_connection *ic, int step, char *msg ); 211 G_MODULE_EXPORT void hide_login_progress( struct im_connection *ic, char *msg ); 212 G_MODULE_EXPORT void hide_login_progress_error( struct im_connection *ic, char *msg ); 213 G_MODULE_EXPORT void serv_got_crap( struct im_connection *ic, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 214 G_MODULE_EXPORT void account_online( struct im_connection *ic ); 215 G_MODULE_EXPORT void signoff( struct im_connection *ic ); 208 216 209 217 /* dialogs.c */ 210 G_MODULE_EXPORT void do_error_dialog( struct gaim_connection *gc, char *msg, char *title );211 G_MODULE_EXPORT void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont );218 G_MODULE_EXPORT void do_error_dialog( struct im_connection *ic, char *msg, char *title ); 219 G_MODULE_EXPORT void do_ask_dialog( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ); 212 220 213 221 /* list.c */ 214 G_MODULE_EXPORT void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname );215 G_MODULE_EXPORT struct buddy *find_buddy( struct gaim_connection *gc, char *handle );216 G_MODULE_EXPORT void signoff_blocked( struct gaim_connection *gc );217 218 G_MODULE_EXPORT void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname );222 G_MODULE_EXPORT void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname ); 223 G_MODULE_EXPORT struct buddy *find_buddy( struct im_connection *ic, char *handle ); 224 G_MODULE_EXPORT void signoff_blocked( struct im_connection *ic ); 225 226 G_MODULE_EXPORT void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ); 219 227 220 228 /* buddy_chat.c */ 221 G_MODULE_EXPORT void add_chat_buddy( struct conversation*b, char *handle );222 G_MODULE_EXPORT void remove_chat_buddy( struct conversation*b, char *handle, char *reason );229 G_MODULE_EXPORT void add_chat_buddy( struct groupchat *b, char *handle ); 230 G_MODULE_EXPORT void remove_chat_buddy( struct groupchat *b, char *handle, char *reason ); 223 231 224 232 /* prpl.c */ 225 G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char *handle, const char *realname );233 G_MODULE_EXPORT void show_got_added( struct im_connection *ic, char *handle, const char *realname ); 226 234 227 235 /* server.c */ 228 G_MODULE_EXPORT void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps );229 G_MODULE_EXPORT void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len );230 G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type );231 G_MODULE_EXPORT void serv_got_chat_invite( struct gaim_connection *gc, char *handle, char *who, char *msg, GList *data );232 G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, char *handle );233 G_MODULE_EXPORT void serv_got_chat_in( struct conversation*c, char *who, int whisper, char *msg, time_t mtime );234 G_MODULE_EXPORT void serv_got_chat_left( struct conversation*c );235 236 struct conversation*chat_by_channel( char *channel );237 struct conversation*chat_by_id( int id );236 G_MODULE_EXPORT void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps ); 237 G_MODULE_EXPORT void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len ); 238 G_MODULE_EXPORT void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type ); 239 G_MODULE_EXPORT void serv_got_chat_invite( struct im_connection *ic, char *handle, char *who, char *msg, GList *data ); 240 G_MODULE_EXPORT struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ); 241 G_MODULE_EXPORT void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime ); 242 G_MODULE_EXPORT void serv_got_chat_left( struct groupchat *c ); 243 244 struct groupchat *chat_by_channel( char *channel ); 245 struct groupchat *chat_by_id( int id ); 238 246 239 247 #endif -
protocols/oscar/aim.h
rfa29d093 r0da65d5 574 574 575 575 struct aim_chat_invitation { 576 struct gaim_connection * gc;576 struct im_connection * ic; 577 577 char * name; 578 578 guint8 exchange; -
protocols/oscar/im.c
rfa29d093 r0da65d5 1417 1417 guint8 *plugin; 1418 1418 int i = 0, tmp = 0; 1419 struct gaim_connection *gc = sess->aux_data;1419 struct im_connection *ic = sess->aux_data; 1420 1420 1421 1421 /* at the moment we just can deal with requests, not with cancel or accept */ … … 1469 1469 case 0x9c: /* ICQ 5 seems to send this */ 1470 1470 aim_send_im_ch2_statusmessage(sess, userinfo->sn, args->cookie, 1471 gc->away ? gc->away : "", sess->aim_icq_state, dc);1471 ic->away ? ic->away : "", sess->aim_icq_state, dc); 1472 1472 break; 1473 1473 -
protocols/oscar/oscar.c
rfa29d093 r0da65d5 116 116 int inpa; 117 117 int id; 118 struct gaim_connection *gc; /* i hate this. */119 struct conversation*cnv; /* bah. */118 struct im_connection *ic; /* i hate this. */ 119 struct groupchat *cnv; /* bah. */ 120 120 int maxlen; 121 121 int maxvis; … … 123 123 124 124 struct ask_direct { 125 struct gaim_connection *gc;125 struct im_connection *ic; 126 126 char *sn; 127 127 char ip[64]; … … 130 130 131 131 struct icq_auth { 132 struct gaim_connection *gc;132 struct im_connection *ic; 133 133 guint32 uin; 134 134 }; … … 158 158 } 159 159 160 static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc,160 static struct chat_connection *find_oscar_chat_by_conn(struct im_connection *ic, 161 161 aim_conn_t *conn) { 162 GSList *g = ((struct oscar_data *) gc->proto_data)->oscar_chats;162 GSList *g = ((struct oscar_data *)ic->proto_data)->oscar_chats; 163 163 struct chat_connection *c = NULL; 164 164 … … 243 243 aim_conn_t *conn = (aim_conn_t *)data; 244 244 aim_session_t *sess = aim_conn_getsess(conn); 245 struct gaim_connection *gc = sess ? sess->aux_data : NULL;245 struct im_connection *ic = sess ? sess->aux_data : NULL; 246 246 struct oscar_data *odata; 247 247 248 if (! gc) {249 /* gc is null. we return, else we seg SIGSEG on next line. */248 if (!ic) { 249 /* ic is null. we return, else we seg SIGSEG on next line. */ 250 250 return FALSE; 251 251 } 252 252 253 if (!g_slist_find(get_connections(), gc)) {253 if (!g_slist_find(get_connections(), ic)) { 254 254 /* oh boy. this is probably bad. i guess the only thing we 255 255 * can really do is return? */ … … 257 257 } 258 258 259 odata = (struct oscar_data *) gc->proto_data;259 odata = (struct oscar_data *)ic->proto_data; 260 260 261 261 if (condition & GAIM_INPUT_READ) { … … 263 263 aim_rxdispatch(odata->sess); 264 264 if (odata->killme) 265 signoff( gc);265 signoff(ic); 266 266 } else { 267 267 if ((conn->type == AIM_CONN_TYPE_BOS) || 268 268 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { 269 hide_login_progress_error( gc, _("Disconnected."));270 signoff( gc);269 hide_login_progress_error(ic, _("Disconnected.")); 270 signoff(ic); 271 271 } else if (conn->type == AIM_CONN_TYPE_CHAT) { 272 struct chat_connection *c = find_oscar_chat_by_conn( gc, conn);272 struct chat_connection *c = find_oscar_chat_by_conn(ic, conn); 273 273 char buf[BUF_LONG]; 274 274 c->conn = NULL; … … 313 313 static gboolean oscar_login_connect(gpointer data, gint source, b_input_condition cond) 314 314 { 315 struct gaim_connection *gc = data;315 struct im_connection *ic = data; 316 316 struct oscar_data *odata; 317 317 aim_session_t *sess; 318 318 aim_conn_t *conn; 319 319 320 if (!g_slist_find(get_connections(), gc)) {320 if (!g_slist_find(get_connections(), ic)) { 321 321 closesocket(source); 322 322 return FALSE; 323 323 } 324 324 325 odata = gc->proto_data;325 odata = ic->proto_data; 326 326 sess = odata->sess; 327 327 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); 328 328 329 329 if (source < 0) { 330 hide_login_progress( gc, _("Couldn't connect to host"));331 signoff( gc);330 hide_login_progress(ic, _("Couldn't connect to host")); 331 signoff(ic); 332 332 return FALSE; 333 333 } 334 334 335 335 aim_conn_completeconnect(sess, conn); 336 gc->inpa = b_input_add(conn->fd, GAIM_INPUT_READ,336 ic->inpa = b_input_add(conn->fd, GAIM_INPUT_READ, 337 337 oscar_callback, conn); 338 338 … … 340 340 } 341 341 342 static void oscar_ acc_init(account_t *acc)342 static void oscar_init(account_t *acc) 343 343 { 344 344 set_t *s; … … 357 357 aim_conn_t *conn; 358 358 char buf[256]; 359 struct gaim_connection *gc = new_gaim_conn(acc);360 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1);359 struct im_connection *ic = new_gaim_conn(acc); 360 struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1); 361 361 362 362 if (isdigit(acc->user[0])) { … … 365 365 We don't do those anymore, but let's stick with it, just in case 366 366 it accidentally fixes something else too... </bitlbee> */ 367 gc->password[8] = 0;367 ic->password[8] = 0; 368 368 } else { 369 gc->flags |= OPT_CONN_HTML;369 ic->flags |= OPT_CONN_HTML; 370 370 } 371 371 … … 378 378 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); 379 379 odata->sess = sess; 380 sess->aux_data = gc;380 sess->aux_data = ic; 381 381 382 382 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); 383 383 if (conn == NULL) { 384 hide_login_progress( gc, _("Unable to login to AIM"));385 signoff( gc);384 hide_login_progress(ic, _("Unable to login to AIM")); 385 signoff(ic); 386 386 return; 387 387 } 388 388 389 389 if (acc->server == NULL) { 390 hide_login_progress( gc, "No servername specified");391 signoff( gc);390 hide_login_progress(ic, "No servername specified"); 391 signoff(ic); 392 392 return; 393 393 } … … 395 395 if (g_strcasecmp(acc->server, "login.icq.com") != 0 && 396 396 g_strcasecmp(acc->server, "login.oscar.aol.com") != 0) { 397 serv_got_crap( gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",acc->server);398 } 399 400 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username);401 set_login_progress( gc, 2, buf);397 serv_got_crap(ic, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",acc->server); 398 } 399 400 g_snprintf(buf, sizeof(buf), _("Signon: %s"), ic->username); 401 set_login_progress(ic, 2, buf); 402 402 403 403 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); … … 405 405 406 406 conn->status |= AIM_CONN_STATUS_INPROGRESS; 407 conn->fd = proxy_connect(acc->server, AIM_LOGIN_PORT, oscar_login_connect, gc);407 conn->fd = proxy_connect(acc->server, AIM_LOGIN_PORT, oscar_login_connect, ic); 408 408 if (conn->fd < 0) { 409 hide_login_progress( gc, _("Couldn't connect to host"));410 signoff( gc);409 hide_login_progress(ic, _("Couldn't connect to host")); 410 signoff(ic); 411 411 return; 412 412 } 413 aim_request_login(sess, conn, gc->username);414 } 415 416 static void oscar_ close(struct gaim_connection *gc) {417 struct oscar_data *odata = (struct oscar_data *) gc->proto_data;413 aim_request_login(sess, conn, ic->username); 414 } 415 416 static void oscar_logout(struct im_connection *ic) { 417 struct oscar_data *odata = (struct oscar_data *)ic->proto_data; 418 418 419 419 while (odata->oscar_chats) { … … 438 438 if (odata->oldp) 439 439 g_free(odata->oldp); 440 if ( gc->inpa > 0)441 b_event_remove( gc->inpa);440 if (ic->inpa > 0) 441 b_event_remove(ic->inpa); 442 442 if (odata->cnpa > 0) 443 443 b_event_remove(odata->cnpa); … … 447 447 g_free(odata->sess); 448 448 odata->sess = NULL; 449 g_free( gc->proto_data);450 gc->proto_data = NULL;449 g_free(ic->proto_data); 450 ic->proto_data = NULL; 451 451 } 452 452 453 453 static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition cond) { 454 struct gaim_connection *gc = data;454 struct im_connection *ic = data; 455 455 struct oscar_data *odata; 456 456 aim_session_t *sess; 457 457 aim_conn_t *bosconn; 458 458 459 if (!g_slist_find(get_connections(), gc)) {459 if (!g_slist_find(get_connections(), ic)) { 460 460 closesocket(source); 461 461 return FALSE; 462 462 } 463 463 464 odata = gc->proto_data;464 odata = ic->proto_data; 465 465 sess = odata->sess; 466 466 bosconn = odata->conn; 467 467 468 468 if (source < 0) { 469 hide_login_progress( gc, _("Could Not Connect"));470 signoff( gc);469 hide_login_progress(ic, _("Could Not Connect")); 470 signoff(ic); 471 471 return FALSE; 472 472 } 473 473 474 474 aim_conn_completeconnect(sess, bosconn); 475 gc->inpa = b_input_add(bosconn->fd, GAIM_INPUT_READ,475 ic->inpa = b_input_add(bosconn->fd, GAIM_INPUT_READ, 476 476 oscar_callback, bosconn); 477 set_login_progress( gc, 4, _("Connection established, cookie sent"));477 set_login_progress(ic, 4, _("Connection established, cookie sent")); 478 478 479 479 return FALSE; … … 486 486 aim_conn_t *bosconn; 487 487 488 struct gaim_connection *gc = sess->aux_data;489 struct oscar_data *od = gc->proto_data;488 struct im_connection *ic = sess->aux_data; 489 struct oscar_data *od = ic->proto_data; 490 490 port = AIM_LOGIN_PORT; 491 491 … … 498 498 case 0x05: 499 499 /* Incorrect nick/password */ 500 hide_login_progress( gc, _("Incorrect nickname or password."));500 hide_login_progress(ic, _("Incorrect nickname or password.")); 501 501 // plugin_event(event_error, (void *)980, 0, 0, 0); 502 502 break; 503 503 case 0x11: 504 504 /* Suspended account */ 505 hide_login_progress( gc, _("Your account is currently suspended."));505 hide_login_progress(ic, _("Your account is currently suspended.")); 506 506 break; 507 507 case 0x18: 508 508 /* connecting too frequently */ 509 hide_login_progress( gc, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));509 hide_login_progress(ic, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); 510 510 break; 511 511 case 0x1c: 512 512 /* client too old */ 513 hide_login_progress( gc, _("The client version you are using is too old. Please upgrade at " WEBSITE));513 hide_login_progress(ic, _("The client version you are using is too old. Please upgrade at " WEBSITE)); 514 514 break; 515 515 default: 516 hide_login_progress( gc, _("Authentication Failed"));516 hide_login_progress(ic, _("Authentication Failed")); 517 517 break; 518 518 } … … 526 526 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); 527 527 if (bosconn == NULL) { 528 hide_login_progress( gc, _("Internal Error"));528 hide_login_progress(ic, _("Internal Error")); 529 529 od->killme = TRUE; 530 530 return 0; … … 560 560 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parsemtn, 0); 561 561 562 ((struct oscar_data *) gc->proto_data)->conn = bosconn;562 ((struct oscar_data *)ic->proto_data)->conn = bosconn; 563 563 for (i = 0; i < (int)strlen(info->bosip); i++) { 564 564 if (info->bosip[i] == ':') { … … 569 569 host = g_strndup(info->bosip, i); 570 570 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; 571 bosconn->fd = proxy_connect(host, port, oscar_bos_connect, gc);571 bosconn->fd = proxy_connect(host, port, oscar_bos_connect, ic); 572 572 g_free(host); 573 573 if (bosconn->fd < 0) { 574 hide_login_progress( gc, _("Could Not Connect"));574 hide_login_progress(ic, _("Could Not Connect")); 575 575 od->killme = TRUE; 576 576 return 0; 577 577 } 578 578 aim_sendcookie(sess, bosconn, info->cookie); 579 b_event_remove( gc->inpa);579 b_event_remove(ic->inpa); 580 580 581 581 return 1; … … 583 583 584 584 struct pieceofcrap { 585 struct gaim_connection *gc;585 struct im_connection *ic; 586 586 unsigned long offset; 587 587 unsigned long len; … … 595 595 { 596 596 struct pieceofcrap *pos = data; 597 struct oscar_data *od = pos-> gc->proto_data;597 struct oscar_data *od = pos->ic->proto_data; 598 598 char in = '\0'; 599 599 int x = 0; … … 610 610 } 611 611 if (in != '\n') { 612 do_error_dialog(pos-> gc, "Gaim was unable to get a valid hash for logging into AIM."612 do_error_dialog(pos->ic, "Gaim was unable to get a valid hash for logging into AIM." 613 613 " You may be disconnected shortly.", "Login Error"); 614 614 b_event_remove(pos->inpa); … … 633 633 634 634 if (source < 0) { 635 do_error_dialog(pos-> gc, "Gaim was unable to get a valid hash for logging into AIM."635 do_error_dialog(pos->ic, "Gaim was unable to get a valid hash for logging into AIM." 636 636 " You may be disconnected shortly.", "Login Error"); 637 637 if (pos->modname) … … 699 699 700 700 pos = g_new0(struct pieceofcrap, 1); 701 pos-> gc = sess->aux_data;701 pos->ic = sess->aux_data; 702 702 pos->conn = fr->conn; 703 703 … … 727 727 char *key; 728 728 va_list ap; 729 struct gaim_connection *gc = sess->aux_data;729 struct im_connection *ic = sess->aux_data; 730 730 731 731 va_start(ap, fr); … … 733 733 va_end(ap); 734 734 735 aim_send_login(sess, fr->conn, gc->username, gc->password, &info, key);735 aim_send_login(sess, fr->conn, ic->username, ic->password, &info, key); 736 736 737 737 return 1; … … 739 739 740 740 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { 741 struct gaim_connection *gc = sess->aux_data;741 struct im_connection *ic = sess->aux_data; 742 742 struct chat_connection *chatcon; 743 743 static int id = 1; … … 751 751 aim_clientready(sess, fr->conn); 752 752 753 chatcon = find_oscar_chat_by_conn( gc, fr->conn);753 chatcon = find_oscar_chat_by_conn(ic, fr->conn); 754 754 chatcon->id = id; 755 chatcon->cnv = serv_got_joined_chat( gc, chatcon->show);755 chatcon->cnv = serv_got_joined_chat(ic, chatcon->show); 756 756 chatcon->cnv->data = chatcon; 757 757 … … 772 772 773 773 static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condition cond) { 774 struct gaim_connection *gc = data;774 struct im_connection *ic = data; 775 775 struct oscar_data *odata; 776 776 aim_session_t *sess; 777 777 aim_conn_t *tstconn; 778 778 779 if (!g_slist_find(get_connections(), gc)) {779 if (!g_slist_find(get_connections(), ic)) { 780 780 closesocket(source); 781 781 return FALSE; 782 782 } 783 783 784 odata = gc->proto_data;784 odata = ic->proto_data; 785 785 sess = odata->sess; 786 786 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); … … 800 800 static gboolean oscar_auth_connect(gpointer data, gint source, b_input_condition cond) 801 801 { 802 struct gaim_connection *gc = data;802 struct im_connection *ic = data; 803 803 struct oscar_data *odata; 804 804 aim_session_t *sess; 805 805 aim_conn_t *tstconn; 806 806 807 if (!g_slist_find(get_connections(), gc)) {807 if (!g_slist_find(get_connections(), ic)) { 808 808 closesocket(source); 809 809 return FALSE; 810 810 } 811 811 812 odata = gc->proto_data;812 odata = ic->proto_data; 813 813 sess = odata->sess; 814 814 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); … … 829 829 { 830 830 struct chat_connection *ccon = data; 831 struct gaim_connection *gc = ccon->gc;831 struct im_connection *ic = ccon->ic; 832 832 struct oscar_data *odata; 833 833 aim_session_t *sess; 834 834 aim_conn_t *tstconn; 835 835 836 if (!g_slist_find(get_connections(), gc)) {836 if (!g_slist_find(get_connections(), ic)) { 837 837 closesocket(source); 838 838 g_free(ccon->show); … … 842 842 } 843 843 844 odata = gc->proto_data;844 odata = ic->proto_data; 845 845 sess = odata->sess; 846 846 tstconn = ccon->conn; … … 867 867 va_list ap; 868 868 struct aim_redirect_data *redir; 869 struct gaim_connection *gc = sess->aux_data;869 struct im_connection *ic = sess->aux_data; 870 870 aim_conn_t *tstconn; 871 871 int i; … … 899 899 900 900 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; 901 tstconn->fd = proxy_connect(host, port, oscar_auth_connect, gc);901 tstconn->fd = proxy_connect(host, port, oscar_auth_connect, ic); 902 902 if (tstconn->fd < 0) { 903 903 aim_conn_kill(sess, &tstconn); … … 916 916 917 917 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; 918 tstconn->fd = proxy_connect(host, port, oscar_chatnav_connect, gc);918 tstconn->fd = proxy_connect(host, port, oscar_chatnav_connect, ic); 919 919 if (tstconn->fd < 0) { 920 920 aim_conn_kill(sess, &tstconn); … … 938 938 ccon = g_new0(struct chat_connection, 1); 939 939 ccon->conn = tstconn; 940 ccon-> gc = gc;940 ccon->ic = ic; 941 941 ccon->fd = -1; 942 942 ccon->name = g_strdup(redir->chat.room); … … 967 967 968 968 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { 969 struct gaim_connection *gc = sess->aux_data;970 struct oscar_data *od = gc->proto_data;969 struct im_connection *ic = sess->aux_data; 970 struct oscar_data *od = ic->proto_data; 971 971 aim_userinfo_t *info; 972 972 time_t time_idle = 0, signon = 0; … … 1018 1018 signon = time(NULL) - info->sessionlen; 1019 1019 1020 tmp = g_strdup(normalize( gc->username));1020 tmp = g_strdup(normalize(ic->username)); 1021 1021 if (!strcmp(tmp, normalize(info->sn))) 1022 g_snprintf( gc->displayname, sizeof(gc->displayname), "%s", info->sn);1022 g_snprintf(ic->displayname, sizeof(ic->displayname), "%s", info->sn); 1023 1023 g_free(tmp); 1024 1024 1025 serv_got_update( gc, info->sn, 1, info->warnlevel/10, signon,1025 serv_got_update(ic, info->sn, 1, info->warnlevel/10, signon, 1026 1026 time_idle, type, caps); 1027 1027 … … 1032 1032 aim_userinfo_t *info; 1033 1033 va_list ap; 1034 struct gaim_connection *gc = sess->aux_data;1034 struct im_connection *ic = sess->aux_data; 1035 1035 1036 1036 va_start(ap, fr); … … 1038 1038 va_end(ap); 1039 1039 1040 serv_got_update( gc, info->sn, 0, 0, 0, 0, 0, 0);1040 serv_got_update(ic, info->sn, 0, 0, 0, 0, 0, 0); 1041 1041 1042 1042 return 1; … … 1045 1045 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { 1046 1046 char *tmp = g_malloc(BUF_LONG + 1); 1047 struct gaim_connection *gc = sess->aux_data;1047 struct im_connection *ic = sess->aux_data; 1048 1048 int flags = 0; 1049 1049 … … 1083 1083 1084 1084 strip_linefeed(tmp); 1085 serv_got_im( gc, userinfo->sn, tmp, flags, time(NULL), -1);1085 serv_got_im(ic, userinfo->sn, tmp, flags, time(NULL), -1); 1086 1086 g_free(tmp); 1087 1087 … … 1093 1093 1094 1094 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { 1095 struct gaim_connection *gc = sess->aux_data;1095 struct im_connection *ic = sess->aux_data; 1096 1096 1097 1097 if (args->status != AIM_RENDEZVOUS_PROPOSE) … … 1111 1111 g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", name, userinfo->sn, args->msg ); 1112 1112 1113 inv-> gc = gc;1113 inv->ic = ic; 1114 1114 inv->exchange = *exch; 1115 1115 inv->name = g_strdup(name); 1116 1116 1117 do_ask_dialog( gc, txt, inv, oscar_accept_chat, oscar_reject_chat);1117 do_ask_dialog( ic, txt, inv, oscar_accept_chat, oscar_reject_chat); 1118 1118 1119 1119 if (name) … … 1126 1126 static void gaim_icq_authgrant(gpointer w, struct icq_auth *data) { 1127 1127 char *uin, message; 1128 struct oscar_data *od = (struct oscar_data *)data-> gc->proto_data;1128 struct oscar_data *od = (struct oscar_data *)data->ic->proto_data; 1129 1129 1130 1130 uin = g_strdup_printf("%u", data->uin); … … 1132 1132 aim_ssi_auth_reply(od->sess, od->conn, uin, 1, ""); 1133 1133 // aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message); 1134 if(find_buddy(data-> gc, uin) == NULL)1135 show_got_added(data-> gc, uin, NULL);1134 if(find_buddy(data->ic, uin) == NULL) 1135 show_got_added(data->ic, uin, NULL); 1136 1136 1137 1137 g_free(uin); … … 1141 1141 static void gaim_icq_authdeny(gpointer w, struct icq_auth *data) { 1142 1142 char *uin, *message; 1143 struct oscar_data *od = (struct oscar_data *)data-> gc->proto_data;1143 struct oscar_data *od = (struct oscar_data *)data->ic->proto_data; 1144 1144 1145 1145 uin = g_strdup_printf("%u", data->uin); … … 1156 1156 * For when other people ask you for authorization 1157 1157 */ 1158 static void gaim_icq_authask(struct gaim_connection *gc, guint32 uin, char *msg) {1158 static void gaim_icq_authask(struct im_connection *ic, guint32 uin, char *msg) { 1159 1159 struct icq_auth *data = g_new(struct icq_auth, 1); 1160 1160 char *reason = NULL; … … 1165 1165 1166 1166 dialog_msg = g_strdup_printf("The user %u wants to add you to their buddy list for the following reason: %s", uin, reason ? reason : "No reason given."); 1167 data-> gc = gc;1167 data->ic = ic; 1168 1168 data->uin = uin; 1169 do_ask_dialog( gc, dialog_msg, data, gaim_icq_authgrant, gaim_icq_authdeny);1169 do_ask_dialog(ic, dialog_msg, data, gaim_icq_authgrant, gaim_icq_authdeny); 1170 1170 g_free(dialog_msg); 1171 1171 } 1172 1172 1173 1173 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args) { 1174 struct gaim_connection *gc = sess->aux_data;1174 struct im_connection *ic = sess->aux_data; 1175 1175 1176 1176 switch (args->type) { … … 1180 1180 message = g_strdup(args->msg); 1181 1181 strip_linefeed(message); 1182 serv_got_im( gc, uin, message, 0, time(NULL), -1);1182 serv_got_im(ic, uin, message, 0, time(NULL), -1); 1183 1183 g_free(uin); 1184 1184 g_free(message); … … 1199 1199 1200 1200 strip_linefeed(message); 1201 serv_got_im( gc, uin, message, 0, time(NULL), -1);1201 serv_got_im(ic, uin, message, 0, time(NULL), -1); 1202 1202 g_free(uin); 1203 1203 g_free(m); … … 1206 1206 1207 1207 case 0x0006: { /* Someone requested authorization */ 1208 gaim_icq_authask( gc, args->uin, args->msg);1208 gaim_icq_authask(ic, args->uin, args->msg); 1209 1209 } break; 1210 1210 … … 1418 1418 va_list ap; 1419 1419 guint16 type; 1420 struct gaim_connection *gc = sess->aux_data;1421 struct oscar_data *odata = (struct oscar_data *) gc->proto_data;1420 struct im_connection *ic = sess->aux_data; 1421 struct oscar_data *odata = (struct oscar_data *)ic->proto_data; 1422 1422 1423 1423 va_start(ap, fr); … … 1477 1477 int count, i; 1478 1478 aim_userinfo_t *info; 1479 struct gaim_connection *g = sess->aux_data;1479 struct im_connection *g = sess->aux_data; 1480 1480 1481 1481 struct chat_connection *c = NULL; … … 1500 1500 int count, i; 1501 1501 aim_userinfo_t *info; 1502 struct gaim_connection *g = sess->aux_data;1502 struct im_connection *g = sess->aux_data; 1503 1503 1504 1504 struct chat_connection *c = NULL; … … 1528 1528 guint16 unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; 1529 1529 guint32 creationtime; 1530 struct gaim_connection *gc = sess->aux_data;1531 struct chat_connection *ccon = find_oscar_chat_by_conn( gc, fr->conn);1530 struct im_connection *ic = sess->aux_data; 1531 struct chat_connection *ccon = find_oscar_chat_by_conn(ic, fr->conn); 1532 1532 1533 1533 va_start(ap, fr); … … 1555 1555 aim_userinfo_t *info; 1556 1556 char *msg; 1557 struct gaim_connection *gc = sess->aux_data;1558 struct chat_connection *ccon = find_oscar_chat_by_conn( gc, fr->conn);1557 struct im_connection *ic = sess->aux_data; 1558 struct chat_connection *ccon = find_oscar_chat_by_conn(ic, fr->conn); 1559 1559 char *tmp; 1560 1560 … … 1617 1617 va_list ap; 1618 1618 aim_userinfo_t *info; 1619 struct gaim_connection *gc = sess->aux_data;1619 struct im_connection *ic = sess->aux_data; 1620 1620 1621 1621 va_start(ap, fr); … … 1623 1623 va_end(ap); 1624 1624 1625 gc->evil = info->warnlevel/10;1626 /* gc->correction_time = (info->onlinesince - gc->login_time); */1625 ic->evil = info->warnlevel/10; 1626 /* ic->correction_time = (info->onlinesince - ic->login_time); */ 1627 1627 1628 1628 return 1; … … 1646 1646 1647 1647 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { 1648 struct gaim_connection *gc = sess->aux_data;1649 struct oscar_data *od = gc->proto_data;1648 struct im_connection *ic = sess->aux_data; 1649 struct oscar_data *od = ic->proto_data; 1650 1650 1651 1651 aim_clientready(sess, fr->conn); … … 1704 1704 va_list ap; 1705 1705 guint16 maxsiglen; 1706 struct gaim_connection *gc = sess->aux_data;1707 struct oscar_data *odata = (struct oscar_data *) gc->proto_data;1706 struct im_connection *ic = sess->aux_data; 1707 struct oscar_data *odata = (struct oscar_data *)ic->proto_data; 1708 1708 1709 1709 va_start(ap, fr); … … 1715 1715 /* FIXME: It seems we're not really using this, and it broke now that 1716 1716 struct aim_user is dead. 1717 aim_bos_setprofile(sess, fr->conn, gc->user->user_info, NULL, gaim_caps);1717 aim_bos_setprofile(sess, fr->conn, ic->user->user_info, NULL, gaim_caps); 1718 1718 */ 1719 1719 … … 1724 1724 va_list ap; 1725 1725 guint16 maxbuddies, maxwatchers; 1726 struct gaim_connection *gc = sess->aux_data;1727 struct oscar_data *odata = (struct oscar_data *) gc->proto_data;1726 struct im_connection *ic = sess->aux_data; 1727 struct oscar_data *odata = (struct oscar_data *)ic->proto_data; 1728 1728 1729 1729 va_start(ap, fr); … … 1741 1741 guint16 maxpermits, maxdenies; 1742 1742 va_list ap; 1743 struct gaim_connection *gc = sess->aux_data;1744 struct oscar_data *odata = (struct oscar_data *) gc->proto_data;1743 struct im_connection *ic = sess->aux_data; 1744 struct oscar_data *odata = (struct oscar_data *)ic->proto_data; 1745 1745 1746 1746 va_start(ap, fr); … … 1765 1765 va_list ap; 1766 1766 struct aim_icq_offlinemsg *msg; 1767 struct gaim_connection *gc = sess->aux_data;1767 struct im_connection *ic = sess->aux_data; 1768 1768 1769 1769 va_start(ap, fr); … … 1778 1778 g_snprintf(sender, sizeof(sender), "%u", msg->sender); 1779 1779 strip_linefeed(dialog_msg); 1780 serv_got_im( gc, sender, dialog_msg, 0, t, -1);1780 serv_got_im(ic, sender, dialog_msg, 0, t, -1); 1781 1781 g_free(dialog_msg); 1782 1782 } break; … … 1799 1799 1800 1800 strip_linefeed(dialog_msg); 1801 serv_got_im( gc, sender, dialog_msg, 0, t, -1);1801 serv_got_im(ic, sender, dialog_msg, 0, t, -1); 1802 1802 g_free(dialog_msg); 1803 1803 g_free(m); … … 1805 1805 1806 1806 case 0x0006: { /* Authorization request */ 1807 gaim_icq_authask( gc, msg->sender, msg->msg);1807 gaim_icq_authask(ic, msg->sender, msg->msg); 1808 1808 } break; 1809 1809 … … 1833 1833 } 1834 1834 1835 static void oscar_keepalive(struct gaim_connection *gc) {1836 struct oscar_data *odata = (struct oscar_data *) gc->proto_data;1835 static void oscar_keepalive(struct im_connection *ic) { 1836 struct oscar_data *odata = (struct oscar_data *)ic->proto_data; 1837 1837 aim_flap_nop(odata->sess, odata->conn); 1838 1838 } 1839 1839 1840 static int oscar_send_im(struct gaim_connection *gc, char *name, char *message, int len, int imflags) {1841 struct oscar_data *odata = (struct oscar_data *) gc->proto_data;1842 int ret = 0 ;1840 static int oscar_send_im(struct im_connection *ic, char *name, char *message, int imflags) { 1841 struct oscar_data *odata = (struct oscar_data *)ic->proto_data; 1842 int ret = 0, len = strlen(message); 1843 1843 if (imflags & IM_FLAG_AWAY) { 1844 1844 ret = aim_send_im(odata->sess, name, AIM_IMFLAGS_AWAY, message); … … 1892 1892 } 1893 1893 1894 static void oscar_get_info(struct gaim_connection *g, char *name) {1894 static void oscar_get_info(struct im_connection *g, char *name) { 1895 1895 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 1896 1896 if (odata->icq) … … 1902 1902 } 1903 1903 1904 static void oscar_get_away(struct gaim_connection *g, char *who) {1904 static void oscar_get_away(struct im_connection *g, char *who) { 1905 1905 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 1906 1906 if (odata->icq) { … … 1914 1914 } 1915 1915 1916 static void oscar_set_away_aim(struct gaim_connection *gc, struct oscar_data *od, const char *state, const char *message)1916 static void oscar_set_away_aim(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message) 1917 1917 { 1918 1918 … … 1926 1926 1927 1927 if (od->rights.maxawaymsglen == 0) 1928 do_error_dialog( gc, "oscar_set_away_aim called before locate rights received", "Protocol Error");1928 do_error_dialog(ic, "oscar_set_away_aim called before locate rights received", "Protocol Error"); 1929 1929 1930 1930 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); 1931 1931 1932 if ( gc->away)1933 g_free( gc->away);1934 gc->away = NULL;1932 if (ic->away) 1933 g_free(ic->away); 1934 ic->away = NULL; 1935 1935 1936 1936 if (!message) { … … 1944 1944 errstr = g_strdup_printf("Maximum away message length of %d bytes exceeded, truncating", od->rights.maxawaymsglen); 1945 1945 1946 do_error_dialog( gc, errstr, "Away Message Too Long");1946 do_error_dialog(ic, errstr, "Away Message Too Long"); 1947 1947 1948 1948 g_free(errstr); 1949 1949 } 1950 1950 1951 gc->away = g_strndup(message, od->rights.maxawaymsglen);1952 aim_bos_setprofile(od->sess, od->conn, NULL, gc->away, gaim_caps);1951 ic->away = g_strndup(message, od->rights.maxawaymsglen); 1952 aim_bos_setprofile(od->sess, od->conn, NULL, ic->away, gaim_caps); 1953 1953 1954 1954 return; 1955 1955 } 1956 1956 1957 static void oscar_set_away_icq(struct gaim_connection *gc, struct oscar_data *od, const char *state, const char *message)1957 static void oscar_set_away_icq(struct im_connection *ic, struct oscar_data *od, const char *state, const char *message) 1958 1958 { 1959 1959 const char *msg = NULL; … … 1961 1961 1962 1962 /* clean old states */ 1963 if ( gc->away) {1964 g_free( gc->away);1965 gc->away = NULL;1963 if (ic->away) { 1964 g_free(ic->away); 1965 ic->away = NULL; 1966 1966 } 1967 1967 od->sess->aim_icq_state = 0; … … 1979 1979 } else if (!g_strcasecmp(state, "Away")) { 1980 1980 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY); 1981 gc->away = g_strdup(msg);1981 ic->away = g_strdup(msg); 1982 1982 od->sess->aim_icq_state = AIM_MTYPE_AUTOAWAY; 1983 1983 } else if (!g_strcasecmp(state, "Do Not Disturb")) { 1984 1984 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); 1985 gc->away = g_strdup(msg);1985 ic->away = g_strdup(msg); 1986 1986 od->sess->aim_icq_state = AIM_MTYPE_AUTODND; 1987 1987 } else if (!g_strcasecmp(state, "Not Available")) { 1988 1988 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); 1989 gc->away = g_strdup(msg);1989 ic->away = g_strdup(msg); 1990 1990 od->sess->aim_icq_state = AIM_MTYPE_AUTONA; 1991 1991 } else if (!g_strcasecmp(state, "Occupied")) { 1992 1992 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); 1993 gc->away = g_strdup(msg);1993 ic->away = g_strdup(msg); 1994 1994 od->sess->aim_icq_state = AIM_MTYPE_AUTOBUSY; 1995 1995 } else if (!g_strcasecmp(state, "Free For Chat")) { 1996 1996 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_CHAT); 1997 gc->away = g_strdup(msg);1997 ic->away = g_strdup(msg); 1998 1998 od->sess->aim_icq_state = AIM_MTYPE_AUTOFFC; 1999 1999 } else if (!g_strcasecmp(state, "Invisible")) { 2000 2000 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE); 2001 gc->away = g_strdup(msg);2001 ic->away = g_strdup(msg); 2002 2002 } else if (!g_strcasecmp(state, GAIM_AWAY_CUSTOM)) { 2003 2003 if (no_message) { … … 2005 2005 } else { 2006 2006 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY); 2007 gc->away = g_strdup(msg);2007 ic->away = g_strdup(msg); 2008 2008 od->sess->aim_icq_state = AIM_MTYPE_AUTOAWAY; 2009 2009 } … … 2013 2013 } 2014 2014 2015 static void oscar_set_away(struct gaim_connection *gc, char *state, char *message)2016 { 2017 struct oscar_data *od = (struct oscar_data *) gc->proto_data;2018 2019 oscar_set_away_aim( gc, od, state, message);2015 static void oscar_set_away(struct im_connection *ic, char *state, char *message) 2016 { 2017 struct oscar_data *od = (struct oscar_data *)ic->proto_data; 2018 2019 oscar_set_away_aim(ic, od, state, message); 2020 2020 if (od->icq) 2021 oscar_set_away_icq( gc, od, state, message);2021 oscar_set_away_icq(ic, od, state, message); 2022 2022 2023 2023 return; 2024 2024 } 2025 2025 2026 static void oscar_add_buddy(struct gaim_connection *g, char *name) {2026 static void oscar_add_buddy(struct im_connection *g, char *name, char *group) { 2027 2027 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 2028 2028 aim_ssi_addbuddies(odata->sess, odata->conn, OSCAR_GROUP, &name, 1, 0); 2029 2029 } 2030 2030 2031 static void oscar_remove_buddy(struct gaim_connection *g, char *name, char *group) {2031 static void oscar_remove_buddy(struct im_connection *g, char *name, char *group) { 2032 2032 struct oscar_data *odata = (struct oscar_data *)g->proto_data; 2033 2033 struct aim_ssi_item *ssigroup; … … 2040 2040 2041 2041 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { 2042 struct gaim_connection *gc = sess->aux_data;2042 struct im_connection *ic = sess->aux_data; 2043 2043 struct aim_ssi_item *curitem; 2044 2044 int tmp; … … 2049 2049 switch (curitem->type) { 2050 2050 case 0x0000: /* Buddy */ 2051 if ((curitem->name) && (!find_buddy( gc, curitem->name))) {2051 if ((curitem->name) && (!find_buddy(ic, curitem->name))) { 2052 2052 char *realname = NULL; 2053 2053 … … 2055 2055 realname = aim_gettlv_str(curitem->data, 0x0131, 1); 2056 2056 2057 add_buddy( gc, NULL, curitem->name, realname);2057 add_buddy(ic, NULL, curitem->name, realname); 2058 2058 2059 2059 if (realname) … … 2065 2065 if (curitem->name) { 2066 2066 GSList *list; 2067 for (list= gc->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next);2067 for (list=ic->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); 2068 2068 if (!list) { 2069 2069 char *name; 2070 2070 name = g_strdup(normalize(curitem->name)); 2071 gc->permit = g_slist_append(gc->permit, name);2071 ic->permit = g_slist_append(ic->permit, name); 2072 2072 tmp++; 2073 2073 } … … 2078 2078 if (curitem->name) { 2079 2079 GSList *list; 2080 for (list= gc->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next);2080 for (list=ic->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); 2081 2081 if (!list) { 2082 2082 char *name; 2083 2083 name = g_strdup(normalize(curitem->name)); 2084 gc->deny = g_slist_append(gc->deny, name);2084 ic->deny = g_slist_append(ic->deny, name); 2085 2085 tmp++; 2086 2086 } … … 2091 2091 if (curitem->data) { 2092 2092 guint8 permdeny; 2093 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.items)) && (permdeny != gc->permdeny)) {2094 gc->permdeny = permdeny;2093 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.items)) && (permdeny != ic->permdeny)) { 2094 ic->permdeny = permdeny; 2095 2095 tmp++; 2096 2096 } … … 2110 2110 2111 2111 /* Now that we have a buddy list, we can tell BitlBee that we're online. */ 2112 account_online( gc);2112 account_online(ic); 2113 2113 2114 2114 return 1; … … 2155 2155 } 2156 2156 2157 static void oscar_set_permit_deny(struct gaim_connection *gc) {2158 struct oscar_data *od = (struct oscar_data *) gc->proto_data;2157 static void oscar_set_permit_deny(struct im_connection *ic) { 2158 struct oscar_data *od = (struct oscar_data *)ic->proto_data; 2159 2159 if (od->icq) { 2160 2160 GSList *list; … … 2162 2162 int at; 2163 2163 2164 switch( gc->permdeny) {2164 switch(ic->permdeny) { 2165 2165 case 1: 2166 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gc->username);2166 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, ic->username); 2167 2167 break; 2168 2168 case 2: 2169 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gc->username);2169 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, ic->username); 2170 2170 break; 2171 2171 case 3: 2172 list = gc->permit;2172 list = ic->permit; 2173 2173 at = 0; 2174 2174 while (list) { … … 2179 2179 break; 2180 2180 case 4: 2181 list = gc->deny;2181 list = ic->deny; 2182 2182 at = 0; 2183 2183 while (list) { … … 2190 2190 break; 2191 2191 } 2192 signoff_blocked( gc);2192 signoff_blocked(ic); 2193 2193 } else { 2194 2194 if (od->sess->ssi.received_data) 2195 aim_ssi_setpermdeny(od->sess, od->conn, gc->permdeny, 0xffffffff);2196 } 2197 } 2198 2199 static void oscar_add_permit(struct gaim_connection *gc, char *who) {2200 struct oscar_data *od = (struct oscar_data *) gc->proto_data;2195 aim_ssi_setpermdeny(od->sess, od->conn, ic->permdeny, 0xffffffff); 2196 } 2197 } 2198 2199 static void oscar_add_permit(struct im_connection *ic, char *who) { 2200 struct oscar_data *od = (struct oscar_data *)ic->proto_data; 2201 2201 if (od->icq) { 2202 2202 aim_ssi_auth_reply(od->sess, od->conn, who, 1, ""); … … 2207 2207 } 2208 2208 2209 static void oscar_add_deny(struct gaim_connection *gc, char *who) {2210 struct oscar_data *od = (struct oscar_data *) gc->proto_data;2209 static void oscar_add_deny(struct im_connection *ic, char *who) { 2210 struct oscar_data *od = (struct oscar_data *)ic->proto_data; 2211 2211 if (od->icq) { 2212 2212 aim_ssi_auth_reply(od->sess, od->conn, who, 0, ""); … … 2217 2217 } 2218 2218 2219 static void oscar_rem_permit(struct gaim_connection *gc, char *who) {2220 struct oscar_data *od = (struct oscar_data *) gc->proto_data;2219 static void oscar_rem_permit(struct im_connection *ic, char *who) { 2220 struct oscar_data *od = (struct oscar_data *)ic->proto_data; 2221 2221 if (!od->icq) { 2222 2222 if (od->sess->ssi.received_data) … … 2225 2225 } 2226 2226 2227 static void oscar_rem_deny(struct gaim_connection *gc, char *who) {2228 struct oscar_data *od = (struct oscar_data *) gc->proto_data;2227 static void oscar_rem_deny(struct im_connection *ic, char *who) { 2228 struct oscar_data *od = (struct oscar_data *)ic->proto_data; 2229 2229 if (!od->icq) { 2230 2230 if (od->sess->ssi.received_data) … … 2233 2233 } 2234 2234 2235 static GList *oscar_away_states(struct gaim_connection *gc)2236 { 2237 struct oscar_data *od = gc->proto_data;2235 static GList *oscar_away_states(struct im_connection *ic) 2236 { 2237 struct oscar_data *od = ic->proto_data; 2238 2238 GList *m = NULL; 2239 2239 … … 2254 2254 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) 2255 2255 { 2256 struct gaim_connection *gc = sess->aux_data;2256 struct im_connection *ic = sess->aux_data; 2257 2257 gchar who[16]; 2258 2258 GString *str; … … 2330 2330 } 2331 2331 2332 serv_got_crap( gc, "%s\n%s", _("User Info"), str->str);2332 serv_got_crap(ic, "%s\n%s", _("User Info"), str->str); 2333 2333 g_string_free(str, TRUE); 2334 2334 … … 2395 2395 static int gaim_parseaiminfo(aim_session_t *sess, aim_frame_t *fr, ...) 2396 2396 { 2397 struct gaim_connection *gc = sess->aux_data;2397 struct im_connection *ic = sess->aux_data; 2398 2398 va_list ap; 2399 2399 aim_userinfo_t *userinfo; … … 2424 2424 idletime.tm_sec = 0; 2425 2425 strftime(buff, 256, _("%d days %H hours %M minutes"), &idletime); 2426 serv_got_crap( gc, "%s: %s", _("Idle Time"), buff);2426 serv_got_crap(ic, "%s: %s", _("Idle Time"), buff); 2427 2427 } 2428 2428 2429 2429 if(text) { 2430 2430 utf8 = oscar_encoding_to_utf8(extracted_encoding, text, text_length); 2431 serv_got_crap( gc, "%s\n%s", _("User Info"), utf8);2431 serv_got_crap(ic, "%s\n%s", _("User Info"), utf8); 2432 2432 } else { 2433 serv_got_crap( gc, _("No user info available."));2433 serv_got_crap(ic, _("No user info available.")); 2434 2434 } 2435 2435 } else if(infotype == AIM_GETINFO_AWAYMESSAGE && userinfo->flags & AIM_FLAG_AWAY) { 2436 2436 utf8 = oscar_encoding_to_utf8(extracted_encoding, text, text_length); 2437 serv_got_crap( gc, "%s\n%s", _("Away Message"), utf8);2437 serv_got_crap(ic, "%s\n%s", _("Away Message"), utf8); 2438 2438 } 2439 2439 … … 2445 2445 int gaim_parsemtn(aim_session_t *sess, aim_frame_t *fr, ...) 2446 2446 { 2447 struct gaim_connection * gc = sess->aux_data;2447 struct im_connection * ic = sess->aux_data; 2448 2448 va_list ap; 2449 2449 guint16 type1, type2; … … 2458 2458 if(type2 == 0x0002) { 2459 2459 /* User is typing */ 2460 serv_got_typing( gc, sn, 0, 1);2460 serv_got_typing(ic, sn, 0, 1); 2461 2461 } 2462 2462 else if (type2 == 0x0001) { 2463 2463 /* User has typed something, but is not actively typing (stale) */ 2464 serv_got_typing( gc, sn, 0, 2);2464 serv_got_typing(ic, sn, 0, 2); 2465 2465 } 2466 2466 else { 2467 2467 /* User has stopped typing */ 2468 serv_got_typing( gc, sn, 0, 0);2468 serv_got_typing(ic, sn, 0, 0); 2469 2469 } 2470 2470 … … 2472 2472 } 2473 2473 2474 static char *oscar_get_status_string( struct gaim_connection *gc, int number )2475 { 2476 struct oscar_data *od = gc->proto_data;2474 static char *oscar_get_status_string( struct im_connection *ic, int number ) 2475 { 2476 struct oscar_data *od = ic->proto_data; 2477 2477 2478 2478 if( ! number & UC_UNAVAILABLE ) … … 2500 2500 } 2501 2501 2502 int oscar_send_typing(struct gaim_connection *gc, char * who, int typing)2503 { 2504 struct oscar_data *od = gc->proto_data;2502 int oscar_send_typing(struct im_connection *ic, char * who, int typing) 2503 { 2504 struct oscar_data *od = ic->proto_data; 2505 2505 return( aim_im_sendmtn(od->sess, 1, who, typing ? 0x0002 : 0x0000) ); 2506 2506 } 2507 2507 2508 int oscar_chat_send(struct conversation *c, char *message)2509 { 2510 struct gaim_connection *gc = c->gc;2511 struct oscar_data * od = (struct oscar_data*) gc->proto_data;2508 void oscar_chat_send(struct groupchat *c, char *message, int msgflags) 2509 { 2510 struct im_connection *ic = c->ic; 2511 struct oscar_data * od = (struct oscar_data*)ic->proto_data; 2512 2512 struct chat_connection * ccon; 2513 2513 int ret; … … 2550 2550 } 2551 2551 2552 return (ret >= 0); 2553 } 2554 2555 void oscar_chat_invite(struct conversation*c, char *message, char *who)2556 { 2557 struct gaim_connection *gc = c->gc;2558 struct oscar_data * od = (struct oscar_data *) gc->proto_data;2552 /* return (ret >= 0); */ 2553 } 2554 2555 void oscar_chat_invite(struct groupchat *c, char *message, char *who) 2556 { 2557 struct im_connection *ic = c->ic; 2558 struct oscar_data * od = (struct oscar_data *)ic->proto_data; 2559 2559 struct chat_connection *ccon = c->data; 2560 2560 … … 2563 2563 } 2564 2564 2565 void oscar_chat_kill(struct gaim_connection *gc, struct chat_connection *cc)2566 { 2567 struct oscar_data *od = (struct oscar_data *) gc->proto_data;2565 void oscar_chat_kill(struct im_connection *ic, struct chat_connection *cc) 2566 { 2567 struct oscar_data *od = (struct oscar_data *)ic->proto_data; 2568 2568 2569 2569 /* Notify the conversation window that we've left the chat */ … … 2580 2580 } 2581 2581 2582 void oscar_chat_leave(struct conversation*c)2583 { 2584 oscar_chat_kill(c-> gc, c->data);2585 } 2586 2587 int oscar_chat_join(struct gaim_connection * gc, char * name)2588 { 2589 struct oscar_data * od = (struct oscar_data *) gc->proto_data;2582 void oscar_chat_leave(struct groupchat *c) 2583 { 2584 oscar_chat_kill(c->ic, c->data); 2585 } 2586 2587 int oscar_chat_join(struct im_connection * ic, char * name) 2588 { 2589 struct oscar_data * od = (struct oscar_data *)ic->proto_data; 2590 2590 2591 2591 aim_conn_t * cur; … … 2605 2605 } 2606 2606 2607 struct conversation *oscar_chat_open(struct gaim_connection * gc, char *who)2608 { 2609 struct oscar_data * od = (struct oscar_data *) gc->proto_data;2607 struct groupchat *oscar_chat_with(struct im_connection * ic, char *who) 2608 { 2609 struct oscar_data * od = (struct oscar_data *)ic->proto_data; 2610 2610 int ret; 2611 2611 static int chat_id = 0; 2612 2612 char * chatname; 2613 2613 2614 chatname = g_strdup_printf("%s%d", gc->username, chat_id++);2614 chatname = g_strdup_printf("%s%d", ic->username, chat_id++); 2615 2615 2616 ret = oscar_chat_join( gc, chatname);2616 ret = oscar_chat_join(ic, chatname); 2617 2617 2618 2618 aim_chat_invite(od->sess, od->conn, who, "", 4, chatname, 0x0); … … 2625 2625 void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv) 2626 2626 { 2627 oscar_chat_join(inv-> gc, inv->name);2627 oscar_chat_join(inv->ic, inv->name); 2628 2628 g_free(inv->name); 2629 2629 g_free(inv); … … 2636 2636 } 2637 2637 2638 void oscar_init ()2638 void oscar_initmodule() 2639 2639 { 2640 2640 struct prpl *ret = g_new0(struct prpl, 1); 2641 2641 ret->name = "oscar"; 2642 2642 ret->away_states = oscar_away_states; 2643 ret->init = oscar_init; 2643 2644 ret->login = oscar_login; 2644 ret-> acc_init = oscar_acc_init;2645 ret-> close = oscar_close;2645 ret->keepalive = oscar_keepalive; 2646 ret->logout = oscar_logout; 2646 2647 ret->send_im = oscar_send_im; 2647 2648 ret->get_info = oscar_get_info; … … 2653 2654 ret->chat_invite = oscar_chat_invite; 2654 2655 ret->chat_leave = oscar_chat_leave; 2655 ret->chat_ open = oscar_chat_open;2656 ret->chat_with = oscar_chat_with; 2656 2657 ret->add_permit = oscar_add_permit; 2657 2658 ret->add_deny = oscar_add_deny; … … 2659 2660 ret->rem_deny = oscar_rem_deny; 2660 2661 ret->set_permit_deny = oscar_set_permit_deny; 2661 ret->keepalive = oscar_keepalive;2662 2662 ret->get_status_string = oscar_get_status_string; 2663 2663 ret->send_typing = oscar_send_typing; -
protocols/oscar/service.c
rfa29d093 r0da65d5 732 732 guint32 data; 733 733 int tlvlen; 734 struct gaim_connection *gc = sess ? sess->aux_data : NULL;734 struct im_connection *ic = sess ? sess->aux_data : NULL; 735 735 736 736 data = AIM_ICQ_STATE_HIDEIP | status; /* yay for error checking ;^) */ 737 737 738 if ( gc && set_getbool(&gc->acc->set, "web_aware"))738 if (ic && set_getbool(&ic->acc->set, "web_aware")) 739 739 data |= AIM_ICQ_STATE_WEBAWARE; 740 740 -
protocols/yahoo/yahoo.c
rfa29d093 r0da65d5 58 58 { 59 59 char *name; 60 struct conversation*c;60 struct groupchat *c; 61 61 int yid; 62 62 YList *members; 63 struct gaim_connection *gc;63 struct im_connection *ic; 64 64 }; 65 65 … … 123 123 static void byahoo_login( account_t *acc ) 124 124 { 125 struct gaim_connection *gc = new_gaim_conn( acc );126 struct byahoo_data *yd = gc->proto_data = g_new0( struct byahoo_data, 1 );125 struct im_connection *ic = new_gaim_conn( acc ); 126 struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 ); 127 127 128 128 yd->logged_in = FALSE; 129 129 yd->current_status = YAHOO_STATUS_AVAILABLE; 130 130 131 set_login_progress( gc, 1, "Connecting" );131 set_login_progress( ic, 1, "Connecting" ); 132 132 yd->y2_id = yahoo_init( acc->user, acc->pass ); 133 133 yahoo_login( yd->y2_id, yd->current_status ); 134 134 } 135 135 136 static void byahoo_ close( struct gaim_connection *gc )137 { 138 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;136 static void byahoo_logout( struct im_connection *ic ) 137 { 138 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 139 139 GSList *l; 140 140 141 while( gc->conversations )142 serv_got_chat_left( gc->conversations );141 while( ic->conversations ) 142 serv_got_chat_left( ic->conversations ); 143 143 144 144 for( l = yd->buddygroups; l; l = l->next ) … … 160 160 } 161 161 162 static void byahoo_get_info(struct gaim_connection *gc, char *who)162 static void byahoo_get_info(struct im_connection *ic, char *who) 163 163 { 164 164 /* Just make an URL and let the user fetch the info */ 165 serv_got_crap( gc, "%s\n%s: %s%s", _("User Info"),165 serv_got_crap(ic, "%s\n%s: %s%s", _("User Info"), 166 166 _("For now, fetch yourself"), yahoo_get_profile_url(), 167 167 who); 168 168 } 169 169 170 static int byahoo_send_im( struct gaim_connection *gc, char *who, char *what, int len, int flags )171 { 172 struct byahoo_data *yd = gc->proto_data;170 static int byahoo_send_im( struct im_connection *ic, char *who, char *what, int flags ) 171 { 172 struct byahoo_data *yd = ic->proto_data; 173 173 174 174 yahoo_send_im( yd->y2_id, NULL, who, what, 1 ); … … 177 177 } 178 178 179 static int byahoo_send_typing( struct gaim_connection *gc, char *who, int typing )180 { 181 struct byahoo_data *yd = gc->proto_data;179 static int byahoo_send_typing( struct im_connection *ic, char *who, int typing ) 180 { 181 struct byahoo_data *yd = ic->proto_data; 182 182 183 183 yahoo_send_typing( yd->y2_id, NULL, who, typing ); … … 186 186 } 187 187 188 static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg )189 { 190 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;191 192 gc->away = NULL;188 static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) 189 { 190 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 191 192 ic->away = NULL; 193 193 194 194 if( state && msg && g_strcasecmp( state, msg ) != 0 ) 195 195 { 196 196 yd->current_status = YAHOO_STATUS_CUSTOM; 197 gc->away = "";197 ic->away = ""; 198 198 } 199 199 else if( state ) … … 204 204 msg = NULL; 205 205 206 gc->away = "";206 ic->away = ""; 207 207 if( g_strcasecmp( state, "Available" ) == 0 ) 208 208 { 209 209 yd->current_status = YAHOO_STATUS_AVAILABLE; 210 gc->away = NULL;210 ic->away = NULL; 211 211 } 212 212 else if( g_strcasecmp( state, "Be Right Back" ) == 0 ) … … 234 234 yd->current_status = YAHOO_STATUS_AVAILABLE; 235 235 236 gc->away = NULL;236 ic->away = NULL; 237 237 } 238 238 } … … 240 240 yd->current_status = YAHOO_STATUS_AVAILABLE; 241 241 242 yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL );243 } 244 245 static GList *byahoo_away_states( struct gaim_connection *gc )242 yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL ); 243 } 244 245 static GList *byahoo_away_states( struct im_connection *ic ) 246 246 { 247 247 GList *m = NULL; … … 263 263 } 264 264 265 static void byahoo_keepalive( struct gaim_connection *gc )266 { 267 struct byahoo_data *yd = gc->proto_data;265 static void byahoo_keepalive( struct im_connection *ic ) 266 { 267 struct byahoo_data *yd = ic->proto_data; 268 268 269 269 yahoo_keepalive( yd->y2_id ); 270 270 } 271 271 272 static void byahoo_add_buddy( struct gaim_connection *gc, char *who)273 { 274 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;275 276 yahoo_add_buddy( yd->y2_id, who, BYAHOO_DEFAULT_GROUP );277 } 278 279 static void byahoo_remove_buddy( struct gaim_connection *gc, char *who, char *group )280 { 281 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;272 static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group ) 273 { 274 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 275 276 yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP ); 277 } 278 279 static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *group ) 280 { 281 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 282 282 GSList *bgl; 283 283 … … 293 293 } 294 294 295 static char *byahoo_get_status_string( struct gaim_connection *gc, int stat )295 static char *byahoo_get_status_string( struct im_connection *ic, int stat ) 296 296 { 297 297 enum yahoo_status a = stat >> 1; … … 332 332 } 333 333 334 static int byahoo_chat_send( struct conversation *c, char *message)335 { 336 struct byahoo_data *yd = (struct byahoo_data *) c-> gc->proto_data;334 static void byahoo_chat_send( struct groupchat *c, char *message, int flags ) 335 { 336 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 337 337 338 338 yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 ); 339 340 return( 0 ); 341 } 342 343 static void byahoo_chat_invite( struct conversation *c, char *msg, char *who ) 344 { 345 struct byahoo_data *yd = (struct byahoo_data *) c->gc->proto_data; 339 } 340 341 static void byahoo_chat_invite( struct groupchat *c, char *msg, char *who ) 342 { 343 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 346 344 347 345 yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ); 348 346 } 349 347 350 static void byahoo_chat_leave( struct conversation*c )351 { 352 struct byahoo_data *yd = (struct byahoo_data *) c-> gc->proto_data;348 static void byahoo_chat_leave( struct groupchat *c ) 349 { 350 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 353 351 354 352 yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title ); … … 356 354 } 357 355 358 static struct conversation *byahoo_chat_open( struct gaim_connection *gc, char *who )359 { 360 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;361 struct conversation*c;356 static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who ) 357 { 358 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 359 struct groupchat *c; 362 360 char *roomname; 363 361 YList *members; 364 362 365 roomname = g_new0( char, strlen( gc->username ) + 16 );366 g_snprintf( roomname, strlen( gc->username ) + 16, "%s-Bee-%d", gc->username, byahoo_chat_id );367 368 c = serv_got_joined_chat( gc, roomname );369 add_chat_buddy( c, gc->username );363 roomname = g_new0( char, strlen( ic->username ) + 16 ); 364 g_snprintf( roomname, strlen( ic->username ) + 16, "%s-Bee-%d", ic->username, byahoo_chat_id ); 365 366 c = serv_got_joined_chat( ic, roomname ); 367 add_chat_buddy( c, ic->username ); 370 368 371 369 /* FIXME: Free this thing when the chat's destroyed. We can't *always* … … 381 379 } 382 380 383 void byahoo_init ( )381 void byahoo_initmodule( ) 384 382 { 385 383 struct prpl *ret = g_new0(struct prpl, 1); … … 387 385 388 386 ret->login = byahoo_login; 389 ret->close = byahoo_close; 387 ret->keepalive = byahoo_keepalive; 388 ret->logout = byahoo_logout; 389 390 390 ret->send_im = byahoo_send_im; 391 391 ret->get_info = byahoo_get_info; 392 392 ret->away_states = byahoo_away_states; 393 393 ret->set_away = byahoo_set_away; 394 ret->keepalive = byahoo_keepalive;395 394 ret->add_buddy = byahoo_add_buddy; 396 395 ret->remove_buddy = byahoo_remove_buddy; … … 401 400 ret->chat_invite = byahoo_chat_invite; 402 401 ret->chat_leave = byahoo_chat_leave; 403 ret->chat_ open = byahoo_chat_open;402 ret->chat_with = byahoo_chat_with; 404 403 405 404 ret->handle_cmp = g_strcasecmp; … … 408 407 } 409 408 410 static struct gaim_connection *byahoo_get_gc_by_id( int id )409 static struct im_connection *byahoo_get_ic_by_id( int id ) 411 410 { 412 411 GSList *l; 413 struct gaim_connection *gc;412 struct im_connection *ic; 414 413 struct byahoo_data *yd; 415 414 416 415 for( l = get_connections(); l; l = l->next ) 417 416 { 418 gc = l->data;419 yd = gc->proto_data;420 421 if( strcmp( gc->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id )422 return( gc );417 ic = l->data; 418 yd = ic->proto_data; 419 420 if( strcmp( ic->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id ) 421 return( ic ); 423 422 } 424 423 … … 441 440 struct byahoo_connect_callback_data *d = data; 442 441 443 if( !byahoo_get_ gc_by_id( d->id ) )442 if( !byahoo_get_ic_by_id( d->id ) ) 444 443 { 445 444 g_free( d ); … … 463 462 struct byahoo_read_ready_data *d = data; 464 463 465 if( !byahoo_get_ gc_by_id( d->id ) )464 if( !byahoo_get_ic_by_id( d->id ) ) 466 465 /* WTF doesn't libyahoo clean this up? */ 467 466 return FALSE; … … 484 483 struct byahoo_write_ready_data *d = data; 485 484 486 if( !byahoo_get_ gc_by_id( d->id ) )485 if( !byahoo_get_ic_by_id( d->id ) ) 487 486 /* WTF doesn't libyahoo clean this up? */ 488 487 return FALSE; … … 495 494 void ext_yahoo_login_response( int id, int succ, char *url ) 496 495 { 497 struct gaim_connection *gc = byahoo_get_gc_by_id( id );496 struct im_connection *ic = byahoo_get_ic_by_id( id ); 498 497 struct byahoo_data *yd = NULL; 499 498 500 if( gc == NULL )499 if( ic == NULL ) 501 500 { 502 501 /* libyahoo2 seems to call this one twice when something … … 508 507 } 509 508 510 yd = (struct byahoo_data *) gc->proto_data;509 yd = (struct byahoo_data *) ic->proto_data; 511 510 512 511 if( succ == YAHOO_LOGIN_OK ) 513 512 { 514 account_online( gc );513 account_online( ic ); 515 514 516 515 yd->logged_in = TRUE; … … 532 531 { 533 532 errstr = "Logged in on a different machine or device"; 534 gc->wants_to_die = TRUE;533 ic->wants_to_die = TRUE; 535 534 } 536 535 else if( succ == YAHOO_LOGIN_SOCK ) … … 551 550 552 551 if( yd->logged_in ) 553 hide_login_progress_error( gc, s );552 hide_login_progress_error( ic, s ); 554 553 else 555 hide_login_progress( gc, s );554 hide_login_progress( ic, s ); 556 555 557 556 g_free( s ); 558 557 559 signoff( gc );558 signoff( ic ); 560 559 } 561 560 } … … 563 562 void ext_yahoo_got_buddies( int id, YList *buds ) 564 563 { 565 struct gaim_connection *gc = byahoo_get_gc_by_id( id );566 struct byahoo_data *yd = gc->proto_data;564 struct im_connection *ic = byahoo_get_ic_by_id( id ); 565 struct byahoo_data *yd = ic->proto_data; 567 566 YList *bl = buds; 568 567 … … 581 580 } 582 581 583 add_buddy( gc, b->group, b->id, b->real_name );582 add_buddy( ic, b->group, b->id, b->real_name ); 584 583 bl = bl->next; 585 584 } … … 600 599 void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away ) 601 600 { 602 struct gaim_connection *gc = byahoo_get_gc_by_id( id );603 604 serv_got_update( gc, who, stat != YAHOO_STATUS_OFFLINE, 0, 0,601 struct im_connection *ic = byahoo_get_ic_by_id( id ); 602 603 serv_got_update( ic, who, stat != YAHOO_STATUS_OFFLINE, 0, 0, 605 604 ( stat == YAHOO_STATUS_IDLE ) ? away : 0, 606 605 ( stat != YAHOO_STATUS_AVAILABLE ) | ( stat << 1 ), 0 ); … … 609 608 void ext_yahoo_got_im( int id, char *who, char *msg, long tm, int stat, int utf8 ) 610 609 { 611 struct gaim_connection *gc = byahoo_get_gc_by_id( id );610 struct im_connection *ic = byahoo_get_ic_by_id( id ); 612 611 char *m = byahoo_strip( msg ); 613 612 614 serv_got_im( gc, who, m, 0, 0, strlen( m ) );613 serv_got_im( ic, who, m, 0, 0, strlen( m ) ); 615 614 g_free( m ); 616 615 } … … 618 617 void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, char *fname, unsigned long fesize ) 619 618 { 620 struct gaim_connection *gc = byahoo_get_gc_by_id( id );621 622 serv_got_crap( gc, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who );619 struct im_connection *ic = byahoo_get_ic_by_id( id ); 620 621 serv_got_crap( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); 623 622 } 624 623 625 624 void ext_yahoo_typing_notify( int id, char *who, int stat ) 626 625 { 627 struct gaim_connection *gc = byahoo_get_gc_by_id( id );626 struct im_connection *ic = byahoo_get_ic_by_id( id ); 628 627 if (stat == 1) { 629 628 /* User is typing */ 630 serv_got_typing( gc, who, 1, 1 );629 serv_got_typing( ic, who, 1, 1 ); 631 630 } 632 631 else { 633 632 /* User stopped typing */ 634 serv_got_typing( gc, who, 1, 0 );633 serv_got_typing( ic, who, 1, 0 ); 635 634 } 636 635 } … … 638 637 void ext_yahoo_system_message( int id, char *msg ) 639 638 { 640 struct gaim_connection *gc = byahoo_get_gc_by_id( id );641 642 serv_got_crap( gc, "Yahoo! system message: %s", msg );639 struct im_connection *ic = byahoo_get_ic_by_id( id ); 640 641 serv_got_crap( ic, "Yahoo! system message: %s", msg ); 643 642 } 644 643 645 644 void ext_yahoo_webcam_invite( int id, char *from ) 646 645 { 647 struct gaim_connection *gc = byahoo_get_gc_by_id( id );648 649 serv_got_crap( gc, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from );646 struct im_connection *ic = byahoo_get_ic_by_id( id ); 647 648 serv_got_crap( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); 650 649 } 651 650 652 651 void ext_yahoo_error( int id, char *err, int fatal ) 653 652 { 654 struct gaim_connection *gc = byahoo_get_gc_by_id( id );653 struct im_connection *ic = byahoo_get_ic_by_id( id ); 655 654 656 655 if( fatal ) 657 656 { 658 hide_login_progress_error( gc, err );659 signoff( gc );657 hide_login_progress_error( ic, err ); 658 signoff( ic ); 660 659 } 661 660 else 662 661 { 663 do_error_dialog( gc, err, "Yahoo! error" );662 do_error_dialog( ic, err, "Yahoo! error" ); 664 663 } 665 664 } … … 788 787 { 789 788 yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name ); 790 add_chat_buddy( inv->c, inv-> gc->username );789 add_chat_buddy( inv->c, inv->ic->username ); 791 790 g_free( inv->name ); 792 791 g_free( inv ); … … 803 802 void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList *members ) 804 803 { 805 struct gaim_connection *gc = byahoo_get_gc_by_id( id );804 struct im_connection *ic = byahoo_get_ic_by_id( id ); 806 805 struct byahoo_conf_invitation *inv; 807 806 char txt[1024]; … … 811 810 memset( inv, 0, sizeof( struct byahoo_conf_invitation ) ); 812 811 inv->name = g_strdup( room ); 813 inv->c = serv_got_joined_chat( gc, room );812 inv->c = serv_got_joined_chat( ic, room ); 814 813 inv->c->data = members; 815 814 inv->yid = id; 816 815 inv->members = members; 817 inv-> gc = gc;816 inv->ic = ic; 818 817 819 818 for( m = members; m; m = m->next ) 820 if( g_strcasecmp( m->data, gc->username ) != 0 )819 if( g_strcasecmp( m->data, ic->username ) != 0 ) 821 820 add_chat_buddy( inv->c, m->data ); 822 821 823 822 g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg ); 824 823 825 do_ask_dialog( gc, txt, inv, byahoo_accept_conf, byahoo_reject_conf );824 do_ask_dialog( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf ); 826 825 } 827 826 828 827 void ext_yahoo_conf_userdecline( int id, char *who, char *room, char *msg ) 829 828 { 830 struct gaim_connection *gc = byahoo_get_gc_by_id( id );831 832 serv_got_crap( gc, "Invite to chatroom %s rejected by %s: %s", room, who, msg );829 struct im_connection *ic = byahoo_get_ic_by_id( id ); 830 831 serv_got_crap( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); 833 832 } 834 833 835 834 void ext_yahoo_conf_userjoin( int id, char *who, char *room ) 836 835 { 837 struct gaim_connection *gc = byahoo_get_gc_by_id( id );838 struct conversation*c;839 840 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );836 struct im_connection *ic = byahoo_get_ic_by_id( id ); 837 struct groupchat *c; 838 839 for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); 841 840 842 841 if( c ) … … 846 845 void ext_yahoo_conf_userleave( int id, char *who, char *room ) 847 846 { 848 struct gaim_connection *gc = byahoo_get_gc_by_id( id );849 struct conversation*c;850 851 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );847 struct im_connection *ic = byahoo_get_ic_by_id( id ); 848 struct groupchat *c; 849 850 for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); 852 851 853 852 if( c ) … … 857 856 void ext_yahoo_conf_message( int id, char *who, char *room, char *msg, int utf8 ) 858 857 { 859 struct gaim_connection *gc = byahoo_get_gc_by_id( id );858 struct im_connection *ic = byahoo_get_ic_by_id( id ); 860 859 char *m = byahoo_strip( msg ); 861 struct conversation*c;862 863 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );860 struct groupchat *c; 861 862 for( c = ic->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); 864 863 865 864 if( c ) … … 910 909 void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt ) 911 910 { 912 struct gaim_connection *gc = byahoo_get_gc_by_id( id );911 struct im_connection *ic = byahoo_get_ic_by_id( id ); 913 912 914 913 if( from && subj ) 915 serv_got_crap( gc, "Received e-mail message from %s with subject `%s'", from, subj );914 serv_got_crap( ic, "Received e-mail message from %s with subject `%s'", from, subj ); 916 915 else if( cnt > 0 ) 917 serv_got_crap( gc, "Received %d new e-mails", cnt );916 serv_got_crap( ic, "Received %d new e-mails", cnt ); 918 917 } 919 918
Note: See TracChangeset
for help on using the changeset viewer.