tizen 2.3 release
[kernel/api/system-resource.git] / src / network / settings.c
1 /*
2  * resourced
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 /*
21  *
22  * @file settings.c
23  *
24  * @desc Entity for load vconf options
25  *
26  * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
27  *
28  */
29
30 #include <vconf/vconf.h>
31
32 #include "macro.h"
33 #include "settings.h"
34 #include "trace.h"
35
36 API int load_options(resourced_options *options)
37 {
38         int val = 0;
39
40         if (!options) {
41                 _E("Please provide valid argument!");
42                 return -1;
43         }
44         if (vconf_get_bool(RESOURCED_WIFI_STATISTICS_PATH, &val) == 0)
45                 options->wifi = val ?
46                         RESOURCED_OPTION_ENABLE : RESOURCED_OPTION_DISABLE;
47         else {
48                 _D("Can not get WiFi statistics settings");
49                 return -1;
50         }
51
52         if (vconf_get_bool(RESOURCED_DATACALL_PATH, &val) == 0)
53                 options->datacall = val ?
54                         RESOURCED_OPTION_ENABLE : RESOURCED_OPTION_DISABLE;
55         else {
56                 _D("Can not get DataCall settings");
57                 return -1;
58         }
59
60         if (vconf_get_int(RESOURCED_DATAUSAGE_TIMER_PATH, &val) == 0)
61                 options->datausage_timer = val;
62         else {
63                 _D("Can not get DataUsage timer settings");
64                 return -1;
65         }
66
67         if (vconf_get_bool(RESOURCED_DATACALL_LOGGING_PATH, &val) == 0)
68                 options->datacall_logging = val ?
69         RESOURCED_OPTION_ENABLE : RESOURCED_OPTION_DISABLE;
70         else {
71                 _D("Can not get DataCall logging settings");
72                 return -1;
73         }
74         return 0;
75 }