X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fstorage.c;h=9be60defec27511c472101b11bff085bad991876;hb=c647a4b6f1132684c9d8b8ad71ec38d81147b278;hp=7d031303b37fad6be8feee43c681a1624a346067;hpb=1b9d0a62f59bb48c8deb2f0b98d9acdffdd9abe7;p=platform%2Fupstream%2Fconnman.git diff --git a/src/storage.c b/src/storage.c old mode 100644 new mode 100755 index 7d03130..9be60de --- a/src/storage.c +++ b/src/storage.c @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -34,6 +35,9 @@ #define SETTINGS "settings" #define DEFAULT "default.profile" +#if defined TIZEN_EXT +#define INS_SETTINGS "settings.ins" +#endif #define MODE (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | \ S_IXGRP | S_IROTH | S_IXOTH) @@ -43,8 +47,6 @@ static GKeyFile *storage_load(const char *pathname) GKeyFile *keyfile = NULL; GError *error = NULL; - DBG("Loading %s", pathname); - keyfile = g_key_file_new(); if (!g_key_file_load_from_file(keyfile, pathname, 0, &error)) { @@ -73,6 +75,19 @@ static int storage_save(GKeyFile *keyfile, char *pathname) ret = -EIO; } +#if defined TIZEN_EXT + { + FILE *fp = NULL; + fp = fopen(pathname, "a+"); + if(fp){ + fflush(fp); + fsync(fp->_fileno); + fclose(fp); + DBG("sync the file to disk"); + } + } +#endif + g_free(data); return ret; @@ -118,41 +133,59 @@ int __connman_storage_save_global(GKeyFile *keyfile) return ret; } -void __connman_storage_delete_global(void) +#if defined TIZEN_EXT +GKeyFile *__connman_storage_load_ins(void) { gchar *pathname; + GKeyFile *keyfile = NULL; - pathname = g_strdup_printf("%s/%s", STORAGEDIR, SETTINGS); + pathname = g_strdup_printf("%s/%s", STORAGEDIR, INS_SETTINGS); if (!pathname) - return; + return NULL; - storage_delete(pathname); + keyfile = storage_load(pathname); g_free(pathname); + + return keyfile; } -GKeyFile *__connman_storage_load_config(const char *ident) +int __connman_storage_save_ins(GKeyFile *keyfile) { gchar *pathname; - GKeyFile *keyfile = NULL; + int ret; - pathname = g_strdup_printf("%s/%s.config", STORAGEDIR, ident); + pathname = g_strdup_printf("%s/%s", STORAGEDIR, INS_SETTINGS); if (!pathname) - return NULL; + return -ENOMEM; - keyfile = storage_load(pathname); + ret = storage_save(keyfile, pathname); g_free(pathname); - return keyfile; + return ret; } +#endif -GKeyFile *__connman_storage_load_provider_config(const char *ident) +void __connman_storage_delete_global(void) +{ + gchar *pathname; + + pathname = g_strdup_printf("%s/%s", STORAGEDIR, SETTINGS); + if (!pathname) + return; + + storage_delete(pathname); + + g_free(pathname); +} + +GKeyFile *__connman_storage_load_config(const char *ident) { gchar *pathname; GKeyFile *keyfile = NULL; - pathname = g_strdup_printf("%s/%s.config", VPN_STORAGEDIR, ident); + pathname = g_strdup_printf("%s/%s.config", STORAGEDIR, ident); if (!pathname) return NULL; @@ -163,25 +196,19 @@ GKeyFile *__connman_storage_load_provider_config(const char *ident) return keyfile; } -GKeyFile *__connman_storage_open_service(const char *service_id) +GKeyFile *__connman_storage_load_provider_config(const char *ident) { gchar *pathname; GKeyFile *keyfile = NULL; - pathname = g_strdup_printf("%s/%s/%s", STORAGEDIR, service_id, SETTINGS); + pathname = g_strdup_printf("%s/%s.config", VPN_STORAGEDIR, ident); if (!pathname) return NULL; - keyfile = storage_load(pathname); - if (keyfile) { - g_free(pathname); - return keyfile; - } + keyfile = storage_load(pathname); g_free(pathname); - keyfile = g_key_file_new(); - return keyfile; }