2 * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <system_info.h>
21 #include "location_internal.h"
23 int __convert_error_code(int code)
26 const char *msg = NULL;
28 case LOCATION_ERROR_NONE:
29 ret = LOCATIONS_ERROR_NONE;
30 msg = "LOCATIONS_ERROR_NONE";
32 case LOCATION_ERROR_PARAMETER:
33 ret = LOCATIONS_ERROR_INVALID_PARAMETER;
34 msg = "LOCATIONS_ERROR_INVALID_PARAMETER";
36 case LOCATION_ERROR_NOT_ALLOWED:
37 ret = LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED;
38 msg = "LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED";
40 case LOCATION_ERROR_NOT_SUPPORTED:
41 ret = LOCATIONS_ERROR_NOT_SUPPORTED;
42 msg = "LOCATIONS_ERROR_NOT_SUPPORTED";
44 case LOCATION_ERROR_NETWORK_FAILED:
45 case LOCATION_ERROR_NETWORK_NOT_CONNECTED:
46 ret = LOCATIONS_ERROR_NETWORK_FAILED;
47 msg = "LOCATIONS_ERROR_NETWORK_FAILED";
49 case LOCATION_ERROR_SETTING_OFF:
50 ret = LOCATIONS_ERROR_GPS_SETTING_OFF;
51 msg = "LOCATIONS_ERROR_GPS_SETTING_OFF";
53 case LOCATION_ERROR_SECURITY_DENIED:
54 ret = LOCATIONS_ERROR_SECURITY_RESTRICTED;
55 msg = "LOCATIONS_ERROR_SECURITY_RESTRICTED";
57 case LOCATION_ERROR_NOT_AVAILABLE:
58 case LOCATION_ERROR_CONFIGURATION:
59 case LOCATION_ERROR_UNKNOWN:
61 msg = "LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE";
62 ret = LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE;
65 if (ret != LOCATIONS_ERROR_NONE) {
66 LOCATIONS_LOGE("%s(0x%08x) : core fw error(0x%x)", msg, ret, code);
71 int __is_gps_supported(void)
73 bool is_supported = false;
76 retval = system_info_get_platform_bool("http://tizen.org/feature/location.gps", &is_supported);
77 if (retval != SYSTEM_INFO_ERROR_NONE) {
78 LOCATIONS_LOGW("system_info_get_platform_bool failed: retval = %d", retval);
80 if (is_supported == false) {
81 return LOCATIONS_ERROR_NOT_SUPPORTED;
83 return LOCATIONS_ERROR_NONE;
86 int __is_wps_supported(void)
88 bool is_supported = false;
91 retval = system_info_get_platform_bool("http://tizen.org/feature/location.wps", &is_supported);
92 if (retval != SYSTEM_INFO_ERROR_NONE) {
93 LOCATIONS_LOGW("system_info_get_platform_bool failed: retval = %d", retval);
95 if (is_supported == false) {
96 return LOCATIONS_ERROR_NOT_SUPPORTED;
98 return LOCATIONS_ERROR_NONE;
101 int __is_location_supported(void)
103 if (__is_gps_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) {
104 if (__is_wps_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) {
105 return LOCATIONS_ERROR_NOT_SUPPORTED;
107 return LOCATIONS_ERROR_NONE;
111 return LOCATIONS_ERROR_NONE;
114 int __set_callback(_location_event_e type, location_manager_h manager, void *callback, void *user_data)
116 LOCATIONS_NULL_ARG_CHECK(manager);
117 LOCATIONS_NULL_ARG_CHECK(callback);
118 location_manager_s *handle = (location_manager_s *) manager;
119 handle->user_cb[type] = callback;
120 handle->user_data[type] = user_data;
121 LOCATIONS_LOGD("event type : %d", type);
122 return LOCATIONS_ERROR_NONE;
125 int __unset_callback(_location_event_e type, location_manager_h manager)
127 LOCATIONS_NULL_ARG_CHECK(manager);
128 location_manager_s *handle = (location_manager_s *) manager;
129 handle->user_cb[type] = NULL;
130 handle->user_data[type] = NULL;
131 LOCATIONS_LOGD("event type : %d. ", type);
132 return LOCATIONS_ERROR_NONE;