diff options
author | Timo Sirainen <cras@irssi.org> | 2002-12-28 17:54:13 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-12-28 17:54:13 +0000 |
commit | bd6fe052bce57849a7a850c0c5bee0ad896b9460 (patch) | |
tree | 95f3cb743874913a6dc1ff1314264b88989a4b60 /src/irc/notifylist | |
parent | 9c18cb00e7d096e46f5853f802724da4c59c2857 (diff) | |
download | irssi-bd6fe052bce57849a7a850c0c5bee0ad896b9460.zip |
Added time, size and level setting types. Breaks some settings - I'll add
automatic converter to these settings later. Meanwhile you CVS users can
fix your config files yourself :)
Time settings allow using "days", "hours", "minutes", "seconds" and
"milliseconds" or several of their abbreviations. For example "5d 4h
5msecs".
Size settings allow using "gbytes", "mbytes", "kbytes" and "bytes" or their
abbrevations. For example "5MB".
Level settings are currently handled pretty much the way they were before.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3080 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/notifylist')
-rw-r--r-- | src/irc/notifylist/notify-commands.c | 16 | ||||
-rw-r--r-- | src/irc/notifylist/notify-ison.c | 13 |
2 files changed, 15 insertions, 14 deletions
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(); |