applied capi-system-system-settings into Settings- use font-type related enumeration .
[apps/core/preloaded/settings.git] / src / conf_util / setting_confutil.c
index 1563860..59d5c1e 100755 (executable)
 #include <setting-common-general-func.h>
 #include <setting-common-data-slp-setting.h>
 #include <unistd.h>
+#include <system_settings.h>
 
 static char* get_timezone();
 
+static void get_gmt_offset(char *str_buf, int size)
+{
+       // timezone string +/-<n> ex. +9, -1
+       time_t t = time(0);     // get unix time. sec.
+
+       struct tm* data;
+       data = localtime(&t);           // save time as structure.
+       setting_retm_if(!data, "data is NULL");
+       data->tm_isdst = 0;                     // summer time, not applied.
+       time_t a = mktime(data);
+
+       data = gmtime(&a);
+       data->tm_isdst = 0;                     // summer time, not applied.
+       time_t b = mktime(data);
+
+       int gmtoffset_hour = (a-b)/3600;        // result : hour.
+       int gmtoffset_min = ((a-b)%3600)/60;    // result : min.
+       if(gmtoffset_min != 0) {
+               gmtoffset_min = 30;
+       }
+
+       snprintf(str_buf, size, "%+d:%02u", gmtoffset_hour, gmtoffset_min);
+       SETTING_TRACE("szTimezone is of a valid format: GMT: %s", str_buf);
+}
+
+
+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);
+
+       char str_buf[256] = {0, };
+       get_gmt_offset(str_buf, 256);
+       printf(">>> time zone GMT string : %s \n", str_buf);
+}
+
+void get_current_font()
+{
+       char *value = NULL;
+       int retcode = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &value);
+       printf(">>> get current font type : %s \n", value);
+}
+
 /**
 sh-4.1# /opt/apps/com.samsung.setting/bin/setting_conf_util timezone_check
 debug level init 1(1)
@@ -30,14 +75,12 @@ int main(int argc, char* argv[])
        int ret;
        // exporting - current status
        if ( (argc == 2) && (0 == strcmp(argv[1], "export"))) {
-                       setting_export();
-       }
-       else if ( (argc == 2) && (0 == strcmp(argv[1], "timezone_init"))) {
-               char* tzpath = get_timezone();
-               //printf(">>> time zone : %s \n", tzpath+20);
-               ret = vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_INT, tzpath+20);
-       }
-       else {
+               setting_export();
+       } 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 {
                // cfg create
                // TRUE or FALSE
                ret = setting_cfg_create();