change nodisplay of ring from false to true to fix TIVI-702
[profile/ivi/clock.git] / src / clock_vconf.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <vconf.h>
18
19 #include "clock.h"
20 #include "clock_vconf.h"
21
22 /**
23  * Load vconf setting from vconf module,
24  * And save such information to data
25  *
26  * @param[out]  data   Pointer to the application data structure,
27  *                     which used for store vconf setting
28  *
29  * @return     EINA_FALSE if load failed
30  *             EINA_TRUE if load successfully.
31  */
32 Eina_Bool clock_vconf_load_history_conf(void *data)
33 {
34         CLK_FUN_BEG();
35         if (!data) {
36                 return EINA_FALSE;
37         }
38
39         struct appdata *ad = (struct appdata *)data;
40         int app_id = 0;
41         int ref = -1;
42
43         // read history view id from vconf module
44         ref = vconf_get_int(VCONF_CLOCK_APPLICATION_ID, &app_id);
45
46         if (0 == ref && app_id >= 1 && app_id <= 4) {
47                 ad->history_view_id = app_id;
48                 CLK_INFO("\n\n\t <<<<<<<<<<<< application_id = %d\n", app_id);
49         } else {
50                 // if there is no history information, set default value to 1
51                 ad->history_view_id = 1;
52         }
53
54         CLK_FUN_END();
55         return EINA_TRUE;
56 }
57
58 /**
59  * Save the system setting which read from app data structure,
60  * And save such information into vconf setting
61  *
62  * @param[in]  data   Pointer to the application data structure,
63  *                    which used for read setting used for store
64  *
65  * @return     EINA_FALSE if save failed
66  *             EINA_TRUE if save successfully.
67  */
68 Eina_Bool clock_vconf_set_history_conf(void *data)
69 {
70         CLK_FUN_BEG();
71         if (!data) {
72                 return EINA_FALSE;
73         }
74
75         struct appdata *ad = (struct appdata *)data;
76
77         int app_id = ad->current_view_id;
78         // set current view id to vconf sets
79         if (vconf_set_int(VCONF_CLOCK_APPLICATION_ID, app_id)) {
80                 CLK_INFO
81                     ("\n\n\t <<<<<<<<<<<< clock_vconf_set_history_app_name FAIL\n");
82                 return EINA_FALSE;
83         } else {
84                 CLK_INFO
85                     ("\n\n\t <<<<<<<<<<<< clock_vconf_set_history_app_name OK\n");
86                 // sync
87                 vconf_sync_key(VCONF_CLOCK_APPLICATION_ID);
88         }
89
90         CLK_FUN_END();
91         return EINA_TRUE;
92 }
93
94 /**
95  * Check battery state for judging if battery low.
96  *
97  * @return     EINA_FALSE if battery low
98  *             EINA_TRUE if not
99  */
100 Eina_Bool clock_vconf_check_battery_low()
101 {
102         CLK_FUN_BEG();
103         int low_status = -1;
104
105         if (!vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &low_status)) {
106                 CLK_INFO("\n\tbattery status low = %d\n", low_status);
107                 if (low_status <= VCONFKEY_SYSMAN_BAT_WARNING_LOW) {
108                         CLK_FUN_END();
109                         return EINA_TRUE;
110                 }
111         }
112         CLK_FUN_END();
113         return EINA_FALSE;
114 }