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-passive.h"
38 #include "location-position.h"
39 #include "module-internal.h"
40 #include "location-common-util.h"
41 #include "location-privacy.h"
43 #define LOCATION_PRIVILEGE "http://tizen.org/privilege/location"
44 #define LOCATION_ENABLE_PRIVILEGE "http://tizen.org/privilege/location.enable"
46 typedef struct _LocationSetting {
47 LocationSettingCb callback;
60 static LocationSetting g_location_setting;
61 static bool is_method_created[_METHOD_MAX] = {false};
63 static char *__convert_setting_key(LocationMethod method)
67 case LOCATION_METHOD_HYBRID:
68 key = g_strdup(VCONFKEY_LOCATION_USE_MY_LOCATION);
70 case LOCATION_METHOD_GPS:
71 key = g_strdup(VCONFKEY_LOCATION_ENABLED);
73 case LOCATION_METHOD_WPS:
74 key = g_strdup(VCONFKEY_LOCATION_NETWORK_ENABLED);
76 case INTERNAL_METHOD_MOCK:
77 key = g_strdup(VCONFKEY_LOCATION_MOCK_ENABLED);
86 static LocationMethod __convert_method_from_key(const char *key)
88 LocationMethod _method = LOCATION_METHOD_NONE;
89 if (g_strcmp0(key, VCONFKEY_LOCATION_USE_MY_LOCATION) == 0)
90 _method = LOCATION_METHOD_HYBRID;
91 else if (g_strcmp0(key, VCONFKEY_LOCATION_ENABLED) == 0)
92 _method = LOCATION_METHOD_GPS;
93 else if (g_strcmp0(key, VCONFKEY_LOCATION_NETWORK_ENABLED) == 0)
94 _method = LOCATION_METHOD_WPS;
99 static void __location_setting_cb(keynode_t *key, gpointer data)
101 if (key == NULL || data == NULL)
104 LocationSetting *_setting = (LocationSetting *)data;
105 LocationMethod _method = LOCATION_METHOD_NONE;
107 if (_setting->callback) {
108 _method = __convert_method_from_key(vconf_keynode_get_name(key));
109 _setting->callback(_method, location_setting_get_key_val(key), _setting->user_data);
114 int location_init(void)
116 #if !GLIB_CHECK_VERSION(2, 35, 0)
120 #if !GLIB_CHECK_VERSION(2, 31, 0)
121 if (!g_thread_supported()) g_thread_init(NULL);
123 if (FALSE == module_init())
124 return LOCATION_ERROR_NOT_AVAILABLE;
126 return LOCATION_ERROR_NONE;
129 EXPORT_API LocationObject *
130 location_new(LocationMethod method, gboolean is_internal_for_hybrid)
132 LocationObject *self = NULL;
133 LOCATION_LOGD("method : %d, is_internal_for_hybrid[%d]", method, is_internal_for_hybrid);
136 case LOCATION_METHOD_HYBRID:
137 if (is_method_created[_METHOD_HYBRID]) {
138 LOCATION_LOGE("Hybrid handle already exist.");
140 self = g_object_new(LOCATION_TYPE_HYBRID, NULL);
141 is_method_created[_METHOD_HYBRID] = true;
144 case LOCATION_METHOD_GPS:
145 if (is_internal_for_hybrid) {
146 if (is_method_created[_METHOD_GPS_2]) {
147 LOCATION_LOGD("Hybrid(GPS) handle already exist.");
149 is_method_created[_METHOD_GPS_2] = true;
150 self = g_object_new(LOCATION_TYPE_GPS, NULL);
153 if (is_method_created[_METHOD_GPS_1]) {
154 LOCATION_LOGE("GPS handle already exist.");
156 is_method_created[_METHOD_GPS_1] = true;
157 self = g_object_new(LOCATION_TYPE_GPS, NULL);
161 case LOCATION_METHOD_WPS:
162 if (is_internal_for_hybrid) {
163 if (is_method_created[_METHOD_WPS_2]) {
164 LOCATION_LOGD("Hybrid(WPS) handle already exist.");
166 is_method_created[_METHOD_WPS_2] = true;
167 self = g_object_new(LOCATION_TYPE_WPS, NULL);
170 if (is_method_created[_METHOD_WPS_1]) {
171 LOCATION_LOGE("WPS handle already exist.");
173 is_method_created[_METHOD_WPS_1] = true;
174 self = g_object_new(LOCATION_TYPE_WPS, NULL);
178 case LOCATION_METHOD_PASSIVE:
179 self = g_object_new(LOCATION_TYPE_PASSIVE, NULL);
185 LOC_COND_LOG(!self, _E, "Fail to create location object. [method=%d]", method);
190 location_free(LocationObject *obj, gboolean is_internal_for_hybrid)
192 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
193 if (G_OBJECT_TYPE(obj) == LOCATION_TYPE_HYBRID) {
194 is_method_created[_METHOD_HYBRID] = false;
195 } else if (G_OBJECT_TYPE(obj) == LOCATION_TYPE_GPS) {
196 if (is_internal_for_hybrid)
197 is_method_created[_METHOD_GPS_2] = false;
199 is_method_created[_METHOD_GPS_1] = false;
200 } else if (G_OBJECT_TYPE(obj) == LOCATION_TYPE_WPS) {
201 if (is_internal_for_hybrid)
202 is_method_created[_METHOD_WPS_2] = false;
204 is_method_created[_METHOD_WPS_1] = false;
207 return LOCATION_ERROR_NONE;
211 location_request_single_location(LocationObject *obj, int timeout)
213 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
215 int ret = LOCATION_ERROR_NONE;
216 ret = location_ielement_request_single_location(LOCATION_IELEMENT(obj), timeout);
217 LOC_IF_FAIL(ret, _E, "Fail to request single location [%s]", err_msg(ret));
223 location_start(LocationObject *obj)
225 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
227 int ret = LOCATION_ERROR_NONE;
228 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
229 ret = location_check_cynara(LOCATION_PRIVILEGE);
230 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
233 ret = location_ielement_start(LOCATION_IELEMENT(obj));
234 LOC_IF_FAIL(ret, _E, "Fail to start [%s]", err_msg(ret));
240 location_stop(LocationObject *obj)
242 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
244 int ret = LOCATION_ERROR_NONE;
245 ret = location_ielement_stop(LOCATION_IELEMENT(obj));
246 LOC_IF_FAIL(ret, _E, "Fail to stop [%s]", err_msg(ret));
252 location_start_batch(LocationObject *obj)
254 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
255 int ret = LOCATION_ERROR_NONE;
257 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
258 ret = location_check_cynara(LOCATION_PRIVILEGE);
259 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
262 ret = location_ielement_start_batch(LOCATION_IELEMENT(obj));
263 LOC_IF_FAIL(ret, _E, "Fail to start_batch [%s]", err_msg(ret));
269 location_stop_batch(LocationObject *obj)
271 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
272 int ret = LOCATION_ERROR_NONE;
273 ret = location_ielement_stop_batch(LOCATION_IELEMENT(obj));
274 LOC_IF_FAIL(ret, _E, "Fail to stop_batch [%d]", err_msg(ret));
280 location_is_supported_method(LocationMethod method)
282 gboolean is_supported = FALSE;
285 case LOCATION_METHOD_HYBRID:
286 if (module_is_supported("gps") || module_is_supported("wps"))
289 case LOCATION_METHOD_GPS:
290 is_supported = module_is_supported("gps");
292 case LOCATION_METHOD_WPS:
293 is_supported = module_is_supported("wps");
295 case LOCATION_METHOD_PASSIVE:
296 is_supported = module_is_supported("passive");
306 location_is_enabled_method(LocationMethod method, int *is_enabled)
308 g_return_val_if_fail(is_enabled, LOCATION_ERROR_PARAMETER);
310 int vconf_ret = VCONF_ERROR;
312 char *_key = __convert_setting_key(method);
313 LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
315 vconf_ret = vconf_get_int(_key, &vconf_val);
316 if (vconf_ret != VCONF_OK) {
317 LOCATION_SECLOG("vconf_get failed [%s], error [%d]", _key, vconf_ret);
319 return LOCATION_ERROR_NOT_AVAILABLE;
321 LOCATION_SECLOG("[%s]:[%d]", _key, vconf_val);
324 *is_enabled = vconf_val;
327 return LOCATION_ERROR_NONE;
331 location_enable_method(const LocationMethod method, const int enable)
336 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
337 ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
338 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
341 if (location_setting_get_int(VCONFKEY_LOCATION_RESTRICT) > RESTRICT_OFF) {
342 LOCATION_SECLOG("Location setting is denied by DPM");
343 return LOCATION_ERROR_NOT_ALLOWED;
347 _key = __convert_setting_key(method);
348 LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
350 ret = vconf_set_int(_key, enable);
351 if (ret != VCONF_OK) {
352 LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
354 return LOCATION_ERROR_NOT_ALLOWED;
359 _key = __convert_setting_key(LOCATION_METHOD_HYBRID);
360 LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", LOCATION_METHOD_HYBRID, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
363 ret = vconf_set_int(_key, enable);
364 if (ret != VCONF_OK) {
365 LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
367 return LOCATION_ERROR_NOT_ALLOWED;
371 int enabled_state = 0;
373 for (i = LOCATION_METHOD_GPS; i < LOCATION_METHOD_MAX; i++) {
374 _key = __convert_setting_key(i);
375 enabled_state |= location_setting_get_int(_key);
378 if (!enabled_state) {
379 _key = __convert_setting_key(LOCATION_METHOD_HYBRID);
380 ret = vconf_set_int(_key, enable);
381 if (ret != VCONF_OK) {
382 LOCATION_SECLOG("vconf_set_int failed [%s], error [%d]", _key, ret);
384 return LOCATION_ERROR_NOT_ALLOWED;
386 LOCATION_SECLOG("[%s]:[%d]", _key, ret);
396 location_add_setting_notify(LocationMethod method, LocationSettingCb callback, void *user_data)
398 int ret = LOCATION_ERROR_NONE;
399 char *_key = __convert_setting_key(method);
400 LOC_COND_RET(!_key, LOCATION_ERROR_PARAMETER, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_PARAMETER));
402 g_location_setting.callback = callback;
403 g_location_setting.user_data = user_data;
405 ret = location_setting_add_notify(_key, __location_setting_cb, &g_location_setting);
412 location_ignore_setting_notify(LocationMethod method, LocationSettingCb callback)
414 int ret = LOCATION_ERROR_NONE;
415 char *_key = __convert_setting_key(method);
416 LOC_COND_RET(!_key, LOCATION_ERROR_PARAMETER, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_PARAMETER));
418 g_location_setting.callback = NULL;
419 g_location_setting.user_data = NULL;
421 ret = location_setting_ignore_notify(_key, __location_setting_cb);
429 location_get_position(LocationObject *obj, LocationPosition **position, 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(accuracy, LOCATION_ERROR_PARAMETER);
435 int ret = LOCATION_ERROR_NONE;
437 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
438 ret = location_check_cynara(LOCATION_PRIVILEGE);
439 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
442 ret = location_ielement_get_position(LOCATION_IELEMENT(obj), position, accuracy);
443 LOC_COND_RET(ret != LOCATION_ERROR_NONE, ret, _E, "Fail to get_position [%s]", err_msg(ret));
449 location_get_position_ext(LocationObject *obj, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
451 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
452 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
453 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
454 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
456 int ret = LOCATION_ERROR_NONE;
458 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
459 ret = location_check_cynara(LOCATION_PRIVILEGE);
460 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
463 ret = location_ielement_get_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
464 LOC_IF_FAIL(ret, _E, "Fail to get_position_ext [%s]", err_msg(ret));
470 location_get_last_position(LocationObject *obj, LocationPosition **position, LocationAccuracy **accuracy)
472 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
473 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
474 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
476 int ret = LOCATION_ERROR_NONE;
478 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
479 ret = location_check_cynara(LOCATION_PRIVILEGE);
480 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
483 ret = location_ielement_get_last_position(LOCATION_IELEMENT(obj), position, accuracy);
484 LOC_IF_FAIL(ret, _E, "Fail to get_last_position [%s]", err_msg(ret));
490 location_get_last_position_ext(LocationObject *obj, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
492 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
493 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
494 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
495 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
497 int ret = LOCATION_ERROR_NONE;
499 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
500 ret = location_check_cynara(LOCATION_PRIVILEGE);
501 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
504 ret = location_ielement_get_last_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
505 LOC_IF_FAIL(ret, _E, "Fail to get_last_position_ext [%s]", err_msg(ret));
511 location_get_nmea(LocationObject *obj, char **nmea)
513 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
514 g_return_val_if_fail(nmea, LOCATION_ERROR_PARAMETER);
516 int ret = LOCATION_ERROR_NONE;
517 ret = location_ielement_get_nmea(LOCATION_IELEMENT(obj), nmea);
518 LOC_IF_FAIL(ret, _E, "Fail to get_nmea [%s]", err_msg(ret));
525 location_get_satellite(LocationObject *obj, LocationSatellite **satellite)
527 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
528 g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
530 int ret = LOCATION_ERROR_NONE;
532 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
533 ret = location_check_cynara(LOCATION_PRIVILEGE);
534 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
537 ret = location_ielement_get_satellite(LOCATION_IELEMENT(obj), satellite);
538 LOC_IF_FAIL(ret, _E, "Fail to get_satellite [%s]", err_msg(ret));
544 location_get_batch(LocationObject *obj, LocationBatch **batch)
546 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
547 g_return_val_if_fail(batch, LOCATION_ERROR_PARAMETER);
549 int ret = LOCATION_ERROR_NONE;
551 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
552 ret = location_check_cynara(LOCATION_PRIVILEGE);
553 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
556 ret = location_ielement_get_batch(LOCATION_IELEMENT(obj), batch);
557 LOC_IF_FAIL(ret, _E, "Fail to get_batch [%s]", err_msg(ret));
563 location_get_last_satellite(LocationObject *obj, LocationSatellite **satellite)
565 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
566 g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
568 int ret = LOCATION_ERROR_NONE;
570 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
571 ret = location_check_cynara(LOCATION_PRIVILEGE);
572 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
575 ret = location_ielement_get_last_satellite(LOCATION_IELEMENT(obj), satellite);
576 LOC_IF_FAIL(ret, _E, "Fail to get_last_satellite [%s]", err_msg(ret));
582 location_get_velocity(LocationObject *obj, LocationVelocity **velocity, LocationAccuracy **accuracy)
584 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
585 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
586 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
588 int ret = LOCATION_ERROR_NONE;
590 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
591 ret = location_check_cynara(LOCATION_PRIVILEGE);
592 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
595 ret = location_ielement_get_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
596 LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
602 location_get_last_velocity(LocationObject *obj, LocationVelocity **velocity, LocationAccuracy **accuracy)
604 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
605 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
606 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
608 int ret = LOCATION_ERROR_NONE;
610 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
611 ret = location_check_cynara(LOCATION_PRIVILEGE);
612 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
615 ret = location_ielement_get_last_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
616 LOC_IF_FAIL(ret, _E, "Fail to get_last_velocity [%s]", err_msg(ret));
622 location_get_accessibility_state(LocationAccessState *state)
624 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
625 int ret = location_check_cynara(LOCATION_PRIVILEGE);
627 if (ret == LOCATION_ERROR_NONE) {
628 *state = LOCATION_ACCESS_ALLOWED;
630 *state = LOCATION_ACCESS_DENIED;
631 LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
634 *state = LOCATION_ACCESS_ALLOWED;
637 return LOCATION_ERROR_NONE;
641 location_set_accessibility_state(LocationAccessState state)
643 int auth = LOCATION_APP_NOT_FOUND;
644 int ret = LOCATION_ERROR_NONE;
647 case LOCATION_ACCESS_DENIED:
648 auth = LOCATION_APP_OFF;
650 case LOCATION_ACCESS_ALLOWED:
651 auth = LOCATION_APP_ON;
653 case LOCATION_ACCESS_NONE:
655 return LOCATION_ERROR_PARAMETER;
658 ret = location_application_set_authority(auth);
659 LOCATION_LOGD("set_accessibility_state [%d], Error[%d]", auth, ret);
664 location_send_command(const char *cmd)
666 g_return_val_if_fail(cmd, LOCATION_ERROR_PARAMETER);
667 return LOCATION_ERROR_NOT_AVAILABLE;
671 location_set_option(LocationObject *obj, const char *option)
673 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
674 int ret = LOCATION_ERROR_NONE;
676 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
677 ret = location_check_cynara(LOCATION_PRIVILEGE);
678 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
681 ret = location_ielement_set_option(LOCATION_IELEMENT(obj), option);
682 LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
691 location_enable_mock(const int enable)
693 int ret = LOCATION_ERROR_NONE;
695 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
696 ret = location_check_cynara(LOCATION_PRIVILEGE);
697 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
700 #if 0 /* Tizen platform didn't turn developer option on */
701 gboolean developer_option = FALSE;
703 ret = vconf_get_bool(VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, &developer_option);
704 LOC_COND_RET(!developer_option, LOCATION_ERROR_NOT_ALLOWED, _E, "Cannot enable mock location because developer option is not turned on", ret);
707 ret = vconf_set_int(VCONFKEY_LOCATION_MOCK_ENABLED, enable);
708 if (ret != VCONF_OK) {
709 LOCATION_SECLOG("vconf_set_int failed [MOCK_ENABLED], ret=[%d]", ret);
710 return LOCATION_ERROR_NOT_ALLOWED;
717 location_set_mock_location(LocationObject *obj, const LocationPosition *position, const LocationVelocity *velocity, const LocationAccuracy *accuracy)
719 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
720 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
721 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
722 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
724 int ret = LOCATION_ERROR_NONE;
725 ret = location_ielement_set_mock_location(LOCATION_IELEMENT(obj), position, velocity, accuracy);
726 LOC_IF_FAIL(ret, _E, "Fail to set_mock_location [%s]", err_msg(ret));
732 location_clear_mock_location(LocationObject *obj)
734 g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
736 int ret = LOCATION_ERROR_NONE;
737 ret = location_ielement_clear_mock_location(LOCATION_IELEMENT(obj));
738 LOC_IF_FAIL(ret, _E, "Fail to clear_mock_location [%s]", err_msg(ret));
744 location_enable_restriction(const int enable)
746 int ret = LOCATION_ERROR_NONE;
749 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
750 ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
751 LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
755 ret = vconf_get_int(VCONFKEY_LOCATION_RESTRICT, &restriction);
756 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to get restriction status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
758 if (restriction == RESTRICT_OFF) {
760 if (location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) {
761 value |= RESTRICT_GPS;
762 ret = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 0);
763 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
766 if (location_setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED)) {
767 value |= RESTRICT_WPS;
768 ret = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 0);
769 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
772 if (location_setting_get_int(VCONFKEY_LOCATION_USE_MY_LOCATION)) {
773 value |= RESTRICT_HYBRID;
774 ret = vconf_set_int(VCONFKEY_LOCATION_USE_MY_LOCATION, 0);
775 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
779 value = RESTRICT_NONE;
781 ret = vconf_set_int(VCONFKEY_LOCATION_RESTRICT, value);
782 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set value. %d [%s]", value, err_msg(LOCATION_ERROR_NOT_ALLOWED));
786 ret = vconf_get_int(VCONFKEY_LOCATION_RESTRICT, &restriction);
787 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to get restriction status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
789 if (restriction > RESTRICT_OFF) {
791 if (restriction & RESTRICT_GPS) {
792 ret = vconf_set_int(VCONFKEY_LOCATION_ENABLED, 1);
793 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
796 if (restriction & RESTRICT_WPS) {
797 ret = vconf_set_int(VCONFKEY_LOCATION_NETWORK_ENABLED, 1);
798 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
801 if (restriction & RESTRICT_HYBRID) {
802 ret = vconf_set_int(VCONFKEY_LOCATION_USE_MY_LOCATION, 1);
803 LOC_COND_RET(ret != VCONF_OK, LOCATION_ERROR_NOT_ALLOWED, _E, "Fail to set status [%s]", err_msg(LOCATION_ERROR_NOT_ALLOWED));
806 ret = vconf_set_int(VCONFKEY_LOCATION_RESTRICT, RESTRICT_OFF);
807 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));
811 return LOCATION_ERROR_NONE;