}
}
-static void _update_nodes_table_by_uuid(char *uuid, int click_times,
- int last_clicked)
-{
- int size = get_cfg_array_size();
-
- int i;
- for (i = 0; i < size; i++) {
- if (0 == safeStrCmp(uuid, (s_cfg_node_array[i].uuid))) {
- s_cfg_node_array[i].click_times = click_times;
- s_cfg_node_array[i].last_clicked = last_clicked;
- return;
- }
- }
-}
-
-EXPORT_PUBLIC
-int setting_cfg_migrate(void)
-{
- /*1. read old cfg file */
- struct stat sb;
- memset(&sb, 0, sizeof(struct stat));
- int r = stat(setting_cfg_get_path(), &sb);
- if (0 != r)
- SETTING_TRACE("ERROR, r:%d", r);
-
- SETTING_TRACE("sb.st_size:%d", sb.st_size);
-
- parser = json_parser_new();
- GError *error = NULL;
- if (!sb.st_size
- || FALSE == json_parser_load_from_file(parser,
- setting_cfg_get_path(),
- &error)) {
- if (error)
- SETTING_TRACE_ERROR("error->message:%s",
- (char *)(error->message));
-
- /*if read old cfg file unseccessfully, remove it */
- SETTING_TRACE("Read old cfg fail, Trying to remove it");
- if (remove(setting_cfg_get_path()) != 0)
- SETTING_TRACE_ERROR("Error to remove the damaged file");
-
- /*re-create cfg file */
- SETTING_TRACE("Trying to re-create cfg file.");
- if (FALSE == setting_cfg_create(true))
- SETTING_TRACE_ERROR(
- "Error to create a new config file");
-
- g_object_unref(parser);
- parser = NULL;
- return FALSE;
- }
- root = json_parser_get_root(parser);
-
- /* 2. update click_times & last_clicked in s_cfg_node_array with old
- * cfg */
- int i, j, click_times, last_clicked;
- JsonObject *category_obj;
- JsonArray *menu;
- JsonObject *menu_item;
- char *uuid;
- for (i = 0; i < setting_cfg_get_category_length(); i++) {
- for (j = 0; j < setting_cfg_get_menu_length(i); j++) {
- category_obj = json_array_get_object_element(
- json_node_get_array(root), i);
- menu = json_object_get_array_member(category_obj,
- "menu");
- menu_item = json_array_get_object_element(menu, j);
- uuid = (char *)json_object_get_string_member(menu_item,
- "uuid");
- click_times = json_object_get_int_member(menu_item,
- "click_times");
- last_clicked = json_object_get_int_member(menu_item,
- "last_clicked");
- if (click_times != 0 || last_clicked != 0) {
- _update_nodes_table_by_uuid(uuid, click_times,
- last_clicked);
- }
- }
- }
-
- /*3. create new cfg file */
- if (!setting_cfg_create(true)) {
- SETTING_TRACE_ERROR("fail to create new cfg file");
- setting_cfg_exit();
- return FALSE;
- }
-
- setting_cfg_exit();
- return TRUE;
-}
-
EXPORT_PUBLIC
int setting_cfg_get_category_length(void)
{
"ug_args");
}
-EXPORT_PUBLIC
-void setting_cfg_set_pos_idx(int category_index, int menu_index, int pos)
-{
- JsonObject *category_obj = json_array_get_object_element(
- json_node_get_array(root), category_index);
- JsonArray *menu = json_object_get_array_member(category_obj, "menu");
- JsonObject *menu_item = json_array_get_object_element(menu, menu_index);
- json_object_remove_member(menu_item, "pos");
- json_object_set_int_member(menu_item, "pos", pos);
-}
-
EXPORT_PUBLIC
int setting_cfg_get_last_clicked_idx(int category_index, int menu_index)
{
+++ /dev/null
-/*
- * setting_confutil
- *
- *
- *
- $ setting_confutil // create a cfg file in default
- $ setting_confutil export // export current status to a xml file
- $ setting_confutil timezone_init // timezone init
- */
-#include <stdio.h>
-
-#include <setting-cfg.h>
-#include <setting-debug.h>
-#include <stdio.h>
-#include <Elementary.h>
-#include <setting-common-general-func.h>
-#include <setting-common-data-slp-setting.h>
-#include <unistd.h>
-#include <system_settings.h>
-
-#include <stdio.h>
-#include <libxml/parser.h>
-#include <libxml/tree.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 *pdata;
- struct tm data;
-
- pdata = localtime_r(&t, &data); /* save time as structure. */
- setting_retm_if(!pdata, "data is NULL");
- pdata->tm_isdst = 0; /* summer time, not applied. */
- time_t a = mktime(pdata);
-
- pdata = gmtime_r(&a, &data);
- setting_retm_if(!pdata, "data is NULL");
- pdata->tm_isdst = 0; /* summer time, not applied. */
- time_t b = mktime(pdata);
-
- 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:%02d", gmtoffset_hour, gmtoffset_min);
- 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();
- 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);
- SETTING_TRACE(">>> time zone GMT string : %s", str_buf);
- free(tzpath);
-}
-
-void get_current_font()
-{
- char *value = NULL;
- int retcode = system_settings_get_value_string(
- SYSTEM_SETTINGS_KEY_FONT_TYPE, &value);
- if (retcode != 0)
- SETTING_TRACE("fail to set SYSTEM_SETTINGS_KEY_FONT_TYPE");
-
- SETTING_TRACE(">>> get current font type : %s \n", value);
-}
-
-int status_fp(int total, int current, void *data)
-{
- SETTING_TRACE(">> total : %d ---- current : %d ", total, current);
- return 0;
-}
-
-
-/**
-sh-4.1# [_TZ_SYS_RW_APP]/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[])
-{
- elm_init(argc, argv);
- setting_set_i18n_force(SETTING_PACKAGE, SETTING_LOCALEDIR);
-
- 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 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();
- else {
- /* cfg create */
- /* TRUE or FALSE */
- setting_cfg_create(false);
- }
- return 0;
-}
-
-/* automatic */
-static char *get_timezone()
-{
- SETTING_TRACE_BEGIN;
-
- enum { BUFFERSIZE = 1024 };
- char buf[BUFFERSIZE] = {0, };
- ssize_t len = readlink(_TZ_SYS_ETC"/localtime", buf, sizeof(buf) - 1);
-
- if (len != -1) {
- buf[len] = '\0';
- } else {
- /* handle error condition */
- return NULL;
- }
- return strdup(buf);
-}
-
+++ /dev/null
-/*
- * setting
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
- *
- * Contact: MyoungJune Park <mj2004.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <setting-debug.h>
-#include <app.h>
-#include <ui-gadget.h>
-#include <Elementary.h>
-#include <Evas.h>
-#include <appcore-efl.h>
-#include <appcore-common.h>
-#include <vconf.h>
-#include <feedback.h>
-#include <device.h>
-#include <efl_extension.h>
-#include <setting-common-general-func.h>
-
-#define EXPORT_PUBLIC __attribute__((visibility("default")))
-
-typedef struct _support_display_appdata {
-
- ui_gadget_h ug;
-
- Evas *evas;
- Evas_Object *window;
- Evas_Object *naviframe;
- Evas_Object *ly_main; /**< seting view main */
- app_control_h service;
- Ecore_Event_Handler *event_handler;
-} support_display_appdata;
-
-/**
- * The function is called when Setting is terminated
- */
-static void support_display_app_terminate(void *data)
-{
- SETTING_TRACE_BEGIN;
- support_display_appdata *ad = data;
-
- SETTING_TRACE("support_display_terminate!");
-
- if (ad->event_handler) {
- ecore_event_handler_del(ad->event_handler);
- ad->event_handler = NULL;
- }
-
- if (ad->ly_main) {
- evas_object_del(ad->ly_main);
- ad->ly_main = NULL;
- }
-
- if (ad->window) {
- evas_object_del(ad->window);
- ad->window = NULL;
- }
- elm_exit();
-
- SETTING_TRACE_END;
-}
-
-/**
- * The event process when win object is destroyed
- */
-static void support_display_del_win(void *data, Evas_Object *obj, void *event)
-{
- /*ui_app_exit(); */
- elm_exit();
-}
-
-/**
- * To create a win object, the win is shared between the App and all its UGs
- */
-static Evas_Object *support_display_create_win(const char *name)
-{
- SETTING_TRACE_BEGIN;
- Evas_Object *eo;
- int w, h;
-
- eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
-
- if (eo) {
- elm_win_title_set(eo, name);
- elm_win_borderless_set(eo, EINA_TRUE);
- evas_object_smart_callback_add(eo, "delete,request",
- support_display_del_win, NULL);
-#ifdef ECORE_X
- ecore_x_window_size_get(ecore_x_window_root_first_get(),
- &w, &h);
-#else
- elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
-#endif
- evas_object_resize(eo, w, h);
- }
-
- return eo;
-}
-
-static Eina_Bool __key_press_cb(void *data, int type, void *event)
-{
- SETTING_TRACE_BEGIN;
- Evas_Event_Key_Down *ev = event;
- retv_if(!ev || !data, ECORE_CALLBACK_RENEW);
- support_display_appdata *ad = data;
-
- if (strcmp(ev->keyname, "XF86Home") == 0)
- ug_destroy(ad->ug);
-
- return ECORE_CALLBACK_RENEW;
-}
-
-/**
- * The function is called to create Setting view widgets
- */
-static bool support_display_app_create(void *data)
-{
- SETTING_TRACE_BEGIN;
-
- support_display_appdata *ad = data;
-
- SETTING_TRACE("[TIME] 3. it taked %d msec from main to setting_display_app_create ",
- appcore_measure_time());
- appcore_measure_start();
-
- /* create window */
- ad->window = support_display_create_win("org.tizen.setting.display");
- if (ad->window == NULL) {
- SETTING_TRACE("Can't create window");
- return 0;
- }
-
- if (elm_win_wm_rotation_supported_get(ad->window)) {
- int rots[4] = { 0, 90, 180, 270 };
- elm_win_wm_rotation_available_rotations_set(ad->window, rots,
- 4);
- }
-
- UG_INIT_EFL(ad->window, UG_OPT_INDICATOR_ENABLE);
- ad->evas = evas_object_evas_get(ad->window);
-
- elm_win_indicator_mode_set(ad->window, ELM_WIN_INDICATOR_SHOW);
- elm_win_indicator_opacity_set(ad->window, ELM_WIN_INDICATOR_OPAQUE);
-
- /* call ug */
- Evas_Object *conform = elm_conformant_add(ad->window);
- ad->ly_main = elm_layout_add(ad->window);
- evas_object_size_hint_weight_set(ad->ly_main, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_layout_theme_set(ad->ly_main, "layout", "application", "default");
-
- /* add bg */
- Evas_Object *bg = elm_bg_add(ad->ly_main);
- elm_object_style_set(bg, "group_list");
- evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_object_part_content_set(ad->ly_main, "elm.swallow.bg", bg);
- evas_object_show(bg);
-
- /* Indicator bg */
- Evas_Object *indicator_bg = elm_bg_add(conform);
- elm_object_style_set(indicator_bg, "indicator/headerbg");
- elm_object_part_content_set(conform, "elm.swallow.indicator_bg",
- indicator_bg);
- evas_object_show(indicator_bg);
-
- evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(conform, EVAS_HINT_FILL,
- EVAS_HINT_FILL);
- elm_win_resize_object_add(ad->window, conform);
- elm_object_content_set(conform, ad->ly_main);
- evas_object_show(conform);
- elm_win_conformant_set(ad->window, EINA_TRUE);
-
- SETTING_TRACE("[TIME] 4. setting_main_app_create taked %d msec ",
- appcore_measure_time());
- appcore_measure_start();
-
- /* add event handler */
- ad->event_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
- __key_press_cb, ad);
-
- return TRUE;
-}
-
-/**
- * The function is called when Setting begins run in background from forground
- */
-static void support_display_app_pause(void *data)
-{
- SETTING_TRACE_BEGIN;
- support_display_appdata *ad = data;
-
- if (ad->ug) {
- ug_pause();
- /*ad->ug = NULL; */
- }
-}
-
-/**
- * The function is called when Setting begins run in forground from background
- */
-static void support_display_app_resume(void *data)
-{
- SETTING_TRACE_BEGIN;
- support_display_appdata *ad = data;
-
- if (ad->ug)
- ug_resume();
-}
-
-EXPORT_PUBLIC void update_region(void)
-{
- char *region;
-
- region = vconf_get_str(VCONFKEY_REGIONFORMAT);
- if (region) {
- setenv("LC_CTYPE", region, 1);
- setenv("LC_NUMERIC", region, 1);
- setenv("LC_TIME", region, 1);
- setenv("LC_COLLATE", region, 1);
- setenv("LC_MONETARY", region, 1);
- setenv("LC_PAPER", region, 1);
- setenv("LC_NAME", region, 1);
- setenv("LC_ADDRESS", region, 1);
- setenv("LC_TELEPHONE", region, 1);
- setenv("LC_MEASUREMENT", region, 1);
- setenv("LC_IDENTIFICATION", region, 1);
- free(region);
- }
-}
-
-static int __set_i18n(const char *domain, const char *dir)
-{
- char *r;
- if (domain == NULL) {
- errno = EINVAL;
- return -1;
- }
-
- r = setlocale(LC_ALL, "");
- /* if locale is not set properly, try again to set as language base */
- if (r == NULL)
- r = setlocale(LC_ALL, vconf_get_str(VCONFKEY_LANGSET));
-
- bindtextdomain(domain, dir);
- textdomain(domain);
- return 0;
-}
-
-/**
- * The function is called by app-fwk after app_create. It always do the process
- * which cost much time.
- */
-static void support_display_app_reset(app_control_h service, void *data)
-{
- SETTING_TRACE_BEGIN;
- support_display_appdata *ad = data;
-
- app_launcher("org.tizen.setting-display|viewtype:wallpaper", NULL, NULL);
-
-}
-
-static void support_display_app_lang_changed(app_event_info_h event_info,
- void *data)
-{
- SETTING_TRACE_BEGIN;
- support_display_appdata *ad = data;
- char *lang = NULL;
-
- lang = vconf_get_str(VCONFKEY_LANGSET);
- if (lang) {
- elm_language_set((const char *)lang);
- FREE(lang);
- }
-
- if (ad->ug)
- ug_send_event(UG_EVENT_LANG_CHANGE);
-}
-
-EXPORT_PUBLIC
-int main(int argc, char *argv[])
-{
- SETTING_TRACE_BEGIN;
- int r = 0;
- support_display_appdata ad;
-
- ui_app_lifecycle_callback_s ops = {
- .create = support_display_app_create,
- .terminate = support_display_app_terminate,
- .pause = support_display_app_pause,
- .resume = support_display_app_resume,
- .app_control = support_display_app_reset, };
-
- app_event_handler_h handlers[5] = { NULL, };
- ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY],
- APP_EVENT_LOW_BATTERY, NULL, NULL);
- ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED],
- APP_EVENT_LANGUAGE_CHANGED,
- support_display_app_lang_changed, NULL);
- ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
- APP_EVENT_REGION_FORMAT_CHANGED, NULL, NULL);
- ui_app_add_event_handler(
- &handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED],
- APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, NULL);
-
- memset(&ad, 0x00, sizeof(support_display_appdata));
-
- r = ui_app_main(argc, argv, &ops, &ad);
- SETTING_TRACE_DEBUG("r = %d", r);
-
- if (r == -1) {
- SETTING_TRACE_ERROR("ui_app_main() returns -1");
- return -1;
- }
-
- return 0;
-}