summaryrefslogtreecommitdiff
path: root/src/irc/notifylist
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-06-18 01:18:12 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-06-18 01:18:12 +0000
commita5d31a195d1e3b682cd57d88a5db7ef0ffa5d492 (patch)
treee5c335b77da2d17293e87debeb17ab4c966e34c4 /src/irc/notifylist
parentca4226cca692ee96109a46b3a1d381ac0d37cb6f (diff)
downloadirssi-a5d31a195d1e3b682cd57d88a5db7ef0ffa5d492.zip
Changed option handling in /commands. Irssi will now complain about
unknown options and missing option arguments. Renamed /SERVER -add, -remove and -list to /SERVER ADD, REMOVE and LIST. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@365 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/notifylist')
-rw-r--r--src/irc/notifylist/notify-commands.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/irc/notifylist/notify-commands.c b/src/irc/notifylist/notify-commands.c
index af022dcd..0bef6d23 100644
--- a/src/irc/notifylist/notify-commands.c
+++ b/src/irc/notifylist/notify-commands.c
@@ -30,41 +30,47 @@
static void cmd_notify(gchar *data)
{
- char *params, *mask, *ircnets, *args, *idletime;
+ GHashTable *optlist;
+ char *mask, *ircnets, *idletime;
+ void *free_arg;
int away_check, idle_check_time;
g_return_if_fail(data != NULL);
- args = "@idle";
- params = cmd_get_params(data, 4 | PARAM_FLAG_MULTIARGS | PARAM_FLAG_GETREST, &args, &idletime, &mask, &ircnets);
+ if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST,
+ "notify", &optlist, &mask, &ircnets))
+ return;
if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
- if (stristr(args, "-idle") == NULL)
+ idletime = g_hash_table_lookup(optlist, "idle");
+ if (idletime == NULL)
idle_check_time = 0;
else {
idle_check_time = is_numeric(idletime, 0) ? (atoi(idletime)*60) :
(settings_get_int("notify_idle_time")*60);
}
- away_check = stristr(args, "-away") != NULL;
+ away_check = g_hash_table_lookup(optlist, "away") != NULL;
notifylist_remove(mask);
notifylist_add(mask, ircnets, away_check, idle_check_time);
- g_free(params);
+ cmd_params_free(free_arg);
}
static void cmd_unnotify(const char *data)
{
- char *params, *mask;
+ char *mask;
+ void *free_arg;
g_return_if_fail(data != NULL);
- params = cmd_get_params(data, 1, &mask);
+ if (!cmd_get_params(data, &free_arg, 1, &mask))
+ return;
if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
notifylist_remove(mask);
- g_free(params);
+ cmd_params_free(free_arg);
}
void notifylist_commands_init(void)
@@ -72,6 +78,8 @@ void notifylist_commands_init(void)
settings_add_int("misc", "notify_idle_time", DEFAULT_NOTIFY_IDLE_TIME);
command_bind("notify", NULL, (SIGNAL_FUNC) cmd_notify);
command_bind("unnotify", NULL, (SIGNAL_FUNC) cmd_unnotify);
+
+ command_set_options("notify", "@idle away");
}
void notifylist_commands_deinit(void)