*
* Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
- * Genie Kim <daejins.kim@samsung.com>
- *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
#include <glib.h>
#include <stdio.h>
-#include <pthread.h>
#include <vconf.h>
#include "location.h"
#include "location-hybrid.h"
#include "location-gps.h"
#include "location-wps.h"
-#include "location-mock.h"
+#include "location-passive.h"
#include "location-position.h"
#include "module-internal.h"
#include "location-common-util.h"
-#ifndef TIZEN_PROFILE_TV
#include "location-privacy.h"
-#endif
-#define LOCATION_PRIVILEGE "http://tizen.org/privilege/location"
+#define LOCATION_PRIVILEGE "http://tizen.org/privilege/location"
#define LOCATION_ENABLE_PRIVILEGE "http://tizen.org/privilege/location.enable"
typedef struct _LocationSetting {
case LOCATION_METHOD_WPS:
key = g_strdup(VCONFKEY_LOCATION_NETWORK_ENABLED);
break;
- case LOCATION_METHOD_MOCK:
+ case INTERNAL_METHOD_MOCK:
key = g_strdup(VCONFKEY_LOCATION_MOCK_ENABLED);
break;
default:
_method = LOCATION_METHOD_GPS;
else if (g_strcmp0(key, VCONFKEY_LOCATION_NETWORK_ENABLED) == 0)
_method = LOCATION_METHOD_WPS;
- else if (g_strcmp0(key, VCONFKEY_LOCATION_MOCK_ENABLED) == 0)
- _method = LOCATION_METHOD_MOCK;
return _method;
}
}
EXPORT_API LocationObject *
-location_new(LocationMethod method)
+location_new(LocationMethod method, gboolean multi_handle)
{
LocationObject *self = NULL;
- LOCATION_LOGD("method: %d", method);
+ LOCATION_LOGD("method : %d, multi_handle[%d]", method, multi_handle);
switch (method) {
case LOCATION_METHOD_HYBRID:
case LOCATION_METHOD_WPS:
self = g_object_new(LOCATION_TYPE_WPS, NULL);
break;
- case LOCATION_METHOD_MOCK:
- self = g_object_new(LOCATION_TYPE_MOCK, NULL);
+ case LOCATION_METHOD_PASSIVE:
+ self = g_object_new(LOCATION_TYPE_PASSIVE, NULL);
+ break;
default:
break;
}
}
EXPORT_API int
-location_free(LocationObject *obj)
+location_free(LocationObject *obj, gboolean multi_handle)
{
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
g_object_unref(obj);
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_request_single_location(LOCATION_IELEMENT(obj), timeout);
LOC_IF_FAIL(ret, _E, "Fail to request single location [%s]", err_msg(ret));
}
EXPORT_API int
+location_cancel_single_location(LocationObject *obj)
+{
+ g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
+
+ int ret = LOCATION_ERROR_NONE;
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
+
+ ret = location_ielement_cancel_single_location(LOCATION_IELEMENT(obj));
+ if (ret != LOCATION_ERROR_NONE)
+ LOCATION_LOGE("Fail to cancel single location. Error [%d]", ret);
+
+ return ret;
+}
+
+EXPORT_API int
location_start(LocationObject *obj)
{
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_start(LOCATION_IELEMENT(obj));
LOC_IF_FAIL(ret, _E, "Fail to start [%s]", err_msg(ret));
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_start_batch(LOCATION_IELEMENT(obj));
LOC_IF_FAIL(ret, _E, "Fail to start_batch [%s]", err_msg(ret));
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
ret = location_ielement_stop_batch(LOCATION_IELEMENT(obj));
- LOC_IF_FAIL(ret, _E, "Fail to stop_batch [%d]", err_msg(ret));
+ LOC_IF_FAIL(ret, _E, "Fail to stop_batch [%s]", err_msg(ret));
return ret;
}
switch (method) {
case LOCATION_METHOD_HYBRID:
- if (module_is_supported("gps") || module_is_supported("wps") || module_is_supported("mock"))
- is_supported = TRUE;
- break;
+ if (module_is_supported("gps") || module_is_supported("wps"))
+ is_supported = TRUE;
+ break;
case LOCATION_METHOD_GPS:
- is_supported = module_is_supported("gps");
- break;
+ is_supported = module_is_supported("gps");
+ break;
case LOCATION_METHOD_WPS:
- is_supported = module_is_supported("wps");
- break;
- case LOCATION_METHOD_MOCK:
- is_supported = module_is_supported("mock");
- break;
+ is_supported = module_is_supported("wps");
+ break;
+ case LOCATION_METHOD_PASSIVE:
+ is_supported = module_is_supported("passive");
+ break;
default:
break;
}
int ret = 0;
char *_key = NULL;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
if (location_setting_get_int(VCONFKEY_LOCATION_RESTRICT) > RESTRICT_OFF) {
LOCATION_SECLOG("Location setting is denied by DPM");
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_get_position(LOCATION_IELEMENT(obj), position, accuracy);
LOC_COND_RET(ret != LOCATION_ERROR_NONE, ret, _E, "Fail to get_position [%s]", err_msg(ret));
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_get_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
LOC_IF_FAIL(ret, _E, "Fail to get_position_ext [%s]", err_msg(ret));
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_get_last_position(LOCATION_IELEMENT(obj), position, accuracy);
LOC_IF_FAIL(ret, _E, "Fail to get_last_position [%s]", err_msg(ret));
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_get_last_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
LOC_IF_FAIL(ret, _E, "Fail to get_last_position_ext [%s]", err_msg(ret));
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_get_satellite(LOCATION_IELEMENT(obj), satellite);
LOC_IF_FAIL(ret, _E, "Fail to get_satellite [%s]", err_msg(ret));
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_get_batch(LOCATION_IELEMENT(obj), batch);
LOC_IF_FAIL(ret, _E, "Fail to get_batch [%s]", err_msg(ret));
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_get_last_satellite(LOCATION_IELEMENT(obj), satellite);
LOC_IF_FAIL(ret, _E, "Fail to get_last_satellite [%s]", err_msg(ret));
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_get_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_get_last_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
LOC_IF_FAIL(ret, _E, "Fail to get_last_velocity [%s]", err_msg(ret));
EXPORT_API int
location_get_accessibility_state(LocationAccessState *state)
{
- int auth = location_application_get_authority();
- switch (auth) {
- case LOCATION_APP_OFF:
- *state = LOCATION_ACCESS_DENIED;
- break;
- case LOCATION_APP_ON:
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ int ret = location_check_cynara(LOCATION_PRIVILEGE);
+
+ if (ret == LOCATION_ERROR_NONE) {
+ *state = LOCATION_ACCESS_ALLOWED;
+ } else {
+ *state = LOCATION_ACCESS_DENIED;
+ LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
+ }
+ } else {
*state = LOCATION_ACCESS_ALLOWED;
- break;
- case LOCATION_APP_NOT_FOUND:
- *state = LOCATION_ACCESS_NONE;
- break;
- default:
- return LOCATION_ERROR_UNKNOWN;
}
- LOCATION_LOGD("get_accessibility_state [%d]", auth);
return LOCATION_ERROR_NONE;
}
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
ret = location_ielement_set_option(LOCATION_IELEMENT(obj), option);
LOC_IF_FAIL(ret, _E, "Fail to get_velocity [%s]", err_msg(ret));
/*
* Tizen 3.0
*/
-
EXPORT_API int
-location_get_service_state(LocationObject *obj, int *state)
+location_enable_mock(const int enable)
{
- g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(state, LOCATION_ERROR_PARAMETER);
-
int ret = LOCATION_ERROR_NONE;
- ret = location_ielement_get_status(LOCATION_IELEMENT(obj), state);
- LOC_IF_FAIL(ret, _E, "Fail to get_position [%s]", err_msg(ret));
-
- return ret;
-}
-
-EXPORT_API int
-location_enable_mock(const LocationMethod method, const int enable)
-{
- int ret = 0;
- char *_key = NULL;
-
- LOC_COND_RET(method != LOCATION_METHOD_MOCK, LOCATION_ERROR_PARAMETER, _E, "Method is not mock [%s]", err_msg(LOCATION_ERROR_PARAMETER));
-
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
#if 0 /* Tizen platform didn't turn developer option on */
gboolean developer_option = FALSE;
LOC_COND_RET(!developer_option, LOCATION_ERROR_NOT_ALLOWED, _E, "Cannot enable mock location because developer option is not turned on", ret);
#endif
- _key = __convert_setting_key(method);
- LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
-
- ret = vconf_set_int(_key, enable);
- if (ret != VCONF_OK) {
- LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
- g_free(_key);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
-
- g_free(_key);
-
- return ret;
-}
-
-#if 0
-static char *__convert_mock_setting_key(LocationMethod method)
-{
- char *key = NULL;
- switch (method) {
- case LOCATION_METHOD_MOCK_GPS:
- key = g_strdup(VCONFKEY_LOCATION_MOCK_GPS_ENABLED);
- break;
- case LOCATION_METHOD_MOCK_WPS:
- key = g_strdup(VCONFKEY_LOCATION_MOCK_NETWORK_ENABLED);
- break;
- default:
- break;
- }
- return key;
-}
-
-EXPORT_API int
-location_set_mock_method_enabled(const LocationMethod method, const int enable)
-{
- int ret = 0;
- char *_key = NULL;
- int vconf_val = 0;
-
- _key = __convert_setting_key(method);
- LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method = %d [%s]", method, err_msg(LOCATION_ERROR_NOT_SUPPORTED));
-
- ret = vconf_get_int(_key, &vconf_val);
+ ret = vconf_set_int(VCONFKEY_LOCATION_MOCK_ENABLED, enable);
if (ret != VCONF_OK) {
- LOCATION_SECLOG("failed [%s], error [%d]", _key, ret);
- g_free(_key);
+ LOCATION_SECLOG("vconf_set_int failed [MOCK_ENABLED], ret=[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
- if (vconf_val) {
- _key = __convert_mock_setting_key(method);
- LOC_COND_RET(!_key, LOCATION_ERROR_NOT_SUPPORTED, _E, "Invalid method[%d]", method);
- ret = vconf_set_int(_key, enable);
- if (ret != VCONF_OK) {
- LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
- g_free(_key);
- return LOCATION_ERROR_NOT_ALLOWED;
- }
- g_free(_key);
- }
-
return ret;
}
-#endif
-
EXPORT_API int
location_set_mock_location(LocationObject *obj, const LocationPosition *position, const LocationVelocity *velocity, const LocationAccuracy *accuracy)
g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
+
ret = location_ielement_set_mock_location(LOCATION_IELEMENT(obj), position, velocity, accuracy);
LOC_IF_FAIL(ret, _E, "Fail to set_mock_location [%s]", err_msg(ret));
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
+
ret = location_ielement_clear_mock_location(LOCATION_IELEMENT(obj));
LOC_IF_FAIL(ret, _E, "Fail to clear_mock_location [%s]", err_msg(ret));
int ret = LOCATION_ERROR_NONE;
int restriction = 0;
-#ifndef TIZEN_PROFILE_TV
- ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
- LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
-#endif
+ if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
+ ret = location_check_cynara(LOCATION_ENABLE_PRIVILEGE);
+ LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret));
+ }
if (enable) {
int value = 0;
ret = vconf_get_int(VCONFKEY_LOCATION_RESTRICT, &restriction);