From 0c4159770e177475cb222770f03e0d0ff034f136 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 5 Jun 2012 11:24:16 +0300 Subject: [PATCH] config: Check individual service entries for removal Check if we need to remove a service if user removes an entry from config file. If user changes entry name in config file, then we remove the service and then try to provision the service again because the SSID might still be found. --- src/config.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index c3024c6..6af979d 100644 --- a/src/config.c +++ b/src/config.c @@ -873,9 +873,45 @@ int __connman_config_provision_service_ident(struct connman_service *service, return -ENOSYS; config = g_hash_table_lookup(config_table, ident); - if(config != NULL) + if(config != NULL) { + GHashTableIter iter; + gpointer value, key; + gboolean found = FALSE; + + g_hash_table_iter_init(&iter, config->service_table); + + /* + * Check if we need to remove individual service if it + * is missing from config file. + */ + if (file != NULL && entry != NULL) { + while (g_hash_table_iter_next(&iter, &key, + &value) == TRUE) { + struct connman_config_service *config = value; + + if (g_strcmp0(config->config_ident, + file) == 0 && + g_strcmp0(config->config_entry, + entry) == 0) { + found = TRUE; + break; + } + } + + DBG("found %d ident %s file %s entry %s", found, ident, + file, entry); + + if (found == FALSE) + /* + * The entry+8 will skip "service_" prefix + */ + g_hash_table_remove(config->service_table, + entry + 8); + } + g_hash_table_foreach(config->service_table, provision_service, service); + } return 0; } -- 2.7.4