diff options
author | Timo Sirainen <cras@irssi.org> | 2000-04-26 08:03:38 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-04-26 08:03:38 +0000 |
commit | c95034c6de1bf72536595e1e3431d8ec64b9880e (patch) | |
tree | e51aa4528257ed8aa9d53640649519f299aaf0c7 /src/irc/notifylist/notify-commands.c | |
parent | d01b094151705d433bc43cae9eeb304e6f110a17 (diff) | |
download | irssi-c95034c6de1bf72536595e1e3431d8ec64b9880e.zip |
..adding new files..
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@171 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/notifylist/notify-commands.c')
-rw-r--r-- | src/irc/notifylist/notify-commands.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/irc/notifylist/notify-commands.c b/src/irc/notifylist/notify-commands.c new file mode 100644 index 00000000..9ae5a076 --- /dev/null +++ b/src/irc/notifylist/notify-commands.c @@ -0,0 +1,81 @@ +/* + notify-commands.c : irssi + + Copyright (C) 1999-2000 Timo Sirainen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "module.h" +#include "signals.h" +#include "commands.h" +#include "misc.h" +#include "settings.h" + +#include "notifylist.h" + +#define DEFAULT_NOTIFY_IDLE_TIME 60 + +static void cmd_notify(gchar *data) +{ + char *params, *mask, *ircnets, *args, *idletime; + 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 (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + + if (stristr(args, "-idle") == NULL) + idle_check_time = 0; + else { + idle_check_time = is_numeric(idletime, 0) ? (atol(idletime)*60) : + (settings_get_int("notify_idle_time")*60); + } + + away_check = stristr(args, "-away") != NULL; + notifylist_remove(mask); + notifylist_add(mask, ircnets, away_check, idle_check_time); + + g_free(params); +} + +static void cmd_unnotify(const char *data) +{ + char *params, *mask; + + g_return_if_fail(data != NULL); + + params = cmd_get_params(data, 1, &mask); + if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + + notifylist_remove(mask); + + g_free(params); +} + +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); +} + +void notifylist_commands_deinit(void) +{ + command_unbind("notify", (SIGNAL_FUNC) cmd_notify); + command_unbind("unnotify", (SIGNAL_FUNC) cmd_unnotify); +} |