refactoring for model-config
[framework/api/system-info.git] / src / system_info_network.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
21 #include <dlog.h>
22
23 #include <system_info.h>
24 #include <system_info_private.h>
25
26 #ifdef LOG_TAG
27 #undef LOG_TAG
28 #endif
29
30 #define LOG_TAG "CAPI_SYSTEM_INFO"
31
32 int system_info_get_network_type(system_info_key_e key, system_info_data_type_e data_type, void **value)
33 {
34         bool service_type = 0;
35         char *NET_TYPE = NULL;
36         char NETWORK_TYPE[MAXBUFSIZE];
37
38         NETWORK_TYPE[0] = '\0';
39
40         strcat(NETWORK_TYPE, "Emergency ");
41
42         if (system_info_get_platform_bool("tizen.org/feature/network.telephony.service.cdma", &service_type) == SYSTEM_INFO_ERROR_NONE
43                 && service_type == true)
44                 strcat(NETWORK_TYPE, "| cdma ");
45         if (system_info_get_platform_bool("tizen.org/feature/network.telephony.service.edge", &service_type) == SYSTEM_INFO_ERROR_NONE
46                 && service_type == true)
47                 strcat(NETWORK_TYPE, "| edge ");
48         if (system_info_get_platform_bool("tizen.org/feature/network.telephony.service.gprs", &service_type) == SYSTEM_INFO_ERROR_NONE
49                 && service_type == true)
50                 strcat(NETWORK_TYPE, "| gprs ");
51         if (system_info_get_platform_bool("tizen.org/feature/network.telephony.service.gsm", &service_type) == SYSTEM_INFO_ERROR_NONE
52                 && service_type == true)
53                 strcat(NETWORK_TYPE, "| gsm ");
54         if (system_info_get_platform_bool("tizen.org/feature/network.telephony.service.hsdpa", &service_type) == SYSTEM_INFO_ERROR_NONE
55                 && service_type == true)
56                 strcat(NETWORK_TYPE, "| hsdpa ");
57         if (system_info_get_platform_bool("tizen.org/feature/network.telephony.service.hspa", &service_type) == SYSTEM_INFO_ERROR_NONE
58                 && service_type == true)
59                 strcat(NETWORK_TYPE, "| hspa ");
60         if (system_info_get_platform_bool("tizen.org/feature/network.telephony.service.hsupa", &service_type) == SYSTEM_INFO_ERROR_NONE
61                 && service_type == true)
62                 strcat(NETWORK_TYPE, "| hsupa ");
63         if (system_info_get_platform_bool("tizen.org/feature/network.telephony.service.umts", &service_type) == SYSTEM_INFO_ERROR_NONE
64                 && service_type == true)
65                 strcat(NETWORK_TYPE, "| umts ");
66         if (system_info_get_platform_bool("tizen.org/feature/network.telephony.service.lte", &service_type) == SYSTEM_INFO_ERROR_NONE
67                 && service_type == true)
68                 strcat(NETWORK_TYPE, "| lte ");
69
70         NET_TYPE = strdup(NETWORK_TYPE);
71
72         if (NET_TYPE == NULL) {
73                 LOGE("OUT_OF_MEMORY(0x%08x)", SYSTEM_INFO_ERROR_OUT_OF_MEMORY);
74                 return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
75         }
76
77         *value = NET_TYPE;
78
79         return SYSTEM_INFO_ERROR_NONE;
80 }