# Set required packages
INCLUDE(FindPkgConfig)
+
+IF(FEATURE_PROFILE_TV)
+ MESSAGE("<<< TV Profile >>>")
+ ADD_DEFINITIONS("-DTIZEN_PROFILE_TV")
+ SET(PRIVACY_PKG "")
+ELSE(FEATURE_PROFILE_TV)
+ SET(PRIVACY_PKG "privacy-manager-client")
+
+ IF(FEATURE_PROFILE_WEARABLE)
+ MESSAGE("<<< Wearable Profile >>>")
+ ELSE(FEATURE_PROFILE_WEARABLE)
+ MESSAGE("<<< Mobile Profile >>>")
+ #This is for OSP deamon. We don't need it any more.
+ #ADD_DEFINITIONS("-DTIZEN_PROFILE_MOBILE")
+ ENDIF(FEATURE_PROFILE_WEARABLE)
+ENDIF(FEATURE_PROFILE_TV)
+
pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 gobject-2.0 gmodule-2.0
capi-appfw-app-manager capi-appfw-package-manager pkgmgr-info
- privacy-manager-client dlog vconf json-glib-1.0 lbs-dbus bundle eventsystem)
+ dlog vconf json-glib-1.0 bundle eventsystem ${PRIVACY_PKG})
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(MANAGER_DIR "manager")
SET(MODULE_DIR "module")
+IF(FEATURE_PROFILE_TV)
+ SET (PRIVACY_SRC "")
+ELSE(FEATURE_PROFILE_TV)
+ SET (PRIVACY_SRC "${MANAGER_DIR}/location-privacy.c")
+ENDIF(FEATURE_PROFILE_TV)
+
IF(FEATURE_PROFILE_WEARABLE)
MESSAGE("<<< Wearable Profile >>>")
ELSE(FEATURE_PROFILE_WEARABLE)
${MANAGER_DIR}/location-common-util.c
${MANAGER_DIR}/location-gps.c
${MANAGER_DIR}/location-wps.c
- ${MANAGER_DIR}/location-privacy.c
+ ${PRIVACY_SRC}
${MODULE_DIR}/module-internal.c
)
case LOCATION_BOUNDARY_POLYGON: {
double interval_x = 0.0, interval_y = 0.0;
- double x0, y0;
+ double x0=0.0, y0=0.0;
gboolean edge_area;
int crossing_num = 0;
GList *position_list = boundary->polygon.position_list;
* Case 2. longitude2 - longitude1 < -180 : interval_y = longitude2 - longitude1 + 360
* Case 3. longitude2 - longitude1 > 180 : intreval_y = longitude2 - longitude1 - 360
*/
+
+ LOCATION_LOGD("edge_area = %d, interval_y = %lf, interval_x = %lf", edge_area,interval_y, interval_x);
if (interval_y > 180) {
interval_y = interval_y - 360;
edge_area = TRUE;
#include "location-common-util.h"
#include "location-setting.h"
#include "location-log.h"
+#include <app_manager.h>
int location_application_get_authority(void)
location_boundary_free(priv->boundary);
g_slice_free(LocationBoundaryPrivate, priv);
}
+
+int location_get_app_type(char *target_app_id)
+{
+ int ret = 0;
+ pid_t pid = 0;
+ char *app_id = NULL;
+ app_info_h app_info;
+ char *type = NULL;
+
+ if (target_app_id == NULL) {
+ pid = getpid();
+ ret = app_manager_get_app_id(pid, &app_id);
+ if (ret != APP_MANAGER_ERROR_NONE) {
+ LOCATION_LOGE("Fail to get app_id. Err[%d]", ret);
+ return LOCATION_ERROR_NONE;
+ }
+ } else {
+ app_id = g_strdup(target_app_id);
+ }
+
+ ret = app_info_create(app_id, &app_info);
+ if (ret != APP_MANAGER_ERROR_NONE) {
+ LOCATION_LOGE("Fail to get app_info. Err[%d]", ret);
+ g_free(app_id);
+ return LOCATION_ERROR_NONE;
+ }
+
+ ret = app_info_get_type(app_info, &type);
+ if (ret != APP_MANAGER_ERROR_NONE) {
+ LOCATION_LOGE("Fail to get type. Err[%d]", ret);
+ g_free(app_id);
+ app_info_destroy(app_info);
+ return LOCATION_ERROR_NONE;
+ }
+
+ if (strcmp(type, "c++app") == 0) {
+ ret = CPPAPP;
+ } else if (strcmp(type, "webapp") == 0) {
+ ret = WEBAPP;
+ } else {
+ ret = CAPP;
+ }
+
+ g_free(type);
+ g_free(app_id);
+ app_info_destroy(app_info);
+
+ return ret;
+}
int set_prop_removal_boundary(GList **prev_boundary_list, LocationBoundary *boundary);
void free_boundary_list(gpointer data);
+int location_get_app_type(char *app_id);
+
+
G_END_DECLS
#endif
priv->vel_updated_timestamp = 0;
priv->sat_updated_timestamp = 0;
priv->loc_updated_timestamp = 0;
+
+ priv->signal_type = 0;
}
static gboolean
g_return_if_fail(self);
LocationGpsPrivate *priv = GET_PRIVATE(self);
g_return_if_fail(priv);
- g_return_if_fail(priv->mod);
- g_return_if_fail(priv->mod->handler);
if (location_setting_get_key_val(key) == VCONFKEY_LOCATION_GPS_SEARCHING) {
if (!priv->pos_searching_timer) priv->pos_searching_timer = g_timeout_add(priv->pos_interval * 1000, _position_timeout_cb, self);
static int
location_gps_start(LocationGps *self)
{
- LOCATION_LOGD("location_gps_start");
+ LOCATION_LOGD("ENTER >>>");
LocationGpsPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
if (priv->app_type != CPPAPP && priv->set_noti == FALSE) {
location_setting_add_notify(VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb, self);
+
#ifdef TIZEN_PROFILE_MOBILE
- location_setting_add_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb, self);
+ location_state_add_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb, self);
#endif
priv->set_noti = TRUE;
}
+ LOCATION_LOGD("EXIT <<<");
return ret;
}
if (priv->app_type != CPPAPP && priv->set_noti == TRUE) {
location_setting_ignore_notify(VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb);
#ifdef TIZEN_PROFILE_MOBILE
- location_setting_ignore_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb);
+ location_state_ignore_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb);
#endif
priv->set_noti = FALSE;
}
#ifdef TIZEN_PROFILE_MOBILE
if (priv->pos_searching_timer) g_source_remove(priv->pos_searching_timer);
if (priv->vel_searching_timer) g_source_remove(priv->vel_searching_timer);
- if (priv->loc_timeout) g_source_remove(priv->loc_timeout);
priv->pos_searching_timer = 0;
priv->vel_searching_timer = 0;
- priv->loc_timeout = 0;
#endif
+ if (priv->loc_timeout) g_source_remove(priv->loc_timeout);
+ priv->loc_timeout = 0;
if (priv->app_type != CPPAPP && priv->set_noti == TRUE) {
location_setting_ignore_notify(VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb);
#ifdef TIZEN_PROFILE_MOBILE
- location_setting_ignore_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb);
+ location_state_ignore_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb);
#endif
priv->set_noti = FALSE;
}
case PROP_POS_INTERVAL: {
guint interval = g_value_get_uint(value);
LOCATION_LOGD("Set prop>> PROP_POS_INTERVAL: %u", interval);
+ /* We don't need to set interval when new one is same as the previous one */
+ if (interval == priv->pos_interval) break;
+
if (interval > 0) {
if (interval < LOCATION_UPDATE_INTERVAL_MAX)
priv->pos_interval = interval;
else
priv->pos_interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
- } else
+ } else {
priv->pos_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
+ }
#ifdef TIZEN_PROFILE_MOBILE
if (priv->pos_searching_timer) {
case PROP_VEL_INTERVAL: {
guint interval = g_value_get_uint(value);
LOCATION_LOGD("Set prop>> PROP_VEL_INTERVAL: %u", interval);
+ if (interval == priv->vel_interval) break;
+
if (interval > 0) {
if (interval < LOCATION_UPDATE_INTERVAL_MAX)
priv->vel_interval = interval;
LocationGpsPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
- g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
-
if (__get_started(self) != TRUE) {
LOCATION_LOGE("location is not started");
return LOCATION_ERROR_NOT_AVAILABLE;
LocationGpsPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
if (__get_started(self) != TRUE) {
LocationGpsPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
- g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
if (__get_started(self) != TRUE) {
LOCATION_LOGE("location is not started");
if (priv->loc_timeout) g_source_remove(priv->loc_timeout);
priv->loc_timeout = 0;
- g_signal_emit(self, signals[LOCATION_UPDATED], LOCATION_ERROR_NOT_AVAILABLE, 0, pos, vel, acc);
+ g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NOT_AVAILABLE, pos, vel, acc);
location_gps_stop(self);
return FALSE;
LocationGpsPrivate *priv = GET_PRIVATE(obj);
g_return_if_fail(priv);
- g_signal_emit(self, signals[LOCATION_UPDATED], LOCATION_ERROR_NONE, 0, pos, vel, acc);
+ g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NONE, pos, vel, acc);
if (priv->loc_timeout) {
g_source_remove(priv->loc_timeout);
priv->loc_timeout = 0;
LocationGpsPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
if (__get_started(self) != TRUE) {
priv->enabled = FALSE;
priv->signal_type = 0;
- priv->pos_interval = LOCATION_UPDATE_INTERVAL_NONE;
- priv->vel_interval = LOCATION_UPDATE_INTERVAL_NONE;
- priv->sat_interval = LOCATION_UPDATE_INTERVAL_NONE;
- priv->loc_interval = LOCATION_UPDATE_INTERVAL_NONE;
+ priv->pos_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
+ priv->vel_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
+ priv->sat_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
+ priv->loc_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
priv->batch_interval = LOCATION_UPDATE_INTERVAL_NONE;
priv->batch_period = LOCATION_BATCH_PERIOD_DEFAULT;
priv->min_interval = LOCATION_UPDATE_INTERVAL_NONE;
#ifdef TIZEN_PROFILE_MOBILE
priv->pos_searching_timer = 0;
priv->vel_searching_timer = 0;
- priv->loc_timeout = 0;
#endif
+ priv->loc_timeout = 0;
priv->app_type = location_get_app_type(NULL);
if (priv->app_type == 0) {
G_TYPE_POINTER,
G_TYPE_POINTER);
-#ifdef TIZEN_PROFILE_MOBILE
signals[LOCATION_UPDATED] = g_signal_new("location-updated",
G_TYPE_FROM_CLASS(klass),
G_SIGNAL_RUN_FIRST |
G_TYPE_POINTER,
G_TYPE_POINTER,
G_TYPE_POINTER);
-#endif
signals[BATCH_UPDATED] = g_signal_new("batch-updated",
G_TYPE_FROM_CLASS(klass),
LocationHybridPrivate *priv = GET_PRIVATE((LocationHybrid *)self);
g_return_if_fail(priv);
- g_signal_emit(self, signals[LOCATION_UPDATED], LOCATION_ERROR_NONE, 0, pos, vel, acc);
+ g_signal_emit(self, signals[LOCATION_UPDATED], 0, error, pos, vel, acc);
}
static void
if (priv->gps) ret_gps = location_start(priv->gps);
if (priv->wps) ret_wps = location_start(priv->wps);
- if (ret_gps != LOCATION_ERROR_NONE) {
+ if ((ret_gps != LOCATION_ERROR_NONE) && (ret_wps != LOCATION_ERROR_NONE)) {
LOCATION_LOGD("ret_gps = %d, ret_wps = %d", ret_gps, ret_wps);
- if (ret_gps == LOCATION_ERROR_SECURITY_DENIED) {
+ if (ret_gps == LOCATION_ERROR_SECURITY_DENIED || ret_wps == LOCATION_ERROR_SECURITY_DENIED) {
return LOCATION_ERROR_SECURITY_DENIED;
- } else if (ret_gps == LOCATION_ERROR_SETTING_OFF) {
+ } else if (ret_gps == LOCATION_ERROR_SETTING_OFF || ret_wps == LOCATION_ERROR_SETTING_OFF) {
return LOCATION_ERROR_SETTING_OFF;
- } else if (ret_gps == LOCATION_ERROR_NOT_ALLOWED) {
- return LOCATION_ERROR_NOT_ALLOWED;
- } else {
- return LOCATION_ERROR_NOT_AVAILABLE;
- }
- } else if (ret_wps != LOCATION_ERROR_NONE) {
- if (ret_wps == LOCATION_ERROR_SECURITY_DENIED) {
- return LOCATION_ERROR_SECURITY_DENIED;
- } else if (ret_wps == LOCATION_ERROR_SETTING_OFF) {
- return LOCATION_ERROR_SETTING_OFF;
- } else if (ret_wps == LOCATION_ERROR_NOT_ALLOWED) {
+ } else if (ret_gps == LOCATION_ERROR_NOT_ALLOWED || ret_wps == LOCATION_ERROR_NOT_ALLOWED) {
return LOCATION_ERROR_NOT_ALLOWED;
} else {
return LOCATION_ERROR_NOT_AVAILABLE;
bool found;
} location_privilege_s;
-int
-location_get_app_type(char *target_app_id)
-{
- int ret = 0;
- pid_t pid = 0;
- char *app_id = NULL;
- app_info_h app_info;
- char *type = NULL;
-
- if (target_app_id == NULL) {
- pid = getpid();
- ret = app_manager_get_app_id(pid, &app_id);
- if (ret != APP_MANAGER_ERROR_NONE) {
- LOCATION_LOGE("Fail to get app_id. Err[%d]", ret);
- return LOCATION_ERROR_NONE;
- }
- } else {
- app_id = g_strdup(target_app_id);
- }
-
- ret = app_info_create(app_id, &app_info);
- if (ret != APP_MANAGER_ERROR_NONE) {
- LOCATION_LOGE("Fail to get app_id. Err[%d]", ret);
- g_free(app_id);
- return 0;
- }
-
- ret = app_info_get_type(app_info, &type);
- if (ret != APP_MANAGER_ERROR_NONE) {
- LOCATION_LOGE("Fail to get type. Err[%d]", ret);
- g_free(app_id);
- app_info_destroy(app_info);
- return 0;
- }
- if (strcmp(type, "c++app") == 0) {
- ret = CPPAPP;
- } else if (strcmp(type, "webapp") == 0) {
- ret = WEBAPP;
- } else {
- ret = CAPP;
- }
-
- g_free(type);
- g_free(app_id);
- app_info_destroy(app_info);
-
- return ret;
-}
void
location_privacy_initialize(void)
void location_privacy_initialize(void);
void location_privacy_finalize(void);
-int location_get_app_type(char *app_id);
int location_get_privacy(const char *privilege_name);
int location_check_privilege(const char *privilege_name);
#include "location-log.h"
#include "location-setting.h"
+static unsigned int g_event_req_id;
+
gint location_setting_get_key_val(keynode_t *key)
{
switch (vconf_keynode_get_type(key)) {
case VCONF_TYPE_INT:
val = vconf_keynode_get_int(key);
- LOCATION_SECLOG("Setting changed [%s]:[%d]", vconf_keynode_get_name(key), val);
+ LOCATION_SECLOG("changed [%s]:[%d]", vconf_keynode_get_name(key), val);
break;
default:
LOCATION_LOGW("Unused type(%d)", vconf_keynode_get_type(key));
gint location_setting_get_int(const gchar *path)
{
- g_return_val_if_fail(path, -1);
- int val = -1;
+ g_return_val_if_fail(path, 0);
+ int val = 0;
if (vconf_get_int(path, &val)) {
- LOCATION_SECLOG("vconf_get_int: failed [%s]", path);
- } else if (val == 0)
- LOCATION_SECLOG("vconf_get_int: [%s]:[%d]", path, val);
+ LOCATION_SECLOG("failed [%s]", path);
+ }
return val;
}
gboolean location_setting_get_bool(const gchar *path)
{
- g_return_val_if_fail(path, -1);
+ g_return_val_if_fail(path, FALSE);
gboolean val = FALSE;
if (vconf_get_bool(path, &val)) {
- LOCATION_SECLOG("vconf_get_int: failed [%s]", path);
+ LOCATION_SECLOG("failed [%s]", path);
}
return val;
}
return vconf_get_str(path);
}
-static unsigned int event_req_id;
-
-static char *convert_event_from_key(const char *key)
+static char *__convert_event_from_vconf(const char *vconf)
{
char *event = NULL;
- if (g_strcmp0(key, VCONFKEY_LOCATION_USE_MY_LOCATION) == 0) {
+ if (g_strcmp0(vconf, VCONFKEY_LOCATION_USE_MY_LOCATION) == 0) {
event = g_strdup(SYS_EVENT_LOCATION_ENABLE_STATE);
- } else if (g_strcmp0(key, VCONFKEY_LOCATION_ENABLED) == 0) {
+ } else if (g_strcmp0(vconf, VCONFKEY_LOCATION_ENABLED) == 0) {
event = g_strdup(SYS_EVENT_GPS_ENABLE_STATE);
- } else if (g_strcmp0(key, VCONFKEY_LOCATION_NETWORK_ENABLED) == 0) {
+ } else if (g_strcmp0(vconf, VCONFKEY_LOCATION_NETWORK_ENABLED) == 0) {
event = g_strdup(SYS_EVENT_NPS_ENABLE_STATE);
}
return event;
}
+static char *__convert_key_from_event(const char *event)
+{
+ char *key = NULL;
+ if (g_strcmp0(event, SYS_EVENT_LOCATION_ENABLE_STATE) == 0) {
+ key = g_strdup(EVT_KEY_LOCATION_ENABLE_STATE);
+ } else if (g_strcmp0(event, SYS_EVENT_GPS_ENABLE_STATE) == 0) {
+ key = g_strdup(EVT_KEY_GPS_ENABLE_STATE);
+ } else if (g_strcmp0(event, SYS_EVENT_NPS_ENABLE_STATE) == 0) {
+ key = g_strdup(EVT_KEY_NPS_ENABLE_STATE);
+ }
+ return key;
+}
+
+static char *__convert_event_value(const int val)
+{
+ char *value = NULL;
+ if (val == 1) {
+ value = g_strdup(EVT_VAL_GPS_ENABLED);
+ } else {
+ value = g_strdup(EVT_VAL_GPS_DISABLED);
+ }
+ return value;
+}
+
+gint location_setting_send_system_event(const char *path, const int val)
+{
+ g_return_val_if_fail(path, -1);
+
+ int ret = 0;
+ char *event = NULL;
+ char *key = NULL;
+ char *value = NULL;
+ bundle *b = NULL;
+
+ event = __convert_event_from_vconf(path);
+ key = __convert_key_from_event(event);
+ value = __convert_event_value(val);
+
+ b = bundle_create();
+ bundle_add_str(b, key, value);
+ ret = eventsystem_request_sending_system_event(event, b);
+ bundle_free(b);
+
+ LOCATION_SECLOG("[%s: %s]", key, value);
+
+ g_free(event);
+ g_free(key);
+ g_free(value);
+ return ret;
+}
+
static void __event_handler(const char *event_name, bundle *data, void *self)
{
const char *value = NULL;
value = bundle_get_val(data, EVT_KEY_NPS_ENABLE_STATE);
}
- LOCATION_SECLOG("get event state [%s]", value);
+ LOCATION_SECLOG("[%s: %s]", event_name, value);
}
gint location_setting_add_notify(const gchar *path, SettingCB setting_cb, gpointer self)
g_return_val_if_fail(self, -1);
const char *event_name = NULL;
- event_name = convert_event_from_key(path);
+ event_name = __convert_event_from_vconf(path);
if (eventsystem_register_event(event_name,
- &event_req_id,
+ &g_event_req_id,
(eventsystem_handler) __event_handler, NULL) != ES_R_OK) {
LOCATION_SECLOG("eventsystem_register_event failed");
g_return_val_if_fail(path, -1);
g_return_val_if_fail(setting_cb, -1);
- if (eventsystem_unregister_event(event_req_id) != ES_R_OK) {
+ if (eventsystem_unregister_event(g_event_req_id) != ES_R_OK) {
LOCATION_SECLOG("eventsystem_unregister_event failed");
return -1;
}
LOCATION_SECLOG("vconf notify removed [%s]", path);
return 0;
}
+
+gint location_state_add_notify(const gchar *path, SettingCB setting_cb, gpointer self)
+{
+ g_return_val_if_fail(path, -1);
+ g_return_val_if_fail(self, -1);
+
+ if (vconf_notify_key_changed(path, setting_cb, self)) {
+ LOCATION_SECLOG("vconf notify add failed [%s]", path);
+ return -1;
+ }
+ LOCATION_SECLOG("vconf notify added [%s]", path);
+ return 0;
+}
+
+gint location_state_ignore_notify(const gchar *path, SettingCB setting_cb)
+{
+ g_return_val_if_fail(path, -1);
+ g_return_val_if_fail(setting_cb, -1);
+
+ if (vconf_ignore_key_changed(path, setting_cb)) {
+ LOCATION_SECLOG("vconf notify remove failed [%s]", path);
+ return -1;
+ }
+ LOCATION_SECLOG("vconf notify removed [%s]", path);
+ return 0;
+}
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
+ * See the License for the specific language governing permissions and "1
* limitations under the License.
*/
typedef void (*SettingCB)(keynode_t *key, gpointer data);
+
+gint location_setting_send_system_event(const char *path, const int val);
gint location_setting_get_key_val(keynode_t *key);
gint location_setting_get_int(const gchar *path);
gboolean location_setting_get_bool(const gchar *path);
gchar *location_setting_get_string(const gchar *path);
gint location_setting_add_notify(const gchar *path, SettingCB setting_cb, gpointer self);
gint location_setting_ignore_notify(const gchar *path, SettingCB setting_cb);
+gint location_state_add_notify(const gchar *path, SettingCB setting_cb, gpointer self);
+gint location_state_ignore_notify(const gchar *path, SettingCB setting_cb);
+
#define setting_retval_if_fail(path) {\
int val = location_setting_get_int(path);\
}
}
- if ((pos_interval == 0) && (vel_interval == 0) && (loc_interval == 0)) {
- signal_type |= POSITION_UPDATED;
- }
-
if (signal_type != 0) {
g_signal_emit(obj, signals[SERVICE_UPDATED], 0, signal_type, pos, vel, acc);
}
index++;
}
}
-
}
void
PROP_LAST_POSITION,
PROP_POS_INTERVAL,
PROP_VEL_INTERVAL,
+ PROP_LOC_INTERVAL,
PROP_BOUNDARY,
PROP_REMOVAL_BOUNDARY,
PROP_MIN_INTERVAL,
}
break;
}
+ case PROP_LOC_INTERVAL: {
+ guint interval = g_value_get_uint(value);
+ LOCATION_LOGD("Set prop>> PROP_LOC_INTERVAL: %u", interval);
+ if (interval > 0) {
+ if (interval < LOCATION_UPDATE_INTERVAL_MAX)
+ priv->loc_interval = interval;
+ else
+ priv->loc_interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
+ } else
+ priv->loc_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
+
+ break;
+ }
case PROP_MIN_INTERVAL: {
guint interval = g_value_get_uint(value);
LOCATION_LOGD("Set prop>> update-min-interval: %u", interval);
case PROP_VEL_INTERVAL:
g_value_set_uint(value, priv->vel_interval);
break;
+ case PROP_LOC_INTERVAL:
+ g_value_set_uint(value, priv->loc_interval);
+ break;
case PROP_MIN_INTERVAL:
g_value_set_uint(value, priv->min_interval);
break;
if (priv->loc_timeout) g_source_remove(priv->loc_timeout);
priv->loc_timeout = 0;
- g_signal_emit(self, signals[LOCATION_UPDATED], LOCATION_ERROR_NOT_AVAILABLE, 0, pos, vel, acc);
+ g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NOT_AVAILABLE, pos, vel, acc);
location_wps_stop(self);
return FALSE;
}
+
static void
wps_single_location_cb(gboolean enabled,
LocationPosition *pos,
LocationWpsPrivate *priv = GET_PRIVATE(self);
g_return_if_fail(priv);
- g_signal_emit(self, signals[LOCATION_UPDATED], LOCATION_ERROR_NONE, 0, pos, vel, acc);
+ g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NONE, pos, vel, acc);
if (priv->loc_timeout) {
g_source_remove(priv->loc_timeout);
priv->loc_timeout = 0;
priv->pos_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
priv->vel_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
- priv->min_interval = 0;
+ priv->loc_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
+ priv->min_interval = LOCATION_UPDATE_INTERVAL_NONE;
priv->pos_updated_timestamp = 0;
priv->vel_updated_timestamp = 0;
+ priv->loc_updated_timestamp = 0;
priv->pos = NULL;
priv->vel = NULL;
G_SIGNAL_NO_RECURSE,
G_STRUCT_OFFSET(LocationWpsClass, updated),
NULL, NULL,
- location_VOID__UINT_POINTER_POINTER,
- G_TYPE_NONE, 3,
- G_TYPE_UINT,
+ location_VOID__INT_POINTER_POINTER_POINTER,
+ G_TYPE_NONE, 4,
+ G_TYPE_INT,
+ G_TYPE_POINTER,
G_TYPE_POINTER,
G_TYPE_POINTER);
LOCATION_UPDATE_INTERVAL_DEFAULT,
G_PARAM_READWRITE);
+ properties[PROP_LOC_INTERVAL] = g_param_spec_uint("loc-interval",
+ "gps location interval prop",
+ "gps location interval data",
+ LOCATION_UPDATE_INTERVAL_MIN,
+ LOCATION_UPDATE_INTERVAL_MAX,
+ LOCATION_UPDATE_INTERVAL_DEFAULT,
+ G_PARAM_READWRITE);
+
properties[PROP_MIN_INTERVAL] = g_param_spec_uint("min-interval",
"wps distance-based interval prop",
"wps distance-based interval data",
#include "location-gps.h"
#include "location-wps.h"
#include "location-position.h"
-#include "location-privacy.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_ENABLE_PRIVILEGE "http://tizen.org/privilege/location.enable"
}
}
-
EXPORT_API
int location_init(void)
{
if (FALSE == module_init())
return LOCATION_ERROR_NOT_AVAILABLE;
+#ifndef TIZEN_PROFILE_TV
location_privacy_initialize();
+#endif
return LOCATION_ERROR_NONE;
}
location_free(LocationObject *obj)
{
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
+
+#ifndef TIZEN_PROFILE_TV
location_privacy_finalize();
+#endif
g_object_unref(obj);
return LOCATION_ERROR_NONE;
}
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_request_single_location(LOCATION_IELEMENT(obj), timeout);
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to request single location. Error [%d]", ret);
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_start(LOCATION_IELEMENT(obj));
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to start. Error [%d]", ret);
{
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_stop(LOCATION_IELEMENT(obj));
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to stop. Error [%d]", ret);
{
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_start_batch(LOCATION_IELEMENT(obj));
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to Batch start. Error [%d]", ret);
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_stop_batch(LOCATION_IELEMENT(obj));
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to Batch stop. Error [%d]", ret);
vconf_ret = vconf_get_int(_key, &vconf_val);
if (vconf_ret != VCONF_OK) {
- LOCATION_SECLOG("vconf_get_int: failed [%s], error [%d]", _key, vconf_ret);
+ LOCATION_SECLOG("failed [%s], error [%d]", _key, vconf_ret);
g_free(_key);
return LOCATION_ERROR_NOT_AVAILABLE;
} else {
- LOCATION_SECLOG("vconf_get_int: [%s]:[%d]", _key, vconf_val);
+ LOCATION_SECLOG("[%s]:[%d]", _key, vconf_val);
}
*is_enabled = vconf_val;
location_enable_method(const LocationMethod method, const int enable)
{
int ret = 0;
- int i = 0;
char *_key = NULL;
+
+#ifndef TIZEN_PROFILE_TV
ret = location_check_privilege(LOCATION_ENABLE_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
- if (method == LOCATION_METHOD_HYBRID) {
- for (i = LOCATION_METHOD_HYBRID; i < LOCATION_METHOD_MAX; i++) {
- _key = __convert_setting_key(i);
- if (!_key) {
- LOCATION_LOGE("Invalid method[%d]", method);
- return LOCATION_ERROR_NOT_SUPPORTED;
- }
-
- ret = vconf_set_int(_key, enable);
- if (ret != VCONF_OK) {
- LOCATION_SECLOG("vconf_set_int failed [%s], error [%d]", _key, ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- } else {
- LOCATION_SECLOG("vconf_set_int: [%s]:[%d]", _key, ret);
- }
- g_free(_key);
- }
+ /* for itself */
+ _key = __convert_setting_key(method);
+ if (!_key) {
+ LOCATION_LOGE("Invalid method[%d]", method);
+ return 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;
} else {
- _key = __convert_setting_key(method);
- if (!_key) {
- LOCATION_LOGE("Invalid method[%d]", method);
- return LOCATION_ERROR_NOT_SUPPORTED;
+ ret = location_setting_send_system_event(_key, enable);
+ if (ret != LOCATION_ERROR_NONE) {
+ LOCATION_SECLOG("Fail to send system event [%s], ret=[%d]", _key, ret);
+ g_free(_key);
+ return LOCATION_ERROR_NOT_ALLOWED;
}
+ }
+ g_free(_key);
+
+ /* for hybrid */
+ _key = __convert_setting_key(LOCATION_METHOD_HYBRID);
+ if (!_key) {
+ LOCATION_LOGE("Invalid method[%d]", LOCATION_METHOD_HYBRID);
+ return LOCATION_ERROR_NOT_SUPPORTED;
+ }
+
+ if (enable) {
ret = vconf_set_int(_key, enable);
if (ret != VCONF_OK) {
- LOCATION_SECLOG("vconf_set_int failed [%s], error [%d]", _key, ret);
+ LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
+ g_free(_key);
return LOCATION_ERROR_NOT_ALLOWED;
} else {
- LOCATION_SECLOG("vconf_set_int: [%s]:[%d]", _key, ret);
+ ret = location_setting_send_system_event(_key, enable);
+ if (ret != LOCATION_ERROR_NONE) {
+ LOCATION_SECLOG("Fail to send system event [%s], ret=[%d]", _key, ret);
+ g_free(_key);
+ return LOCATION_ERROR_NOT_ALLOWED;
+ }
}
- g_free(_key);
+ }
+ else {
+ int i = 0;
+ int enabled_state = 0;
- _key = __convert_setting_key(LOCATION_METHOD_HYBRID);
- if (!_key) {
- LOCATION_LOGE("Invalid method[%d]", LOCATION_METHOD_HYBRID);
- return LOCATION_ERROR_NOT_SUPPORTED;
+ for (i = LOCATION_METHOD_GPS; i < LOCATION_METHOD_MAX; i++) {
+ _key = __convert_setting_key(i);
+ enabled_state |= location_setting_get_int(_key);
+ g_free(_key);
}
- ret = vconf_set_int(_key, enable);
- if (ret != VCONF_OK) {
- LOCATION_SECLOG("vconf_set_int failed [%s], error [%d]", _key, ret);
- return LOCATION_ERROR_NOT_ALLOWED;
- } else {
- LOCATION_SECLOG("vconf_set_int: [%s]:[%d]", _key, ret);
+ if (!enabled_state) {
+ _key = __convert_setting_key(LOCATION_METHOD_HYBRID);
+ ret = vconf_set_int(_key, enable);
+ if (ret != VCONF_OK) {
+ LOCATION_SECLOG("vconf_set_int failed [%s], error [%d]", _key, ret);
+ g_free(_key);
+ return LOCATION_ERROR_NOT_ALLOWED;
+ } else {
+ LOCATION_SECLOG("[%s]:[%d]", _key, ret);
+ ret = location_setting_send_system_event(_key, enable);
+ if (ret != LOCATION_ERROR_NONE) {
+ g_free(_key);
+ LOCATION_SECLOG("Fail to send system event [%s], error [%d]", _key, ret);
+ return LOCATION_ERROR_NOT_ALLOWED;
+ }
+ }
+ g_free(_key);
}
- g_free(_key);
}
return ret;
g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_get_position(LOCATION_IELEMENT(obj), position, accuracy);
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_position. Error [%d]", ret);
g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_get_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_position_ext. Error [%d]", ret);
g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_get_last_position(LOCATION_IELEMENT(obj), position, accuracy);
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_last_position. Error [%d]", ret);
int ret = LOCATION_ERROR_NONE;
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_get_last_position_ext(LOCATION_IELEMENT(obj), position, velocity, accuracy);
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_last_position_ext. Error [%d]", ret);
int ret = LOCATION_ERROR_NONE;
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_get_nmea(LOCATION_IELEMENT(obj), nmea);
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_nmea. Error [%d]", ret);
int ret = LOCATION_ERROR_NONE;
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_get_satellite(LOCATION_IELEMENT(obj), satellite);
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_satellite. Error [%d]", ret);
int ret = LOCATION_ERROR_NONE;
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_get_batch(LOCATION_IELEMENT(obj), batch);
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_batch. Error [%d]", ret);
int ret = LOCATION_ERROR_NONE;
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_get_last_satellite(LOCATION_IELEMENT(obj), satellite);
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_last_satellite. Error [%d]", ret);
int ret = LOCATION_ERROR_NONE;
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_get_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_velocity. Error [%d]", ret);
int ret = LOCATION_ERROR_NONE;
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_get_last_velocity(LOCATION_IELEMENT(obj), velocity, accuracy);
if (ret != LOCATION_ERROR_NONE) LOCATION_LOGE("Fail to get_last_velocity. Error [%d]", ret);
g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
int ret = LOCATION_ERROR_NONE;
+#ifndef TIZEN_PROFILE_TV
ret = location_get_privacy(LOCATION_PRIVILEGE);
if (ret != LOCATION_ERROR_NONE) {
LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
return LOCATION_ERROR_NOT_ALLOWED;
}
+#endif
ret = location_ielement_set_option(LOCATION_IELEMENT(obj), option);
if (ret != LOCATION_ERROR_NONE)
Name: liblbs-location
-Summary: Location Based Service Library
-Version: 0.12.0
-Release: 1
-Group: Location/Libraries
-License: Apache-2.0
-Source0: %{name}-%{version}.tar.gz
+Summary: Location Based Service Library
+Version: 0.12.0
+Release: 1
+Group: Location/Libraries
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
Source1001: %{name}.manifest
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: pkgconfig(capi-appfw-package-manager)
BuildRequires: pkgconfig(pkgmgr-info)
+%if "%{profile}" != "tv"
BuildRequires: pkgconfig(privacy-manager-client)
+%endif
BuildRequires: pkgconfig(json-glib-1.0)
BuildRequires: pkgconfig(lbs-dbus)
BuildRequires: pkgconfig(bundle)
# Call make instruction with smp support
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-#cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DBUILD_PKGTYPE=rpm -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} \
-DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
%if "%{profile}" == "wearable"
- -DFEATURE_PROFILE_WEARABLE:BOOL=ON
-%else
- -DFEATURE_PROFILE_WEARABLE:BOOL=OFF
+ -DFEATURE_PROFILE_WEARABLE:BOOL=ON \
+%endif
+%if "%{profile}" == "tv"
+ -DFEATURE_PROFILE_TV:BOOL=ON
%endif
+
+
make %{?jobs:-j%jobs}