6 $ setting_confutil // create a cfg file in default
7 $ setting_confutil export // export current status to a xml file
8 $ setting_confutil timezone_init // timezone init
12 #include <setting-cfg.h>
13 #include <setting-debug.h>
15 #include <Elementary.h>
16 #include <setting-common-general-func.h>
17 #include <setting-common-data-slp-setting.h>
19 #include <system_settings.h>
22 #include <libxml/parser.h>
23 #include <libxml/tree.h>
24 #include <setting-common-search.h>
26 static char *get_timezone();
28 static void get_gmt_offset(char *str_buf, int size)
30 /* timezone string +/-<n> ex. +9, -1 */
31 time_t t = time(0); /* get unix time. sec. */
34 data = localtime(&t); /* save time as structure. */
35 setting_retm_if(!data, "data is NULL");
36 data->tm_isdst = 0; /* summer time, not applied. */
37 time_t a = mktime(data);
40 setting_retm_if(!data, "data is NULL");
41 data->tm_isdst = 0; /* summer time, not applied. */
42 time_t b = mktime(data);
44 int gmtoffset_hour = (a - b) / 3600; /* result : hour. */
45 int gmtoffset_min = ((a - b) % 3600) / 60; /* result : min. */
46 if (gmtoffset_min != 0) {
50 snprintf(str_buf, size, "%+d:%02u", gmtoffset_hour, gmtoffset_min);
51 SETTING_TRACE("szTimezone is of a valid format: GMT: %s", str_buf);
54 int generate_setting_cfg()
56 if (0 == setting_cfg_create(false)) {
57 SETTING_TRACE_ERROR("Error to create a new config file");
64 int migrate_setting_cfg()
67 if (0 == setting_cfg_migrate()) {
68 SETTING_TRACE_ERROR("Fail to migrate config file");
77 char *tzpath = get_timezone();
78 int ret = vconf_set_str(VCONFKEY_SETAPPL_TIMEZONE_ID, tzpath + 20);
80 SETTING_TRACE("fail to set vconf");
82 char str_buf[256] = {0, };
83 get_gmt_offset(str_buf, 256);
84 SETTING_TRACE(">>> time zone GMT string : %s", str_buf);
88 void get_current_font()
91 int retcode = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &value);
93 SETTING_TRACE("fail to set SYSTEM_SETTINGS_KEY_FONT_TYPE");
95 SETTING_TRACE(">>> get current font type : %s \n", value);
98 int status_fp(int total, int current, void *data)
100 SETTING_TRACE(">> total : %d ---- current : %d ", total, current);
106 sh-4.1# /opt/usr/apps/org.tizen.setting/bin/setting_conf_util timezone_check
107 debug level init 1(1)
108 >>> time zone : /usr/share/zoneinfo/Asia/Seoul
110 int main(int argc, char *argv[])
114 elm_init(argc, argv);
115 setting_set_i18n_force(SETTING_PACKAGE, SETTING_LOCALEDIR);
117 if ((argc == 2) && (0 == strcmp(argv[1], "export_json"))) {
118 setting_export_json(status_fp, NULL);
119 } else if ((argc == 2) && (0 == strcmp(argv[1], "import_json"))) {
120 setting_import_json(status_fp, NULL);
121 } else if ((argc == 2) && (0 == strcmp(argv[1], "timezone_init"))) {
123 } else if ((argc == 2) && (0 == strcmp(argv[1], "get_current_font"))) {
125 } else if ((argc == 2) && (0 == strcmp(argv[1], "gen_cfg"))) {
126 generate_setting_cfg();
127 } else if ((argc == 2) && (0 == strcmp(argv[1], "mig_cfg"))) {
128 migrate_setting_cfg();
131 else if ((argc == 2) && (0 == strcmp(argv[1], "search_db_indexing"))) {
133 __setting_init_search_index_app();
135 __setting_init_search_index_module();
141 setting_cfg_create(false);
147 static char *get_timezone()
151 enum { BUFFERSIZE = 1024 };
152 char buf[BUFFERSIZE] = {0, };
153 ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf) - 1);
158 /* handle error condition */
161 return g_strdup(buf);