From 6ca7dc68478772258dea114d29625dc2c87999f9 Mon Sep 17 00:00:00 2001 From: isundil Date: Thu, 1 Oct 2015 22:36:02 +0200 Subject: Updated server removal Removing network will also remove attached channels --- src/core/channels-setup.c | 15 +++++++++++++++ src/core/channels-setup.h | 3 +++ src/core/servers-setup.c | 33 +++++++++++++++------------------ src/core/servers-setup.h | 7 +++---- 4 files changed, 36 insertions(+), 22 deletions(-) (limited to 'src/core') 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); -- cgit v1.2.3