char *phase2;
char *passphrase;
GSList *service_identifiers;
+ char *config_ident; /* file prefix */
+ char *config_entry; /* entry name */
};
struct connman_config {
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);
g_free(config_service->phase2);
g_free(config_service->passphrase);
g_slist_free_full(config_service->service_identifiers, g_free);
+ g_free(config_service->config_ident);
+ g_free(config_service->config_entry);
g_free(config_service);
}
service->passphrase = str;
}
+ service->config_ident = g_strdup(config->ident);
+ service->config_entry = g_strdup_printf("service_%s", service->ident);
+
if (service_created)
g_hash_table_insert(config->service_table, service->ident,
service);
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_immutable(service, TRUE);
- __connman_service_set_favorite(service, TRUE);
+ __connman_service_set_favorite_delayed(service, TRUE, TRUE);
+
+ __connman_service_set_config(service, config->config_ident,
+ config->config_entry);
if (config->eap != NULL)
__connman_service_set_string(service, "EAP", config->eap);
if (config->passphrase != NULL)
__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;
}