Changes in irc.c [0356ae3:dd89a55]
Legend:
- Unmodified
- Added
- Removed
-
irc.c
r0356ae3 rdd89a55 29 29 #include "ipc.h" 30 30 31 static gboolean irc_userping( gpointer _irc , int fd, b_input_condition cond);31 static gboolean irc_userping( gpointer _irc ); 32 32 33 33 GSList *irc_connection_list = NULL; … … 54 54 55 55 irc->fd = fd; 56 sock_make_nonblocking( irc->fd ); 57 58 irc->r_watch_source_id = b_input_add( irc->fd, GAIM_INPUT_READ, bitlbee_io_current_client_read, irc ); 56 irc->io_channel = g_io_channel_unix_new( fd ); 57 #ifdef GLIB2 58 g_io_channel_set_encoding (irc->io_channel, NULL, NULL); 59 g_io_channel_set_buffered (irc->io_channel, FALSE); 60 g_io_channel_set_flags( irc->io_channel, G_IO_FLAG_NONBLOCK, NULL ); 61 #else 62 fcntl( irc->fd, F_SETFL, O_NONBLOCK); 63 #endif 64 irc->r_watch_source_id = g_io_add_watch( irc->io_channel, G_IO_IN | G_IO_ERR | G_IO_HUP, bitlbee_io_current_client_read, irc ); 59 65 60 66 irc->status = USTATUS_OFFLINE; … … 114 120 115 121 if( global.conf->ping_interval > 0 && global.conf->ping_timeout > 0 ) 116 irc->ping_source_id = b_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc );122 irc->ping_source_id = g_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc ); 117 123 118 124 irc_write( irc, ":%s NOTICE AUTH :%s", irc->myhost, "BitlBee-IRCd initialized, please go on" ); … … 184 190 bitlbee_.._write doesn't do it first. */ 185 191 186 b_event_remove( irc->r_watch_source_id );187 irc->r_watch_source_id = b_timeout_add( 1000, (b_event_handler) irc_free, irc);192 g_source_remove( irc->r_watch_source_id ); 193 irc->r_watch_source_id = g_timeout_add_full( G_PRIORITY_HIGH, 1000, (GSourceFunc) irc_free, irc, NULL ); 188 194 } 189 195 else … … 218 224 219 225 if( irc->ping_source_id > 0 ) 220 b_event_remove( irc->ping_source_id );221 b_event_remove( irc->r_watch_source_id );226 g_source_remove( irc->ping_source_id ); 227 g_source_remove( irc->r_watch_source_id ); 222 228 if( irc->w_watch_source_id > 0 ) 223 b_event_remove( irc->w_watch_source_id ); 224 229 g_source_remove( irc->w_watch_source_id ); 230 231 g_io_channel_unref( irc->io_channel ); 225 232 irc_connection_list = g_slist_remove( irc_connection_list, irc ); 226 233 … … 272 279 if(user->host!=user->nick) g_free(user->host); 273 280 if(user->realname!=user->nick) g_free(user->realname); 274 b_event_remove(user->sendbuf_timer);281 gaim_input_remove(user->sendbuf_timer); 275 282 276 283 usertmp = user; … … 322 329 323 330 if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON ) 324 b_main_quit();331 g_main_quit( global.loop ); 325 332 } 326 333 … … 550 557 551 558 u = user_find( irc, irc->mynick ); 552 i f( u ) is_private = u->is_private;559 is_private = u->is_private; 553 560 554 561 va_start( params, format ); … … 576 583 char line[IRC_MAX_LINE+1], *cs; 577 584 578 /* Don't try to write anything new anymore when shutting down. */ 579 if( irc->status == USTATUS_SHUTDOWN ) 585 if( irc->quit ) 580 586 return; 581 587 … … 594 600 strcat( line, "\r\n" ); 595 601 596 if( irc->sendbuffer != NULL ) 597 { 602 if( irc->sendbuffer != NULL ) { 598 603 size = strlen( irc->sendbuffer ) + strlen( line ); 599 604 irc->sendbuffer = g_renew ( char, irc->sendbuffer, size + 1 ); 600 605 strcpy( ( irc->sendbuffer + strlen( irc->sendbuffer ) ), line ); 601 606 } 602 else 603 { 604 irc->sendbuffer = g_strdup(line); 605 } 607 else 608 irc->sendbuffer = g_strdup(line); 606 609 607 610 if( irc->w_watch_source_id == 0 ) 608 611 { 609 /* If the buffer is empty we can probably write, so call the write event handler 610 immediately. If it returns TRUE, it should be called again, so add the event to 611 the queue. If it's FALSE, we emptied the buffer and saved ourselves some work 612 in the event queue. */ 613 if( bitlbee_io_current_client_write( irc, irc->fd, GAIM_INPUT_WRITE ) ) 614 irc->w_watch_source_id = b_input_add( irc->fd, GAIM_INPUT_WRITE, bitlbee_io_current_client_write, irc ); 612 irc->w_watch_source_id = g_io_add_watch( irc->io_channel, G_IO_OUT, bitlbee_io_current_client_write, irc ); 615 613 } 616 614 … … 638 636 if( now ) 639 637 { 640 bitlbee_io_current_client_write( irc , irc->fd, GAIM_INPUT_WRITE);638 bitlbee_io_current_client_write( irc->io_channel, G_IO_OUT, irc ); 641 639 } 642 640 temp = temp->next; … … 1019 1017 } 1020 1018 1021 static gboolean buddy_send_handler_delayed( gpointer data, gint fd, b_input_condition cond)1019 gboolean buddy_send_handler_delayed( gpointer data ) 1022 1020 { 1023 1021 user_t *u = data; … … 1032 1030 u->sendbuf_flags = 0; 1033 1031 1034 return FALSE;1032 return( FALSE ); 1035 1033 } 1036 1034 … … 1046 1044 { 1047 1045 //Flush the buffer 1048 b_event_remove( u->sendbuf_timer );1049 buddy_send_handler_delayed( u , -1, 0);1046 g_source_remove( u->sendbuf_timer ); 1047 buddy_send_handler_delayed( u ); 1050 1048 } 1051 1049 … … 1071 1069 1072 1070 if( u->sendbuf_timer > 0 ) 1073 b_event_remove( u->sendbuf_timer );1074 u->sendbuf_timer = b_timeout_add( delay, buddy_send_handler_delayed, u );1071 g_source_remove( u->sendbuf_timer ); 1072 u->sendbuf_timer = g_timeout_add( delay, buddy_send_handler_delayed, u ); 1075 1073 } 1076 1074 else … … 1156 1154 pongs from the user. When not connected yet, we don't ping but drop the 1157 1155 connection when the user fails to connect in IRC_LOGIN_TIMEOUT secs. */ 1158 static gboolean irc_userping( gpointer _irc , gint fd, b_input_condition cond)1156 static gboolean irc_userping( gpointer _irc ) 1159 1157 { 1160 1158 irc_t *irc = _irc;
Note: See TracChangeset
for help on using the changeset viewer.