while ((d = readdir(dir))) {
if (strcmp(d->d_name, ".") == 0 ||
- strcmp(d->d_name, "..") == 0)
+ strcmp(d->d_name, "..") == 0 ||
+ strncmp(d->d_name, "provider_", 9) == 0)
continue;
switch (d->d_type) {
return services;
}
-GKeyFile *__connman_storage_load_service(const char *service_id)
+GKeyFile *connman_storage_load_service(const char *service_id)
{
gchar *pathname;
GKeyFile *keyfile = NULL;
return NULL;
keyfile = storage_load(pathname);
- if (keyfile) {
- g_free(pathname);
- return keyfile;
- }
-
g_free(pathname);
+ if (keyfile)
+ return keyfile;
pathname = g_strdup_printf("%s/%s", STORAGEDIR, DEFAULT);
if(pathname == NULL)
g_free(pathname);
}
+GKeyFile *__connman_storage_load_provider(const char *identifier)
+{
+ gchar *pathname;
+ GKeyFile *keyfile;
+
+ pathname = g_strdup_printf("%s/%s_%s/%s", STORAGEDIR, "provider",
+ identifier, SETTINGS);
+ if (pathname == NULL)
+ return NULL;
+
+ keyfile = storage_load(pathname);
+ g_free(pathname);
+
+ return keyfile;
+}
+
+void __connman_storage_save_provider(GKeyFile *keyfile, const char *identifier)
+{
+ gchar *pathname, *dirname;
+
+ dirname = g_strdup_printf("%s/%s_%s", STORAGEDIR,
+ "provider", identifier);
+ if (dirname == NULL)
+ return;
+
+ if (g_file_test(dirname, G_FILE_TEST_IS_DIR) == FALSE &&
+ mkdir(dirname, MODE) < 0) {
+ g_free(dirname);
+ return;
+ }
+
+ pathname = g_strdup_printf("%s/%s", dirname, SETTINGS);
+ g_free(dirname);
+
+ storage_save(keyfile, pathname);
+ g_free(pathname);
+}
+
/*
* This function migrates keys from default.profile to settings file.
* This can be removed once the migration is over.