2eee74959773e1f074dff6e70b7d6ced58e9db82
[apps/home/call-setting.git] / src / cst-util.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://www.tizenopensource.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 "cst-debug.h"
18 #include "cst-util.h"
19 #include <Evas.h>
20 #include <vconf.h>
21
22 void _cst_vconf_get_bool(const char *in_key, int *boolval)
23 {
24         if ((vconf_get_bool(in_key, boolval)) < 0)
25                 DBG("vconf get error : %s", in_key);
26 }
27
28 void _cst_vconf_get_int(const char *in_key, int *intval)
29 {
30         if ((vconf_get_int(in_key, intval)) < 0)
31                 DBG("vconf get error : %s", in_key);
32 }
33
34 char *_cst_vconf_get_str(const char *in_key)
35 {
36         char *result = NULL;
37         result = vconf_get_str(in_key);
38         if (result == NULL)
39                 DBG("vconf get error : %s", in_key);
40
41         return result;
42 }
43
44 void _cst_vconf_set_bool(const char *in_key, const int boolval)
45 {
46         if (vconf_set_bool(in_key, boolval) < 0)
47                 DBG("vconf set error : %s", in_key);
48         else
49                 DBG("vconf set : %d(%s)", boolval, in_key);
50 }
51
52 void _cst_vconf_set_int(const char *in_key, const int intval)
53 {
54         if (vconf_set_int(in_key, intval) < 0)
55                 DBG("vconf set error : %s", in_key);
56         else
57                 DBG("vconf set : %d(%s)", intval, in_key);
58 }
59
60 void _cst_vconf_set_str(const char *in_key, const char *strval)
61 {
62         if (vconf_set_str(in_key, strval) < 0)
63                 DBG("vconf set error : %s", in_key);
64         else
65                 DBG("vconf set : %s(%s)", strval, in_key);
66 }
67
68 Eina_Bool _cst_check_flight_mode(void)
69 {
70         ENTER(_cst_check_flight_mode);
71         int flight_mode = EINA_FALSE;
72
73         _cst_vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, &flight_mode);
74         return flight_mode;
75 }
76
77 Eina_Bool _cst_check_sim_status(void)
78 {
79         ENTER(_cst_check_sim_status);
80         int sim_status = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
81         Eina_Bool sim_avail = EINA_FALSE;
82
83         _cst_vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &sim_status);
84         if (sim_status == VCONFKEY_TELEPHONY_SIM_INSERTED) {
85                 sim_avail = EINA_TRUE;
86         }
87         return sim_avail;
88 }