Changes in irc.c [823de9d:435f552]
Legend:
- Unmodified
- Added
- Removed
-
irc.c
r823de9d r435f552 29 29 #include "crypting.h" 30 30 #include "ipc.h" 31 #include <sys/types.h>32 #include <sys/wait.h>33 31 34 32 static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond ); 35 static void irc_welcome( irc_t* irc );36 33 37 34 GSList *irc_connection_list = NULL; … … 81 78 } 82 79 80 static char *set_eval_away_status( set_t *set, char *value ) 81 { 82 irc_t *irc = set->data; 83 account_t *a; 84 85 g_free( set->value ); 86 set->value = g_strdup( value ); 87 88 for( a = irc->accounts; a; a = a->next ) 89 { 90 struct im_connection *ic = a->ic; 91 92 if( ic && ic->flags & OPT_LOGGED_IN ) 93 imc_away_send_update( ic ); 94 } 95 96 return value; 97 } 98 83 99 irc_t *irc_new( int fd ) 84 100 { … … 145 161 146 162 irc_connection_list = g_slist_append( irc_connection_list, irc ); 147 163 164 s = set_add( &irc->set, "away", NULL, set_eval_away_status, irc ); 165 s->flags |= SET_NULL_OK; 166 s = set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc ); 148 167 s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc ); 149 s = set_add( &irc->set, "auto_reconnect", " false", set_eval_bool, irc );168 s = set_add( &irc->set, "auto_reconnect", "true", set_eval_bool, irc ); 150 169 s = set_add( &irc->set, "auto_reconnect_delay", "5*3<900", set_eval_account_reconnect_delay, irc ); 151 170 s = set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc ); 152 171 s = set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); 153 172 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 );155 173 s = set_add( &irc->set, "debug", "false", set_eval_bool, irc ); 156 174 s = set_add( &irc->set, "default_target", "root", NULL, irc ); 157 175 s = set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 158 176 s = set_add( &irc->set, "handle_unknown", "root", NULL, irc ); 159 s = set_add( &irc->set, "halfop_buddies", "encrypted", set_eval_halfop_buddies, irc );160 177 s = set_add( &irc->set, "lcnicks", "true", set_eval_bool, 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 ); 178 s = set_add( &irc->set, "ops", "both", set_eval_ops, irc ); 164 179 s = set_add( &irc->set, "password", NULL, set_eval_password, irc ); 165 180 s->flags |= SET_NULL_OK; … … 169 184 s = set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc ); 170 185 s = set_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc ); 186 s = set_add( &irc->set, "status", NULL, set_eval_away_status, irc ); 187 s->flags |= SET_NULL_OK; 171 188 s = set_add( &irc->set, "strip_html", "true", NULL, irc ); 172 189 s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); 173 190 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);175 191 176 192 conf_loaddefaults( irc ); 177 178 irc->otr = otr_new(); 179 193 180 194 /* Evaluator sets the iconv/oconv structures. */ 181 195 set_eval_charset( set_find( &irc->set, "charset" ), set_getstr( &irc->set, "charset" ) ); … … 329 343 330 344 g_free( irc->last_target ); 331 332 otr_free(irc->otr);333 345 334 346 g_free( irc ); 335 347 336 348 if( global.conf->runmode == RUNMODE_INETD || 337 349 global.conf->runmode == RUNMODE_FORKDAEMON || … … 418 430 } 419 431 420 if( lines[i] ) 421 { 422 if( ( cmd = irc_parse_line( lines[i] ) ) == NULL ) 423 continue; 432 if( lines[i] && ( cmd = irc_parse_line( lines[i] ) ) ) 433 { 424 434 irc_exec( irc, cmd ); 425 435 g_free( cmd ); … … 496 506 if( line[0] == ':' ) 497 507 { 498 for( i = 0; line[i] != ' '; i ++ );508 for( i = 0; line[i] && line[i] != ' '; i ++ ); 499 509 line = line + i; 500 510 } … … 704 714 } 705 715 706 const 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 else737 return none;738 }739 740 716 void irc_names( irc_t *irc, char *channel ) 741 717 { … … 743 719 char namelist[385] = ""; 744 720 struct groupchat *c = NULL; 721 char *ops = set_getstr( &irc->set, "ops" ); 745 722 746 723 /* RFCs say there is no error reply allowed on NAMES, so when the … … 757 734 } 758 735 759 strcat( namelist, user_mode_prefix(irc, u) ); 736 if( u->ic && !u->away && set_getbool( &irc->set, "away_devoice" ) ) 737 strcat( namelist, "+" ); 738 else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) || 739 ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ) 740 strcat( namelist, "@" ); 741 760 742 strcat( namelist, u->nick ); 761 743 strcat( namelist, " " ); … … 768 750 /* root and the user aren't in the channel userlist but should 769 751 show up in /NAMES, so list them first: */ 770 sprintf( namelist, "%s%s %s%s ", s et_getbool(&irc->set, "op_root") ? "@" : "", irc->mynick,771 s et_getbool(&irc->set, "op_user") ? "@" : "", irc->nick );752 sprintf( namelist, "%s%s %s%s ", strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->mynick, 753 strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->nick ); 772 754 773 755 for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c->ic, l->data ) ) ) … … 779 761 } 780 762 781 strcat( namelist, user_mode_prefix(irc, u) );782 763 strcat( namelist, u->nick ); 783 764 strcat( namelist, " " ); … … 821 802 irc_reply( irc, 3, ":%s", IRCD_INFO ); 822 803 irc_reply( irc, 4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES UMODES_PRIV, CMODES ); 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 ); 804 irc_reply( irc, 5, "PREFIX=(ov)@+ CHANTYPES=%s CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee " 805 "CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", 806 CTYPES, CMODES, MAX_NICK_LENGTH - 1 ); 824 807 irc_motd( irc ); 825 808 irc->umode[0] = '\0'; 826 809 irc_umode_set( irc, "+" UMODE, 1 ); 827 u = user_add( irc, irc->mynick ); 810 811 u = user_add( irc, irc->mynick ); 828 812 u->host = g_strdup( irc->myhost ); 829 813 u->realname = g_strdup( ROOT_FN ); … … 847 831 irc_spawn( irc, u ); 848 832 849 irc_welcome( irc ); 833 irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\n" 834 "If you've never used BitlBee before, please do read the help " 835 "information using the \x02help\x02 command. Lots of FAQs are " 836 "answered there.\n" 837 "If you already have an account on this server, just use the " 838 "\x02identify\x02 command to identify yourself." ); 850 839 851 840 if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON ) … … 862 851 root_command( irc, send_cmd ); 863 852 g_free( send_cmd[1] ); 864 }865 }866 867 static 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 else884 {885 char linebuf[380];886 887 while( fgets( linebuf, 380, f ) )888 {889 irc_usermsg( irc, linebuf );890 }891 892 fclose( f );893 853 } 894 854 } … … 1085 1045 user_t *u = NULL; 1086 1046 1087 if( *nick == '#' || *nick == '&')1047 if( strchr( CTYPES, *nick ) ) 1088 1048 { 1089 1049 if( !( c = irc_chat_by_channel( irc, nick ) ) )
Note: See TracChangeset
for help on using the changeset viewer.