From: Jukka Rissanen Date: Tue, 5 Jun 2012 08:24:16 +0000 (+0300) Subject: config: Check individual service entries for removal X-Git-Tag: 2.0_alpha~96 X-Git-Url: http://review.tizen.org/git/?p=framework%2Fconnectivity%2Fconnman.git;a=commitdiff_plain;h=0c4159770e177475cb222770f03e0d0ff034f136 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. --- 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; }