diff options
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/core/irc-commands.c | 15 | ||||
-rw-r--r-- | src/irc/core/irc-servers-reconnect.c | 2 | ||||
-rw-r--r-- | src/irc/core/irc-servers.c | 6 | ||||
-rw-r--r-- | src/irc/core/lag.c | 8 | ||||
-rw-r--r-- | src/irc/dcc/dcc-autoget.c | 6 | ||||
-rw-r--r-- | src/irc/dcc/dcc.c | 4 | ||||
-rw-r--r-- | src/irc/flood/autoignore.c | 12 | ||||
-rw-r--r-- | src/irc/notifylist/notify-commands.c | 16 | ||||
-rw-r--r-- | src/irc/notifylist/notify-ison.c | 13 |
9 files changed, 43 insertions, 39 deletions
diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c index d7512de2..8c888ffe 100644 --- a/src/irc/core/irc-commands.c +++ b/src/irc/core/irc-commands.c @@ -736,7 +736,7 @@ static int knockout_timeout(void) return 1; } -/* SYNTAX: KNOCKOUT [<seconds>] <nicks> <reason> */ +/* SYNTAX: KNOCKOUT [<time>] <nicks> <reason> */ static void cmd_knockout(const char *data, IRC_SERVER_REC *server, IRC_CHANNEL_REC *channel) { @@ -753,20 +753,21 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server, if (!channel->wholist) cmd_return_error(CMDERR_CHAN_NOT_SYNCED); - if (is_numeric(data, ' ')) { + if (i_isdigit(*data)) { /* first argument is the timeout */ if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, &timeoutstr, &nicks, &reason)) return; - timeleft = atoi(timeoutstr); + + if (!parse_time_interval(timeoutstr, &timeleft)) + cmd_param_error(CMDERR_INVALID_TIME); } else { if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &nicks, &reason)) return; - timeleft = 0; + timeleft = settings_get_time("knockout_time"); } - if (timeleft == 0) timeleft = settings_get_int("knockout_time"); if (*nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); nicklist = g_strsplit(nicks, ",", -1); @@ -797,7 +798,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server, else { /* create knockout record */ rec = g_new(KNOCKOUT_REC, 1); - rec->unban_time = time(NULL)+timeleft; + rec->unban_time = time(NULL)+timeleft/1000; rec->channel = channel; rec->ban = banmasks; @@ -916,7 +917,7 @@ void irc_commands_init(void) tmpstr = g_string_new(NULL); settings_add_str("misc", "part_message", ""); - settings_add_int("misc", "knockout_time", 300); + settings_add_time("misc", "knockout_time", "5min"); settings_add_str("misc", "wall_format", "[Wall/$0] $1-"); settings_add_bool("misc", "kick_first_on_kickban", FALSE); diff --git a/src/irc/core/irc-servers-reconnect.c b/src/irc/core/irc-servers-reconnect.c index c2649f5e..7e66b255 100644 --- a/src/irc/core/irc-servers-reconnect.c +++ b/src/irc/core/irc-servers-reconnect.c @@ -88,7 +88,7 @@ static void event_nick_collision(IRC_SERVER_REC *server, const char *data) don't connect to the server more than once in every 10 seconds. */ new_connect = server->connect_time+10 - - settings_get_int("server_reconnect_time"); + settings_get_time("server_reconnect_time")/1000; if (server->connect_time > new_connect) server->connect_time = new_connect; diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index b1a7b007..fa3ded76 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -46,7 +46,7 @@ #define DEFAULT_MAX_MSGS 1 #define DEFAULT_USER_MODE "+i" -#define DEFAULT_CMD_QUEUE_SPEED 2200 +#define DEFAULT_CMD_QUEUE_SPEED "2200msec" #define DEFAULT_CMDS_MAX_AT_ONCE 5 #define DEFAULT_MAX_QUERY_CHANS 1 /* more and more IRC networks are using stupid ircds.. */ @@ -180,7 +180,7 @@ SERVER_REC *irc_server_init_connect(SERVER_CONNECT_REC *conn) } server->cmd_queue_speed = ircconn->cmd_queue_speed > 0 ? - ircconn->cmd_queue_speed : settings_get_int("cmd_queue_speed"); + ircconn->cmd_queue_speed : settings_get_time("cmd_queue_speed"); server->max_cmds_at_once = ircconn->max_cmds_at_once > 0 ? ircconn->max_cmds_at_once : settings_get_int("cmds_max_at_once"); server->max_query_chans = ircconn->max_query_chans > 0 ? @@ -587,7 +587,7 @@ static void event_empty(void) void irc_servers_init(void) { settings_add_str("misc", "usermode", DEFAULT_USER_MODE); - settings_add_int("flood", "cmd_queue_speed", DEFAULT_CMD_QUEUE_SPEED); + settings_add_time("flood", "cmd_queue_speed", DEFAULT_CMD_QUEUE_SPEED); settings_add_int("flood", "cmds_max_at_once", DEFAULT_CMDS_MAX_AT_ONCE); cmd_tag = g_timeout_add(500, (GSourceFunc) servers_cmd_timeout, NULL); diff --git a/src/irc/core/lag.c b/src/irc/core/lag.c index e919b3fc..7d4f51ed 100644 --- a/src/irc/core/lag.c +++ b/src/irc/core/lag.c @@ -88,8 +88,8 @@ static int sig_check_lag(void) time_t now; int lag_check_time, max_lag; - lag_check_time = settings_get_int("lag_check_time"); - max_lag = settings_get_int("lag_max_before_disconnect"); + lag_check_time = settings_get_time("lag_check_time")/1000; + max_lag = settings_get_time("lag_max_before_disconnect")/1000; if (lag_check_time <= 0) return 1; @@ -122,8 +122,8 @@ static int sig_check_lag(void) void lag_init(void) { - settings_add_int("misc", "lag_check_time", 60); - settings_add_int("misc", "lag_max_before_disconnect", 300); + settings_add_time("misc", "lag_check_time", "1min"); + settings_add_time("misc", "lag_max_before_disconnect", "5min"); timeout_tag = g_timeout_add(1000, (GSourceFunc) sig_check_lag, NULL); signal_add_first("lag pong", (SIGNAL_FUNC) lag_event_pong); diff --git a/src/irc/dcc/dcc-autoget.c b/src/irc/dcc/dcc-autoget.c index 87dd00d8..bf9a3b66 100644 --- a/src/irc/dcc/dcc-autoget.c +++ b/src/irc/dcc/dcc-autoget.c @@ -57,8 +57,8 @@ static void sig_dcc_request(GET_DCC_REC *dcc, const char *nickaddr) /* check file size limit, NOTE: it's still possible to send a bogus file size and then just send what ever sized file.. */ - max_size = settings_get_int("dcc_autoget_max_size"); - if (max_size > 0 && (uoff_t)max_size*1024 < dcc->size) + max_size = settings_get_size("dcc_autoget_max_size"); + if (max_size > 0 && (uoff_t)max_size < dcc->size) return; /* ok. but do we want/need to resume? */ @@ -77,7 +77,7 @@ void dcc_autoget_init(void) settings_add_bool("dcc", "dcc_autoget", FALSE); settings_add_bool("dcc", "dcc_autoaccept_lowports", FALSE); settings_add_bool("dcc", "dcc_autoresume", FALSE); - settings_add_int("dcc", "dcc_autoget_max_size", 0); + settings_add_size("dcc", "dcc_autoget_max_size", 0); settings_add_str("dcc", "dcc_autoget_masks", ""); signal_add_last("dcc request", (SIGNAL_FUNC) sig_dcc_request); diff --git a/src/irc/dcc/dcc.c b/src/irc/dcc/dcc.c index 44ef3f20..e3e04107 100644 --- a/src/irc/dcc/dcc.c +++ b/src/irc/dcc/dcc.c @@ -420,7 +420,7 @@ static int dcc_timeout_func(void) GSList *tmp, *next; time_t now; - now = time(NULL)-settings_get_int("dcc_timeout"); + now = time(NULL)-settings_get_time("dcc_timeout")/1000; for (tmp = dcc_conns; tmp != NULL; tmp = next) { DCC_REC *dcc = tmp->data; @@ -514,7 +514,7 @@ void irc_dcc_init(void) dcc_timeouttag = g_timeout_add(1000, (GSourceFunc) dcc_timeout_func, NULL); settings_add_str("dcc", "dcc_port", "0"); - settings_add_int("dcc", "dcc_timeout", 300); + settings_add_time("dcc", "dcc_timeout", "5min"); settings_add_str("dcc", "dcc_own_ip", ""); signal_add("event connected", (SIGNAL_FUNC) sig_connected); diff --git a/src/irc/flood/autoignore.c b/src/irc/flood/autoignore.c index 7d409b6c..f029a39f 100644 --- a/src/irc/flood/autoignore.c +++ b/src/irc/flood/autoignore.c @@ -32,7 +32,8 @@ void autoignore_update(IGNORE_REC *rec, int level) { rec->level |= level; - rec->unignore_time = time(NULL)+settings_get_int("autoignore_time"); + rec->unignore_time = time(NULL) + + settings_get_time("autoignore_time")/1000; ignore_update_rec(rec); } @@ -46,7 +47,8 @@ void autoignore_add(IRC_SERVER_REC *server, char *mask, int level) rec->mask = g_strdup(mask); rec->servertag = g_strdup(server->tag); rec->level = level; - rec->unignore_time = time(NULL)+settings_get_int("autoignore_time"); + rec->unignore_time = time(NULL) + + settings_get_time("autoignore_time")/1000; ignore_add_rec(rec); } @@ -60,7 +62,7 @@ static void sig_flood(IRC_SERVER_REC *server, const char *nick, const char *host g_return_if_fail(IS_IRC_SERVER(server)); level = GPOINTER_TO_INT(levelp); - check_level = level2bits(settings_get_str("autoignore_level")); + check_level = settings_get_level("autoignore_level"); mask = g_strdup_printf("%s!%s", nick, host); if (level & check_level) { @@ -75,8 +77,8 @@ static void sig_flood(IRC_SERVER_REC *server, const char *nick, const char *host void autoignore_init(void) { - settings_add_int("flood", "autoignore_time", 300); - settings_add_str("flood", "autoignore_level", ""); + settings_add_time("flood", "autoignore_time", "5min"); + settings_add_level("flood", "autoignore_level", ""); signal_add("flood", (SIGNAL_FUNC) sig_flood); } diff --git a/src/irc/notifylist/notify-commands.c b/src/irc/notifylist/notify-commands.c index c51f33f3..1fb485e3 100644 --- a/src/irc/notifylist/notify-commands.c +++ b/src/irc/notifylist/notify-commands.c @@ -26,9 +26,7 @@ #include "notifylist.h" -#define DEFAULT_NOTIFY_IDLE_TIME 60 - -/* SYNTAX: NOTIFY [-away] [-idle [<minutes>]] <mask> [<ircnets>] */ +/* SYNTAX: NOTIFY [-away] [-idle [<time>]] <mask> [<ircnets>] */ static void cmd_notify(gchar *data) { GHashTable *optlist; @@ -46,14 +44,16 @@ static void cmd_notify(gchar *data) idletime = g_hash_table_lookup(optlist, "idle"); if (idletime == NULL) idle_check_time = 0; + else if (*idletime == '\0') + idle_check_time = settings_get_time("notify_idle_time"); else { - idle_check_time = is_numeric(idletime, 0) ? (atoi(idletime)*60) : - (settings_get_int("notify_idle_time")*60); + if (!parse_time_interval(idletime, &idle_check_time)) + cmd_return_error(CMDERR_INVALID_TIME); } away_check = g_hash_table_lookup(optlist, "away") != NULL; notifylist_remove(mask); - notifylist_add(mask, ircnets, away_check, idle_check_time); + notifylist_add(mask, ircnets, away_check, idle_check_time/1000); cmd_params_free(free_arg); } @@ -77,11 +77,11 @@ static void cmd_unnotify(const char *data) void notifylist_commands_init(void) { - settings_add_int("misc", "notify_idle_time", DEFAULT_NOTIFY_IDLE_TIME); + settings_add_time("misc", "notify_idle_time", "hour"); command_bind("notify", NULL, (SIGNAL_FUNC) cmd_notify); command_bind("unnotify", NULL, (SIGNAL_FUNC) cmd_unnotify); - command_set_options("notify", "@idle away"); + command_set_options("notify", "-idle away"); } void notifylist_commands_deinit(void) diff --git a/src/irc/notifylist/notify-ison.c b/src/irc/notifylist/notify-ison.c index 2de398a1..e27e3d60 100644 --- a/src/irc/notifylist/notify-ison.c +++ b/src/irc/notifylist/notify-ison.c @@ -29,8 +29,8 @@ #include "notifylist.h" -#define DEFAULT_NOTIFY_CHECK_TIME 60 -#define DEFAULT_NOTIFY_WHOIS_TIME (60*5) +#define DEFAULT_NOTIFY_CHECK_TIME "1min" +#define DEFAULT_NOTIFY_WHOIS_TIME "5min" typedef struct { char *nick; @@ -321,15 +321,16 @@ static void event_ison(IRC_SERVER_REC *server, const char *data) static void read_settings(void) { if (notify_tag != -1) g_source_remove(notify_tag); - notify_tag = g_timeout_add(1000*settings_get_int("notify_check_time"), (GSourceFunc) notifylist_timeout_func, NULL); + notify_tag = g_timeout_add(settings_get_time("notify_check_time"), + (GSourceFunc) notifylist_timeout_func, NULL); - notify_whois_time = settings_get_int("notify_whois_time"); + notify_whois_time = settings_get_time("notify_whois_time")/1000; } void notifylist_ison_init(void) { - settings_add_int("misc", "notify_check_time", DEFAULT_NOTIFY_CHECK_TIME); - settings_add_int("misc", "notify_whois_time", DEFAULT_NOTIFY_WHOIS_TIME); + settings_add_time("misc", "notify_check_time", DEFAULT_NOTIFY_CHECK_TIME); + settings_add_time("misc", "notify_whois_time", DEFAULT_NOTIFY_WHOIS_TIME); notify_tag = -1; read_settings(); |