diff options
author | isundil <isundill@gmail.com> | 2015-10-01 22:36:02 +0200 |
---|---|---|
committer | isundil <isundill@gmail.com> | 2015-10-01 22:36:02 +0200 |
commit | 6ca7dc68478772258dea114d29625dc2c87999f9 (patch) | |
tree | cfa0cab1545d4a429351509ee13c3bd13341df11 | |
parent | 2ad6bb12955b3e9bfa43628e6dbfc984537f8b26 (diff) | |
download | irssi-6ca7dc68478772258dea114d29625dc2c87999f9.zip |
Updated server removal
Removing network will also remove attached channels
-rw-r--r-- | src/core/channels-setup.c | 15 | ||||
-rw-r--r-- | src/core/channels-setup.h | 3 | ||||
-rw-r--r-- | src/core/servers-setup.c | 33 | ||||
-rw-r--r-- | src/core/servers-setup.h | 7 | ||||
-rw-r--r-- | src/fe-common/irc/fe-ircnet.c | 10 |
5 files changed, 40 insertions, 28 deletions
diff --git a/src/core/channels-setup.c b/src/core/channels-setup.c index b2d971dd..2902ef8e 100644 --- a/src/core/channels-setup.c +++ b/src/core/channels-setup.c @@ -86,6 +86,21 @@ static void channel_setup_destroy(CHANNEL_SETUP_REC *channel) g_free(channel); } +void channel_setup_remove_chatnet(const char *chatnet) +{ + GSList *tmp, *next; + + g_return_if_fail(chatnet != NULL); + + for (tmp = setupchannels; tmp != NULL; tmp = next) { + CHANNEL_SETUP_REC *rec = tmp->data; + + next = tmp->next; + if (g_ascii_strcasecmp(rec->chatnet, chatnet) == 0) + channel_setup_remove(rec); + } +} + void channel_setup_remove(CHANNEL_SETUP_REC *channel) { channel_config_remove(channel); diff --git a/src/core/channels-setup.h b/src/core/channels-setup.h index 61b828b2..3bb7da7f 100644 --- a/src/core/channels-setup.h +++ b/src/core/channels-setup.h @@ -21,6 +21,9 @@ void channels_setup_deinit(void); void channel_setup_create(CHANNEL_SETUP_REC *channel); void channel_setup_remove(CHANNEL_SETUP_REC *channel); +/* Remove channels attached to chatnet */ +void channel_setup_remove_chatnet(const char *chatnet); + CHANNEL_SETUP_REC *channel_setup_find(const char *channel, const char *chatnet); diff --git a/src/core/servers-setup.c b/src/core/servers-setup.c index 74b818e7..cd5fe406 100644 --- a/src/core/servers-setup.c +++ b/src/core/servers-setup.c @@ -333,24 +333,6 @@ 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, @@ -523,6 +505,21 @@ void server_setup_add(SERVER_SETUP_REC *rec) signal_emit("server setup updated", 1, rec); } +void server_setup_remove_chatnet(const char *chatnet) +{ + GSList *tmp, *next; + + g_return_val_if_fail(chatnet != NULL, NULL); + + for (tmp = setupservers; tmp != NULL; tmp = next) { + SERVER_SETUP_REC *rec = tmp->data; + + next = tmp->next; + if (g_ascii_strcasecmp(rec->chatnet, chatnet) == 0) + server_setup_remove(rec); + } +} + void server_setup_remove(SERVER_SETUP_REC *rec) { server_setup_remove_config(rec); diff --git a/src/core/servers-setup.h b/src/core/servers-setup.h index dffaec02..e7ff7abf 100644 --- a/src/core/servers-setup.h +++ b/src/core/servers-setup.h @@ -36,13 +36,12 @@ 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); +/* Remove servers attached to chatne */ +void server_setup_remove_chatnet(const char *chatnet); + void servers_setup_init(void); void servers_setup_deinit(void); diff --git a/src/fe-common/irc/fe-ircnet.c b/src/fe-common/irc/fe-ircnet.c index 1760b966..4d7037d5 100644 --- a/src/fe-common/irc/fe-ircnet.c +++ b/src/fe-common/irc/fe-ircnet.c @@ -29,6 +29,8 @@ #include "irc-servers.h" #include "irc-chatnets.h" #include "printtext.h" +#include "servers-setup.h" +#include "channels-setup.h" static void cmd_network_list(void) { @@ -176,8 +178,6 @@ 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); @@ -185,10 +185,8 @@ 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); + server_setup_remove_chatnet(data); + channel_setup_remove_chatnet(data); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NETWORK_REMOVED, data); chatnet_remove(CHATNET(rec)); } |