Changeset 0da65d5 for protocols/msn/ns.c
- Timestamp:
- 2007-03-31T05:40:45Z (17 years ago)
- Branches:
- master
- Children:
- aef4828
- Parents:
- fa29d093
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.