Changeset f1c2b21
- Timestamp:
- 2010-07-10T15:08:02Z (14 years ago)
- Branches:
- master
- Children:
- e92c4f4
- Parents:
- 534e406
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ipc.c
r534e406 rf1c2b21 333 333 strcmp( irc->password, cmd[3] ) == 0 ) 334 334 { 335 GSList *l; 336 337 /* TODO: Move this all into irc_switch_fd() or so and 338 irc_sync() */ 339 b_event_remove( irc->r_watch_source_id ); 340 closesocket( irc->fd ); 341 irc->fd = ipc_child_recv_fd; 342 irc->r_watch_source_id = b_input_add( irc->fd, B_EV_IO_READ, bitlbee_io_current_client_read, irc ); 335 irc_switch_fd( irc, ipc_child_recv_fd ); 336 irc_sync( irc ); 337 irc_usermsg( irc, "You've successfully taken over your old session" ); 343 338 ipc_child_recv_fd = -1; 344 345 irc_write( irc, ":%s!%s@%s MODE %s :+%s", irc->user->nick,346 irc->user->user, irc->user->host, irc->user->nick,347 irc->umode );348 349 for( l = irc->channels; l; l = l->next )350 {351 irc_channel_t *ic = l->data;352 if( ic->flags & IRC_CHANNEL_JOINED )353 irc_send_join( ic, irc->user );354 }355 irc_usermsg( irc, "You've successfully taken over your old session" );356 339 357 340 ipc_to_master_str( "TAKEOVER DONE\r\n" ); … … 377 360 { 378 361 irc_t *irc = data; 379 GSList *l;380 362 381 363 /* Master->New connection */ … … 392 374 irc_umode_set( irc, "-R", 1 ); 393 375 394 for( l = irc->channels; l; l = l->next ) 395 irc_channel_del_user( l->data, irc->user, IRC_CDU_KICK, 396 "Switching to old session" ); 397 398 irc_write( irc, ":%s!%s@%s MODE %s :-%s", irc->user->nick, 399 irc->user->user, irc->user->host, irc->user->nick, 400 irc->umode ); 376 irc_desync( irc ); 401 377 } 402 378 -
ipc.h
r534e406 rf1c2b21 55 55 void ipc_child_disable(); 56 56 57 gboolean ipc_child_identify( irc_t *irc ); 58 57 59 void ipc_to_master( char **cmd ); 58 60 void ipc_to_master_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 ); -
irc.c
r534e406 rf1c2b21 619 619 } 620 620 621 /* Flush sendbuffer if you can. If it fails, fail silently and let some 622 I/O event handler clean up. */ 623 void irc_flush( irc_t *irc ) 624 { 625 ssize_t n; 626 size_t len; 627 628 if( irc->sendbuffer == NULL ) 629 return; 630 631 len = strlen( irc->sendbuffer ); 632 if( ( n = send( irc->fd, irc->sendbuffer, len, 0 ) ) == len ) 633 { 634 g_free( irc->sendbuffer ); 635 irc->sendbuffer = NULL; 636 637 b_event_remove( irc->w_watch_source_id ); 638 irc->w_watch_source_id = 0; 639 } 640 else if( n > 0 ) 641 { 642 char *s = g_strdup( irc->sendbuffer + n ); 643 g_free( irc->sendbuffer ); 644 irc->sendbuffer = s; 645 } 646 /* Otherwise something went wrong and we don't currently care 647 what the error was. We may or may not succeed later, we 648 were just trying to flush the buffer immediately. */ 649 } 650 651 /* Meant for takeover functionality. Transfer an IRC connection to a different 652 socket. */ 653 void irc_switch_fd( irc_t *irc, int fd ) 654 { 655 irc_write( irc, "ERROR :Transferring session to a new connection" ); 656 irc_flush( irc ); /* Write it now or forget about it forever. */ 657 658 if( irc->sendbuffer ) 659 { 660 b_event_remove( irc->w_watch_source_id ); 661 g_free( irc->sendbuffer ); 662 irc->sendbuffer = irc->w_watch_source_id = 0; 663 } 664 665 b_event_remove( irc->r_watch_source_id ); 666 closesocket( irc->fd ); 667 irc->fd = fd; 668 irc->r_watch_source_id = b_input_add( irc->fd, B_EV_IO_READ, bitlbee_io_current_client_read, irc ); 669 } 670 671 void irc_sync( irc_t *irc ) 672 { 673 GSList *l; 674 675 irc_write( irc, ":%s!%s@%s MODE %s :+%s", irc->user->nick, 676 irc->user->user, irc->user->host, irc->user->nick, 677 irc->umode ); 678 679 for( l = irc->channels; l; l = l->next ) 680 { 681 irc_channel_t *ic = l->data; 682 if( ic->flags & IRC_CHANNEL_JOINED ) 683 irc_send_join( ic, irc->user ); 684 } 685 } 686 687 void irc_desync( irc_t *irc ) 688 { 689 GSList *l; 690 691 for( l = irc->channels; l; l = l->next ) 692 irc_channel_del_user( l->data, irc->user, IRC_CDU_KICK, 693 "Switching to old session" ); 694 695 irc_write( irc, ":%s!%s@%s MODE %s :-%s", irc->user->nick, 696 irc->user->user, irc->user->host, irc->user->nick, 697 irc->umode ); 698 } 699 621 700 int irc_check_login( irc_t *irc ) 622 701 { -
irc.h
r534e406 rf1c2b21 229 229 void irc_write_all( int now, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 230 230 void irc_vawrite( irc_t *irc, char *format, va_list params ); 231 232 void irc_flush( irc_t *irc ); 233 void irc_switch_fd( irc_t *irc, int fd ); 234 void irc_sync( irc_t *irc ); 235 void irc_desync( irc_t *irc ); 231 236 232 237 int irc_check_login( irc_t *irc ); -
root_commands.c
r534e406 rf1c2b21 28 28 #include "bitlbee.h" 29 29 #include "help.h" 30 31 #include <string.h> 30 #include "ipc.h" 32 31 33 32 void root_command_string( irc_t *irc, char *command )
Note: See TracChangeset
for help on using the changeset viewer.