static GIOChannel *inotify_channel = NULL;
static uint inotify_watch = 0;
+static connman_bool_t cleanup = FALSE;
#define INTERNAL_CONFIG_PREFIX "__internal"
char *service_id;
GSList *list;
+ if (cleanup == TRUE)
+ goto free_only;
+
connman_info("Removing service configuration %s",
config_service->ident);
service_id);
}
+free_only:
g_free(config_service->ident);
g_free(config_service->type);
g_free(config_service->name);
config = g_hash_table_lookup(config_table, ident);
if (config != NULL) {
+ int ret;
+
g_hash_table_remove_all(config->service_table);
load_config(config);
- __connman_service_provision_changed(ident);
+ ret = __connman_service_provision_changed(ident);
+ if (ret > 0) {
+ /*
+ * Re-scan the config file for any
+ * changes
+ */
+ g_hash_table_remove_all(config->service_table);
+ load_config(config);
+ __connman_service_provision_changed(ident);
+ }
}
}
{
DBG("");
+ cleanup = TRUE;
+
remove_watch();
g_hash_table_destroy(config_table);
config_table = NULL;
+
+ cleanup = FALSE;
}
static char *config_pem_fsid(const char *pem_file)
__connman_service_set_string(service, "Passphrase", config->passphrase);
__connman_service_mark_dirty();
+
+ __connman_service_save(service);
}
int __connman_config_provision_service(struct connman_service *service)
}
int __connman_config_provision_service_ident(struct connman_service *service,
- const char *ident)
+ const char *ident, const char *file, const char *entry)
{
enum connman_service_type type;
struct connman_config *config;
+ int ret = 0;
DBG("service %p", 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);
+ ret = 1;
+ }
+ }
+
g_hash_table_foreach(config->service_table,
provision_service, service);
+ }
- return 0;
+ return ret;
}