Use TIZEN_EXT_INS for INS related code
[platform/upstream/connman.git] / src / storage.c
old mode 100644 (file)
new mode 100755 (executable)
index 90f03eb..fb6dc14
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#include <stdio.h>
 
 #include <connman/storage.h>
 
@@ -34,6 +35,9 @@
 
 #define SETTINGS       "settings"
 #define DEFAULT                "default.profile"
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+#define INS_SETTINGS   "settings.ins"
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
 
 #define MODE           (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | \
                        S_IXGRP | S_IROTH | S_IXOTH)
@@ -71,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;
@@ -116,6 +133,40 @@ int __connman_storage_save_global(GKeyFile *keyfile)
        return ret;
 }
 
+#if defined TIZEN_EXT && defined TIZEN_EXT_INS
+GKeyFile *__connman_storage_load_ins(void)
+{
+       gchar *pathname;
+       GKeyFile *keyfile = NULL;
+
+       pathname = g_strdup_printf("%s/%s", STORAGEDIR, INS_SETTINGS);
+       if (!pathname)
+               return NULL;
+
+       keyfile = storage_load(pathname);
+
+       g_free(pathname);
+
+       return keyfile;
+}
+
+int __connman_storage_save_ins(GKeyFile *keyfile)
+{
+       gchar *pathname;
+       int ret;
+
+       pathname = g_strdup_printf("%s/%s", STORAGEDIR, INS_SETTINGS);
+       if (!pathname)
+               return -ENOMEM;
+
+       ret = storage_save(keyfile, pathname);
+
+       g_free(pathname);
+
+       return ret;
+}
+#endif /* defined TIZEN_EXT && defined TIZEN_EXT_INS */
+
 void __connman_storage_delete_global(void)
 {
        gchar *pathname;