Changes in / [ba7d16f:51a799e]


Ignore:
Files:
13 added
54 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    rba7d16f r51a799e  
    126126ctags:
    127127        ctags `find . -name "*.c"` `find . -name "*.h"`
     128
     129# Using this as a bogus Make target to test if a GNU-compatible version of
     130# make is available.
     131helloworld:
     132        @echo Hello World
  • bitlbee.c

    rba7d16f r51a799e  
    3636static gboolean bitlbee_io_new_client( gpointer data, gint fd, b_input_condition condition );
    3737
     38static gboolean try_listen( struct addrinfo *res )
     39{
     40        int i;
     41       
     42        global.listen_socket = socket( res->ai_family, res->ai_socktype, res->ai_protocol );
     43        if( global.listen_socket < 0 )
     44        {
     45                log_error( "socket" );
     46                return FALSE;
     47        }
     48
     49#ifdef IPV6_V6ONLY             
     50        if( res->ai_family == AF_INET6 )
     51        {
     52                i = 0;
     53                setsockopt( global.listen_socket, IPPROTO_IPV6, IPV6_V6ONLY,
     54                            (char *) &i, sizeof( i ) );
     55        }
     56#endif
     57
     58        /* TIME_WAIT (?) sucks.. */
     59        i = 1;
     60        setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i, sizeof( i ) );
     61
     62        i = bind( global.listen_socket, res->ai_addr, res->ai_addrlen );
     63        if( i == -1 )
     64        {
     65                closesocket( global.listen_socket );
     66                global.listen_socket = -1;
     67               
     68                log_error( "bind" );
     69                return FALSE;
     70        }
     71       
     72        return TRUE;
     73}
     74
    3875int bitlbee_daemon_init()
    3976{
     
    4279        FILE *fp;
    4380       
    44         log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG );
    45         log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG );
     81        log_link( LOGLVL_ERROR, LOGOUTPUT_CONSOLE );
     82        log_link( LOGLVL_WARNING, LOGOUTPUT_CONSOLE );
    4683       
    4784        memset( &hints, 0, sizeof( hints ) );
     
    63100
    64101        global.listen_socket = -1;
    65 
     102       
     103        /* Try IPv6 first (which will become an IPv6+IPv4 socket). */
    66104        for( res = addrinfo_bind; res; res = res->ai_next )
    67         {
    68                 global.listen_socket = socket( res->ai_family, res->ai_socktype, res->ai_protocol );
    69                 if( global.listen_socket < 0 )
    70                         continue;
    71 
    72                 /* TIME_WAIT (?) sucks.. */
    73                 i = 1;
    74                 setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i, sizeof( i ) );
    75 
    76                 i = bind( global.listen_socket, res->ai_addr, res->ai_addrlen );
    77                 if( i == -1 )
    78                 {
    79                         log_error( "bind" );
    80                         return( -1 );
    81                 }
    82 
    83                 break;
    84         }
    85 
     105                if( res->ai_family == AF_INET6 && try_listen( res ) )
     106                        break;
     107       
     108        /* The rest (so IPv4, I guess). */
     109        if( res == NULL )
     110                for( res = addrinfo_bind; res; res = res->ai_next )
     111                        if( res->ai_family != AF_INET6 && try_listen( res ) )
     112                                break;
     113       
    86114        freeaddrinfo( addrinfo_bind );
    87115
     
    93121        }
    94122       
    95         global.listen_watch_source_id = b_input_add( global.listen_socket, GAIM_INPUT_READ, bitlbee_io_new_client, NULL );
     123        global.listen_watch_source_id = b_input_add( global.listen_socket, B_EV_IO_READ, bitlbee_io_new_client, NULL );
    96124       
    97125#ifndef _WIN32
     
    107135                        exit( 0 );
    108136               
     137                setsid();
    109138                chdir( "/" );
    110139               
     
    137166#endif
    138167       
     168        if( !global.conf->nofork )
     169        {
     170                log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG );
     171                log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG );
     172        }
     173       
    139174        return( 0 );
    140175}
     
    286321                        child->pid = client_pid;
    287322                        child->ipc_fd = fds[0];
    288                         child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
     323                        child->ipc_inpa = b_input_add( child->ipc_fd, B_EV_IO_READ, ipc_master_read, child );
    289324                        child_list = g_slist_append( child_list, child );
    290325                       
     
    314349                        /* We can store the IPC fd there now. */
    315350                        global.listen_socket = fds[1];
    316                         global.listen_watch_source_id = b_input_add( fds[1], GAIM_INPUT_READ, ipc_child_read, irc );
     351                        global.listen_watch_source_id = b_input_add( fds[1], B_EV_IO_READ, ipc_child_read, irc );
    317352                       
    318353                        close( fds[0] );
  • bitlbee.h

    rba7d16f r51a799e  
    3535
    3636#define PACKAGE "BitlBee"
    37 #define BITLBEE_VERSION "1.2.5"
     37#define BITLBEE_VERSION "1.2.6a"
    3838#define VERSION BITLBEE_VERSION
     39#define BITLBEE_VER(a,b,c) (((a) << 16) + ((b) << 8) + (c))
     40#define BITLBEE_VERSION_CODE BITLBEE_VER(1, 2, 6)
    3941
    4042#define MAX_STRING 511
  • conf.c

    rba7d16f r51a799e  
    8282        }
    8383       
    84         while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:" ) ) >= 0 )
     84        while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:V" ) ) >= 0 )
    8585        /*     ^^^^ Just to make sure we skip this step from the REHASH handler. */
    8686        {
     
    148148                                "  -d  Specify alternative user configuration directory\n"
    149149                                "  -x  Command-line interface to password encryption/hashing\n"
    150                                 "  -h  Show this help page.\n" );
     150                                "  -h  Show this help page.\n"
     151                                "  -V  Show version info.\n" );
     152                        return NULL;
     153                }
     154                else if( opt == 'V' )
     155                {
     156                        printf( "BitlBee %s\nAPI version %06x\n",
     157                                BITLBEE_VERSION, BITLBEE_VERSION_CODE );
    151158                        return NULL;
    152159                }
  • configure

    rba7d16f r51a799e  
    2626oscar=1
    2727yahoo=1
     28twitter=1
     29purple=1
    2830
    2931debug=0
     
    6668--oscar=0/1     Disable/enable Oscar part (ICQ, AIM)    $oscar
    6769--yahoo=0/1     Disable/enable Yahoo part               $yahoo
     70--twitter=0/1 Disable/enable Twitter part               $twitter
     71
     72--purple=0/1    Disable/enable libpurple support        $purple
    6873
    6974--debug=0/1     Disable/enable debugging                $debug
     
    267272detect_ldap()
    268273{
    269         TMPFILE=$(mktemp)
     274        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
    270275        if $CC -o $TMPFILE -shared -lldap 2>/dev/null >/dev/null; then
    271276                cat<<EOF>>Makefile.settings
     
    295300detect_resolv_dynamic()
    296301{
    297         TMPFILE=$(mktemp)
     302        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
    298303        ret=1
    299304        echo "$RESOLV_TESTCODE" | $CC -o $TMPFILE -x c - -lresolv >/dev/null 2>/dev/null
     
    309314detect_resolv_static()
    310315{
    311         TMPFILE=$(mktemp)
     316        TMPFILE=$(mktemp /tmp/bitlbee-configure.XXXXXX)
    312317        ret=1
    313318        for i in $systemlibdirs; do
     
    476481fi
    477482
     483if ! make helloworld > /dev/null 2>&1; then
     484        echo "WARNING: Your version of make (BSD make?) does not support BitlBee's makefiles."
     485        echo "BitlBee needs GNU make to build properly. On most systems GNU make is available"
     486        echo "under the name 'gmake'."
     487        echo
     488        if gmake helloworld > /dev/null 2>&1; then
     489                echo "gmake seems to be available on your machine, great."
     490                echo
     491        else
     492                echo "gmake is not installed (or not working). Please try to install it."
     493                echo
     494        fi
     495fi
     496
    478497cat <<EOF>bitlbee.pc
    479498prefix=$prefix
     
    492511protoobjs=''
    493512
     513if [ "$purple" = 0 ]; then
     514        echo '#undef WITH_PURPLE' >> config.h
     515else
     516        if ! $PKG_CONFIG purple; then
     517                echo
     518                echo 'Cannot find libpurple development libraries, aborting. (Install libpurple-dev?)'
     519                exit 1
     520        fi
     521        echo '#define WITH_PURPLE' >> config.h
     522        cat<<EOF>>Makefile.settings
     523EFLAGS += $($PKG_CONFIG purple --libs)
     524PURPLE_CFLAGS += $($PKG_CONFIG purple --cflags)
     525EOF
     526        protocols=$protocols'purple '
     527        protoobjs=$protoobjs'purple_mod.o '
     528
     529        # Having both libpurple and native IM modules in one binary may
     530        # do strange things. Let's not do that.
     531        msn=0
     532        jabber=0
     533        oscar=0
     534        yahoo=0
     535        twitter=0
     536       
     537        if [ "$events" = "libevent" ]; then
     538                echo
     539                echo 'Warning: Some libpurple modules (including msn-pecan) do their event handling'
     540                echo 'outside libpurple, talking to GLib directly. At least for now the combination'
     541                echo 'libpurple + libevent is *not* recommended!'
     542        fi
     543fi
     544
    494545if [ "$msn" = 0 ]; then
    495546        echo '#undef WITH_MSN' >> config.h
     
    524575fi
    525576
     577if [ "$twitter" = 0 ]; then
     578        echo '#undef WITH_TWITTER' >> config.h
     579else
     580        echo '#define WITH_TWITTER' >> config.h
     581        protocols=$protocols'twitter '
     582        protoobjs=$protoobjs'twitter_mod.o '
     583fi
     584
    526585if [ "$protocols" = "PROTOCOLS = " ]; then
    527586        echo "Warning: You haven't selected any communication protocol to compile!"
  • dcc.c

    rba7d16f r51a799e  
    154154
    155155        /* watch */
    156         df->watch_in = b_input_add( df->fd, GAIM_INPUT_READ, dccs_send_proto, df );
     156        df->watch_in = b_input_add( df->fd, B_EV_IO_READ, dccs_send_proto, df );
    157157
    158158        df->ic->irc->file_transfers = g_slist_prepend( df->ic->irc->file_transfers, file );
     
    267267        file_transfer_t *file = df->ft;
    268268       
    269         if( ( cond & GAIM_INPUT_READ ) &&
     269        if( ( cond & B_EV_IO_READ ) &&
    270270            ( file->status & FT_STATUS_LISTENING ) )
    271271        {       
     
    287287
    288288                /* reschedule for reading on new fd */
    289                 df->watch_in = b_input_add( fd, GAIM_INPUT_READ, dccs_send_proto, df );
     289                df->watch_in = b_input_add( fd, B_EV_IO_READ, dccs_send_proto, df );
    290290
    291291                return FALSE;
    292292        }
    293293
    294         if( cond & GAIM_INPUT_READ )
     294        if( cond & B_EV_IO_READ )
    295295        {
    296296                int ret;
     
    364364
    365365        /* watch */
    366         df->watch_out = b_input_add( df->fd, GAIM_INPUT_WRITE, dccs_recv_proto, df );
     366        df->watch_out = b_input_add( df->fd, B_EV_IO_WRITE, dccs_recv_proto, df );
    367367        ft->write_request = dccs_recv_write_request;
    368368
     
    377377        file_transfer_t *ft = df->ft;
    378378
    379         if( ( cond & GAIM_INPUT_WRITE ) &&
     379        if( ( cond & B_EV_IO_WRITE ) &&
    380380            ( ft->status & FT_STATUS_CONNECTING ) )
    381381        {
    382382                ft->status = FT_STATUS_TRANSFERRING;
    383383
    384                 //df->watch_in = b_input_add( df->fd, GAIM_INPUT_READ, dccs_recv_proto, df );
     384                //df->watch_in = b_input_add( df->fd, B_EV_IO_READ, dccs_recv_proto, df );
    385385
    386386                df->watch_out = 0;
     
    388388        }
    389389
    390         if( cond & GAIM_INPUT_READ )
     390        if( cond & B_EV_IO_READ )
    391391        {
    392392                int ret, done;
     
    445445                return dcc_abort( df, "BUG: write_request() called while watching" );
    446446
    447         df->watch_in = b_input_add( df->fd, GAIM_INPUT_READ, dccs_recv_proto, df );
     447        df->watch_in = b_input_add( df->fd, B_EV_IO_READ, dccs_recv_proto, df );
    448448
    449449        return TRUE;
     
    488488
    489489        if( df->bytes_sent < df->ft->file_size )
    490                 df->watch_out = b_input_add( df->fd, GAIM_INPUT_WRITE, dccs_send_can_write, df );
     490                df->watch_out = b_input_add( df->fd, B_EV_IO_WRITE, dccs_send_can_write, df );
    491491
    492492        return TRUE;
  • debian/bitlbee.init

    rba7d16f r51a799e  
    3838d_start() {
    3939        # Make sure BitlBee can actually write its PID...
    40         touch /var/run/bitlbee.pid
    41         chown bitlbee: /var/run/bitlbee.pid
     40        touch $PIDFILE
     41        chown bitlbee: $PIDFILE
    4242       
    4343        start-stop-daemon --start --quiet --pidfile $PIDFILE \
  • debian/changelog

    rba7d16f r51a799e  
     1bitlbee (1.2.6a-1) unstable; urgency=low
     2
     3  * New upstream version.
     4  * Native support for Twitter.
     5  * Fixed /WHOIS response format. (Closes: #576120)
     6  * Problems with bitlbee-skype are solved by now. (Closes: #575572)
     7
     8 -- Wilmer van der Gaast <wilmer@peer.gaast.net>  Tue, 20 Apr 2010 00:34:51 +0200
     9
    110bitlbee (1.2.5-1) unstable; urgency=low
    211
  • debian/control

    rba7d16f r51a799e  
    55Uploaders: Jelmer Vernooij <jelmer@samba.org>
    66Standards-Version: 3.8.0
    7 Build-Depends: libglib2.0-dev (>= 2.4), libevent-dev, libgnutls-dev | libnss-dev (>= 1.6), debconf-2.0, po-debconf
     7Build-Depends: libglib2.0-dev (>= 2.4), libevent-dev, libgnutls-dev | libnss-dev (>= 1.6), debconf-2.0, po-debconf, libpurple-dev
    88Homepage: http://www.bitlbee.org/
    99Vcs-Bzr: http://code.bitlbee.org/bitlbee/
  • debian/rules

    rba7d16f r51a799e  
    11#!/usr/bin/make -f
    22
     3BITLBEE_CONFIGURE_FLAGS ?=
    34DEBUG ?= 0
    45
     
    1415build-arch-stamp:
    1516        [ -d debian ]
    16         ./configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent
     17        ./configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent $(BITLBEE_CONFIGURE_FLAGS)
    1718        $(MAKE)
    1819#       $(MAKE) -C doc/ all
     
    99100                find usr -type f -exec md5sum {} \; > DEBIAN/md5sums
    100101
    101         dpkg-gencontrol -ldebian/changelog -isp -pbitlbee-dev -Pdebian/bitlbee-dev
     102        dpkg-gencontrol -ldebian/changelog -isp -pbitlbee-dev -Pdebian/bitlbee-dev -v1:$(BITLBEE_VERSION)-0
    102103
    103104        dpkg --build debian/bitlbee-dev ..
  • doc/CHANGES

    rba7d16f r51a799e  
    33
    44http://bugs.bitlbee.org/bitlbee/timeline?daysback=90&changeset=on
     5
     6Version 1.2.6a:
     7- Fixed a typo that renders the Twitter groupchat mode unusable. A last-
     8  minute change that came a few minutes late.
     9
     10Finished 19 Apr 2010
     11
     12Version 1.2.6:
     13- Native (very basic) support for Twitter, implemented by Geert Mulders.
     14  Currently supported are posting tweets, reading the ones of people you
     15  follow, and sending (not yet receiving!) direct messages.
     16- Fixed format of status messages in /WHOIS to improve IRC client
     17  compatibility.
     18- Show timestamps of offline messages/channel backlogs.
     19- Allow saving MSN display names locally since sometimes this stuff breaks
     20  server-side. (Use the local_display_name per-account setting.)
     21- Suppress empty "Headline:" messages for certain new XMPP broadcast
     22  messages.
     23- Better handling of XMPP contacts with multiple resources on-line. Default
     24  behaviour now is to write to wherever the last message came from, or to
     25  the bare JID (usually becomes a broadcast) if there wasn't any recent msg.
     26- Added a switchboard_keepalives setting which should solve some issues with
     27  talking to offline MSN contacts. (Although full support for offline
     28  messages is not ready yet!)
     29- The usual misc. bug fixes.
     30
     31Finished 19 Apr 2010
    532
    633Version 1.2.5:
     
    2350  the main client).
    2451
    25 Fixed 17 Mar 2010
     52Finished 17 Mar 2010
    2653
    2754Version 1.2.4:
  • doc/user-guide/commands.xml

    rba7d16f r51a799e  
    2121                        <description>
    2222                                <para>
    23                                         Adds an account on the given server with the specified protocol, username and password to the account list. Supported protocols right now are: Jabber, MSN, OSCAR (AIM/ICQ) and Yahoo. For more information about adding an account, see <emphasis>help account add &lt;protocol&gt;</emphasis>.
     23                                        Adds an account on the given server with the specified protocol, username and password to the account list. Supported protocols right now are: Jabber, MSN, OSCAR (AIM/ICQ), Yahoo and Twitter. For more information about adding an account, see <emphasis>help account add &lt;protocol&gt;</emphasis>.
    2424                                </para>
    2525                        </description>
     
    6363                                </ircexample>
    6464                        </bitlbee-command>
     65                       
     66                        <bitlbee-command name="twitter">
     67                                <syntax>account add twitter &lt;handle&gt; &lt;password&gt;</syntax>
     68
     69                                <description>
     70                                        <para>
     71                                                This module gives you simple access to Twitter. Although it uses the Twitter API, only Twitter itself is supported at the moment.
     72                                        </para>
     73                                       
     74                                        <para>
     75                                                By default all your Twitter contacts will come from a contact called twitter_(yourusername). You can change this behaviour using the <emphasis>mode</emphasis> setting (see <emphasis>help set mode</emphasis>).
     76                                        </para>
     77                                       
     78                                        <para>
     79                                                To send tweets yourself, send them to the twitter_(yourusername) contact, or just write in the groupchat channel if you enabled that option.
     80                                        </para>
     81
     82                                        <para>
     83                                                Since Twitter now requires OAuth authentication, you should not enter your Twitter password into BitlBee. Just type a bogus password. The first time you log in, BitlBee will start OAuth authentication. (See <emphasis>help set oauth</emphasis>.)
     84                                        </para>
     85                                </description>
     86                        </bitlbee-command>
    6587
    6688                        <bitlbee-command name="yahoo">
     
    401423
    402424        <bitlbee-setting name="auto_reconnect" type="boolean" scope="both">
    403                 <default>false</default>
     425                <default>true</default>
    404426
    405427                <description>
     
    556578                        <para>
    557579                                With this option enabled, root will inform you when someone in your buddy list changes his/her "friendly name".
     580                        </para>
     581                </description>
     582        </bitlbee-setting>
     583
     584        <bitlbee-setting name="display_timestamps" type="boolean" scope="global">
     585                <default>true</default>
     586
     587                <description>
     588                        <para>
     589                                When incoming messages are old (i.e. offline messages and channel backlogs), BitlBee will prepend them with a timestamp. If you find them ugly or useless, you can use this setting to hide them.
    558590                        </para>
    559591                </description>
     
    609641        </bitlbee-setting>
    610642
     643        <bitlbee-setting name="local_display_name" type="boolean" scope="account">
     644                <default>false</default>
     645
     646                <description>
     647                        <para>
     648                                Mostly meant to work around a bug in MSN servers (forgetting the display name set by the user), this setting tells BitlBee to store your display name locally and set this name on the MSN servers when connecting.
     649                        </para>
     650                </description>
     651
     652        </bitlbee-setting>
     653
    611654        <bitlbee-setting name="mail_notifications" type="boolean" scope="account">
    612655                <default>false</default>
     
    615658                        <para>
    616659                                Some protocols (MSN, Yahoo!) can notify via IM about new e-mail. Since most people use their Hotmail/Yahoo! addresses as a spam-box, this is disabled default. If you want these notifications, you can enable this setting.
     660                        </para>
     661                </description>
     662
     663        </bitlbee-setting>
     664
     665        <bitlbee-setting name="message_length" type="integer" scope="account">
     666                <default>140</default>
     667
     668                <description>
     669                        <para>
     670                                Since Twitter rejects messages longer than 140 characters, BitlBee can count message length and emit a warning instead of waiting for Twitter to reject it.
     671                        </para>
     672
     673                        <para>
     674                                You can change this limit here but this won't disable length checks on Twitter's side. You can also set it to 0 to disable the check in case you believe BitlBee doesn't count the characters correctly.
     675                        </para>
     676                </description>
     677
     678        </bitlbee-setting>
     679
     680        <bitlbee-setting name="mode" type="string" scope="account">
     681                <possible-values>one, many, chat</possible-values>
     682                <default>one</default>
     683
     684                <description>
     685                        <para>
     686                                By default, everything from the Twitter module will come from one nick, twitter_(yourusername). If you prefer to have individual nicks for everyone, you can set this setting to "many" instead.
     687                        </para>
     688                       
     689                        <para>
     690                                If you prefer to have all your Twitter things in a separate channel, you can set this setting to "chat".
     691                        </para>
     692                       
     693                        <para>
     694                                In the last two modes, you can send direct messages by /msg'ing your contacts directly. Note, however, that incoming DMs are not fetched yet.
    617695                        </para>
    618696                </description>
     
    644722        </bitlbee-setting>
    645723
     724        <bitlbee-setting name="oauth" type="boolean" scope="account">
     725                <default>true</default>
     726
     727                <description>
     728                        <para>
     729                                This enables OAuth authentication for Twitter accounts. From June 2010 this will be mandatory.
     730                        </para>
     731
     732                        <para>
     733                                With OAuth enabled, you shouldn't tell BitlBee your Twitter password. Just add your account with a bogus password and type <emphasis>account on</emphasis>. BitlBee will then give you a URL to authenticate with Twitter. If this succeeds, Twitter will return a PIN code which you can give back to BitlBee to finish the process.
     734                        </para>
     735
     736                        <para>
     737                                The resulting access token will be saved permanently, so you have to do this only once.
     738                        </para>
     739                </description>
     740
     741        </bitlbee-setting>
     742
    646743        <bitlbee-setting name="ops" type="string" scope="global">
    647744                <default>both</default>
     
    779876        </bitlbee-setting>
    780877
     878        <bitlbee-setting name="show_offline" type="boolean" scope="global">
     879                <default>false</default>
     880
     881                <description>
     882                        <para>
     883                                If enabled causes BitlBee to also show offline users in Channel. Online-users will get op, away-users voice and offline users none of both. This option takes effect as soon as you reconnect.
     884                        </para>
     885                </description>
     886        </bitlbee-setting>
     887
    781888        <bitlbee-setting name="simulate_netsplit" type="boolean" scope="global">
    782889                <default>true</default>
     
    824931                        <para>
    825932                                If BitlBee fails to detect this sometimes (most likely in AIM messages over an ICQ connection), you can set this setting to <emphasis>always</emphasis>, but this might sometimes accidentally strip non-HTML things too.
     933                        </para>
     934                </description>
     935        </bitlbee-setting>
     936
     937        <bitlbee-setting name="switchboard_keepalives" type="boolean" scope="account">
     938                <default>false</default>
     939
     940                <description>
     941                        <para>
     942                                Turn on this flag if you have difficulties talking to offline/invisible contacts.
     943                        </para>
     944                       
     945                        <para>
     946                                With this setting enabled, BitlBee will send keepalives to MSN switchboards with offline/invisible contacts every twenty seconds. This should keep the server and client on the other side from shutting it down.
     947                        </para>
     948                       
     949                        <para>
     950                                This is useful because BitlBee doesn't support MSN offline messages yet and the MSN servers won't let the user reopen switchboards to offline users. Once offline messaging is supported, this flag might be removed.
     951                        </para>
     952                </description>
     953        </bitlbee-setting>
     954
     955        <bitlbee-setting name="timezone" type="string" scope="global">
     956                <default>local</default>
     957                <possible-values>local, utc, gmt, timezone-spec</possible-values>
     958
     959                <description>
     960                        <para>
     961                                If message timestamps are available for offline messages or chatroom backlogs, BitlBee will display them as part of the message. By default it will use the local timezone. If you're not in the same timezone as the BitlBee server, you can adjust the timestamps using this setting.
     962                        </para>
     963
     964                        <para>
     965                                Values local/utc/gmt should be self-explanatory. timezone-spec is a time offset in hours:minutes, for example: -8 for Pacific Standard Time, +2 for Central European Summer Time, +5:30 for Indian Standard Time.
    826966                        </para>
    827967                </description>
  • help.c

    rba7d16f r51a799e  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2005 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2009 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    169169        return NULL;
    170170}
     171
     172int help_add_mem( help_t **help, const char *title, const char *content )
     173{
     174        help_t *h, *l = NULL;
     175       
     176        for( h = *help; h; h = h->next )
     177        {
     178                if( g_strcasecmp( h->title, title ) == 0 )
     179                        return 0;
     180               
     181                l = h;
     182        }
     183       
     184        if( l )
     185                h = l->next = g_new0( struct help, 1 );
     186        else
     187                *help = h = g_new0( struct help, 1 );
     188        h->fd = -1;
     189        h->title = g_strdup( title );
     190        h->length = strlen( content );
     191        h->offset.mem_offset = g_strdup( content );
     192       
     193        return 1;
     194}
  • help.h

    rba7d16f r51a799e  
    4646void help_free( help_t **help );
    4747char *help_get( help_t **help, char *title );
     48int help_add_mem( help_t **help, const char *title, const char *content_ );
    4849
    4950#endif
  • ipc.c

    rba7d16f r51a799e  
    514514        }
    515515               
    516         child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
     516        child->ipc_inpa = b_input_add( child->ipc_fd, B_EV_IO_READ, ipc_master_read, child );
    517517       
    518518        child_list = g_slist_append( child_list, child );
     
    552552        }
    553553       
    554         b_input_add( serversock, GAIM_INPUT_READ, new_ipc_client, NULL );
     554        b_input_add( serversock, B_EV_IO_READ, new_ipc_client, NULL );
    555555       
    556556        return 1;
     
    597597                        return 0;
    598598                }
    599                 child->ipc_inpa = b_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
     599                child->ipc_inpa = b_input_add( child->ipc_fd, B_EV_IO_READ, ipc_master_read, child );
    600600               
    601601                child_list = g_slist_append( child_list, child );
  • irc.c

    rba7d16f r51a799e  
    5252{
    5353        irc_t *irc = set->data;
     54        char *test;
     55        gsize test_bytes = 0;
    5456        GIConv ic, oc;
    5557
     
    5759                value = g_strdup( "utf-8" );
    5860
     61        if( ( oc = g_iconv_open( value, "utf-8" ) ) == (GIConv) -1 )
     62        {
     63                return NULL;
     64        }
     65       
     66        /* Do a test iconv to see if the user picked an IRC-compatible
     67           charset (for example utf-16 goes *horribly* wrong). */
     68        if( ( test = g_convert_with_iconv( " ", 1, oc, NULL, &test_bytes, NULL ) ) == NULL ||
     69            test_bytes > 1 )
     70        {
     71                g_free( test );
     72                g_iconv_close( oc );
     73                irc_usermsg( irc, "Unsupported character set: The IRC protocol "
     74                                  "only supports 8-bit character sets." );
     75                return NULL;
     76        }
     77        g_free( test );
     78       
    5979        if( ( ic = g_iconv_open( "utf-8", value ) ) == (GIConv) -1 )
    6080        {
    61                 return NULL;
    62         }
    63         if( ( oc = g_iconv_open( value, "utf-8" ) ) == (GIConv) -1 )
    64         {
    65                 g_iconv_close( ic );
     81                g_iconv_close( oc );
    6682                return NULL;
    6783        }
     
    109125        sock_make_nonblocking( irc->fd );
    110126       
    111         irc->r_watch_source_id = b_input_add( irc->fd, GAIM_INPUT_READ, bitlbee_io_current_client_read, irc );
     127        irc->r_watch_source_id = b_input_add( irc->fd, B_EV_IO_READ, bitlbee_io_current_client_read, irc );
    112128       
    113129        irc->status = USTATUS_OFFLINE;
     
    175191        s = set_add( &irc->set, "default_target", "root", NULL, irc );
    176192        s = set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc );
     193        s = set_add( &irc->set, "display_timestamps", "true", set_eval_bool, irc );
    177194        s = set_add( &irc->set, "handle_unknown", "root", NULL, irc );
    178195        s = set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc );
     
    184201        s = set_add( &irc->set, "root_nick", irc->mynick, set_eval_root_nick, irc );
    185202        s = set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc );
     203        s = set_add( &irc->set, "show_offline", "false", set_eval_bool, irc );
    186204        s = set_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc );
    187205        s = set_add( &irc->set, "status", NULL,  set_eval_away_status, irc );
    188206        s->flags |= SET_NULL_OK;
    189207        s = set_add( &irc->set, "strip_html", "true", NULL, irc );
     208        s = set_add( &irc->set, "timezone", "local", set_eval_timezone, irc );
    190209        s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc );
    191210        s = set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc );
     
    195214        /* Evaluator sets the iconv/oconv structures. */
    196215        set_eval_charset( set_find( &irc->set, "charset" ), set_getstr( &irc->set, "charset" ) );
     216       
     217        nogaim_init();
    197218       
    198219        return( irc );
     
    677698                   in the event queue. */
    678699                /* Really can't be done as long as the code doesn't do error checking very well:
    679                 if( bitlbee_io_current_client_write( irc, irc->fd, GAIM_INPUT_WRITE ) ) */
     700                if( bitlbee_io_current_client_write( irc, irc->fd, B_EV_IO_WRITE ) ) */
    680701               
    681702                /* So just always do it via the event handler. */
    682                 irc->w_watch_source_id = b_input_add( irc->fd, GAIM_INPUT_WRITE, bitlbee_io_current_client_write, irc );
     703                irc->w_watch_source_id = b_input_add( irc->fd, B_EV_IO_WRITE, bitlbee_io_current_client_write, irc );
    683704        }
    684705       
     
    706727                if( now )
    707728                {
    708                         bitlbee_io_current_client_write( irc, irc->fd, GAIM_INPUT_WRITE );
     729                        bitlbee_io_current_client_write( irc, irc->fd, B_EV_IO_WRITE );
    709730                }
    710731                temp = temp->next;
  • irc_commands.c

    rba7d16f r51a799e  
    498498                        irc_reply( irc, 301, "%s :%s", u->nick, u->away );
    499499                if( u->status_msg )
    500                         irc_reply( irc, 333, "%s :Status: %s", u->nick, u->status_msg );
     500                        irc_reply( irc, 320, "%s :%s", u->nick, u->status_msg );
    501501               
    502502                irc_reply( irc, 318, "%s :End of /WHOIS list", nick );
  • lib/Makefile

    rba7d16f r51a799e  
    1010
    1111# [SH] Program variables
    12 objects = arc.o base64.o $(EVENT_HANDLER) http_client.o ini.o md5.o misc.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o ftutil.o
     12objects = arc.o base64.o $(EVENT_HANDLER) ftutil.o http_client.o ini.o md5.o misc.o oauth.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o
    1313
    1414CFLAGS += -Wall
  • lib/events.h

    rba7d16f r51a799e  
    4848   the given callback function. */
    4949typedef enum {
    50         GAIM_INPUT_READ = 1 << 1,
    51         GAIM_INPUT_WRITE = 1 << 2
     50        B_EV_IO_READ = 1 << 0,
     51        B_EV_IO_WRITE = 1 << 1,
     52        B_EV_FLAG_FORCE_ONCE = 1 << 16,
     53        B_EV_FLAG_FORCE_REPEAT = 1 << 17,
    5254} b_input_condition;
    5355typedef gboolean (*b_event_handler)(gpointer data, gint fd, b_input_condition cond);
  • lib/events_glib.c

    rba7d16f r51a799e  
    4949        b_event_handler function;
    5050        gpointer data;
     51        guint flags;
    5152} GaimIOClosure;
    5253
     
    7677
    7778        if (condition & GAIM_READ_COND)
    78                 gaim_cond |= GAIM_INPUT_READ;
     79                gaim_cond |= B_EV_IO_READ;
    7980        if (condition & GAIM_WRITE_COND)
    80                 gaim_cond |= GAIM_INPUT_WRITE;
     81                gaim_cond |= B_EV_IO_WRITE;
    8182       
    8283        event_debug( "gaim_io_invoke( %d, %d, 0x%x )\n", g_io_channel_unix_get_fd(source), condition, data );
     
    8788                event_debug( "Returned FALSE, cancelling.\n" );
    8889       
    89         return st;
     90        if (closure->flags & B_EV_FLAG_FORCE_ONCE)
     91                return FALSE;
     92        else if (closure->flags & B_EV_FLAG_FORCE_REPEAT)
     93                return TRUE;
     94        else
     95                return st;
    9096}
    9197
     
    105111        closure->function = function;
    106112        closure->data = data;
     113        closure->flags = condition;
    107114       
    108         if (condition & GAIM_INPUT_READ)
     115        if (condition & B_EV_IO_READ)
    109116                cond |= GAIM_READ_COND;
    110         if (condition & GAIM_INPUT_WRITE)
     117        if (condition & B_EV_IO_WRITE)
    111118                cond |= GAIM_WRITE_COND;
    112119       
  • lib/events_libevent.c

    rba7d16f r51a799e  
    6060        b_event_handler function;
    6161        void *data;
     62        guint flags;
    6263};
    6364
     
    126127        {
    127128                if( event & EV_READ )
    128                         cond |= GAIM_INPUT_READ;
     129                        cond |= B_EV_IO_READ;
    129130                if( event & EV_WRITE )
    130                         cond |= GAIM_INPUT_WRITE;
     131                        cond |= B_EV_IO_WRITE;
    131132        }
    132133       
     
    150151                return;
    151152        }
    152         else if( !st )
     153        else if( !st && !( b_ev->flags & B_EV_FLAG_FORCE_REPEAT ) )
    153154        {
    154155                event_debug( "Handler returned FALSE: " );
     
    174175        event_debug( "b_input_add( %d, %d, 0x%x, 0x%x ) ", fd, condition, function, data );
    175176       
    176         if( ( condition & GAIM_INPUT_READ  && ( b_ev = g_hash_table_lookup( read_hash,  &fd ) ) ) ||
    177             ( condition & GAIM_INPUT_WRITE && ( b_ev = g_hash_table_lookup( write_hash, &fd ) ) ) )
     177        if( ( condition & B_EV_IO_READ  && ( b_ev = g_hash_table_lookup( read_hash,  &fd ) ) ) ||
     178            ( condition & B_EV_IO_WRITE && ( b_ev = g_hash_table_lookup( write_hash, &fd ) ) ) )
    178179        {
    179180                /* We'll stick with this libevent entry, but give it a new BitlBee id. */
     
    198199               
    199200                out_cond = EV_PERSIST;
    200                 if( condition & GAIM_INPUT_READ )
     201                if( condition & B_EV_IO_READ )
    201202                        out_cond |= EV_READ;
    202                 if( condition & GAIM_INPUT_WRITE )
     203                if( condition & B_EV_IO_WRITE )
    203204                        out_cond |= EV_WRITE;
    204205               
     
    212213        }
    213214       
     215        b_ev->flags = condition;
    214216        g_hash_table_insert( id_hash, &b_ev->id, b_ev );
    215217        return b_ev->id;
  • lib/http_client.c

    rba7d16f r51a799e  
    149149        if( req->bytes_written < req->request_length )
    150150                req->inpa = b_input_add( source,
    151                                          req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_WRITE,
     151                                         req->ssl ? ssl_getdirection( req->ssl ) : B_EV_IO_WRITE,
    152152                                         http_connected, req );
    153153        else
    154                 req->inpa = b_input_add( source, GAIM_INPUT_READ, http_incoming_data, req );
     154                req->inpa = b_input_add( source, B_EV_IO_READ, http_incoming_data, req );
    155155       
    156156        return FALSE;
     
    234234        /* There will be more! */
    235235        req->inpa = b_input_add( req->fd,
    236                                  req->ssl ? ssl_getdirection( req->ssl ) : GAIM_INPUT_READ,
     236                                 req->ssl ? ssl_getdirection( req->ssl ) : B_EV_IO_READ,
    237237                                 http_incoming_data, req );
    238238       
  • lib/misc.c

    rba7d16f r51a799e  
    7777       
    7878        return mktime(&tm);
     79}
     80
     81time_t mktime_utc( struct tm *tp )
     82{
     83        struct tm utc;
     84        time_t res, tres;
     85       
     86        tp->tm_isdst = -1;
     87        res = mktime( tp );
     88        /* Problem is, mktime() just gave us the GMT timestamp for the
     89           given local time... While the given time WAS NOT local. So
     90           we should fix this now.
     91           
     92           Now I could choose between messing with environment variables
     93           (kludgy) or using timegm() (not portable)... Or doing the
     94           following, which I actually prefer...
     95           
     96           tzset() may also work but in other places I actually want to
     97           use local time.
     98           
     99           FFFFFFFFFFFFFFFFFFFFFUUUUUUUUUUUUUUUUUUUU!! */
     100        gmtime_r( &res, &utc );
     101        utc.tm_isdst = -1;
     102        if( utc.tm_hour == tp->tm_hour && utc.tm_min == tp->tm_min )
     103                /* Sweet! We're in UTC right now... */
     104                return res;
     105       
     106        tres = mktime( &utc );
     107        res += res - tres;
     108       
     109        /* Yes, this is a hack. And it will go wrong around DST changes.
     110           BUT this is more likely to be threadsafe than messing with
     111           environment variables, and possibly more portable... */
     112       
     113        return res;
    79114}
    80115
     
    271306        for( i = j = 0; t[i]; i ++, j ++ )
    272307        {
    273                 /* if( t[i] <= ' ' || ((unsigned char *)t)[i] >= 128 || t[i] == '%' ) */
    274                 if( !isalnum( t[i] ) )
     308                if( !isalnum( t[i] ) && !strchr( "._-~", t[i] ) )
    275309                {
    276310                        sprintf( s + j, "%%%02X", ((unsigned char*)t)[i] );
  • lib/misc.h

    rba7d16f r51a799e  
    4343
    4444G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec );
     45G_MODULE_EXPORT time_t mktime_utc( struct tm *tp );
    4546double gettime( void );
    4647
  • lib/proxy.c

    rba7d16f r51a799e  
    9191                b_event_remove(phb->inpa);
    9292                if( phb->proxy_func )
    93                         phb->proxy_func(phb->proxy_data, -1, GAIM_INPUT_READ);
     93                        phb->proxy_func(phb->proxy_data, -1, B_EV_IO_READ);
    9494                else {
    95                         phb->func(phb->data, -1, GAIM_INPUT_READ);
     95                        phb->func(phb->data, -1, B_EV_IO_READ);
    9696                        g_free(phb);
    9797                }
     
    102102        b_event_remove(phb->inpa);
    103103        if( phb->proxy_func )
    104                 phb->proxy_func(phb->proxy_data, source, GAIM_INPUT_READ);
     104                phb->proxy_func(phb->proxy_data, source, B_EV_IO_READ);
    105105        else {
    106                 phb->func(phb->data, source, GAIM_INPUT_READ);
     106                phb->func(phb->data, source, B_EV_IO_READ);
    107107                g_free(phb);
    108108        }
     
    147147                return -1;
    148148        } else {
    149                 phb->inpa = b_input_add(fd, GAIM_INPUT_WRITE, gaim_io_connected, phb);
     149                phb->inpa = b_input_add(fd, B_EV_IO_WRITE, gaim_io_connected, phb);
    150150                phb->fd = fd;
    151151               
     
    179179        if ((memcmp(HTTP_GOODSTRING, inputline, strlen(HTTP_GOODSTRING)) == 0) ||
    180180            (memcmp(HTTP_GOODSTRING2, inputline, strlen(HTTP_GOODSTRING2)) == 0)) {
    181                 phb->func(phb->data, source, GAIM_INPUT_READ);
     181                phb->func(phb->data, source, B_EV_IO_READ);
    182182                g_free(phb->host);
    183183                g_free(phb);
     
    186186
    187187        close(source);
    188         phb->func(phb->data, -1, GAIM_INPUT_READ);
     188        phb->func(phb->data, -1, B_EV_IO_READ);
    189189        g_free(phb->host);
    190190        g_free(phb);
     
    204204        if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
    205205                close(source);
    206                 phb->func(phb->data, -1, GAIM_INPUT_READ);
     206                phb->func(phb->data, -1, B_EV_IO_READ);
    207207                g_free(phb->host);
    208208                g_free(phb);
     
    215215        if (send(source, cmd, strlen(cmd), 0) < 0) {
    216216                close(source);
    217                 phb->func(phb->data, -1, GAIM_INPUT_READ);
     217                phb->func(phb->data, -1, B_EV_IO_READ);
    218218                g_free(phb->host);
    219219                g_free(phb);
     
    230230                if (send(source, cmd, strlen(cmd), 0) < 0) {
    231231                        close(source);
    232                         phb->func(phb->data, -1, GAIM_INPUT_READ);
     232                        phb->func(phb->data, -1, B_EV_IO_READ);
    233233                        g_free(phb->host);
    234234                        g_free(phb);
     
    240240        if (send(source, cmd, strlen(cmd), 0) < 0) {
    241241                close(source);
    242                 phb->func(phb->data, -1, GAIM_INPUT_READ);
    243                 g_free(phb->host);
    244                 g_free(phb);
    245                 return FALSE;
    246         }
    247 
    248         phb->inpa = b_input_add(source, GAIM_INPUT_READ, http_canread, phb);
     242                phb->func(phb->data, -1, B_EV_IO_READ);
     243                g_free(phb->host);
     244                g_free(phb);
     245                return FALSE;
     246        }
     247
     248        phb->inpa = b_input_add(source, B_EV_IO_READ, http_canread, phb);
    249249       
    250250        return FALSE;
     
    273273        memset(packet, 0, sizeof(packet));
    274274        if (read(source, packet, 9) >= 4 && packet[1] == 90) {
    275                 phb->func(phb->data, source, GAIM_INPUT_READ);
     275                phb->func(phb->data, source, B_EV_IO_READ);
    276276                g_free(phb->host);
    277277                g_free(phb);
     
    280280
    281281        close(source);
    282         phb->func(phb->data, -1, GAIM_INPUT_READ);
     282        phb->func(phb->data, -1, B_EV_IO_READ);
    283283        g_free(phb->host);
    284284        g_free(phb);
     
    299299        if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
    300300                close(source);
    301                 phb->func(phb->data, -1, GAIM_INPUT_READ);
     301                phb->func(phb->data, -1, B_EV_IO_READ);
    302302                g_free(phb->host);
    303303                g_free(phb);
     
    309309        if (!(hp = gethostbyname(phb->host))) {
    310310                close(source);
    311                 phb->func(phb->data, -1, GAIM_INPUT_READ);
     311                phb->func(phb->data, -1, B_EV_IO_READ);
    312312                g_free(phb->host);
    313313                g_free(phb);
     
    326326        if (write(source, packet, 9) != 9) {
    327327                close(source);
    328                 phb->func(phb->data, -1, GAIM_INPUT_READ);
    329                 g_free(phb->host);
    330                 g_free(phb);
    331                 return FALSE;
    332         }
    333 
    334         phb->inpa = b_input_add(source, GAIM_INPUT_READ, s4_canread, phb);
     328                phb->func(phb->data, -1, B_EV_IO_READ);
     329                g_free(phb->host);
     330                g_free(phb);
     331                return FALSE;
     332        }
     333
     334        phb->inpa = b_input_add(source, B_EV_IO_READ, s4_canread, phb);
    335335       
    336336        return FALSE;
     
    359359        if (read(source, buf, 10) < 10) {
    360360                close(source);
    361                 phb->func(phb->data, -1, GAIM_INPUT_READ);
     361                phb->func(phb->data, -1, B_EV_IO_READ);
    362362                g_free(phb->host);
    363363                g_free(phb);
     
    366366        if ((buf[0] != 0x05) || (buf[1] != 0x00)) {
    367367                close(source);
    368                 phb->func(phb->data, -1, GAIM_INPUT_READ);
    369                 g_free(phb->host);
    370                 g_free(phb);
    371                 return FALSE;
    372         }
    373 
    374         phb->func(phb->data, source, GAIM_INPUT_READ);
     368                phb->func(phb->data, -1, B_EV_IO_READ);
     369                g_free(phb->host);
     370                g_free(phb);
     371                return FALSE;
     372        }
     373
     374        phb->func(phb->data, source, B_EV_IO_READ);
    375375        g_free(phb->host);
    376376        g_free(phb);
     
    396396        if (write(source, buf, (5 + strlen(phb->host) + 2)) < (5 + strlen(phb->host) + 2)) {
    397397                close(source);
    398                 phb->func(phb->data, -1, GAIM_INPUT_READ);
     398                phb->func(phb->data, -1, B_EV_IO_READ);
    399399                g_free(phb->host);
    400400                g_free(phb);
     
    402402        }
    403403
    404         phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_canread_again, phb);
     404        phb->inpa = b_input_add(source, B_EV_IO_READ, s5_canread_again, phb);
    405405}
    406406
     
    414414        if (read(source, buf, 2) < 2) {
    415415                close(source);
    416                 phb->func(phb->data, -1, GAIM_INPUT_READ);
     416                phb->func(phb->data, -1, B_EV_IO_READ);
    417417                g_free(phb->host);
    418418                g_free(phb);
     
    422422        if ((buf[0] != 0x01) || (buf[1] != 0x00)) {
    423423                close(source);
    424                 phb->func(phb->data, -1, GAIM_INPUT_READ);
     424                phb->func(phb->data, -1, B_EV_IO_READ);
    425425                g_free(phb->host);
    426426                g_free(phb);
     
    442442        if (read(source, buf, 2) < 2) {
    443443                close(source);
    444                 phb->func(phb->data, -1, GAIM_INPUT_READ);
     444                phb->func(phb->data, -1, B_EV_IO_READ);
    445445                g_free(phb->host);
    446446                g_free(phb);
     
    450450        if ((buf[0] != 0x05) || (buf[1] == 0xff)) {
    451451                close(source);
    452                 phb->func(phb->data, -1, GAIM_INPUT_READ);
     452                phb->func(phb->data, -1, B_EV_IO_READ);
    453453                g_free(phb->host);
    454454                g_free(phb);
     
    465465                if (write(source, buf, 3 + i + j) < 3 + i + j) {
    466466                        close(source);
    467                         phb->func(phb->data, -1, GAIM_INPUT_READ);
     467                        phb->func(phb->data, -1, B_EV_IO_READ);
    468468                        g_free(phb->host);
    469469                        g_free(phb);
     
    471471                }
    472472
    473                 phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_readauth, phb);
     473                phb->inpa = b_input_add(source, B_EV_IO_READ, s5_readauth, phb);
    474474        } else {
    475475                s5_sendconnect(phb, source);
     
    491491        if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
    492492                close(source);
    493                 phb->func(phb->data, -1, GAIM_INPUT_READ);
     493                phb->func(phb->data, -1, B_EV_IO_READ);
    494494                g_free(phb->host);
    495495                g_free(phb);
     
    513513        if (write(source, buf, i) < i) {
    514514                close(source);
    515                 phb->func(phb->data, -1, GAIM_INPUT_READ);
    516                 g_free(phb->host);
    517                 g_free(phb);
    518                 return FALSE;
    519         }
    520 
    521         phb->inpa = b_input_add(source, GAIM_INPUT_READ, s5_canread, phb);
     515                phb->func(phb->data, -1, B_EV_IO_READ);
     516                g_free(phb->host);
     517                g_free(phb);
     518                return FALSE;
     519        }
     520
     521        phb->inpa = b_input_add(source, B_EV_IO_READ, s5_canread, phb);
    522522       
    523523        return FALSE;
  • lib/ssl_bogus.c

    rba7d16f r51a799e  
    5959b_input_condition ssl_getdirection( void *conn )
    6060{
    61         return GAIM_INPUT_READ;
     61        return B_EV_IO_READ;
    6262}
    6363
  • lib/ssl_client.h

    rba7d16f r51a799e  
    7171G_MODULE_EXPORT int ssl_getfd( void *conn );
    7272
    73 /* This function returns GAIM_INPUT_READ/WRITE. With SSL connections it's
     73/* This function returns B_EV_IO_READ/WRITE. With SSL connections it's
    7474   possible that something has to be read while actually were trying to
    7575   write something (think about key exchange/refresh/etc). So when an
  • lib/ssl_gnutls.c

    rba7d16f r51a799e  
    106106        struct scd *conn = data;
    107107       
    108         return ssl_connected( conn, conn->fd, GAIM_INPUT_WRITE );
     108        return ssl_connected( conn, conn->fd, B_EV_IO_WRITE );
    109109}
    110110
     
    244244{
    245245        return( gnutls_record_get_direction( ((struct scd*)conn)->session ) ?
    246                 GAIM_INPUT_WRITE : GAIM_INPUT_READ );
    247 }
     246                B_EV_IO_WRITE : B_EV_IO_READ );
     247}
  • lib/ssl_nss.c

    rba7d16f r51a799e  
    193193{
    194194        /* Just in case someone calls us, let's return the most likely case: */
    195         return GAIM_INPUT_READ;
     195        return B_EV_IO_READ;
    196196}
  • lib/ssl_openssl.c

    rba7d16f r51a799e  
    102102        struct scd *conn = data;
    103103       
    104         return ssl_connected( conn, conn->fd, GAIM_INPUT_WRITE );
     104        return ssl_connected( conn, conn->fd, B_EV_IO_WRITE );
    105105}
    106106
     
    270270b_input_condition ssl_getdirection( void *conn )
    271271{
    272         return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? GAIM_INPUT_WRITE : GAIM_INPUT_READ );
    273 }
     272        return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? B_EV_IO_WRITE : B_EV_IO_READ );
     273}
  • lib/ssl_sspi.c

    rba7d16f r51a799e  
    275275GaimInputCondition ssl_getdirection( void *conn )
    276276{
    277         return GAIM_INPUT_WRITE; /* FIXME: or GAIM_INPUT_READ */
    278 }
     277        return B_EV_IO_WRITE; /* FIXME: or B_EV_IO_READ */
     278}
  • lib/url.c

    rba7d16f r51a799e  
    2727
    2828/* Convert an URL to a url_t structure */
    29 int url_set( url_t *url, char *set_url )
     29int url_set( url_t *url, const char *set_url )
    3030{
    3131        char s[MAX_STRING+1];
  • lib/url.h

    rba7d16f r51a799e  
    4242} url_t;
    4343
    44 int url_set( url_t *url, char *set_url );
     44int url_set( url_t *url, const char *set_url );
  • lib/xmltree.c

    rba7d16f r51a799e  
    449449        while( node )
    450450        {
    451                 if( g_strcasecmp( node->name, name ) == 0 )
     451                char *colon;
     452               
     453                if( g_strcasecmp( node->name, name ) == 0 ||
     454                    ( ( colon = strchr( node->name, ':' ) ) &&
     455                      g_strcasecmp( colon + 1, name ) == 0 ) )
    452456                        break;
    453457               
     
    461465{
    462466        int i;
     467        char *colon;
    463468       
    464469        if( !node )
     
    468473                if( g_strcasecmp( node->attr[i].key, key ) == 0 )
    469474                        break;
     475       
     476        /* This is an awful hack that only takes care of namespace prefixes
     477           inside a tag. Since IMHO excessive namespace usage in XMPP is
     478           massive overkill anyway (this code exists for almost four years
     479           now and never really missed it): Meh. */
     480        if( !node->attr[i].key && strcmp( key, "xmlns" ) == 0 &&
     481            ( colon = strchr( node->name, ':' ) ) )
     482        {
     483                *colon = '\0';
     484                for( i = 0; node->attr[i].key; i ++ )
     485                        if( strncmp( node->attr[i].key, "xmlns:", 6 ) == 0 &&
     486                            strcmp( node->attr[i].key + 6, node->name ) == 0 )
     487                                break;
     488                *colon = ':';
     489        }
    470490       
    471491        return node->attr[i].value;
  • log.c

    rba7d16f r51a799e  
    172172                fprintf(stdout, "Debug: %s\n", message);
    173173#endif
     174        /* Always log stuff in syslogs too. */
     175        log_syslog(level, message);
    174176        return;
    175177}
  • protocols/jabber/conference.c

    rba7d16f r51a799e  
    272272                }
    273273               
    274                 if( bud != jc->me )
    275                 {
     274                if( bud != jc->me && bud->flags & JBFLAG_IS_ANONYMOUS )
     275                {
     276                        /* If JIDs are anonymized, add them to the local
     277                           list for the duration of this chat. */
    276278                        imcb_add_buddy( ic, bud->ext_jid, NULL );
    277279                        imcb_buddy_nick_hint( ic, bud->ext_jid, bud->resource );
  • protocols/jabber/io.c

    rba7d16f r51a799e  
    6464                   most cases it probably won't be necessary.) */
    6565                if( ( ret = jabber_write_queue( ic ) ) && jd->tx_len > 0 )
    66                         jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, ic );
     66                        jd->w_inpa = b_input_add( jd->fd, B_EV_IO_WRITE, jabber_write_callback, ic );
    6767        }
    6868        else
     
    504504       
    505505        if( jd->r_inpa <= 0 )
    506                 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, ic );
     506                jd->r_inpa = b_input_add( jd->fd, B_EV_IO_READ, jabber_read_callback, ic );
    507507       
    508508        greet = g_strdup_printf( "%s<stream:stream to=\"%s\" xmlns=\"jabber:client\" "
  • protocols/jabber/jabber_util.c

    rba7d16f r51a799e  
    671671time_t jabber_get_timestamp( struct xt_node *xt )
    672672{
    673         struct tm tp, utc;
    674673        struct xt_node *c;
    675         time_t res, tres;
    676674        char *s = NULL;
     675        struct tm tp;
    677676       
    678677        for( c = xt->children; ( c = xt_find_node( c, "x" ) ); c = c->next )
     
    692691        tp.tm_year -= 1900;
    693692        tp.tm_mon --;
    694         tp.tm_isdst = -1; /* GRRRRRRRRRRR */
    695        
    696         res = mktime( &tp );
    697         /* Problem is, mktime() just gave us the GMT timestamp for the
    698            given local time... While the given time WAS NOT local. So
    699            we should fix this now.
    700        
    701            Now I could choose between messing with environment variables
    702            (kludgy) or using timegm() (not portable)... Or doing the
    703            following, which I actually prefer... */
    704         gmtime_r( &res, &utc );
    705         utc.tm_isdst = -1; /* Once more: GRRRRRRRRRRRRRRRRRR!!! */
    706         if( utc.tm_hour == tp.tm_hour && utc.tm_min == tp.tm_min )
    707                 /* Sweet! We're in UTC right now... */
    708                 return res;
    709        
    710         tres = mktime( &utc );
    711         res += res - tres;
    712        
    713         /* Yes, this is a hack. And it will go wrong around DST changes.
    714            BUT this is more likely to be threadsafe than messing with
    715            environment variables, and possibly more portable... */
    716        
    717         return res;
     693       
     694        return mktime_utc( &tp );
    718695}
    719696
  • protocols/jabber/message.c

    rba7d16f r51a799e  
    8080                if( type && strcmp( type, "headline" ) == 0 )
    8181                {
    82                         c = xt_find_node( node->children, "subject" );
    83                         g_string_append_printf( fullmsg, "Headline: %s\n", c && c->text_len > 0 ? c->text : "" );
     82                        if( ( c = xt_find_node( node->children, "subject" ) ) && c->text_len > 0 )
     83                                g_string_append_printf( fullmsg, "Headline: %s\n", c->text );
    8484                       
    8585                        /* <x xmlns="jabber:x:oob"><url>http://....</url></x> can contain a URL, it seems. */
  • protocols/jabber/s5bytestream.c

    rba7d16f r51a799e  
    406406                        bt->phase = BS_PHASE_CONNECTED;
    407407                       
    408                         bt->tf->watch_out = b_input_add( fd, GAIM_INPUT_WRITE, jabber_bs_recv_handshake, bt );
     408                        bt->tf->watch_out = b_input_add( fd, B_EV_IO_WRITE, jabber_bs_recv_handshake, bt );
    409409
    410410                        /* since it takes forever(3mins?) till connect() fails on itself we schedule a timeout */
     
    433433                        bt->phase = BS_PHASE_REQUEST;
    434434
    435                         bt->tf->watch_in = b_input_add( fd, GAIM_INPUT_READ, jabber_bs_recv_handshake, bt );
     435                        bt->tf->watch_in = b_input_add( fd, B_EV_IO_READ, jabber_bs_recv_handshake, bt );
    436436
    437437                        bt->tf->watch_out = 0;
     
    589589
    590590        tf->ft->data = tf;
    591         tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_recv_read, bt );
     591        tf->watch_in = b_input_add( tf->fd, B_EV_IO_READ, jabber_bs_recv_read, bt );
    592592        tf->ft->write_request = jabber_bs_recv_write_request;
    593593
     
    631631                if( ( ret == -1 ) && ( errno == EAGAIN ) )
    632632                {
    633                         tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_recv_read, bt );
     633                        tf->watch_in = b_input_add( tf->fd, B_EV_IO_READ, jabber_bs_recv_read, bt );
    634634                        return FALSE;
    635635                }
     
    707707                imcb_file_finished( ft );
    708708        else
    709                 bt->tf->watch_out = b_input_add( tf->fd, GAIM_INPUT_WRITE, jabber_bs_send_can_write, bt );
     709                bt->tf->watch_out = b_input_add( tf->fd, B_EV_IO_WRITE, jabber_bs_send_can_write, bt );
    710710               
    711711        return TRUE;
     
    918918                                bt->streamhosts = g_slist_append( bt->streamhosts, sh );
    919919
    920                                 bt->tf->watch_in = b_input_add( tf->fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt );
     920                                bt->tf->watch_in = b_input_add( tf->fd, B_EV_IO_READ, jabber_bs_send_handshake, bt );
    921921                                bt->connect_timeout = b_timeout_add( JABBER_BS_LISTEN_TIMEOUT * 1000, jabber_bs_connect_timeout, bt );
    922922                        } else {
     
    10551055                        bt->phase = BS_PHASE_CONNECTED;
    10561056
    1057                         bt->tf->watch_in = b_input_add( fd, GAIM_INPUT_READ, jabber_bs_send_handshake, bt );
     1057                        bt->tf->watch_in = b_input_add( fd, B_EV_IO_READ, jabber_bs_send_handshake, bt );
    10581058                        return FALSE;
    10591059                }
  • protocols/msn/invitation.c

    rba7d16f r51a799e  
    209209        sock_make_nonblocking( fd );
    210210
    211         msn_file->r_event_id = b_input_add( fd, GAIM_INPUT_READ, msn_ftp_read, file );
     211        msn_file->r_event_id = b_input_add( fd, B_EV_IO_READ, msn_ftp_read, file );
    212212
    213213        return FALSE;
     
    230230        }
    231231
    232         msn_file->r_event_id = b_input_add( msn_file->fd, GAIM_INPUT_READ, msn_ftps_connected, file );
     232        msn_file->r_event_id = b_input_add( msn_file->fd, B_EV_IO_READ, msn_ftps_connected, file );
    233233
    234234        g_snprintf( buf, sizeof( buf ),
     
    318318       
    319319        sock_make_nonblocking( msn_file->fd );
    320         msn_file->r_event_id = b_input_add( msn_file->fd, GAIM_INPUT_READ, msn_ftp_read, file );
     320        msn_file->r_event_id = b_input_add( msn_file->fd, B_EV_IO_READ, msn_ftp_read, file );
    321321       
    322322        return FALSE;
     
    415415            ( msn_file->data_sent + msn_file->sbufpos - 3 < file->file_size ) ) {
    416416                if( !msn_file->w_event_id )
    417                         msn_file->w_event_id = b_input_add( msn_file->fd, GAIM_INPUT_WRITE, msn_ftp_send, file );
     417                        msn_file->w_event_id = b_input_add( msn_file->fd, B_EV_IO_WRITE, msn_ftp_send, file );
    418418                return TRUE;
    419419        }
     
    452452                /* we might already be listening if this is data from an overflow */
    453453                if( !msn_file->w_event_id )
    454                         msn_file->w_event_id = b_input_add( msn_file->fd, GAIM_INPUT_WRITE, msn_ftp_send, file );
     454                        msn_file->w_event_id = b_input_add( msn_file->fd, B_EV_IO_WRITE, msn_ftp_send, file );
    455455        }
    456456
     
    617617
    618618        msn_file->r_event_id =
    619                 b_input_add( msn_file->fd, GAIM_INPUT_READ, msn_ftp_read, file );
     619                b_input_add( msn_file->fd, B_EV_IO_READ, msn_ftp_read, file );
    620620
    621621        return TRUE;
  • protocols/msn/msn.c

    rba7d16f r51a799e  
    3131GSList *msn_switchboards;
    3232
    33 static char *msn_set_display_name( set_t *set, char *value );
     33static char *set_eval_display_name( set_t *set, char *value );
    3434
    3535static void msn_init( account_t *acc )
    3636{
    37         set_t *s;
    38        
    39         s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc );
    40         s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
    41 
    42         s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
     37        set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc );
     38        set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc );
     39        set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
     40        set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc );
    4341}
    4442
     
    171169static void msn_set_my_name( struct im_connection *ic, char *info )
    172170{
    173         msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info );
     171        msn_set_display_name( ic, info );
    174172}
    175173
     
    287285}
    288286
    289 static char *msn_set_display_name( set_t *set, char *value )
     287static char *set_eval_display_name( set_t *set, char *value )
    290288{
    291289        account_t *acc = set->data;
    292290        struct im_connection *ic = acc->ic;
    293         struct msn_data *md;
    294         char buf[1024], *fn;
    295        
    296         /* Double-check. */
     291       
     292        /* Allow any name if we're offline. */
    297293        if( ic == NULL )
    298                 return NULL;
    299        
    300         md = ic->proto_data;
     294                return value;
    301295       
    302296        if( strlen( value ) > 129 )
     
    305299                return NULL;
    306300        }
    307        
    308         fn = msn_http_encode( value );
    309        
    310         g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );
    311         msn_write( ic, buf, strlen( buf ) );
    312         g_free( fn );
    313301       
    314302        /* Returning NULL would be better, because the server still has to
    315303           confirm the name change. However, it looks a bit confusing to the
    316304           user. */
    317         return value;
     305        return msn_set_display_name( ic, value ) ? value : NULL;
    318306}
    319307
  • protocols/msn/msn.h

    rba7d16f r51a799e  
    3131#define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r"
    3232#define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r"
     33#define SB_KEEPALIVE_MESSAGE "\r\r\rDONT HANG UP ON ME!\r\r\r"
    3334
    3435#ifdef DEBUG_MSN
     
    5354                           "TypingUser: %s\r\n" \
    5455                           "\r\n\r\n"
     56
     57#define SB_KEEPALIVE_HEADERS "MIME-Version: 1.0\r\n" \
     58                             "Content-Type: text/x-ping\r\n" \
     59                             "\r\n\r\n"
    5560
    5661#define PROFILE_URL "http://members.msn.com/"
     
    8489        gint inp;
    8590        struct msn_handler_data *handler;
     91        gint keepalive;
    8692       
    8793        int trId;
     
    162168char *msn_http_encode( const char *input );
    163169void msn_msgq_purge( struct im_connection *ic, GSList **list );
     170gboolean msn_set_display_name( struct im_connection *ic, const char *rawname );
    164171
    165172/* tables.c */
     
    180187gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond );
    181188int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m );
     189void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial );
     190void msn_sb_stop_keepalives( struct msn_switchboard *sb );
    182191
    183192/* invitation.c */
  • protocols/msn/msn_util.c

    rba7d16f r51a799e  
    3838                imcb_error( ic, "Short write() to main server" );
    3939                imc_logout( ic, TRUE );
    40                 return( 0 );
    41         }
    42        
    43         return( 1 );
     40                return 0;
     41        }
     42       
     43        return 1;
    4444}
    4545
     
    377377        g_string_free( ret, TRUE );
    378378}
     379
     380gboolean msn_set_display_name( struct im_connection *ic, const char *rawname )
     381{
     382        char *fn = msn_http_encode( rawname );
     383        struct msn_data *md = ic->proto_data;
     384        char buf[1024];
     385       
     386        g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );
     387        g_free( fn );
     388       
     389        return msn_write( ic, buf, strlen( buf ) ) != 0;
     390}
  • protocols/msn/ns.c

    rba7d16f r51a799e  
    3535
    3636static void msn_auth_got_passport_token( struct msn_auth_data *mad );
     37static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name );
    3738
    3839gboolean msn_ns_connected( gpointer data, gint source, b_input_condition cond )
     
    7576        if( msn_write( ic, s, strlen( s ) ) )
    7677        {
    77                 ic->inpa = b_input_add( md->fd, GAIM_INPUT_READ, msn_ns_callback, ic );
     78                ic->inpa = b_input_add( md->fd, B_EV_IO_READ, msn_ns_callback, ic );
    7879                imcb_log( ic, "Connected to server, waiting for reply" );
    7980        }
     
    231232                else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 )
    232233                {
    233                         set_t *s;
    234                        
    235234                        if( num_parts == 7 )
    236                         {
    237                                 http_decode( cmd[4] );
    238                                
    239                                 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) );
    240                                 ic->displayname[sizeof(ic->displayname)-1] = 0;
    241                                
    242                                 if( ( s = set_find( &ic->acc->set, "display_name" ) ) )
    243                                 {
    244                                         g_free( s->value );
    245                                         s->value = g_strdup( cmd[4] );
    246                                 }
    247                         }
     235                                msn_ns_got_display_name( ic, cmd[4] );
    248236                        else
    249                         {
    250237                                imcb_log( ic, "Warning: Friendly name in server response was corrupted" );
    251                         }
    252238                       
    253239                        imcb_log( ic, "Authenticated, getting buddy list" );
     
    436422        else if( strcmp( cmd[0], "FLN" ) == 0 )
    437423        {
    438                 if( cmd[1] )
    439                         imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
     424                if( cmd[1] == NULL )
     425                        return 1;
     426               
     427                imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
     428               
     429                msn_sb_start_keepalives( msn_sb_by_handle( ic, cmd[1] ), TRUE );
    440430        }
    441431        else if( strcmp( cmd[0], "NLN" ) == 0 )
     
    463453                                   ( st != msn_away_state_list ? OPT_AWAY : 0 ),
    464454                                   st->name, NULL );
     455               
     456                msn_sb_stop_keepalives( msn_sb_by_handle( ic, cmd[2] ) );
    465457        }
    466458        else if( strcmp( cmd[0], "RNG" ) == 0 )
     
    567559                return( 0 );
    568560        }
     561#if 0
     562        /* Discard this one completely for now since I don't care about the ack
     563           and since MSN servers can apparently screw up the formatting. */
    569564        else if( strcmp( cmd[0], "REA" ) == 0 )
    570565        {
     
    597592                }
    598593        }
     594#endif
    599595        else if( strcmp( cmd[0], "IPG" ) == 0 )
    600596        {
     
    746742        }
    747743}
     744
     745static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name )
     746{
     747        set_t *s;
     748       
     749        if( ( s = set_find( &ic->acc->set, "display_name" ) ) == NULL )
     750                return FALSE; /* Shouldn't happen.. */
     751       
     752        http_decode( name );
     753       
     754        if( s->value && strcmp( s->value, name ) == 0 )
     755        {
     756                return TRUE;
     757                /* The names match, nothing to worry about. */
     758        }
     759        else if( s->value != NULL &&
     760                 ( strcmp( name, ic->acc->user ) == 0 ||
     761                   set_getbool( &ic->acc->set, "local_display_name" ) ) )
     762        {
     763                /* The server thinks our display name is our e-mail address
     764                   which is probably wrong, or the user *wants* us to do this:
     765                   Always use the locally set display_name. */
     766                return msn_set_display_name( ic, s->value );
     767        }
     768        else
     769        {
     770                if( s->value && *s->value )
     771                        imcb_log( ic, "BitlBee thinks your display name is `%s' but "
     772                                      "the MSN server says it's `%s'. Using the MSN "
     773                                      "server's name. Set local_display_name to true "
     774                                      "to use the local name.", s->value, name );
     775               
     776                if( g_utf8_validate( name, -1, NULL ) )
     777                {
     778                        g_free( s->value );
     779                        s->value = g_strdup( name );
     780                }
     781                else
     782                {
     783                        imcb_log( ic, "Warning: Friendly name in server response was corrupted" );
     784                }
     785               
     786                return TRUE;
     787        }
     788}
  • protocols/msn/sb.c

    rba7d16f r51a799e  
    180180                        i = strlen( buf );
    181181                }
     182                else if( strcmp( text, SB_KEEPALIVE_MESSAGE ) == 0 )
     183                {
     184                        buf = g_strdup( SB_KEEPALIVE_HEADERS );
     185                        i = strlen( buf );
     186                }
    182187                else
    183188                {
     
    256261       
    257262        msn_msgq_purge( ic, &sb->msgq );
     263        msn_sb_stop_keepalives( sb );
    258264       
    259265        if( sb->key ) g_free( sb->key );
     
    315321       
    316322        if( msn_sb_write( sb, buf, strlen( buf ) ) )
    317                 sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb );
     323                sb->inp = b_input_add( sb->fd, B_EV_IO_READ, msn_sb_callback, sb );
    318324        else
    319325                debug( "Error %d while connecting to switchboard server", 2 );
     
    328334        struct msn_data *md = ic->proto_data;
    329335       
    330         if( msn_handler( sb->handler ) == -1 )
     336        if( msn_handler( sb->handler ) != -1 )
     337                return TRUE;
     338       
     339        if( sb->msgq != NULL )
    331340        {
    332341                time_t now = time( NULL );
     342                char buf[1024];
    333343               
    334344                if( now - md->first_sb_failure > 600 )
     
    347357                                      "There might be problems delivering your messages." );
    348358               
    349                 if( sb->msgq != NULL )
    350                 {
    351                         char buf[1024];
    352                        
    353                         if( md->msgq == NULL )
    354                         {
    355                                 md->msgq = sb->msgq;
    356                         }
    357                         else
    358                         {
    359                                 GSList *l;
    360                                
    361                                 for( l = md->msgq; l->next; l = l->next );
    362                                 l->next = sb->msgq;
    363                         }
    364                         sb->msgq = NULL;
    365                        
    366                         debug( "Moved queued messages back to the main queue, creating a new switchboard to retry." );
    367                         g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
    368                         if( !msn_write( ic, buf, strlen( buf ) ) )
    369                                 return FALSE;
    370                 }
    371                
    372                 msn_sb_destroy( sb );
    373                
    374                 return FALSE;
    375         }
    376         else
    377         {
    378                 return TRUE;
    379         }
     359                if( md->msgq == NULL )
     360                {
     361                        md->msgq = sb->msgq;
     362                }
     363                else
     364                {
     365                        GSList *l;
     366                       
     367                        for( l = md->msgq; l->next; l = l->next );
     368                        l->next = sb->msgq;
     369                }
     370                sb->msgq = NULL;
     371               
     372                debug( "Moved queued messages back to the main queue, "
     373                       "creating a new switchboard to retry." );
     374                g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );
     375                if( !msn_write( ic, buf, strlen( buf ) ) )
     376                        return FALSE;
     377        }
     378       
     379        msn_sb_destroy( sb );
     380        return FALSE;
    380381}
    381382
     
    477478               
    478479                sb->ready = 1;
     480               
     481                msn_sb_start_keepalives( sb, FALSE );
    479482        }
    480483        else if( strcmp( cmd[0], "CAL" ) == 0 )
     
    526529                        }
    527530                       
     531                        msn_sb_start_keepalives( sb, FALSE );
     532                       
    528533                        return( st );
    529534                }
     
    587592                if( sb->who )
    588593                {
     594                        msn_sb_stop_keepalives( sb );
     595                       
    589596                        /* This is a single-person chat, and the other person is leaving. */
    590597                        g_free( sb->who );
     
    749756        return( 1 );
    750757}
     758
     759static gboolean msn_sb_keepalive( gpointer data, gint source, b_input_condition cond )
     760{
     761        struct msn_switchboard *sb = data;
     762        return sb->ready && msn_sb_sendmessage( sb, SB_KEEPALIVE_MESSAGE );
     763}
     764
     765void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial )
     766{
     767        struct buddy *b;
     768       
     769        if( sb && sb->who && sb->keepalive == 0 &&
     770            ( b = imcb_find_buddy( sb->ic, sb->who ) ) && !b->present &&
     771            set_getbool( &sb->ic->acc->set, "switchboard_keepalives" ) )
     772        {
     773                if( initial )
     774                        msn_sb_keepalive( sb, 0, 0 );
     775               
     776                sb->keepalive = b_timeout_add( 20000, msn_sb_keepalive, sb );
     777        }
     778}
     779
     780void msn_sb_stop_keepalives( struct msn_switchboard *sb )
     781{
     782        if( sb && sb->keepalive > 0 )
     783        {
     784                b_event_remove( sb->keepalive );
     785                sb->keepalive = 0;
     786        }
     787}
  • protocols/nogaim.c

    rba7d16f r51a799e  
    3939
    4040static int remove_chat_buddy_silent( struct groupchat *b, const char *handle );
     41static char *format_timestamp( irc_t *irc, time_t msg_ts );
    4142
    4243GSList *connections;
     
    116117{
    117118        GList *gl;
    118         for (gl = protocols; gl; gl = gl->next)
     119       
     120        for( gl = protocols; gl; gl = gl->next )
    119121        {
    120122                struct prpl *proto = gl->data;
    121                 if(!g_strcasecmp(proto->name, name))
     123               
     124                if( g_strcasecmp( proto->name, name ) == 0 )
    122125                        return proto;
    123126        }
     127       
    124128        return NULL;
    125129}
     
    132136        extern void byahoo_initmodule();
    133137        extern void jabber_initmodule();
     138        extern void twitter_initmodule();
     139        extern void purple_initmodule();
    134140
    135141#ifdef WITH_MSN
     
    147153#ifdef WITH_JABBER
    148154        jabber_initmodule();
     155#endif
     156
     157#ifdef WITH_TWITTER
     158        twitter_initmodule();
     159#endif
     160       
     161#ifdef WITH_PURPLE
     162        purple_initmodule();
    149163#endif
    150164
     
    651665        u->away = u->status_msg = NULL;
    652666       
    653         if( ( flags & OPT_LOGGED_IN ) && !u->online )
    654         {
     667        if( set_getbool( &ic->irc->set, "show_offline" ) && !u->online )
     668        {
     669                /* always set users as online */
    655670                irc_spawn( ic->irc, u );
    656671                u->online = 1;
     672                if( !( flags & OPT_LOGGED_IN ) )
     673                {
     674                        /* set away message if user isn't really online */
     675                        u->away = g_strdup( "User is offline" );
     676                }
     677        }
     678        else if( ( flags & OPT_LOGGED_IN ) && !u->online )
     679        {
     680                irc_spawn( ic->irc, u );
     681                u->online = 1;
    657682        }
    658683        else if( !( flags & OPT_LOGGED_IN ) && u->online )
     
    660685                struct groupchat *c;
    661686               
    662                 irc_kill( ic->irc, u );
    663                 u->online = 0;
    664                
    665                 /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */
    666                 for( c = ic->groupchats; c; c = c->next )
    667                         remove_chat_buddy_silent( c, handle );
    668         }
    669        
     687                if( set_getbool( &ic->irc->set, "show_offline" ) )
     688                {
     689                        /* keep offline users in channel and set away message to "offline" */
     690                        u->away = g_strdup( "User is offline" );
     691
     692                        /* Keep showing him/her in the control channel but not in groupchats. */
     693                        for( c = ic->groupchats; c; c = c->next )
     694                        {
     695                                if( remove_chat_buddy_silent( c, handle ) && c->joined )
     696                                        irc_part( c->ic->irc, u, c->channel );
     697                        }
     698                }
     699                else
     700                {
     701                        /* kill offline users */
     702                        irc_kill( ic->irc, u );
     703                        u->online = 0;
     704
     705                        /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */
     706                        for( c = ic->groupchats; c; c = c->next )
     707                                remove_chat_buddy_silent( c, handle );
     708                }
     709        }
     710
    670711        if( flags & OPT_AWAY )
    671712        {
     
    692733        }
    693734       
    694         /* LISPy... */
    695         if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
    696             ( u->online ) &&                                            /* Don't touch offline people */
    697             ( ( ( u->online != oo ) && !u->away ) ||                    /* Voice joining people */
    698               ( ( u->online == oo ) && ( oa == !u->away ) ) ) )         /* (De)voice people changing state */
     735        /* early if-clause for show_offline even if there is some redundant code here because this isn't LISP but C ;) */
     736        if( set_getbool( &ic->irc->set, "show_offline" ) && set_getbool( &ic->irc->set, "away_devoice" ) )
    699737        {
    700738                char *from;
     
    709747                                                            ic->irc->myhost );
    710748                }
    711                 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
    712                                                           u->away?'-':'+', u->nick );
    713                 g_free( from );
     749
     750                /* if we use show_offline, we op online users, voice away users, and devoice/deop offline users */
     751                if( flags & OPT_LOGGED_IN )
     752                {
     753                        /* user is "online" (either really online or away) */
     754                        irc_write( ic->irc, ":%s MODE %s %cv%co %s %s", from, ic->irc->channel,
     755                                                                  u->away?'+':'-', u->away?'-':'+', u->nick, u->nick );
     756                }
     757                else
     758                {
     759                        /* user is offline */
     760                        irc_write( ic->irc, ":%s MODE %s -vo %s %s", from, ic->irc->channel, u->nick, u->nick );
     761                }
     762        }
     763        else
     764        {
     765                /* LISPy... */
     766                if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
     767                    ( u->online ) &&                                            /* Don't touch offline people */
     768                    ( ( ( u->online != oo ) && !u->away ) ||                    /* Voice joining people */
     769                      ( ( u->online == oo ) && ( oa == !u->away ) ) ) )         /* (De)voice people changing state */
     770                {
     771                        char *from;
     772
     773                        if( set_getbool( &ic->irc->set, "simulate_netsplit" ) )
     774                        {
     775                                from = g_strdup( ic->irc->myhost );
     776                        }
     777                        else
     778                        {
     779                                from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick,
     780                                                                    ic->irc->myhost );
     781                        }
     782                        irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
     783                                                                  u->away?'-':'+', u->nick );
     784                        g_free( from );
     785                }
    714786        }
    715787}
     
    718790{
    719791        irc_t *irc = ic->irc;
    720         char *wrapped;
     792        char *wrapped, *ts = NULL;
    721793        user_t *u;
    722794       
     
    760832            ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
    761833                strip_html( msg );
    762 
     834       
     835        if( set_getbool( &ic->irc->set, "display_timestamps" ) &&
     836            ( ts = format_timestamp( irc, sent_at ) ) )
     837        {
     838                char *new = g_strconcat( ts, msg, NULL );
     839                g_free( ts );
     840                ts = msg = new;
     841        }
     842       
    763843        wrapped = word_wrap( msg, 425 );
    764844        irc_msgfrom( irc, u->nick, wrapped );
    765845        g_free( wrapped );
     846        g_free( ts );
    766847}
    767848
     
    805886       
    806887        return c;
     888}
     889
     890void imcb_chat_name_hint( struct groupchat *c, const char *name )
     891{
     892        if( !c->joined )
     893        {
     894                struct im_connection *ic = c->ic;
     895                char stripped[MAX_NICK_LENGTH+1], *full_name;
     896               
     897                strncpy( stripped, name, MAX_NICK_LENGTH );
     898                stripped[MAX_NICK_LENGTH] = '\0';
     899                nick_strip( stripped );
     900                if( set_getbool( &ic->irc->set, "lcnicks" ) )
     901                        nick_lc( stripped );
     902               
     903                full_name = g_strdup_printf( "&%s", stripped );
     904               
     905                if( stripped[0] &&
     906                    nick_cmp( stripped, ic->irc->channel + 1 ) != 0 &&
     907                    irc_chat_by_channel( ic->irc, full_name ) == NULL )
     908                {
     909                        g_free( c->channel );
     910                        c->channel = full_name;
     911                }
     912                else
     913                {
     914                        g_free( full_name );
     915                }
     916        }
    807917}
    808918
     
    867977        if( c && u )
    868978        {
    869                 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, "", wrapped );
     979                char *ts = NULL;
     980                if( set_getbool( &ic->irc->set, "display_timestamps" ) )
     981                        ts = format_timestamp( ic->irc, sent_at );
     982                irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped );
     983                g_free( ts );
    870984        }
    871985        else
     
    10611175}
    10621176
    1063 
    1064 
     1177char *set_eval_timezone( set_t *set, char *value )
     1178{
     1179        char *s;
     1180       
     1181        if( strcmp( value, "local" ) == 0 ||
     1182            strcmp( value, "gmt" ) == 0 || strcmp( value, "utc" ) == 0 )
     1183                return value;
     1184       
     1185        /* Otherwise: +/- at the beginning optional, then one or more numbers,
     1186           possibly followed by a colon and more numbers. Don't bother bound-
     1187           checking them since users are free to shoot themselves in the foot. */
     1188        s = value;
     1189        if( *s == '+' || *s == '-' )
     1190                s ++;
     1191       
     1192        /* \d+ */
     1193        if( !isdigit( *s ) )
     1194                return SET_INVALID;
     1195        while( *s && isdigit( *s ) ) s ++;
     1196       
     1197        /* EOS? */
     1198        if( *s == '\0' )
     1199                return value;
     1200       
     1201        /* Otherwise, colon */
     1202        if( *s != ':' )
     1203                return SET_INVALID;
     1204        s ++;
     1205       
     1206        /* \d+ */
     1207        if( !isdigit( *s ) )
     1208                return SET_INVALID;
     1209        while( *s && isdigit( *s ) ) s ++;
     1210       
     1211        /* EOS */
     1212        return *s == '\0' ? value : SET_INVALID;
     1213}
     1214
     1215static char *format_timestamp( irc_t *irc, time_t msg_ts )
     1216{
     1217        time_t now_ts = time( NULL );
     1218        struct tm now, msg;
     1219        char *set;
     1220       
     1221        /* If the timestamp is <= 0 or less than a minute ago, discard it as
     1222           it doesn't seem to add to much useful info and/or might be noise. */
     1223        if( msg_ts <= 0 || msg_ts > now_ts - 60 )
     1224                return NULL;
     1225       
     1226        set = set_getstr( &irc->set, "timezone" );
     1227        if( strcmp( set, "local" ) == 0 )
     1228        {
     1229                localtime_r( &now_ts, &now );
     1230                localtime_r( &msg_ts, &msg );
     1231        }
     1232        else
     1233        {
     1234                int hr, min = 0, sign = 60;
     1235               
     1236                if( set[0] == '-' )
     1237                {
     1238                        sign *= -1;
     1239                        set ++;
     1240                }
     1241                else if( set[0] == '+' )
     1242                {
     1243                        set ++;
     1244                }
     1245               
     1246                if( sscanf( set, "%d:%d", &hr, &min ) >= 1 )
     1247                {
     1248                        msg_ts += sign * ( hr * 60 + min );
     1249                        now_ts += sign * ( hr * 60 + min );
     1250                }
     1251               
     1252                gmtime_r( &now_ts, &now );
     1253                gmtime_r( &msg_ts, &msg );
     1254        }
     1255       
     1256        if( msg.tm_year == now.tm_year && msg.tm_yday == now.tm_yday )
     1257                return g_strdup_printf( "\x02[\x02\x02\x02%02d:%02d:%02d\x02]\x02 ",
     1258                                        msg.tm_hour, msg.tm_min, msg.tm_sec );
     1259        else
     1260                return g_strdup_printf( "\x02[\x02\x02\x02%04d-%02d-%02d "
     1261                                        "%02d:%02d:%02d\x02]\x02 ",
     1262                                        msg.tm_year + 1900, msg.tm_mon + 1, msg.tm_mday,
     1263                                        msg.tm_hour, msg.tm_min, msg.tm_sec );
     1264}
    10651265
    10661266/* The plan is to not allow straight calls to prpl functions anymore, but do
     
    11051305{
    11061306        char *away, *msg = NULL;
     1307       
     1308        if( ic->acc->prpl->away_states == NULL ||
     1309            ic->acc->prpl->set_away == NULL )
     1310                return 0;
    11071311       
    11081312        away = set_getstr( &ic->acc->set, "away" ) ?
  • protocols/nogaim.h

    rba7d16f r51a799e  
    134134         * - The user sees this name ie. when imcb_log() is used. */
    135135        const char *name;
     136        void *data;
    136137
    137138        /* Added this one to be able to add per-account settings, don't think
     
    307308 *   user, too. */
    308309G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle );
     310G_MODULE_EXPORT void imcb_chat_name_hint( struct groupchat *c, const char *name );
    309311G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, const char *handle );
    310312/* To remove a handle from a group chat. Reason can be NULL. */
     
    329331
    330332/* Misc. stuff */
     333char *set_eval_timezone( set_t *set, char *value );
    331334char *set_eval_away_devoice( set_t *set, char *value );
    332335gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond );
  • protocols/oscar/oscar.c

    rba7d16f r51a799e  
    205205static int gaim_icbm_param_info  (aim_session_t *, aim_frame_t *, ...);
    206206static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...);
    207 static int gaim_memrequest       (aim_session_t *, aim_frame_t *, ...);
    208207static int gaim_selfinfo         (aim_session_t *, aim_frame_t *, ...);
    209208static int gaim_offlinemsg       (aim_session_t *, aim_frame_t *, ...);
     
    291290        odata = (struct oscar_data *)ic->proto_data;
    292291
    293         if (condition & GAIM_INPUT_READ) {
     292        if (condition & B_EV_IO_READ) {
    294293                if (aim_get_command(odata->sess, conn) >= 0) {
    295294                        aim_rxdispatch(odata->sess);
     
    363362
    364363        aim_conn_completeconnect(sess, conn);
    365         ic->inpa = b_input_add(conn->fd, GAIM_INPUT_READ,
     364        ic->inpa = b_input_add(conn->fd, B_EV_IO_READ,
    366365                        oscar_callback, conn);
    367366       
     
    493492
    494493        aim_conn_completeconnect(sess, bosconn);
    495         ic->inpa = b_input_add(bosconn->fd, GAIM_INPUT_READ,
     494        ic->inpa = b_input_add(bosconn->fd, B_EV_IO_READ,
    496495                        oscar_callback, bosconn);
    497496        imcb_log(ic, _("Connection established, cookie sent"));
     
    570569        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ERROR, gaim_parse_genericerr, 0);
    571570        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BOS, AIM_CB_BOS_ERROR, gaim_parse_genericerr, 0);
    572         aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, 0x1f, gaim_memrequest, 0);
    573571        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SELFINFO, gaim_selfinfo, 0);
    574572        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0);
     
    604602}
    605603
    606 struct pieceofcrap {
    607         struct im_connection *ic;
    608         unsigned long offset;
    609         unsigned long len;
    610         char *modname;
    611         int fd;
    612         aim_conn_t *conn;
    613         unsigned int inpa;
    614 };
    615 
    616 static gboolean damn_you(gpointer data, gint source, b_input_condition c)
    617 {
    618         struct pieceofcrap *pos = data;
    619         struct oscar_data *od = pos->ic->proto_data;
    620         char in = '\0';
    621         int x = 0;
    622         unsigned char m[17];
    623 
    624         while (read(pos->fd, &in, 1) == 1) {
    625                 if (in == '\n')
    626                         x++;
    627                 else if (in != '\r')
    628                         x = 0;
    629                 if (x == 2)
    630                         break;
    631                 in = '\0';
    632         }
    633         if (in != '\n') {
    634                 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."
    635                                 " You may be disconnected shortly.");
    636                 b_event_remove(pos->inpa);
    637                 closesocket(pos->fd);
    638                 g_free(pos);
    639                 return FALSE;
    640         }
    641         /* [WvG] Wheeeee! Who needs error checking anyway? ;-) */
    642         read(pos->fd, m, 16);
    643         m[16] = '\0';
    644         b_event_remove(pos->inpa);
    645         closesocket(pos->fd);
    646         aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH);
    647         g_free(pos);
    648        
    649         return FALSE;
    650 }
    651 
    652 static gboolean straight_to_hell(gpointer data, gint source, b_input_condition cond) {
    653         struct pieceofcrap *pos = data;
    654         char buf[BUF_LONG];
    655 
    656         if (source < 0) {
    657                 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."
    658                                 " You may be disconnected shortly.");
    659                 if (pos->modname)
    660                         g_free(pos->modname);
    661                 g_free(pos);
    662                 return FALSE;
    663         }
    664 
    665         g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA
    666                         "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n",
    667                         pos->offset, pos->len, pos->modname ? pos->modname : "");
    668         write(pos->fd, buf, strlen(buf));
    669         if (pos->modname)
    670                 g_free(pos->modname);
    671         pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);
    672         return FALSE;
    673 }
    674 
    675604/* size of icbmui.ocm, the largest module in AIM 3.5 */
    676605#define AIM_MAX_FILE_SIZE 98304
    677 
    678 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) {
    679         va_list ap;
    680         struct pieceofcrap *pos;
    681         guint32 offset, len;
    682         char *modname;
    683         int fd;
    684 
    685         va_start(ap, fr);
    686         offset = (guint32)va_arg(ap, unsigned long);
    687         len = (guint32)va_arg(ap, unsigned long);
    688         modname = va_arg(ap, char *);
    689         va_end(ap);
    690 
    691         if (len == 0) {
    692                 aim_sendmemblock(sess, fr->conn, offset, len, NULL,
    693                                 AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
    694                 return 1;
    695         }
    696         /* uncomment this when you're convinced it's right. remember, it's been wrong before.
    697         if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) {
    698                 char *buf;
    699                 int i = 8;
    700                 if (modname)
    701                         i += strlen(modname);
    702                 buf = g_malloc(i);
    703                 i = 0;
    704                 if (modname) {
    705                         memcpy(buf, modname, strlen(modname));
    706                         i += strlen(modname);
    707                 }
    708                 buf[i++] = offset & 0xff;
    709                 buf[i++] = (offset >> 8) & 0xff;
    710                 buf[i++] = (offset >> 16) & 0xff;
    711                 buf[i++] = (offset >> 24) & 0xff;
    712                 buf[i++] = len & 0xff;
    713                 buf[i++] = (len >> 8) & 0xff;
    714                 buf[i++] = (len >> 16) & 0xff;
    715                 buf[i++] = (len >> 24) & 0xff;
    716                 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
    717                 g_free(buf);
    718                 return 1;
    719         }
    720         */
    721 
    722         pos = g_new0(struct pieceofcrap, 1);
    723         pos->ic = sess->aux_data;
    724         pos->conn = fr->conn;
    725 
    726         pos->offset = offset;
    727         pos->len = len;
    728         pos->modname = modname ? g_strdup(modname) : NULL;
    729 
    730         fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos);
    731         if (fd < 0) {
    732                 if (pos->modname)
    733                         g_free(pos->modname);
    734                 g_free(pos);
    735                 imcb_error(sess->aux_data, "Gaim was unable to get a valid hash for logging into AIM."
    736                                 " You may be disconnected shortly.");
    737         }
    738         pos->fd = fd;
    739 
    740         return 1;
    741 }
    742606
    743607static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {
     
    838702
    839703        aim_conn_completeconnect(sess, tstconn);
    840         odata->cnpa = b_input_add(tstconn->fd, GAIM_INPUT_READ,
     704        odata->cnpa = b_input_add(tstconn->fd, B_EV_IO_READ,
    841705                                        oscar_callback, tstconn);
    842706       
     
    866730
    867731        aim_conn_completeconnect(sess, tstconn);
    868         odata->paspa = b_input_add(tstconn->fd, GAIM_INPUT_READ,
     732        odata->paspa = b_input_add(tstconn->fd, B_EV_IO_READ,
    869733                                oscar_callback, tstconn);
    870734       
     
    902766        aim_conn_completeconnect(sess, ccon->conn);
    903767        ccon->inpa = b_input_add(tstconn->fd,
    904                         GAIM_INPUT_READ,
     768                        B_EV_IO_READ,
    905769                        oscar_callback, tstconn);
    906770        odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon);
     
    26512515        char * chatname;
    26522516       
    2653         chatname = g_strdup_printf("%s%d", ic->acc->user, chat_id++);
     2517        chatname = g_strdup_printf("%s%s_%d", isdigit(*ic->acc->user) ? "icq_" : "",
     2518                                   ic->acc->user, chat_id++);
    26542519 
    26552520        ret = oscar_chat_join(ic, chatname, NULL, NULL);
  • protocols/yahoo/yahoo.c

    rba7d16f r51a799e  
    138138        struct im_connection *ic = imcb_new( acc );
    139139        struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 );
     140        char *s;
    140141       
    141142        yd->logged_in = FALSE;
    142143        yd->current_status = YAHOO_STATUS_AVAILABLE;
     144       
     145        if( ( s = strchr( acc->user, '@' ) ) && g_strcasecmp( s, "@yahoo.com" ) == 0 )
     146                imcb_error( ic, "Your Yahoo! username should just be a username. "
     147                                "Do not include any @domain part." );
    143148       
    144149        imcb_log( ic, "Connecting" );
     
    681686               
    682687                inp->d = d;
    683                 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d );
     688                d->tag = inp->h = b_input_add( fd, B_EV_IO_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d );
    684689        }
    685690        else if( cond == YAHOO_INPUT_WRITE )
     
    692697               
    693698                inp->d = d;
    694                 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d );
     699                d->tag = inp->h = b_input_add( fd, B_EV_IO_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d );
    695700        }
    696701        else
     
    828833        YList *m;
    829834       
     835        if( g_strcasecmp( who, ic->acc->user ) == 0 )
     836                /* WTF, Yahoo! seems to echo these now? */
     837                return;
     838       
    830839        inv = g_malloc( sizeof( struct byahoo_conf_invitation ) );
    831840        memset( inv, 0, sizeof( struct byahoo_conf_invitation ) );
  • set.c

    rba7d16f r51a799e  
    2929char *SET_INVALID = "nee";
    3030
    31 set_t *set_add( set_t **head, char *key, char *def, set_eval eval, void *data )
     31set_t *set_add( set_t **head, const char *key, const char *def, set_eval eval, void *data )
    3232{
    3333        set_t *s = set_find( head, key );
     
    6363}
    6464
    65 set_t *set_find( set_t **head, char *key )
     65set_t *set_find( set_t **head, const char *key )
    6666{
    6767        set_t *s = *head;
     
    7777}
    7878
    79 char *set_getstr( set_t **head, char *key )
     79char *set_getstr( set_t **head, const char *key )
    8080{
    8181        set_t *s = set_find( head, key );
     
    8787}
    8888
    89 int set_getint( set_t **head, char *key )
     89int set_getint( set_t **head, const char *key )
    9090{
    9191        char *s = set_getstr( head, key );
     
    101101}
    102102
    103 int set_getbool( set_t **head, char *key )
     103int set_getbool( set_t **head, const char *key )
    104104{
    105105        char *s = set_getstr( head, key );
     
    111111}
    112112
    113 int set_setstr( set_t **head, char *key, char *value )
     113int set_setstr( set_t **head, const char *key, char *value )
    114114{
    115115        set_t *s = set_find( head, key );
     
    150150}
    151151
    152 int set_setint( set_t **head, char *key, int value )
     152int set_setint( set_t **head, const char *key, int value )
    153153{
    154154        char s[24];     /* Not quite 128-bit clean eh? ;-) */
     
    158158}
    159159
    160 void set_del( set_t **head, char *key )
     160void set_del( set_t **head, const char *key )
    161161{
    162162        set_t *s = *head, *t = NULL;
     
    182182}
    183183
    184 int set_reset( set_t **head, char *key )
     184int set_reset( set_t **head, const char *key )
    185185{
    186186        set_t *s;
     
    211211{
    212212        return is_bool( value ) ? value : SET_INVALID;
     213}
     214
     215char *set_eval_list( set_t *set, char *value )
     216{
     217        GSList *options = set->eval_data, *opt;
     218       
     219        for( opt = options; opt; opt = opt->next )
     220                if( strcmp( value, opt->data ) == 0 )
     221                        return value;
     222       
     223        /* TODO: It'd be nice to show the user a list of allowed values,
     224                 but we don't have enough context here to do that. May
     225                 want to fix that. */
     226       
     227        return NULL;
    213228}
    214229
  • set.h

    rba7d16f r51a799e  
    6969           set_setstr() should be able to free() the returned string! */
    7070        set_eval eval;
     71        void *eval_data;
    7172        struct set *next;
    7273} set_t;
    7374
    7475/* Should be pretty clear. */
    75 set_t *set_add( set_t **head, char *key, char *def, set_eval eval, void *data );
     76set_t *set_add( set_t **head, const char *key, const char *def, set_eval eval, void *data );
    7677
    7778/* Returns the raw set_t. Might be useful sometimes. */
    78 set_t *set_find( set_t **head, char *key );
     79set_t *set_find( set_t **head, const char *key );
    7980
    8081/* Returns a pointer to the string value of this setting. Don't modify the
    8182   returned string, and don't free() it! */
    82 G_MODULE_EXPORT char *set_getstr( set_t **head, char *key );
     83G_MODULE_EXPORT char *set_getstr( set_t **head, const char *key );
    8384
    8485/* Get an integer. In previous versions set_getint() was also used to read
    8586   boolean values, but this SHOULD be done with set_getbool() now! */
    86 G_MODULE_EXPORT int set_getint( set_t **head, char *key );
    87 G_MODULE_EXPORT int set_getbool( set_t **head, char *key );
     87G_MODULE_EXPORT int set_getint( set_t **head, const char *key );
     88G_MODULE_EXPORT int set_getbool( set_t **head, const char *key );
    8889
    8990/* set_setstr() strdup()s the given value, so after using this function
    9091   you can free() it, if you want. */
    91 int set_setstr( set_t **head, char *key, char *value );
    92 int set_setint( set_t **head, char *key, int value );
    93 void set_del( set_t **head, char *key );
    94 int set_reset( set_t **head, char *key );
     92int set_setstr( set_t **head, const char *key, char *value );
     93int set_setint( set_t **head, const char *key, int value );
     94void set_del( set_t **head, const char *key );
     95int set_reset( set_t **head, const char *key );
    9596
    9697/* Two very useful generic evaluators. */
    9798char *set_eval_int( set_t *set, char *value );
    9899char *set_eval_bool( set_t *set, char *value );
     100
     101/* Another more complicated one. */
     102char *set_eval_list( set_t *set, char *value );
    99103
    100104/* Some not very generic evaluators that really shouldn't be here... */
  • storage_xml.c

    rba7d16f r51a799e  
    496496                goto write_error;
    497497       
     498        fsync( fd );
    498499        close( fd );
    499500       
  • unix.c

    rba7d16f r51a799e  
    5656       
    5757        log_init();
     58       
    5859        global.conf_file = g_strdup( CONF_FILE_DEF );
    5960        global.conf = conf_load( argc, argv );
     
    6263       
    6364        b_main_init();
    64         nogaim_init();
    6565       
    6666        srand( time( NULL ) ^ getpid() );
     67       
    6768        global.helpfile = g_strdup( HELP_FILE );
     69        if( help_init( &global.help, global.helpfile ) == NULL )
     70                log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );
     71
     72        global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage );
     73        if( global.storage == NULL )
     74        {
     75                log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage );
     76                return( 1 );
     77        }
    6878       
    6979        if( global.conf->runmode == RUNMODE_INETD )
     
    7383       
    7484                i = bitlbee_inetd_init();
    75                 log_message( LOGLVL_INFO, "Bitlbee %s starting in inetd mode.", BITLBEE_VERSION );
     85                log_message( LOGLVL_INFO, "BitlBee %s starting in inetd mode.", BITLBEE_VERSION );
    7686
    7787        }
    7888        else if( global.conf->runmode == RUNMODE_DAEMON )
    7989        {
    80                 log_link( LOGLVL_ERROR, LOGOUTPUT_SYSLOG );
    81                 log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG );
     90                log_link( LOGLVL_ERROR, LOGOUTPUT_CONSOLE );
     91                log_link( LOGLVL_WARNING, LOGOUTPUT_CONSOLE );
    8292
    8393                i = bitlbee_daemon_init();
    84                 log_message( LOGLVL_INFO, "Bitlbee %s starting in daemon mode.", BITLBEE_VERSION );
     94                log_message( LOGLVL_INFO, "BitlBee %s starting in daemon mode.", BITLBEE_VERSION );
    8595        }
    8696        else if( global.conf->runmode == RUNMODE_FORKDAEMON )
    8797        {
     98                log_link( LOGLVL_ERROR, LOGOUTPUT_CONSOLE );
     99                log_link( LOGLVL_WARNING, LOGOUTPUT_CONSOLE );
     100
    88101                /* In case the operator requests a restart, we need this. */
    89102                old_cwd = g_malloc( 256 );
     
    96109               
    97110                i = bitlbee_daemon_init();
    98                 log_message( LOGLVL_INFO, "Bitlbee %s starting in forking daemon mode.", BITLBEE_VERSION );
     111                log_message( LOGLVL_INFO, "BitlBee %s starting in forking daemon mode.", BITLBEE_VERSION );
    99112        }
    100113        if( i != 0 )
     
    113126                        setuid( pw->pw_uid );
    114127                }
    115         }
    116 
    117         global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage );
    118         if( global.storage == NULL )
    119         {
    120                 log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage );
    121                 return( 1 );
    122128        }
    123129       
     
    139145        if( !getuid() || !geteuid() )
    140146                log_message( LOGLVL_WARNING, "BitlBee is running with root privileges. Why?" );
    141         if( help_init( &global.help, global.helpfile ) == NULL )
    142                 log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );
    143147       
    144148        b_main_run();
Note: See TracChangeset for help on using the changeset viewer.