Changeset 601e813 for irc.c


Ignore:
Timestamp:
2006-05-24T23:04:18Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
80c1e4d
Parents:
46ad029 (diff), fc630f9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

[merge] Wilmer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    r46ad029 r601e813  
    199199}
    200200
    201 static gboolean irc_free_userhash( gpointer key, gpointer value, gpointer data )
     201static gboolean irc_free_hashkey( gpointer key, gpointer value, gpointer data )
    202202{
    203203        g_free( key );
     
    232232        irc_connection_list = g_slist_remove( irc_connection_list, irc );
    233233       
    234         for (account = irc->accounts; account; account = account->next)
    235                 if (account->gc)
     234        for (account = irc->accounts; account; account = account->next) {
     235                if (account->gc) {
     236                        account->gc->wants_to_die = TRUE;
    236237                        signoff(account->gc);
     238                } else if (account->reconnect) {
     239                        cancel_auto_reconnect(account);
     240                }
     241        }
    237242       
    238243        g_free(irc->sendbuffer);
     
    282287        }
    283288       
    284         g_hash_table_foreach_remove(irc->userhash, irc_free_userhash, NULL);
     289        g_hash_table_foreach_remove(irc->userhash, irc_free_hashkey, NULL);
    285290        g_hash_table_destroy(irc->userhash);
    286291       
    287         g_hash_table_foreach_remove(irc->watches, irc_free_userhash, NULL);
     292        g_hash_table_foreach_remove(irc->watches, irc_free_hashkey, NULL);
    288293        g_hash_table_destroy(irc->watches);
    289294       
     
    343348void irc_process( irc_t *irc )
    344349{
    345         char **lines, *temp, **cmd;
     350        char **lines, *temp, **cmd, *cs;
    346351        int i;
    347352
     
    352357                for( i = 0; *lines[i] != '\0'; i ++ )
    353358                {
     359                        char conv[IRC_MAX_LINE+1];
     360                       
     361                        /* [WvG] Because irc_tokenize splits at every newline, the lines[] list
     362                            should end with an empty string. This is why this actually works.
     363                            Took me a while to figure out, Maurits. :-P */
    354364                        if( lines[i+1] == NULL )
    355365                        {
     
    359369                                i ++;
    360370                                break;
    361                         }                       
     371                        }
     372                       
     373                        if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )
     374                        {
     375                                conv[IRC_MAX_LINE] = 0;
     376                                if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) != -1 )
     377                                        lines[i] = conv;
     378                        }
    362379                       
    363380                        if( ( cmd = irc_parse_line( lines[i] ) ) == NULL )
     
    385402}
    386403
     404/* Splits a long string into separate lines. The array is NULL-terminated and, unless the string
     405   contains an incomplete line at the end, ends with an empty string. */
    387406char **irc_tokenize( char *buffer )
    388407{
     
    425444}
    426445
     446/* Split an IRC-style line into little parts/arguments. */
    427447char **irc_parse_line( char *line )
    428448{
     
    484504}
    485505
     506/* Converts such an array back into a command string. Mainly used for the IPC code right now. */
    486507char *irc_build_line( char **cmd )
    487508{
     
    536557       
    537558        u = user_find( irc, irc->mynick );
    538         if( u ) is_private = u->is_private;
     559        is_private = u->is_private;
    539560       
    540561        va_start( params, format );
     
    560581{
    561582        int size;
    562         char line[IRC_MAX_LINE];
    563        
     583        char line[IRC_MAX_LINE+1], *cs;
     584               
    564585        if( irc->quit )
    565586                return;
    566 
    567         g_vsnprintf( line, IRC_MAX_LINE - 3, format, params );
    568 
     587       
     588        line[IRC_MAX_LINE] = 0;
     589        g_vsnprintf( line, IRC_MAX_LINE - 2, format, params );
     590       
    569591        strip_newlines( line );
     592        if( ( cs = set_getstr( irc, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) )
     593        {
     594                char conv[IRC_MAX_LINE+1];
     595               
     596                conv[IRC_MAX_LINE] = 0;
     597                if( do_iconv( "UTF-8", cs, line, conv, 0, IRC_MAX_LINE - 2 ) != -1 )
     598                        strcpy( line, conv );
     599        }
    570600        strcat( line, "\r\n" );
    571 
     601       
    572602        if( irc->sendbuffer != NULL ) {
    573603                size = strlen( irc->sendbuffer ) + strlen( line );
     
    800830                        irc_reply( irc, 332, "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", channel, c->title );
    801831                else
    802                         irc_reply( irc, 331, "%s :No topic for this channel" );
     832                        irc_reply( irc, 331, "%s :No topic for this channel", channel );
    803833        }
    804834}
     
    856886        if( g_hash_table_lookup( irc->watches, nick ) )
    857887        {
    858                 irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged online" );
     888                irc_reply( irc, 600, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged online" );
    859889        }
    860890        g_free( nick );
     
    881911        if( g_hash_table_lookup( irc->watches, nick ) )
    882912        {
    883                 irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, time( NULL ), "logged offline" );
     913                irc_reply( irc, 601, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "logged offline" );
    884914        }
    885915        g_free( nick );
     
    9811011        else if( c && c->gc && c->gc->prpl )
    9821012        {
    983                 return( serv_send_chat( irc, c->gc, c->id, s ) );
     1013                return( bim_chat_msg( c->gc, c->id, s ) );
    9841014        }
    9851015       
     
    9911021        user_t *u = data;
    9921022       
     1023        /* Shouldn't happen, but just to be sure. */
     1024        if( u->sendbuf_len < 2 )
     1025                return FALSE;
     1026       
    9931027        u->sendbuf[u->sendbuf_len-2] = 0; /* Cut off the last newline */
    994         serv_send_im( u->gc->irc, u, u->sendbuf, u->sendbuf_flags );
     1028        bim_buddy_msg( u->gc, u->handle, u->sendbuf, u->sendbuf_flags );
    9951029       
    9961030        g_free( u->sendbuf );
     
    10001034        u->sendbuf_flags = 0;
    10011035       
    1002         return( FALSE );
     1036        return FALSE;
    10031037}
    10041038
     
    10131047                if( u->sendbuf_len > 0 && u->sendbuf_flags != flags)
    10141048                {
    1015                         //Flush the buffer
     1049                        /* Flush the buffer */
    10161050                        g_source_remove( u->sendbuf_timer );
    10171051                        buddy_send_handler_delayed( u );
     
    10211055                {
    10221056                        u->sendbuf_len = strlen( msg ) + 2;
    1023                         u->sendbuf = g_new (char, u->sendbuf_len );
     1057                        u->sendbuf = g_new( char, u->sendbuf_len );
    10241058                        u->sendbuf[0] = 0;
    10251059                        u->sendbuf_flags = flags;
     
    10281062                {
    10291063                        u->sendbuf_len += strlen( msg ) + 1;
    1030                         u->sendbuf = g_renew ( char, u->sendbuf, u->sendbuf_len );
     1064                        u->sendbuf = g_renew( char, u->sendbuf, u->sendbuf_len );
    10311065                }
    10321066               
     
    10441078        else
    10451079        {
    1046                 serv_send_im( irc, u, msg, flags );
     1080                bim_buddy_msg( u->gc, u->handle, msg, flags );
    10471081        }
    10481082}
Note: See TracChangeset for help on using the changeset viewer.