diff --git a/src/core/servers-setup.c b/src/core/servers-setup.c index 90a447d4..74b818e7 100644 --- a/src/core/servers-setup.c +++ b/src/core/servers-setup.c @@ -333,6 +333,24 @@ server_create_conn(int chat_type, const char *dest, int port, chatnet, password, nick); } +GSList *server_setup_find_chatnet(const char *chatnet) +{ + GSList *servers; + GSList *tmp; + + g_return_val_if_fail(chatnet != NULL, NULL); + + servers = NULL; + for (tmp = setupservers; tmp != NULL; tmp = tmp->next) { + SERVER_SETUP_REC *rec = tmp->data; + + if (g_ascii_strcasecmp(rec->chatnet, chatnet) == 0) + servers = g_slist_append(servers, rec); + } + + return servers; +} + /* Find matching server from setup. Try to find record with a same port, but fallback to any server with the same address. */ SERVER_SETUP_REC *server_setup_find(const char *address, int port, diff --git a/src/core/servers-setup.h b/src/core/servers-setup.h index f7601a68..dffaec02 100644 --- a/src/core/servers-setup.h +++ b/src/core/servers-setup.h @@ -36,6 +36,10 @@ server_create_conn(int chat_type, const char *dest, int port, SERVER_SETUP_REC *server_setup_find(const char *address, int port, const char *chatnet); +/* Find all servers matching chatnet. + Return a list of SERVER_SETUP_REC */ +GSList *server_setup_find_chatnet(const char *chatnet); + void server_setup_add(SERVER_SETUP_REC *rec); void server_setup_remove(SERVER_SETUP_REC *rec); diff --git a/src/fe-common/irc/fe-ircnet.c b/src/fe-common/irc/fe-ircnet.c index bb0af313..1760b966 100644 --- a/src/fe-common/irc/fe-ircnet.c +++ b/src/fe-common/irc/fe-ircnet.c @@ -176,6 +176,8 @@ static void cmd_network_add(const char *data) static void cmd_network_remove(const char *data) { IRC_CHATNET_REC *rec; + GSList *servers; + GSList *tmp; if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS); @@ -183,6 +185,10 @@ static void cmd_network_remove(const char *data) if (rec == NULL) printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NETWORK_NOT_FOUND, data); else { + servers = server_setup_find_chatnet(data); + + for (tmp = servers; tmp != NULL; tmp = tmp->next) + server_setup_remove((SERVER_SETUP_REC *) tmp->data); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NETWORK_REMOVED, data); chatnet_remove(CHATNET(rec)); }