tizen 2.3 release
[apps/home/settings.git] / src / conf_util / setting_confutil.c
index 6f6cb30..de32bcf 100755 (executable)
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
+#include <setting-common-search.h>
 
 static char* get_timezone();
 
@@ -49,18 +50,40 @@ static void get_gmt_offset(char *str_buf, int size)
        SETTING_TRACE("szTimezone is of a valid format: GMT: %s", str_buf);
 }
 
+int generate_setting_cfg()
+{
+       if( 0 == setting_cfg_create(false) )
+       {
+               SETTING_TRACE_ERROR("Error to create a new config file");
+               return 0 ;
+       }
+
+       return 1;
+}
+
+int migrate_setting_cfg()
+{
+       SETTING_TRACE_BEGIN;
+       if(0 == setting_cfg_migrate())
+       {
+               SETTING_TRACE_ERROR("Fail to migrate config file");
+               return 0 ;
+       }
+       SETTING_TRACE_END;
+       return 1;
+}
 
 void timezone_init()
 {
        char* tzpath = get_timezone();
-       //printf(">>> time zone : %s \n", tzpath+20);
-       int ret = vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_INT, tzpath+20);
+       int ret = vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_ID, tzpath+20);
        if (ret != 0) {
                SETTING_TRACE("fail to set vconf");
        }
        char str_buf[256] = {0, };
        get_gmt_offset(str_buf, 256);
-       printf(">>> time zone GMT string : %s \n", str_buf);
+       SETTING_TRACE(">>> time zone GMT string : %s", str_buf);
+       g_free(tzpath);
 }
 
 void get_current_font()
@@ -70,7 +93,7 @@ void get_current_font()
        if (retcode != 0) {
                SETTING_TRACE("fail to set SYSTEM_SETTINGS_KEY_FONT_TYPE");
        }
-       printf(">>> get current font type : %s \n", value);
+       SETTING_TRACE(">>> get current font type : %s \n", value);
 }
 
 int status_fp(int total, int current, void* data)
@@ -81,30 +104,42 @@ int status_fp(int total, int current, void* data)
 
 
 /**
-sh-4.1# /usr/apps/org.tizen.setting/bin/setting_conf_util timezone_check
+sh-4.1# /opt/usr/apps/org.tizen.setting/bin/setting_conf_util timezone_check
 debug level init 1(1)
 >>> time zone : /usr/share/zoneinfo/Asia/Seoul
 */
 int main(int argc, char* argv[])
 {
-       g_type_init ();
-       int ret;
-       // exporting - current status
-       if ( (argc == 2) && (0 == strcmp(argv[1], "import"))) {
-               // void setting_import(status_handler fp, void* data)
+       g_type_init();
 
-               setting_import(status_fp, NULL);
+       elm_init(argc, argv);
+       setting_set_i18n_force(SETTING_PACKAGE, SETTING_LOCALEDIR);
 
-       } else if ( (argc == 2) && (0 == strcmp(argv[1], "export"))) {
-               setting_export(status_fp, NULL);
+       if ( (argc == 2) && (0 == strcmp(argv[1], "export_json"))) {
+               setting_export_json(status_fp, NULL);
+       } else if ( (argc == 2) && (0 == strcmp(argv[1], "import_json"))) {
+               setting_import_json(status_fp, NULL);
        } else if ( (argc == 2) && (0 == strcmp(argv[1], "timezone_init"))) {
                timezone_init();
        } else if ( (argc == 2) && (0 == strcmp(argv[1], "get_current_font"))) {
                get_current_font();
-       } else {
+       } else if ( (argc == 2) && (0 == strcmp(argv[1], "gen_cfg"))) {
+               generate_setting_cfg();
+       } else if ( (argc == 2) && (0 == strcmp(argv[1], "mig_cfg"))) {
+               migrate_setting_cfg();
+       }
+       #if SETTING_SEARCH
+       else if ( (argc == 2) && (0 == strcmp(argv[1], "search_db_indexing"))) {
+               // app db search
+               __setting_init_search_index_app();
+
+               __setting_init_search_index_module();
+       }
+       #endif
+       else {
                // cfg create
                // TRUE or FALSE
-               ret = setting_cfg_create();
+               setting_cfg_create(false);
        }
        return 0;
 }
@@ -115,7 +150,7 @@ static char* get_timezone()
        SETTING_TRACE_BEGIN;
 
     enum { BUFFERSIZE = 1024 };
-    char buf[BUFFERSIZE];
+    char buf[BUFFERSIZE] = {0, };
     ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf)-1);
 
     if (len != -1) {
@@ -123,6 +158,7 @@ static char* get_timezone()
     }
     else {
         /* handle error condition */
+       return NULL;
     }
        return g_strdup(buf);
 }