2 * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
4 * This file is a modified version of BSD licensed file and
5 * licensed under the Flora License, Version 1.1 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * Please, see the LICENSE file for the original copyright owner and
21 #include <Elementary.h>
23 #include "screen_reader_vconf.h"
24 #include "screen_reader_spi.h"
27 #ifdef RUN_IPC_TEST_SUIT
28 #include "test_suite/test_suite.h"
34 #define LOG_TAG "SCREEN READER VCONF"
37 keylist_t *keys = NULL;
39 // ------------------------------ vconf callbacks----------------------
41 void app_termination_cb(keynode_t *node, void *user_data)
44 DEBUG("Application terminate %d", !node->value.i);
46 Service_Data *service_data = user_data;
47 service_data->run_service = node->value.i;
49 if(service_data->run_service == 0)
57 void display_language_cb(keynode_t *node, void *user_data)
60 DEBUG("Trying to set LC_MESSAGES to: %s", node->value.s);
62 Service_Data *sd = user_data;
63 snprintf(sd->display_language, LANGUAGE_NAME_SIZE, "%s", node->value.s);
64 //to make gettext work
65 setenv("LC_MESSAGES", sd->display_language, 1);
70 // --------------------------------------------------------------------
72 int get_key_values(Service_Data *sd)
77 char *display_language = vconf_get_str("db/menu_widget/language");
80 snprintf(sd->display_language, LANGUAGE_NAME_SIZE, "%s", display_language);
81 //to make gettext work
82 setenv("LC_MESSAGES", sd->display_language, 1);
83 free(display_language);
86 WARNING("Can't get db/menu_widget/language value");
88 DEBUG("SCREEN READER DATA SET TO: Display_Language: %s, Tracking signal: %s;",
89 sd->display_language, sd->tracking_signal_name);
95 int _set_vconf_callback_and_print_message_on_error_and_return_error_code(const char *in_key, vconf_callback_fn cb,
98 int ret = vconf_notify_key_changed(in_key, cb, user_data);
100 DEBUG("Could not add notify callback to %s key", in_key);
105 bool vconf_init(Service_Data *service_data)
107 DEBUG( "--------------------- VCONF_init START ---------------------");
112 DEBUG("nothing is written\n");
116 DEBUG("everything is written\n");
119 vconf_keylist_free(keys);
120 // ----------------------------------------------------------------------------------
122 ret = get_key_values(service_data);
125 DEBUG("Could not set data from vconf: %d", ret);
128 _set_vconf_callback_and_print_message_on_error_and_return_error_code("db/menu_widget/language", display_language_cb, service_data);
130 DEBUG( "---------------------- VCONF_init END ----------------------\n\n");