Changes in / [c53911e:68b518d6]
- Files:
-
- 3 added
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
rc53911e r68b518d6 34 34 #include <errno.h> 35 35 36 gboolean bitlbee_io_new_client( GIOChannel *source, GIOCondition condition, gpointer data);36 static gboolean bitlbee_io_new_client( gpointer data, gint fd, b_input_condition condition ); 37 37 38 38 int bitlbee_daemon_init() … … 44 44 #endif 45 45 int i; 46 GIOChannel *ch;47 46 FILE *fp; 48 47 … … 91 90 } 92 91 93 ch = g_io_channel_unix_new( global.listen_socket ); 94 global.listen_watch_source_id = g_io_add_watch( ch, G_IO_IN, bitlbee_io_new_client, NULL ); 92 global.listen_watch_source_id = b_input_add( global.listen_socket, GAIM_INPUT_READ, bitlbee_io_new_client, NULL ); 95 93 96 94 #ifndef _WIN32 … … 147 145 } 148 146 149 gboolean bitlbee_io_current_client_read( GIOChannel *source, GIOCondition condition, gpointer data)147 gboolean bitlbee_io_current_client_read( gpointer data, gint fd, b_input_condition cond ) 150 148 { 151 149 irc_t *irc = data; … … 153 151 int st; 154 152 155 if( condition & G_IO_ERR || condition & G_IO_HUP )156 {157 irc_abort( irc, 1, "Read error" );158 return FALSE;159 }160 161 153 st = read( irc->fd, line, sizeof( line ) - 1 ); 162 154 if( st == 0 ) … … 194 186 if( !g_slist_find( irc_connection_list, irc ) ) 195 187 { 196 log_message( LOGLVL_WARNING, "Abnormal termination of connection with fd %d.", irc->fd );188 log_message( LOGLVL_WARNING, "Abnormal termination of connection with fd %d.", fd ); 197 189 return FALSE; 198 190 } … … 208 200 } 209 201 210 gboolean bitlbee_io_current_client_write( GIOChannel *source, GIOCondition condition, gpointer data)202 gboolean bitlbee_io_current_client_write( gpointer data, gint fd, b_input_condition cond ) 211 203 { 212 204 irc_t *irc = data; … … 215 207 216 208 if( irc->sendbuffer == NULL ) 217 return ( FALSE );209 return FALSE; 218 210 219 211 size = strlen( irc->sendbuffer ); … … 239 231 irc_free( irc ); 240 232 241 return ( FALSE );233 return FALSE; 242 234 } 243 235 else … … 247 239 irc->sendbuffer = temp; 248 240 249 return ( TRUE );250 } 251 } 252 253 gboolean bitlbee_io_new_client( GIOChannel *source, GIOCondition condition, gpointer data)254 { 255 s ize_t size = sizeof( struct sockaddr_in );241 return TRUE; 242 } 243 } 244 245 static gboolean bitlbee_io_new_client( gpointer data, gint fd, b_input_condition condition ) 246 { 247 socklen_t size = sizeof( struct sockaddr_in ); 256 248 struct sockaddr_in conn_info; 257 249 int new_socket = accept( global.listen_socket, (struct sockaddr *) &conn_info, &size ); … … 286 278 child->pid = client_pid; 287 279 child->ipc_fd = fds[0]; 288 child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );280 child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child ); 289 281 child_list = g_slist_append( child_list, child ); 290 282 … … 301 293 /* Close the listening socket, we're a client. */ 302 294 close( global.listen_socket ); 303 g_source_remove( global.listen_watch_source_id );295 b_event_remove( global.listen_watch_source_id ); 304 296 305 297 /* Make the connection. */ … … 308 300 /* We can store the IPC fd there now. */ 309 301 global.listen_socket = fds[1]; 310 global.listen_watch_source_id = gaim_input_add( fds[1], GAIM_INPUT_READ, ipc_child_read, irc );302 global.listen_watch_source_id = b_input_add( fds[1], GAIM_INPUT_READ, ipc_child_read, irc ); 311 303 312 304 close( fds[0] ); … … 324 316 } 325 317 326 void bitlbee_shutdown( gpointer data)318 gboolean bitlbee_shutdown( gpointer data, gint fd, b_input_condition cond ) 327 319 { 328 320 /* Try to save data for all active connections (if desired). */ … … 331 323 332 324 /* We'll only reach this point when not running in inetd mode: */ 333 g_main_quit( global.loop ); 334 } 325 b_main_quit(); 326 327 return FALSE; 328 } -
bitlbee.h
rc53911e r68b518d6 58 58 /* The following functions should not be used if we want to maintain Windows compatibility... */ 59 59 #undef free 60 #define free __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM_ INSTEAD__60 #define free __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM__ 61 61 #undef malloc 62 #define malloc __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM_ INSTEAD__62 #define malloc __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM__ 63 63 #undef calloc 64 #define calloc __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM_ INSTEAD__64 #define calloc __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM__ 65 65 #undef realloc 66 #define realloc __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM_ INSTEAD__66 #define realloc __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM__ 67 67 #undef strdup 68 #define strdup __PLEASE_USE_THE_GLIB_STRDUP_FUNCTIONS_SYSTEM_ INSTEAD__68 #define strdup __PLEASE_USE_THE_GLIB_STRDUP_FUNCTIONS_SYSTEM__ 69 69 #undef strndup 70 #define strndup __PLEASE_USE_THE_GLIB_STRDUP_FUNCTIONS_SYSTEM_ INSTEAD__70 #define strndup __PLEASE_USE_THE_GLIB_STRDUP_FUNCTIONS_SYSTEM__ 71 71 #undef snprintf 72 #define snprintf __PLEASE_USE_G_SNPRINTF_ INSTEAD__72 #define snprintf __PLEASE_USE_G_SNPRINTF__ 73 73 #undef strcasecmp 74 #define strcasecmp __PLEASE_USE_G_STRCASECMP_ INSTEAD__74 #define strcasecmp __PLEASE_USE_G_STRCASECMP__ 75 75 #undef strncasecmp 76 #define strncasecmp __PLEASE_USE_G_STRNCASECMP_INSTEAD__ 76 #define strncasecmp __PLEASE_USE_G_STRNCASECMP__ 77 78 /* And the following functions shouldn't be used anymore to keep compatibility 79 with other event handling libs than GLib. */ 80 #undef g_timeout_add 81 #define g_timeout_add __PLEASE_USE_B_TIMEOUT_ADD__ 82 #undef g_timeout_add_full 83 #define g_timeout_add_full __PLEASE_USE_B_TIMEOUT_ADD__ 84 #undef g_io_add_watch 85 #define g_io_add_watch __PLEASE_USE_B_INPUT_ADD__ 86 #undef g_io_add_watch_full 87 #define g_io_add_watch_full __PLEASE_USE_B_INPUT_ADD__ 88 #undef g_source_remove 89 #define g_source_remove __PLEASE_USE_B_EVENT_REMOVE__ 90 #undef g_source_remove_by_user_data 91 #define g_source_remove_by_user_data __PLEASE_USE_B_SOURCE_REMOVE_BY_USER_DATA__ 92 #undef g_main_run 93 #define g_main_run __PLEASE_USE_B_MAIN_RUN__ 94 #undef g_main_quit 95 #define g_main_quit __PLEASE_USE_B_MAIN_QUIT__ 77 96 78 97 #ifndef F_OK … … 112 131 #include "sock.h" 113 132 #include "util.h" 133 #include "proxy.h" 114 134 115 135 typedef struct global { … … 121 141 GList *storage; /* The first backend in the list will be used for saving */ 122 142 char *helpfile; 123 GMainLoop *loop;124 143 int restart; 125 144 } global_t; … … 128 147 int bitlbee_inetd_init( void ); 129 148 130 gboolean bitlbee_io_current_client_read( GIOChannel *source, GIOCondition condition, gpointer data);131 gboolean bitlbee_io_current_client_write( GIOChannel *source, GIOCondition condition, gpointer data);149 gboolean bitlbee_io_current_client_read( gpointer data, gint source, b_input_condition cond ); 150 gboolean bitlbee_io_current_client_write( gpointer data, gint source, b_input_condition cond ); 132 151 133 152 void root_command_string( irc_t *irc, user_t *u, char *command, int flags ); 134 153 void root_command( irc_t *irc, char *command[] ); 135 void bitlbee_shutdown( gpointer data);154 gboolean bitlbee_shutdown( gpointer data, gint fd, b_input_condition cond ); 136 155 137 156 extern global_t global; -
configure
rc53911e r68b518d6 14 14 datadir='$prefix/share/bitlbee/' 15 15 config='/var/lib/bitlbee/' 16 plugindir='$prefix/lib/bitlbee/' 17 includedir='$prefix/include/bitlbee/' 18 libevent='/usr/' 16 19 pidfile='/var/run/bitlbee.pid' 17 20 ipcsocket='/var/run/bitlbee' 18 plugindir='$prefix/lib/bitlbee'19 21 pcdir='$prefix/lib/pkgconfig' 20 includedir='$prefix/include/bitlbee'21 22 22 23 msn=1 … … 28 29 strip=1 29 30 ipv6=1 31 32 events=glib 30 33 ssl=auto 31 34 … … 64 67 --ipv6=0/1 IPv6 socket support $ipv6 65 68 69 --events=... Event handler (glib, libevent) $events 66 70 --ssl=... SSL library to use (gnutls, nss, openssl, bogus, auto) 67 71 $ssl … … 80 84 config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'` 81 85 plugindir=`eval echo "$plugindir/" | sed 's/\/\{1,\}/\//g'` 86 includedir=`eval echo "$includedir"/ | sed 's/\/\{1,\}/\//g'` 87 libevent=`eval echo "$libevent"/ | sed 's/\/\{1,\}/\//g'` 88 82 89 pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'` 83 90 ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'` 84 includedir=`eval echo "$includedir" | sed 's/\/\{1,\}/\//g'`85 91 pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'` 86 92 … … 163 169 fi 164 170 171 GLIB=0 172 165 173 if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then 166 174 cat<<EOF>>Makefile.settings … … 169 177 EOF 170 178 echo '#define GLIB2' >> config.h 179 GLIB=2 171 180 elif type glib-config > /dev/null 2> /dev/null; then 172 181 cat<<EOF>>Makefile.settings … … 175 184 EOF 176 185 echo '#define GLIB1' >> config.h 186 GLIB=1 177 187 else 178 188 echo 'Cannot find glib development libraries, aborting. (Install libglib-dev?)' … … 180 190 fi 181 191 182 if [ -r /usr/include/iconv.h ]; then192 if [ GLIB = 1 -o -r /usr/include/iconv.h ]; then 183 193 :; 184 194 elif [ -r /usr/local/include/iconv.h ]; then 185 echo CFLAGS+=-I/usr/local/include >> Makefile.settings ;195 echo CFLAGS+=-I/usr/local/include >> Makefile.settings 186 196 else 187 197 echo 188 198 echo 'Warning: Could not find iconv.h, you might have to install it and/or modify' 189 echo 'Makefile.settings to tell where this file is.'; 190 fi 199 echo 'Makefile.settings to tell where this file is.' 200 fi 201 202 203 if [ "$events" = "libevent" ]; then 204 if ! [ -e "${libevent}include/event.h" ]; then 205 echo 206 echo 'Warning: Could not find event.h, you might have to install it and/or specify' 207 echo 'its location using the --libevent= argument. (Example: If event.h is in' 208 echo '/usr/local/include and binaries are in /usr/local/lib: --libevent=/usr/local)' 209 fi 210 211 echo '#define EVENTS_LIBEVENT' >> config.h 212 cat <<EOF>>Makefile.settings 213 EFLAGS+=-levent -L${libevent}lib 214 CFLAGS+=-I${libevent}include 215 EOF 216 elif [ "$events" = "glib" ]; then 217 ## We already use glib anyway, so this is all we need (and in fact not even this, but just to be sure...): 218 echo '#define EVENTS_GLIB' >> config.h 219 else 220 echo 221 echo 'ERROR: Unknown event handler specified.' 222 exit 1 223 fi 224 echo 'EVENT_HANDLER=events_'$events'.o' >> Makefile.settings 191 225 192 226 … … 422 456 fi 423 457 424 if [ "$msn" = "1" ]; then 425 echo ' Using SSL library: '$ssl; 426 fi 458 echo ' Using event handler: '$events; 459 echo ' Using SSL library: '$ssl; 427 460 428 461 #if [ "$flood" = "0" ]; then -
ipc.c
rc53911e r68b518d6 60 60 ipc_to_children_str( "DIE\r\n" ); 61 61 62 bitlbee_shutdown( NULL );62 bitlbee_shutdown( NULL, -1, 0 ); 63 63 } 64 64 … … 91 91 92 92 global.restart = -1; 93 bitlbee_shutdown( NULL );93 bitlbee_shutdown( NULL, -1, 0 ); 94 94 } 95 95 … … 246 246 } 247 247 248 void ipc_master_read( gpointer data, gint source, GaimInputCondition cond )248 gboolean ipc_master_read( gpointer data, gint source, b_input_condition cond ) 249 249 { 250 250 char *buf, **cmd; … … 272 272 } 273 273 } 274 } 275 276 void ipc_child_read( gpointer data, gint source, GaimInputCondition cond ) 274 275 return TRUE; 276 } 277 278 gboolean ipc_child_read( gpointer data, gint source, b_input_condition cond ) 277 279 { 278 280 char *buf, **cmd; … … 286 288 else 287 289 { 288 gaim_input_remove( global.listen_watch_source_id );290 b_event_remove( global.listen_watch_source_id ); 289 291 close( global.listen_socket ); 290 292 291 293 global.listen_socket = -1; 292 294 } 295 296 return TRUE; 293 297 } 294 298 … … 397 401 void ipc_master_free_one( struct bitlbee_child *c ) 398 402 { 399 gaim_input_remove( c->ipc_inpa );403 b_event_remove( c->ipc_inpa ); 400 404 closesocket( c->ipc_fd ); 401 405 … … 463 467 464 468 465 static gboolean new_ipc_client (GIOChannel *gio, GIOCondition cond, gpointer data)469 static gboolean new_ipc_client( gpointer data, gint serversock, b_input_condition cond ) 466 470 { 467 471 struct bitlbee_child *child = g_new0( struct bitlbee_child, 1 ); 468 int serversock; 469 470 serversock = g_io_channel_unix_get_fd(gio); 471 472 child->ipc_fd = accept(serversock, NULL, 0); 473 474 if (child->ipc_fd == -1) { 472 473 child->ipc_fd = accept( serversock, NULL, 0 ); 474 475 if( child->ipc_fd == -1 ) 476 { 475 477 log_message( LOGLVL_WARNING, "Unable to accept connection on UNIX domain socket: %s", strerror(errno) ); 476 478 return TRUE; 477 479 } 478 480 479 child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );480 481 child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child ); 482 481 483 child_list = g_slist_append( child_list, child ); 482 484 483 485 return TRUE; 484 486 } … … 489 491 struct sockaddr_un un_addr; 490 492 int serversock; 491 GIOChannel *gio;492 493 493 494 /* Clean up old socket files that were hanging around.. */ … … 517 518 } 518 519 519 gio = g_io_channel_unix_new(serversock); 520 521 if (gio == NULL) { 522 log_message( LOGLVL_WARNING, "Unable to create IO channel for unix socket" ); 523 return 0; 524 } 525 526 g_io_add_watch(gio, G_IO_IN, new_ipc_client, NULL); 520 b_input_add( serversock, GAIM_INPUT_READ, new_ipc_client, NULL ); 521 527 522 return 1; 528 523 } … … 563 558 return 0; 564 559 } 565 child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );560 child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child ); 566 561 567 562 child_list = g_slist_append( child_list, child ); -
ipc.h
rc53911e r68b518d6 40 40 41 41 42 void ipc_master_read( gpointer data, gint source, GaimInputCondition cond );43 void ipc_child_read( gpointer data, gint source, GaimInputCondition cond );42 gboolean ipc_master_read( gpointer data, gint source, b_input_condition cond ); 43 gboolean ipc_child_read( gpointer data, gint source, b_input_condition cond ); 44 44 45 45 void ipc_master_free_one( struct bitlbee_child *child ); … … 47 47 48 48 void ipc_to_master( char **cmd ); 49 void ipc_to_master_str( char *format, ... ) ;49 void ipc_to_master_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 ); 50 50 void ipc_to_children( char **cmd ); 51 void ipc_to_children_str( char *format, ... ) ;51 void ipc_to_children_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 ); 52 52 53 53 /* We need this function in inetd mode, so let's just make it non-static. */ -
irc.c
rc53911e r68b518d6 29 29 #include "ipc.h" 30 30 31 static gboolean irc_userping( gpointer _irc );31 static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond ); 32 32 33 33 GSList *irc_connection_list = NULL; … … 54 54 55 55 irc->fd = fd; 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 ); 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 ); 65 59 66 60 irc->status = USTATUS_OFFLINE; … … 120 114 121 115 if( global.conf->ping_interval > 0 && global.conf->ping_timeout > 0 ) 122 irc->ping_source_id = g_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc );116 irc->ping_source_id = b_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc ); 123 117 124 118 irc_write( irc, ":%s NOTICE AUTH :%s", irc->myhost, "BitlBee-IRCd initialized, please go on" ); … … 190 184 bitlbee_.._write doesn't do it first. */ 191 185 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);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 ); 194 188 } 195 189 else … … 224 218 225 219 if( irc->ping_source_id > 0 ) 226 g_source_remove( irc->ping_source_id );227 g_source_remove( irc->r_watch_source_id );220 b_event_remove( irc->ping_source_id ); 221 b_event_remove( irc->r_watch_source_id ); 228 222 if( irc->w_watch_source_id > 0 ) 229 g_source_remove( irc->w_watch_source_id ); 230 231 g_io_channel_unref( irc->io_channel ); 223 b_event_remove( irc->w_watch_source_id ); 224 232 225 irc_connection_list = g_slist_remove( irc_connection_list, irc ); 233 226 … … 279 272 if(user->host!=user->nick) g_free(user->host); 280 273 if(user->realname!=user->nick) g_free(user->realname); 281 gaim_input_remove(user->sendbuf_timer);274 b_event_remove(user->sendbuf_timer); 282 275 283 276 usertmp = user; … … 329 322 330 323 if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON ) 331 g_main_quit( global.loop);324 b_main_quit(); 332 325 } 333 326 … … 583 576 char line[IRC_MAX_LINE+1], *cs; 584 577 585 if( irc->quit ) 578 /* Don't try to write anything new anymore when shutting down. */ 579 if( irc->status == USTATUS_SHUTDOWN ) 586 580 return; 587 581 … … 600 594 strcat( line, "\r\n" ); 601 595 602 if( irc->sendbuffer != NULL ) { 596 if( irc->sendbuffer != NULL ) 597 { 603 598 size = strlen( irc->sendbuffer ) + strlen( line ); 604 599 irc->sendbuffer = g_renew ( char, irc->sendbuffer, size + 1 ); 605 600 strcpy( ( irc->sendbuffer + strlen( irc->sendbuffer ) ), line ); 606 601 } 607 else 608 irc->sendbuffer = g_strdup(line); 602 else 603 { 604 irc->sendbuffer = g_strdup(line); 605 } 609 606 610 607 if( irc->w_watch_source_id == 0 ) 611 608 { 612 irc->w_watch_source_id = g_io_add_watch( irc->io_channel, G_IO_OUT, bitlbee_io_current_client_write, irc ); 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 ); 613 615 } 614 616 … … 636 638 if( now ) 637 639 { 638 bitlbee_io_current_client_write( irc ->io_channel, G_IO_OUT, irc);640 bitlbee_io_current_client_write( irc, irc->fd, GAIM_INPUT_WRITE ); 639 641 } 640 642 temp = temp->next; … … 830 832 irc_reply( irc, 332, "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", channel, c->title ); 831 833 else 832 irc_reply( irc, 331, "%s :No topic for this channel" );834 irc_reply( irc, 331, "%s :No topic for this channel", channel ); 833 835 } 834 836 } … … 886 888 if( g_hash_table_lookup( irc->watches, nick ) ) 887 889 { 888 irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged online" );890 irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged online" ); 889 891 } 890 892 g_free( nick ); … … 911 913 if( g_hash_table_lookup( irc->watches, nick ) ) 912 914 { 913 irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged offline" );915 irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged offline" ); 914 916 } 915 917 g_free( nick ); … … 1011 1013 else if( c && c->gc && c->gc->prpl ) 1012 1014 { 1013 return( serv_send_chat( irc,c->gc, c->id, s ) );1015 return( bim_chat_msg( c->gc, c->id, s ) ); 1014 1016 } 1015 1017 … … 1017 1019 } 1018 1020 1019 gboolean buddy_send_handler_delayed( gpointer data)1021 static gboolean buddy_send_handler_delayed( gpointer data, gint fd, b_input_condition cond ) 1020 1022 { 1021 1023 user_t *u = data; 1022 1024 1025 /* Shouldn't happen, but just to be sure. */ 1026 if( u->sendbuf_len < 2 ) 1027 return FALSE; 1028 1023 1029 u->sendbuf[u->sendbuf_len-2] = 0; /* Cut off the last newline */ 1024 serv_send_im( u->gc->irc, u, u->sendbuf, u->sendbuf_flags );1030 bim_buddy_msg( u->gc, u->handle, u->sendbuf, u->sendbuf_flags ); 1025 1031 1026 1032 g_free( u->sendbuf ); … … 1030 1036 u->sendbuf_flags = 0; 1031 1037 1032 return ( FALSE );1038 return FALSE; 1033 1039 } 1034 1040 … … 1043 1049 if( u->sendbuf_len > 0 && u->sendbuf_flags != flags) 1044 1050 { 1045 / /Flush the buffer1046 g_source_remove( u->sendbuf_timer );1047 buddy_send_handler_delayed( u );1051 /* Flush the buffer */ 1052 b_event_remove( u->sendbuf_timer ); 1053 buddy_send_handler_delayed( u, -1, 0 ); 1048 1054 } 1049 1055 … … 1051 1057 { 1052 1058 u->sendbuf_len = strlen( msg ) + 2; 1053 u->sendbuf = g_new (char, u->sendbuf_len );1059 u->sendbuf = g_new( char, u->sendbuf_len ); 1054 1060 u->sendbuf[0] = 0; 1055 1061 u->sendbuf_flags = flags; … … 1058 1064 { 1059 1065 u->sendbuf_len += strlen( msg ) + 1; 1060 u->sendbuf = g_renew 1066 u->sendbuf = g_renew( char, u->sendbuf, u->sendbuf_len ); 1061 1067 } 1062 1068 … … 1069 1075 1070 1076 if( u->sendbuf_timer > 0 ) 1071 g_source_remove( u->sendbuf_timer );1072 u->sendbuf_timer = g_timeout_add( delay, buddy_send_handler_delayed, u );1077 b_event_remove( u->sendbuf_timer ); 1078 u->sendbuf_timer = b_timeout_add( delay, buddy_send_handler_delayed, u ); 1073 1079 } 1074 1080 else 1075 1081 { 1076 serv_send_im( irc, u, msg, flags );1082 bim_buddy_msg( u->gc, u->handle, msg, flags ); 1077 1083 } 1078 1084 } … … 1154 1160 pongs from the user. When not connected yet, we don't ping but drop the 1155 1161 connection when the user fails to connect in IRC_LOGIN_TIMEOUT secs. */ 1156 static gboolean irc_userping( gpointer _irc )1162 static gboolean irc_userping( gpointer _irc, gint fd, b_input_condition cond ) 1157 1163 { 1158 1164 irc_t *irc = _irc; -
irc.h
rc53911e r68b518d6 61 61 char *sendbuffer; 62 62 char *readbuffer; 63 int quit;64 63 65 64 int sentbytes; … … 93 92 struct set *set; 94 93 95 GIOChannel *io_channel;96 94 gint r_watch_source_id; 97 95 gint w_watch_source_id; … … 105 103 106 104 irc_t *irc_new( int fd ); 107 void irc_abort( irc_t *irc, int immed, char *format, ... ) ;105 void irc_abort( irc_t *irc, int immed, char *format, ... ) G_GNUC_PRINTF( 3, 4 ); 108 106 void irc_free( irc_t *irc ); 109 107 … … 114 112 115 113 void irc_vawrite( irc_t *irc, char *format, va_list params ); 116 void irc_write( irc_t *irc, char *format, ... ) ;117 void irc_write_all( int now, char *format, ... ) ;118 void irc_reply( irc_t *irc, int code, char *format, ... ) ;119 G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... ) ;114 void irc_write( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 115 void irc_write_all( int now, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 116 void irc_reply( irc_t *irc, int code, char *format, ... ) G_GNUC_PRINTF( 3, 4 ); 117 G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 120 118 char **irc_tokenize( char *buffer ); 121 119 -
irc_commands.c
rc53911e r68b518d6 385 385 386 386 if( u && u->online ) 387 irc_reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "is online" );387 irc_reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "is online" ); 388 388 else 389 irc_reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", time( NULL ), "is offline" );389 irc_reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", (int) time( NULL ), "is offline" ); 390 390 } 391 391 else if( cmd[i][0] == '-' ) … … 448 448 449 449 if( gc && gc->flags & OPT_LOGGED_IN ) 450 proto_away( gc, u->away );450 bim_set_away( gc, u->away ); 451 451 } 452 452 } -
log.h
rc53911e r68b518d6 54 54 void log_init(void); 55 55 void log_link(int level, int output); 56 void log_message(int level, char *message, ...) ;56 void log_message(int level, char *message, ...) G_GNUC_PRINTF( 2, 3 ); 57 57 void log_error(char *functionname); 58 58 -
protocols/Makefile
rc53911e r68b518d6 10 10 11 11 # [SH] Program variables 12 objects = http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT)12 objects = $(EVENT_HANDLER) http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT) 13 13 14 14 # [SH] The next two lines should contain the directory name (in $(subdirs)) -
protocols/http_client.c
rc53911e r68b518d6 32 32 33 33 34 static void http_connected( gpointer data, int source, GaimInputCondition cond );35 static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond );36 static void http_incoming_data( gpointer data, int source, GaimInputCondition cond );34 static gboolean http_connected( gpointer data, int source, b_input_condition cond ); 35 static gboolean http_ssl_connected( gpointer data, void *source, b_input_condition cond ); 36 static gboolean http_incoming_data( gpointer data, int source, b_input_condition cond ); 37 37 38 38 … … 104 104 /* This one is actually pretty simple... Might get more calls if we can't write 105 105 the whole request at once. */ 106 static void http_connected( gpointer data, int source, GaimInputCondition cond )106 static gboolean http_connected( gpointer data, int source, b_input_condition cond ) 107 107 { 108 108 struct http_request *req = data; … … 113 113 114 114 if( req->inpa > 0 ) 115 gaim_input_remove( req->inpa );115 b_event_remove( req->inpa ); 116 116 117 117 sock_make_nonblocking( req->fd ); … … 148 148 149 149 if( req->bytes_written < req->request_length ) 150 req->inpa = gaim_input_add( source,151 152 153 else 154 req->inpa = gaim_input_add( source, GAIM_INPUT_READ, http_incoming_data, req );155 156 return ;150 req->inpa = b_input_add( source, 151 req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_WRITE, 152 http_connected, req ); 153 else 154 req->inpa = b_input_add( source, GAIM_INPUT_READ, http_incoming_data, req ); 155 156 return FALSE; 157 157 158 158 error: … … 162 162 g_free( req ); 163 163 164 return ;164 return FALSE; 165 165 } 166 166 167 static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond )167 static gboolean http_ssl_connected( gpointer data, void *source, b_input_condition cond ) 168 168 { 169 169 struct http_request *req = data; … … 177 177 } 178 178 179 static void http_incoming_data( gpointer data, int source, GaimInputCondition cond )179 static gboolean http_incoming_data( gpointer data, int source, b_input_condition cond ) 180 180 { 181 181 struct http_request *req = data; … … 186 186 187 187 if( req->inpa > 0 ) 188 gaim_input_remove( req->inpa );188 b_event_remove( req->inpa ); 189 189 190 190 if( req->ssl ) … … 233 233 234 234 /* There will be more! */ 235 req->inpa = gaim_input_add( req->fd,236 237 238 239 return ;235 req->inpa = b_input_add( req->fd, 236 req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_READ, 237 http_incoming_data, req ); 238 239 return FALSE; 240 240 241 241 got_reply: 242 /* Maybe if the webserver is overloaded, or when there's bad SSL 243 support... */ 244 if( req->bytes_read == 0 ) 245 goto cleanup; 246 242 247 /* Zero termination is very convenient. */ 243 248 req->reply_headers[req->bytes_read] = 0; … … 396 401 req->reply_headers = req->reply_body = NULL; 397 402 398 return ;403 return FALSE; 399 404 } 400 405 … … 414 419 g_free( req->reply_headers ); 415 420 g_free( req ); 421 422 return FALSE; 416 423 } -
protocols/jabber/jabber.c
rc53911e r68b518d6 471 471 } 472 472 473 static void jabber_callback(gpointer data, gint source, GaimInputCondition condition)473 static gboolean jabber_callback(gpointer data, gint source, b_input_condition condition) 474 474 { 475 475 struct gaim_connection *gc = (struct gaim_connection *)data; … … 477 477 478 478 gjab_recv(jd->gjc); 479 480 return TRUE; 479 481 } 480 482 … … 487 489 } 488 490 489 static void gjab_connected(gpointer data, gint source, GaimInputCondition cond)491 static gboolean gjab_connected(gpointer data, gint source, b_input_condition cond) 490 492 { 491 493 xmlnode x; … … 497 499 if (!g_slist_find(get_connections(), gc)) { 498 500 closesocket(source); 499 return ;501 return FALSE; 500 502 } 501 503 … … 508 510 if (source == -1) { 509 511 STATE_EVT(JCONN_STATE_OFF) 510 return ;512 return FALSE; 511 513 } 512 514 … … 530 532 531 533 gc = GJ_GC(gjc); 532 gc->inpa = gaim_input_add(gjc->fd, GAIM_INPUT_READ, jabber_callback, gc); 533 } 534 535 static void gjab_connected_ssl(gpointer data, void *source, GaimInputCondition cond) 534 gc->inpa = b_input_add(gjc->fd, GAIM_INPUT_READ, jabber_callback, gc); 535 536 return FALSE; 537 } 538 539 static gboolean gjab_connected_ssl(gpointer data, void *source, b_input_condition cond) 536 540 { 537 541 struct gaim_connection *gc = data; … … 544 548 if (source == NULL) { 545 549 STATE_EVT(JCONN_STATE_OFF) 546 return ;550 return FALSE; 547 551 } 548 552 549 553 if (!g_slist_find(get_connections(), gc)) { 550 554 ssl_disconnect(source); 551 return ;555 return FALSE; 552 556 } 553 557 554 gjab_connected(data, gjc->fd, cond);558 return gjab_connected(data, gjc->fd, cond); 555 559 } 556 560 … … 1543 1547 } 1544 1548 1545 static gboolean jabber_free(gpointer data )1549 static gboolean jabber_free(gpointer data, gint fd, b_input_condition cond) 1546 1550 { 1547 1551 struct jabber_data *jd = data; … … 1588 1592 } 1589 1593 if (gc->inpa) 1590 gaim_input_remove(gc->inpa);1594 b_event_remove(gc->inpa); 1591 1595 1592 1596 if(jd) { 1593 g_timeout_add(50, jabber_free, jd);1597 b_timeout_add(50, jabber_free, jd); 1594 1598 if(jd->gjc != NULL) 1595 1599 xmlnode_free(jd->gjc->current); -
protocols/msn/msn.h
rc53911e r68b518d6 146 146 147 147 /* ns.c */ 148 void msn_ns_connected( gpointer data, gint source, GaimInputCondition cond );148 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ); 149 149 150 150 /* msn_util.c */ … … 173 173 void msn_sb_to_chat( struct msn_switchboard *sb ); 174 174 void msn_sb_destroy( struct msn_switchboard *sb ); 175 void msn_sb_connected( gpointer data, gint source, GaimInputCondition cond );175 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); -
protocols/msn/ns.c
rc53911e r68b518d6 30 30 #include "md5.h" 31 31 32 static void msn_ns_callback( gpointer data, gint source, GaimInputCondition cond );32 static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond ); 33 33 static int msn_ns_command( gpointer data, char **cmd, int num_parts ); 34 34 static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts ); … … 36 36 static void msn_auth_got_passport_id( struct passport_reply *rep ); 37 37 38 void msn_ns_connected( gpointer data, gint source, GaimInputCondition cond )38 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond ) 39 39 { 40 40 struct gaim_connection *gc = data; … … 43 43 44 44 if( !g_slist_find( msn_connections, gc ) ) 45 return ;45 return FALSE; 46 46 47 47 if( source == -1 ) … … 49 49 hide_login_progress( gc, "Could not connect to server" ); 50 50 signoff( gc ); 51 return ;51 return FALSE; 52 52 } 53 53 … … 75 75 if( msn_write( gc, s, strlen( s ) ) ) 76 76 { 77 gc->inpa = gaim_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, gc );77 gc->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, gc ); 78 78 set_login_progress( gc, 1, "Connected to server, waiting for reply" ); 79 79 } 80 81 return FALSE; 80 82 } 81 83 82 void msn_ns_callback( gpointer data, gint source, GaimInputCondition cond )84 static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond ) 83 85 { 84 86 struct gaim_connection *gc = data; … … 89 91 hide_login_progress( gc, "Error while reading from server" ); 90 92 signoff( gc ); 91 } 93 94 return FALSE; 95 } 96 else 97 return TRUE; 92 98 } 93 99 … … 130 136 if( num_parts == 6 && strcmp( cmd[2], "NS" ) == 0 ) 131 137 { 132 gaim_input_remove( gc->inpa );138 b_event_remove( gc->inpa ); 133 139 gc->inpa = 0; 134 140 closesocket( md->fd ); -
protocols/msn/sb.c
rc53911e r68b518d6 30 30 #include "md5.h" 31 31 32 static void msn_sb_callback( gpointer data, gint source, GaimInputCondition cond );32 static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond ); 33 33 static int msn_sb_command( gpointer data, char **cmd, int num_parts ); 34 34 static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts ); … … 237 237 } 238 238 239 if( sb->inp ) gaim_input_remove( sb->inp );239 if( sb->inp ) b_event_remove( sb->inp ); 240 240 closesocket( sb->fd ); 241 241 … … 245 245 } 246 246 247 void msn_sb_connected( gpointer data, gint source, GaimInputCondition cond )247 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ) 248 248 { 249 249 struct msn_switchboard *sb = data; … … 254 254 /* Are we still alive? */ 255 255 if( !g_slist_find( msn_switchboards, sb ) ) 256 return ;256 return FALSE; 257 257 258 258 gc = sb->gc; … … 263 263 debug( "ERROR %d while connecting to switchboard server", 1 ); 264 264 msn_sb_destroy( sb ); 265 return ;265 return FALSE; 266 266 } 267 267 … … 280 280 281 281 if( msn_sb_write( sb, buf, strlen( buf ) ) ) 282 sb->inp = gaim_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb );282 sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb ); 283 283 else 284 284 debug( "ERROR %d while connecting to switchboard server", 2 ); 285 } 286 287 static void msn_sb_callback( gpointer data, gint source, GaimInputCondition cond ) 285 286 return FALSE; 287 } 288 289 static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond ) 288 290 { 289 291 struct msn_switchboard *sb = data; … … 293 295 debug( "ERROR: Switchboard died" ); 294 296 msn_sb_destroy( sb ); 295 } 297 298 return FALSE; 299 } 300 else 301 return TRUE; 296 302 } 297 303 -
protocols/nogaim.c
rc53911e r68b518d6 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-200 4Wilmer van der Gaast and others *4 * Copyright 2002-2006 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 13 13 * from scratch for BitlBee and doesn't contain any code from Gaim anymore 14 14 * (except for the function names). 15 *16 * Copyright 2002-2006 Wilmer van der Gaast <wilmer@gaast.net> and others17 15 */ 18 16 … … 37 35 #include "nogaim.h" 38 36 #include <ctype.h> 39 40 static char *proto_away_alias[8][5] =41 {42 { "Away from computer", "Away", "Extended away", NULL },43 { "NA", "N/A", "Not available", NULL },44 { "Busy", "Do not disturb", "DND", "Occupied", NULL },45 { "Be right back", "BRB", NULL },46 { "On the phone", "Phone", "On phone", NULL },47 { "Out to lunch", "Lunch", "Food", NULL },48 { "Invisible", "Hidden" },49 { NULL }50 };51 static char *proto_away_alias_find( GList *gcm, char *away );52 37 53 38 static int remove_chat_buddy_silent( struct conversation *b, char *handle ); … … 158 143 GSList *get_connections() { return connections; } 159 144 160 int proto_away( struct gaim_connection *gc, char *away )161 {162 GList *m, *ms;163 char *s;164 165 if( !away ) away = "";166 ms = m = gc->prpl->away_states( gc );167 168 while( m )169 {170 if( *away )171 {172 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )173 break;174 }175 else176 {177 if( g_strcasecmp( m->data, "Available" ) == 0 )178 break;179 if( g_strcasecmp( m->data, "Online" ) == 0 )180 break;181 }182 m = m->next;183 }184 185 if( m )186 {187 gc->prpl->set_away( gc, m->data, *away ? away : NULL );188 }189 else190 {191 s = proto_away_alias_find( ms, away );192 if( s )193 {194 gc->prpl->set_away( gc, s, away );195 if( set_getint( gc->irc, "debug" ) )196 serv_got_crap( gc, "Setting away state to %s", s );197 }198 else199 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );200 }201 202 g_list_free( ms );203 204 return( 1 );205 }206 207 static char *proto_away_alias_find( GList *gcm, char *away )208 {209 GList *m;210 int i, j;211 212 for( i = 0; *proto_away_alias[i]; i ++ )213 {214 for( j = 0; proto_away_alias[i][j]; j ++ )215 if( g_strncasecmp( away, proto_away_alias[i][j], strlen( proto_away_alias[i][j] ) ) == 0 )216 break;217 218 if( !proto_away_alias[i][j] ) /* If we reach the end, this row */219 continue; /* is not what we want. Next! */220 221 /* Now find an entry in this row which exists in gcm */222 for( j = 0; proto_away_alias[i][j]; j ++ )223 {224 m = gcm;225 while( m )226 {227 if( g_strcasecmp( proto_away_alias[i][j], m->data ) == 0 )228 return( proto_away_alias[i][j] );229 m = m->next;230 }231 }232 }233 234 return( NULL );235 }236 237 145 /* multi.c */ 238 146 … … 250 158 * This fixes daemon mode breakage where IRC doesn't point to the currently active connection. 251 159 */ 252 gc->irc =user->irc;160 gc->irc = user->irc; 253 161 254 162 connections = g_slist_append( connections, gc ); … … 330 238 } 331 239 332 static gboolean send_keepalive( gpointer d )240 static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond ) 333 241 { 334 242 struct gaim_connection *gc = d; … … 354 262 serv_got_crap( gc, "Logged in" ); 355 263 356 gc->keepalive = g_timeout_add( 60000, send_keepalive, gc );264 gc->keepalive = b_timeout_add( 60000, send_keepalive, gc ); 357 265 gc->flags |= OPT_LOGGED_IN; 358 266 359 267 /* Also necessary when we're not away, at least for some of the 360 268 protocols. */ 361 proto_away( gc, u->away );362 } 363 364 gboolean auto_reconnect( gpointer data )269 bim_set_away( gc, u->away ); 270 } 271 272 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ) 365 273 { 366 274 account_t *a = data; … … 374 282 void cancel_auto_reconnect( account_t *a ) 375 283 { 376 while( g_source_remove_by_user_data( (gpointer) a ) ); 284 /* while( b_event_remove_by_data( (gpointer) a ) ); */ 285 b_event_remove( a->reconnect ); 377 286 a->reconnect = 0; 378 287 } … … 386 295 serv_got_crap( gc, "Signing off.." ); 387 296 388 gaim_input_remove( gc->keepalive );297 b_event_remove( gc->keepalive ); 389 298 gc->keepalive = 0; 390 299 gc->prpl->close( gc ); 391 gaim_input_remove( gc->inpa );300 b_event_remove( gc->inpa ); 392 301 393 302 while( u ) … … 416 325 { 417 326 int delay = set_getint( irc, "auto_reconnect_delay" ); 327 418 328 serv_got_crap( gc, "Reconnecting in %d seconds..", delay ); 419 420 a->reconnect = 1; 421 g_timeout_add( delay * 1000, auto_reconnect, a ); 329 a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a ); 422 330 } 423 331 … … 1031 939 } 1032 940 1033 int serv_send_im( irc_t *irc, user_t *u, char *msg, int flags ) 941 942 943 944 /* The plan is to not allow straight calls to prpl functions anymore, but do 945 them all from some wrappers. We'll start to define some down here: */ 946 947 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ) 1034 948 { 1035 949 char *buf = NULL; 1036 950 int st; 1037 951 1038 if( ( u->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )952 if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 1039 953 { 1040 954 buf = escape_html( msg ); … … 1042 956 } 1043 957 1044 st = ((struct gaim_connection *)u->gc)->prpl->send_im( u->gc, u->handle, msg, strlen( msg ), flags );958 st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags ); 1045 959 g_free( buf ); 1046 960 … … 1048 962 } 1049 963 1050 int serv_send_chat( irc_t *irc,struct gaim_connection *gc, int id, char *msg )964 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ) 1051 965 { 1052 966 char *buf = NULL; … … 1064 978 return st; 1065 979 } 980 981 static char *bim_away_alias_find( GList *gcm, char *away ); 982 983 int bim_set_away( struct gaim_connection *gc, char *away ) 984 { 985 GList *m, *ms; 986 char *s; 987 988 if( !away ) away = ""; 989 ms = m = gc->prpl->away_states( gc ); 990 991 while( m ) 992 { 993 if( *away ) 994 { 995 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 996 break; 997 } 998 else 999 { 1000 if( g_strcasecmp( m->data, "Available" ) == 0 ) 1001 break; 1002 if( g_strcasecmp( m->data, "Online" ) == 0 ) 1003 break; 1004 } 1005 m = m->next; 1006 } 1007 1008 if( m ) 1009 { 1010 gc->prpl->set_away( gc, m->data, *away ? away : NULL ); 1011 } 1012 else 1013 { 1014 s = bim_away_alias_find( ms, away ); 1015 if( s ) 1016 { 1017 gc->prpl->set_away( gc, s, away ); 1018 if( set_getint( gc->irc, "debug" ) ) 1019 serv_got_crap( gc, "Setting away state to %s", s ); 1020 } 1021 else 1022 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); 1023 } 1024 1025 g_list_free( ms ); 1026 1027 return( 1 ); 1028 } 1029 1030 static char *bim_away_alias_list[8][5] = 1031 { 1032 { "Away from computer", "Away", "Extended away", NULL }, 1033 { "NA", "N/A", "Not available", NULL }, 1034 { "Busy", "Do not disturb", "DND", "Occupied", NULL }, 1035 { "Be right back", "BRB", NULL }, 1036 { "On the phone", "Phone", "On phone", NULL }, 1037 { "Out to lunch", "Lunch", "Food", NULL }, 1038 { "Invisible", "Hidden" }, 1039 { NULL } 1040 }; 1041 1042 static char *bim_away_alias_find( GList *gcm, char *away ) 1043 { 1044 GList *m; 1045 int i, j; 1046 1047 for( i = 0; *bim_away_alias_list[i]; i ++ ) 1048 { 1049 for( j = 0; bim_away_alias_list[i][j]; j ++ ) 1050 if( g_strncasecmp( away, bim_away_alias_list[i][j], strlen( bim_away_alias_list[i][j] ) ) == 0 ) 1051 break; 1052 1053 if( !bim_away_alias_list[i][j] ) /* If we reach the end, this row */ 1054 continue; /* is not what we want. Next! */ 1055 1056 /* Now find an entry in this row which exists in gcm */ 1057 for( j = 0; bim_away_alias_list[i][j]; j ++ ) 1058 { 1059 m = gcm; 1060 while( m ) 1061 { 1062 if( g_strcasecmp( bim_away_alias_list[i][j], m->data ) == 0 ) 1063 return( bim_away_alias_list[i][j] ); 1064 m = m->next; 1065 } 1066 } 1067 } 1068 1069 return( NULL ); 1070 } 1071 1072 void bim_add_allow( struct gaim_connection *gc, char *handle ) 1073 { 1074 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1075 { 1076 gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) ); 1077 } 1078 1079 gc->prpl->add_permit( gc, handle ); 1080 } 1081 1082 void bim_rem_allow( struct gaim_connection *gc, char *handle ) 1083 { 1084 GSList *l; 1085 1086 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1087 { 1088 g_free( l->data ); 1089 gc->permit = g_slist_delete_link( gc->permit, l ); 1090 } 1091 1092 gc->prpl->rem_permit( gc, handle ); 1093 } 1094 1095 void bim_add_block( struct gaim_connection *gc, char *handle ) 1096 { 1097 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1098 { 1099 gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) ); 1100 } 1101 1102 gc->prpl->add_deny( gc, handle ); 1103 } 1104 1105 void bim_rem_block( struct gaim_connection *gc, char *handle ) 1106 { 1107 GSList *l; 1108 1109 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1110 { 1111 g_free( l->data ); 1112 gc->deny = g_slist_delete_link( gc->deny, l ); 1113 } 1114 1115 gc->prpl->rem_deny( gc, handle ); 1116 } -
protocols/nogaim.h
rc53911e r68b518d6 52 52 #define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */ 53 53 54 #define WEBSITE "http://www.bitl ee.org/"54 #define WEBSITE "http://www.bitlbee.org/" 55 55 #define IM_FLAG_AWAY 0x0020 56 56 #define OPT_CONN_HTML 0x00000001 … … 194 194 195 195 /* nogaim.c */ 196 int serv_send_im(irc_t *irc, user_t *u, char *msg, int flags); 197 int serv_send_chat(irc_t *irc, struct gaim_connection *gc, int id, char *msg ); 196 int bim_set_away( struct gaim_connection *gc, char *away ); 197 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ); 198 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ); 199 200 void bim_add_allow( struct gaim_connection *gc, char *handle ); 201 void bim_rem_allow( struct gaim_connection *gc, char *handle ); 202 void bim_add_block( struct gaim_connection *gc, char *handle ); 203 void bim_rem_block( struct gaim_connection *gc, char *handle ); 198 204 199 205 void nogaim_init(); 200 int proto_away( struct gaim_connection *gc, char *away );201 206 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ); 202 207 203 gboolean auto_reconnect( gpointer data );208 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ); 204 209 void cancel_auto_reconnect( struct account *a ); 205 210 … … 210 215 G_MODULE_EXPORT void hide_login_progress( struct gaim_connection *gc, char *msg ); 211 216 G_MODULE_EXPORT void hide_login_progress_error( struct gaim_connection *gc, char *msg ); 212 G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ) ;217 G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 213 218 G_MODULE_EXPORT void account_online( struct gaim_connection *gc ); 214 219 G_MODULE_EXPORT void signoff( struct gaim_connection *gc ); -
protocols/oscar/aim.h
rc53911e r68b518d6 728 728 }; 729 729 730 #define AIM_CHATFLAGS_NOREFLECT 0x0001 731 #define AIM_CHATFLAGS_AWAY 0x0002 730 #define AIM_CHATFLAGS_NOREFLECT 0x0001 731 #define AIM_CHATFLAGS_AWAY 0x0002 732 #define AIM_CHATFLAGS_UNICODE 0x0004 733 #define AIM_CHATFLAGS_ISO_8859_1 0x0008 734 732 735 int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const char *msg, int msglen); 733 736 int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance); -
protocols/oscar/chat.c
rc53911e r68b518d6 159 159 if (flags & AIM_CHATFLAGS_AWAY) 160 160 aim_addtlvtochain_noval(&otl, 0x0007); 161 161 162 /* [WvG] This wasn't there originally, but we really should send 163 the right charset flags, as we also do with normal 164 messages. Hope this will work. :-) */ 165 /* 166 if (flags & AIM_CHATFLAGS_UNICODE) 167 aimbs_put16(&fr->data, 0x0002); 168 else if (flags & AIM_CHATFLAGS_ISO_8859_1) 169 aimbs_put16(&fr->data, 0x0003); 170 else 171 aimbs_put16(&fr->data, 0x0000); 172 173 aimbs_put16(&fr->data, 0x0000); 174 */ 175 162 176 /* 163 177 * SubTLV: Type 1: Message -
protocols/oscar/im.c
rc53911e r68b518d6 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 , sess->aim_icq_state, dc);1471 gc->away ? gc->away : "", sess->aim_icq_state, dc); 1472 1472 break; 1473 1473 -
protocols/oscar/oscar.c
rc53911e r68b518d6 2 2 * gaim 3 3 * 4 * Some code copyright (C) 2002-2006, Jelmer Vernooij <jelmer@samba.org> 5 * and the BitlBee team. 4 6 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> 5 7 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> … … 136 138 int i, j; 137 139 char *x = strchr(name, '-'); 138 if (!x) return NULL;140 if (!x) return g_strdup(name); 139 141 x = strchr(++x, '-'); 140 if (!x) return NULL;142 if (!x) return g_strdup(name); 141 143 tmp = g_strdup(++x); 142 144 … … 253 255 static int msgerrreasonlen = 25; 254 256 255 static voidoscar_callback(gpointer data, gint source,256 GaimInputCondition condition) {257 static gboolean oscar_callback(gpointer data, gint source, 258 b_input_condition condition) { 257 259 aim_conn_t *conn = (aim_conn_t *)data; 258 260 aim_session_t *sess = aim_conn_getsess(conn); … … 262 264 if (!gc) { 263 265 /* gc is null. we return, else we seg SIGSEG on next line. */ 264 return ;266 return FALSE; 265 267 } 266 268 … … 268 270 /* oh boy. this is probably bad. i guess the only thing we 269 271 * can really do is return? */ 270 return ;272 return FALSE; 271 273 } 272 274 … … 288 290 c->conn = NULL; 289 291 if (c->inpa > 0) 290 gaim_input_remove(c->inpa);292 b_event_remove(c->inpa); 291 293 c->inpa = 0; 292 294 c->fd = -1; … … 296 298 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { 297 299 if (odata->cnpa > 0) 298 gaim_input_remove(odata->cnpa);300 b_event_remove(odata->cnpa); 299 301 odata->cnpa = 0; 300 302 while (odata->create_rooms) { … … 310 312 } else if (conn->type == AIM_CONN_TYPE_AUTH) { 311 313 if (odata->paspa > 0) 312 gaim_input_remove(odata->paspa);314 b_event_remove(odata->paspa); 313 315 odata->paspa = 0; 314 316 aim_conn_kill(odata->sess, &conn); … … 317 319 } 318 320 } 319 } 320 } 321 322 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) 321 } else { 322 /* WTF??? */ 323 return FALSE; 324 } 325 326 return TRUE; 327 } 328 329 static gboolean oscar_login_connect(gpointer data, gint source, b_input_condition cond) 323 330 { 324 331 struct gaim_connection *gc = data; … … 329 336 if (!g_slist_find(get_connections(), gc)) { 330 337 closesocket(source); 331 return ;338 return FALSE; 332 339 } 333 340 … … 339 346 hide_login_progress(gc, _("Couldn't connect to host")); 340 347 signoff(gc); 341 return ;348 return FALSE; 342 349 } 343 350 344 351 aim_conn_completeconnect(sess, conn); 345 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ,352 gc->inpa = b_input_add(conn->fd, GAIM_INPUT_READ, 346 353 oscar_callback, conn); 354 355 return FALSE; 347 356 } 348 357 … … 383 392 if (g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.icq.com") != 0 && 384 393 g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.oscar.aol.com") != 0) { 385 serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails." );394 serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",user->proto_opt[USEROPT_AUTH]); 386 395 } 387 396 … … 412 421 struct chat_connection *n = odata->oscar_chats->data; 413 422 if (n->inpa > 0) 414 gaim_input_remove(n->inpa);423 b_event_remove(n->inpa); 415 424 g_free(n->name); 416 425 g_free(n->show); … … 431 440 g_free(odata->oldp); 432 441 if (gc->inpa > 0) 433 gaim_input_remove(gc->inpa);442 b_event_remove(gc->inpa); 434 443 if (odata->cnpa > 0) 435 gaim_input_remove(odata->cnpa);444 b_event_remove(odata->cnpa); 436 445 if (odata->paspa > 0) 437 gaim_input_remove(odata->paspa);446 b_event_remove(odata->paspa); 438 447 aim_session_kill(odata->sess); 439 448 g_free(odata->sess); … … 443 452 } 444 453 445 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) {454 static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition cond) { 446 455 struct gaim_connection *gc = data; 447 456 struct oscar_data *odata; … … 451 460 if (!g_slist_find(get_connections(), gc)) { 452 461 closesocket(source); 453 return ;462 return FALSE; 454 463 } 455 464 … … 461 470 hide_login_progress(gc, _("Could Not Connect")); 462 471 signoff(gc); 463 return ;472 return FALSE; 464 473 } 465 474 466 475 aim_conn_completeconnect(sess, bosconn); 467 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ,476 gc->inpa = b_input_add(bosconn->fd, GAIM_INPUT_READ, 468 477 oscar_callback, bosconn); 469 478 set_login_progress(gc, 4, _("Connection established, cookie sent")); 479 480 return FALSE; 470 481 } 471 482 … … 570 581 } 571 582 aim_sendcookie(sess, bosconn, info->cookie); 572 gaim_input_remove(gc->inpa);583 b_event_remove(gc->inpa); 573 584 574 585 return 1; … … 585 596 }; 586 597 587 static void damn_you(gpointer data, gint source, GaimInputCondition c)598 static gboolean damn_you(gpointer data, gint source, b_input_condition c) 588 599 { 589 600 struct pieceofcrap *pos = data; … … 605 616 do_error_dialog(pos->gc, "Gaim was unable to get a valid hash for logging into AIM." 606 617 " You may be disconnected shortly.", "Login Error"); 607 gaim_input_remove(pos->inpa);618 b_event_remove(pos->inpa); 608 619 closesocket(pos->fd); 609 620 g_free(pos); 610 return ;621 return FALSE; 611 622 } 612 623 /* [WvG] Wheeeee! Who needs error checking anyway? ;-) */ 613 624 read(pos->fd, m, 16); 614 625 m[16] = '\0'; 615 gaim_input_remove(pos->inpa);626 b_event_remove(pos->inpa); 616 627 closesocket(pos->fd); 617 628 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); 618 629 g_free(pos); 619 } 620 621 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { 630 631 return FALSE; 632 } 633 634 static gboolean straight_to_hell(gpointer data, gint source, b_input_condition cond) { 622 635 struct pieceofcrap *pos = data; 623 636 char buf[BUF_LONG]; … … 629 642 g_free(pos->modname); 630 643 g_free(pos); 631 return ;644 return FALSE; 632 645 } 633 646 … … 638 651 if (pos->modname) 639 652 g_free(pos->modname); 640 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);641 return ;653 pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); 654 return FALSE; 642 655 } 643 656 … … 761 774 } 762 775 763 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) {776 static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condition cond) { 764 777 struct gaim_connection *gc = data; 765 778 struct oscar_data *odata; … … 769 782 if (!g_slist_find(get_connections(), gc)) { 770 783 closesocket(source); 771 return ;784 return FALSE; 772 785 } 773 786 … … 778 791 if (source < 0) { 779 792 aim_conn_kill(sess, &tstconn); 780 return ;793 return FALSE; 781 794 } 782 795 783 796 aim_conn_completeconnect(sess, tstconn); 784 odata->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ,797 odata->cnpa = b_input_add(tstconn->fd, GAIM_INPUT_READ, 785 798 oscar_callback, tstconn); 786 } 787 788 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) 799 800 return FALSE; 801 } 802 803 static gboolean oscar_auth_connect(gpointer data, gint source, b_input_condition cond) 789 804 { 790 805 struct gaim_connection *gc = data; … … 795 810 if (!g_slist_find(get_connections(), gc)) { 796 811 closesocket(source); 797 return ;812 return FALSE; 798 813 } 799 814 … … 804 819 if (source < 0) { 805 820 aim_conn_kill(sess, &tstconn); 806 return ;821 return FALSE; 807 822 } 808 823 809 824 aim_conn_completeconnect(sess, tstconn); 810 odata->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ,825 odata->paspa = b_input_add(tstconn->fd, GAIM_INPUT_READ, 811 826 oscar_callback, tstconn); 812 } 813 814 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) 827 828 return FALSE; 829 } 830 831 static gboolean oscar_chat_connect(gpointer data, gint source, b_input_condition cond) 815 832 { 816 833 struct chat_connection *ccon = data; … … 825 842 g_free(ccon->name); 826 843 g_free(ccon); 827 return ;844 return FALSE; 828 845 } 829 846 … … 837 854 g_free(ccon->name); 838 855 g_free(ccon); 839 return ;856 return FALSE; 840 857 } 841 858 842 859 aim_conn_completeconnect(sess, ccon->conn); 843 ccon->inpa = gaim_input_add(tstconn->fd,860 ccon->inpa = b_input_add(tstconn->fd, 844 861 GAIM_INPUT_READ, 845 862 oscar_callback, tstconn); 846 863 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); 864 865 return FALSE; 847 866 } 848 867 … … 2500 2519 int ret; 2501 2520 guint8 len = strlen(message); 2521 guint16 flags; 2502 2522 char *s; 2503 2523 … … 2508 2528 if (*s & 128) 2509 2529 break; 2510 2530 2531 flags = AIM_CHATFLAGS_NOREFLECT; 2532 2511 2533 /* Message contains high ASCII chars, time for some translation! */ 2512 2534 if (*s) { … … 2515 2537 If we can't, fall back to UTF16. */ 2516 2538 if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) { 2539 flags |= AIM_CHATFLAGS_ISO_8859_1; 2517 2540 len = ret; 2518 2541 } else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) { 2542 flags |= AIM_CHATFLAGS_UNICODE; 2519 2543 len = ret; 2520 2544 } else { … … 2527 2551 } 2528 2552 2529 ret = aim_chat_send_im(od->sess, ccon->conn, AIM_CHATFLAGS_NOREFLECT, s, len);2553 ret = aim_chat_send_im(od->sess, ccon->conn, flags, s, len); 2530 2554 2531 2555 if (s != message) { … … 2558 2582 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); 2559 2583 if (cc->inpa > 0) 2560 gaim_input_remove(cc->inpa);2584 b_event_remove(cc->inpa); 2561 2585 aim_conn_kill(od->sess, &cc->conn); 2562 2586 g_free(cc->name); … … 2600 2624 int ret; 2601 2625 static int chat_id = 0; 2602 char * chatname = g_new0(char, strlen(gc->username)+4);2603 2604 g_snprintf(chatname, strlen(gc->username) + 4,"%s%d", gc->username, chat_id++);2626 char * chatname; 2627 2628 chatname = g_strdup_printf("%s%d", gc->username, chat_id++); 2605 2629 2606 2630 ret = oscar_chat_join(gc, chatname); -
protocols/proxy.c
rc53911e r68b518d6 21 21 */ 22 22 23 /* this is a little piece of code to handle proxy connection */24 /* it is intended to : 1st handle http proxy, using the CONNECT command25 , 2nd provide an easy way to add socks support */26 27 23 #define BITLBEE_CORE 28 24 #include <stdio.h> … … 46 42 #include "proxy.h" 47 43 48 #define GAIM_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR)49 #define GAIM_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)50 #define GAIM_ERR_COND (G_IO_HUP | G_IO_ERR | G_IO_NVAL)51 52 44 char proxyhost[128] = ""; 53 45 int proxyport = 0; … … 57 49 58 50 struct PHB { 59 GaimInputFunctionfunc, proxy_func;51 b_event_handler func, proxy_func; 60 52 gpointer data, proxy_data; 61 53 char *host; … … 64 56 gint inpa; 65 57 }; 66 67 typedef struct _GaimIOClosure {68 GaimInputFunction function;69 guint result;70 gpointer data;71 } GaimIOClosure;72 58 73 59 … … 92 78 } 93 79 94 static void gaim_io_destroy(gpointer data) 95 { 96 g_free(data); 97 } 98 99 static gboolean gaim_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) 100 { 101 GaimIOClosure *closure = data; 102 GaimInputCondition gaim_cond = 0; 103 104 if (condition & GAIM_READ_COND) 105 gaim_cond |= GAIM_INPUT_READ; 106 if (condition & GAIM_WRITE_COND) 107 gaim_cond |= GAIM_INPUT_WRITE; 108 109 closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond); 110 111 return TRUE; 112 } 113 114 static void gaim_io_connected(gpointer data, gint source, GaimInputCondition cond) 80 static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition cond) 115 81 { 116 82 struct PHB *phb = data; … … 122 88 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { 123 89 closesocket(source); 124 gaim_input_remove(phb->inpa);90 b_event_remove(phb->inpa); 125 91 if( phb->proxy_func ) 126 92 phb->proxy_func(phb->proxy_data, -1, GAIM_INPUT_READ); … … 129 95 g_free(phb); 130 96 } 131 return ;97 return FALSE; 132 98 } 133 99 #endif 134 100 sock_make_blocking(source); 135 gaim_input_remove(phb->inpa);101 b_event_remove(phb->inpa); 136 102 if( phb->proxy_func ) 137 103 phb->proxy_func(phb->proxy_data, source, GAIM_INPUT_READ); … … 140 106 g_free(phb); 141 107 } 108 109 return FALSE; 142 110 } 143 111 … … 158 126 159 127 sock_make_nonblocking(fd); 160 128 129 event_debug("proxy_connect_none( \"%s\", %d ) = %d\n", host, port, fd); 130 161 131 if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) { 162 132 if (sockerr_again()) { 163 phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb);133 phb->inpa = b_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb); 164 134 phb->fd = fd; 165 135 } else { … … 179 149 #define HTTP_GOODSTRING2 "HTTP/1.1 200 Connection established" 180 150 181 static void http_canread(gpointer data, gint source, GaimInputCondition cond)151 static gboolean http_canread(gpointer data, gint source, b_input_condition cond) 182 152 { 183 153 int nlc = 0; … … 186 156 char inputline[8192]; 187 157 188 gaim_input_remove(phb->inpa);158 b_event_remove(phb->inpa); 189 159 190 160 while ((pos < sizeof(inputline)-1) && (nlc != 2) && (read(source, &inputline[pos++], 1) == 1)) { … … 201 171 g_free(phb->host); 202 172 g_free(phb); 203 return ;173 return FALSE; 204 174 } 205 175 … … 208 178 g_free(phb->host); 209 179 g_free(phb); 210 return; 211 } 212 213 static void http_canwrite(gpointer data, gint source, GaimInputCondition cond) 180 181 return FALSE; 182 } 183 184 static gboolean http_canwrite(gpointer data, gint source, b_input_condition cond) 214 185 { 215 186 char cmd[384]; … … 218 189 int error = ETIMEDOUT; 219 190 if (phb->inpa > 0) 220 gaim_input_remove(phb->inpa);191 b_event_remove(phb->inpa); 221 192 len = sizeof(error); 222 193 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { … … 225 196 g_free(phb->host); 226 197 g_free(phb); 227 return ;198 return FALSE; 228 199 } 229 200 sock_make_blocking(source); … … 236 207 g_free(phb->host); 237 208 g_free(phb); 238 return ;209 return FALSE; 239 210 } 240 211 … … 251 222 g_free(phb->host); 252 223 g_free(phb); 253 return ;224 return FALSE; 254 225 } 255 226 } … … 261 232 g_free(phb->host); 262 233 g_free(phb); 263 return; 264 } 265 266 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, http_canread, phb); 234 return FALSE; 235 } 236 237 phb->inpa = b_input_add(source, GAIM_INPUT_READ, http_canread, phb); 238 239 return FALSE; 267 240 } 268 241 … … 280 253 /* Connecting to SOCKS4 proxies */ 281 254 282 static void s4_canread(gpointer data, gint source, GaimInputCondition cond)255 static gboolean s4_canread(gpointer data, gint source, b_input_condition cond) 283 256 { 284 257 unsigned char packet[12]; 285 258 struct PHB *phb = data; 286 259 287 gaim_input_remove(phb->inpa);260 b_event_remove(phb->inpa); 288 261 289 262 memset(packet, 0, sizeof(packet)); … … 292 265 g_free(phb->host); 293 266 g_free(phb); 294 return ;267 return FALSE; 295 268 } 296 269 … … 299 272 g_free(phb->host); 300 273 g_free(phb); 301 } 302 303 static void s4_canwrite(gpointer data, gint source, GaimInputCondition cond) 274 275 return FALSE; 276 } 277 278 static gboolean s4_canwrite(gpointer data, gint source, b_input_condition cond) 304 279 { 305 280 unsigned char packet[12]; … … 309 284 int error = ETIMEDOUT; 310 285 if (phb->inpa > 0) 311 gaim_input_remove(phb->inpa);286 b_event_remove(phb->inpa); 312 287 len = sizeof(error); 313 288 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { … … 316 291 g_free(phb->host); 317 292 g_free(phb); 318 return ;293 return FALSE; 319 294 } 320 295 sock_make_blocking(source); … … 326 301 g_free(phb->host); 327 302 g_free(phb); 328 return ;303 return FALSE; 329 304 } 330 305 … … 343 318 g_free(phb->host); 344 319 g_free(phb); 345 return; 346 } 347 348 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s4_canread, phb); 320 return FALSE; 321 } 322 323 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s4_canread, phb); 324 325 return FALSE; 349 326 } 350 327 … … 362 339 /* Connecting to SOCKS5 proxies */ 363 340 364 static void s5_canread_again(gpointer data, gint source, GaimInputCondition cond)341 static gboolean s5_canread_again(gpointer data, gint source, b_input_condition cond) 365 342 { 366 343 unsigned char buf[512]; 367 344 struct PHB *phb = data; 368 345 369 gaim_input_remove(phb->inpa);346 b_event_remove(phb->inpa); 370 347 371 348 if (read(source, buf, 10) < 10) { … … 374 351 g_free(phb->host); 375 352 g_free(phb); 376 return ;353 return FALSE; 377 354 } 378 355 if ((buf[0] != 0x05) || (buf[1] != 0x00)) { … … 381 358 g_free(phb->host); 382 359 g_free(phb); 383 return ;360 return FALSE; 384 361 } 385 362 … … 387 364 g_free(phb->host); 388 365 g_free(phb); 389 return; 366 367 return FALSE; 390 368 } 391 369 … … 395 373 struct PHB *phb = data; 396 374 int hlen = strlen(phb->host); 397 375 398 376 buf[0] = 0x05; 399 377 buf[1] = 0x01; /* CONNECT */ … … 413 391 } 414 392 415 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_canread_again, phb);416 } 417 418 static void s5_readauth(gpointer data, gint source, GaimInputCondition cond)393 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_canread_again, phb); 394 } 395 396 static gboolean s5_readauth(gpointer data, gint source, b_input_condition cond) 419 397 { 420 398 unsigned char buf[512]; 421 399 struct PHB *phb = data; 422 400 423 gaim_input_remove(phb->inpa);401 b_event_remove(phb->inpa); 424 402 425 403 if (read(source, buf, 2) < 2) { … … 428 406 g_free(phb->host); 429 407 g_free(phb); 430 return ;408 return FALSE; 431 409 } 432 410 … … 436 414 g_free(phb->host); 437 415 g_free(phb); 438 return ;416 return FALSE; 439 417 } 440 418 441 419 s5_sendconnect(phb, source); 442 } 443 444 static void s5_canread(gpointer data, gint source, GaimInputCondition cond) 420 421 return FALSE; 422 } 423 424 static gboolean s5_canread(gpointer data, gint source, b_input_condition cond) 445 425 { 446 426 unsigned char buf[512]; 447 427 struct PHB *phb = data; 448 428 449 gaim_input_remove(phb->inpa);429 b_event_remove(phb->inpa); 450 430 451 431 if (read(source, buf, 2) < 2) { … … 454 434 g_free(phb->host); 455 435 g_free(phb); 456 return ;436 return FALSE; 457 437 } 458 438 … … 462 442 g_free(phb->host); 463 443 g_free(phb); 464 return ;444 return FALSE; 465 445 } 466 446 … … 477 457 g_free(phb->host); 478 458 g_free(phb); 479 return ;459 return FALSE; 480 460 } 481 461 482 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_readauth, phb);462 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_readauth, phb); 483 463 } else { 484 464 s5_sendconnect(phb, source); 485 465 } 486 } 487 488 static void s5_canwrite(gpointer data, gint source, GaimInputCondition cond) 466 467 return FALSE; 468 } 469 470 static gboolean s5_canwrite(gpointer data, gint source, b_input_condition cond) 489 471 { 490 472 unsigned char buf[512]; … … 494 476 int error = ETIMEDOUT; 495 477 if (phb->inpa > 0) 496 gaim_input_remove(phb->inpa);478 b_event_remove(phb->inpa); 497 479 len = sizeof(error); 498 480 if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { … … 501 483 g_free(phb->host); 502 484 g_free(phb); 503 return ;485 return FALSE; 504 486 } 505 487 sock_make_blocking(source); … … 523 505 g_free(phb->host); 524 506 g_free(phb); 525 return; 526 } 527 528 phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_canread, phb); 507 return FALSE; 508 } 509 510 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_canread, phb); 511 512 return FALSE; 529 513 } 530 514 … … 542 526 /* Export functions */ 543 527 544 gint gaim_input_add(gint source, GaimInputCondition condition, GaimInputFunction function, gpointer data) 545 { 546 GaimIOClosure *closure = g_new0(GaimIOClosure, 1); 547 GIOChannel *channel; 548 GIOCondition cond = 0; 549 550 closure->function = function; 551 closure->data = data; 552 553 if (condition & GAIM_INPUT_READ) 554 cond |= GAIM_READ_COND; 555 if (condition & GAIM_INPUT_WRITE) 556 cond |= GAIM_WRITE_COND; 557 558 channel = g_io_channel_unix_new(source); 559 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, 560 gaim_io_invoke, closure, gaim_io_destroy); 561 562 g_io_channel_unref(channel); 563 return closure->result; 564 } 565 566 void gaim_input_remove(gint tag) 567 { 568 if (tag > 0) 569 g_source_remove(tag); 570 } 571 572 int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data) 528 int proxy_connect(const char *host, int port, b_event_handler func, gpointer data) 573 529 { 574 530 struct PHB *phb; -
protocols/proxy.h
rc53911e r68b518d6 1 1 /* 2 * gaim2 * nogaim 3 3 * 4 4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> … … 36 36 #include <gmodule.h> 37 37 38 #include "events.h" 39 38 40 #define PROXY_NONE 0 39 41 #define PROXY_HTTP 1 … … 47 49 extern char proxypass[128]; 48 50 49 typedef enum { 50 GAIM_INPUT_READ = 1 << 0, 51 GAIM_INPUT_WRITE = 1 << 1 52 } GaimInputCondition; 53 typedef void (*GaimInputFunction)(gpointer, gint, GaimInputCondition); 54 55 G_MODULE_EXPORT gint gaim_input_add(int, GaimInputCondition, GaimInputFunction, gpointer); 56 G_MODULE_EXPORT void gaim_input_remove(gint); 57 58 G_MODULE_EXPORT int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data); 51 G_MODULE_EXPORT int proxy_connect(const char *host, int port, b_event_handler func, gpointer data); 59 52 60 53 #endif /* _PROXY_H_ */ -
protocols/ssl_bogus.c
rc53911e r68b518d6 52 52 } 53 53 54 GaimInputCondition ssl_getdirection( void *conn )54 b_input_condition ssl_getdirection( void *conn ) 55 55 { 56 56 return GAIM_INPUT_READ; -
protocols/ssl_client.h
rc53911e r68b518d6 33 33 extern int ssl_errno; 34 34 35 typedef void (*ssl_input_function)(gpointer, void*, GaimInputCondition);35 typedef gboolean (*ssl_input_function)(gpointer, void*, b_input_condition); 36 36 37 37 G_MODULE_EXPORT void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ); … … 40 40 G_MODULE_EXPORT void ssl_disconnect( void *conn_ ); 41 41 G_MODULE_EXPORT int ssl_getfd( void *conn ); 42 G_MODULE_EXPORT GaimInputCondition ssl_getdirection( void *conn );42 G_MODULE_EXPORT b_input_condition ssl_getdirection( void *conn ); -
protocols/ssl_gnutls.c
rc53911e r68b518d6 48 48 }; 49 49 50 static void ssl_connected( gpointer data, gint source, GaimInputCondition cond );50 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ); 51 51 52 52 … … 81 81 } 82 82 83 static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond );84 85 static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )83 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ); 84 85 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ) 86 86 { 87 87 struct scd *conn = data; … … 96 96 g_free( conn ); 97 97 98 return ;98 return FALSE; 99 99 } 100 100 … … 102 102 gnutls_transport_set_ptr( conn->session, (gnutls_transport_ptr) conn->fd ); 103 103 104 ssl_handshake( data, source, cond );105 } 106 107 static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond )104 return ssl_handshake( data, source, cond ); 105 } 106 107 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ) 108 108 { 109 109 struct scd *conn = data; 110 110 int st; 111 111 112 if( conn->inpa != -1 )113 {114 gaim_input_remove( conn->inpa );115 conn->inpa = -1;116 }117 118 112 if( ( st = gnutls_handshake( conn->session ) ) < 0 ) 119 113 { 120 114 if( st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED ) 121 115 { 122 conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ),123 116 conn->inpa = b_input_add( conn->fd, ssl_getdirection( conn ), 117 ssl_handshake, data ); 124 118 } 125 119 else … … 142 136 conn->func( conn->data, conn, cond ); 143 137 } 138 139 return FALSE; 144 140 } 145 141 … … 187 183 188 184 if( conn->inpa != -1 ) 189 gaim_input_remove( conn->inpa );185 b_event_remove( conn->inpa ); 190 186 191 187 if( conn->established ) … … 204 200 } 205 201 206 GaimInputCondition ssl_getdirection( void *conn )202 b_input_condition ssl_getdirection( void *conn ) 207 203 { 208 204 return( gnutls_record_get_direction( ((struct scd*)conn)->session ) ? -
protocols/ssl_nss.c
rc53911e r68b518d6 52 52 }; 53 53 54 static void ssl_connected( gpointer data, gint source, GaimInputCondition cond );54 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ); 55 55 56 56 … … 116 116 } 117 117 118 static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )118 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ) 119 119 { 120 120 struct scd *conn = data; … … 140 140 conn->established = TRUE; 141 141 conn->func( conn->data, conn, cond ); 142 return ;142 return FALSE; 143 143 144 144 ssl_connected_failure: … … 149 149 if( source >= 0 ) closesocket( source ); 150 150 g_free( conn ); 151 152 return FALSE; 151 153 } 152 154 … … 182 184 } 183 185 184 GaimInputCondition ssl_getdirection( void *conn )186 b_input_condition ssl_getdirection( void *conn ) 185 187 { 186 188 /* Just in case someone calls us, let's return the most likely case: */ -
protocols/ssl_openssl.c
rc53911e r68b518d6 52 52 }; 53 53 54 static void ssl_connected( gpointer data, gint source, GaimInputCondition cond ); 55 54 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ); 56 55 57 56 … … 95 94 } 96 95 97 static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond );98 99 static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )96 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ); 97 98 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ) 100 99 { 101 100 struct scd *conn = data; … … 104 103 return ssl_handshake( data, -1, cond ); 105 104 106 /* Make it non-blocking at least during the handshake...*/105 /* We can do at least the handshake with non-blocking I/O */ 107 106 sock_make_nonblocking( conn->fd ); 108 107 SSL_set_fd( conn->ssl, conn->fd ); … … 111 110 } 112 111 113 static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond )112 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond ) 114 113 { 115 114 struct scd *conn = data; 116 115 int st; 117 118 if( conn->inpa != -1 )119 {120 gaim_input_remove( conn->inpa );121 conn->inpa = -1;122 }123 116 124 117 if( ( st = SSL_connect( conn->ssl ) ) < 0 ) … … 128 121 goto ssl_connected_failure; 129 122 130 conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data );131 return ;123 conn->inpa = b_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data ); 124 return FALSE; 132 125 } 133 126 … … 135 128 sock_make_blocking( conn->fd ); /* For now... */ 136 129 conn->func( conn->data, conn, cond ); 137 return ;130 return FALSE; 138 131 139 132 ssl_connected_failure: … … 151 144 if( source >= 0 ) closesocket( source ); 152 145 g_free( conn ); 146 147 return FALSE; 153 148 } 154 149 … … 204 199 205 200 if( conn->inpa != -1 ) 206 gaim_input_remove( conn->inpa );201 b_event_remove( conn->inpa ); 207 202 208 203 if( conn->established ) … … 221 216 } 222 217 223 GaimInputCondition ssl_getdirection( void *conn )218 b_input_condition ssl_getdirection( void *conn ) 224 219 { 225 220 return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ ); -
protocols/yahoo/yahoo.c
rc53911e r68b518d6 443 443 }; 444 444 445 void byahoo_connect_callback( gpointer data, gint source, GaimInputCondition cond )445 void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond ) 446 446 { 447 447 struct byahoo_connect_callback_data *d = data; … … 465 465 }; 466 466 467 void byahoo_read_ready_callback( gpointer data, gint source, GaimInputCondition cond )467 gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_condition cond ) 468 468 { 469 469 struct byahoo_read_ready_data *d = data; 470 470 471 471 if( !byahoo_get_gc_by_id( d->id ) ) 472 {473 472 /* WTF doesn't libyahoo clean this up? */ 474 ext_yahoo_remove_handler( d->id, d->tag ); 475 return; 476 } 473 return FALSE; 477 474 478 475 yahoo_read_ready( d->id, d->fd, d->data ); 476 477 return TRUE; 479 478 } 480 479 … … 487 486 }; 488 487 489 void byahoo_write_ready_callback( gpointer data, gint source, GaimInputCondition cond )488 gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condition cond ) 490 489 { 491 490 struct byahoo_write_ready_data *d = data; 492 491 493 492 if( !byahoo_get_gc_by_id( d->id ) ) 494 {495 493 /* WTF doesn't libyahoo clean this up? */ 496 ext_yahoo_remove_handler( d->id, d->tag ); 497 return; 498 } 494 return FALSE; 499 495 500 496 yahoo_write_ready( d->id, d->fd, d->data ); 497 498 return FALSE; 501 499 } 502 500 … … 687 685 688 686 inp->d = d; 689 d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_READ, (GaimInputFunction) byahoo_read_ready_callback, (gpointer) d );687 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d ); 690 688 } 691 689 else if( cond == YAHOO_INPUT_WRITE ) … … 698 696 699 697 inp->d = d; 700 d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_WRITE, (GaimInputFunction) byahoo_write_ready_callback, (gpointer) d );698 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d ); 701 699 } 702 700 else … … 729 727 } 730 728 731 gaim_input_remove( tag );729 b_event_remove( tag ); 732 730 } 733 731 … … 738 736 739 737 d = g_new0( struct byahoo_connect_callback_data, 1 ); 740 if( ( fd = proxy_connect( host, port, ( GaimInputFunction) byahoo_connect_callback, (gpointer) d ) ) < 0 )738 if( ( fd = proxy_connect( host, port, (b_event_handler) byahoo_connect_callback, (gpointer) d ) ) < 0 ) 741 739 { 742 740 g_free( d ); -
root_commands.c
rc53911e r68b518d6 56 56 cmd[k++] = s; 57 57 s --; 58 } 59 else 60 { 61 break; 58 62 } 59 63 } … … 554 558 else 555 559 { 556 gc->prpl->rem_permit( gc, cmd[2] );557 gc->prpl->add_deny( gc, cmd[2] );558 irc_usermsg( irc, "Buddy `%s' moved from your permit- to your deny-list", cmd[2] );560 bim_rem_allow( gc, cmd[2] ); 561 bim_add_block( gc, cmd[2] ); 562 irc_usermsg( irc, "Buddy `%s' moved from your allow- to your block-list", cmd[2] ); 559 563 } 560 564 } … … 613 617 else 614 618 { 615 gc->prpl->rem_deny( gc, cmd[2] );616 gc->prpl->add_permit( gc, cmd[2] );617 618 irc_usermsg( irc, "Buddy `%s' moved from your deny- to your permit-list", cmd[2] );619 bim_rem_block( gc, cmd[2] ); 620 bim_add_allow( gc, cmd[2] ); 621 622 irc_usermsg( irc, "Buddy `%s' moved from your block- to your allow-list", cmd[2] ); 619 623 } 620 624 } -
sock.h
rc53911e r68b518d6 18 18 #define sock_make_blocking(fd) fcntl(fd, F_SETFL, 0) 19 19 #define sockerr_again() (errno == EINPROGRESS || errno == EINTR) 20 #ifndef EVENTS_LIBEVENT 20 21 #define closesocket(a) close(a) 22 #endif 21 23 #else 22 24 # include <winsock2.h> -
unix.c
rc53911e r68b518d6 47 47 memset( &global, 0, sizeof( global_t ) ); 48 48 49 global.loop = g_main_new( FALSE);49 b_main_init(); 50 50 51 51 log_init(); … … 117 117 log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE ); 118 118 119 g_main_run( global.loop);119 b_main_run(); 120 120 121 121 if( global.restart ) … … 165 165 166 166 log_message( LOGLVL_ERROR, "SIGTERM received, cleaning up process." ); 167 g_timeout_add_full( G_PRIORITY_LOW, 1, (GSourceFunc) bitlbee_shutdown, NULL, NULL );167 b_timeout_add( 1, (b_event_handler) bitlbee_shutdown, NULL ); 168 168 169 169 first = 0; -
user.c
rc53911e r68b518d6 109 109 if( u->handle ) g_free( u->handle ); 110 110 if( u->sendbuf ) g_free( u->sendbuf ); 111 if( u->sendbuf_timer ) g_source_remove( u->sendbuf_timer );111 if( u->sendbuf_timer ) b_event_remove( u->sendbuf_timer ); 112 112 g_free( u ); 113 113 -
util.c
rc53911e r68b518d6 39 39 #include <glib.h> 40 40 #include <time.h> 41 #ifdef GLIB2 42 #define iconv_t GIConv 43 #define iconv_open g_iconv_open 44 #define iconv_close g_iconv_close 45 #define iconv g_iconv 46 #else 41 47 #include <iconv.h> 48 #endif 42 49 43 50 void strip_linefeed(gchar *text)
Note: See TracChangeset
for help on using the changeset viewer.