From 421288cf5066267b60580af2b6ae511c46570bf0 Mon Sep 17 00:00:00 2001 From: Jari Matilainen Date: Sat, 18 Jun 2016 17:52:47 +0200 Subject: Add /network modify --- src/fe-common/irc/fe-ircnet.c | 47 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'src/fe-common/irc') diff --git a/src/fe-common/irc/fe-ircnet.c b/src/fe-common/irc/fe-ircnet.c index 4d7037d5..90697bba 100644 --- a/src/fe-common/irc/fe-ircnet.c +++ b/src/fe-common/irc/fe-ircnet.c @@ -88,14 +88,7 @@ static void cmd_network_list(void) printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_NETWORK_FOOTER); } -/* SYNTAX: NETWORK ADD [-nick ] [-user ] [-realname ] - [-host ] [-usermode ] [-autosendcmd ] - [-querychans ] [-whois ] [-msgs ] - [-kicks ] [-modes ] [-cmdspeed ] - [-cmdmax ] [-sasl_mechanism ] - [-sasl_username ] [-sasl_password ] - */ -static void cmd_network_add(const char *data) +static void cmd_network_add_modify(const char *data, gboolean add) { GHashTable *optlist; char *name, *value; @@ -103,15 +96,23 @@ static void cmd_network_add(const char *data) IRC_CHATNET_REC *rec; if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS, - "network add", &optlist, &name)) + "network add", &optlist, &name)) return; + if (*name == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); rec = ircnet_find(name); if (rec == NULL) { + if (!add) { + cmd_params_free(free_arg); + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + IRCTXT_NETWORK_NOT_FOUND, name); + return; + } + rec = g_new0(IRC_CHATNET_REC, 1); rec->name = g_strdup(name); - } else { + } else if (!add) { if (g_hash_table_lookup(optlist, "nick")) g_free_and_null(rec->nick); if (g_hash_table_lookup(optlist, "user")) g_free_and_null(rec->username); if (g_hash_table_lookup(optlist, "realname")) g_free_and_null(rec->realname); @@ -174,6 +175,30 @@ static void cmd_network_add(const char *data) cmd_params_free(free_arg); } +/* SYNTAX: NETWORK ADD [-nick ] [-user ] [-realname ] + [-host ] [-usermode ] [-autosendcmd ] + [-querychans ] [-whois ] [-msgs ] + [-kicks ] [-modes ] [-cmdspeed ] + [-cmdmax ] [-sasl_mechanism ] + [-sasl_username ] [-sasl_password ] + */ +static void cmd_network_add(const char *data) +{ + cmd_network_add_modify(data, 1); +} + +/* SYNTAX: NETWORK MODIFY [-nick ] [-user ] [-realname ] + [-host ] [-usermode ] [-autosendcmd ] + [-querychans ] [-whois ] [-msgs ] + [-kicks ] [-modes ] [-cmdspeed ] + [-cmdmax ] [-sasl_mechanism ] + [-sasl_username ] [-sasl_password ] + */ +static void cmd_network_modify(const char *data) +{ + cmd_network_add_modify(data, 0); +} + /* SYNTAX: NETWORK REMOVE */ static void cmd_network_remove(const char *data) { @@ -206,6 +231,7 @@ void fe_ircnet_init(void) command_bind("network", NULL, (SIGNAL_FUNC) cmd_network); command_bind("network list", NULL, (SIGNAL_FUNC) cmd_network_list); command_bind("network add", NULL, (SIGNAL_FUNC) cmd_network_add); + command_bind("network modify", NULL, (SIGNAL_FUNC) cmd_network_modify); command_bind("network remove", NULL, (SIGNAL_FUNC) cmd_network_remove); command_set_options("network add", "-kicks -msgs -modes -whois -cmdspeed " @@ -218,5 +244,6 @@ void fe_ircnet_deinit(void) command_unbind("network", (SIGNAL_FUNC) cmd_network); command_unbind("network list", (SIGNAL_FUNC) cmd_network_list); command_unbind("network add", (SIGNAL_FUNC) cmd_network_add); + command_unbind("network modify", (SIGNAL_FUNC) cmd_network_modify); command_unbind("network remove", (SIGNAL_FUNC) cmd_network_remove); } -- cgit v1.2.3