4 * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
7 * Genie Kim <daejins.kim@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
31 #include "location-log.h"
32 #include "location-setting.h"
33 #include "location-ielement.h"
34 #include "location-hybrid.h"
35 #include "location-gps.h"
36 #include "location-wps.h"
37 #include "location-position.h"
38 #include "module-internal.h"
39 #include "location-common-util.h"
40 #ifndef TIZEN_PROFILE_TV
41 #include "location-privacy.h"
44 #define LOCATION_PRIVILEGE "http://tizen.org/privilege/location"
45 #define LOCATION_ENABLE_PRIVILEGE "http://tizen.org/privilege/location.enable"
47 typedef struct _LocationSetting {
48 LocationSettingCb callback;
52 static LocationSetting g_location_setting;
54 static char *__convert_setting_key(LocationMethod method)
58 case LOCATION_METHOD_HYBRID:
59 key = g_strdup(VCONFKEY_LOCATION_USE_MY_LOCATION);
61 case LOCATION_METHOD_GPS:
62 key = g_strdup(VCONFKEY_LOCATION_ENABLED);
64 case LOCATION_METHOD_WPS:
65 key = g_strdup(VCONFKEY_LOCATION_NETWORK_ENABLED);
67 case INTERNAL_METHOD_MOCK:
68 key = g_strdup(VCONFKEY_LOCATION_MOCK_ENABLED);
77 static LocationMethod __convert_method_from_key(const char *key)
79 LocationMethod _method = LOCATION_METHOD_NONE;
80 if (g_strcmp0(key, VCONFKEY_LOCATION_USE_MY_LOCATION) == 0)
81 _method = LOCATION_METHOD_HYBRID;
82 else if (g_strcmp0(key, VCONFKEY_LOCATION_ENABLED) == 0)
83 _method = LOCATION_METHOD_GPS;
84 else if (g_strcmp0(key, VCONFKEY_LOCATION_NETWORK_ENABLED) == 0)
85 _method = LOCATION_METHOD_WPS;
90 static void __location_setting_cb(keynode_t *key, gpointer data)
92 if (key == NULL || data == NULL)
95 LocationSetting *_setting = (LocationSetting *)data;
96 LocationMethod _method = LOCATION_METHOD_NONE;
98 if (_setting->callback) {
99 _method = __convert_method_from_key(vconf_keynode_get_name(key));
100 _setting->callback(_method, location_setting_get_key_val(key), _setting->user_data);
105 int location_init(void)
107 #if !GLIB_CHECK_VERSION(2, 35, 0)
111 #if !GLIB_CHECK_VERSION(2, 31, 0)
112 if (!g_thread_supported()) g_thread_init(NULL);
114 if (FALSE == module_init())
115 return LOCATION_ERROR_NOT_AVAILABLE;
117 return LOCATION_ERROR_NONE;
120 EXPORT_API LocationObject *
121 location_new(LocationMethod method)
123 LocationObject *self = NULL;
124 LOCATION_LOGD("method: %d", method);
127 case LOCATION_METHOD_HYBRID:
128 self = g_object_new(LOCATION_TYPE_HYBRID, NULL);
130 case LOCATION_METHOD_GPS:
131 self = g_object_new(LOCATION_TYPE_GPS, NULL);
133 case LOCATION_METHOD_WPS:
134 self = g_object_new(LOCATION_TYPE_WPS, NULL);
140 LOC_COND_LOG(!self, _E, "Fail to create location object. [method=%d]", method);
145 location_free(LocationObject *obj)
147 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
149 return LOCATION_ERROR_NONE;
153 location_request_single_location(LocationObject *obj, int timeout)
155 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
157 int ret = LOCATION_ERROR_NONE;
158 ret = location_ielement_request_single_location(LOCATION_IELEMENT(obj), timeout);
159 LOC_IF_FAIL(ret, _E, "Fail to request single location [%s]", err_msg(ret));
165 location_start(LocationObject *obj)
167 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
169 int ret = LOCATION_ERROR_NONE;
170 #ifndef TIZEN_PROFILE_TV
171 ret = location_check_cynara(LOCATION_PRIVILEGE);
172 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
175 ret = location_ielement_start(LOCATION_IELEMENT(obj));
176 LOC_IF_FAIL(ret, _E, "Fail to start [%s]", err_msg(ret));
182 location_stop(LocationObject *obj)
184 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
186 int ret = LOCATION_ERROR_NONE;
187 ret = location_ielement_stop(LOCATION_IELEMENT(obj));
188 LOC_IF_FAIL(ret, _E, "Fail to stop [%s]", err_msg(ret));
194 location_start_batch(LocationObject *obj)
196 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
197 int ret = LOCATION_ERROR_NONE;
199 #ifndef TIZEN_PROFILE_TV
200 ret = location_check_cynara(LOCATION_PRIVILEGE);
201 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
204 ret = location_ielement_start_batch(LOCATION_IELEMENT(obj));
205 LOC_IF_FAIL(ret, _E, "Fail to start_batch [%s]", err_msg(ret));
211 location_stop_batch(LocationObject *obj)
213 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
214 int ret = LOCATION_ERROR_NONE;
215 ret = location_ielement_stop_batch(LOCATION_IELEMENT(obj));
216 LOC_IF_FAIL(ret, _E, "Fail to stop_batch [%d]", err_msg(ret));
222 location_is_supported_method(LocationMethod method)
224 gboolean is_supported = FALSE;
227 case LOCATION_METHOD_HYBRID:
228 if (module_is_supported("gps") || module_is_supported("wps"))
231 case LOCATION_METHOD_GPS:
232 is_supported = module_is_supported("gps");
234 case LOCATION_METHOD_WPS:
235 is_supported = module_is_supported("wps");
245 location_is_enabled_method(LocationMethod method, int *is_enabled)
247 g_return_val_if_fail(is_enabled, LOCATION_ERROR_PARAMETER);
249 int vconf_ret = VCONF_ERROR;
251 char *_key = __convert_setting_key(method);
252 LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
254 vconf_ret = vconf_get_int(_key, &vconf_val);
255 if (vconf_ret != VCONF_OK) {
256 LOCATION_SECLOG("vconf_get failed [%s], error [%d]", _key, vconf_ret);
258 return LOCATION_ERROR_NOT_AVAILABLE;
260 LOCATION_SECLOG("[%s]:[%d]", _key, vconf_val);
263 *is_enabled = vconf_val;
266 return LOCATION_ERROR_NONE;
270 location_enable_method(const LocationMethod method, const int enable)
275 #ifndef TIZEN_PROFILE_TV
276 ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
277 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
280 if (location_setting_get_int(VCONFKEY_LOCATION_RESTRICT) > RESTRICT_OFF) {
281 LOCATION_SECLOG("Location setting is denied by DPM");
282 return LOCATION_ERROR_NOT_ALLOWED;
286 _key = __convert_setting_key(method);
287 LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
289 ret = vconf_set_int(_key, enable);
290 if (ret != VCONF_OK) {
291 LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
293 return LOCATION_ERROR_NOT_ALLOWED;
298 _key = __convert_setting_key(LOCATION_METHOD_HYBRID);
299 LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", LOCATION_METHOD_HYBRID, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
302 ret = vconf_set_int(_key, enable);
303 if (ret != VCONF_OK) {
304 LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
306 return LOCATION_ERROR_NOT_ALLOWED;
310 int enabled_state = 0;
312 for (i = LOCATION_METHOD_GPS; i < LOCATION_METHOD_MAX; i++) {
313 _key = __convert_setting_key(i);
314 enabled_state |= location_setting_get_int(_key);
317 if (!enabled_state) {
318 _key = __convert_setting_key(LOCATION_METHOD_HYBRID);
319 ret = vconf_set_int(_key, enable);
320 if (ret != VCONF_OK) {
321 LOCATION_SECLOG("vconf_set_int failed [%s], error [%d]", _key, ret);
323 return LOCATION_ERROR_NOT_ALLOWED;
325 LOCATION_SECLOG("[%s]:[%d]", _key, ret);
335 location_add_setting_notify(LocationMethod method, LocationSettingCb callback, void *user_data)
337 int ret = LOCATION_ERROR_NONE;
338 char *_key = __convert_setting_key(method);
339 LOC_COND_RET(!_key, LOCATION_ERROR_PARAMETER, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_PARAMETER));
341 g_location_setting.callback = callback;
342 g_location_setting.user_data = user_data;
344 ret = location_setting_add_notify(_key, __location_setting_cb, &g_location_setting);
351 location_ignore_setting_notify(LocationMethod method, LocationSettingCb callback)
353 int ret = LOCATION_ERROR_NONE;
354 char *_key = __convert_setting_key(method);
355 LOC_COND_RET(!_key, LOCATION_ERROR_PARAMETER, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_PARAMETER));
357 g_location_setting.callback = NULL;
358 g_location_setting.user_data = NULL;
360 ret = location_setting_ignore_notify(_key, __location_setting_cb);
368 location_get_position(LocationObject *obj, LocationPosition **position, LocationAccuracy **accuracy)
370 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
371 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
372 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
374 int ret = LOCATION_ERROR_NONE;
376 #ifndef TIZEN_PROFILE_TV
377 ret = location_check_cynara(LOCATION_PRIVILEGE);
378 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
381 ret = location_ielement_get_position(LOCATION_IELEMENT(obj), position, accuracy);
382 LOC_COND_RET(ret != LOCATION_ERROR_NONE, ret, _E, "Fail to get_position [%s]", err_msg(ret));
388 location_get_position_ext(LocationObject *obj, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
390 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
391 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
392 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
393 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
395 int ret = LOCATION_ERROR_NONE;
397 #ifndef TIZEN_PROFILE_TV
398 ret = location_check_cynara(LOCATION_PRIVILEGE);
399 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
402 ret = location_ielement_get_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
403 LOC_IF_FAIL(ret, _E, "Fail to get_position_ext [%s]", err_msg(ret));
409 location_get_last_position(LocationObject *obj, LocationPosition **position, LocationAccuracy **accuracy)
411 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
412 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
413 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
415 int ret = LOCATION_ERROR_NONE;
417 #ifndef TIZEN_PROFILE_TV
418 ret = location_check_cynara(LOCATION_PRIVILEGE);
419 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
422 ret = location_ielement_get_last_position(LOCATION_IELEMENT(obj), position, accuracy);
423 LOC_IF_FAIL(ret, _E, "Fail to get_last_position [%s]", err_msg(ret));
429 location_get_last_position_ext(LocationObject *obj, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
431 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
432 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
433 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
434 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
436 int ret = LOCATION_ERROR_NONE;
438 #ifndef TIZEN_PROFILE_TV
439 ret = location_check_cynara(LOCATION_PRIVILEGE);
440 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
443 ret = location_ielement_get_last_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
444 LOC_IF_FAIL(ret, _E, "Fail to get_last_position_ext [%s]", err_msg(ret));
450 location_get_nmea(LocationObject *obj, char **nmea)
452 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
453 g_return_val_if_fail(nmea, LOCATION_ERROR_PARAMETER);
455 int ret = LOCATION_ERROR_NONE;
456 ret = location_ielement_get_nmea(LOCATION_IELEMENT(obj), nmea);
457 LOC_IF_FAIL(ret, _E, "Fail to get_nmea [%s]", err_msg(ret));
464 location_get_satellite(LocationObject *obj, LocationSatellite **satellite)
466 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
467 g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
469 int ret = LOCATION_ERROR_NONE;
471 #ifndef TIZEN_PROFILE_TV
472 ret = location_check_cynara(LOCATION_PRIVILEGE);
473 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
476 ret = location_ielement_get_satellite(LOCATION_IELEMENT(obj), satellite);
477 LOC_IF_FAIL(ret, _E, "Fail to get_satellite [%s]", err_msg(ret));
483 location_get_batch(LocationObject *obj, LocationBatch **batch)
485 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
486 g_return_val_if_fail(batch, LOCATION_ERROR_PARAMETER);
488 int ret = LOCATION_ERROR_NONE;
490 #ifndef TIZEN_PROFILE_TV
491 ret = location_check_cynara(LOCATION_PRIVILEGE);
492 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
495 ret = location_ielement_get_batch(LOCATION_IELEMENT(obj), batch);
496 LOC_IF_FAIL(ret, _E, "Fail to get_batch [%s]", err_msg(ret));
502 location_get_last_satellite(LocationObject *obj, LocationSatellite **satellite)
504 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
505 g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
507 int ret = LOCATION_ERROR_NONE;
509 #ifndef TIZEN_PROFILE_TV
510 ret = location_check_cynara(LOCATION_PRIVILEGE);
511 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
514 ret = location_ielement_get_last_satellite(LOCATION_IELEMENT(obj), satellite);
515 LOC_IF_FAIL(ret, _E, "Fail to get_last_satellite [%s]", err_msg(ret));
521 location_get_velocity(LocationObject *obj, LocationVelocity **velocity, LocationAccuracy **accuracy)
523 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
524 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
525 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
527 int ret = LOCATION_ERROR_NONE;
529 #ifndef TIZEN_PROFILE_TV
530 ret = location_check_cynara(LOCATION_PRIVILEGE);
531 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
534 ret = location_ielement_get_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
535 LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
541 location_get_last_velocity(LocationObject *obj, LocationVelocity **velocity, LocationAccuracy **accuracy)
543 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
544 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
545 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
547 int ret = LOCATION_ERROR_NONE;
549 #ifndef TIZEN_PROFILE_TV
550 ret = location_check_cynara(LOCATION_PRIVILEGE);
551 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
554 ret = location_ielement_get_last_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
555 LOC_IF_FAIL(ret, _E, "Fail to get_last_velocity [%s]", err_msg(ret));
561 location_get_accessibility_state(LocationAccessState *state)
563 int ret = LOCATION_ERROR_NONE;
565 #ifndef TIZEN_PROFILE_TV
566 ret = location_check_cynara(LOCATION_PRIVILEGE);
569 if (ret == LOCATION_ERROR_NONE) {
570 *state = LOCATION_ACCESS_ALLOWED;
572 *state = LOCATION_ACCESS_DENIED;
573 LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
576 return LOCATION_ERROR_NONE;
580 location_set_accessibility_state(LocationAccessState state)
582 int auth = LOCATION_APP_NOT_FOUND;
583 int ret = LOCATION_ERROR_NONE;
586 case LOCATION_ACCESS_DENIED:
587 auth = LOCATION_APP_OFF;
589 case LOCATION_ACCESS_ALLOWED:
590 auth = LOCATION_APP_ON;
592 case LOCATION_ACCESS_NONE:
594 return LOCATION_ERROR_PARAMETER;
597 ret = location_application_set_authority(auth);
598 LOCATION_LOGD("set_accessibility_state [%d], Error[%d]", auth, ret);
603 location_send_command(const char *cmd)
605 g_return_val_if_fail(cmd, LOCATION_ERROR_PARAMETER);
606 return LOCATION_ERROR_NOT_AVAILABLE;
610 location_set_option(LocationObject *obj, const char *option)
612 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
613 int ret = LOCATION_ERROR_NONE;
615 #ifndef TIZEN_PROFILE_TV
616 ret = location_check_cynara(LOCATION_PRIVILEGE);
617 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
620 ret = location_ielement_set_option(LOCATION_IELEMENT(obj), option);
621 LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
630 location_enable_mock(const int enable)
632 int ret = LOCATION_ERROR_NONE;
634 #ifndef TIZEN_PROFILE_TV
635 ret = location_check_cynara(LOCATION_PRIVILEGE);
636 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
639 #if 0 /* Tizen platform didn't turn developer option on */
640 gboolean developer_option = FALSE;
642 ret = vconf_get_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &developer_option);
643 LOC_COND_RET(!developer_option, LOCATION_ERROR_NOT_ALLOWED, _E, "Cannot enable mock location because developer option is not turned on", ret);
646 ret = vconf_set_int(VCONFKEY_LOCATION_MOCK_ENABLED, enable);
647 if (ret != VCONF_OK) {
648 LOCATION_SECLOG("vconf_set_int failed [MOCK_ENABLED], ret=[%d]", ret);
649 return LOCATION_ERROR_NOT_ALLOWED;
656 location_set_mock_location(LocationObject *obj, const LocationPosition *position, const LocationVelocity *velocity, const LocationAccuracy *accuracy)
658 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
659 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
660 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
661 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
663 int ret = LOCATION_ERROR_NONE;
664 ret = location_ielement_set_mock_location(LOCATION_IELEMENT(obj), position, velocity, accuracy);
665 LOC_IF_FAIL(ret, _E, "Fail to set_mock_location [%s]", err_msg(ret));
671 location_clear_mock_location(LocationObject *obj)
673 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
675 int ret = LOCATION_ERROR_NONE;
676 ret = location_ielement_clear_mock_location(LOCATION_IELEMENT(obj));
677 LOC_IF_FAIL(ret, _E, "Fail to clear_mock_location [%s]", err_msg(ret));
683 location_enable_restriction(const int enable)
685 int ret = LOCATION_ERROR_NONE;
688 #ifndef TIZEN_PROFILE_TV
689 ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
690 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
694 ret = vconf_get_int(VCONFKEY_LOCATION_RESTRICT, &restriction);
695 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to get restriction status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
697 if (restriction == RESTRICT_OFF) {
699 if (location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) {
700 value |= RESTRICT_GPS;
701 ret = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 0);
702 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
705 if (location_setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED)) {
706 value |= RESTRICT_WPS;
707 ret = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 0);
708 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
711 if (location_setting_get_int(VCONFKEY_LOCATION_USE_MY_LOCATION)) {
712 value |= RESTRICT_HYBRID;
713 ret = vconf_set_int(VCONFKEY_LOCATION_USE_MY_LOCATION, 0);
714 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
718 value = RESTRICT_NONE;
720 ret = vconf_set_int(VCONFKEY_LOCATION_RESTRICT, value);
721 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set value. %d [%s]", value, err_msg(LOCATION_ERROR_NOT_ALLOWED));
725 ret = vconf_get_int(VCONFKEY_LOCATION_RESTRICT, &restriction);
726 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to get restriction status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
728 if (restriction > RESTRICT_OFF) {
730 if (restriction & RESTRICT_GPS) {
731 ret = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 1);
732 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
735 if (restriction & RESTRICT_WPS) {
736 ret = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 1);
737 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
740 if (restriction & RESTRICT_HYBRID) {
741 ret = vconf_set_int(VCONFKEY_LOCATION_USE_MY_LOCATION, 1);
742 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
745 ret = vconf_set_int(VCONFKEY_LOCATION_RESTRICT, RESTRICT_OFF);
746 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set value. %d [%s]", RESTRICT_OFF, err_msg(LOCATION_ERROR_NOT_ALLOWED));
750 return LOCATION_ERROR_NONE;