Initialize Tizen 2.3
[framework/api/system-info.git] / src / system_info_device.c
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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 <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <unistd.h>
21
22 #include <dlog.h>
23
24 #include <system_info.h>
25 #include <system_info_private.h>
26
27 #ifdef LOG_TAG
28 #undef LOG_TAG
29 #endif
30
31 #define LOG_TAG "CAPI_SYSTEM_INFO"
32
33 #define TETHERING_INFO_FILE_PATH "/etc/config/connectivity/sysinfo-tethering.xml"
34
35 int system_info_get_manufacturer(system_info_key_e key, system_info_data_type_e data_type, void **value)
36 {
37         char *manufacturer = NULL;
38
39         manufacturer = strdup("samsung");
40         if (manufacturer == NULL) {
41                 LOGE("OUT_OF_MEMORY(0x%08x)", SYSTEM_INFO_ERROR_OUT_OF_MEMORY);
42                 return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
43         }
44
45         *value = manufacturer;
46
47         return SYSTEM_INFO_ERROR_NONE;
48 }
49
50 int system_info_get_tethering_supported(system_info_key_e key, system_info_data_type_e data_type, void **value)
51 {
52         bool *supported;
53         char *string = NULL;
54         char *model = "default";
55
56         supported = (bool *)value;
57
58         if (access(TETHERING_INFO_FILE_PATH, R_OK)) {
59                         *supported = false;
60                         return SYSTEM_INFO_ERROR_NONE;
61         }
62
63         if (system_info_get_value_from_xml(TETHERING_INFO_FILE_PATH, model, "tethering-support", &string)) {
64                         LOGE("cannot get tethering-support info from %s!!!", TETHERING_INFO_FILE_PATH);
65                         return SYSTEM_INFO_ERROR_IO_ERROR;
66         }
67
68         if (!strcmp(string, "true") || !strcmp(string, "TRUE"))
69                         *supported = true;
70         else
71                         *supported = false;
72
73         free(string);
74
75         return SYSTEM_INFO_ERROR_NONE;
76 }