Changes in / [68b518d6:c53911e]


Ignore:
Files:
3 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    r68b518d6 rc53911e  
    3434#include <errno.h>
    3535
    36 static gboolean bitlbee_io_new_client( gpointer data, gint fd, b_input_condition condition );
     36gboolean bitlbee_io_new_client( GIOChannel *source, GIOCondition condition, gpointer data );
    3737
    3838int bitlbee_daemon_init()
     
    4444#endif
    4545        int i;
     46        GIOChannel *ch;
    4647        FILE *fp;
    4748       
     
    9091        }
    9192       
    92         global.listen_watch_source_id = b_input_add( global.listen_socket, GAIM_INPUT_READ, bitlbee_io_new_client, NULL );
     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 );
    9395       
    9496#ifndef _WIN32
     
    145147}
    146148
    147 gboolean bitlbee_io_current_client_read( gpointer data, gint fd, b_input_condition cond )
     149gboolean bitlbee_io_current_client_read( GIOChannel *source, GIOCondition condition, gpointer data )
    148150{
    149151        irc_t *irc = data;
     
    151153        int st;
    152154       
     155        if( condition & G_IO_ERR || condition & G_IO_HUP )
     156        {
     157                irc_abort( irc, 1, "Read error" );
     158                return FALSE;
     159        }
     160       
    153161        st = read( irc->fd, line, sizeof( line ) - 1 );
    154162        if( st == 0 )
     
    186194        if( !g_slist_find( irc_connection_list, irc ) )
    187195        {
    188                 log_message( LOGLVL_WARNING, "Abnormal termination of connection with fd %d.", fd );
     196                log_message( LOGLVL_WARNING, "Abnormal termination of connection with fd %d.", irc->fd );
    189197                return FALSE;
    190198        }
     
    200208}
    201209
    202 gboolean bitlbee_io_current_client_write( gpointer data, gint fd, b_input_condition cond )
     210gboolean bitlbee_io_current_client_write( GIOChannel *source, GIOCondition condition, gpointer data )
    203211{
    204212        irc_t *irc = data;
     
    207215
    208216        if( irc->sendbuffer == NULL )
    209                 return FALSE;
     217                return( FALSE );
    210218       
    211219        size = strlen( irc->sendbuffer );
     
    231239                        irc_free( irc );
    232240               
    233                 return FALSE;
     241                return( FALSE );
    234242        }
    235243        else
     
    239247                irc->sendbuffer = temp;
    240248               
    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 );
     249                return( TRUE );
     250        }
     251}
     252
     253gboolean bitlbee_io_new_client( GIOChannel *source, GIOCondition condition, gpointer data )
     254{
     255        size_t size = sizeof( struct sockaddr_in );
    248256        struct sockaddr_in conn_info;
    249257        int new_socket = accept( global.listen_socket, (struct sockaddr *) &conn_info, &size );
     
    278286                        child->pid = client_pid;
    279287                        child->ipc_fd = fds[0];
    280                         child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
     288                        child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
    281289                        child_list = g_slist_append( child_list, child );
    282290                       
     
    293301                        /* Close the listening socket, we're a client. */
    294302                        close( global.listen_socket );
    295                         b_event_remove( global.listen_watch_source_id );
     303                        g_source_remove( global.listen_watch_source_id );
    296304                       
    297305                        /* Make the connection. */
     
    300308                        /* We can store the IPC fd there now. */
    301309                        global.listen_socket = fds[1];
    302                         global.listen_watch_source_id = b_input_add( fds[1], GAIM_INPUT_READ, ipc_child_read, irc );
     310                        global.listen_watch_source_id = gaim_input_add( fds[1], GAIM_INPUT_READ, ipc_child_read, irc );
    303311                       
    304312                        close( fds[0] );
     
    316324}
    317325
    318 gboolean bitlbee_shutdown( gpointer data, gint fd, b_input_condition cond )
     326void bitlbee_shutdown( gpointer data )
    319327{
    320328        /* Try to save data for all active connections (if desired). */
     
    323331       
    324332        /* We'll only reach this point when not running in inetd mode: */
    325         b_main_quit();
    326        
    327         return FALSE;
    328 }
     333        g_main_quit( global.loop );
     334}
  • bitlbee.h

    r68b518d6 rc53911e  
    5858/* The following functions should not be used if we want to maintain Windows compatibility... */
    5959#undef free
    60 #define free            __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM__
     60#define free            __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM_INSTEAD__
    6161#undef malloc
    62 #define malloc          __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM__
     62#define malloc          __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM_INSTEAD__
    6363#undef calloc
    64 #define calloc          __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM__
     64#define calloc          __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM_INSTEAD__
    6565#undef realloc
    66 #define realloc         __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM__
     66#define realloc         __PLEASE_USE_THE_GLIB_MEMORY_ALLOCATION_SYSTEM_INSTEAD__
    6767#undef strdup
    68 #define strdup          __PLEASE_USE_THE_GLIB_STRDUP_FUNCTIONS_SYSTEM__
     68#define strdup          __PLEASE_USE_THE_GLIB_STRDUP_FUNCTIONS_SYSTEM_INSTEAD__
    6969#undef strndup
    70 #define strndup         __PLEASE_USE_THE_GLIB_STRDUP_FUNCTIONS_SYSTEM__
     70#define strndup         __PLEASE_USE_THE_GLIB_STRDUP_FUNCTIONS_SYSTEM_INSTEAD__
    7171#undef snprintf
    72 #define snprintf        __PLEASE_USE_G_SNPRINTF__
     72#define snprintf        __PLEASE_USE_G_SNPRINTF_INSTEAD__
    7373#undef strcasecmp
    74 #define strcasecmp      __PLEASE_USE_G_STRCASECMP__
     74#define strcasecmp      __PLEASE_USE_G_STRCASECMP_INSTEAD__
    7575#undef strncasecmp
    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__
     76#define strncasecmp     __PLEASE_USE_G_STRNCASECMP_INSTEAD__
    9677
    9778#ifndef F_OK
     
    131112#include "sock.h"
    132113#include "util.h"
    133 #include "proxy.h"
    134114
    135115typedef struct global {
     
    141121        GList *storage; /* The first backend in the list will be used for saving */
    142122        char *helpfile;
     123        GMainLoop *loop;
    143124        int restart;
    144125} global_t;
     
    147128int bitlbee_inetd_init( void );
    148129
    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 );
     130gboolean bitlbee_io_current_client_read( GIOChannel *source, GIOCondition condition, gpointer data );
     131gboolean bitlbee_io_current_client_write( GIOChannel *source, GIOCondition condition, gpointer data );
    151132
    152133void root_command_string( irc_t *irc, user_t *u, char *command, int flags );
    153134void root_command( irc_t *irc, char *command[] );
    154 gboolean bitlbee_shutdown( gpointer data, gint fd, b_input_condition cond );
     135void bitlbee_shutdown( gpointer data );
    155136
    156137extern global_t global;
  • configure

    r68b518d6 rc53911e  
    1414datadir='$prefix/share/bitlbee/'
    1515config='/var/lib/bitlbee/'
    16 plugindir='$prefix/lib/bitlbee/'
    17 includedir='$prefix/include/bitlbee/'
    18 libevent='/usr/'
    1916pidfile='/var/run/bitlbee.pid'
    2017ipcsocket='/var/run/bitlbee'
     18plugindir='$prefix/lib/bitlbee'
    2119pcdir='$prefix/lib/pkgconfig'
     20includedir='$prefix/include/bitlbee'
    2221
    2322msn=1
     
    2928strip=1
    3029ipv6=1
    31 
    32 events=glib
    3330ssl=auto
    3431
     
    6764--ipv6=0/1      IPv6 socket support                     $ipv6
    6865
    69 --events=...    Event handler (glib, libevent)          $events
    7066--ssl=...       SSL library to use (gnutls, nss, openssl, bogus, auto)
    7167                                                        $ssl
     
    8480config=`eval echo "$config/" | sed 's/\/\{1,\}/\//g'`
    8581plugindir=`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 
    8982pidfile=`eval echo "$pidfile" | sed 's/\/\{1,\}/\//g'`
    9083ipcsocket=`eval echo "$ipcsocket" | sed 's/\/\{1,\}/\//g'`
     84includedir=`eval echo "$includedir" | sed 's/\/\{1,\}/\//g'`
    9185pcdir=`eval echo "$pcdir" | sed 's/\/\{1,\}/\//g'`
    9286
     
    169163fi
    170164
    171 GLIB=0
    172 
    173165if $PKG_CONFIG --version > /dev/null 2>/dev/null && $PKG_CONFIG glib-2.0; then
    174166        cat<<EOF>>Makefile.settings
     
    177169EOF
    178170        echo '#define GLIB2' >> config.h
    179         GLIB=2
    180171elif type glib-config > /dev/null 2> /dev/null; then
    181172        cat<<EOF>>Makefile.settings
     
    184175EOF
    185176        echo '#define GLIB1' >> config.h
    186         GLIB=1
    187177else
    188178        echo 'Cannot find glib development libraries, aborting. (Install libglib-dev?)'
     
    190180fi
    191181
    192 if [ GLIB = 1 -o -r /usr/include/iconv.h ]; then
     182if [ -r /usr/include/iconv.h ]; then
    193183        :;
    194184elif [ -r /usr/local/include/iconv.h ]; then
    195         echo CFLAGS+=-I/usr/local/include >> Makefile.settings
     185        echo CFLAGS+=-I/usr/local/include >> Makefile.settings;
    196186else
    197187        echo
    198188        echo 'Warning: Could not find iconv.h, you might have to install it and/or modify'
    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
     189        echo 'Makefile.settings to tell where this file is.';
     190fi
    225191
    226192
     
    456422fi
    457423
    458 echo '  Using event handler: '$events;
    459 echo '  Using SSL library: '$ssl;
     424if [ "$msn" = "1" ]; then
     425        echo '  Using SSL library: '$ssl;
     426fi
    460427
    461428#if [ "$flood" = "0" ]; then
  • ipc.c

    r68b518d6 rc53911e  
    6060                ipc_to_children_str( "DIE\r\n" );
    6161       
    62         bitlbee_shutdown( NULL, -1, 0 );
     62        bitlbee_shutdown( NULL );
    6363}
    6464
     
    9191       
    9292        global.restart = -1;
    93         bitlbee_shutdown( NULL, -1, 0 );
     93        bitlbee_shutdown( NULL );
    9494}
    9595
     
    246246}
    247247
    248 gboolean ipc_master_read( gpointer data, gint source, b_input_condition cond )
     248void ipc_master_read( gpointer data, gint source, GaimInputCondition cond )
    249249{
    250250        char *buf, **cmd;
     
    272272                }
    273273        }
    274        
    275         return TRUE;
    276 }
    277 
    278 gboolean ipc_child_read( gpointer data, gint source, b_input_condition cond )
     274}
     275
     276void ipc_child_read( gpointer data, gint source, GaimInputCondition cond )
    279277{
    280278        char *buf, **cmd;
     
    288286        else
    289287        {
    290                 b_event_remove( global.listen_watch_source_id );
     288                gaim_input_remove( global.listen_watch_source_id );
    291289                close( global.listen_socket );
    292290               
    293291                global.listen_socket = -1;
    294292        }
    295        
    296         return TRUE;
    297293}
    298294
     
    401397void ipc_master_free_one( struct bitlbee_child *c )
    402398{
    403         b_event_remove( c->ipc_inpa );
     399        gaim_input_remove( c->ipc_inpa );
    404400        closesocket( c->ipc_fd );
    405401       
     
    467463
    468464
    469 static gboolean new_ipc_client( gpointer data, gint serversock, b_input_condition cond )
     465static gboolean new_ipc_client (GIOChannel *gio, GIOCondition cond, gpointer data)
    470466{
    471467        struct bitlbee_child *child = g_new0( struct bitlbee_child, 1 );
    472        
    473         child->ipc_fd = accept( serversock, NULL, 0 );
    474        
    475         if( child->ipc_fd == -1 )
    476         {
     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) {
    477475                log_message( LOGLVL_WARNING, "Unable to accept connection on UNIX domain socket: %s", strerror(errno) );
    478476                return TRUE;
    479477        }
    480478               
    481         child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
    482        
     479        child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
     480               
    483481        child_list = g_slist_append( child_list, child );
    484        
     482
    485483        return TRUE;
    486484}
     
    491489        struct sockaddr_un un_addr;
    492490        int serversock;
     491        GIOChannel *gio;
    493492
    494493        /* Clean up old socket files that were hanging around.. */
     
    518517        }
    519518       
    520         b_input_add( serversock, GAIM_INPUT_READ, new_ipc_client, NULL );
    521        
     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);
    522527        return 1;
    523528}
     
    558563                        return 0;
    559564                }
    560                 child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
     565                child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
    561566               
    562567                child_list = g_slist_append( child_list, child );
  • ipc.h

    r68b518d6 rc53911e  
    4040
    4141
    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 );
     42void ipc_master_read( gpointer data, gint source, GaimInputCondition cond );
     43void ipc_child_read( gpointer data, gint source, GaimInputCondition cond );
    4444
    4545void ipc_master_free_one( struct bitlbee_child *child );
     
    4747
    4848void ipc_to_master( char **cmd );
    49 void ipc_to_master_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 );
     49void ipc_to_master_str( char *format, ... );
    5050void ipc_to_children( char **cmd );
    51 void ipc_to_children_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 );
     51void ipc_to_children_str( char *format, ... );
    5252
    5353/* We need this function in inetd mode, so let's just make it non-static. */
  • irc.c

    r68b518d6 rc53911e  
    2929#include "ipc.h"
    3030
    31 static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond );
     31static gboolean irc_userping( gpointer _irc );
    3232
    3333GSList *irc_connection_list = NULL;
     
    5454       
    5555        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 );
    5965       
    6066        irc->status = USTATUS_OFFLINE;
     
    114120
    115121        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 );
    117123       
    118124        irc_write( irc, ":%s NOTICE AUTH :%s", irc->myhost, "BitlBee-IRCd initialized, please go on" );
     
    184190                   bitlbee_.._write doesn't do it first. */
    185191               
    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 );
    188194        }
    189195        else
     
    218224       
    219225        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 );
    222228        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 );
    225232        irc_connection_list = g_slist_remove( irc_connection_list, irc );
    226233       
     
    272279                        if(user->host!=user->nick) g_free(user->host);
    273280                        if(user->realname!=user->nick) g_free(user->realname);
    274                         b_event_remove(user->sendbuf_timer);
     281                        gaim_input_remove(user->sendbuf_timer);
    275282                                       
    276283                        usertmp = user;
     
    322329       
    323330        if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON )
    324                 b_main_quit();
     331                g_main_quit( global.loop );
    325332}
    326333
     
    576583        char line[IRC_MAX_LINE+1], *cs;
    577584               
    578         /* Don't try to write anything new anymore when shutting down. */
    579         if( irc->status == USTATUS_SHUTDOWN )
     585        if( irc->quit )
    580586                return;
    581587       
     
    594600        strcat( line, "\r\n" );
    595601       
    596         if( irc->sendbuffer != NULL )
    597         {
     602        if( irc->sendbuffer != NULL ) {
    598603                size = strlen( irc->sendbuffer ) + strlen( line );
    599604                irc->sendbuffer = g_renew ( char, irc->sendbuffer, size + 1 );
    600605                strcpy( ( irc->sendbuffer + strlen( irc->sendbuffer ) ), line );
    601606        }
    602         else
    603         {
    604                 irc->sendbuffer = g_strdup(line);
    605         }
     607        else
     608                irc->sendbuffer = g_strdup(line);       
    606609       
    607610        if( irc->w_watch_source_id == 0 )
    608611        {
    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 );
    615613        }
    616614       
     
    638636                if( now )
    639637                {
    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 );
    641639                }
    642640                temp = temp->next;
     
    832830                        irc_reply( irc, 332, "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", channel, c->title );
    833831                else
    834                         irc_reply( irc, 331, "%s :No topic for this channel", channel );
     832                        irc_reply( irc, 331, "%s :No topic for this channel" );
    835833        }
    836834}
     
    888886        if( g_hash_table_lookup( irc->watches, nick ) )
    889887        {
    890                 irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged online" );
     888                irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged online" );
    891889        }
    892890        g_free( nick );
     
    913911        if( g_hash_table_lookup( irc->watches, nick ) )
    914912        {
    915                 irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged offline" );
     913                irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged offline" );
    916914        }
    917915        g_free( nick );
     
    10131011        else if( c && c->gc && c->gc->prpl )
    10141012        {
    1015                 return( bim_chat_msg( c->gc, c->id, s ) );
     1013                return( serv_send_chat( irc, c->gc, c->id, s ) );
    10161014        }
    10171015       
     
    10191017}
    10201018
    1021 static gboolean buddy_send_handler_delayed( gpointer data, gint fd, b_input_condition cond )
     1019gboolean buddy_send_handler_delayed( gpointer data )
    10221020{
    10231021        user_t *u = data;
    10241022       
    1025         /* Shouldn't happen, but just to be sure. */
    1026         if( u->sendbuf_len < 2 )
    1027                 return FALSE;
    1028        
    10291023        u->sendbuf[u->sendbuf_len-2] = 0; /* Cut off the last newline */
    1030         bim_buddy_msg( u->gc, u->handle, u->sendbuf, u->sendbuf_flags );
     1024        serv_send_im( u->gc->irc, u, u->sendbuf, u->sendbuf_flags );
    10311025       
    10321026        g_free( u->sendbuf );
     
    10361030        u->sendbuf_flags = 0;
    10371031       
    1038         return FALSE;
     1032        return( FALSE );
    10391033}
    10401034
     
    10491043                if( u->sendbuf_len > 0 && u->sendbuf_flags != flags)
    10501044                {
    1051                         /* Flush the buffer */
    1052                         b_event_remove( u->sendbuf_timer );
    1053                         buddy_send_handler_delayed( u, -1, 0 );
     1045                        //Flush the buffer
     1046                        g_source_remove( u->sendbuf_timer );
     1047                        buddy_send_handler_delayed( u );
    10541048                }
    10551049
     
    10571051                {
    10581052                        u->sendbuf_len = strlen( msg ) + 2;
    1059                         u->sendbuf = g_new( char, u->sendbuf_len );
     1053                        u->sendbuf = g_new (char, u->sendbuf_len );
    10601054                        u->sendbuf[0] = 0;
    10611055                        u->sendbuf_flags = flags;
     
    10641058                {
    10651059                        u->sendbuf_len += strlen( msg ) + 1;
    1066                         u->sendbuf = g_renew( char, u->sendbuf, u->sendbuf_len );
     1060                        u->sendbuf = g_renew ( char, u->sendbuf, u->sendbuf_len );
    10671061                }
    10681062               
     
    10751069               
    10761070                if( u->sendbuf_timer > 0 )
    1077                         b_event_remove( u->sendbuf_timer );
    1078                 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 );
    10791073        }
    10801074        else
    10811075        {
    1082                 bim_buddy_msg( u->gc, u->handle, msg, flags );
     1076                serv_send_im( irc, u, msg, flags );
    10831077        }
    10841078}
     
    11601154   pongs from the user. When not connected yet, we don't ping but drop the
    11611155   connection when the user fails to connect in IRC_LOGIN_TIMEOUT secs. */
    1162 static gboolean irc_userping( gpointer _irc, gint fd, b_input_condition cond )
     1156static gboolean irc_userping( gpointer _irc )
    11631157{
    11641158        irc_t *irc = _irc;
  • irc.h

    r68b518d6 rc53911e  
    6161        char *sendbuffer;
    6262        char *readbuffer;
     63        int quit;
    6364
    6465        int sentbytes;
     
    9293        struct set *set;
    9394
     95        GIOChannel *io_channel;
    9496        gint r_watch_source_id;
    9597        gint w_watch_source_id;
     
    103105
    104106irc_t *irc_new( int fd );
    105 void irc_abort( irc_t *irc, int immed, char *format, ... ) G_GNUC_PRINTF( 3, 4 );
     107void irc_abort( irc_t *irc, int immed, char *format, ... );
    106108void irc_free( irc_t *irc );
    107109
     
    112114
    113115void irc_vawrite( irc_t *irc, char *format, va_list params );
    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 );
     116void irc_write( irc_t *irc, char *format, ... );
     117void irc_write_all( int now, char *format, ... );
     118void irc_reply( irc_t *irc, int code, char *format, ... );
     119G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... );
    118120char **irc_tokenize( char *buffer );
    119121
  • irc_commands.c

    r68b518d6 rc53911e  
    385385                       
    386386                        if( u && u->online )
    387                                 irc_reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "is online" );
     387                                irc_reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "is online" );
    388388                        else
    389                                 irc_reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", (int) time( NULL ), "is offline" );
     389                                irc_reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", time( NULL ), "is offline" );
    390390                }
    391391                else if( cmd[i][0] == '-' )
     
    448448               
    449449                if( gc && gc->flags & OPT_LOGGED_IN )
    450                         bim_set_away( gc, u->away );
     450                        proto_away( gc, u->away );
    451451        }
    452452}
  • log.h

    r68b518d6 rc53911e  
    5454void log_init(void);
    5555void log_link(int level, int output);
    56 void log_message(int level, char *message, ...) G_GNUC_PRINTF( 2, 3 );
     56void log_message(int level, char *message, ...);
    5757void log_error(char *functionname);
    5858
  • protocols/Makefile

    r68b518d6 rc53911e  
    1010
    1111# [SH] Program variables
    12 objects = $(EVENT_HANDLER) http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT)
     12objects = http_client.o md5.o nogaim.o proxy.o sha.o $(SSL_CLIENT)
    1313
    1414# [SH] The next two lines should contain the directory name (in $(subdirs))
  • protocols/http_client.c

    r68b518d6 rc53911e  
    3232
    3333
    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 );
     34static void http_connected( gpointer data, int source, GaimInputCondition cond );
     35static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond );
     36static void http_incoming_data( gpointer data, int source, GaimInputCondition cond );
    3737
    3838
     
    104104/* This one is actually pretty simple... Might get more calls if we can't write
    105105   the whole request at once. */
    106 static gboolean http_connected( gpointer data, int source, b_input_condition cond )
     106static void http_connected( gpointer data, int source, GaimInputCondition cond )
    107107{
    108108        struct http_request *req = data;
     
    113113       
    114114        if( req->inpa > 0 )
    115                 b_event_remove( req->inpa );
     115                gaim_input_remove( req->inpa );
    116116       
    117117        sock_make_nonblocking( req->fd );
     
    148148       
    149149        if( req->bytes_written < req->request_length )
    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;
     150                req->inpa = gaim_input_add( source,
     151                                            req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_WRITE,
     152                                            http_connected, req );
     153        else
     154                req->inpa = gaim_input_add( source, GAIM_INPUT_READ, http_incoming_data, req );
     155       
     156        return;
    157157       
    158158error:
     
    162162        g_free( req );
    163163       
    164         return FALSE;
     164        return;
    165165}
    166166
    167 static gboolean http_ssl_connected( gpointer data, void *source, b_input_condition cond )
     167static void http_ssl_connected( gpointer data, void *source, GaimInputCondition cond )
    168168{
    169169        struct http_request *req = data;
     
    177177}
    178178
    179 static gboolean http_incoming_data( gpointer data, int source, b_input_condition cond )
     179static void http_incoming_data( gpointer data, int source, GaimInputCondition cond )
    180180{
    181181        struct http_request *req = data;
     
    186186       
    187187        if( req->inpa > 0 )
    188                 b_event_remove( req->inpa );
     188                gaim_input_remove( req->inpa );
    189189       
    190190        if( req->ssl )
     
    233233       
    234234        /* There will be more! */
    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;
     235        req->inpa = gaim_input_add( req->fd,
     236                                    req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_READ,
     237                                    http_incoming_data, req );
     238       
     239        return;
    240240
    241241got_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        
    247242        /* Zero termination is very convenient. */
    248243        req->reply_headers[req->bytes_read] = 0;
     
    401396                req->reply_headers = req->reply_body = NULL;
    402397               
    403                 return FALSE;
     398                return;
    404399        }
    405400       
     
    419414        g_free( req->reply_headers );
    420415        g_free( req );
    421        
    422         return FALSE;
    423416}
  • protocols/jabber/jabber.c

    r68b518d6 rc53911e  
    471471}
    472472
    473 static gboolean jabber_callback(gpointer data, gint source, b_input_condition condition)
     473static void jabber_callback(gpointer data, gint source, GaimInputCondition condition)
    474474{
    475475        struct gaim_connection *gc = (struct gaim_connection *)data;
     
    477477
    478478        gjab_recv(jd->gjc);
    479        
    480         return TRUE;
    481479}
    482480
     
    489487}
    490488
    491 static gboolean gjab_connected(gpointer data, gint source, b_input_condition cond)
     489static void gjab_connected(gpointer data, gint source, GaimInputCondition cond)
    492490{
    493491        xmlnode x;
     
    499497        if (!g_slist_find(get_connections(), gc)) {
    500498                closesocket(source);
    501                 return FALSE;
     499                return;
    502500        }
    503501
     
    510508        if (source == -1) {
    511509                STATE_EVT(JCONN_STATE_OFF)
    512                 return FALSE;
     510                return;
    513511        }
    514512
     
    532530
    533531        gc = GJ_GC(gjc);
    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)
     532        gc->inpa = gaim_input_add(gjc->fd, GAIM_INPUT_READ, jabber_callback, gc);
     533}
     534
     535static void gjab_connected_ssl(gpointer data, void *source, GaimInputCondition cond)
    540536{
    541537        struct gaim_connection *gc = data;
     
    548544        if (source == NULL) {
    549545                STATE_EVT(JCONN_STATE_OFF)
    550                 return FALSE;
     546                return;
    551547        }
    552548       
    553549        if (!g_slist_find(get_connections(), gc)) {
    554550                ssl_disconnect(source);
    555                 return FALSE;
     551                return;
    556552        }
    557553       
    558         return gjab_connected(data, gjc->fd, cond);
     554        gjab_connected(data, gjc->fd, cond);
    559555}
    560556
     
    15471543}
    15481544
    1549 static gboolean jabber_free(gpointer data, gint fd, b_input_condition cond)
     1545static gboolean jabber_free(gpointer data)
    15501546{
    15511547        struct jabber_data *jd = data;
     
    15921588        }
    15931589        if (gc->inpa)
    1594                 b_event_remove(gc->inpa);
     1590                gaim_input_remove(gc->inpa);
    15951591
    15961592        if(jd) {
    1597                 b_timeout_add(50, jabber_free, jd);
     1593                g_timeout_add(50, jabber_free, jd);
    15981594                if(jd->gjc != NULL)
    15991595                        xmlnode_free(jd->gjc->current);
  • protocols/msn/msn.h

    r68b518d6 rc53911e  
    146146
    147147/* ns.c */
    148 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond );
     148void msn_ns_connected( gpointer data, gint source, GaimInputCondition cond );
    149149
    150150/* msn_util.c */
     
    173173void msn_sb_to_chat( struct msn_switchboard *sb );
    174174void msn_sb_destroy( struct msn_switchboard *sb );
    175 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond );
     175void msn_sb_connected( gpointer data, gint source, GaimInputCondition cond );
  • protocols/msn/ns.c

    r68b518d6 rc53911e  
    3030#include "md5.h"
    3131
    32 static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond );
     32static void msn_ns_callback( gpointer data, gint source, GaimInputCondition cond );
    3333static int msn_ns_command( gpointer data, char **cmd, int num_parts );
    3434static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts );
     
    3636static void msn_auth_got_passport_id( struct passport_reply *rep );
    3737
    38 gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond )
     38void msn_ns_connected( gpointer data, gint source, GaimInputCondition cond )
    3939{
    4040        struct gaim_connection *gc = data;
     
    4343       
    4444        if( !g_slist_find( msn_connections, gc ) )
    45                 return FALSE;
     45                return;
    4646       
    4747        if( source == -1 )
     
    4949                hide_login_progress( gc, "Could not connect to server" );
    5050                signoff( gc );
    51                 return FALSE;
     51                return;
    5252        }
    5353       
     
    7575        if( msn_write( gc, s, strlen( s ) ) )
    7676        {
    77                 gc->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, gc );
     77                gc->inpa = gaim_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, gc );
    7878                set_login_progress( gc, 1, "Connected to server, waiting for reply" );
    7979        }
    80        
    81         return FALSE;
    8280}
    8381
    84 static gboolean msn_ns_callback( gpointer data, gint source, b_input_condition cond )
     82void msn_ns_callback( gpointer data, gint source, GaimInputCondition cond )
    8583{
    8684        struct gaim_connection *gc = data;
     
    9189                hide_login_progress( gc, "Error while reading from server" );
    9290                signoff( gc );
    93                
    94                 return FALSE;
    95         }
    96         else
    97                 return TRUE;
     91        }
    9892}
    9993
     
    136130                if( num_parts == 6 && strcmp( cmd[2], "NS" ) == 0 )
    137131                {
    138                         b_event_remove( gc->inpa );
     132                        gaim_input_remove( gc->inpa );
    139133                        gc->inpa = 0;
    140134                        closesocket( md->fd );
  • protocols/msn/sb.c

    r68b518d6 rc53911e  
    3030#include "md5.h"
    3131
    32 static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond );
     32static void msn_sb_callback( gpointer data, gint source, GaimInputCondition cond );
    3333static int msn_sb_command( gpointer data, char **cmd, int num_parts );
    3434static int msn_sb_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts );
     
    237237        }
    238238       
    239         if( sb->inp ) b_event_remove( sb->inp );
     239        if( sb->inp ) gaim_input_remove( sb->inp );
    240240        closesocket( sb->fd );
    241241       
     
    245245}
    246246
    247 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond )
     247void msn_sb_connected( gpointer data, gint source, GaimInputCondition cond )
    248248{
    249249        struct msn_switchboard *sb = data;
     
    254254        /* Are we still alive? */
    255255        if( !g_slist_find( msn_switchboards, sb ) )
    256                 return FALSE;
     256                return;
    257257       
    258258        gc = sb->gc;
     
    263263                debug( "ERROR %d while connecting to switchboard server", 1 );
    264264                msn_sb_destroy( sb );
    265                 return FALSE;
     265                return;
    266266        }
    267267       
     
    280280       
    281281        if( msn_sb_write( sb, buf, strlen( buf ) ) )
    282                 sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb );
     282                sb->inp = gaim_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb );
    283283        else
    284284                debug( "ERROR %d while connecting to switchboard server", 2 );
    285        
    286         return FALSE;
    287 }
    288 
    289 static gboolean msn_sb_callback( gpointer data, gint source, b_input_condition cond )
     285}
     286
     287static void msn_sb_callback( gpointer data, gint source, GaimInputCondition cond )
    290288{
    291289        struct msn_switchboard *sb = data;
     
    295293                debug( "ERROR: Switchboard died" );
    296294                msn_sb_destroy( sb );
    297                
    298                 return FALSE;
    299         }
    300         else
    301                 return TRUE;
     295        }
    302296}
    303297
  • protocols/nogaim.c

    r68b518d6 rc53911e  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2006 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2004 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    1313 * from scratch for BitlBee and doesn't contain any code from Gaim anymore
    1414 * (except for the function names).
     15 *
     16 * Copyright 2002-2006 Wilmer van der Gaast <wilmer@gaast.net> and others
    1517 */
    1618
     
    3537#include "nogaim.h"
    3638#include <ctype.h>
     39
     40static 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};
     51static char *proto_away_alias_find( GList *gcm, char *away );
    3752
    3853static int remove_chat_buddy_silent( struct conversation *b, char *handle );
     
    143158GSList *get_connections() { return connections; }
    144159
     160int 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                else
     176                {
     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        else
     190        {
     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                else
     199                        gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );
     200        }
     201       
     202        g_list_free( ms );
     203       
     204        return( 1 );
     205}
     206
     207static 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
    145237/* multi.c */
    146238
     
    158250         * This fixes daemon mode breakage where IRC doesn't point to the currently active connection.
    159251         */
    160         gc->irc = user->irc;
     252        gc->irc=user->irc;
    161253       
    162254        connections = g_slist_append( connections, gc );
     
    238330}
    239331
    240 static gboolean send_keepalive( gpointer d, gint fd, b_input_condition cond )
     332static gboolean send_keepalive( gpointer d )
    241333{
    242334        struct gaim_connection *gc = d;
     
    262354        serv_got_crap( gc, "Logged in" );
    263355       
    264         gc->keepalive = b_timeout_add( 60000, send_keepalive, gc );
     356        gc->keepalive = g_timeout_add( 60000, send_keepalive, gc );
    265357        gc->flags |= OPT_LOGGED_IN;
    266358       
    267359        /* Also necessary when we're not away, at least for some of the
    268360           protocols. */
    269         bim_set_away( gc, u->away );
    270 }
    271 
    272 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond )
     361        proto_away( gc, u->away );
     362}
     363
     364gboolean auto_reconnect( gpointer data )
    273365{
    274366        account_t *a = data;
     
    282374void cancel_auto_reconnect( account_t *a )
    283375{
    284         /* while( b_event_remove_by_data( (gpointer) a ) ); */
    285         b_event_remove( a->reconnect );
     376        while( g_source_remove_by_user_data( (gpointer) a ) );
    286377        a->reconnect = 0;
    287378}
     
    295386        serv_got_crap( gc, "Signing off.." );
    296387
    297         b_event_remove( gc->keepalive );
     388        gaim_input_remove( gc->keepalive );
    298389        gc->keepalive = 0;
    299390        gc->prpl->close( gc );
    300         b_event_remove( gc->inpa );
     391        gaim_input_remove( gc->inpa );
    301392       
    302393        while( u )
     
    325416        {
    326417                int delay = set_getint( irc, "auto_reconnect_delay" );
    327                
    328418                serv_got_crap( gc, "Reconnecting in %d seconds..", delay );
    329                 a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a );
     419               
     420                a->reconnect = 1;
     421                g_timeout_add( delay * 1000, auto_reconnect, a );
    330422        }
    331423       
     
    9391031}
    9401032
    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 )
     1033int serv_send_im( irc_t *irc, user_t *u, char *msg, int flags )
    9481034{
    9491035        char *buf = NULL;
    9501036        int st;
    9511037       
    952         if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
     1038        if( ( u->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )
    9531039        {
    9541040                buf = escape_html( msg );
     
    9561042        }
    9571043       
    958         st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );
     1044        st = ((struct gaim_connection *)u->gc)->prpl->send_im( u->gc, u->handle, msg, strlen( msg ), flags );
    9591045        g_free( buf );
    9601046       
     
    9621048}
    9631049
    964 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg )
     1050int serv_send_chat( irc_t *irc, struct gaim_connection *gc, int id, char *msg )
    9651051{
    9661052        char *buf = NULL;
     
    9781064        return st;
    9791065}
    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

    r68b518d6 rc53911e  
    5252#define BUDDY_ALIAS_MAXLEN 388   /* because MSN names can be 387 characters */
    5353
    54 #define WEBSITE "http://www.bitlbee.org/"
     54#define WEBSITE "http://www.bitlee.org/"
    5555#define IM_FLAG_AWAY 0x0020
    5656#define OPT_CONN_HTML 0x00000001
     
    194194
    195195/* nogaim.c */
    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 );
     196int serv_send_im(irc_t *irc, user_t *u, char *msg, int flags);
     197int serv_send_chat(irc_t *irc, struct gaim_connection *gc, int id, char *msg );
    204198
    205199void nogaim_init();
     200int proto_away( struct gaim_connection *gc, char *away );
    206201char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value );
    207202
    208 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond );
     203gboolean auto_reconnect( gpointer data );
    209204void cancel_auto_reconnect( struct account *a );
    210205
     
    215210G_MODULE_EXPORT void hide_login_progress( struct gaim_connection *gc, char *msg );
    216211G_MODULE_EXPORT void hide_login_progress_error( struct gaim_connection *gc, char *msg );
    217 G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
     212G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... );
    218213G_MODULE_EXPORT void account_online( struct gaim_connection *gc );
    219214G_MODULE_EXPORT void signoff( struct gaim_connection *gc );
  • protocols/oscar/aim.h

    r68b518d6 rc53911e  
    728728};
    729729
    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 
     730#define AIM_CHATFLAGS_NOREFLECT 0x0001
     731#define AIM_CHATFLAGS_AWAY      0x0002
    735732int aim_chat_send_im(aim_session_t *sess, aim_conn_t *conn, guint16 flags, const char *msg, int msglen);
    736733int aim_chat_join(aim_session_t *sess, aim_conn_t *conn, guint16 exchange, const char *roomname, guint16 instance);
  • protocols/oscar/chat.c

    r68b518d6 rc53911e  
    159159        if (flags & AIM_CHATFLAGS_AWAY)
    160160                aim_addtlvtochain_noval(&otl, 0x0007);
    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        
     161
    176162        /*
    177163         * SubTLV: Type 1: Message
  • protocols/oscar/im.c

    r68b518d6 rc53911e  
    14691469            case 0x9c:  /* ICQ 5 seems to send this */
    14701470                aim_send_im_ch2_statusmessage(sess, userinfo->sn, args->cookie,
    1471                         gc->away ? gc->away : "", sess->aim_icq_state, dc);
     1471                        gc->away, sess->aim_icq_state, dc);
    14721472                break;
    14731473
  • protocols/oscar/oscar.c

    r68b518d6 rc53911e  
    22 * gaim
    33 *
    4  * Some code copyright (C) 2002-2006, Jelmer Vernooij <jelmer@samba.org>
    5  *                                    and the BitlBee team.
    64 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
    75 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx>
     
    138136        int i, j;
    139137        char *x = strchr(name, '-');
    140         if (!x) return g_strdup(name);
     138        if (!x) return NULL;
    141139        x = strchr(++x, '-');
    142         if (!x) return g_strdup(name);
     140        if (!x) return NULL;
    143141        tmp = g_strdup(++x);
    144142
     
    255253static int msgerrreasonlen = 25;
    256254
    257 static gboolean oscar_callback(gpointer data, gint source,
    258                                 b_input_condition condition) {
     255static void oscar_callback(gpointer data, gint source,
     256                                GaimInputCondition condition) {
    259257        aim_conn_t *conn = (aim_conn_t *)data;
    260258        aim_session_t *sess = aim_conn_getsess(conn);
     
    264262        if (!gc) {
    265263                /* gc is null. we return, else we seg SIGSEG on next line. */
    266                 return FALSE;
     264                return;
    267265        }
    268266     
     
    270268                /* oh boy. this is probably bad. i guess the only thing we
    271269                 * can really do is return? */
    272                 return FALSE;
     270                return;
    273271        }
    274272
     
    290288                                c->conn = NULL;
    291289                                if (c->inpa > 0)
    292                                         b_event_remove(c->inpa);
     290                                        gaim_input_remove(c->inpa);
    293291                                c->inpa = 0;
    294292                                c->fd = -1;
     
    298296                        } else if (conn->type == AIM_CONN_TYPE_CHATNAV) {
    299297                                if (odata->cnpa > 0)
    300                                         b_event_remove(odata->cnpa);
     298                                        gaim_input_remove(odata->cnpa);
    301299                                odata->cnpa = 0;
    302300                                while (odata->create_rooms) {
     
    312310                        } else if (conn->type == AIM_CONN_TYPE_AUTH) {
    313311                                if (odata->paspa > 0)
    314                                         b_event_remove(odata->paspa);
     312                                        gaim_input_remove(odata->paspa);
    315313                                odata->paspa = 0;
    316314                                aim_conn_kill(odata->sess, &conn);
     
    319317                        }
    320318                }
    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)
     319        }
     320}
     321
     322static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond)
    330323{
    331324        struct gaim_connection *gc = data;
     
    336329        if (!g_slist_find(get_connections(), gc)) {
    337330                closesocket(source);
    338                 return FALSE;
     331                return;
    339332        }
    340333
     
    346339                hide_login_progress(gc, _("Couldn't connect to host"));
    347340                signoff(gc);
    348                 return FALSE;
     341                return;
    349342        }
    350343
    351344        aim_conn_completeconnect(sess, conn);
    352         gc->inpa = b_input_add(conn->fd, GAIM_INPUT_READ,
     345        gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ,
    353346                        oscar_callback, conn);
    354        
    355         return FALSE;
    356347}
    357348
     
    392383        if (g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.icq.com") != 0 &&
    393384            g_strcasecmp(user->proto_opt[USEROPT_AUTH], "login.oscar.aol.com") != 0) {
    394                 serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.",user->proto_opt[USEROPT_AUTH]);
     385                serv_got_crap(gc, "Warning: Unknown OSCAR server: `%s'. Please review your configuration if the connection fails.");
    395386        }
    396387       
     
    421412                struct chat_connection *n = odata->oscar_chats->data;
    422413                if (n->inpa > 0)
    423                         b_event_remove(n->inpa);
     414                        gaim_input_remove(n->inpa);
    424415                g_free(n->name);
    425416                g_free(n->show);
     
    440431                g_free(odata->oldp);
    441432        if (gc->inpa > 0)
    442                 b_event_remove(gc->inpa);
     433                gaim_input_remove(gc->inpa);
    443434        if (odata->cnpa > 0)
    444                 b_event_remove(odata->cnpa);
     435                gaim_input_remove(odata->cnpa);
    445436        if (odata->paspa > 0)
    446                 b_event_remove(odata->paspa);
     437                gaim_input_remove(odata->paspa);
    447438        aim_session_kill(odata->sess);
    448439        g_free(odata->sess);
     
    452443}
    453444
    454 static gboolean oscar_bos_connect(gpointer data, gint source, b_input_condition cond) {
     445static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) {
    455446        struct gaim_connection *gc = data;
    456447        struct oscar_data *odata;
     
    460451        if (!g_slist_find(get_connections(), gc)) {
    461452                closesocket(source);
    462                 return FALSE;
     453                return;
    463454        }
    464455
     
    470461                hide_login_progress(gc, _("Could Not Connect"));
    471462                signoff(gc);
    472                 return FALSE;
     463                return;
    473464        }
    474465
    475466        aim_conn_completeconnect(sess, bosconn);
    476         gc->inpa = b_input_add(bosconn->fd, GAIM_INPUT_READ,
     467        gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ,
    477468                        oscar_callback, bosconn);
    478469        set_login_progress(gc, 4, _("Connection established, cookie sent"));
    479        
    480         return FALSE;
    481470}
    482471
     
    581570        }
    582571        aim_sendcookie(sess, bosconn, info->cookie);
    583         b_event_remove(gc->inpa);
     572        gaim_input_remove(gc->inpa);
    584573
    585574        return 1;
     
    596585};
    597586
    598 static gboolean damn_you(gpointer data, gint source, b_input_condition c)
     587static void damn_you(gpointer data, gint source, GaimInputCondition c)
    599588{
    600589        struct pieceofcrap *pos = data;
     
    616605                do_error_dialog(pos->gc, "Gaim was unable to get a valid hash for logging into AIM."
    617606                                " You may be disconnected shortly.", "Login Error");
    618                 b_event_remove(pos->inpa);
     607                gaim_input_remove(pos->inpa);
    619608                closesocket(pos->fd);
    620609                g_free(pos);
    621                 return FALSE;
     610                return;
    622611        }
    623612        /* [WvG] Wheeeee! Who needs error checking anyway? ;-) */
    624613        read(pos->fd, m, 16);
    625614        m[16] = '\0';
    626         b_event_remove(pos->inpa);
     615        gaim_input_remove(pos->inpa);
    627616        closesocket(pos->fd);
    628617        aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH);
    629618        g_free(pos);
    630        
    631         return FALSE;
    632 }
    633 
    634 static gboolean straight_to_hell(gpointer data, gint source, b_input_condition cond) {
     619}
     620
     621static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) {
    635622        struct pieceofcrap *pos = data;
    636623        char buf[BUF_LONG];
     
    642629                        g_free(pos->modname);
    643630                g_free(pos);
    644                 return FALSE;
     631                return;
    645632        }
    646633
     
    651638        if (pos->modname)
    652639                g_free(pos->modname);
    653         pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);
    654         return FALSE;
     640        pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);
     641        return;
    655642}
    656643
     
    774761}
    775762
    776 static gboolean oscar_chatnav_connect(gpointer data, gint source, b_input_condition cond) {
     763static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) {
    777764        struct gaim_connection *gc = data;
    778765        struct oscar_data *odata;
     
    782769        if (!g_slist_find(get_connections(), gc)) {
    783770                closesocket(source);
    784                 return FALSE;
     771                return;
    785772        }
    786773
     
    791778        if (source < 0) {
    792779                aim_conn_kill(sess, &tstconn);
    793                 return FALSE;
     780                return;
    794781        }
    795782
    796783        aim_conn_completeconnect(sess, tstconn);
    797         odata->cnpa = b_input_add(tstconn->fd, GAIM_INPUT_READ,
     784        odata->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ,
    798785                                        oscar_callback, tstconn);
    799        
    800         return FALSE;
    801 }
    802 
    803 static gboolean oscar_auth_connect(gpointer data, gint source, b_input_condition cond)
     786}
     787
     788static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond)
    804789{
    805790        struct gaim_connection *gc = data;
     
    810795        if (!g_slist_find(get_connections(), gc)) {
    811796                closesocket(source);
    812                 return FALSE;
     797                return;
    813798        }
    814799
     
    819804        if (source < 0) {
    820805                aim_conn_kill(sess, &tstconn);
    821                 return FALSE;
     806                return;
    822807        }
    823808
    824809        aim_conn_completeconnect(sess, tstconn);
    825         odata->paspa = b_input_add(tstconn->fd, GAIM_INPUT_READ,
     810        odata->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ,
    826811                                oscar_callback, tstconn);
    827        
    828         return FALSE;
    829 }
    830 
    831 static gboolean oscar_chat_connect(gpointer data, gint source, b_input_condition cond)
     812}
     813
     814static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond)
    832815{
    833816        struct chat_connection *ccon = data;
     
    842825                g_free(ccon->name);
    843826                g_free(ccon);
    844                 return FALSE;
     827                return;
    845828        }
    846829
     
    854837                g_free(ccon->name);
    855838                g_free(ccon);
    856                 return FALSE;
     839                return;
    857840        }
    858841
    859842        aim_conn_completeconnect(sess, ccon->conn);
    860         ccon->inpa = b_input_add(tstconn->fd,
     843        ccon->inpa = gaim_input_add(tstconn->fd,
    861844                        GAIM_INPUT_READ,
    862845                        oscar_callback, tstconn);
    863846        odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon);
    864        
    865         return FALSE;
    866847}
    867848
     
    25192500        int ret;
    25202501        guint8 len = strlen(message);
    2521         guint16 flags;
    25222502        char *s;
    25232503       
     
    25282508                if (*s & 128)
    25292509                        break;
    2530        
    2531         flags = AIM_CHATFLAGS_NOREFLECT;
    2532        
     2510               
    25332511        /* Message contains high ASCII chars, time for some translation! */
    25342512        if (*s) {
     
    25372515                   If we can't, fall back to UTF16. */
    25382516                if ((ret = do_iconv("UTF-8", "ISO8859-1", message, s, len, BUF_LONG)) >= 0) {
    2539                         flags |= AIM_CHATFLAGS_ISO_8859_1;
    25402517                        len = ret;
    25412518                } else if ((ret = do_iconv("UTF-8", "UNICODEBIG", message, s, len, BUF_LONG)) >= 0) {
    2542                         flags |= AIM_CHATFLAGS_UNICODE;
    25432519                        len = ret;
    25442520                } else {
     
    25512527        }
    25522528               
    2553         ret = aim_chat_send_im(od->sess, ccon->conn, flags, s, len);
     2529        ret = aim_chat_send_im(od->sess, ccon->conn, AIM_CHATFLAGS_NOREFLECT, s, len);
    25542530               
    25552531        if (s != message) {     
     
    25822558        od->oscar_chats = g_slist_remove(od->oscar_chats, cc);
    25832559        if (cc->inpa > 0)
    2584                 b_event_remove(cc->inpa);
     2560                gaim_input_remove(cc->inpa);
    25852561        aim_conn_kill(od->sess, &cc->conn);
    25862562        g_free(cc->name);
     
    26242600        int ret;
    26252601        static int chat_id = 0;
    2626         char * chatname;
    2627        
    2628         chatname = g_strdup_printf("%s%d", gc->username, chat_id++);
     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++);
    26292605 
    26302606        ret = oscar_chat_join(gc, chatname);
  • protocols/proxy.c

    r68b518d6 rc53911e  
    2121 */
    2222
     23/* this is a little piece of code to handle proxy connection */
     24/* it is intended to : 1st handle http proxy, using the CONNECT command
     25 , 2nd provide an easy way to add socks support */
     26
    2327#define BITLBEE_CORE
    2428#include <stdio.h>
     
    4246#include "proxy.h"
    4347
     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
    4452char proxyhost[128] = "";
    4553int proxyport = 0;
     
    4957
    5058struct PHB {
    51         b_event_handler func, proxy_func;
     59        GaimInputFunction func, proxy_func;
    5260        gpointer data, proxy_data;
    5361        char *host;
     
    5664        gint inpa;
    5765};
     66
     67typedef struct _GaimIOClosure {
     68        GaimInputFunction function;
     69        guint result;
     70        gpointer data;
     71} GaimIOClosure;
    5872
    5973
     
    7892}
    7993
    80 static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition cond)
     94static void gaim_io_destroy(gpointer data)
     95{
     96        g_free(data);
     97}
     98
     99static 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
     114static void gaim_io_connected(gpointer data, gint source, GaimInputCondition cond)
    81115{
    82116        struct PHB *phb = data;
     
    88122        if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
    89123                closesocket(source);
    90                 b_event_remove(phb->inpa);
     124                gaim_input_remove(phb->inpa);
    91125                if( phb->proxy_func )
    92126                        phb->proxy_func(phb->proxy_data, -1, GAIM_INPUT_READ);
     
    95129                        g_free(phb);
    96130                }
    97                 return FALSE;
     131                return;
    98132        }
    99133#endif
    100134        sock_make_blocking(source);
    101         b_event_remove(phb->inpa);
     135        gaim_input_remove(phb->inpa);
    102136        if( phb->proxy_func )
    103137                phb->proxy_func(phb->proxy_data, source, GAIM_INPUT_READ);
     
    106140                g_free(phb);
    107141        }
    108        
    109         return FALSE;
    110142}
    111143
     
    126158
    127159        sock_make_nonblocking(fd);
    128        
    129         event_debug("proxy_connect_none( \"%s\", %d ) = %d\n", host, port, fd);
    130        
     160
    131161        if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0) {
    132162                if (sockerr_again()) {
    133                         phb->inpa = b_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb);
     163                        phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb);
    134164                        phb->fd = fd;
    135165                } else {
     
    149179#define HTTP_GOODSTRING2 "HTTP/1.1 200 Connection established"
    150180
    151 static gboolean http_canread(gpointer data, gint source, b_input_condition cond)
     181static void http_canread(gpointer data, gint source, GaimInputCondition cond)
    152182{
    153183        int nlc = 0;
     
    156186        char inputline[8192];
    157187
    158         b_event_remove(phb->inpa);
     188        gaim_input_remove(phb->inpa);
    159189
    160190        while ((pos < sizeof(inputline)-1) && (nlc != 2) && (read(source, &inputline[pos++], 1) == 1)) {
     
    171201                g_free(phb->host);
    172202                g_free(phb);
    173                 return FALSE;
     203                return;
    174204        }
    175205
     
    178208        g_free(phb->host);
    179209        g_free(phb);
    180        
    181         return FALSE;
    182 }
    183 
    184 static gboolean http_canwrite(gpointer data, gint source, b_input_condition cond)
     210        return;
     211}
     212
     213static void http_canwrite(gpointer data, gint source, GaimInputCondition cond)
    185214{
    186215        char cmd[384];
     
    189218        int error = ETIMEDOUT;
    190219        if (phb->inpa > 0)
    191                 b_event_remove(phb->inpa);
     220                gaim_input_remove(phb->inpa);
    192221        len = sizeof(error);
    193222        if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
     
    196225                g_free(phb->host);
    197226                g_free(phb);
    198                 return FALSE;
     227                return;
    199228        }
    200229        sock_make_blocking(source);
     
    207236                g_free(phb->host);
    208237                g_free(phb);
    209                 return FALSE;
     238                return;
    210239        }
    211240
     
    222251                        g_free(phb->host);
    223252                        g_free(phb);
    224                         return FALSE;
     253                        return;
    225254                }
    226255        }
     
    232261                g_free(phb->host);
    233262                g_free(phb);
    234                 return FALSE;
    235         }
    236 
    237         phb->inpa = b_input_add(source, GAIM_INPUT_READ, http_canread, phb);
    238        
    239         return FALSE;
     263                return;
     264        }
     265
     266        phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, http_canread, phb);
    240267}
    241268
     
    253280/* Connecting to SOCKS4 proxies */
    254281
    255 static gboolean s4_canread(gpointer data, gint source, b_input_condition cond)
     282static void s4_canread(gpointer data, gint source, GaimInputCondition cond)
    256283{
    257284        unsigned char packet[12];
    258285        struct PHB *phb = data;
    259286
    260         b_event_remove(phb->inpa);
     287        gaim_input_remove(phb->inpa);
    261288
    262289        memset(packet, 0, sizeof(packet));
     
    265292                g_free(phb->host);
    266293                g_free(phb);
    267                 return FALSE;
     294                return;
    268295        }
    269296
     
    272299        g_free(phb->host);
    273300        g_free(phb);
    274        
    275         return FALSE;
    276 }
    277 
    278 static gboolean s4_canwrite(gpointer data, gint source, b_input_condition cond)
     301}
     302
     303static void s4_canwrite(gpointer data, gint source, GaimInputCondition cond)
    279304{
    280305        unsigned char packet[12];
     
    284309        int error = ETIMEDOUT;
    285310        if (phb->inpa > 0)
    286                 b_event_remove(phb->inpa);
     311                gaim_input_remove(phb->inpa);
    287312        len = sizeof(error);
    288313        if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
     
    291316                g_free(phb->host);
    292317                g_free(phb);
    293                 return FALSE;
     318                return;
    294319        }
    295320        sock_make_blocking(source);
     
    301326                g_free(phb->host);
    302327                g_free(phb);
    303                 return FALSE;
     328                return;
    304329        }
    305330
     
    318343                g_free(phb->host);
    319344                g_free(phb);
    320                 return FALSE;
    321         }
    322 
    323         phb->inpa = b_input_add(source, GAIM_INPUT_READ, s4_canread, phb);
    324        
    325         return FALSE;
     345                return;
     346        }
     347
     348        phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s4_canread, phb);
    326349}
    327350
     
    339362/* Connecting to SOCKS5 proxies */
    340363
    341 static gboolean s5_canread_again(gpointer data, gint source, b_input_condition cond)
     364static void s5_canread_again(gpointer data, gint source, GaimInputCondition cond)
    342365{
    343366        unsigned char buf[512];
    344367        struct PHB *phb = data;
    345368
    346         b_event_remove(phb->inpa);
     369        gaim_input_remove(phb->inpa);
    347370
    348371        if (read(source, buf, 10) < 10) {
     
    351374                g_free(phb->host);
    352375                g_free(phb);
    353                 return FALSE;
     376                return;
    354377        }
    355378        if ((buf[0] != 0x05) || (buf[1] != 0x00)) {
     
    358381                g_free(phb->host);
    359382                g_free(phb);
    360                 return FALSE;
     383                return;
    361384        }
    362385
     
    364387        g_free(phb->host);
    365388        g_free(phb);
    366        
    367         return FALSE;
     389        return;
    368390}
    369391
     
    373395        struct PHB *phb = data;
    374396        int hlen = strlen(phb->host);
    375        
     397
    376398        buf[0] = 0x05;
    377399        buf[1] = 0x01;          /* CONNECT */
     
    391413        }
    392414
    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)
     415        phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_canread_again, phb);
     416}
     417
     418static void s5_readauth(gpointer data, gint source, GaimInputCondition cond)
    397419{
    398420        unsigned char buf[512];
    399421        struct PHB *phb = data;
    400422
    401         b_event_remove(phb->inpa);
     423        gaim_input_remove(phb->inpa);
    402424
    403425        if (read(source, buf, 2) < 2) {
     
    406428                g_free(phb->host);
    407429                g_free(phb);
    408                 return FALSE;
     430                return;
    409431        }
    410432
     
    414436                g_free(phb->host);
    415437                g_free(phb);
    416                 return FALSE;
     438                return;
    417439        }
    418440
    419441        s5_sendconnect(phb, source);
    420        
    421         return FALSE;
    422 }
    423 
    424 static gboolean s5_canread(gpointer data, gint source, b_input_condition cond)
     442}
     443
     444static void s5_canread(gpointer data, gint source, GaimInputCondition cond)
    425445{
    426446        unsigned char buf[512];
    427447        struct PHB *phb = data;
    428448
    429         b_event_remove(phb->inpa);
     449        gaim_input_remove(phb->inpa);
    430450
    431451        if (read(source, buf, 2) < 2) {
     
    434454                g_free(phb->host);
    435455                g_free(phb);
    436                 return FALSE;
     456                return;
    437457        }
    438458
     
    442462                g_free(phb->host);
    443463                g_free(phb);
    444                 return FALSE;
     464                return;
    445465        }
    446466
     
    457477                        g_free(phb->host);
    458478                        g_free(phb);
    459                         return FALSE;
     479                        return;
    460480                }
    461481
    462                 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_readauth, phb);
     482                phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_readauth, phb);
    463483        } else {
    464484                s5_sendconnect(phb, source);
    465485        }
    466        
    467         return FALSE;
    468 }
    469 
    470 static gboolean s5_canwrite(gpointer data, gint source, b_input_condition cond)
     486}
     487
     488static void s5_canwrite(gpointer data, gint source, GaimInputCondition cond)
    471489{
    472490        unsigned char buf[512];
     
    476494        int error = ETIMEDOUT;
    477495        if (phb->inpa > 0)
    478                 b_event_remove(phb->inpa);
     496                gaim_input_remove(phb->inpa);
    479497        len = sizeof(error);
    480498        if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
     
    483501                g_free(phb->host);
    484502                g_free(phb);
    485                 return FALSE;
     503                return;
    486504        }
    487505        sock_make_blocking(source);
     
    505523                g_free(phb->host);
    506524                g_free(phb);
    507                 return FALSE;
    508         }
    509 
    510         phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_canread, phb);
    511        
    512         return FALSE;
     525                return;
     526        }
     527
     528        phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, s5_canread, phb);
    513529}
    514530
     
    526542/* Export functions */
    527543
    528 int proxy_connect(const char *host, int port, b_event_handler func, gpointer data)
     544gint 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
     566void gaim_input_remove(gint tag)
     567{
     568        if (tag > 0)
     569                g_source_remove(tag);
     570}
     571
     572int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data)
    529573{
    530574        struct PHB *phb;
  • protocols/proxy.h

    r68b518d6 rc53911e  
    11/*
    2  * nogaim
     2 * gaim
    33 *
    44 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
     
    3636#include <gmodule.h>
    3737
    38 #include "events.h"
    39 
    4038#define PROXY_NONE 0
    4139#define PROXY_HTTP 1
     
    4947extern char proxypass[128];
    5048
    51 G_MODULE_EXPORT int proxy_connect(const char *host, int port, b_event_handler func, gpointer data);
     49typedef enum {
     50        GAIM_INPUT_READ = 1 << 0,
     51        GAIM_INPUT_WRITE = 1 << 1
     52} GaimInputCondition;
     53typedef void (*GaimInputFunction)(gpointer, gint, GaimInputCondition);
     54
     55G_MODULE_EXPORT gint gaim_input_add(int, GaimInputCondition, GaimInputFunction, gpointer);
     56G_MODULE_EXPORT void gaim_input_remove(gint);
     57
     58G_MODULE_EXPORT int proxy_connect(const char *host, int port, GaimInputFunction func, gpointer data);
    5259
    5360#endif /* _PROXY_H_ */
  • protocols/ssl_bogus.c

    r68b518d6 rc53911e  
    5252}
    5353
    54 b_input_condition ssl_getdirection( void *conn )
     54GaimInputCondition ssl_getdirection( void *conn )
    5555{
    5656        return GAIM_INPUT_READ;
  • protocols/ssl_client.h

    r68b518d6 rc53911e  
    3333extern int ssl_errno;
    3434
    35 typedef gboolean (*ssl_input_function)(gpointer, void*, b_input_condition);
     35typedef void (*ssl_input_function)(gpointer, void*, GaimInputCondition);
    3636
    3737G_MODULE_EXPORT void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data );
     
    4040G_MODULE_EXPORT void ssl_disconnect( void *conn_ );
    4141G_MODULE_EXPORT int ssl_getfd( void *conn );
    42 G_MODULE_EXPORT b_input_condition ssl_getdirection( void *conn );
     42G_MODULE_EXPORT GaimInputCondition ssl_getdirection( void *conn );
  • protocols/ssl_gnutls.c

    r68b518d6 rc53911e  
    4848};
    4949
    50 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond );
     50static void ssl_connected( gpointer data, gint source, GaimInputCondition cond );
    5151
    5252
     
    8181}
    8282
    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 )
     83static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond );
     84
     85static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )
    8686{
    8787        struct scd *conn = data;
     
    9696                g_free( conn );
    9797               
    98                 return FALSE;
     98                return;
    9999        }
    100100       
     
    102102        gnutls_transport_set_ptr( conn->session, (gnutls_transport_ptr) conn->fd );
    103103       
    104         return ssl_handshake( data, source, cond );
    105 }
    106 
    107 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond )
     104        ssl_handshake( data, source, cond );
     105}
     106
     107static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond )
    108108{
    109109        struct scd *conn = data;
    110110        int st;
    111111       
     112        if( conn->inpa != -1 )
     113        {
     114                gaim_input_remove( conn->inpa );
     115                conn->inpa = -1;
     116        }
     117       
    112118        if( ( st = gnutls_handshake( conn->session ) ) < 0 )
    113119        {
    114120                if( st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED )
    115121                {
    116                         conn->inpa = b_input_add( conn->fd, ssl_getdirection( conn ),
    117                                                   ssl_handshake, data );
     122                        conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ),
     123                                                     ssl_handshake, data );
    118124                }
    119125                else
     
    136142                conn->func( conn->data, conn, cond );
    137143        }
    138        
    139         return FALSE;
    140144}
    141145
     
    183187       
    184188        if( conn->inpa != -1 )
    185                 b_event_remove( conn->inpa );
     189                gaim_input_remove( conn->inpa );
    186190       
    187191        if( conn->established )
     
    200204}
    201205
    202 b_input_condition ssl_getdirection( void *conn )
     206GaimInputCondition ssl_getdirection( void *conn )
    203207{
    204208        return( gnutls_record_get_direction( ((struct scd*)conn)->session ) ?
  • protocols/ssl_nss.c

    r68b518d6 rc53911e  
    5252};
    5353
    54 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond );
     54static void ssl_connected( gpointer data, gint source, GaimInputCondition cond );
    5555
    5656
     
    116116}
    117117
    118 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond )
     118static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )
    119119{
    120120        struct scd *conn = data;
     
    140140        conn->established = TRUE;
    141141        conn->func( conn->data, conn, cond );
    142         return FALSE;
     142        return;
    143143       
    144144        ssl_connected_failure:
     
    149149        if( source >= 0 ) closesocket( source );
    150150        g_free( conn );
    151        
    152         return FALSE;
    153151}
    154152
     
    184182}
    185183
    186 b_input_condition ssl_getdirection( void *conn )
     184GaimInputCondition ssl_getdirection( void *conn )
    187185{
    188186        /* Just in case someone calls us, let's return the most likely case: */
  • protocols/ssl_openssl.c

    r68b518d6 rc53911e  
    5252};
    5353
    54 static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond );
     54static void ssl_connected( gpointer data, gint source, GaimInputCondition cond );
     55
    5556
    5657
     
    9495}
    9596
    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 )
     97static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond );
     98
     99static void ssl_connected( gpointer data, gint source, GaimInputCondition cond )
    99100{
    100101        struct scd *conn = data;
     
    103104                return ssl_handshake( data, -1, cond );
    104105       
    105         /* We can do at least the handshake with non-blocking I/O */
     106        /* Make it non-blocking at least during the handshake... */
    106107        sock_make_nonblocking( conn->fd );
    107108        SSL_set_fd( conn->ssl, conn->fd );
     
    110111}       
    111112
    112 static gboolean ssl_handshake( gpointer data, gint source, b_input_condition cond )
     113static void ssl_handshake( gpointer data, gint source, GaimInputCondition cond )
    113114{
    114115        struct scd *conn = data;
    115116        int st;
     117       
     118        if( conn->inpa != -1 )
     119        {
     120                gaim_input_remove( conn->inpa );
     121                conn->inpa = -1;
     122        }
    116123       
    117124        if( ( st = SSL_connect( conn->ssl ) ) < 0 )
     
    121128                        goto ssl_connected_failure;
    122129               
    123                 conn->inpa = b_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data );
    124                 return FALSE;
     130                conn->inpa = gaim_input_add( conn->fd, ssl_getdirection( conn ), ssl_handshake, data );
     131                return;
    125132        }
    126133       
     
    128135        sock_make_blocking( conn->fd );         /* For now... */
    129136        conn->func( conn->data, conn, cond );
    130         return FALSE;
     137        return;
    131138       
    132139ssl_connected_failure:
     
    144151        if( source >= 0 ) closesocket( source );
    145152        g_free( conn );
    146        
    147         return FALSE;
    148153}
    149154
     
    199204       
    200205        if( conn->inpa != -1 )
    201                 b_event_remove( conn->inpa );
     206                gaim_input_remove( conn->inpa );
    202207       
    203208        if( conn->established )
     
    216221}
    217222
    218 b_input_condition ssl_getdirection( void *conn )
     223GaimInputCondition ssl_getdirection( void *conn )
    219224{
    220225        return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ );
  • protocols/yahoo/yahoo.c

    r68b518d6 rc53911e  
    443443};
    444444
    445 void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond )
     445void byahoo_connect_callback( gpointer data, gint source, GaimInputCondition cond )
    446446{
    447447        struct byahoo_connect_callback_data *d = data;
     
    465465};
    466466
    467 gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_condition cond )
     467void byahoo_read_ready_callback( gpointer data, gint source, GaimInputCondition cond )
    468468{
    469469        struct byahoo_read_ready_data *d = data;
    470470       
    471471        if( !byahoo_get_gc_by_id( d->id ) )
     472        {
    472473                /* WTF doesn't libyahoo clean this up? */
    473                 return FALSE;
     474                ext_yahoo_remove_handler( d->id, d->tag );
     475                return;
     476        }
    474477       
    475478        yahoo_read_ready( d->id, d->fd, d->data );
    476        
    477         return TRUE;
    478479}
    479480
     
    486487};
    487488
    488 gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condition cond )
     489void byahoo_write_ready_callback( gpointer data, gint source, GaimInputCondition cond )
    489490{
    490491        struct byahoo_write_ready_data *d = data;
    491492       
    492493        if( !byahoo_get_gc_by_id( d->id ) )
     494        {
    493495                /* WTF doesn't libyahoo clean this up? */
    494                 return FALSE;
     496                ext_yahoo_remove_handler( d->id, d->tag );
     497                return;
     498        }
    495499       
    496500        yahoo_write_ready( d->id, d->fd, d->data );
    497        
    498         return FALSE;
    499501}
    500502
     
    685687               
    686688                inp->d = d;
    687                 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d );
     689                d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_READ, (GaimInputFunction) byahoo_read_ready_callback, (gpointer) d );
    688690        }
    689691        else if( cond == YAHOO_INPUT_WRITE )
     
    696698               
    697699                inp->d = d;
    698                 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d );
     700                d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_WRITE, (GaimInputFunction) byahoo_write_ready_callback, (gpointer) d );
    699701        }
    700702        else
     
    727729        }
    728730       
    729         b_event_remove( tag );
     731        gaim_input_remove( tag );
    730732}
    731733
     
    736738       
    737739        d = g_new0( struct byahoo_connect_callback_data, 1 );
    738         if( ( fd = proxy_connect( host, port, (b_event_handler) byahoo_connect_callback, (gpointer) d ) ) < 0 )
     740        if( ( fd = proxy_connect( host, port, (GaimInputFunction) byahoo_connect_callback, (gpointer) d ) ) < 0 )
    739741        {
    740742                g_free( d );
  • root_commands.c

    r68b518d6 rc53911e  
    5656                                cmd[k++] = s;
    5757                                s --;
    58                         }
    59                         else
    60                         {
    61                                 break;
    6258                        }
    6359                }
     
    558554        else
    559555        {
    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] );
     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] );
    563559        }
    564560}
     
    617613        else
    618614        {
    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] );
     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] );
    623619        }
    624620}
  • sock.h

    r68b518d6 rc53911e  
    1818#define sock_make_blocking(fd) fcntl(fd, F_SETFL, 0)
    1919#define sockerr_again() (errno == EINPROGRESS || errno == EINTR)
    20 #ifndef EVENTS_LIBEVENT
    2120#define closesocket(a) close(a)
    22 #endif
    2321#else
    2422# include <winsock2.h>
  • unix.c

    r68b518d6 rc53911e  
    4747        memset( &global, 0, sizeof( global_t ) );
    4848       
    49         b_main_init();
     49        global.loop = g_main_new( FALSE );
    5050       
    5151        log_init();
     
    117117                log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );
    118118       
    119         b_main_run();
     119        g_main_run( global.loop );
    120120       
    121121        if( global.restart )
     
    165165                       
    166166                        log_message( LOGLVL_ERROR, "SIGTERM received, cleaning up process." );
    167                         b_timeout_add( 1, (b_event_handler) bitlbee_shutdown, NULL );
     167                        g_timeout_add_full( G_PRIORITY_LOW, 1, (GSourceFunc) bitlbee_shutdown, NULL, NULL );
    168168                       
    169169                        first = 0;
  • user.c

    r68b518d6 rc53911e  
    109109                        if( u->handle ) g_free( u->handle );
    110110                        if( u->sendbuf ) g_free( u->sendbuf );
    111                         if( u->sendbuf_timer ) b_event_remove( u->sendbuf_timer );
     111                        if( u->sendbuf_timer ) g_source_remove( u->sendbuf_timer );
    112112                        g_free( u );
    113113                       
  • util.c

    r68b518d6 rc53911e  
    3939#include <glib.h>
    4040#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
    4741#include <iconv.h>
    48 #endif
    4942
    5043void strip_linefeed(gchar *text)
Note: See TracChangeset for help on using the changeset viewer.