From e05c13a0973f6758c4de91d07afc4bb8a8c90f42 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Mon, 22 Oct 2012 20:00:08 +0200 Subject: [PATCH] More fixes, sorting and cleanup --- src/common/cfgfiles.c | 209 ++++++++++++++++++++++-------------------- src/common/ignore.c | 2 +- src/common/xchat.h | 196 ++++++++++++++++++++------------------- 3 files changed, 210 insertions(+), 197 deletions(-) diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index a22edd5f..2312dada 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -432,7 +432,7 @@ const struct prefs vars[] = {"flood_ctcp_num", P_OFFINT (hex_flood_ctcp_num), TYPE_INT}, {"flood_ctcp_time", P_OFFINT (hex_flood_ctcp_time), TYPE_INT}, - {"flood_msg_num", P_OFFINT (hex_flood_msg_time), TYPE_INT}, + {"flood_msg_num", P_OFFINT (hex_flood_msg_num), TYPE_INT}, {"flood_msg_time", P_OFFINT (hex_flood_msg_time), TYPE_INT}, {"gui_autoopen_chat", P_OFFINT (hex_gui_autoopen_chat), TYPE_BOOL}, @@ -637,6 +637,9 @@ load_config (void) char *cfg, *sp; const char *username, *realname; int res, val, i, fh; +#ifdef WIN32 + char out[256]; +#endif check_prefs_dir (); username = g_get_user_name (); @@ -655,137 +658,143 @@ load_config (void) memset (&prefs, 0, sizeof (struct hexchatprefs)); /* put in default values, anything left out is automatically zero */ - prefs.local_ip = 0xffffffff; - prefs.hex_irc_join_delay = 3; - prefs.hex_text_show_marker = 1; - prefs.hex_gui_tab_newtofront = 2; - prefs.hex_completion_amount = 5; - prefs.hex_away_timeout = 60; - prefs.hex_away_size_max = 300; - prefs.hex_away_track = 1; - prefs.hex_stamp_log = 1; - prefs.hex_gui_tab_trunc = 20; - prefs.hex_dcc_auto_resume = 1; + + /* BOOLEANS */ prefs.hex_away_show_once = 1; - prefs.hex_text_indent = 1; - prefs.hex_text_thin_sep = 1; - prefs.hex_identd = 1; + prefs.hex_away_track = 1; + prefs.hex_dcc_auto_resume = 1; #ifndef WIN32 prefs.hex_dcc_fast_send = 1; #endif - prefs.hex_text_wordwrap = 1; + prefs.hex_gui_autoopen_chat = 1; prefs.hex_gui_autoopen_dialog = 1; - prefs.hex_gui_input_spell = 1; - prefs.hex_gui_lang = 15; - prefs.hex_net_auto_reconnect = 1; - prefs.hex_net_reconnect_delay = 10; - prefs.hex_text_autocopy_text = 1; - prefs.hex_text_replay = 1; - prefs.hex_text_stripcolor_replay = 1; - prefs.hex_text_stripcolor_topic = 1; - prefs.hex_gui_tab_chans = 1; - prefs.hex_gui_tab_layout = 2; /* 0=Tabs 1=Reserved 2=Tree */ - prefs.hex_gui_tab_icons = 1; - prefs.hex_gui_tab_sort = 1; - prefs.hex_gui_ulist_count = 1; - prefs.hex_gui_ulist_resizable = 1; - prefs.hex_gui_tab_newtofront = 2; - prefs.hex_gui_tab_server = 1; - prefs.hex_gui_tab_dialogs = 1; - /* prefs.hex_text_color_nicks = 1; */ - prefs.hex_gui_input_style = 1; - prefs.hex_gui_ulist_style = 1; - prefs.hex_dcc_permissions = 0600; - prefs.hex_text_max_lines = 500; - prefs.hex_gui_win_width = 640; - prefs.hex_gui_win_height = 400; - prefs.hex_gui_dialog_width = 500; - prefs.hex_gui_dialog_height = 256; - prefs.hex_gui_join_dialog = 1; - prefs.hex_gui_quit_dialog = 1; - prefs.hex_dcc_timeout = 180; - prefs.hex_dcc_stall_timeout = 60; - prefs.hex_notify_timeout = 15; - prefs.hex_text_tint_red = - prefs.hex_text_tint_green = - prefs.hex_text_tint_blue = 195; - prefs.hex_text_max_indent = 256; - prefs.hex_text_show_sep = 1; - prefs.hex_dcc_blocksize = 1024; - prefs.hex_net_throttle = 1; - /*FIXME*/ prefs.hex_flood_msg_time = 30; - prefs.hex_flood_msg_time = 5; - prefs.hex_flood_ctcp_time = 30; - prefs.hex_flood_ctcp_num = 5; - prefs.hex_gui_input_nick = 1; - prefs.hex_gui_topicbar = 1; - prefs.hex_gui_lagometer = 1; - prefs.hex_gui_throttlemeter = 1; prefs.hex_gui_autoopen_recv = 1; prefs.hex_gui_autoopen_send = 1; - prefs.hex_gui_autoopen_chat = 1; - /* prevent kicks and bans caused by overwhelming who'ing after reconnects */ - /* prefs.userhost = 1; */ + prefs.hex_gui_input_nick = 1; + prefs.hex_gui_input_spell = 1; + prefs.hex_gui_input_style = 1; + prefs.hex_gui_join_dialog = 1; + prefs.hex_gui_quit_dialog = 1; + prefs.hex_gui_tab_chans = 1; + prefs.hex_gui_tab_dialogs = 1; + prefs.hex_gui_tab_dots = 1; + prefs.hex_gui_tab_icons = 1; + prefs.hex_gui_tab_server = 1; + prefs.hex_gui_tab_sort = 1; + prefs.hex_gui_topicbar = 1; + prefs.hex_gui_tray = 1; + prefs.hex_gui_ulist_count = 1; + prefs.hex_gui_ulist_icons = 1; + prefs.hex_gui_ulist_resizable = 1; + prefs.hex_gui_ulist_style = 1; + prefs.hex_gui_win_save = 1; + prefs.hex_identd = 1; + prefs.hex_input_flash_hilight = 1; + prefs.hex_input_flash_priv = 1; + prefs.hex_input_tray_hilight = 1; + prefs.hex_input_tray_priv = 1; + /* prefs.hex_irc_who_join = 1; prevent kicks and bans caused by overwhelming who'ing after reconnects */ + prefs.hex_net_auto_reconnect = 1; + prefs.hex_net_throttle = 1; + prefs.hex_stamp_log = 1; + prefs.hex_stamp_text = 1; + prefs.hex_text_autocopy_text = 1; + prefs.hex_text_indent = 1; + prefs.hex_text_replay = 1; + prefs.hex_text_search_follow = 1; + prefs.hex_text_show_marker = 1; + prefs.hex_text_show_sep = 1; + prefs.hex_text_stripcolor_replay = 1; + prefs.hex_text_stripcolor_topic = 1; + prefs.hex_text_thin_sep = 1; + prefs.hex_text_wordwrap = 1; + prefs.hex_url_grabber = 1; + + /* NUMBERS */ + prefs.hex_away_size_max = 300; + prefs.hex_away_timeout = 60; + prefs.hex_completion_amount = 5; + prefs.hex_dcc_auto_recv = 1; /* browse mode */ + prefs.hex_dcc_blocksize = 1024; + prefs.hex_dcc_permissions = 0600; + prefs.hex_dcc_stall_timeout = 60; + prefs.hex_dcc_timeout = 180; + prefs.hex_flood_ctcp_num = 5; + prefs.hex_flood_ctcp_time = 30; + prefs.hex_flood_msg_num = 5; + /*FIXME*/ prefs.hex_flood_msg_time = 30; prefs.hex_gui_chanlist_maxusers = 9999; prefs.hex_gui_chanlist_minusers = 5; - prefs.hex_gui_tab_dots = 1; - prefs.hex_gui_tray = 1; + prefs.hex_gui_dialog_height = 256; + prefs.hex_gui_dialog_width = 500; + prefs.hex_gui_lagometer = 1; + prefs.hex_gui_lang = 15; prefs.hex_gui_pane_left_size = 128; /* with treeview icons we need a bit bigger space */ prefs.hex_gui_pane_right_size = 100; prefs.hex_gui_pane_right_size_min = 80; + prefs.hex_gui_tab_layout = 2; /* 0=Tabs 1=Reserved 2=Tree */ + prefs.hex_gui_tab_newtofront = 2; prefs.hex_gui_tab_pos = 1; - prefs.hex_gui_ulist_icons = 1; + prefs.hex_gui_tab_trunc = 20; + prefs.hex_gui_throttlemeter = 1; prefs.hex_gui_ulist_pos = 3; - prefs.hex_gui_win_save = 1; - prefs.hex_irc_ban_type = 2; + prefs.hex_gui_win_height = 400; + prefs.hex_gui_win_width = 640; prefs.hex_input_balloon_time = 20; - prefs.hex_input_flash_priv = prefs.hex_input_flash_hilight = 1; - prefs.hex_input_tray_priv = prefs.hex_input_tray_hilight = 1; - prefs.hex_dcc_auto_recv = 1; /* browse mode */ - prefs.hex_url_grabber = 1; - prefs.hex_url_grabber_limit = 100; /* 0 means unlimited */ - prefs.hex_text_search_follow = 1; - prefs.hex_stamp_text = 1; - strcpy (prefs.hex_text_spell_langs, g_getenv ("LC_ALL") ? g_getenv ("LC_ALL") : "en_US"); - strcpy (prefs.hex_stamp_text_format, "[%H:%M:%S] "); - strcpy (prefs.hex_stamp_log_format, "%b %d %H:%M:%S "); - strcpy (prefs.hex_irc_logmask, "%n-%c.log"); + prefs.hex_irc_ban_type = 2; + prefs.hex_irc_join_delay = 3; + prefs.hex_net_reconnect_delay = 10; + prefs.hex_notify_timeout = 15; + prefs.hex_text_max_indent = 256; + prefs.hex_text_max_lines = 500; + prefs.hex_text_tint_blue = 195; + prefs.hex_text_tint_green = 195; + prefs.hex_text_tint_red = 195; + prefs.hex_url_grabber_limit = 100; /* 0 means unlimited */ + + /* STRINGS */ + strcpy (prefs.hex_away_reason, _("I'm busy")); strcpy (prefs.hex_completion_suffix, ","); +#ifdef WIN32 + if (portable_mode () || !get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Personal", out, sizeof (out))) + { + snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s\\downloads", get_xdir_utf8 ()); + } + else + { + snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s\\Downloads", out); + } +#else + snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s/downloads", get_xdir_utf8 ()); +#endif + strcpy (prefs.hex_dnsprogram, "host"); + strcpy (prefs.hex_gui_ulist_doubleclick, "QUOTE WHOIS %s %s"); strcpy (prefs.hex_input_command_char, "/"); + strcpy (prefs.hex_irc_logmask, "%n-%c.log"); strcpy (prefs.hex_irc_nick1, username); strcpy (prefs.hex_irc_nick2, username); strcat (prefs.hex_irc_nick2, "_"); strcpy (prefs.hex_irc_nick3, username); strcat (prefs.hex_irc_nick3, "__"); + strcpy (prefs.hex_irc_no_hilight, "NickServ,ChanServ,InfoServ,N,Q"); + strcpy (prefs.hex_irc_part_reason, _("Leaving")); + strcpy (prefs.hex_irc_quit_reason, prefs.hex_irc_part_reason); strcpy (prefs.hex_irc_real_name, realname); strcpy (prefs.hex_irc_user_name, username); #ifdef WIN32 strcpy (prefs.hex_sound_dir, "./sounds"); - { - char out[256]; - - if (portable_mode () || !get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Personal", out, sizeof (out))) - { - snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s\\downloads", get_xdir_utf8 ()); - } - else - { - snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s\\Downloads", out); - } - } #else snprintf (prefs.hex_sound_dir, sizeof (prefs.hex_sound_dir), "%s/sounds", get_xdir_utf8 ()); - snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s/downloads", get_xdir_utf8 ()); #endif - strcpy (prefs.hex_gui_ulist_doubleclick, "QUOTE WHOIS %s %s"); - strcpy (prefs.hex_away_reason, _("I'm busy")); - strcpy (prefs.hex_irc_quit_reason, _("Leaving")); - strcpy (prefs.hex_irc_part_reason, prefs.hex_irc_quit_reason); + strcpy (prefs.hex_stamp_log_format, "%b %d %H:%M:%S "); + strcpy (prefs.hex_stamp_text_format, "[%H:%M:%S] "); strcpy (prefs.hex_text_font, DEF_FONT); strcpy (prefs.hex_text_font_main, DEF_FONT); strcpy (prefs.hex_text_font_alternative, DEF_FONT_ALTER); - strcpy (prefs.hex_dnsprogram, "host"); - strcpy (prefs.hex_irc_no_hilight, "NickServ,ChanServ,InfoServ,N,Q"); + strcpy (prefs.hex_text_spell_langs, g_getenv ("LC_ALL") ? g_getenv ("LC_ALL") : "en_US"); + + /* private variables */ + prefs.local_ip = 0xffffffff; g_free ((char *)username); g_free ((char *)realname); diff --git a/src/common/ignore.c b/src/common/ignore.c index aea482a2..12a2926a 100644 --- a/src/common/ignore.c +++ b/src/common/ignore.c @@ -401,7 +401,7 @@ flood_check (char *nick, char *ip, server *serv, session *sess, int what) /*0=ct prefs.hex_flood_msg_time) { serv->msg_counter++; - if (serv->msg_counter == prefs.hex_flood_msg_time) /*if we reached the maximun numbers of ctcp in the seconds limits */ + if (serv->msg_counter == prefs.hex_flood_msg_num) /*if we reached the maximun numbers of ctcp in the seconds limits */ { snprintf (buf, sizeof (buf), _("You are being MSG flooded from %s, setting gui_auto_open_dialog OFF.\n"), diff --git a/src/common/xchat.h b/src/common/xchat.h index c7bac850..a19716f6 100644 --- a/src/common/xchat.h +++ b/src/common/xchat.h @@ -105,103 +105,8 @@ struct nbexec struct hexchatprefs { /* these are the rebranded, consistent, sorted hexchat variables */ - char hex_away_reason[256]; - char hex_completion_suffix[4]; /* Only ever holds a one-character string. */ - char hex_dcc_completed_dir[PATHLEN + 1]; - char hex_dcc_dir[PATHLEN + 1]; - char hex_dcc_ip[DOMAINLEN + 1]; - char hex_dnsprogram[72]; - char hex_gui_ulist_doubleclick[256]; - char hex_input_command_char[4]; - char hex_irc_extra_hilight[300]; - char hex_irc_id_ntext[64]; - char hex_irc_id_ytext[64]; - char hex_irc_logmask[256]; - char hex_irc_nick1[NICKLEN]; - char hex_irc_nick2[NICKLEN]; - char hex_irc_nick3[NICKLEN]; - char hex_irc_nick_hilight[300]; - char hex_irc_no_hilight[300]; - char hex_irc_part_reason[256]; - char hex_irc_quit_reason[256]; - char hex_irc_real_name[127]; - char hex_irc_user_name[127]; - char hex_net_bind_host[127]; - char hex_net_proxy_host[64]; - char hex_net_proxy_pass[32]; - char hex_net_proxy_user[32]; - char hex_sound_command[PATHLEN + 1]; - char hex_sound_dir[PATHLEN + 1]; - char hex_stamp_log_format[64]; - char hex_stamp_text_format[64]; - char hex_text_background[PATHLEN + 1]; - char hex_text_font[4 * FONTNAMELEN + 1]; - char hex_text_font_main[FONTNAMELEN + 1]; - char hex_text_font_alternative[3 * FONTNAMELEN + 1]; - char hex_text_spell_langs[64]; - - int hex_away_size_max; - int hex_away_timeout; - int hex_completion_amount; - int hex_completion_sort; - int hex_dcc_auto_recv; - int hex_dcc_blocksize; - int hex_dcc_global_max_get_cps; - int hex_dcc_global_max_send_cps; - int hex_dcc_max_get_cps; - int hex_dcc_max_send_cps; - int hex_dcc_permissions; - int hex_dcc_port_first; - int hex_dcc_port_last; - int hex_dcc_stall_timeout; - int hex_dcc_timeout; - int hex_flood_ctcp_num; /*flood */ - int hex_flood_ctcp_time; /*seconds of floods */ - int hex_flood_msg_num; /*same deal */ - int hex_flood_msg_time; - int hex_gui_chanlist_maxusers; - int hex_gui_chanlist_minusers; - int hex_gui_dialog_height; - int hex_gui_dialog_left; - int hex_gui_dialog_top; - int hex_gui_dialog_width; - int hex_gui_lagometer; - int hex_gui_lang; - int hex_gui_pane_left_size; - int hex_gui_pane_right_size; - int hex_gui_pane_right_size_min; - int hex_gui_slist_select; - int hex_gui_tab_layout; - int hex_gui_tab_newtofront; - int hex_gui_tab_pos; - int hex_gui_tab_small; - int hex_gui_tab_trunc; - int hex_gui_throttlemeter; - int hex_gui_tray_flags; - int hex_gui_ulist_pos; - int hex_gui_ulist_sort; - int hex_gui_url_mod; - int hex_gui_win_height; - int hex_gui_win_left; - int hex_gui_win_state; - int hex_gui_win_top; - int hex_gui_win_width; - int hex_input_balloon_time; - int hex_irc_ban_type; - int hex_irc_join_delay; - int hex_net_ping_timeout; - int hex_net_proxy_port; - int hex_net_proxy_type; /* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */ - int hex_net_proxy_use; /* 0=all 1=IRC_ONLY 2=DCC_ONLY */ - int hex_net_reconnect_delay; - int hex_notify_timeout; - int hex_text_max_indent; - int hex_text_max_lines; - int hex_text_tint_blue; - int hex_text_tint_green; - int hex_text_tint_red; - int hex_url_grabber_limit; + /* BOOLEANS */ unsigned int hex_away_auto_unmark; unsigned int hex_away_omit_alerts; unsigned int hex_away_show_message; @@ -309,6 +214,105 @@ struct hexchatprefs unsigned int hex_url_grabber; unsigned int hex_url_logging; + /* NUMBERS */ + int hex_away_size_max; + int hex_away_timeout; + int hex_completion_amount; + int hex_completion_sort; + int hex_dcc_auto_recv; + int hex_dcc_blocksize; + int hex_dcc_global_max_get_cps; + int hex_dcc_global_max_send_cps; + int hex_dcc_max_get_cps; + int hex_dcc_max_send_cps; + int hex_dcc_permissions; + int hex_dcc_port_first; + int hex_dcc_port_last; + int hex_dcc_stall_timeout; + int hex_dcc_timeout; + int hex_flood_ctcp_num; /* flood */ + int hex_flood_ctcp_time; /* seconds of floods */ + int hex_flood_msg_num; /* same deal */ + int hex_flood_msg_time; + int hex_gui_chanlist_maxusers; + int hex_gui_chanlist_minusers; + int hex_gui_dialog_height; + int hex_gui_dialog_left; + int hex_gui_dialog_top; + int hex_gui_dialog_width; + int hex_gui_lagometer; + int hex_gui_lang; + int hex_gui_pane_left_size; + int hex_gui_pane_right_size; + int hex_gui_pane_right_size_min; + int hex_gui_slist_select; + int hex_gui_tab_layout; + int hex_gui_tab_newtofront; + int hex_gui_tab_pos; + int hex_gui_tab_small; + int hex_gui_tab_trunc; + int hex_gui_throttlemeter; + int hex_gui_tray_flags; + int hex_gui_ulist_pos; + int hex_gui_ulist_sort; + int hex_gui_url_mod; + int hex_gui_win_height; + int hex_gui_win_left; + int hex_gui_win_state; + int hex_gui_win_top; + int hex_gui_win_width; + int hex_input_balloon_time; + int hex_irc_ban_type; + int hex_irc_join_delay; + int hex_net_ping_timeout; + int hex_net_proxy_port; + int hex_net_proxy_type; /* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */ + int hex_net_proxy_use; /* 0=all 1=IRC_ONLY 2=DCC_ONLY */ + int hex_net_reconnect_delay; + int hex_notify_timeout; + int hex_text_max_indent; + int hex_text_max_lines; + int hex_text_tint_blue; + int hex_text_tint_green; + int hex_text_tint_red; + int hex_url_grabber_limit; + + /* STRINGS */ + char hex_away_reason[256]; + char hex_completion_suffix[4]; /* Only ever holds a one-character string. */ + char hex_dcc_completed_dir[PATHLEN + 1]; + char hex_dcc_dir[PATHLEN + 1]; + char hex_dcc_ip[DOMAINLEN + 1]; + char hex_dnsprogram[72]; + char hex_gui_ulist_doubleclick[256]; + char hex_input_command_char[4]; + char hex_irc_extra_hilight[300]; + char hex_irc_id_ntext[64]; + char hex_irc_id_ytext[64]; + char hex_irc_logmask[256]; + char hex_irc_nick1[NICKLEN]; + char hex_irc_nick2[NICKLEN]; + char hex_irc_nick3[NICKLEN]; + char hex_irc_nick_hilight[300]; + char hex_irc_no_hilight[300]; + char hex_irc_part_reason[256]; + char hex_irc_quit_reason[256]; + char hex_irc_real_name[127]; + char hex_irc_user_name[127]; + char hex_net_bind_host[127]; + char hex_net_proxy_host[64]; + char hex_net_proxy_pass[32]; + char hex_net_proxy_user[32]; + char hex_sound_command[PATHLEN + 1]; + char hex_sound_dir[PATHLEN + 1]; + char hex_stamp_log_format[64]; + char hex_stamp_text_format[64]; + char hex_text_background[PATHLEN + 1]; + char hex_text_font[4 * FONTNAMELEN + 1]; + char hex_text_font_main[FONTNAMELEN + 1]; + char hex_text_font_alternative[3 * FONTNAMELEN + 1]; + char hex_text_spell_langs[64]; + /* these are the private variables */ guint32 local_ip; guint32 dcc_ip;