diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-06-05 11:24:16 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-06-11 13:04:54 +0300 |
commit | 0c4159770e177475cb222770f03e0d0ff034f136 (patch) | |
tree | 68bd5b819cccc242d03a326eed856ce14bd65b85 /src/config.c | |
parent | 92ce554b89c6a343bf2a59f07a868fc7ca872634 (diff) | |
download | connman-0c4159770e177475cb222770f03e0d0ff034f136.tar.gz connman-0c4159770e177475cb222770f03e0d0ff034f136.tar.bz2 connman-0c4159770e177475cb222770f03e0d0ff034f136.zip |
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.
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/config.c b/src/config.c index c3024c6b..6af979d8 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; } |