Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    re1720ce r823de9d  
    2929#include "crypting.h"
    3030#include "ipc.h"
     31#include <sys/types.h>
     32#include <sys/wait.h>
    3133
    3234static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond );
     35static void irc_welcome( irc_t* irc );
    3336
    3437GSList *irc_connection_list = NULL;
     
    142145
    143146        irc_connection_list = g_slist_append( irc_connection_list, irc );
    144        
    145         s = set_add( &irc->set, "away_devoice", "true",  set_eval_away_devoice, irc );
     147
    146148        s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc );
    147149        s = set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc );
     
    150152        s = set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc );
    151153        s = set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc );
     154        s = set_add( &irc->set, "color_encrypted", "true", set_eval_bool, irc );
    152155        s = set_add( &irc->set, "debug", "false", set_eval_bool, irc );
    153156        s = set_add( &irc->set, "default_target", "root", NULL, irc );
    154157        s = set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc );
    155158        s = set_add( &irc->set, "handle_unknown", "root", NULL, irc );
     159        s = set_add( &irc->set, "halfop_buddies", "encrypted", set_eval_halfop_buddies, irc );
    156160        s = set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc );
    157         s = set_add( &irc->set, "ops", "both", set_eval_ops, irc );
     161        s = set_add( &irc->set, "op_buddies", "trusted", set_eval_op_buddies, irc );
     162        s = set_add( &irc->set, "op_root", "true", set_eval_op_root, irc );
     163        s = set_add( &irc->set, "otr_policy", "oppurtunistic", set_eval_otr_policy, irc );
    158164        s = set_add( &irc->set, "password", NULL, set_eval_password, irc );
    159165        s->flags |= SET_NULL_OK;
     
    166172        s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc );
    167173        s = set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc );
     174        s = set_add( &irc->set, "voice_buddies", "notaway", set_eval_voice_buddies, irc);
    168175       
    169176        conf_loaddefaults( irc );
    170        
     177
     178        irc->otr = otr_new();
     179
    171180        /* Evaluator sets the iconv/oconv structures. */
    172181        set_eval_charset( set_find( &irc->set, "charset" ), set_getstr( &irc->set, "charset" ) );
     
    320329       
    321330        g_free( irc->last_target );
     331
     332        otr_free(irc->otr);
    322333       
    323334        g_free( irc );
    324        
     335
    325336        if( global.conf->runmode == RUNMODE_INETD ||
    326337            global.conf->runmode == RUNMODE_FORKDAEMON ||
     
    407418                        }
    408419                       
    409                         if( lines[i] && ( cmd = irc_parse_line( lines[i] ) ) )
    410                         {
     420                        if( lines[i] )
     421                        {
     422                                if( ( cmd = irc_parse_line( lines[i] ) ) == NULL )
     423                                        continue;
    411424                                irc_exec( irc, cmd );
    412425                                g_free( cmd );
     
    483496        if( line[0] == ':' )
    484497        {
    485                 for( i = 0; line[i] && line[i] != ' '; i ++ );
     498                for( i = 0; line[i] != ' '; i ++ );
    486499                line = line + i;
    487500        }
     
    691704}
    692705
     706const char *user_mode_prefix( irc_t *irc, user_t *u )
     707{
     708        static char op[] = "@";
     709        static char halfop[] = "%";
     710        static char voice[] = "+";
     711        static char none[] = "";
     712
     713        int or = set_getbool(&irc->set, "op_root");
     714        int ou = set_getbool(&irc->set, "op_user");
     715        char *ob = set_getstr(&irc->set, "op_buddies");
     716        char *hb = set_getstr(&irc->set, "halfop_buddies");
     717        char *vb = set_getstr(&irc->set, "voice_buddies");
     718
     719        if( (!strcmp(u->nick, irc->mynick) && or) ||
     720            (!strcmp(u->nick, irc->nick) && ou) ||
     721        (!u->away && !strcmp(ob, "notaway")) ||
     722        (u->encrypted && !strcmp(ob, "encrypted")) ||
     723        (u->encrypted>1 && !strcmp(ob, "trusted"))
     724      )
     725                return op;
     726        else if( (!u->away && !strcmp(hb, "notaway")) ||
     727             (u->encrypted && !strcmp(hb, "encrypted")) ||
     728             (u->encrypted>1 && !strcmp(hb, "trusted"))
     729               )
     730                return halfop;
     731        else if( (!u->away && !strcmp(vb, "notaway")) ||
     732             (u->encrypted && !strcmp(vb, "encrypted")) ||
     733             (u->encrypted>1 && !strcmp(vb, "trusted"))
     734               )
     735                return voice;
     736        else
     737                return none;
     738}
     739                       
    693740void irc_names( irc_t *irc, char *channel )
    694741{
     
    696743        char namelist[385] = "";
    697744        struct groupchat *c = NULL;
    698         char *ops = set_getstr( &irc->set, "ops" );
    699745       
    700746        /* RFCs say there is no error reply allowed on NAMES, so when the
     
    711757                        }
    712758                       
    713                         if( u->ic && !u->away && set_getbool( &irc->set, "away_devoice" ) )
    714                                 strcat( namelist, "+" );
    715                         else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ||
    716                                  ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) )
    717                                 strcat( namelist, "@" );
    718                        
     759                        strcat( namelist, user_mode_prefix(irc, u) );
    719760                        strcat( namelist, u->nick );
    720761                        strcat( namelist, " " );
     
    727768                /* root and the user aren't in the channel userlist but should
    728769                   show up in /NAMES, so list them first: */
    729                 sprintf( namelist, "%s%s %s%s ", strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->mynick,
    730                                                  strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->nick );
     770                sprintf( namelist, "%s%s %s%s ", set_getbool(&irc->set, "op_root") ? "@" : "", irc->mynick,
     771                                                 set_getbool(&irc->set, "op_user") ? "@" : "", irc->nick );
    731772               
    732773                for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c->ic, l->data ) ) )
     
    738779                        }
    739780                       
     781                        strcat( namelist, user_mode_prefix(irc, u) );
    740782                        strcat( namelist, u->nick );
    741783                        strcat( namelist, " " );
     
    779821        irc_reply( irc,   3, ":%s", IRCD_INFO );
    780822        irc_reply( irc,   4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES UMODES_PRIV, CMODES );
    781         irc_reply( irc,   5, "PREFIX=(ov)@+ CHANTYPES=%s CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee "
    782                              "CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server",
    783                              CTYPES, CMODES, MAX_NICK_LENGTH - 1 );
     823        irc_reply( irc,   5, "PREFIX=(ohv)@%%+ CHANTYPES=#& CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", CMODES, MAX_NICK_LENGTH - 1 );
    784824        irc_motd( irc );
    785825        irc->umode[0] = '\0';
    786826        irc_umode_set( irc, "+" UMODE, 1 );
    787 
    788         u = user_add( irc, irc->mynick );
     827u = user_add( irc, irc->mynick );
    789828        u->host = g_strdup( irc->myhost );
    790829        u->realname = g_strdup( ROOT_FN );
     
    808847        irc_spawn( irc, u );
    809848       
    810         irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\n"
    811                           "If you've never used BitlBee before, please do read the help "
    812                           "information using the \x02help\x02 command. Lots of FAQs are "
    813                           "answered there.\n"
    814                           "If you already have an account on this server, just use the "
    815                           "\x02identify\x02 command to identify yourself." );
     849        irc_welcome( irc );
    816850       
    817851        if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON )
     
    828862                root_command( irc, send_cmd );
    829863                g_free( send_cmd[1] );
     864        }
     865}
     866
     867static void irc_welcome( irc_t *irc )
     868{
     869        FILE *f;
     870       
     871        f = fopen( global.conf->welcomefile, "r" );
     872        if( !f )
     873        {
     874                irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\n"
     875                                  "If you've never used BitlBee before, please do read the help "
     876                                  "information using the \x02help\x02 command. Lots of FAQs are "
     877                                  "answered there.\n"
     878                                  "OTR users please note: Private key files are owned by the user "
     879                                  "BitlBee is running as.\n"
     880                                  "If you already have an account on this server, just use the "
     881                                  "\x02identify\x02 command to identify yourself." );
     882        }
     883        else
     884        {
     885                char linebuf[380];
     886               
     887                while( fgets( linebuf, 380, f ) )
     888                {
     889                        irc_usermsg( irc, linebuf );
     890                }
     891               
     892                fclose( f );
    830893        }
    831894}
     
    10221085        user_t *u = NULL;
    10231086       
    1024         if( strchr( CTYPES, *nick ) )
     1087        if( *nick == '#' || *nick == '&' )
    10251088        {
    10261089                if( !( c = irc_chat_by_channel( irc, nick ) ) )
Note: See TracChangeset for help on using the changeset viewer.