4 * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
28 #include "location-log.h"
29 #include "location-setting.h"
30 #include "location-ielement.h"
31 #include "location-hybrid.h"
32 #include "location-gps.h"
33 #include "location-wps.h"
34 #include "location-passive.h"
35 #include "location-fused.h"
36 #include "location-position.h"
37 #include "module-internal.h"
38 #include "location-common-util.h"
39 #include "location-privacy.h"
41 #define LOCATION_PRIVILEGE "http://tizen.org/privilege/location"
42 #define LOCATION_ENABLE_PRIVILEGE "http://tizen.org/privilege/location.enable"
44 typedef struct _LocationSetting {
45 LocationSettingCb callback;
49 static LocationSetting g_location_setting;
51 static char *__convert_setting_key(LocationMethod method)
55 case LOCATION_METHOD_HYBRID:
56 key = g_strdup(VCONFKEY_LOCATION_USE_MY_LOCATION);
58 case LOCATION_METHOD_GPS:
59 key = g_strdup(VCONFKEY_LOCATION_ENABLED);
61 case LOCATION_METHOD_WPS:
62 key = g_strdup(VCONFKEY_LOCATION_NETWORK_ENABLED);
64 case INTERNAL_METHOD_MOCK:
65 key = g_strdup(VCONFKEY_LOCATION_MOCK_ENABLED);
74 static LocationMethod __convert_method_from_key(const char *key)
76 LocationMethod _method = LOCATION_METHOD_NONE;
77 if (g_strcmp0(key, VCONFKEY_LOCATION_USE_MY_LOCATION) == 0)
78 _method = LOCATION_METHOD_HYBRID;
79 else if (g_strcmp0(key, VCONFKEY_LOCATION_ENABLED) == 0)
80 _method = LOCATION_METHOD_GPS;
81 else if (g_strcmp0(key, VCONFKEY_LOCATION_NETWORK_ENABLED) == 0)
82 _method = LOCATION_METHOD_WPS;
87 static void __location_setting_cb(keynode_t *key, gpointer data)
89 if (key == NULL || data == NULL)
92 LocationSetting *_setting = (LocationSetting *)data;
93 LocationMethod _method = LOCATION_METHOD_NONE;
95 if (_setting->callback) {
96 _method = __convert_method_from_key(vconf_keynode_get_name(key));
97 _setting->callback(_method, location_setting_get_key_val(key), _setting->user_data);
102 int location_init(void)
104 #if !GLIB_CHECK_VERSION(2, 35, 0)
108 #if !GLIB_CHECK_VERSION(2, 31, 0)
109 if (!g_thread_supported()) g_thread_init(NULL);
111 if (FALSE == module_init())
112 return LOCATION_ERROR_NOT_AVAILABLE;
114 return LOCATION_ERROR_NONE;
117 EXPORT_API LocationObject *
118 location_new(LocationMethod method)
120 LocationObject *self = NULL;
121 LOCATION_LOGD("method : %d", method);
124 case LOCATION_METHOD_HYBRID:
125 self = g_object_new(LOCATION_TYPE_HYBRID, NULL);
127 case LOCATION_METHOD_GPS:
128 self = g_object_new(LOCATION_TYPE_GPS, NULL);
130 case LOCATION_METHOD_WPS:
131 self = g_object_new(LOCATION_TYPE_WPS, NULL);
133 case LOCATION_METHOD_PASSIVE:
134 self = g_object_new(LOCATION_TYPE_PASSIVE, NULL);
136 case LOCATION_METHOD_FUSED:
137 self = g_object_new(LOCATION_TYPE_FUSED, NULL);
143 LOC_COND_LOG(!self, _E, "Fail to create location object. [method=%d]", method);
148 location_free(LocationObject *obj)
150 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
152 return LOCATION_ERROR_NONE;
156 location_request_single_location(LocationObject *obj, int timeout)
158 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
160 int ret = location_check_cynara(LOCATION_PRIVILEGE);
161 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
163 ret = location_ielement_request_single_location(LOCATION_IELEMENT(obj), timeout);
164 LOC_IF_FAIL(ret, _E, "Fail to request single location [%s]", err_msg(ret));
170 location_cancel_single_location(LocationObject *obj)
172 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
174 int ret = location_check_cynara(LOCATION_PRIVILEGE);
175 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
177 ret = location_ielement_cancel_single_location(LOCATION_IELEMENT(obj));
178 if (ret != LOCATION_ERROR_NONE)
179 LOCATION_LOGE("Fail to cancel single location. Error [%d]", ret);
185 location_start(LocationObject *obj)
187 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
189 int ret = location_check_cynara(LOCATION_PRIVILEGE);
190 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
192 ret = location_ielement_start(LOCATION_IELEMENT(obj));
193 LOC_IF_FAIL(ret, _E, "Fail to start [%s]", err_msg(ret));
199 location_stop(LocationObject *obj)
201 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
203 int ret = LOCATION_ERROR_NONE;
204 ret = location_ielement_stop(LOCATION_IELEMENT(obj));
205 LOC_IF_FAIL(ret, _E, "Fail to stop [%s]", err_msg(ret));
211 location_start_batch(LocationObject *obj)
213 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
215 int ret = location_check_cynara(LOCATION_PRIVILEGE);
216 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
218 ret = location_ielement_start_batch(LOCATION_IELEMENT(obj));
219 LOC_IF_FAIL(ret, _E, "Fail to start_batch [%s]", err_msg(ret));
225 location_stop_batch(LocationObject *obj)
227 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
228 int ret = LOCATION_ERROR_NONE;
229 ret = location_ielement_stop_batch(LOCATION_IELEMENT(obj));
230 LOC_IF_FAIL(ret, _E, "Fail to stop_batch [%s]", err_msg(ret));
236 location_is_supported_method(LocationMethod method)
238 gboolean is_supported = FALSE;
241 case LOCATION_METHOD_HYBRID:
242 if (module_is_supported("gps") || module_is_supported("wps"))
245 case LOCATION_METHOD_GPS:
246 is_supported = module_is_supported("gps");
248 case LOCATION_METHOD_WPS:
249 is_supported = module_is_supported("wps");
251 case LOCATION_METHOD_PASSIVE:
252 is_supported = module_is_supported("passive");
254 case LOCATION_METHOD_FUSED:
255 is_supported = module_is_supported("fused");
265 location_is_enabled_method(LocationMethod method, int *is_enabled)
267 g_return_val_if_fail(is_enabled, LOCATION_ERROR_PARAMETER);
269 int vconf_ret = VCONF_ERROR;
271 char *_key = __convert_setting_key(method);
272 LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
274 vconf_ret = vconf_get_int(_key, &vconf_val);
275 if (vconf_ret != VCONF_OK) {
276 LOCATION_SECLOG("vconf_get failed [%s], error [%d]", _key, vconf_ret);
278 return LOCATION_ERROR_NOT_AVAILABLE;
280 LOCATION_SECLOG("[%s]:[%d]", _key, vconf_val);
283 *is_enabled = vconf_val;
286 return LOCATION_ERROR_NONE;
290 location_enable_method(const LocationMethod method, const int enable)
294 int ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
295 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
297 if (location_setting_get_int(VCONFKEY_LOCATION_RESTRICT) > RESTRICT_OFF) {
298 LOCATION_SECLOG("Location setting is denied by DPM");
299 return LOCATION_ERROR_NOT_ALLOWED;
303 _key = __convert_setting_key(method);
304 LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
306 ret = vconf_set_int(_key, enable);
307 if (ret != VCONF_OK) {
308 LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
310 return LOCATION_ERROR_NOT_ALLOWED;
315 _key = __convert_setting_key(LOCATION_METHOD_HYBRID);
316 LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", LOCATION_METHOD_HYBRID, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
319 ret = vconf_set_int(_key, enable);
320 if (ret != VCONF_OK) {
321 LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
323 return LOCATION_ERROR_NOT_ALLOWED;
327 int enabled_state = 0;
329 for (i = LOCATION_METHOD_GPS; i < LOCATION_METHOD_MAX; i++) {
330 _key = __convert_setting_key(i);
331 enabled_state |= location_setting_get_int(_key);
334 if (!enabled_state) {
335 _key = __convert_setting_key(LOCATION_METHOD_HYBRID);
336 ret = vconf_set_int(_key, enable);
337 if (ret != VCONF_OK) {
338 LOCATION_SECLOG("vconf_set_int failed [%s], error [%d]", _key, ret);
340 return LOCATION_ERROR_NOT_ALLOWED;
342 LOCATION_SECLOG("[%s]:[%d]", _key, ret);
352 location_add_setting_notify(LocationMethod method, LocationSettingCb callback, void *user_data)
354 int ret = LOCATION_ERROR_NONE;
355 char *_key = __convert_setting_key(method);
356 LOC_COND_RET(!_key, LOCATION_ERROR_PARAMETER, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_PARAMETER));
358 g_location_setting.callback = callback;
359 g_location_setting.user_data = user_data;
361 ret = location_setting_add_notify(_key, __location_setting_cb, &g_location_setting);
368 location_ignore_setting_notify(LocationMethod method, LocationSettingCb callback)
370 int ret = LOCATION_ERROR_NONE;
371 char *_key = __convert_setting_key(method);
372 LOC_COND_RET(!_key, LOCATION_ERROR_PARAMETER, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_PARAMETER));
374 g_location_setting.callback = NULL;
375 g_location_setting.user_data = NULL;
377 ret = location_setting_ignore_notify(_key, __location_setting_cb);
385 location_get_position(LocationObject *obj, LocationPosition **position, LocationAccuracy **accuracy)
387 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
388 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
389 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
391 int ret = location_check_cynara(LOCATION_PRIVILEGE);
392 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
394 ret = location_ielement_get_position(LOCATION_IELEMENT(obj), position, accuracy);
395 LOC_COND_RET(ret != LOCATION_ERROR_NONE, ret, _E, "Fail to get_position [%s]", err_msg(ret));
401 location_get_position_ext(LocationObject *obj, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
403 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
404 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
405 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
406 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
408 int ret = location_check_cynara(LOCATION_PRIVILEGE);
409 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
411 ret = location_ielement_get_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
412 LOC_IF_FAIL(ret, _E, "Fail to get_position_ext [%s]", err_msg(ret));
418 location_get_last_position(LocationObject *obj, LocationPosition **position, LocationAccuracy **accuracy)
420 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
421 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
422 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
424 int ret = location_check_cynara(LOCATION_PRIVILEGE);
425 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
427 ret = location_ielement_get_last_position(LOCATION_IELEMENT(obj), position, accuracy);
428 LOC_IF_FAIL(ret, _E, "Fail to get_last_position [%s]", err_msg(ret));
434 location_get_last_position_ext(LocationObject *obj, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
436 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
437 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
438 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
439 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
441 int ret = location_check_cynara(LOCATION_PRIVILEGE);
442 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
444 ret = location_ielement_get_last_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
445 LOC_IF_FAIL(ret, _E, "Fail to get_last_position_ext [%s]", err_msg(ret));
451 location_get_nmea(LocationObject *obj, char **nmea)
453 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
454 g_return_val_if_fail(nmea, LOCATION_ERROR_PARAMETER);
456 int ret = LOCATION_ERROR_NONE;
457 ret = location_ielement_get_nmea(LOCATION_IELEMENT(obj), nmea);
458 LOC_IF_FAIL(ret, _E, "Fail to get_nmea [%s]", err_msg(ret));
465 location_get_satellite(LocationObject *obj, LocationSatellite **satellite)
467 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
468 g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
470 int ret = location_check_cynara(LOCATION_PRIVILEGE);
471 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
473 ret = location_ielement_get_satellite(LOCATION_IELEMENT(obj), satellite);
474 LOC_IF_FAIL(ret, _E, "Fail to get_satellite [%s]", err_msg(ret));
480 location_get_batch(LocationObject *obj, LocationBatch **batch)
482 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
483 g_return_val_if_fail(batch, LOCATION_ERROR_PARAMETER);
485 int ret = location_check_cynara(LOCATION_PRIVILEGE);
486 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
488 ret = location_ielement_get_batch(LOCATION_IELEMENT(obj), batch);
489 LOC_IF_FAIL(ret, _E, "Fail to get_batch [%s]", err_msg(ret));
495 location_get_last_satellite(LocationObject *obj, LocationSatellite **satellite)
497 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
498 g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
500 int ret = location_check_cynara(LOCATION_PRIVILEGE);
501 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
503 ret = location_ielement_get_last_satellite(LOCATION_IELEMENT(obj), satellite);
504 LOC_IF_FAIL(ret, _E, "Fail to get_last_satellite [%s]", err_msg(ret));
510 location_get_velocity(LocationObject *obj, LocationVelocity **velocity, LocationAccuracy **accuracy)
512 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
513 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
514 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
516 int ret = location_check_cynara(LOCATION_PRIVILEGE);
517 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
519 ret = location_ielement_get_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
520 LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
526 location_get_last_velocity(LocationObject *obj, LocationVelocity **velocity, LocationAccuracy **accuracy)
528 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
529 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
530 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
532 int ret = location_check_cynara(LOCATION_PRIVILEGE);
533 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
535 ret = location_ielement_get_last_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
536 LOC_IF_FAIL(ret, _E, "Fail to get_last_velocity [%s]", err_msg(ret));
542 location_get_accessibility_state(LocationAccessState *state)
544 int ret = location_check_cynara(LOCATION_PRIVILEGE);
546 if (ret == LOCATION_ERROR_NONE) {
547 *state = LOCATION_ACCESS_ALLOWED;
549 *state = LOCATION_ACCESS_DENIED;
550 LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
553 return LOCATION_ERROR_NONE;
557 location_set_accessibility_state(LocationAccessState state)
559 int auth = LOCATION_APP_NOT_FOUND;
560 int ret = LOCATION_ERROR_NONE;
563 case LOCATION_ACCESS_DENIED:
564 auth = LOCATION_APP_OFF;
566 case LOCATION_ACCESS_ALLOWED:
567 auth = LOCATION_APP_ON;
569 case LOCATION_ACCESS_NONE:
571 return LOCATION_ERROR_PARAMETER;
574 ret = location_application_set_authority(auth);
575 LOCATION_LOGD("set_accessibility_state [%d], Error[%d]", auth, ret);
580 location_send_command(const char *cmd)
582 g_return_val_if_fail(cmd, LOCATION_ERROR_PARAMETER);
583 return LOCATION_ERROR_NOT_AVAILABLE;
587 location_set_option(LocationObject *obj, const char *option)
589 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
591 int ret = location_check_cynara(LOCATION_PRIVILEGE);
592 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
594 ret = location_ielement_set_option(LOCATION_IELEMENT(obj), option);
595 LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
604 location_enable_mock(const int enable)
606 int ret = location_check_cynara(LOCATION_PRIVILEGE);
607 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
609 #if 0 /* Tizen platform didn't turn developer option on */
610 gboolean developer_option = FALSE;
612 ret = vconf_get_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &developer_option);
613 LOC_COND_RET(!developer_option, LOCATION_ERROR_NOT_ALLOWED, _E, "Cannot enable mock location because developer option is not turned on", ret);
616 ret = vconf_set_int(VCONFKEY_LOCATION_MOCK_ENABLED, enable);
617 if (ret != VCONF_OK) {
618 LOCATION_SECLOG("vconf_set_int failed [MOCK_ENABLED], ret=[%d]", ret);
619 return LOCATION_ERROR_NOT_ALLOWED;
626 location_set_mock_location(LocationObject *obj, const LocationPosition *position, const LocationVelocity *velocity, const LocationAccuracy *accuracy)
628 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
629 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
630 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
631 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
633 int ret = location_check_cynara(LOCATION_PRIVILEGE);
634 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
636 ret = location_ielement_set_mock_location(LOCATION_IELEMENT(obj), position, velocity, accuracy);
637 LOC_IF_FAIL(ret, _E, "Fail to set_mock_location [%s]", err_msg(ret));
643 location_clear_mock_location(LocationObject *obj)
645 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
647 int ret = location_check_cynara(LOCATION_PRIVILEGE);
648 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
650 ret = location_ielement_clear_mock_location(LOCATION_IELEMENT(obj));
651 LOC_IF_FAIL(ret, _E, "Fail to clear_mock_location [%s]", err_msg(ret));
657 location_set_fused_mode(LocationObject *obj, LocationFusedMode mode)
659 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
661 int ret = LOCATION_ERROR_NONE;
662 ret = location_ielement_set_fused_mode(LOCATION_IELEMENT(obj), mode);
663 LOC_IF_FAIL(ret, _E, "Fail to set_fused_mode [%s]", err_msg(ret));
669 location_enable_restriction(const int enable)
672 int ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
673 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
677 ret = vconf_get_int(VCONFKEY_LOCATION_RESTRICT, &restriction);
678 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to get restriction status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
680 if (restriction == RESTRICT_OFF) {
682 if (location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) {
683 value |= RESTRICT_GPS;
684 ret = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 0);
685 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
688 if (location_setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED)) {
689 value |= RESTRICT_WPS;
690 ret = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 0);
691 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
694 if (location_setting_get_int(VCONFKEY_LOCATION_USE_MY_LOCATION)) {
695 value |= RESTRICT_HYBRID;
696 ret = vconf_set_int(VCONFKEY_LOCATION_USE_MY_LOCATION, 0);
697 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
701 value = RESTRICT_NONE;
703 ret = vconf_set_int(VCONFKEY_LOCATION_RESTRICT, value);
704 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set value. %d [%s]", value, err_msg(LOCATION_ERROR_NOT_ALLOWED));
708 ret = vconf_get_int(VCONFKEY_LOCATION_RESTRICT, &restriction);
709 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to get restriction status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
711 if (restriction > RESTRICT_OFF) {
713 if (restriction & RESTRICT_GPS) {
714 ret = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 1);
715 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
718 if (restriction & RESTRICT_WPS) {
719 ret = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 1);
720 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
723 if (restriction & RESTRICT_HYBRID) {
724 ret = vconf_set_int(VCONFKEY_LOCATION_USE_MY_LOCATION, 1);
725 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
728 ret = vconf_set_int(VCONFKEY_LOCATION_RESTRICT, RESTRICT_OFF);
729 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));
733 return LOCATION_ERROR_NONE;