diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2011-10-31 15:31:36 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-11-07 17:40:08 +0100 |
commit | f4daef01c5d68523e9a58ab489b085714e877bc8 (patch) | |
tree | c7c7f7126c8a1f5380d45b5021202cfbeb998514 /src/storage.c | |
parent | 0f87b4e6267cef63e06dce2961b31dff595606e0 (diff) | |
download | connman-f4daef01c5d68523e9a58ab489b085714e877bc8.tar.gz connman-f4daef01c5d68523e9a58ab489b085714e877bc8.tar.bz2 connman-f4daef01c5d68523e9a58ab489b085714e877bc8.zip |
storage: Load and save functions for providers
Diffstat (limited to 'src/storage.c')
-rw-r--r-- | src/storage.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/storage.c b/src/storage.c index 0854ed4b..1d14e138 100644 --- a/src/storage.c +++ b/src/storage.c @@ -290,6 +290,44 @@ void __connman_storage_save_service(GKeyFile *keyfile, const char *service_id) 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. |