Removing unnecessary HTML link for feature/privilege
[platform/core/api/url-download.git] / src / download-private.c
1 #include <stdarg.h>
2 #include <system_info.h>
3 #include <download_private.h>
4
5 static __thread int feature_supported[DOWNLOAD_SUPPORTED_FEATURE_MAX] = { -1, -1, -1, -1};
6
7 static bool __check_feature_supported(const char *key, download_supported_feature_e feature)
8 {
9         if (feature_supported[feature] == -1) {
10                 bool value = false;
11                 if (system_info_get_platform_bool(key, &value) < 0) {
12                         TRACE_ERROR("Failed to get system info");
13                         return false;
14                 }
15                 feature_supported[feature] = (int)value;
16         }
17         return (feature_supported[feature] > 0 ? true : false);
18 }
19
20 int _download_check_feature_supported(const char *feature, ...)
21 {
22         va_list list;
23         const char *key;
24         bool value = false;
25         bool supported = false;
26
27         va_start(list, feature);
28         key = feature;
29
30         while (1) {
31                 if (strcmp(key, DOWNLOAD_FEATURE) == 0)
32                         value = __check_feature_supported(key, DOWNLOAD_SUPPORTED_FEATURE_DOWNLOAD);
33                 else if (strcmp(key, TELEPHONY_FEATURE) == 0)
34                         value = __check_feature_supported(key, DOWNLOAD_SUPPORTED_FEATURE_TELEPHONY);
35                 else if (strcmp(key, WIFI_FEATURE) == 0)
36                         value =  __check_feature_supported(key, DOWNLOAD_SUPPORTED_FEATURE_WIFI);
37                 else if (strcmp(key, WIFI_DIRECT_FEATURE) == 0)
38                         value =  __check_feature_supported(key, DOWNLOAD_SUPPORTED_FEATURE_WIFI_DIRECT);
39
40                 supported |= value;
41                 key = va_arg(list, const char *);
42                 if (!key) break;
43         }
44
45         if (!supported) {
46                 TRACE_ERROR("Not supported features");
47                 set_last_result(DOWNLOAD_ERROR_NOT_SUPPORTED);
48                 va_end(list);
49                 return DOWNLOAD_ERROR_NOT_SUPPORTED;
50         }
51         va_end(list);
52         set_last_result(DOWNLOAD_ERROR_NONE);
53
54         return DOWNLOAD_ERROR_NONE;
55 }