From ad2a6d880cfbdcd34e2004db858739480c283a98 Mon Sep 17 00:00:00 2001 From: Young-Ae Kang Date: Wed, 10 Jun 2015 21:09:59 +0900 Subject: [PATCH] 1. Code synchronization with tizen_2.4 2. Changed configuration to depend on lbs-location 3. Fixed build error for 64bit arch. Signed-off-by: Young-Ae Kang Change-Id: Ife52faf55df91e872bdfc48824d0a29a76c85688 --- CMakeLists.txt | 88 +-- capi-location-manager.pc.in | 9 +- doc/location-manager-doc.h | 228 +++++++ include/location_batch.h | 101 +++ include/location_bounds.h | 188 +++--- include/location_internal.h | 130 ++++ include/location_preference.h | 417 ------------ include/locations.h | 1049 +++++++++++++++++++----------- include/locations_private.h | 97 --- packaging/capi-location-manager.changes | 494 ++++++++++++++ packaging/capi-location-manager.manifest | 6 +- packaging/capi-location-manager.spec | 62 +- src/location_batch.c | 159 +++++ src/location_bounds.c | 111 +++- src/location_internal.c | 134 ++++ src/location_preference.c | 557 ---------------- src/locations.c | 943 +++++++++++++++++---------- test/CMakeLists.txt | 14 +- test/capi-location-manager-test.efl | 30 + test/capi-location-manager-test.manifest | 19 + test/location_test.c | 239 +++++-- 21 files changed, 3016 insertions(+), 2059 deletions(-) create mode 100644 doc/location-manager-doc.h create mode 100644 include/location_batch.h create mode 100644 include/location_internal.h delete mode 100644 include/location_preference.h delete mode 100755 include/locations_private.h create mode 100644 src/location_batch.c create mode 100644 src/location_internal.c delete mode 100755 src/location_preference.c create mode 100644 test/capi-location-manager-test.efl create mode 100755 test/capi-location-manager-test.manifest mode change 100644 => 100755 test/location_test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f9efb7..1da16b7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,47 +10,47 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(dependents "dlog location capi-base-common") SET(pc_dependents "capi-base-common") INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_name} REQUIRED ${dependents}) -FOREACH(flag ${${fw_name}_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") + pkg_check_modules(dependents REQUIRED dlog lbs-location capi-base-common capi-system-info) + +FOREACH(flag ${dependents_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=hidden -fPIC -Wall -Werror") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") - ADD_DEFINITIONS("-DTARGET") + ADD_DEFINITIONS("-DTARGET") ENDIF("${ARCH}" STREQUAL "arm") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DEXPORT_API=__attribute__((visibility(\"default\")))") ADD_DEFINITIONS("-DTIZEN_DEBUG") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") aux_source_directory(src SOURCES) ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) SET_TARGET_PROPERTIES(${fw_name} - PROPERTIES - VERSION ${FULLVER} - SOVERSION ${MAJORVER} - CLEAN_DIRECT_OUTPUT 1 + PROPERTIES + VERSION ${FULLVER} + SOVERSION ${MAJORVER} + CLEAN_DIRECT_OUTPUT 1 ) -TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) +TARGET_LINK_LIBRARIES(${fw_name} ${dependents_LDFLAGS}) -INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(TARGETS ${fw_name} DESTINATION ${LIBDIR}) INSTALL( - DIRECTORY ${INC_DIR}/ DESTINATION include/location - FILES_MATCHING - PATTERN "*_private.h" EXCLUDE - PATTERN "${INC_DIR}/*.h" - ) + DIRECTORY ${INC_DIR}/ DESTINATION ${INCLUDEDIR}/location + FILES_MATCHING + PATTERN "*_internal.h" EXCLUDE + PATTERN "${INC_DIR}/*.h" + ) SET(PC_NAME ${fw_name}) SET(PC_REQUIRED ${pc_dependents}) @@ -58,11 +58,11 @@ SET(PC_LDFLAGS -l${fw_name}) SET(PC_CFLAGS -I\${includedir}/location) CONFIGURE_FILE( - ${fw_name}.pc.in - ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc - @ONLY + ${fw_name}.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc + @ONLY ) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIBDIR}/pkgconfig) ADD_SUBDIRECTORY(test) @@ -70,29 +70,29 @@ IF(UNIX) ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) ADD_CUSTOM_COMMAND( - DEPENDS clean - COMMENT "distribution clean" - COMMAND find - ARGS . - -not -name config.cmake -and \( - -name tester.c -or - -name Testing -or - -name CMakeFiles -or - -name cmake.depends -or - -name cmake.check_depends -or - -name CMakeCache.txt -or - -name cmake.check_cache -or - -name *.cmake -or - -name Makefile -or - -name core -or - -name core.* -or - -name gmon.out -or - -name install_manifest.txt -or - -name *.pc -or - -name *~ \) - | grep -v TC | xargs rm -rf - TARGET distclean - VERBATIM + DEPENDS clean + COMMENT "distribution clean" + COMMAND find + ARGS . + -not -name config.cmake -and \( + -name tester.c -or + -name Testing -or + -name CMakeFiles -or + -name cmake.depends -or + -name cmake.check_depends -or + -name CMakeCache.txt -or + -name cmake.check_cache -or + -name *.cmake -or + -name Makefile -or + -name core -or + -name core.* -or + -name gmon.out -or + -name install_manifest.txt -or + -name *.pc -or + -name *~ \) + | grep -v TC | xargs rm -rf + TARGET distclean + VERBATIM ) ENDIF(UNIX) diff --git a/capi-location-manager.pc.in b/capi-location-manager.pc.in index 241551f..0931f89 100644 --- a/capi-location-manager.pc.in +++ b/capi-location-manager.pc.in @@ -1,15 +1,14 @@ - # Package Information for pkg-config prefix=@PREFIX@ -exec_prefix=/usr -libdir=@LIB_INSTALL_DIR@ -includedir=/usr/include/location +exec_prefix=@PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@/location Name: @PC_NAME@ Description: @PACKAGE_DESCRIPTION@ Version: @VERSION@ -Requires: @PC_REQUIRED@ +Requires: @PC_REQUIRED@ Libs: -L${libdir} @PC_LDFLAGS@ Cflags: -I${includedir} diff --git a/doc/location-manager-doc.h b/doc/location-manager-doc.h new file mode 100644 index 0000000..ada3251 --- /dev/null +++ b/doc/location-manager-doc.h @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.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 + * limitations under the License. + */ + + +#ifndef __TIZEN_LOCATION_LOCATION_MANAGER_DOC_H__ +#define __TIZEN_LOCATION_LOCATION_MANAGER_DOC_H__ + +/** + * @ingroup CAPI_LOCATION_FRAMEWORK + * @defgroup CAPI_LOCATION_MANAGER_MODULE Location Manager + * @brief This Location Manager API provides functions for obtaining information related to geographical location. + * This API provides functions to acquire information related to the current position. Notifications on events like service becoming + * enabled or disabled, new position data being available and others can also be acquired. + * + * @section CAPI_LOCATION_MANAGER_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_LOCATION_MANAGER_MODULE_OVERVIEW Overview + * The Location Manager API provides functions to acquire information about geographical location, including both as accurate a current position as possible, + * and receiving notification of changes in position, crossing boundary "fences", and velocity changes detected by the device. + * + * The related Geolocation API can be used to convert the location to a physical address. + * + * Notifications can be received about the following events: + * - Change in service status (enabled / disabled) + * - New position and velocity information becoming available + * - Given area being entered or left (geofencing) + * + * Information on GPS satellites is provided by the GPS Status & Satellite API. + * + * The main component of the Location Service is the location manager. A location manager serves as a gateway so the application does not have + * to manage the details of the back-end connection, which might be GPS, WiFi or others, although it may instruct the location manager + * as to a preference. The location manager also manages the callback functions which it invokes when a given event takes place. + * + * The location manager has the following properties: + * - Method + * - Boundary + * - 'Position updated' callback + * - 'Service state change' callback + * - 'Velocity updated' callback + * - 'Boundary event' callback + * + * The method property of a location manager (#location_method_e) determines the source of location information. It can be set only + * once - when the location manager is instantiated. The method can be one specific location method, or hybrid. + * + * A location manager set to the hybrid method will automatically choose + * the best method available at the moment, choosing between GPS, WPS + * and WPS. Note that the method may change any time, due to signals + * coming in/out of range, and so on. If more than one method is available, + * priorities are as follows: + * + * 1. GPS\n + * 2. WPS\n + * + * If no methods are available, the service state is changed to disabled + * and the appropriate callback is called. See location_manager_set_service_state_changed_cb() and location_service_state_changed_cb(). + * + * The boundary property describes a border enclosing an area. The area + * can be circular - defined by its center in geographic coordinates a radius, or rectangular - defined by the geographic coordinates of its + * top left and bottom right corner. + * The location manager will use the selected method to track if the area has been entered or exited. + * The location manager will send asynchronous notifications by invoking + * previously registered callback functions on such change events. + * + * There may be multiple location managers. Callback functions to receive + * notifications are registered to a specific location manager, not to the location service as a whole. + * So it is, for example, possible to define several different geographic areas or fences, using different location methods, + * each being tracked by a different location manager and leading to distinct callbacks. + * + * Setting and unsetting callbacks for the manager can be done at any time, however before callbacks set for a given location manager can + * be invoked, the location service must be started for that location manager. This constraint holds for managers with GPS, WPS and + * Hybrid methods. See the Location manager life cycle section below. Note the start/stop functions apply only to + * the individual location manager and do not affect any other location managers that may be running. + * + * Only one callback can be set for a given event within the scope of a single location manager. Successive callback setting will result in + * the new callback replacing the old one. If an 'unset callback' function is called when there is no callback set, no error is returned. + * Callbacks can be set and unset any number of times. + * + * @subsection CAPI_LOCATION_MANAGER_MODULE_MANAGER_LIFECYCLE Location manager life cycle + * + * 1. Create location manager ( location_manager_create() )\n + * 2. Set callbacks and other required information\n + * 3. Start service with location_manager_start()\n + * 4. Wait until state change callback ( location_service_state_changed_cb() ) is called with #LOCATIONS_SERVICE_ENABLED as first argument\n + * 5. Other callbacks are working now, wait for events and process\n + * 6. Stop service with location_manager_stop()\n + * 7. Wait until state change callback ( location_service_state_changed_cb() ) is called with #LOCATIONS_SERVICE_DISABLED as first argument\n + * 8. Destroy location manager (location_manager_destroy())\n + * + * After stopping the location service for a given location manager, + * the location manager can still be used. So some functions can be called if they do not require a location service running on your device. + * The location service can be re-started later. + * + * If a location manager is no longer needed and is going to be destroyed, it is not mandatory to call location_manager_stop(), + * as location_manager_destroy() will call it automatically. + * + * Note that after a location manager has been destroyed, the handle (#location_manager_h) can be reused - location_manager_create() can + * be called again for this handle. In other words, the state before creation and after destruction can be treated as the same state. + * + * @section CAPI_LOCATION_MANAGER_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/location\n + * - http://tizen.org/feature/location.gps\n + * - http://tizen.org/feature/location.wps\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a devrice supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature Element. + * + */ + +/** +* @ingroup CAPI_LOCATION_MANAGER_MODULE +* @defgroup CAPI_LOCATION_GPS_STATUS_MODULE GPS Status & Satellite +* @brief The GPS Status & Satellite API provides functions to acquire information about GPS satellites in range and in use. +* +* @section CAPI_LOCATION_GPS_STATUS_MODULE_HEADER Required Header +* \#include +* +* @section CAPI_LOCATION_GPS_STATUS_MODULE_OVERVIEW Overview +* The GPS Status & Satellite API provides functions to acquire data on satellites that are currently visible to the device. Information +* like azimuth and elevation of each satellite is available, along with number of satellites in range and in use. +* +* @par System Info note: +* All of the functions require a started location manager with the #LOCATIONS_METHOD_GPS method set. See the Location Manager API for details. +* +* The gps_status_get_nmea() function gets NMEA data from the GPS system. NMEA 0183 (or NMEA for short) is a combined electrical and data +* specification for communication between electronic devices. NMEA standard uses a simple ASCII, serial communications protocol that +* defines how data is transmitted in a "sentence" from one "talker" to multiple "listeners" at a time. For more details, see NMEA_0183. +* +* The gps_status_get_satellite() method returns a count of satellites in view. The gps_status_foreach_satellites_in_view() method is an +* iterator which will invoke a callback function for each satellite in view. The gps_status_get_satellite() method returns a count of +* satellites in use. +* + * @section CAPI_LOCATION_GPS_STATUS_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/location\n + * - http://tizen.org/feature/location.gps\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a devrice supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature Element. + * +*/ + +/** + * @ingroup CAPI_LOCATION_MANAGER_MODULE + * @defgroup CAPI_LOCATION_BOUNDS_MODULE Location Bounds + * @brief The Location Bounds APIs provides functions related to geographic bounds information. + * + * + * @section CAPI_LOCATION_BOUNDS_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_LOCATION_BOUNDS_MODULE_OVERVIEW Overview + * + * Boundary defines geographical boundary. It is same as geo-fence which is a virtual perimeter for a real-world geographic area. + * If you create a boundary, you can trigger some activities when a device enters(or exits) the boundaries defined by you. + * + * @section CAPI_LOCATION_BOUNDS_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/location\n + * - http://tizen.org/feature/location.gps\n + * - http://tizen.org/feature/location.wps\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a devrice supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature Element. + * + */ + +/** + * @internal + * @{ + * @ingroup CAPI_LOCATION_FRAMEWORK + * @defgroup CAPI_LOCATION_PREF_MODULE Location Preference + * @brief The Location Preference APIs provides functions related to Maps + * Service. + * + * + * @section CAPI_LOCATION_PREF_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_LOCATION_PREF_MODULE_OVERVIEW Overview + * + * You can set some options with Location Preference when you use Maps Service(geocoder, poi, and route) module. + * + * @section CAPI_LOCATION_PREF_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/location\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a devrice supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from Feature Element. + * @} + * + */ + +#endif /* __TIZEN_LOCATION_LOCATION_MANAGER_DOC_H__ */ diff --git a/include/location_batch.h b/include/location_batch.h new file mode 100644 index 0000000..9fba862 --- /dev/null +++ b/include/location_batch.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.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 + * limitations under the License. + */ + +#ifndef __TIZEN_LOCATION_BATCH_H__ +#define __TIZEN_LOCATION_BATCH_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @internal + * @{ + * @addtogroup CAPI_LOCATION_MANAGER_MODULE + * @{ + */ + +/** + * @brief Called when the batch interval is expired. + * @param[in] num_of_location The number of location batch data + * @param[in] user_data The user data passed from the callback registration function + */ +typedef void(*location_batch_cb)(int num_of_location, void *user_data); + +/** + * @brief Gets called iteratively to receive location batch data. + * @param[in] latitude The updated latitude [-90.0 ~ 90.0] (degrees) + * @param[in] longitude The updated longitude [-180.0 ~ 180.0] (degrees) + * @param[in] altitude The updated altitude (meters) + * @param[in] speed The updated speed (km/h) + * @param[in] direction The updated direction (in degrees from the north) + * @param[in] horizontal The horizontal accuracy (meters) + * @param[in] vertical The vertical accuracy (meters) + * @param[in] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @param[in] user_data The user data passed from the callback registration function + * @pre location_batch_get_location_cb() will invoke this callback if you register this callback using location_manager_foreach_location_batch() + */ +typedef bool(*location_batch_get_location_cb)(double latitude, double longitude, double altitude, double speed, double direction, double horizontal, double vertical, time_t timestamp, void *user_data); + +/** + * @brief Registers a callback function to be invoked when batch_period is expired. + * @param[in] manager The location manager handle + * @param[in] callback The callback function to register + * @param[in] batch_interval The batch smpling interval + * @param[in] batch_period The batch period + * @post location_batch_cb() will be invoked + */ +int location_manager_set_location_batch_cb(location_manager_h manager, location_batch_cb callback, int batch_interval, int batch_period, void *user_data); + +/** + * @brief Unregisters the callback function. + * @param[in] manager The location manager handle + */ +int location_manager_unset_location_batch_cb(location_manager_h manager); + +/** + * @brief Start the location batch mode. + * @param[in] manager The location manager handle + */ +int location_manager_start_batch(location_manager_h manager); + +/** + * @brief Stop the location batch mode. + * @param[in] manager The location manager handle + */ +int location_manager_stop_batch(location_manager_h manager); + +/** + * @brief Retrieves all location information by invoking a specific callback for each location data. + * @param[in] manager The location manager handle + * @param[in] callback The iteration callback function + * @param[in] user_data The user data passed from the callback registration function + * @post location_batch_get_location_cb() will be invoked + */ +int location_manager_foreach_location_batch(location_manager_h manager, location_batch_get_location_cb callback, void *user_data); + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_LOCATION_BATCH_H__ */ diff --git a/include/location_bounds.h b/include/location_bounds.h index 5889a99..05526ed 100644 --- a/include/location_bounds.h +++ b/include/location_bounds.h @@ -24,7 +24,7 @@ extern "C" { #endif -#define LOCATION_BOUNDS_ERROR_CLASS TIZEN_ERROR_LOCATION_CLASS | 0x20 +#define LOCATION_BOUNDS_ERROR_CLASS TIZEN_ERROR_LOCATION_MANAGER | 0x20 /** * @addtogroup CAPI_LOCATION_BOUNDS_MODULE @@ -32,54 +32,56 @@ extern "C" { */ /** - * @brief Represents a coordinates with latitude and longitude. + * @brief The structure type to represent coordinates with latitude and longitude. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -typedef struct -{ +typedef struct { double latitude; /**< The latitude [-90.0 ~ 90.0] (degrees) */ double longitude; /**< The longitude [-180.0 ~ 180.0] (degrees) */ } location_coords_s; /** - * @brief Enumerations of error code for Location manager. + * @brief Enumeration for error code for Location manager. */ -typedef enum -{ - LOCATION_BOUNDS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ +typedef enum { + LOCATION_BOUNDS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - LOCATION_BOUNDS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - LOCATION_BOUNDS_ERROR_INCORRECT_TYPE = LOCATION_BOUNDS_ERROR_CLASS | 0x01, /**< Incorrect bounds type for a given call */ + LOCATION_BOUNDS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + LOCATION_BOUNDS_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ + LOCATION_BOUNDS_ERROR_INCORRECT_TYPE = LOCATION_BOUNDS_ERROR_CLASS | 0x01, /**< Incorrect bounds type for a given call */ LOCATION_BOUNDS_ERROR_IS_ADDED = LOCATION_BOUNDS_ERROR_CLASS | 0x02, /**< Cannot remove bounds handle from location manager */ } location_bound_error_e; /** - * @brief Location boundary type. + * @brief Enumeration for Location boundary type. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -typedef enum -{ - LOCATION_BOUNDS_RECT = 1, /**< Rectangular geographical area type. */ - LOCATION_BOUNDS_CIRCLE, /**< Circle geographical area type.. */ - LOCATION_BOUNDS_POLYGON, /**< Polygon geographical area type.. */ +typedef enum { + LOCATION_BOUNDS_RECT = 1, /**< Rectangular geographical area type. */ + LOCATION_BOUNDS_CIRCLE, /**< Circle geographical area type.. */ + LOCATION_BOUNDS_POLYGON, /**< Polygon geographical area type.. */ } location_bounds_type_e; /** - * @brief Enumerations of the boundary state. + * @brief Enumeration for the boundary state. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -typedef enum -{ - LOCATIONS_BOUNDARY_IN, /**< Boundary In (Zone In) */ - LOCATIONS_BOUNDARY_OUT /**< Boundary Out (Zone Out) */ +typedef enum { + LOCATIONS_BOUNDARY_IN, /**< Boundary In (Zone In) */ + LOCATIONS_BOUNDARY_OUT /**< Boundary Out (Zone Out) */ } location_boundary_state_e; /** * @brief The location boundary handle. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef struct location_bounds_s *location_bounds_h; /** - * @brief Gets called iteratively to notify you of coordinates of polygon. - * @param[in] coords The coordinates - * @param[in] user_data The user data passed from the foreach function + * @brief Gets called iteratively to notify you of coordinates of a polygon. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] coords The coordinates + * @param[in] user_data The user data passed from the foreach function * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop * @pre location_bounds_foreach_polygon_coords() will invoke this callback. * @see location_bounds_foreach_polygon_coords() @@ -88,7 +90,8 @@ typedef bool (*polygon_coords_cb)(location_coords_s coords, void *user_data); /** * @brief Called when the given boundary is entered or exited. - * @param[in] state The boundary state + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] state The boundary state * @pre location_manager_start() will invoke this callback if you register this callback using location_bounds_set_state_changed_cb() * @see #location_boundary_state_e * @see location_manager_start() @@ -98,56 +101,67 @@ typedef void (*location_bounds_state_changed_cb)(location_boundary_state_e state /** * @brief Creates a rect type of new location bounds. - * @remarks @a bounds must be released location_bounds_destroy() by you. - * @param[in] top_left The top left position - * @param[in] bottom_right The bottom right position - * @param[out] bounds A location bounds handle to be newly created on success - * @return 0 on success, otherwise a negative error value. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks You must release @a bounds using location_bounds_destroy(). + * @param[in] top_left The top left position + * @param[in] bottom_right The bottom right position + * @param[out] bounds The location bounds handle that is newly created + * @return @c 0 on success, otherwise a negative error value. * @retval #LOCATION_BOUNDS_ERROR_NONE Successful * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported * @see location_bounds_get_rect_coords() * @see location_bounds_destroy() */ -int location_bounds_create_rect(location_coords_s top_left, location_coords_s bottom_right, location_bounds_h* bounds); +int location_bounds_create_rect(location_coords_s top_left, location_coords_s bottom_right, location_bounds_h *bounds); /** * @brief Creates a circle type of new location bounds. - * @remarks @a bounds must be released location_bounds_destroy() by you. - * @param[in] center The center position - * @param[in] radius The radius of a circle (meters) - * @param[out] bounds A location bounds handle to be newly created on success - * @return 0 on success, otherwise a negative error value. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks You must release @a bounds using location_bounds_destroy(). + * @param[in] center The center position + * @param[in] radius The radius of a circle (meters) + * @param[out] bounds The location bounds handle that is newly created + * @return @c 0 on success, otherwise a negative error value * @retval #LOCATION_BOUNDS_ERROR_NONE Successful * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported * @see location_bounds_get_circle_coords() * @see location_bounds_destroy() */ -int location_bounds_create_circle(location_coords_s center, double radius, location_bounds_h* bounds); +int location_bounds_create_circle(location_coords_s center, double radius, location_bounds_h *bounds); /** * @brief Creates a polygon type of new location bounds. - * @remarks @a bounds must be released location_bounds_destroy() by you. - * @remarks @a length sholud be over than 3 to represent polygon. - * @param[in] coords_list The list of coordinates - * @param[in] length The length of the coordinates list - * @param[out] bounds A location bounds handle to be newly created on success - * @return 0 on success, otherwise a negative error value. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks You must release @a bounds using location_bounds_destroy(). + * @remarks @a length should be more than @c 3 to represent polygon. + * @param[in] coords_list The list of coordinates + * @param[in] length The length of the coordinates list + * @param[out] bounds The location bounds handle that is newly created on success + * @return @c 0 on success, otherwise a negative error value * @retval #LOCATION_BOUNDS_ERROR_NONE Successful * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported * @see location_bounds_foreach_polygon_coords() * @see location_bounds_destroy() */ -int location_bounds_create_polygon(location_coords_s* coords_list, int length, location_bounds_h* bounds); +int location_bounds_create_polygon(location_coords_s *coords_list, int length, location_bounds_h *bounds); /** - * @brief Check if the bounds contains the specified coordinates. - * @param[in] bounds The location bounds handle - * @param[in] coords The coordinates - * @param[out] contained The result indicating whether the boundary contains the specified coordinate (@c true = contained, @c false = not contained ) - * @return @c true if the bouns contains the specified coordinates. \n else @c false + * @brief Checks whether the bounds contains the specified coordinates. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remark The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section. + * @param[in] bounds The location bounds handle + * @param[in] coords The coordinates + * @return @c true if the bounds contains the specified coordinates, otherwise else @c false + * @exception #LOCATION_BOUNDS_ERROR_NONE Successful + * @exception #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory + * @exception #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported * @see location_bounds_create_rect() * @see location_bounds_create_circle() * @see location_bounds_create_polygon() @@ -155,12 +169,14 @@ int location_bounds_create_polygon(location_coords_s* coords_list, int length, l bool location_bounds_contains_coordinates(location_bounds_h bounds, location_coords_s coords); /** - * @brief Get the type of location bounds. - * @param[in] bounds The location bounds handle - * @param[out] type The type of location bounds - * @return 0 on success, otherwise a negative error value. + * @brief Gets the type of location bounds. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] bounds The location bounds handle + * @param[out] type The type of location bounds + * @return @c 0 on success, otherwise a negative error value. * @retval #LOCATION_BOUNDS_ERROR_NONE Successful * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported * @see location_bounds_create_rect() * @see location_bounds_create_circle() * @see location_bounds_create_polygon() @@ -168,39 +184,45 @@ bool location_bounds_contains_coordinates(location_bounds_h bounds, location_coo int location_bounds_get_type(location_bounds_h bounds, location_bounds_type_e *type); /** - * @brief Get the center position and radius of circle bounds. - * @param[in] bounds The location bounds handle - * @param[out] top_left The top left position - * @param[out] bottom_right The bottom right position - * @return 0 on success, otherwise a negative error value. + * @brief Gets the center position and radius of circle bounds. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] bounds The location bounds handle + * @param[out] top_left The top left position + * @param[out] bottom_right The bottom right position + * @return @c 0 on success, otherwise a negative error value. * @retval #LOCATION_BOUNDS_ERROR_NONE Successful * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported * @retval #LOCATION_BOUNDS_ERROR_INCORRECT_TYPE Incorrect bounds type * @see location_bounds_create_rect() */ -int location_bounds_get_rect_coords(location_bounds_h bounds, location_coords_s *top_left, location_coords_s *bottom_right); +int location_bounds_get_rect_coords(location_bounds_h bounds, location_coords_s *top_left, location_coords_s *bottom_right); /** - * @brief Get the center position and radius of circle bounds. - * @param[in] bounds The location bounds handle - * @param[out] center The center position of circle - * @param[radius] center The radius of circle - * @return 0 on success, otherwise a negative error value. + * @brief Gets the center position and radius of circle bounds. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] bounds The location bounds handle + * @param[out] center The center position of the circle + * @param[out] radius The radius of the circle + * @return @c 0 on success, otherwise a negative error value. * @retval #LOCATION_BOUNDS_ERROR_NONE Successful * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported * @retval #LOCATION_BOUNDS_ERROR_INCORRECT_TYPE Incorrect bounds type * @see location_bounds_create_circle() */ -int location_bounds_get_circle_coords(location_bounds_h bounds, location_coords_s *center, double *radius); +int location_bounds_get_circle_coords(location_bounds_h bounds, location_coords_s *center, double *radius); /** - * @brief Get the coordinates of polygon. - * @param[in] bounds The location bounds handle - * @param[in] callback The geocoder get positions callback function - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. + * @brief Get the coordinates of a polygon. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] bounds The location bounds handle + * @param[in] callback The geocoder get position callback function + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value. * @retval #LOCATION_BOUNDS_ERROR_NONE Successful * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported * @retval #LOCATION_BOUNDS_ERROR_INCORRECT_TYPE Incorrect bounds type * @post It invokes polygon_coords_cb() to get coordinates of polygon. * @see polygon_coords_cb() @@ -210,10 +232,12 @@ int location_bounds_foreach_polygon_coords(location_bounds_h bounds, polygon_coo /** * @brief Releases the location bounds. - * @param[in] bounds The location bounds handle - * @return 0 on success, otherwise a negative error value. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] bounds The location bounds handle + * @return @c 0 on success, otherwise a negative error value. * @retval #LOCATION_BOUNDS_ERROR_NONE Successful * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported * @see location_bounds_create_rect() * @see location_bounds_create_circle() * @see location_bounds_create_polygon() @@ -221,25 +245,29 @@ int location_bounds_foreach_polygon_coords(location_bounds_h bounds, polygon_coo int location_bounds_destroy(location_bounds_h bounds); /** - * @brief Registers a callback function to be invoked when boundary area is entered or exited. - * @param[in] bounds The location bounds handle - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. + * @brief Registers a callback function to be invoked when the boundary area is entered or exited. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] bounds The location bounds handle + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value. * @retval #LOCATION_BOUNDS_ERROR_NONE Successful * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported * @post location_bounds_state_changed_cb() will be invoked * @see location_bounds_unset_state_changed_cb() * @see location_bounds_state_changed_cb() */ -int location_bounds_set_state_changed_cb(location_bounds_h bounds, location_bounds_state_changed_cb callback, void* user_data); +int location_bounds_set_state_changed_cb(location_bounds_h bounds, location_bounds_state_changed_cb callback, void *user_data); /** * @brief Unregisters the callback function. - * @param[in] bounds The location bounds handle - * @return 0 on success, otherwise a negative error value. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] bounds The location bounds handle + * @return @c 0 on success, otherwise a negative error value. * @retval #LOCATION_BOUNDS_ERROR_NONE Successful * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATION_BOUNDS_ERROR_NOT_SUPPORTED Not supported * @see location_bounds_set_state_changed_cb() */ int location_bounds_unset_state_changed_cb(location_bounds_h bounds); diff --git a/include/location_internal.h b/include/location_internal.h new file mode 100644 index 0000000..cbb2668 --- /dev/null +++ b/include/location_internal.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.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 + * limitations under the License. + */ + +#ifndef __TIZEN_LOCATION_INTERNAL_H__ +#define __TIZEN_LOCATION_INTERNAL_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "CAPI_LOCATION_MANAGER" + + +/* +* Internal Macros +*/ +#define LOCATIONS_LOGD(fmt,args...) LOGD(fmt, ##args) +#define LOCATIONS_LOGW(fmt,args...) LOGW(fmt, ##args) +#define LOCATIONS_LOGI(fmt,args...) LOGI(fmt, ##args) +#define LOCATIONS_LOGE(fmt,args...) LOGE(fmt, ##args) + +#define LOCATIONS_CHECK_CONDITION(condition, error, msg) \ + do { \ + if (condition) { \ + } else { \ + LOCATIONS_LOGE("%s(0x%08x)", msg, error); \ + return error; \ + } \ + } while (0) + + +#define LOCATIONS_PRINT_ERROR_CODE(error, msg) \ + do { \ + LOCATIONS_LOGE("%s(0x%08x)", msg, error); \ + return error; \ + } while (0) + +#define LOCATIONS_NULL_ARG_CHECK(arg) \ + LOCATIONS_CHECK_CONDITION((arg != NULL),LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER") \ + +#define LOCATIONS_NOT_SUPPORTED_CHECK(arg) \ + LOCATIONS_CHECK_CONDITION((arg == LOCATIONS_ERROR_NONE),LOCATIONS_ERROR_NOT_SUPPORTED,"LOCATIONS_ERROR_NOT_SUPPORTED") \ + +typedef enum { + _LOCATIONS_EVENT_TYPE_SERVICE_STATE, + _LOCATIONS_EVENT_TYPE_POSITION, + _LOCATIONS_EVENT_TYPE_VELOCITY, + _LOCATIONS_EVENT_TYPE_BOUNDARY, + _LOCATIONS_EVENT_TYPE_SATELLITE, + _LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS, + _LOCATIONS_EVENT_TYPE_COLLECTION_STATE, + _LOCATIONS_EVENT_TYPE_LOCATION, + _LOCATIONS_EVENT_TYPE_BATCH, + _LOCATIONS_EVENT_TYPE_DISTANCE, + _LOCATIONS_EVENT_TYPE_POS_VEL, + _LOCATIONS_EVENT_TYPE_NUM +} +_location_event_e; + +typedef enum { + _LOCATION_SIGNAL_SERVICE_ENABLED, + _LOCATION_SIGNAL_SERVICE_DISABLED, + _LOCATION_SIGNAL_SERVICE_UPDATED, + _LOCATION_SIGNAL_ZONE_IN, + _LOCATION_SIGNAL_ZONE_OUT, + _LOCATION_SIGNAL_LOCATION_UPDATED, + _LOCATION_SIGNAL_BATCH_UPDATED, + _LOCATION_SIGNAL_ERROR_EMITTED, + _LOCATION_SIGNAL_NUM +} _location_signal_e; + +typedef struct _location_manager_s { + LocationObject *object; + const void *user_cb[_LOCATIONS_EVENT_TYPE_NUM]; + void *user_data[_LOCATIONS_EVENT_TYPE_NUM]; + location_method_e method; + bool is_continue_foreach_bounds; + int collection_state; + GList *bounds_list; + guint timeout; + gulong sig_id[_LOCATION_SIGNAL_NUM]; +} location_manager_s; + +typedef struct _location_bounds_s { + LocationBoundary *boundary; + const void *user_cb; + void *user_data; + bool is_added; +} location_bounds_s; + +typedef struct _location_setting_changed_s { + location_setting_changed_cb callback; + void *user_data; +} location_setting_changed_s; + +/* +* Internal Functions +*/ +int __convert_error_code(int code); +int __is_gps_supported(void); +int __is_wps_supported(void); +int __is_location_supported(void); +int __set_callback(_location_event_e type, location_manager_h manager, void *callback, void *user_data); +int __unset_callback(_location_event_e type, location_manager_h manager); + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_LOCATION_INTERNAL_H__ */ diff --git a/include/location_preference.h b/include/location_preference.h deleted file mode 100644 index db780a6..0000000 --- a/include/location_preference.h +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.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 - * limitations under the License. - */ - -#ifndef __TIZEN_LOCATION_LOCATION_PREFERENCE_H__ -#define __TIZEN_LOCATION_LOCATION_PREFERENCE_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * @addtogroup CAPI_LOCATION_PREF_MODULE - * @{ - */ - -/** - * @brief The handle of location service - */ -typedef void* location_service_h; - - -/** - * @brief Gets a handle of location service from x - */ -#define GET_LOCATION_SERVICE(x) (location_service_h)(x) - - -/** - * @brief Enumerations of error code for Location Preference - */ -typedef enum -{ - LOCATION_PREFERENCE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND = TIZEN_ERROR_LOCATION_CLASS|0x0101, /**< Result not found */ - LOCATION_PREFERENCE_ERROR_NETWORK_FAILED = TIZEN_ERROR_LOCATION_CLASS|0x0102, /**< Network unavailable */ - LOCATION_PREFERENCE_ERROR_INVALID_KEY = TIZEN_ERROR_LOCATION_CLASS | 0x0103, /**< Invalid key */ -} location_preference_error_e; - -/** - * @brief Enumerations of distance unit - */ -typedef enum -{ - LOCATION_PREFERENCE_DISTANCE_UNIT_M = 0, /**< Meter */ - LOCATION_PREFERENCE_DISTANCE_UNIT_KM = 1, /**< Kilometer */ - LOCATION_PREFERENCE_DISTANCE_UNIT_FT = 2, /**< Feet */ - LOCATION_PREFERENCE_DISTANCE_UNIT_YD = 3, /**< Mile */ - LOCATION_PREFERENCE_DISTANCE_UNIT_MI = 4, /**< Mile */ -} location_preference_distance_unit_e; - -/** - * @brief Called repeatedly when you get the available property keys. - * @param[in] key The property key of location preference - * @param[in] user_data The user data passed from foreach function - * @pre location_preference_foreach_available_property_keys() will invoke this callback. - * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop - * @see location_preference_foreach_available_property_keys() - */ -typedef bool (*location_preference_available_property_key_cb)(const char* key, void* user_data); - -/** - * @brief Called repeatedly when you get the available property values. - * @param[in] value The property value of location preference - * @param[in] user_data The user data passed from foreach function - * @pre location_preference_foreach_available_property_values() will invoke this callback. - * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop - * @see location_preference_foreach_available_property_values() - */ -typedef bool (*location_preference_available_property_value_cb)(const char* value, void* user_data); - -/** - * @brief Called repeatedly when you get the available languages. - * @param[in] language The language of location preference - * @param[in] user_data The user data passed from foreach function - * @pre location_preference_foreach_available_languages() will invoke this callback. - * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop - * @see location_preference_foreach_available_languages() - */ -typedef bool (*location_preference_available_language_cb)(const char* language, void* user_data); - -/** - * @brief Called repeatedly when you get the available country code. - * @param[in] country_code The country code of location preference - * @param[in] user_data The user data passed from foreach function - * @pre location_preference_foreach_available_country_code() will invoke this callback. - * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop - * @see location_preference_foreach_available_country_code() - */ -typedef bool (*location_preference_available_country_code_cb)(const char* country_code, void* user_data); - -/** - * @brief Called repeatedly when you get the properties that was set in location preference. - * @param[in] key The property key of location preference - * @param[in] value The property value of location preference - * @param[in] user_data The user data passed from foreach function - * @pre location_preference_foreach_properties() will invoke this callback. - * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop - * @see location_preference_foreach_properties() - */ -typedef bool (*location_preference_property_cb)(const char* key, const char* value, void* user_data); - -/** - * @brief Called repeatedly to get each supported providers. - * @param[in] provider The supported provider name - * @param[in] user_data The user data passed from the foreach function - * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop. - * @pre location_preference_foreach_supported_provider() will invoke this callback. - * @see location_preference_foreach_supported_provider() - */ -typedef bool (*location_preference_supported_provider_cb)(const char* provider, void *user_data); - -/** - * @brief Retrieves the available property keys of location preference. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] callback The callback function to be invoked - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #LOCATION_PREFERENCE_ERROR_NETWORK_FAILED Network unavailable - * @retval #LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND Result not found - * @post location_preference_available_property_key_cb() will be invoked. - * @see GET_LOCATION_SERVICE() - * @see location_preference_available_property_key_cb() - * @see location_preference_foreach_available_property_values() - */ -int location_preference_foreach_available_property_keys(location_service_h service, location_preference_available_property_key_cb callback, void* user_data); - -/** - * @brief Retrieves the available property values of location preference. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] key The property of location preference - * @param[in] callback The callback function to be invoked - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_KEY Invalid key - * @retval #LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND Result not found - * @post location_preference_available_property_value_cb() will be invoked. - * @see GET_LOCATION_SERVICE() - * @see location_preference_available_property_value_cb() - * @see location_preference_foreach_available_property_keys() - */ -int location_preference_foreach_available_property_values(location_service_h service, const char* key, location_preference_available_property_value_cb callback, void* user_data); - -/** - * @brief Retrieves the available languages of location preference. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] callback The callback function to be invoked - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #LOCATION_PREFERENCE_ERROR_NETWORK_FAILED Network unavailable - * @retval #LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND Result not found - * @post location_preference_available_language_cb() will be invoked. - * @see GET_LOCATION_SERVICE() - * @see location_preference_available_language_cb() - */ -int location_preference_foreach_available_languages(location_service_h service, location_preference_available_language_cb callback, void* user_data); - -/** - * @brief Retrieves the available country code of location preference. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] callback The callback function to be invoked - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #LOCATION_PREFERENCE_ERROR_NETWORK_FAILED Network unavailable - * @retval #LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND Result not found - * @post location_preference_available_country_code_cb() will be invoked. - * @see GET_LOCATION_SERVICE() - * @see location_preference_available_country_code_cb() - */ -int location_preference_foreach_available_country_code(location_service_h service, location_preference_available_country_code_cb callback, void* user_data); - -/** - * @brief Gets the location preference that was set in location preference. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] key The property of location preference - * @param[in] callback The callback function to be invoked - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - */ -int location_preference_foreach_properties(location_service_h service, location_preference_property_cb callback, void* user_data); - -/** - * @brief Sets the location preference value. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] property The property of location preference - * @param[in] value The value of location preference - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - * @see location_preference_foreach_available_property_keys() - * @see location_preference_foreach_available_property_values() - * @see location_preference_get() - */ -int location_preference_set(location_service_h service, const char* key, const char* value); - -/** - * @brief Gets the location preference value. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] property The property of location preference - * @param[out] value The value of location preference - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_KEY Invalid key - * @see GET_LOCATION_SERVICE() - * @see location_preference_foreach_available_property_keys() - * @see location_preference_set() - */ -int location_preference_get(location_service_h service, const char* key, char** value); - -__attribute__ ((deprecated)) int location_preference_get_provider_name(location_service_h service, char** provider); - -/** - * @brief Sets the provider of location service. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] provider The provider name of location service - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - * @see location_preference_get_provider() - */ -int location_preference_set_provider(location_service_h service, char* provider); - -/** - * @brief Gets the provider of location service. - * @remarks The @a provider must be released with free() by you. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[out] provider The provider name of location service - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - * @see location_preference_set_provider() - */ -int location_preference_get_provider(location_service_h service, char** provider); - -/** - * @brief Gets the default provider of location service. - * @remarks The @a provider must be released with free() by you. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[out] provider The default provider name of location service - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - */ -int location_preference_get_default_provider(location_service_h service, char** provider); - -/** - * @brief Gets the provider of location service. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] callback The callback function to be invoked - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @post This function invokes location_preference_supported_provider_cb() to get all supported providers. - * @see GET_LOCATION_SERVICE() - * @see location_preference_set_provider() - */ -int location_preference_foreach_supported_provider(location_service_h service, location_preference_supported_provider_cb callback , void *user_data); - -/** - * @brief Gets the distance unit of location service. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[out] unit The distance unit - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND Result not found - * @see GET_LOCATION_SERVICE() - * @see location_preference_set_distance_unit() - */ -int location_preference_get_distance_unit(location_service_h service, location_preference_distance_unit_e* unit); - -/** - * @brief Sets the distance unit of location service. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] unit The distance unit - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - * @see location_preference_get_distance_unit() - */ -int location_preference_set_distance_unit(location_service_h service, location_preference_distance_unit_e unit); - -/** - * @brief Gets the language of location service. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[out] language The language - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - * @see location_preference_set_language() - */ -int location_preference_get_language(location_service_h service, char** language); - -/** - * @brief Sets the language of location service. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] language The language - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - * @see location_preference_get_language() - */ -int location_preference_set_language(location_service_h service, const char* language); - -/** - * @brief Sets the country code. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] country_code The country code - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - * @see location_preference_get_country_code() - */ -int location_preference_set_country_code(location_service_h service, const char* country_code); - -/** - * @brief Gets the country code. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[out] country_code The country code - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - * @see location_preference_set_country_code() - */ -int location_preference_get_country_code(location_service_h service, char** country_code); - -/** - * @brief Sets the account. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[in] maps_key The maps key - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - * @see location_preference_get_maps_key() - */ -int location_preference_set_maps_key(location_service_h service, const char* maps_key); - -/** - * @brief Gets the account. - * @param[in] location_service The memory pointer of location service handle. - * It must be converted into location_service_h by GET_LOCATION_SERVICE(). - * @param[out] maps_key The maps key - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful - * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER Invalid parameter - * @see GET_LOCATION_SERVICE() - * @see location_preference_set_maps_key() - */ -int location_preference_get_maps_key(location_service_h service, char** maps_key); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_LOCATION_LOCATION_PREFERENCE_H__ */ diff --git a/include/locations.h b/include/locations.h index 581be11..35e69e3 100644 --- a/include/locations.h +++ b/include/locations.h @@ -32,68 +32,70 @@ extern "C" { */ /** - * @brief Enumerations of error code for Location manager. - */ -typedef enum -{ - LOCATIONS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - LOCATIONS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - LOCATIONS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - LOCATIONS_ERROR_INCORRECT_METHOD = TIZEN_ERROR_LOCATION_CLASS | 0x01, /**< Location manager contains incorrect method for a given call */ - LOCATIONS_ERROR_NETWORK_FAILED = TIZEN_ERROR_LOCATION_CLASS | 0x02, /**< Network unavailable */ - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE = TIZEN_ERROR_LOCATION_CLASS | 0x03, /**< Location service is not available */ - LOCATIONS_ERROR_GPS_SETTING_OFF = TIZEN_ERROR_LOCATION_CLASS | 0x04, /**< GPS/WPS setting is not enabled */ - LOCATIONS_ERROR_SECURITY_RESTRICTED = TIZEN_ERROR_LOCATION_CLASS | 0x05, /**< Restricted by security system policy */ - LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED = TIZEN_ERROR_LOCATION_CLASS | 0x06, /**< Location service accessibility is not allowed */ + * @brief Enumeration for error code for Location manager. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum { + LOCATIONS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + LOCATIONS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + LOCATIONS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + LOCATIONS_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ + LOCATIONS_ERROR_INCORRECT_METHOD = TIZEN_ERROR_LOCATION_MANAGER | 0x01, /**< Location manager contains incorrect method for a given call */ + LOCATIONS_ERROR_NETWORK_FAILED = TIZEN_ERROR_LOCATION_MANAGER | 0x02, /**< Network unavailable */ + LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE = TIZEN_ERROR_LOCATION_MANAGER | 0x03, /**< Location service is not available */ + LOCATIONS_ERROR_GPS_SETTING_OFF = TIZEN_ERROR_LOCATION_MANAGER | 0x04, /**< GPS/WPS setting is not enabled */ + LOCATIONS_ERROR_SECURITY_RESTRICTED = TIZEN_ERROR_LOCATION_MANAGER | 0x05, /**< Restricted by security system policy */ } location_error_e; + /** - * @brief Location method type. + * @brief Enumeration for Location method type. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -typedef enum -{ - LOCATIONS_METHOD_NONE=-1, /**< Undefined method. */ - LOCATIONS_METHOD_HYBRID, /**< This method selects the best method available at the moment. */ - LOCATIONS_METHOD_GPS, /**< This method uses Global Positioning System. */ - LOCATIONS_METHOD_WPS, /**< This method uses Wifi Positioning System. */ - LOCATIONS_METHOD_CPS /**< This method uses Cellular Positioning System. */ +typedef enum { + LOCATIONS_METHOD_NONE = -1, /**< Undefined method */ + LOCATIONS_METHOD_HYBRID, /**< This method selects the best method available at the moment */ + LOCATIONS_METHOD_GPS, /**< This method uses Global Positioning System */ + LOCATIONS_METHOD_WPS, /**< This method uses WiFi Positioning System */ } location_method_e; /** - * @brief Approximate accuracy level of given information. + * @brief Enumeration for Approximate accuracy level of given information. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -typedef enum -{ - LOCATIONS_ACCURACY_NONE=0, /**< Invalid data. */ - LOCATIONS_ACCURACY_COUNTRY, /**< Country accuracy level. */ - LOCATIONS_ACCURACY_REGION, /**< Regional accuracy level. */ - LOCATIONS_ACCURACY_LOCALITY, /**< Local accuracy level. */ - LOCATIONS_ACCURACY_POSTALCODE, /**< Postal accuracy level. */ - LOCATIONS_ACCURACY_STREET, /**< Street accuracy level. */ - LOCATIONS_ACCURACY_DETAILED, /**< Detailed accuracy level. */ +typedef enum { + LOCATIONS_ACCURACY_NONE = 0, /**< Invalid data */ + LOCATIONS_ACCURACY_COUNTRY, /**< Country accuracy level */ + LOCATIONS_ACCURACY_REGION, /**< Regional accuracy level */ + LOCATIONS_ACCURACY_LOCALITY, /**< Local accuracy level */ + LOCATIONS_ACCURACY_POSTALCODE, /**< Postal accuracy level */ + LOCATIONS_ACCURACY_STREET, /**< Street accuracy level */ + LOCATIONS_ACCURACY_DETAILED, /**< Detailed accuracy level */ } location_accuracy_level_e; /** - * @brief Enumerations of the state of the location service. + * @brief Enumeration for the state of the location service. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -typedef enum -{ - LOCATIONS_SERVICE_DISABLED, /**< Service is disabled */ - LOCATIONS_SERVICE_ENABLED /**< Service is enabled */ +typedef enum { + LOCATIONS_SERVICE_DISABLED, /**< Service is disabled */ + LOCATIONS_SERVICE_ENABLED, /**< Service is enabled */ } location_service_state_e; /** - * @brief Enumerations of the location service accessibility state. + * @brief Enumeration for the location service accessibility state. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ -typedef enum -{ - LOCATIONS_ACCESS_STATE_NONE, /**< Not determined yet */ - LOCATIONS_ACCESS_STATE_DENIED, /**< Access denied */ - LOCATIONS_ACCESS_STATE_ALLOWED, /**< Access authorized */ +typedef enum { + LOCATIONS_ACCESS_STATE_NONE, /**< Access state is not determined */ + LOCATIONS_ACCESS_STATE_DENIED, /**< Access denied */ + LOCATIONS_ACCESS_STATE_ALLOWED, /**< Access authorized */ } location_accessibility_state_e; /** * @brief The location manager handle. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef struct location_manager_s *location_manager_h; @@ -109,12 +111,13 @@ typedef struct location_manager_s *location_manager_h; */ /** * @brief Called at defined interval with updated position information. - * @param[in] latitude The updated latitude [-90.0 ~ 90.0] (degrees) - * @param[in] longitude The updated longitude [-180.0 ~ 180.0] (degrees) - * @param[in] altitude The updated altitude (meters) - * @param[in] timestamp The timestamp (time when measurement took place or 0 if invalid) - * @param[in] user_data The user data passed from the call registration function - * @pre location_manager_start() will invoke this callback if you register this callback using location_manager_set_position_updated_cb() + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] latitude The updated latitude [-90.0 ~ 90.0] (degrees) + * @param[in] longitude The updated longitude [-180.0 ~ 180.0] (degrees) + * @param[in] altitude The updated altitude (meters) + * @param[in] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @param[in] user_data The user data passed from the call registration function + * @pre location_manager_start() will invoke this callback if you register this callback using location_manager_set_position_updated_cb(). * @see location_manager_start() * @see location_manager_set_position_updated_cb() */ @@ -122,21 +125,40 @@ typedef void(*location_position_updated_cb)(double latitude, double longitude, d /** * @brief Called at defined interval with updated velocity information. - * @param[in] speed The updated speed (km/h) - * @param[in] direction The updated direction (in degrees from the north) - * @param[in] climb The updated climb (km/h) - * @param[in] timestamp The timestamp (time when measurement took place or 0 if invalid) - * @param[in] user_data The user data passed from the callback registration function - * @pre location_manager_start() will invoke this callback if you register this callback using location_manager_set_velocity_updated_cb() + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] speed The updated speed (km/h) + * @param[in] direction The updated direction (in degrees from the north) + * @param[in] climb The updated climb (km/h) + * @param[in] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @param[in] user_data The user data passed from the callback registration function + * @pre location_manager_start() will invoke this callback if you register this callback using location_manager_set_velocity_updated_cb(). * @see location_manager_start() * @see location_manager_set_velocity_updated_cb() */ typedef void(*location_velocity_updated_cb)(double speed, double direction, double climb, time_t timestamp, void *user_data); /** + * @brief Called at defined interval with updated location information. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] error #LOCATIONS_ERROR_NONE Successful + * @param[in] latitude The updated latitude [-90.0 ~ 90.0] (degrees) + * @param[in] longitude The updated longitude [-180.0 ~ 180.0] (degrees) + * @param[in] altitude The updated altitude (meters) + * @param[in] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @param[in] speed The updated speed (km/h) + * @param[in] direction The updated direction (in degrees from the north) + * @param[in] climb The updated climb (km/h) + * @param[in] user_data The user data passed from the callback registration function + * @pre location_manager_request_single_location() will invoke this callback. + * @see location_manager_request_single_location() + */ +typedef void(*location_updated_cb)(location_error_e error, double latitude, double longitude, double altitude, time_t timestamp, double speed, double direction, double climb, void *user_data); + +/** * @brief Called when the state of location service is changed from enabled to disabled or vice versa. - * @param[in] state The service state - * @param[in] user_data The user data passed from the callback registration function + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] state The service state + * @param[in] user_data The user data passed from the callback registration function * @pre Either location_manager_start() or location_manager_stop() will invoke this callback if you register this callback using location_manager_set_service_state_changed_cb() * @see location_manager_start() * @see location_manager_stop() @@ -147,13 +169,14 @@ typedef void(*location_service_state_changed_cb)(location_service_state_e state, /** * @brief Called when the user defined zones are entered or exited. - * @param[in] state The boundary state - * @param[in] latitude The updated latitude [-90.0 ~ 90.0] (degrees) - * @param[in] longitude The updated longitude [-180.0 ~ 180.0] (degrees) - * @param[in] altitude The updated altitude (meters) - * @param[in] timestamp The timestamp (time when measurement took place or 0 if invalid) - * @param[in] user_data The user data passed from the callback registration function - * @pre location_manager_start() will invoke this callback if you register this callback using location_manager_set_zone_changed_cb() + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] state The boundary state + * @param[in] latitude The updated latitude [-90.0 ~ 90.0] (degrees) + * @param[in] longitude The updated longitude [-180.0 ~ 180.0] (degrees) + * @param[in] altitude The updated altitude (meters) + * @param[in] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @param[in] user_data The user data passed from the callback registration function + * @pre location_manager_start() will invoke this callback if you register this callback using location_manager_set_zone_changed_cb(). * @see #location_boundary_state_e * @see location_manager_start() * @see location_manager_set_zone_changed_cb() @@ -161,74 +184,173 @@ typedef void(*location_service_state_changed_cb)(location_service_state_e state, typedef void(*location_zone_changed_cb)(location_boundary_state_e state, double latitude, double longitude, double altitude, time_t timestamp, void *user_data); /** + * @brief Called when the state of location method is changed. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] method The method changed on setting + * @param[in] enable The setting value changed + * @param[in] user_data The user data passed from the callback registration function + * @pre location_setting_changed_cb() will invoke this callback if you register this callback using location_manager_set_setting_changed_cb() + * @see location_manager_set_setting_changed_cb() + * @see location_manager_unset_setting_changed_cb() + */ +typedef void(*location_setting_changed_cb)(location_method_e method, bool enable, void *user_data); + +/** * @brief Gets called iteratively to notify you of location bounds. - * @param[in] bounds The location bounds handle - * @param[in] user_data The user data passed from the callback registration function + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] bounds The location bounds handle + * @param[in] user_data The user data passed from the callback registration function * @pre location_manager_foreach_boundary() will invoke this callback. * @see location_manager_foreach_boundary() */ typedef bool(*location_bounds_cb)(location_bounds_h bounds, void *user_data); /** - * @brief Checks whether the given location method is avaliable or not. + * @brief Called at defined interval with updated location information. + * @since_tizen 2.4 + * @param[in] latitude The updated latitude [-90.0 ~ 90.0] (degrees) + * @param[in] longitude The updated longitude [-180.0 ~ 180.0] (degrees) + * @param[in] altitude The updated altitude (meters) + * @param[in] speed The updated speed (km/h) + * @param[in] direction The updated direction (in degrees from the north) + * @param[in] horizontal_accuracy The horizontal accuracy (meters) + * @param[in] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @param[in] user_data The user data passed from the callback registration function + * @pre location_manager_start() will invoke this callback if you register this callback using location_manager_set_position_updated_cb() + * @see location_manager_start() + * @see location_manager_set_distance_based_location_changed_cb() + * @see location_manager_set_location_changed_cb() + */ +typedef void(*location_changed_cb)(double latitude, double longitude, double altitude, double speed, double direction, double horizontal_accuracy, time_t timestamp, void *user_data); + +/** + * @brief Checks whether the given location method is available. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remark The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section. * @param[in] method The location method to be checked - * @return @c true if the specified location method is supported, \n else @c false + * @return @c true if the specified location method is supported, otherwise @c false if it is not available + * @exception #LOCATIONS_ERROR_NONE Successful + * @exception #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @exception #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method * @see location_manager_create() * @see location_manager_get_method() */ bool location_manager_is_supported_method(location_method_e method); +/** + * @brief Checks whether the given location method is enabled or not on setting. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] method The location method to be checked + * @param[out] enable The result value of checking the given location method + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @see location_manager_create() + * @see location_manager_set_setting_changed_cb() + * @see location_manager_unset_setting_changed_cb() + */ +int location_manager_is_enabled_method(location_method_e method, bool *enable); /** - * @brief Creates a new location manager. - * @remarks @a manager must be released location_manager_destroy() by you. - * @param[in] method The location method - * @param[out] manager A location manager handle to be newly created on success - * @return 0 on success, otherwise a negative error value. + * @platform + * @brief Enable the given location method. + * @since_tizen 2.3.1 + * @privlevel platform + * @privilege %http://tizen.org/privilege/location.enable + * @param[in] method The location method to be checked + * @param[in] enable The value to set + * @return 0 on success, otherwise a negative error value * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_OUT_OF_MEMORY Out of memory + * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED Permission denied + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @see location_manager_is_enabled_method() + * @see location_manager_create() + */ +int location_manager_enable_method(const location_method_e method, const bool enable); + +/** + * @brief Creates a new location manager. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks You must release @a manager using location_manager_destroy(). + * @param[in] method The location method + * @param[out] manager The location manager handle that is newly created + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_OUT_OF_MEMORY Out of memory * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @see location_manager_destroy() */ -int location_manager_create(location_method_e method, location_manager_h* manager); +int location_manager_create(location_method_e method, location_manager_h *manager); /** * @brief Releases the location manager. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] manager The location manager handle - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @see location_manager_create() */ int location_manager_destroy(location_manager_h manager); /** + * @brief Request to update current location once. + * @remarks Do not request to start the location service using the same manager handler + * Calling this function invokes a location service event. When the location service is updated, location_updated_cb + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @param[in] manager The location manager handle + * @param[in] timeout Timeout to stop requesting single location after + * @param[in] callback The location callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_NETWORK_FAILED Network failed + * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @post It invokes location_updated_cb(). + */ +int location_manager_request_single_location(location_manager_h manager, int timeout, location_updated_cb callback, void *user_data); + +/** * @brief Starts the location service. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location * * @remarks There is no limit on number of location managers for which this function was called. * - * Calling this function invokes a location service event. When the location service is enabled, the service state change callback - * (set using #location_manager_set_service_state_changed_cb()) notifies the user with #LOCATIONS_SERVICE_ENABLED as - * the first argument, and the service starts. \n - - * Started service is a requirement for calling these functions: + * @remarks Calling this function invokes a location service event. When the location service is enabled, the service state change callback + * (set using location_manager_set_service_state_changed_cb()) notifies the user with #LOCATIONS_SERVICE_ENABLED as + * the first argument, and the service starts. * - * location_manager_get_position(), location_manager_get_velocity(), location_manager_get_accuracy(), - * gps_status_get_nmea(), gps_status_get_satellite_count_in_view(), gps_status_foreach_satellites_in_view(), gps_status_get_active_satellite_count(). + * @remarks The started service is a requirement for calling these functions: + * location_manager_get_position(), location_manager_get_velocity(), location_manager_get_accuracy(), + * gps_status_get_nmea(), gps_status_get_satellite(), gps_status_foreach_satellites_in_view(). * - * Once you stop the service, using #location_manager_stop(), you can no longer call the functions listed above. + * @remarks Once you stop the service using location_manager_stop(), you can no longer call the functions listed above. * - * Starting and stopping the service is in the scope of the given location manager only (if there's more than one manager, - * starting and stopping should be executed for each of them separately). + * @remarks Starting and stopping the service is in the scope of the given location manager only (if there is more than one manager, + * starting and stopping should be executed for each of them separately). * - * @param[in] manager The location manager handle - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available - * @retval #LOCATIONS_ERROR_NETWORK_FAILED Network failed - * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled + * @param[in] manager The location manager handle + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_NETWORK_FAILED Network failed + * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @post It invokes location_position_updated_cb(), location_velocity_updated_cb(), location_zone_changed_cb(), and location_service_state_changed_cb(). * @see location_manager_stop() * @see location_manager_get_position() @@ -246,18 +368,20 @@ int location_manager_start(location_manager_h manager); /** * @brief Stops the location service. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks This function initiates the process of stopping the service. When the process is finished, callback set using * #location_manager_set_service_state_changed_cb() will be called, with #LOCATIONS_SERVICE_DISABLED as first argument. * When that happens, the service is stopped and the user is notified. * * You can stop and start the location manager as needed. * - * @param[in] manager The location manager handle - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available - * @retval #LOCATIONS_ERROR_NETWORK_FAILED Network failed + * @param[in] manager The location manager handle + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_NETWORK_FAILED Network failed + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @see location_manager_start() * @see location_manager_set_service_state_changed_cb() * @see location_service_state_changed_cb() @@ -266,138 +390,155 @@ int location_manager_stop(location_manager_h manager); /** * @brief Adds a bounds for a given location manager. - * @param[in] manager The location manager handle - * @param[in] bounds The location bounds handle - * @return 0 on success, otherwise a negative error value. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @param[in] bounds The location bounds handle + * @return @c 0 on success, otherwise a negative error value * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #LOCATIONS_ERROR_OUT_OF_MEMORY Out of memory + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_OUT_OF_MEMORY Out of memory + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @post It invokes location_manager_set_zone_changed_cb() when a boundary is entered or exited, if you set a callback with location_manager_set_zone_changed_cb(). * @see location_manager_remove_boundary() * @see location_manager_set_zone_changed_cb() - * @see location_manager_is_boundary_contains_coordinate() */ int location_manager_add_boundary(location_manager_h manager, const location_bounds_h bounds); /** * @brief Deletes a bounds for a given location manager. - * @param[in] manager The location manager handle - * @param[in] bounds The location bounds handle - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #LOCATIONS_ERROR_OUT_OF_MEMORY Out of memory + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @param[in] bounds The location bounds handle + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_OUT_OF_MEMORY Out of memory + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @see location_manager_add_boundary() */ int location_manager_remove_boundary(location_manager_h manager, const location_bounds_h bounds); /** - * @brief Retrieves all location bounds by invoking a specific callback for each locatoin bounds - * @param[in] manager The location manager handle - * @param[in] callback The iteration callback - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter - * @post location_bounds_cb() will be invoked + * @brief Retrieves all location bounds by invoking a specific callback for each location bounds + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @param[in] callback The iteration callback + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @post location_bounds_cb() will be invoked * @see location_manager_add_boundary() * @see location_manager_remove_boundary() * @see location_bounds_cb() */ -int location_manager_foreach_boundary(location_manager_h manager, location_bounds_cb callback, void *user_data); +int location_manager_foreach_boundary(location_manager_h manager, location_bounds_cb callback, void *user_data); /** * @brief Gets the given location manager's method. - * - * @param[in] manager The location manager handle - * @param[out] method The location method - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @param[out] method The location method + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @see location_manager_create() */ int location_manager_get_method(location_manager_h manager, location_method_e *method); /** * @brief Gets the current position information. - * @details - * The result is current altitude, latitude, and longitude, with a measurement timestamp. - * - * If @a altitude is negative, only altitude and latitude are available (fix status is 2D). - * If @a altitude is positive, fix status is 3D and returned altitude value is the result of measurement. + * @details The result contains the current altitude, latitude, and longitude, with a measurement timestamp. * - * @param[in] manager The location manager handle - * @param[out] altitude The current altitude (meters) - * @param[out] latitude The current latitude [-90.0 ~ 90.0] (degrees) - * @param[out] longitude The current longitude [-180.0 ~ 180.0] (degrees) - * @param[out] timestamp The timestamp (time when measurement took place or 0 if valid) - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available - * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @param[in] manager The location manager handle + * @param[out] altitude The current altitude (meters) + * @param[out] latitude The current latitude [-90.0 ~ 90.0] (degrees) + * @param[out] longitude The current longitude [-180.0 ~ 180.0] (degrees) + * @param[out] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() */ int location_manager_get_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, time_t *timestamp); /** * @brief Gets the current position information. - * @details - * The result is current altitude, latitude, longitude, climb, direction, speed, level, horizontal and verticalwith a measurement timestamp. - * - * If @a altitude is negative, only altitude and latitude are available (fix status is 2D). - * If @a altitude is positive, fix status is 3D and returned altitude value is the result of measurement. + * @details The result contains the current altitude, latitude, longitude, climb, direction, speed, level, horizontal and vertical with a measurement timestamp. * - * @param[in] manager The location manager handle - * @param[out] altitude The current altitude (meters) - * @param[out] latitude The current latitude [-90.0 ~ 90.0] (degrees) - * @param[out] longitude The current longitude [-180.0 ~ 180.0] (degrees) - * @param[out] climb The climb (km/h) - * @param[out] direction The direction, degrees from the north - * @param[out] speed The speed (km/h) - * @param[out] level The accuracy level - * @param[out] horizontal The horizontal accuracy (meters) - * @param[out] vertical The vertical accuracy (meters) - * @param[out] timestamp The timestamp (time when measurement took place or 0 if valid) - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available - * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @param[in] manager The location manager handle + * @param[out] altitude The current altitude (meters) + * @param[out] latitude The current latitude [-90.0 ~ 90.0] (degrees) + * @param[out] longitude The current longitude [-180.0 ~ 180.0] (degrees) + * @param[out] climb The climb (km/h) + * @param[out] direction The direction, degrees from the north + * @param[out] speed The speed (km/h) + * @param[out] level The accuracy level + * @param[out] horizontal The horizontal accuracy (meters) + * @param[out] vertical The vertical accuracy (meters) + * @param[out] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() */ int location_manager_get_location(location_manager_h manager, double *altitude, double *latitude, double *longitude, double *climb, double *direction, double *speed, location_accuracy_level_e *level, double *horizontal, double *vertical, time_t *timestamp); /** * @brief Gets the current velocity information. - * @details - * The result is current climb, direction, and speed, with a measurement timestamp. + * @details The result contains the current climb, direction, and speed, with a measurement timestamp. * - * @param[in] manager The location manager handle - * @param[out] climb The climb (km/h) - * @param[out] direction The direction, degrees from the north - * @param[out] speed The speed (km/h) - * @param[out] timestamp The timestamp (time when measurement took place or 0 if invalid) - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available - * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @param[in] manager The location manager handle + * @param[out] climb The climb (km/h) + * @param[out] direction The direction, degrees from the north + * @param[out] speed The speed (km/h) + * @param[out] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() */ int location_manager_get_velocity(location_manager_h manager, double *climb, double *direction, double *speed, time_t *timestamp); /** * @brief Gets the current accuracy information. - * @param[in] manager The location manager handle - * @param[out] level The accuracy level - * @param[out] horizontal The horizontal accuracy (meters) - * @param[out] vertical The vertical accuracy (meters) - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available - * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @param[in] manager The location manager handle + * @param[out] level The accuracy level + * @param[out] horizontal The horizontal accuracy (meters) + * @param[out] vertical The vertical accuracy (meters) + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() */ int location_manager_get_accuracy(location_manager_h manager, location_accuracy_level_e *level, double *horizontal, double *vertical); @@ -405,16 +546,19 @@ int location_manager_get_accuracy(location_manager_h manager, location_accuracy_ /** * @brief Gets the last position information which is recorded. * @details The @a altitude, @a latitude, @a longitude, and @c timestamp values should be 0, if there is no record of any previous position information. - * @details If @a altitude is negative, only altitude and latitude are available (fix status is 2D). - * @details If @a altitude is positive, fix status is 3D and returned altitude value is the result of measurement. - * @param[in] manager The location manager handle - * @param[out] altitude The last altitude (meters) - * @param[out] latitude The last latitude [-90.0 ~ 90.0] (degrees) - * @param[out] longitude The last longitude [-180.0 ~ 180.0] (degrees) - * @param[out] timestamp The timestamp (time when measurement took place or 0 if invalid) - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @param[in] manager The location manager handle + * @param[out] altitude The last altitude (meters) + * @param[out] latitude The last latitude [-90.0 ~ 90.0] (degrees) + * @param[out] longitude The last longitude [-180.0 ~ 180.0] (degrees) + * @param[out] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location manager handle must be created by location_manager_create() */ int location_manager_get_last_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, time_t *timestamp); @@ -422,22 +566,25 @@ int location_manager_get_last_position(location_manager_h manager, double *altit /** * @brief Gets the last location information. * @details The @a altitude, @a latitude, @a longitude, @a climb, @a direction, @a speed and @c timestamp values should be 0, if there is no record of any previous position information. - * @details If @a altitude is negative, only altitude and latitude are available (fix status is 2D). - * @details If @a altitude is positive, fix status is 3D and returned altitude value is the result of measurement. - * @param[in] manager The location manager handle - * @param[out] altitude The current altitude (meters) - * @param[out] latitude The current latitude [-90.0 ~ 90.0] (degrees) - * @param[out] longitude The current longitude [-180.0 ~ 180.0] (degrees) - * @param[out] climb The climb (km/h) - * @param[out] direction The direction, degrees from the north - * @param[out] speed The speed (km/h) - * @param[out] level The accuracy level - * @param[out] horizontal The horizontal accuracy (meters) - * @param[out] vertical The vertical accuracy (meters) - * @param[out] timestamp The timestamp (time when measurement took place or 0 if valid) - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @param[in] manager The location manager handle + * @param[out] altitude The current altitude (meters) + * @param[out] latitude The current latitude [-90.0 ~ 90.0] (degrees) + * @param[out] longitude The current longitude [-180.0 ~ 180.0] (degrees) + * @param[out] climb The climb (km/h) + * @param[out] direction The direction, degrees from the north + * @param[out] speed The speed (km/h) + * @param[out] level The accuracy level + * @param[out] horizontal The horizontal accuracy (meters) + * @param[out] vertical The vertical accuracy (meters) + * @param[out] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location manager handle must be created by location_manager_create() */ int location_manager_get_last_location(location_manager_h manager, double *altitude, double *latitude, double *longitude, double *climb, double *direction, double *speed, location_accuracy_level_e *level, double *horizontal, double *vertical, time_t *timestamp); @@ -445,56 +592,68 @@ int location_manager_get_last_location(location_manager_h manager, double *altit /** * @brief Gets the last velocity information which is recorded. - * @details - * The @a climb, @a direction and @a speed values should be 0, if there is no record of any previous velocity information. + * @details The @a climb, @a direction and @a speed values should be @c 0, if there is no record of any previous velocity information. * - * @param[in] manager The location manager handle - * @param[out] climb The last climb (km/h) - * @param[out] direction The last direction, degrees from the north - * @param[out] speed The last speed (km/h) - * @param[out] timestamp The timestamp (time when measurement took place or 0 if invalid) - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @param[in] manager The location manager handle + * @param[out] climb The last climb (km/h) + * @param[out] direction The last direction, degrees from the north + * @param[out] speed The last speed (km/h) + * @param[out] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location manager handle must be created by location_manager_create() */ int location_manager_get_last_velocity(location_manager_h manager, double *climb, double *direction, double *speed, time_t *timestamp); /** * @brief Gets the last accuracy information which is recorded. - * @param[in] manager The location manager handle - * @param[out] level The last accuracy level - * @param[out] horizontal The last horizontal accuracy (meters) - * @param[out] vertical The last vertical accuracy (meters) - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @param[in] manager The location manager handle + * @param[out] level The last accuracy level + * @param[out] horizontal The last horizontal accuracy (meters) + * @param[out] vertical The last vertical accuracy (meters) + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location manager handle must be created by location_manager_create() */ int location_manager_get_last_accuracy(location_manager_h manager, location_accuracy_level_e *level, double *horizontal, double *vertical); /** * @brief Gets the current application's location accessibility status. - * @param[in] manager The location manager handle - * @param[out] state The current location service accessibility status. - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[out] state The current location service accessibility status. + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported */ -int location_manager_get_accessibility_state(location_accessibility_state_e* state); +int location_manager_get_accessibility_state(location_accessibility_state_e *state); /** * @brief Registers a callback function to be invoked at defined interval with updated position information. * - * @param[in] manager The location manager handle - * @param[in] callback The callback function to register - * @param[in] interval The interval [1 ~ 120] (seconds) - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter - * @post location_position_updated_cb() will be invoked + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @param[in] callback The callback function to register + * @param[in] interval The interval [1 ~ 120] (seconds) + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @post location_position_updated_cb() will be invoked * @see location_manager_unset_position_updated_cb() * @see location_position_updated_cb() */ @@ -502,26 +661,28 @@ int location_manager_set_position_updated_cb(location_manager_h manager, locatio /** * @brief Unregisters the callback function. - * - * @param[in] manager The location manager handle - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @see location_manager_set_position_updated_cb() */ int location_manager_unset_position_updated_cb(location_manager_h manager); /** * @brief Registers a callback function to be invoked at defined interval with updated velocity information. - * - * @param[in] manager The location manager handle - * @param[in] callback The callback function to register - * @param[in] interval The interval [1 ~ 120] (seconds) - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter - * @post location_velocity_updated_cb() will be invoked + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @param[in] callback The callback function to register + * @param[in] interval The interval [1 ~ 120] (seconds) + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @post location_velocity_updated_cb() will be invoked * @see location_manager_unset_velocity_updated_cb() * @see location_velocity_updated_cb() */ @@ -529,25 +690,27 @@ int location_manager_set_velocity_updated_cb(location_manager_h manager, locatio /** * @brief Unregisters the callback function. - * - * @param[in] manager The location manager handle - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @see location_manager_set_velocity_updated_cb() */ int location_manager_unset_velocity_updated_cb(location_manager_h manager); /** - * @brief Registers a callback function to be invoked when the location service state is changed. - * - * @param[in] manager The location manager handle - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter - * @post location_service_state_changed_cb() will be invoked + * @brief Registers a callback function to be invoked when the location service state is changed. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @post location_service_state_changed_cb() will be invoked * @see location_manager_unset_service_state_changed_cb() * @see location_service_state_changed_cb() * @see location_manager_start() @@ -558,10 +721,12 @@ int location_manager_set_service_state_changed_cb(location_manager_h manager, lo /** * @brief Unregisters the callback function. - * @param[in] manager The location manager handle - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @see location_manager_set_service_state_changed_cb() */ int location_manager_unset_service_state_changed_cb(location_manager_h manager); @@ -569,14 +734,16 @@ int location_manager_unset_service_state_changed_cb(location_manager_h manager); /** * @brief Registers a callback function to be invoked when the previously set boundary area is entered or left. * - * @param[in] manager The location manager handle - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter - * @pre Either location_manager_set_boundary_rect() or location_manager_set_boundary_circle() is called before. - * @post location_zone_changed_cb() will be invoked + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @pre location_manager_add_boundary() is called before. + * @post location_zone_changed_cb() will be invoked * @see location_manager_unset_zone_changed_cb() * @see location_zone_changed_cb() */ @@ -584,35 +751,117 @@ int location_manager_set_zone_changed_cb(location_manager_h manager, location_zo /** * @brief Unregisters the callback function. - * @param[in] manager The location manager handle - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] manager The location manager handle + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @see location_manager_set_zone_changed_cb() */ int location_manager_unset_zone_changed_cb(location_manager_h manager); /** + * @brief Registers a callback function to be invoked when the location setting is changed. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] method The method to observe + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @post location_setting_changed_cb() will be invoked + * @see location_manager_unset_setting_changed_cb() + * @see location_setting_changed_cb() + */ +int location_manager_set_setting_changed_cb(location_method_e method, location_setting_changed_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] method The method to observe + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @see location_manager_set_setting_changed_cb() + */ +int location_manager_unset_setting_changed_cb(location_method_e method); + +/** * @brief Gets the distance in meters between two locations. - * @param[in] start_latitude The starting latitude [-90.0 ~ 90.0] (degrees) - * @param[in] start_longitude The starting longitude [-180.0 ~ 180.0] (degrees) - * @param[in] end_latitude The ending latitude [-90.0 ~ 90.0] (degrees) - * @param[in] end_longitude The ending longitude [-180.0 ~ 180.0] (degrees) - * @param[out] distance The distance between two locations (meters) - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] start_latitude The starting latitude [-90.0 ~ 90.0] (degrees) + * @param[in] start_longitude The starting longitude [-180.0 ~ 180.0] (degrees) + * @param[in] end_latitude The ending latitude [-90.0 ~ 90.0] (degrees) + * @param[in] end_longitude The ending longitude [-180.0 ~ 180.0] (degrees) + * @param[out] distance The distance between two locations (meters) + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported */ int location_manager_get_distance(double start_latitude, double start_longitude, double end_latitude, double end_longitude, double *distance); /** - * @brief Sends command to the server. - * @param[in] cmd The command string to be sent - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @brief Registers a callback function to be invoked at minimum interval or minimum distance with updated position information. + * @since_tizen 2.4 + * @param[in] manager The location manager handle + * @param[in] callback The callback function to register + * @param[in] interval The minimum interval between position updates [1 ~ 120] (seconds) + * @param[in] distance The minimum distance between position updates [1 ~ 120] (meters) + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @post location_changed_cb() will be invoked + * @see location_manager_unset_distance_based_location_changed_cb() + * @see location_changed_cb() + */ +int location_manager_set_distance_based_location_changed_cb(location_manager_h manager, location_changed_cb callback, int interval, double distance, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 2.4 + * @param[in] manager The location manager handle + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @see location_manager_set_distance_based_location_changed_cb() */ -int location_manager_send_command(const char *cmd); +int location_manager_unset_distance_based_location_changed_cb(location_manager_h manager); + +/** + * @brief Registers a callback function to be invoked at defined interval with updated location information. + * @since_tizen 2.4 + * @param[in] manager The location manager handle + * @param[in] callback The callback function to register + * @param[in] interval The interval [1 ~ 120] (seconds) + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @post location_changed_cb() will be invoked + * @see location_manager_unset_location_changed_cb() + * @see location_changed_cb() + */ +int location_manager_set_location_changed_cb(location_manager_h manager, location_changed_cb callback, int interval, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 2.4 + * @param[in] manager The location manager handle + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @see location_manager_set_location_changed_cb() + */ +int location_manager_unset_location_changed_cb(location_manager_h manager); /** * @} @@ -628,13 +877,14 @@ int location_manager_send_command(const char *cmd); */ /** - * @brief Called once for each satellite in range. - * @param[in] azimuth The azimuth of the satellite (degrees) - * @param[in] elevation The elevation of the satellite (meters) - * @param[in] prn The PRN of the satellite - * @param[in] snr The SNR of the satellite [dB] - * @param[in] is_active The flag signaling if satellite is in use - * @param[in] user_data The user data passed from the foreach function + * @brief Called once for each satellite in range. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[in] azimuth The azimuth of the satellite (degrees) + * @param[in] elevation The elevation of the satellite (meters) + * @param[in] prn The PRN of the satellite + * @param[in] snr The SNR of the satellite [dB] + * @param[in] is_active The flag signaling if satellite is in use + * @param[in] user_data The user data passed from the foreach function * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop * @pre gps_status_foreach_satellites_in_view() will invoke this callback. * @pre gps_status_foreach_last_satellites_in_view() will invoke this callback. @@ -644,28 +894,31 @@ typedef bool(*gps_status_get_satellites_cb)(unsigned int azimuth, unsigned int e /** * @brief Called at defined interval with updated satellite information. - * @param[out] num_of_active The last number of active satellites - * @param[out] num_of_inview The last number of satellites in view - * @param[out] timestamp The last timestamp (time when last measurement took place or 0 if invalid) - * @param[in] user_data The user data passed from the call registration function + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @param[out] num_of_active The last number of active satellites + * @param[out] num_of_inview The last number of satellites in view + * @param[out] timestamp The last timestamp (time when measurement took place or @c 0 if valid) + * @param[in] user_data The user data passed from the call registration function * @pre location_manager_start() will invoke this callback if you register this callback using location_manager_set_position_updated_cb() * @see location_manager_start() * @see location_manager_set_position_updated_cb() */ -typedef void(*gps_status_satellite_updated_cb)(int num_of_active, int num_of_inview, time_t timestamp, void *user_data); +typedef void(*gps_status_satellite_updated_cb)(int num_of_active, int num_of_inview, time_t timestamp, void *user_data); /** * @brief Gets the GPS NMEA data. - * @remarks This call is valid only for location managers with #LOCATIONS_METHOD_GPS method.\n - * @a nmea must be released with @c free() by you. - * @param[in] manager The location manager handle - * @param[out] nmea The NMEA data - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument - * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available - * @retval #LOCATIONS_ERROR_OUT_OF_MEMORY Out of memory + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @remarks This call is valid only for location managers with #LOCATIONS_METHOD_GPS method. + * You must release @a nmea using @c free(). + * @param[in] manager The location manager handle + * @param[out] nmea The NMEA data + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_OUT_OF_MEMORY Out of memory + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() * @see location_manager_start() */ @@ -673,98 +926,134 @@ int gps_status_get_nmea(location_manager_h manager, char **nmea); /** * @brief Gets the information of satellites. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location * @remarks This call is valid only for location managers with #LOCATIONS_METHOD_GPS method. - * @param[in] manager The location manager handle - * @param[out] num_of_active The number of active satellites - * @param[out] num_of_inview The number of satellites in view - * @param[out] timestamp The timestamp (time when measurement took place or 0 if invalid) - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument - * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @param[in] manager The location manager handle + * @param[out] num_of_active The number of active satellites + * @param[out] num_of_inview The number of satellites in view + * @param[out] timestamp The timestamp (time when measurement took place or @c 0 if valid) + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() - * @see gps_status_foreach_satellites_in_view() + * @pre The gps_status_satellite_updated_cb must be set with gps_status_set_satellite_updated_cb() + * @see gps_status_foreach_satellites_in_view() */ -int gps_status_get_satellite(location_manager_h manager, int *num_of_active, int *num_of_inview, time_t *timestamp); +int gps_status_get_satellite(location_manager_h manager, int *num_of_active, int *num_of_inview, time_t *timestamp); /** * @brief Registers a callback function to be invoked at defined interval with updated satellite information. - * - * @param[in] manager The location manager handle - * @param[in] callback The callback function to register - * @param[in] interval The interval [1 ~ 120] (seconds) - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter - * @post gps_status_satellite_updated_cb() will be invoked + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @param[in] manager The location manager handle + * @param[in] callback The callback function to register + * @param[in] interval The interval [1 ~ 120] (seconds) + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @post gps_status_satellite_updated_cb() will be invoked * @see gps_status_unset_satellite_updated_cb() * @see gps_status_satellite_updated_cb() + * @see gps_status_get_satellite() + * @see gps_status_foreach_satellites_in_view() + * @see gps_status_get_last_satellite() + * @see gps_status_foreach_last_satellites_in_view() */ int gps_status_set_satellite_updated_cb(location_manager_h manager, gps_status_satellite_updated_cb callback, int interval, void *user_data); /** * @brief Unregisters the callback function. - * - * @param[in] manager The location manager handle - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @param[in] manager The location manager handle + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @see gps_status_set_satellite_updated_cb() */ int gps_status_unset_satellite_updated_cb(location_manager_h manager); /** * @brief Invokes the callback function for each satellite. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location * @remarks This function is valid only for location managers with the #LOCATIONS_METHOD_GPS method. - * @param[in] manager The location manager handle - * @param[in] callback The iteration callback function - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument - * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @param[in] manager The location manager handle + * @param[in] callback The iteration callback function + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() - * @post It invokes gps_status_get_satellites_cb(). - * @see gps_status_get_satellite() - * @see gps_status_get_satellites_cb() + * @pre The gps_status_satellite_updated_cb must be set with gps_status_set_satellite_updated_cb() + * @post It invokes gps_status_get_satellites_cb(). + * @see gps_status_get_satellite() + * @see gps_status_get_satellites_cb() */ -int gps_status_foreach_satellites_in_view (location_manager_h manager, gps_status_get_satellites_cb callback, void *user_data); +int gps_status_foreach_satellites_in_view(location_manager_h manager, gps_status_get_satellites_cb callback, void *user_data); /** * @brief Gets the last information of satellites. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location * @remarks This call is valid only for location managers with #LOCATIONS_METHOD_GPS method. - * @param[in] manager The location manager handle - * @param[out] num_of_active The last number of active satellites - * @param[out] num_of_inview The last number of satellites in view - * @param[out] timestamp The last timestamp (time when last measurement took place or 0 if invalid) - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument - * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @param[in] manager The location manager handle + * @param[out] num_of_active The last number of active satellites + * @param[out] num_of_inview The last number of satellites in view + * @param[out] timestamp The last timestamp (time when last measurement took place or @c 0 if valid) + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() - * @see gps_status_foreach_satellites_in_view() + * @pre The gps_status_satellite_updated_cb must be set with gps_status_set_satellite_updated_cb() + * @see gps_status_foreach_satellites_in_view() */ int gps_status_get_last_satellite(location_manager_h manager, int *num_of_active, int *num_of_inview, time_t *timestamp); /** * @brief Invokes the callback function for each last satellite which is recorded. - * @remarks This function is valid only for location managers with the #LOCATIONS_METHOD_GPS method. - * @param[in] manager The location manager handle - * @param[in] callback The iteration callback function - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #LOCATIONS_ERROR_NONE Successful - * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument - * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method - * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/location + * @remarks This function is valid only for location managers with the #LOCATIONS_METHOD_GPS method. + * @param[in] manager The location manager handle + * @param[in] callback The iteration callback function + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument + * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() - * @post It invokes gps_status_get_satellites_cb(). - * @see gps_status_get_last_satellite() - * @see gps_status_get_satellites_cb() + * @pre The gps_status_satellite_updated_cb must be set with gps_status_set_satellite_updated_cb() + * @post It invokes gps_status_get_satellites_cb(). + * @see gps_status_get_last_satellite() + * @see gps_status_get_satellites_cb() */ int gps_status_foreach_last_satellites_in_view(location_manager_h manager, gps_status_get_satellites_cb callback, void *user_data); diff --git a/include/locations_private.h b/include/locations_private.h deleted file mode 100755 index 5dd0063..0000000 --- a/include/locations_private.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.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 - * limitations under the License. - */ - -#ifndef __TIZEN_LOCATION_LOCATIONS_PRIVATE_H__ -#define __TIZEN_LOCATION_LOCATIONS_PRIVATE_H__ - -#include -#include -#include - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "CAPI_LOCATION_MANAGER" - -/* -* Internal Macros -*/ -#define LOCATIONS_LOGD(fmt,args...) LOGD(fmt, ##args) -#define LOCATIONS_LOGW(fmt,args...) LOGW(fmt, ##args) -#define LOCATIONS_LOGI(fmt,args...) LOGI(fmt, ##args) -#define LOCATIONS_LOGE(fmt,args...) LOGE(fmt, ##args) - -#define LOCATIONS_CHECK_CONDITION(condition, error, msg) \ - do { \ - if (condition) { \ - } else { \ - LOCATIONS_LOGE("%s(0x%08x)", msg, error); \ - return error; \ - } \ - } while (0) - - -#define LOCATIONS_PRINT_ERROR_CODE(error, msg) \ - do { \ - LOCATIONS_LOGE("%s(0x%08x)", msg, error); \ - return error; \ - } while (0) - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - _LOCATIONS_EVENT_TYPE_SERVICE_STATE, - _LOCATIONS_EVENT_TYPE_POSITION, - _LOCATIONS_EVENT_TYPE_VELOCITY, - _LOCATIONS_EVENT_TYPE_BOUNDARY, - _LOCATIONS_EVENT_TYPE_SATELLITE, - _LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS, - _LOCATIONS_EVENT_TYPE_NUM -} _location_event_e; - -typedef enum { - _LOCATION_SIGNAL_SERVICE_ENABLED, - _LOCATION_SIGNAL_SERVICE_DISABLED, - _LOCATION_SIGNAL_SERVICE_UPDATED, - _LOCATION_SIGNAL_ZONE_IN, - _LOCATION_SIGNAL_ZONE_OUT, - _LOCATION_SIGNAL_NUM -} _location_signal_e; - -typedef struct _location_manager_s { - LocationObject* object; - const void* user_cb[_LOCATIONS_EVENT_TYPE_NUM]; - void* user_data[_LOCATIONS_EVENT_TYPE_NUM]; - location_method_e method; - bool is_continue_foreach_bounds; - GList *bounds_list; - gulong sig_id[_LOCATION_SIGNAL_NUM]; -} location_manager_s; - -typedef struct _location_bounds_s { - LocationBoundary* boundary; - const void* user_cb; - void* user_data; - bool is_added; -} location_bounds_s; -#ifdef __cplusplus -} -#endif - -#endif //__TIZEN_LOCATION_LOCATIONS_PRIVATE_H__ diff --git a/packaging/capi-location-manager.changes b/packaging/capi-location-manager.changes index 7b07f77..aa2d833 100644 --- a/packaging/capi-location-manager.changes +++ b/packaging/capi-location-manager.changes @@ -1,3 +1,497 @@ +[Version] capi-location-manager_0.6.0 +[Date] 29 May 2015 +[Title] [ACR-225][2.4][location-manager][Add] Turn Location setting on or off; enum LOCATIONS_SERVICE_HOST_SETTING_OFF was deleted. +[Developer] Young-Ae Kang + +================================================================================ + + +[Version] capi-location-manager_0.5.2 +[Date] 17 Apr 2015 +[Title] Fixed the bug of gps_status_get_nmea(). +[Developer] Young-Ae Kang + +================================================================================ + +[Version] capi-location-manager_0.5.1 +[Date] 14 Apr 2015 +[Title] Added to support LOCATIONS_ERROR_NOT_SUPPORTED +[Developer] Kyoungjun Sung + +================================================================================ + +[Version] capi-location-manager_0.5.0 +[Date] 12 Mar 2015 +[Title] Added location_changed_cb +[New API] location_changed_cb + location_manager_set_location_changed_cb + location_manager_unset_location_changed_cb + location_manager_set_distance_based_location_changed_cb + location_manager_unset_distance_based_location_changed_cb +[Developer] Kyoungjun Sung + +================================================================================ + +[Version] capi-location-manager_0.4.0 +[Date] 17 Aug 2014 +[Title] Support multi profile build +[New API] Internal batch API + Added error types +[Developer] Kyoungjun Sung + +================================================================================ + +[Version] capi-location-manager_0.3.1 +[date] 17 Aug 2014 +[Title] Added check condition of location-manager's method to avoid crash issue.(zone-in,zone-out signal) +[Issue#] P140816-02326 +[Problem] NA +[Cause] NA +[Solution] check condition of location-manager's method. +[Developer] Youngho Jeon + +================================================================================ + +[Version] capi-location-manager_0.3.0 +[date] 12 Aug 2014 +[Title] add getter API of location setting +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] NA +[Developer] Youngho Jeon + +================================================================================ + +[Version] capi-location-manager_0.2.6 +[date] 17 Apr 2014 +[Title] Modify typo, location_preference_foreach_available_country_codes +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] NA +[Developer] Minjune Kim + +================================================================================ + +[Version] capi-location-manager_0.2.5 +[date] 16 Jan 2014 +[Title] Move geofence into libslp-location +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] NA +[Developer] Kartika Sharma + +================================================================================ + +[Version] capi-location-manager_0.2.4 +[date] 30 Dec 2013 +[Title] Requirement: Add consent popup +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] API added to just show the consent popup +[Developer] Kartika Sharma + +================================================================================ + +[Version] capi-location-manager_0.2.3 +[date] 9 Nov 2013 +[Title] Dont update satellite_cb to application before gps_status_satellite_cb is set +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] NA +[Developer] Genie Kim + +================================================================================ + +[Version] capi-location-manager_0.2.2-1 +[date] 26 Sep 2013 +[Title] Add description(reference guide) and TC for geofence service +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] NA +[Developer] Genie Kim + +================================================================================ + +[Version] capi-location-manager_0.2.1-1 +[date] 24 Sep 2013 +[Title] Add direction parameter of location_manager_get_location in location_product.h +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] NA +[Developer] Genie Kim + +================================================================================ + +[Version] capi-location-manager_0.2.0-1 +[date] 22 August 2013 +[Title] Support geofence +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] NA +[Developer] Genie Kim + +================================================================================ + +[Version] capi-location-manager_0.1.14-1 +[date] 1 July 2013 +[Title] add collectrion state callback in location_product.c +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] NA +[Developer] Genie Kim + +================================================================================ + +[Version] capi-location-manager_0.1.13-1 +[date] 27 June 2013 +[Title] Remove the duplicated signal connections/disconnections which make abort message. +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] NA +[Developer] Minjune Kim + +================================================================================ + +[Version] capi-location-manager_0.1.12-1 +[date] 31 May 2013 +[Title] Altitude can have nonpositive value +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] NA +[Developer] Genie Kim + +================================================================================ + +[Version] capi-location-manager_0.1.11-1 +[date] 17 Apr 2013 +[Title] Set an account key / Support Geofence method +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] Set an account key +[Developer] Minjune Kim + +================================================================================ + +[Version] capi-location-manager_0.1.10-1 +[date] 21 Feb 2013 +[Title] Add to get position_ext +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] Add to get position_ext +[Developer] Minjune Kim + +================================================================================ + +[Version] capi-location-manager_0.1.9-1 +[date] 6 Feb 2013 +[Title] add signal id of each g_signal & include time.h to fix build break +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] NA +[Developer] Genie Kim + +================================================================================ + +[Version] capi-location-manager_0.1.8-1 +[date] 24 Jan 2013 +[Title] change boilerplate +[Issue#] NA +[Problem] NA +[Cause] NA +[Solution] change boilerplate +[Developer] Genie Kim + +================================================================================ + * Fri May 31 2013 Anas Nashif accepted/tizen/20130520.100703@f7a18ab - Remove placeholders and cleanup spec +capi-location-manager (0.1.7-1) precise; urgency=low + + * Change Dlog Format + * Tag: capi-location-manager_0.1.7-1 + + -- Ming Zhu Fri, 28 Dec 2012 19:10:57 +0900 + +capi-location-manager (0.1.6-1) precise; urgency=low + + * get accessibility from process not location manager handle + * Tag: capi-location-manager_0.1.-1 + + -- Genie Kim Wed, 26 Dec 2012 11:10:57 +0900 + +capi-location-manager (0.1.5-1) unstable; urgency=low + + * Support the boundary state changed callback + * Tag: capi-location-manager_0.1.5-1 + + -- Genie Kim Tue, 27 Nov 2012 22:37:13 +0900 + +capi-location-manager (0.1.4-1) unstable; urgency=low + + * 1. Extends error code 2. Support to check accessibility state 3. changes prototype of location_zone_changed_cb() 4. Add available country code APIs + * Tag: capi-location-manager_0.1.4-1 + + -- Minjune Kim Wed, 21 Nov 2012 11:02:55 +0900 + +capi-location-manager (0.1.3-1) unstable; urgency=low + + * Check NULL at location_manager_get_accuracy + * Tag: capi-location-manager_0.1.3-1 + + -- Minjune Kim Tue, 18 Sep 2012 22:22:46 +0900 + +capi-location-manager (0.1.2-1) unstable; urgency=low + + * Add location_manager_get_distance, location_preference_get_country_code and location_preference_set_country_code + * Tag: capi-location-manager_0.1.2-1 + + -- Minjune Kim Mon, 20 Aug 2012 17:03:51 +0900 + +capi-location-manager (0.1.1-2) unstable; urgency=low + + * Change the type of a parameter in location_manager_get_velocity and location_manager_get_last_velocity from int to double. + * Tag: capi-location-manager_0.1.1-2 + + -- Minjune Kim Mon, 13 Aug 2012 16:42:03 +0900 + +capi-location-manager (0.1.1-1) unstable; urgency=low + + * Support to muliple provider + * Tag: capi-location-manager_0.1.1-1 + + -- Minjune Kim Wed, 01 Aug 2012 10:29:48 +0900 + +capi-location-manager (0.1.0-26) unstable; urgency=low + + * Seperate map service from location service + * Tag: capi-location-manager_0.1.0-26 + + -- Minjune Kim Fri, 27 Jul 2012 20:11:48 +0900 + +capi-location-manager (0.1.0-25) unstable; urgency=low + + * Support developer mode + * Tag: capi-location-manager_0.1.0-25 + + -- Minjune Kim Thu, 19 Jul 2012 19:58:47 +0900 + +capi-location-manager (0.1.0-24) unstable; urgency=low + + * Add the env variable, LOCATION_TEST_ENABLE + * Tag: capi-location-manager_0.1.0-24 + + -- Minjune Kim Fri, 13 Jul 2012 13:50:04 +0900 + +capi-location-manager (0.1.0-23) unstable; urgency=low + + * Apply to the grammar check for locatoin_bounds_contains_coordinates() + * Tag: capi-location-manager_0.1.0-23 + + -- Kangho Hur Tue, 26 Jun 2012 22:36:13 +0900 + +capi-location-manager (0.1.0-22) unstable; urgency=low + + * Support LOCATION_METHOD_CPS & Remove LOCATIONS_METHOD_SPS + * Tag: capi-location-manager_0.1.0-22 + + -- Minjune Kim Fri, 25 May 2012 20:21:07 +0900 + +capi-location-manager (0.1.0-21) unstable; urgency=low + + * Support the satellte information updates + * LOCATION_METHOD_SPS is not supported. + * Tag: capi-location-manager_0.1.0-21 + + -- Minjune Kim Wed, 16 May 2012 12:32:07 +0900 + +capi-location-manager (0.1.0-20) unstable; urgency=low + + * Fix a bug that getting satellite was failed when a method was hybrid. + * Tag: capi-location-manager_0.1.0-20 + + -- Minjune Kim Wed, 09 May 2012 10:06:03 +0900 + +capi-location-manager (0.1.0-19) unstable; urgency=low + + * Resolve Gcc 4.6 warning + * Tag: capi-location-manager_0.1.0-19 + + -- Kangho Hur Fri, 20 Apr 2012 17:54:51 +0900 + +capi-location-manager (0.1.0-18) unstable; urgency=low + + * Fix return value for location_bounds_is_contains_coordinates() + * Tag: capi-location-manager_0.1.0-18 + + -- Minjune Kim Tue, 03 Apr 2012 11:24:16 +0900 + +capi-location-manager (0.1.0-17) unstable; urgency=low + + * fixed TC results + * Tag: capi-location-manager_0.1.0-17 + + -- Genie Kim Thu, 22 Mar 2012 17:22:01 +0900 + +capi-location-manager (0.1.0-16) unstable; urgency=low + + * Correct bugs in location preference + * Tag: capi-location-manager_0.1.0-16 + + -- ByungWoo Lee Tue, 20 Mar 2012 21:02:48 +0900 + +capi-location-manager (0.1.0-15) unstable; urgency=low + + * Add location preference + * Tag: capi-location-manager_0.1.0-15 + + -- ByungWoo Lee Mon, 19 Mar 2012 19:37:00 +0900 + +capi-location-manager (0.1.0-14) unstable; urgency=low + + * change gps_status_get_satellite functions + * Tag: capi-location-manager_0.1.0-14 + + -- Genie Kim Wed, 14 Mar 2012 20:41:44 +0900 + +capi-location-manager (0.1.0-13) unstable; urgency=low + + * Remove the unneccesary structure (location_bounds_s) + * Tag: capi-location-manager_0.1.0-13 + + -- Kangho Hur Tue, 13 Mar 2012 16:03:12 +0900 + +capi-location-manager (0.1.0-12) unstable; urgency=low + + * Add the last position, velocity, accuracy and satellite + * Tag: capi-location-manager_0.1.0-12 + + -- Genie Kim Thu, 08 Mar 2012 14:56:28 +0900 + +capi-location-manager (0.1.0-11) unstable; urgency=low + + * Support to multiple boundaries + * Tag: capi-location-manager_0.1.0-11 + + -- Kangho Hur Tue, 06 Mar 2012 20:21:26 +0900 + +capi-location-manager (0.1.0-10) unstable; urgency=low + + * Add the location_bounds. + * Tag: capi-location-manager_0.1.0-10 + + -- Kangho Hur Fri, 02 Mar 2012 20:52:01 +0900 + +capi-location-manager (0.1.0-9) unstable; urgency=low + + * Use 'static' to local function which is limited to the current source file. + * Tag: capi-location-manager_0.1.0-9 + + -- Kangho Hur Tue, 21 Feb 2012 10:11:16 +0900 + +capi-location-manager (0.1.0-8) unstable; urgency=low + + * Apply the SOVERSION + * Tag: capi-location-manager_0.1.0-8 + + -- Kangho Hur Tue, 14 Feb 2012 17:53:09 +0900 + +capi-location-manager (0.1.0-7) unstable; urgency=low + + * Add the location_manager_get_last_known_position(), location_manager_is_supported_method(), and interval setting. + * Tag: capi-location-manager_0.1.0-7 + + -- Kangho Hur Thu, 26 Jan 2012 20:08:56 +0900 + +capi-location-manager (0.1.0-6) unstable; urgency=low + + * Apply Location Boundary changes + * Tag: capi-location-manager_0.1.0-6 + + -- Kangho Hur Wed, 07 Dec 2011 11:44:27 +0900 + +capi-location-manager (0.1.0-5) unstable; urgency=low + + * Changes the value of ERROR_NONE + * Tag: capi-location-manager_0.1.0-5 + + -- Kangho Hur Mon, 05 Dec 2011 11:18:34 +0900 + +capi-location-manager (0.1.0-4) unstable; urgency=low + + * Apply the Tizen + * Tag: capi-location-manager_0.1.0-4 + + -- Kangho Hur Wed, 23 Nov 2011 15:09:01 +0900 + +capi-location-manager (0.1.0-3) unstable; urgency=low + + * Repackage for SDK + * Tag: capi-location-manager_0.1.0-3 + + -- Kangho Hur Mon, 07 Nov 2011 21:40:30 +0900 + +capi-location-manager (0.1.0-2) unstable; urgency=low + + * Apply the error messages + * Tag: capi-location-manager_0.1.0-2 + + -- Kangho Hur Fri, 07 Oct 2011 13:28:33 +0900 + +capi-location-manager (0.1.0-1) unstable; urgency=low + + * Alpha Release + * Tag: capi-location-manager_0.1.0-1 + + -- Kangho Hur Tue, 27 Sep 2011 20:03:39 +0900 + +capi-location-manager (0.0.1-5) unstable; urgency=low + + * Add the location_manager_is_boundary_contains_coordinate() + * Tag: capi-location-manager_0.0.1-5 + + -- Kangho Hur Mon, 26 Sep 2011 19:41:49 +0900 + +capi-location-manager (0.0.1-4) unstable; urgency=low + + * gps_status_get_used_satellite_count() API name changes. + * Tag: capi-location-manager_0.0.1-4 + + -- Kangho Hur Fri, 09 Sep 2011 16:58:25 +0900 + +capi-location-manager (0.0.1-3) unstable; urgency=low + + * Remove IPS, CPS location method type + * Tag: capi-location-manager_0.0.1-3 + + -- Kangho Hur Mon, 05 Sep 2011 14:19:50 +0900 + +capi-location-manager (0.0.1-2) unstable; urgency=low + + * Rename the callback prototype + * Tag: capi-location-manager_0.0.1-2 + + -- Kangho Hur Mon, 08 Aug 2011 10:15:11 +0900 + +capi-location-manager (0.0.1-1) unstable; urgency=low + + * Initial Upload + * Tag: capi-location-manager_0.0.1-1 + + -- Kangho Hur Thu, 04 Aug 2011 16:51:02 +0900 + + diff --git a/packaging/capi-location-manager.manifest b/packaging/capi-location-manager.manifest index 017d22d..97e8c31 100644 --- a/packaging/capi-location-manager.manifest +++ b/packaging/capi-location-manager.manifest @@ -1,5 +1,5 @@ - - - + + + diff --git a/packaging/capi-location-manager.spec b/packaging/capi-location-manager.spec index 0e96a07..a93eb9d 100755 --- a/packaging/capi-location-manager.spec +++ b/packaging/capi-location-manager.spec @@ -1,18 +1,23 @@ -Name: capi-location-manager -Summary: A Location Manager library in Tizen Native API -Version: 0.1.11 -Release: 0 -Group: Location/API -License: Apache-2.0 -Source0: %{name}-%{version}.tar.gz -Source1001: capi-location-manager.manifest +Name: capi-location-manager +Summary: A Location Manager library in Tizen Native API +Version: 0.6.1 +Release: 1 +Group: Location/API +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz +Source1001: %{name}.manifest BuildRequires: cmake BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(location) +BuildRequires: pkgconfig(lbs-location) BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(vconf) +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig %description -A Location Manager library in Tizen Native API package. +A Location Manager library in Tizen Native API + %package devel Summary: A Location Manager library in Tizen Native API (Development) @@ -20,21 +25,33 @@ Group: Location/Development Requires: %{name} = %{version}-%{release} %description devel -A Location Manager library in Tizen Native API (Development) package. -%devel_desc +A Location Manager library in Tizen Native API (Development) + %prep %setup -q cp %{SOURCE1001} . %build + +export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" +export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" +export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" + MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -%__make %{?jobs:-j%jobs} +#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} \ + +make %{?jobs:-j%jobs} %install +rm -rf %{buildroot} %make_install +#mkdir -p %{buildroot}/usr/share/license +#cp LICENSE %{buildroot}/usr/share/license/%{name} + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -45,7 +62,22 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %{_libdir}/libcapi-location-manager.so.* %files devel -%manifest %{name}.manifest %{_includedir}/location/*.h %{_libdir}/pkgconfig/*.pc %{_libdir}/libcapi-location-manager.so + + +%if 1 +%package test +Summary: Test application of Location Manager +Group: Location/Testing +Requires: %{name} = %{version}-%{release} + +%description test +Test application of Location Manager + +%files test +%manifest test/capi-location-manager-test.manifest +/etc/smack/accesses.d/capi-location-manager-test.efl +/opt/usr/devel/location/location_test +%endif diff --git a/src/location_batch.c b/src/location_batch.c new file mode 100644 index 0000000..3801ae4 --- /dev/null +++ b/src/location_batch.c @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.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 + * limitations under the License. + */ + +#include +#include +#include +#include +#include "location_internal.h" +#include "location_batch.h" + + +/* +* Internal Implementation +*/ + +static void __cb_batch_updated(GObject *self, guint num_of_location, gpointer userdata) +{ + LOCATIONS_LOGD("Batch callback function has been invoked."); + location_manager_s *handle = (location_manager_s *) userdata; + + if (handle->user_cb[_LOCATIONS_EVENT_TYPE_BATCH]) { + ((location_batch_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_BATCH])(num_of_location, handle->user_data[_LOCATIONS_EVENT_TYPE_BATCH]); + } +} + +/*/////////////////////////////////////// */ +/* Location Manager */ +/*////////////////////////////////////// */ + +EXPORT_API int location_manager_set_location_batch_cb(location_manager_h manager, location_batch_cb callback, int batch_interval, int batch_period, void *user_data) +{ + LOCATIONS_LOGD("location_manager_set_location_batch_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + + LOCATIONS_CHECK_CONDITION(batch_interval >= 1 && batch_interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(batch_period >= 120 && batch_period <= 600, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_NULL_ARG_CHECK(manager); + LOCATIONS_NULL_ARG_CHECK(callback); + location_manager_s *handle = (location_manager_s *) manager; + g_object_set(handle->object, "batch-period", batch_period, NULL); + g_object_set(handle->object, "batch-interval", batch_interval, NULL); + return __set_callback(_LOCATIONS_EVENT_TYPE_BATCH, manager, callback, user_data); +} + +EXPORT_API int location_manager_unset_location_batch_cb(location_manager_h manager) +{ + LOCATIONS_LOGD("location_manager_unset_location_batch_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + return __unset_callback(_LOCATIONS_EVENT_TYPE_BATCH, manager); +} + +EXPORT_API int location_manager_start_batch(location_manager_h manager) +{ + LOCATIONS_LOGD("location_manager_start_batch"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + LOCATIONS_NULL_ARG_CHECK(manager); + location_manager_s *handle = (location_manager_s *) manager; + + if (LOCATIONS_METHOD_GPS == handle->method) { + if (!handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED]) { + handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED] = g_signal_connect(handle->object, "batch-updated", G_CALLBACK(__cb_batch_updated), handle); + } + } else { + LOCATIONS_LOGE("method is not GPS"); + } + + if (handle->user_cb[_LOCATIONS_EVENT_TYPE_BATCH] != NULL) { + LOCATIONS_LOGI("batch status set : Start"); + } + + int ret = location_start_batch(handle->object); + if (ret != LOCATION_ERROR_NONE) { + return __convert_error_code(ret); + } + + return LOCATIONS_ERROR_NONE; +} + +EXPORT_API int location_manager_stop_batch(location_manager_h manager) +{ + LOCATIONS_LOGD("location_manager_stop_batch"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + LOCATIONS_NULL_ARG_CHECK(manager); + location_manager_s *handle = (location_manager_s *) manager; + + if (LOCATIONS_METHOD_GPS == handle->method) { + if (handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED]) { + g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED]); + handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED] = 0; + } + } else { + LOCATIONS_LOGE("method is not GPS"); + } + + int ret = location_stop_batch(handle->object); + if (ret != LOCATION_ERROR_NONE) { + return __convert_error_code(ret); + } + + return LOCATIONS_ERROR_NONE; +} + +EXPORT_API int location_manager_foreach_location_batch(location_manager_h manager, location_batch_get_location_cb callback, void *user_data) +{ + LOCATIONS_LOGD("location_manager_foreach_location_batch"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + LOCATIONS_NULL_ARG_CHECK(manager); + LOCATIONS_NULL_ARG_CHECK(callback); + location_manager_s *handle = (location_manager_s *) manager; + LocationBatch *batch = NULL; + + int ret = location_get_batch(handle->object, &batch); + if (ret != LOCATION_ERROR_NONE || batch == NULL) { + if (ret == LOCATION_ERROR_NOT_SUPPORTED) { + LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); + return LOCATIONS_ERROR_INCORRECT_METHOD; + } else if (ret == LOCATION_ERROR_NOT_ALLOWED) { + LOCATIONS_LOGE("LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED"); + return LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED; + } + + LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : batch is NULL ", + LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; + } + + int i; + for (i = 0; i < batch->num_of_location; i++) { + gdouble latitude; + gdouble longitude; + gdouble altitude; + gdouble speed; + gdouble direction; + gdouble h_accuracy; + gdouble v_accuracy; + guint timestamp; + + location_get_batch_details(batch, i, &latitude, &longitude, &altitude, &speed, &direction, &h_accuracy, &v_accuracy, ×tamp); + if (callback(latitude, longitude, altitude, speed, direction, h_accuracy, v_accuracy, timestamp, user_data) != TRUE) { + break; + } + } + location_batch_free(batch); + batch = NULL; + return LOCATIONS_ERROR_NONE; +} diff --git a/src/location_bounds.c b/src/location_bounds.c index 1819f27..a3c3919 100755 --- a/src/location_bounds.c +++ b/src/location_bounds.c @@ -17,13 +17,11 @@ #include #include #include -#include -#include +#include +#include "location_bounds.h" +#include "location_internal.h" -#define LOCATIONS_NULL_ARG_CHECK(arg) \ - LOCATIONS_CHECK_CONDITION((arg != NULL),LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER") \ - static void __free_position_list(gpointer data) { if (data == NULL) @@ -37,28 +35,29 @@ static location_bounds_type_e __convert_bounds_type(LocationBoundaryType type) { location_bounds_type_e ret; switch (type) { - case LOCATION_BOUNDARY_CIRCLE: - ret = LOCATION_BOUNDS_CIRCLE; - break; - case LOCATION_BOUNDARY_POLYGON: - ret = LOCATION_BOUNDS_POLYGON; - break; - case LOCATION_BOUNDARY_NONE: - case LOCATION_BOUNDARY_RECT: - default: - ret = LOCATION_BOUNDS_RECT; - break; + case LOCATION_BOUNDARY_CIRCLE: + ret = LOCATION_BOUNDS_CIRCLE; + break; + case LOCATION_BOUNDARY_POLYGON: + ret = LOCATION_BOUNDS_POLYGON; + break; + case LOCATION_BOUNDARY_NONE: + case LOCATION_BOUNDARY_RECT: + default: + ret = LOCATION_BOUNDS_RECT; + break; } return ret; } -EXPORT_API int location_bounds_create_rect(location_coords_s top_left, location_coords_s bottom_right, location_bounds_h * bounds) +EXPORT_API int location_bounds_create_rect(location_coords_s top_left, location_coords_s bottom_right, location_bounds_h *bounds) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(bounds); - LOCATIONS_CHECK_CONDITION(top_left.latitude>=-90 && top_left.latitude<=90,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); - LOCATIONS_CHECK_CONDITION(top_left.longitude>=-180 && top_left.longitude<=180,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); - LOCATIONS_CHECK_CONDITION(bottom_right.latitude>=-90 && bottom_right.latitude<=90,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); - LOCATIONS_CHECK_CONDITION(bottom_right.longitude>=-180 && bottom_right.longitude<=180,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(top_left.latitude >= -90 && top_left.latitude <= 90, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(top_left.longitude >= -180 && top_left.longitude <= 180, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(bottom_right.latitude >= -90 && bottom_right.latitude <= 90, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(bottom_right.longitude >= -180 && bottom_right.longitude <= 180, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); LocationPosition *lt = location_position_new(0, top_left.latitude, top_left.longitude, 0, LOCATION_STATUS_2D_FIX); if (lt == NULL) { @@ -98,12 +97,13 @@ EXPORT_API int location_bounds_create_rect(location_coords_s top_left, location_ return LOCATION_BOUNDS_ERROR_NONE; } -EXPORT_API int location_bounds_create_circle(location_coords_s center, double radius, location_bounds_h * bounds) +EXPORT_API int location_bounds_create_circle(location_coords_s center, double radius, location_bounds_h *bounds) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(bounds); - LOCATIONS_CHECK_CONDITION(radius>=0,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); - LOCATIONS_CHECK_CONDITION(center.latitude>=-90 && center.latitude<=90,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); - LOCATIONS_CHECK_CONDITION(center.longitude>=-180 && center.longitude<=180,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(radius >= 0, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(center.latitude >= -90 && center.latitude <= 90, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(center.longitude >= -180 && center.longitude <= 180, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); LocationPosition *ct = location_position_new(0, center.latitude, center.longitude, 0, LOCATION_STATUS_2D_FIX); if (ct == NULL) { @@ -123,9 +123,15 @@ EXPORT_API int location_bounds_create_circle(location_coords_s center, double ra handle->boundary = location_boundary_new_for_circle(ct, radius); location_position_free(ct); if (handle->boundary == NULL) { - LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_circle", LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); + int ret = get_last_result(); free(handle); - return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY; + if (ret == LOCATION_ERROR_PARAMETER) { + LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_INVALID_PARAMETER(0x%08x) fail to location_boundary_new_for_circle", LOCATION_BOUNDS_ERROR_INVALID_PARAMETER); + return LOCATION_BOUNDS_ERROR_INVALID_PARAMETER; + } else { + LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_circle", LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); + return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY; + } } handle->user_cb = NULL; handle->user_data = NULL; @@ -134,11 +140,12 @@ EXPORT_API int location_bounds_create_circle(location_coords_s center, double ra return LOCATION_BOUNDS_ERROR_NONE; } -EXPORT_API int location_bounds_create_polygon(location_coords_s * coords_list, int length, location_bounds_h * bounds) +EXPORT_API int location_bounds_create_polygon(location_coords_s *coords_list, int length, location_bounds_h *bounds) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(coords_list); LOCATIONS_NULL_ARG_CHECK(bounds); - LOCATIONS_CHECK_CONDITION(length>=3, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(length >= 3, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); int i; GList *position_list = NULL; @@ -178,9 +185,15 @@ EXPORT_API int location_bounds_create_polygon(location_coords_s * coords_list, i handle->is_added = FALSE; handle->boundary = location_boundary_new_for_polygon(position_list); if (handle->boundary == NULL) { - LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_polygon", LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); + int ret = get_last_result(); free(handle); - return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY; + if (ret == LOCATION_ERROR_PARAMETER) { + LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_INVALID_PARAMETER(0x%08x) fail to location_boundary_new_for_polygon", LOCATION_BOUNDS_ERROR_INVALID_PARAMETER); + return LOCATION_BOUNDS_ERROR_INVALID_PARAMETER; + } else { + LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_polygon", LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); + return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY; + } } handle->user_cb = NULL; handle->user_data = NULL; @@ -191,38 +204,54 @@ EXPORT_API int location_bounds_create_polygon(location_coords_s * coords_list, i EXPORT_API bool location_bounds_contains_coordinates(location_bounds_h bounds, location_coords_s coords) { - if (!bounds) + if (__is_location_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) { + set_last_result(LOCATIONS_ERROR_NOT_SUPPORTED); return FALSE; + } - if (coords.latitude < -90 || coords.latitude > 90 || coords.longitude < -180 || coords.longitude > 180) + if (!bounds) { + set_last_result(LOCATION_BOUNDS_ERROR_INVALID_PARAMETER); return FALSE; + } + + if (coords.latitude < -90 || coords.latitude > 90 || coords.longitude < -180 || coords.longitude > 180) { + set_last_result(LOCATION_BOUNDS_ERROR_INVALID_PARAMETER); + return FALSE; + } LocationPosition *pos = location_position_new(0, coords.latitude, coords.longitude, 0, LOCATION_STATUS_2D_FIX); if (pos == NULL) { LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_position_new", LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); + set_last_result(LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); return FALSE; } location_bounds_s *handle = (location_bounds_s *) bounds; gboolean is_inside = location_boundary_if_inside(handle->boundary, pos); location_position_free(pos); bool result = is_inside ? TRUE : FALSE; + + set_last_result(LOCATION_BOUNDS_ERROR_NONE); return result; } -EXPORT_API int location_bounds_get_type(location_bounds_h bounds, location_bounds_type_e * type) +EXPORT_API int location_bounds_get_type(location_bounds_h bounds, location_bounds_type_e *type) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(bounds); LOCATIONS_NULL_ARG_CHECK(type); + location_bounds_s *handle = (location_bounds_s *) bounds; *type = __convert_bounds_type(handle->boundary->type); return LOCATION_BOUNDS_ERROR_NONE; } -EXPORT_API int location_bounds_get_rect_coords(location_bounds_h bounds, location_coords_s * top_left, location_coords_s * bottom_right) +EXPORT_API int location_bounds_get_rect_coords(location_bounds_h bounds, location_coords_s *top_left, location_coords_s *bottom_right) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(bounds); LOCATIONS_NULL_ARG_CHECK(top_left); LOCATIONS_NULL_ARG_CHECK(bottom_right); + location_bounds_s *handle = (location_bounds_s *) bounds; if (__convert_bounds_type(handle->boundary->type) != LOCATION_BOUNDS_RECT) { LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_INCORRECT_TYPE(0x%08x)", LOCATION_BOUNDS_ERROR_INCORRECT_TYPE); @@ -236,11 +265,13 @@ EXPORT_API int location_bounds_get_rect_coords(location_bounds_h bounds, locatio return LOCATION_BOUNDS_ERROR_NONE; } -EXPORT_API int location_bounds_get_circle_coords(location_bounds_h bounds, location_coords_s * center, double *radius) +EXPORT_API int location_bounds_get_circle_coords(location_bounds_h bounds, location_coords_s *center, double *radius) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(bounds); LOCATIONS_NULL_ARG_CHECK(center); LOCATIONS_NULL_ARG_CHECK(radius); + location_bounds_s *handle = (location_bounds_s *) bounds; if (__convert_bounds_type(handle->boundary->type) != LOCATION_BOUNDS_CIRCLE) { LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_INCORRECT_TYPE(0x%08x)", LOCATION_BOUNDS_ERROR_INCORRECT_TYPE); @@ -255,8 +286,10 @@ EXPORT_API int location_bounds_get_circle_coords(location_bounds_h bounds, locat EXPORT_API int location_bounds_foreach_polygon_coords(location_bounds_h bounds, polygon_coords_cb callback, void *user_data) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(bounds); LOCATIONS_NULL_ARG_CHECK(callback); + location_bounds_s *handle = (location_bounds_s *) bounds; if (__convert_bounds_type(handle->boundary->type) != LOCATION_BOUNDS_POLYGON) { LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_INCORRECT_TYPE(0x%08x)", LOCATION_BOUNDS_ERROR_INCORRECT_TYPE); @@ -281,7 +314,9 @@ EXPORT_API int location_bounds_foreach_polygon_coords(location_bounds_h bounds, EXPORT_API int location_bounds_destroy(location_bounds_h bounds) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(bounds); + location_bounds_s *handle = (location_bounds_s *) bounds; if (handle->is_added) { LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_IS_ADDED(0x%08x)", LOCATION_BOUNDS_ERROR_IS_ADDED); @@ -297,8 +332,10 @@ EXPORT_API int location_bounds_destroy(location_bounds_h bounds) EXPORT_API int location_bounds_set_state_changed_cb(location_bounds_h bounds, location_bounds_state_changed_cb callback, void *user_data) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(bounds); LOCATIONS_NULL_ARG_CHECK(callback); + location_bounds_s *handle = (location_bounds_s *) bounds; handle->user_cb = callback; handle->user_data = user_data; @@ -307,7 +344,9 @@ EXPORT_API int location_bounds_set_state_changed_cb(location_bounds_h bounds, lo EXPORT_API int location_bounds_unset_state_changed_cb(location_bounds_h bounds) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(bounds); + location_bounds_s *handle = (location_bounds_s *) bounds; handle->user_cb = NULL; handle->user_data = NULL; diff --git a/src/location_internal.c b/src/location_internal.c new file mode 100644 index 0000000..7b9867f --- /dev/null +++ b/src/location_internal.c @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.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 + * limitations under the License. + */ + +#include +#include +#include +#include +#include "location_internal.h" + +int __convert_error_code(int code) +{ + int ret; + const char *msg = NULL; + switch (code) { + case LOCATION_ERROR_NONE: + ret = LOCATIONS_ERROR_NONE; + msg = "LOCATIONS_ERROR_NONE"; + break; + case LOCATION_ERROR_PARAMETER: + ret = LOCATIONS_ERROR_INVALID_PARAMETER; + msg = "LOCATIONS_ERROR_INVALID_PARAMETER"; + break; + case LOCATION_ERROR_NOT_ALLOWED: + ret = LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED; + msg = "LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED"; + break; + case LOCATION_ERROR_NOT_SUPPORTED: + ret = LOCATIONS_ERROR_NOT_SUPPORTED; + msg = "LOCATIONS_ERROR_NOT_SUPPORTED"; + break; + case LOCATION_ERROR_NETWORK_FAILED: + case LOCATION_ERROR_NETWORK_NOT_CONNECTED: + ret = LOCATIONS_ERROR_NETWORK_FAILED; + msg = "LOCATIONS_ERROR_NETWORK_FAILED"; + break; + case LOCATION_ERROR_SETTING_OFF: + ret = LOCATIONS_ERROR_GPS_SETTING_OFF; + msg = "LOCATIONS_ERROR_GPS_SETTING_OFF"; + break; + case LOCATION_ERROR_SECURITY_DENIED: + ret = LOCATIONS_ERROR_SECURITY_RESTRICTED; + msg = "LOCATIONS_ERROR_SECURITY_RESTRICTED"; + break; + case LOCATION_ERROR_NOT_AVAILABLE: + case LOCATION_ERROR_CONFIGURATION: + case LOCATION_ERROR_UNKNOWN: + default: + msg = "LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE"; + ret = LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; + } + + if (ret != LOCATIONS_ERROR_NONE) { + LOCATIONS_LOGE("%s(0x%08x) : core fw error(0x%x)", msg, ret, code); + } + return ret; +} + +int __is_gps_supported(void) +{ + bool is_supported = false; + int retval = 0; + + retval = system_info_get_platform_bool("http://tizen.org/feature/location.gps", &is_supported); + if (retval != SYSTEM_INFO_ERROR_NONE) { + LOCATIONS_LOGW("system_info_get_platform_bool failed: retval = %d", retval); + } + if (is_supported == false) { + return LOCATIONS_ERROR_NOT_SUPPORTED; + } + return LOCATIONS_ERROR_NONE; +} + +int __is_wps_supported(void) +{ + bool is_supported = false; + int retval = 0; + + retval = system_info_get_platform_bool("http://tizen.org/feature/location.wps", &is_supported); + if (retval != SYSTEM_INFO_ERROR_NONE) { + LOCATIONS_LOGW("system_info_get_platform_bool failed: retval = %d", retval); + } + if (is_supported == false) { + return LOCATIONS_ERROR_NOT_SUPPORTED; + } + return LOCATIONS_ERROR_NONE; +} + +int __is_location_supported(void) +{ + if (__is_gps_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) { + if (__is_wps_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) { + return LOCATIONS_ERROR_NOT_SUPPORTED; + } else { + return LOCATIONS_ERROR_NONE; + } + } + + return LOCATIONS_ERROR_NONE; +} + +int __set_callback(_location_event_e type, location_manager_h manager, void *callback, void *user_data) +{ + LOCATIONS_NULL_ARG_CHECK(manager); + LOCATIONS_NULL_ARG_CHECK(callback); + location_manager_s *handle = (location_manager_s *) manager; + handle->user_cb[type] = callback; + handle->user_data[type] = user_data; + LOCATIONS_LOGD("event type : %d", type); + return LOCATIONS_ERROR_NONE; +} + +int __unset_callback(_location_event_e type, location_manager_h manager) +{ + LOCATIONS_NULL_ARG_CHECK(manager); + location_manager_s *handle = (location_manager_s *) manager; + handle->user_cb[type] = NULL; + handle->user_data[type] = NULL; + LOCATIONS_LOGD("event type : %d. ", type); + return LOCATIONS_ERROR_NONE; +} + diff --git a/src/location_preference.c b/src/location_preference.c deleted file mode 100755 index c2d1f73..0000000 --- a/src/location_preference.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.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 - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -#define LOCATION_PREFERENCE_NULL_ARG_CHECK(arg) \ - LOCATIONS_CHECK_CONDITION((arg != NULL), LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER") - -#define LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service) *((LocationMapObject**)service) - -/* -* Internal Implementation -*/ - -static int __convert_error_code(int code) -{ - int ret = LOCATION_PREFERENCE_ERROR_NONE; - char* msg = "LOCATION_PREFERENCE_ERROR_NONE"; - switch(code) - { - case LOCATION_ERROR_NONE: - ret = LOCATION_PREFERENCE_ERROR_NONE; - msg = "LOCATION_PREFERENCE_ERROR_NONE"; - break; - case LOCATION_ERROR_NETWORK_NOT_CONNECTED: - ret = LOCATION_PREFERENCE_ERROR_NETWORK_FAILED; - msg = "LOCATION_PREFERENCE_ERROR_NETWORK_FAILED"; - break; - case LOCATION_ERROR_PARAMETER: - ret = LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER; - msg = "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"; - break; - case LOCATION_ERROR_NOT_AVAILABLE: - msg = "LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND"; - ret = LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND; - } - LOCATIONS_LOGE("%s(0x%08x)", msg, ret); - return ret; -} - - -/* - * Public Implementation - */ -EXPORT_API int location_preference_foreach_available_property_keys(location_service_h service, location_preference_available_property_key_cb callback, void* user_data) -{ - LocationMapObject* object = NULL; - GList* keys = NULL; - char* key = NULL; - int ret = 0; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(callback); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - ret = location_map_get_provider_capability_key(object, MAP_SERVICE_PREF_PROPERTY, &keys); - if(ret != LOCATION_ERROR_NONE) - { - return __convert_error_code(ret); - } - else - { - while(keys) { - key = keys->data; - if(!callback(key, user_data)) - break; - keys = keys->next; - } - - return LOCATION_PREFERENCE_ERROR_NONE; - } -} - -EXPORT_API int location_preference_foreach_available_property_values(location_service_h service, const char* key, location_preference_available_property_value_cb callback, void* user_data) -{ - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(key); - LOCATION_PREFERENCE_NULL_ARG_CHECK(callback); - return LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND; -} - -EXPORT_API int location_preference_foreach_available_languages(location_service_h service, location_preference_available_language_cb callback, void* user_data) -{ - LocationMapObject* object = NULL; - GList* keys = NULL; - char* key = NULL; - int ret = 0; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(callback); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - ret = location_map_get_provider_capability_key(object, MAP_SERVICE_PREF_LANGUAGE, &keys); - if(ret != LOCATION_ERROR_NONE) - { - return __convert_error_code(ret); - } - else - { - while(keys) { - key = keys->data; - if(!callback(key, user_data)) - break; - keys = keys->next; - } - - return LOCATION_PREFERENCE_ERROR_NONE; - } -} - -EXPORT_API int location_preference_foreach_available_country_codes(location_service_h service, location_preference_available_country_code_cb callback, void* user_data) -{ - LocationMapObject* object = NULL; - GList* keys = NULL; - char* key = NULL; - int ret = 0; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(callback); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - ret = location_map_get_provider_capability_key(object, MAP_SERVICE_PREF_COUNTRY, &keys); - if(ret != LOCATION_ERROR_NONE) - { - return __convert_error_code(ret); - } - else - { - while(keys) { - key = keys->data; - if(!callback(key, user_data)) - break; - keys = keys->next; - } - } - - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_foreach_properties(location_service_h service, location_preference_property_cb callback, void* user_data) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - GList* keys = NULL; - char* key = NULL; - char* value = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(callback); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - keys = location_map_pref_get_property_key(pref); - while(keys) { - key = keys->data; - value = (char*)location_map_pref_get_property(pref, key); - if(!callback(key, value, user_data)) - break; - keys = keys->next; - } - - location_map_pref_free(pref); - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_set(location_service_h service, const char* key, const char* value) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(key); - LOCATION_PREFERENCE_NULL_ARG_CHECK(value); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - location_map_pref_set_property(pref, (gconstpointer)key, (gconstpointer)value); - location_map_set_service_pref(object, pref); - location_map_pref_free(pref); - - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_get(location_service_h service, const char* key, char** value) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - char* ret = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(key); - LOCATION_PREFERENCE_NULL_ARG_CHECK(value); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - ret = (char*)location_map_pref_get_property(pref, (gconstpointer)key); - if(ret != NULL) - { - *value = strdup(ret); - location_map_pref_free(pref); - } - else - { - *value = NULL; - location_map_pref_free(pref); - LOCATIONS_PRINT_ERROR_CODE(LOCATION_PREFERENCE_ERROR_INVALID_KEY, "LOCATION_PREFERENCE_ERROR_INVALID_KEY"); - } - - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_set_provider(location_service_h service, char* provider) -{ - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(provider); - - LocationMapObject *object = NULL; - LocationMapPref *pref = NULL; - gboolean ret = FALSE; - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - ret = location_map_pref_set_provider_name(pref, provider); - if (!ret) { - location_map_pref_free(pref); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_KEY, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - } - ret = location_map_set_service_pref(object, pref); - if (!ret) { - location_map_pref_free(pref); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_KEY, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - } - - location_map_pref_free(pref); - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_get_provider(location_service_h service, char** provider) -{ - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(provider); - - LocationMapObject *object = NULL; - LocationMapPref *pref = NULL; - gchar* current_provider = NULL; - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - current_provider = location_map_pref_get_provider_name(pref); - if (!current_provider) { - location_map_pref_free(pref); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_KEY, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - } - - *provider = g_strdup (current_provider); - location_map_pref_free(pref); - - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_get_default_provider(location_service_h service, char** provider) -{ - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(provider); - - LocationMapObject *object = NULL; - gchar *current_provider = NULL; - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - current_provider = location_map_get_default_provider(object); - LOCATIONS_CHECK_CONDITION(current_provider != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - *provider = g_strdup(current_provider); - g_free(current_provider); - - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_foreach_supported_provider(location_service_h service, location_preference_supported_provider_cb callback , void *user_data) -{ - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(callback); - - LocationMapObject *object = NULL; - GList *providers = NULL; - gchar *provider = NULL; - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - providers = location_map_get_supported_providers(object); - LOCATIONS_CHECK_CONDITION(providers != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - while(providers) { - provider = providers->data; - if(!callback(provider, user_data)) - break; - providers = providers->next; - } - - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_get_provider_name(location_service_h service, char** provider) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - char* ret = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(provider); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - ret = location_map_pref_get_provider_name(pref); - if(ret != NULL) - *provider = strdup(ret); - else - *provider = NULL; - - location_map_pref_free(pref); - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_get_distance_unit(location_service_h service, location_preference_distance_unit_e* unit) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - char* ret = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(unit); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - ret = location_map_pref_get_distance_unit(pref); - if(ret != NULL) - { - switch(ret[0]) { - case 'F' : - *unit = LOCATION_PREFERENCE_DISTANCE_UNIT_FT; - break; - case 'K' : - *unit = LOCATION_PREFERENCE_DISTANCE_UNIT_KM; - break; - case 'Y' : - *unit = LOCATION_PREFERENCE_DISTANCE_UNIT_YD; - break; - case 'M' : - if(ret[1] == 'I') - *unit = LOCATION_PREFERENCE_DISTANCE_UNIT_MI; - else - *unit = LOCATION_PREFERENCE_DISTANCE_UNIT_M; - break; - } - location_map_pref_free(pref); - return LOCATION_PREFERENCE_ERROR_NONE; - } - else - { - location_map_pref_free(pref); - LOCATIONS_PRINT_ERROR_CODE(LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND, "LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND"); - } -} - -EXPORT_API int location_preference_set_distance_unit(location_service_h service, location_preference_distance_unit_e unit) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - char* distance = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - switch(unit) { - case LOCATION_PREFERENCE_DISTANCE_UNIT_FT : - distance = "FT"; - break; - case LOCATION_PREFERENCE_DISTANCE_UNIT_KM : - distance = "KM"; - break; - case LOCATION_PREFERENCE_DISTANCE_UNIT_YD : - distance = "YD"; - break; - case LOCATION_PREFERENCE_DISTANCE_UNIT_MI : - distance = "MI"; - break; - case LOCATION_PREFERENCE_DISTANCE_UNIT_M : - distance = "M"; - break; - default : - LOCATIONS_PRINT_ERROR_CODE(LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - } - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - location_map_pref_set_distance_unit(pref, distance); - location_map_set_service_pref(object, pref); - location_map_pref_free(pref); - - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_get_language(location_service_h service, char** language) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - char* ret = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(language); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - ret = location_map_pref_get_language(pref); - if(ret != NULL) - *language = strdup(ret); - else - *language = NULL; - - location_map_pref_free(pref); - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_set_language(location_service_h service, const char* language) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(language); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - location_map_pref_set_language(pref, language); - location_map_set_service_pref(object, pref); - location_map_pref_free(pref); - - return LOCATION_PREFERENCE_ERROR_NONE; -} - - -EXPORT_API int location_preference_get_country_code(location_service_h service, char** country_code) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - char* ret = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(country_code); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - ret = location_map_pref_get_country(pref); - if(ret != NULL) - *country_code = strdup(ret); - else - *country_code = NULL; - - location_map_pref_free(pref); - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_set_country_code(location_service_h service, const char* country_code) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(country_code); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - location_map_pref_set_country(pref, country_code); - location_map_set_service_pref(object, pref); - location_map_pref_free(pref); - - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_set_maps_key (location_service_h service, const char* maps_key) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(maps_key); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - location_map_pref_set_maps_key(pref, maps_key); - location_map_set_service_pref(object, pref); - location_map_pref_free(pref); - - return LOCATION_PREFERENCE_ERROR_NONE; -} - -EXPORT_API int location_preference_get_maps_key (location_service_h service, char** maps_key) -{ - LocationMapPref* pref = NULL; - LocationMapObject* object = NULL; - char* ret = NULL; - - LOCATION_PREFERENCE_NULL_ARG_CHECK(service); - LOCATION_PREFERENCE_NULL_ARG_CHECK(maps_key); - - object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service); - pref = location_map_get_service_pref(object); - LOCATIONS_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER"); - - ret = location_map_pref_get_maps_key(pref); - if(ret != NULL) - *maps_key = strdup(ret); - else - *maps_key = NULL; - - location_map_pref_free(pref); - return LOCATION_PREFERENCE_ERROR_NONE; - -} \ No newline at end of file diff --git a/src/locations.c b/src/locations.c index c871165..1f2951a 100755 --- a/src/locations.c +++ b/src/locations.c @@ -17,192 +17,218 @@ #include #include #include -#include -#include +#include +#include "locations.h" +#include "location_internal.h" +static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_WPS + 1]; -#define LOCATIONS_NULL_ARG_CHECK(arg) \ - LOCATIONS_CHECK_CONDITION((arg != NULL),LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER") \ - -/* -* Internal Implementation -*/ +static location_method_e __convert_location_method_e(LocationMethod method) +{ + location_method_e _method = LOCATIONS_METHOD_NONE; + switch (method) { + case LOCATION_METHOD_HYBRID: + _method = LOCATIONS_METHOD_HYBRID; + break; + case LOCATION_METHOD_GPS: + _method = LOCATIONS_METHOD_GPS; + break; + case LOCATION_METHOD_WPS: + _method = LOCATIONS_METHOD_WPS; + break; + case LOCATION_METHOD_NONE: + default: + break; + } + return _method; +} -static int __convert_error_code(int code) +static LocationMethod __convert_LocationMethod(location_method_e method) { - int ret; - char *msg = "LOCATIONS_ERROR_NONE"; - switch (code) { - case LOCATION_ERROR_NONE: - ret = LOCATIONS_ERROR_NONE; - msg = "LOCATIONS_ERROR_NONE"; - break; - case LOCATION_ERROR_NETWORK_FAILED: - case LOCATION_ERROR_NETWORK_NOT_CONNECTED: - ret = LOCATIONS_ERROR_NETWORK_FAILED; - msg = "LOCATIONS_ERROR_NETWORK_FAILED"; - break; - case LOCATION_ERROR_NOT_ALLOWED: - ret = LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED; - msg = "LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED"; - break; - case LOCATION_ERROR_SETTING_OFF: - ret = LOCATIONS_ERROR_GPS_SETTING_OFF; - msg = "LOCATIONS_ERROR_GPS_SETTING_OFF"; - break; - case LOCATION_ERROR_SECURITY_DENIED: - ret = LOCATIONS_ERROR_SECURITY_RESTRICTED; - msg = "LOCATIONS_ERROR_SECURITY_RESTRICTED"; - break; - case LOCATION_ERROR_NOT_AVAILABLE: - case LOCATION_ERROR_CONFIGURATION: - case LOCATION_ERROR_PARAMETER: - case LOCATION_ERROR_UNKNOWN: - default: - msg = "LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE"; - ret = LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; - } - LOCATIONS_LOGE("%s(0x%08x) : core fw error(0x%x)", msg, ret, code); - return ret; + LocationMethod _method = LOCATION_METHOD_NONE; + switch (method) { + case LOCATIONS_METHOD_HYBRID: + _method = LOCATION_METHOD_HYBRID; + break; + case LOCATIONS_METHOD_GPS: + _method = LOCATION_METHOD_GPS; + break; + case LOCATIONS_METHOD_WPS: + _method = LOCATION_METHOD_WPS; + break; + case LOCATIONS_METHOD_NONE: + default: + _method = LOCATION_METHOD_NONE; + break; + } + return _method; } -static void __cb_service_updated(GObject * self, guint type, gpointer data, gpointer accuracy, gpointer userdata) +static void __cb_service_updated(GObject *self, guint type, gpointer data, gpointer velocity, gpointer accuracy, gpointer userdata) { - LOCATIONS_LOGI("Callback function has been invoked. "); + LOCATIONS_LOGD("Callback function has been invoked. "); location_manager_s *handle = (location_manager_s *) userdata; - if (type == VELOCITY_UPDATED && handle->user_cb[_LOCATIONS_EVENT_TYPE_VELOCITY]) { - LocationVelocity *vel = (LocationVelocity *) data; - LOCATIONS_LOGI("Current velocity: timestamp : %d", vel->timestamp); - ((location_velocity_updated_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_VELOCITY]) (vel->speed, vel->direction, - vel->climb, vel->timestamp, - handle->user_data - [_LOCATIONS_EVENT_TYPE_VELOCITY]); - } - else if (type == POSITION_UPDATED && handle->user_cb[_LOCATIONS_EVENT_TYPE_POSITION]) { + + if (type == SATELLITE_UPDATED && handle->user_cb[_LOCATIONS_EVENT_TYPE_SATELLITE]) { + LocationSatellite *sat = (LocationSatellite *)data; + LOCATIONS_LOGD("Current satellite information: timestamp : %d, number of active : %d, number of inview : %d", + sat->timestamp, sat->num_of_sat_used, sat->num_of_sat_inview); + ((gps_status_satellite_updated_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_SATELLITE])(sat->num_of_sat_used, sat->num_of_sat_inview, + sat->timestamp, handle->user_data[_LOCATIONS_EVENT_TYPE_SATELLITE]); + } else if (type == DISTANCE_UPDATED && handle->user_cb[_LOCATIONS_EVENT_TYPE_DISTANCE]) { LocationPosition *pos = (LocationPosition *) data; - LOCATIONS_LOGI("Current position: timestamp : %d", pos->timestamp); - ((location_position_updated_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_POSITION]) (pos->latitude, pos->longitude, - pos->altitude, pos->timestamp, - handle->user_data - [_LOCATIONS_EVENT_TYPE_POSITION]); + LocationVelocity *vel = (LocationVelocity *) velocity; /* current velocity */ + ((location_changed_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_DISTANCE])(0, pos->latitude, pos->longitude, pos->altitude, + vel->speed, vel->direction, pos->timestamp, handle->user_data[_LOCATIONS_EVENT_TYPE_DISTANCE]); + } else { + + if (handle->user_cb[_LOCATIONS_EVENT_TYPE_POSITION] && (type & POSITION_UPDATED) != 0) { + LocationPosition *pos = (LocationPosition *) data; + ((location_position_updated_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_POSITION])(pos->latitude, pos->longitude, pos->altitude, pos->timestamp, + handle->user_data[_LOCATIONS_EVENT_TYPE_POSITION]); + } + + if (handle->user_cb[_LOCATIONS_EVENT_TYPE_VELOCITY] && (type & VELOCITY_UPDATED) != 0) { + LocationVelocity *vel = (LocationVelocity *) data; + ((location_velocity_updated_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_VELOCITY])(vel->speed, vel->direction, vel->climb, vel->timestamp, + handle->user_data[_LOCATIONS_EVENT_TYPE_VELOCITY]); + } + + if (handle->user_cb[_LOCATIONS_EVENT_TYPE_POS_VEL] && (type & LOCATION_CHANGED) != 0) { + LocationPosition *pos = (LocationPosition *) data; + LocationVelocity *vel = (LocationVelocity *) velocity; + LocationAccuracy *acc = (LocationAccuracy *) accuracy; + ((location_changed_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_POS_VEL])(pos->latitude, pos->longitude, pos->altitude, + vel->speed, vel->direction, acc->horizontal_accuracy, pos->timestamp, handle->user_data[_LOCATIONS_EVENT_TYPE_POS_VEL]); + } } - else if (type == SATELLITE_UPDATED && handle->user_cb[_LOCATIONS_EVENT_TYPE_SATELLITE]) { - LocationSatellite *sat = (LocationSatellite *)data; - LOCATIONS_LOGI("Current satellite information: timestamp : %d, number of active : %d, number of inview : %d", - sat->timestamp, sat->num_of_sat_used, sat->num_of_sat_inview); - ((gps_status_satellite_updated_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_SATELLITE]) (sat->num_of_sat_used, sat->num_of_sat_inview, - sat->timestamp, handle->user_data[_LOCATIONS_EVENT_TYPE_SATELLITE]); +} + +static void __cb_location_updated(GObject *self, int error, gpointer position, gpointer velocity, gpointer accuracy, gpointer userdata) +{ + LOCATIONS_LOGD("Callback function has been invoked. "); + int converted_err = __convert_error_code(error); + location_manager_s *handle = (location_manager_s *) userdata; + LocationPosition *pos = (LocationPosition *) position; + LocationVelocity *vel = (LocationVelocity *) velocity; + + LOCATIONS_LOGD("Current position: timestamp : %d", pos->timestamp); + if (handle->user_cb[_LOCATIONS_EVENT_TYPE_LOCATION]) { + ((location_updated_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_LOCATION])(converted_err, pos->latitude, pos->longitude, pos->altitude, + pos->timestamp, vel->speed, vel->climb, vel->direction, handle->user_data[_LOCATIONS_EVENT_TYPE_LOCATION]); } } -static void __cb_service_enabled(GObject * self, guint status, gpointer userdata) +static void __cb_service_enabled(GObject *self, guint status, gpointer userdata) { - LOCATIONS_LOGI("Callback function has been invoked. "); + LOCATIONS_LOGD("Callback function has been invoked. "); location_manager_s *handle = (location_manager_s *) userdata; if (handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]) { ((location_service_state_changed_cb) - handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]) (LOCATIONS_SERVICE_ENABLED, - handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]); + handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])(LOCATIONS_SERVICE_ENABLED, + handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]); } } -static void __cb_service_disabled(GObject * self, guint status, gpointer userdata) +static void __cb_service_disabled(GObject *self, guint status, gpointer userdata) { - LOCATIONS_LOGI("Callback function has been invoked. "); + LOCATIONS_LOGD("Callback function has been invoked. "); location_manager_s *handle = (location_manager_s *) userdata; if (handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]) ((location_service_state_changed_cb) - handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]) (LOCATIONS_SERVICE_DISABLED, - handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]); + handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])(LOCATIONS_SERVICE_DISABLED, + handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]); } -static int __compare_position (gconstpointer a, gconstpointer b) +static int __compare_position(gconstpointer a, gconstpointer b) { - if(location_position_equal((LocationPosition*) a, (LocationPosition *)b) == TRUE) { + if (location_position_equal((LocationPosition *) a, (LocationPosition *)b) == TRUE) { return 0; } return -1; } -static int __boundary_compare(LocationBoundary * bound1, LocationBoundary * bound2) +static int __boundary_compare(LocationBoundary *bound1, LocationBoundary *bound2) { int ret = -1; if (bound1->type == bound2->type) { switch (bound1->type) { - case LOCATION_BOUNDARY_CIRCLE: - if (location_position_equal(bound1->circle.center, bound2->circle.center) && bound1->circle.radius == bound2->circle.radius) { - ret = 0; - } - break; - case LOCATION_BOUNDARY_RECT: - if (location_position_equal(bound1->rect.left_top, bound2->rect.left_top) && location_position_equal(bound1->rect.right_bottom, bound2->rect.right_bottom)) { - ret = 0; - } - break; - case LOCATION_BOUNDARY_POLYGON: { - GList *boundary1_next = NULL; - GList *boundary2_start = NULL, *boundary2_prev = NULL, *boundary2_next = NULL; - if (g_list_length(bound1->polygon.position_list) != g_list_length(bound2->polygon.position_list)) { - return -1; - } - - boundary2_start = g_list_find_custom(bound2->polygon.position_list, g_list_nth_data(bound1->polygon.position_list, 0), (GCompareFunc) __compare_position); - if (boundary2_start == NULL) return -1; + case LOCATION_BOUNDARY_CIRCLE: + if (location_position_equal(bound1->circle.center, bound2->circle.center) && bound1->circle.radius == bound2->circle.radius) { + ret = 0; + } + break; + case LOCATION_BOUNDARY_RECT: + if (location_position_equal(bound1->rect.left_top, bound2->rect.left_top) && location_position_equal(bound1->rect.right_bottom, bound2->rect.right_bottom)) { + ret = 0; + } + break; + case LOCATION_BOUNDARY_POLYGON: { + GList *boundary1_next = NULL; + GList *boundary2_start = NULL, *boundary2_prev = NULL, *boundary2_next = NULL; + if (g_list_length(bound1->polygon.position_list) != g_list_length(bound2->polygon.position_list)) { + return -1; + } - boundary2_prev = g_list_previous(boundary2_start); - boundary2_next = g_list_next(boundary2_start); + boundary2_start = g_list_find_custom(bound2->polygon.position_list, g_list_nth_data(bound1->polygon.position_list, 0), (GCompareFunc) __compare_position); + if (boundary2_start == NULL) return -1; - if (boundary2_prev == NULL) boundary2_prev = g_list_last(bound2->polygon.position_list); - if (boundary2_next == NULL) boundary2_next = g_list_first(bound2->polygon.position_list); + boundary2_prev = g_list_previous(boundary2_start); + boundary2_next = g_list_next(boundary2_start); - boundary1_next = g_list_next(bound1->polygon.position_list); - if (location_position_equal((LocationPosition*)boundary1_next->data, (LocationPosition*)boundary2_prev->data) == TRUE) { - boundary1_next = g_list_next(boundary1_next); - while (boundary1_next) { - boundary2_prev = g_list_previous(boundary2_prev); if (boundary2_prev == NULL) boundary2_prev = g_list_last(bound2->polygon.position_list); - if (location_position_equal((LocationPosition*)boundary1_next->data, (LocationPosition*) boundary2_prev->data) == FALSE) { - return -1; - } - boundary1_next = g_list_next(boundary1_next); - } - ret = 0; - } else if (location_position_equal((LocationPosition*)boundary1_next->data, (LocationPosition*)boundary2_next->data) == TRUE) { - boundary1_next = g_list_next(boundary1_next); - while(boundary1_next) { - boundary2_next = g_list_next(boundary2_next); if (boundary2_next == NULL) boundary2_next = g_list_first(bound2->polygon.position_list); - if (location_position_equal((LocationPosition*)boundary1_next->data, (LocationPosition*) boundary2_next->data) == FALSE) { + + boundary1_next = g_list_next(bound1->polygon.position_list); + if (boundary1_next != NULL && boundary2_prev != NULL && + location_position_equal((LocationPosition *)boundary1_next->data, (LocationPosition *)boundary2_prev->data) == TRUE) { + boundary1_next = g_list_next(boundary1_next); + while (boundary1_next) { + boundary2_prev = g_list_previous(boundary2_prev); + if (boundary2_prev == NULL) boundary2_prev = g_list_last(bound2->polygon.position_list); + if (location_position_equal((LocationPosition *)boundary1_next->data, (LocationPosition *) boundary2_prev->data) == FALSE) { + return -1; + } + boundary1_next = g_list_next(boundary1_next); + } + ret = 0; + } else if (boundary1_next != NULL && boundary2_next != NULL && + location_position_equal((LocationPosition *)boundary1_next->data, (LocationPosition *)boundary2_next->data) == TRUE) { + boundary1_next = g_list_next(boundary1_next); + while (boundary1_next) { + boundary2_next = g_list_next(boundary2_next); + if (boundary2_next == NULL) boundary2_next = g_list_first(bound2->polygon.position_list); + if (location_position_equal((LocationPosition *)boundary1_next->data, (LocationPosition *) boundary2_next->data) == FALSE) { + return -1; + } + boundary1_next = g_list_next(boundary1_next); + } + ret = 0; + } else { return -1; } - boundary1_next = g_list_next(boundary1_next); + break; } - ret = 0; - } else { - return -1; - } - break; - } - default: - break; + default: + break; } } return ret; } -static void __cb_zone_in(GObject * self, gpointer boundary, gpointer position, gpointer accuracy, gpointer userdata) +static void __cb_zone_in(GObject *self, gpointer boundary, gpointer position, gpointer accuracy, gpointer userdata) { - LOCATIONS_LOGI("Callback function has been invoked."); + LOCATIONS_LOGD("ENTER >>>"); location_manager_s *handle = (location_manager_s *) userdata; if (handle->user_cb[_LOCATIONS_EVENT_TYPE_BOUNDARY]) { LocationPosition *pos = (LocationPosition *) position; - ((location_zone_changed_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_BOUNDARY]) (LOCATIONS_BOUNDARY_IN, - pos->latitude, pos->longitude, - pos->altitude, pos->timestamp, - handle->user_data - [_LOCATIONS_EVENT_TYPE_BOUNDARY]); + ((location_zone_changed_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_BOUNDARY])(LOCATIONS_BOUNDARY_IN, + pos->latitude, pos->longitude, + pos->altitude, pos->timestamp, + handle->user_data + [_LOCATIONS_EVENT_TYPE_BOUNDARY]); } location_bounds_s *bounds; @@ -210,25 +236,28 @@ static void __cb_zone_in(GObject * self, gpointer boundary, gpointer position, g while (bounds_list) { bounds = (location_bounds_s *)bounds_list->data; if (__boundary_compare(boundary, bounds->boundary) == 0) { - LOCATIONS_LOGI("Find zone in boundary"); - ((location_bounds_state_changed_cb) bounds->user_cb) (LOCATIONS_BOUNDARY_IN, bounds->user_data); + LOCATIONS_LOGD("Find zone in boundary"); + if (bounds->user_cb) { + ((location_bounds_state_changed_cb) bounds->user_cb)(LOCATIONS_BOUNDARY_IN, bounds->user_data); + } break; } bounds_list = g_list_next(bounds_list); } + LOCATIONS_LOGD("EXIT <<<"); } -static void __cb_zone_out(GObject * self, gpointer boundary, gpointer position, gpointer accuracy, gpointer userdata) +static void __cb_zone_out(GObject *self, gpointer boundary, gpointer position, gpointer accuracy, gpointer userdata) { - LOCATIONS_LOGI("Callback function has been invoked."); + LOCATIONS_LOGD("ENTER >>>"); location_manager_s *handle = (location_manager_s *) userdata; if (handle->user_cb[_LOCATIONS_EVENT_TYPE_BOUNDARY]) { LocationPosition *pos = (LocationPosition *) position; - ((location_zone_changed_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_BOUNDARY]) (LOCATIONS_BOUNDARY_OUT, - pos->latitude, pos->longitude, - pos->altitude, pos->timestamp, - handle->user_data - [_LOCATIONS_EVENT_TYPE_BOUNDARY]); + ((location_zone_changed_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_BOUNDARY])(LOCATIONS_BOUNDARY_OUT, + pos->latitude, pos->longitude, + pos->altitude, pos->timestamp, + handle->user_data + [_LOCATIONS_EVENT_TYPE_BOUNDARY]); } location_bounds_s *bounds; @@ -236,36 +265,18 @@ static void __cb_zone_out(GObject * self, gpointer boundary, gpointer position, while (bounds_list) { bounds = (location_bounds_s *)bounds_list->data; if (__boundary_compare(boundary, bounds->boundary) == 0) { - LOCATIONS_LOGI("Find zone out boundary"); - ((location_bounds_state_changed_cb) bounds->user_cb) (LOCATIONS_BOUNDARY_OUT, bounds->user_data); + LOCATIONS_LOGD("Find zone out boundary"); + if (bounds->user_cb) { + ((location_bounds_state_changed_cb) bounds->user_cb)(LOCATIONS_BOUNDARY_OUT, bounds->user_data); + } break; } bounds_list = g_list_next(bounds_list); } + LOCATIONS_LOGD("EXIT <<<"); } -static int __set_callback(_location_event_e type, location_manager_h manager, void *callback, void *user_data) -{ - LOCATIONS_NULL_ARG_CHECK(manager); - LOCATIONS_NULL_ARG_CHECK(callback); - location_manager_s *handle = (location_manager_s *) manager; - handle->user_cb[type] = callback; - handle->user_data[type] = user_data; - LOCATIONS_LOGI("event type : %d. ", type); - return LOCATIONS_ERROR_NONE; -} - -static int __unset_callback(_location_event_e type, location_manager_h manager) -{ - LOCATIONS_NULL_ARG_CHECK(manager); - location_manager_s *handle = (location_manager_s *) manager; - handle->user_cb[type] = NULL; - handle->user_data[type] = NULL; - LOCATIONS_LOGI("event type : %d. ", type); - return LOCATIONS_ERROR_NONE; -} - -static void __foreach_boundary(LocationBoundary * boundary, void *user_data) +static void __foreach_boundary(LocationBoundary *boundary, void *user_data) { location_manager_s *handle = (location_manager_s *) user_data; @@ -309,77 +320,121 @@ static void __foreach_boundary(LocationBoundary * boundary, void *user_data) } else { if (handle->is_continue_foreach_bounds) { handle->is_continue_foreach_bounds = - ((location_bounds_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS]) (bounds, - handle-> - user_data - [_LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS]); + ((location_bounds_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS])(bounds, + handle-> + user_data + [_LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS]); } location_bounds_destroy(bounds); } } else { - LOCATIONS_LOGI("__foreach_boundary() has been failed"); + LOCATIONS_LOGD("__foreach_boundary() has been failed"); } } -///////////////////////////////////////// -// Location Manager -//////////////////////////////////////// +static void __setting_changed_cb(LocationMethod method, gboolean enable, void *user_data) +{ + LOCATIONS_LOGD("__setting_changed_cb method [%d]", method); + location_method_e _method = __convert_location_method_e(method); + location_setting_changed_s *_setting_changed = (location_setting_changed_s *)user_data; + if (_setting_changed == NULL) { + LOCATIONS_LOGE("Invaild userdata\n"); + return; + } -/* -* Public Implementation -*/ + if (_setting_changed[_method].callback != NULL) { + _setting_changed[_method].callback(_method, enable, _setting_changed[_method].user_data); + } +} + +/*/////////////////////////////////////// */ +/* Location Manager */ +/*////////////////////////////////////// */ EXPORT_API bool location_manager_is_supported_method(location_method_e method) { - LocationMethod _method = LOCATION_METHOD_NONE; - switch (method) { - case LOCATIONS_METHOD_HYBRID: - _method = LOCATION_METHOD_HYBRID; - break; - case LOCATIONS_METHOD_GPS: - _method = LOCATION_METHOD_GPS; - break; - case LOCATIONS_METHOD_WPS: - _method = LOCATION_METHOD_WPS; - break; - case LOCATIONS_METHOD_CPS: - _method = LOCATION_METHOD_CPS; - break; - default: - _method = LOCATION_METHOD_NONE; - break; + LOCATIONS_LOGD("location_manager_is_supported_method %d", method); + if (__is_location_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) { + set_last_result(LOCATIONS_ERROR_NOT_SUPPORTED); + return false; + } + + LocationMethod _method = __convert_LocationMethod(method); + if (_method == LOCATION_METHOD_NONE) { + LOCATIONS_LOGE("Not supported method [%d]", method); + set_last_result(LOCATIONS_ERROR_INCORRECT_METHOD); + return false; } + + set_last_result(LOCATIONS_ERROR_NONE); return location_is_supported_method(_method); } -EXPORT_API int location_manager_create(location_method_e method, location_manager_h * manager) +EXPORT_API int location_manager_is_enabled_method(location_method_e method, bool *enable) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + + if (LOCATIONS_METHOD_HYBRID > method || LOCATIONS_METHOD_WPS < method) { + LOCATIONS_LOGE("Not supported method [%d]", method); + return LOCATIONS_ERROR_INCORRECT_METHOD; + } + + LOCATIONS_LOGD("location_manager_is_enabled_method %d", method); + LOCATIONS_NULL_ARG_CHECK(enable); + int is_enabled_val = -1; + LocationMethod _method = __convert_LocationMethod(method); + int ret = location_is_enabled_method(_method, &is_enabled_val); + if (ret != LOCATION_ERROR_NONE) { + if (ret == LOCATION_ERROR_NOT_SUPPORTED) + return LOCATIONS_ERROR_INCORRECT_METHOD; + return __convert_error_code(ret); + } + if (is_enabled_val == -1) + return TIZEN_ERROR_PERMISSION_DENIED; + + *enable = (is_enabled_val == 0) ? FALSE : TRUE; + return LOCATIONS_ERROR_NONE; +} + +EXPORT_API int location_manager_enable_method(const location_method_e method, const bool enable) +{ + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + + if (LOCATIONS_METHOD_HYBRID > method || LOCATIONS_METHOD_WPS < method) { + LOCATIONS_LOGE("Not supported method [%d]", method); + return LOCATIONS_ERROR_INCORRECT_METHOD; + } + + LOCATIONS_LOGD("method: %d, enable: %d", method, enable); + + LocationMethod _method = __convert_LocationMethod(method); + + int ret = location_enable_method(_method, enable); + return __convert_error_code(ret); +} + + +EXPORT_API int location_manager_create(location_method_e method, location_manager_h *manager) +{ + LOCATIONS_LOGD("location_manager_create (method : %d)", method); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + + LocationMethod _method = __convert_LocationMethod(method); + if (_method == LOCATION_METHOD_NONE) { + LOCATIONS_LOGE("LOCATIONS_ERROR_NOT_SUPPORTED(0x%08x) : fail to location_init", LOCATIONS_ERROR_NOT_SUPPORTED); + return LOCATIONS_ERROR_NOT_SUPPORTED; + } + if (!location_is_supported_method(_method)) { + LOCATIONS_LOGE("LOCATIONS_ERROR_NOT_SUPPORTED(0x%08x) : fail to location_is_supported_method", LOCATIONS_ERROR_NOT_SUPPORTED); + return LOCATIONS_ERROR_NOT_SUPPORTED; + } + + /*It is moved here becasue of TCS. */ LOCATIONS_NULL_ARG_CHECK(manager); - if (location_init() != LOCATION_ERROR_NONE) - return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; - LocationMethod _method = LOCATION_METHOD_NONE; - switch (method) { - case LOCATIONS_METHOD_HYBRID: - _method = LOCATION_METHOD_HYBRID; - break; - case LOCATIONS_METHOD_GPS: - _method = LOCATION_METHOD_GPS; - break; - case LOCATIONS_METHOD_WPS: - _method = LOCATION_METHOD_WPS; - break; - case LOCATIONS_METHOD_CPS: - _method = LOCATION_METHOD_CPS; - break; - case LOCATIONS_METHOD_NONE: + if (location_init() != LOCATION_ERROR_NONE) { + LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : fail to location_init", LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; - default: - { - LOCATIONS_LOGE("LOCATIONS_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (location_method_e) - method : %d ", - LOCATIONS_ERROR_INVALID_PARAMETER, method); - return LOCATIONS_ERROR_INVALID_PARAMETER; - } } location_manager_s *handle = (location_manager_s *) malloc(sizeof(location_manager_s)); @@ -392,8 +447,7 @@ EXPORT_API int location_manager_create(location_method_e method, location_manage handle->object = location_new(_method); if (handle->object == NULL) { - LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : fail to location_new", - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : fail to location_new", LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); free(handle); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } @@ -401,8 +455,11 @@ EXPORT_API int location_manager_create(location_method_e method, location_manage handle->is_continue_foreach_bounds = TRUE; handle->bounds_list = NULL; - handle->sig_id[_LOCATION_SIGNAL_SERVICE_ENABLED] = g_signal_connect(handle->object, "service-enabled", G_CALLBACK(__cb_service_enabled), handle); - handle->sig_id[_LOCATION_SIGNAL_SERVICE_DISABLED] = g_signal_connect(handle->object, "service-disabled", G_CALLBACK(__cb_service_disabled), handle); + if (!handle->sig_id[_LOCATION_SIGNAL_SERVICE_ENABLED]) + handle->sig_id[_LOCATION_SIGNAL_SERVICE_ENABLED] = g_signal_connect(handle->object, "service-enabled", G_CALLBACK(__cb_service_enabled), handle); + + if (!handle->sig_id[_LOCATION_SIGNAL_SERVICE_DISABLED]) + handle->sig_id[_LOCATION_SIGNAL_SERVICE_DISABLED] = g_signal_connect(handle->object, "service-disabled", G_CALLBACK(__cb_service_disabled), handle); *manager = (location_manager_h) handle; return LOCATIONS_ERROR_NONE; @@ -410,11 +467,20 @@ EXPORT_API int location_manager_create(location_method_e method, location_manage EXPORT_API int location_manager_destroy(location_manager_h manager) { + LOCATIONS_LOGD("location_manager_destroy"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); location_manager_s *handle = (location_manager_s *) manager; - g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_SERVICE_ENABLED]); - g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_SERVICE_DISABLED]); + if (handle->sig_id[_LOCATION_SIGNAL_SERVICE_ENABLED]) { + g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_SERVICE_ENABLED]); + handle->sig_id[_LOCATION_SIGNAL_SERVICE_ENABLED] = 0; + } + + if (handle->sig_id[_LOCATION_SIGNAL_SERVICE_DISABLED]) { + g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_SERVICE_DISABLED]); + handle->sig_id[_LOCATION_SIGNAL_SERVICE_DISABLED] = 0; + } int ret = location_free(handle->object); if (ret != LOCATIONS_ERROR_NONE) { @@ -426,12 +492,28 @@ EXPORT_API int location_manager_destroy(location_manager_h manager) EXPORT_API int location_manager_start(location_manager_h manager) { + LOCATIONS_LOGD("location_manager_start"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); location_manager_s *handle = (location_manager_s *) manager; - handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED] = g_signal_connect(handle->object, "service-updated", G_CALLBACK(__cb_service_updated), handle); - handle->sig_id[_LOCATION_SIGNAL_ZONE_IN] = g_signal_connect(handle->object, "zone-in", G_CALLBACK(__cb_zone_in), handle); - handle->sig_id[_LOCATION_SIGNAL_ZONE_OUT] = g_signal_connect(handle->object, "zone-out", G_CALLBACK(__cb_zone_out), handle); + if (!handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED]) + handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED] = g_signal_connect(handle->object, "service-updated", G_CALLBACK(__cb_service_updated), handle); + + if (LOCATIONS_METHOD_HYBRID <= handle->method && LOCATIONS_METHOD_WPS >= handle->method) { + if (!handle->sig_id[_LOCATION_SIGNAL_ZONE_IN]) + handle->sig_id[_LOCATION_SIGNAL_ZONE_IN] = g_signal_connect(handle->object, "zone-in", G_CALLBACK(__cb_zone_in), handle); + + if (!handle->sig_id[_LOCATION_SIGNAL_ZONE_OUT]) + handle->sig_id[_LOCATION_SIGNAL_ZONE_OUT] = g_signal_connect(handle->object, "zone-out", G_CALLBACK(__cb_zone_out), handle); + } else { + LOCATIONS_LOGI("This method [%d] is not supported zone-in, zone-out signal.", handle->method); + } + + if (handle->user_cb[_LOCATIONS_EVENT_TYPE_SATELLITE] != NULL) { + LOCATIONS_LOGI("Satellite update_cb is set"); + location_set_option(handle->object, "USE_SV"); + } int ret = location_start(handle->object); if (ret != LOCATION_ERROR_NONE) { @@ -440,14 +522,59 @@ EXPORT_API int location_manager_start(location_manager_h manager) return LOCATIONS_ERROR_NONE; } +EXPORT_API int location_manager_request_single_location(location_manager_h manager, int timeout, location_updated_cb callback, void *user_data) +{ + LOCATIONS_LOGD("location_manager_request_single_location"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + LOCATIONS_NULL_ARG_CHECK(manager); + LOCATIONS_NULL_ARG_CHECK(callback); + if (timeout <= 0 || timeout > 120) { + LOCATIONS_LOGE("timeout scope is incorrect(1~120) [%d]", timeout); + return LOCATIONS_ERROR_INVALID_PARAMETER; + } + + location_manager_s *handle = (location_manager_s *) manager; + int ret = LOCATIONS_ERROR_NONE; + + if (!handle->sig_id[_LOCATION_SIGNAL_LOCATION_UPDATED]) + handle->sig_id[_LOCATION_SIGNAL_LOCATION_UPDATED] = g_signal_connect(handle->object, "location-updated", G_CALLBACK(__cb_location_updated), handle); + + ret = __set_callback(_LOCATIONS_EVENT_TYPE_LOCATION, manager, callback, user_data); + if (ret != LOCATIONS_ERROR_NONE) { + return ret; + } + + ret = location_request_single_location(handle->object, timeout); + if (ret != LOCATION_ERROR_NONE) { + return __convert_error_code(ret); + } + return LOCATIONS_ERROR_NONE; +} + EXPORT_API int location_manager_stop(location_manager_h manager) { + LOCATIONS_LOGD("location_manager_stop"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); + location_manager_s *handle = (location_manager_s *) manager; - g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED]); - g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_ZONE_IN]); - g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_ZONE_OUT]); + if (handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED]) { + g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED]); + handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED] = 0; + } + + if (LOCATIONS_METHOD_HYBRID <= handle->method && LOCATIONS_METHOD_WPS >= handle->method) { + if (handle->sig_id[_LOCATION_SIGNAL_ZONE_IN]) { + g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_ZONE_IN]); + handle->sig_id[_LOCATION_SIGNAL_ZONE_IN] = 0; + } + + if (handle->sig_id[_LOCATION_SIGNAL_ZONE_OUT]) { + g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_ZONE_OUT]); + handle->sig_id[_LOCATION_SIGNAL_ZONE_OUT] = 0; + } + } int ret = location_stop(handle->object); if (ret != LOCATION_ERROR_NONE) { @@ -458,6 +585,8 @@ EXPORT_API int location_manager_stop(location_manager_h manager) EXPORT_API int location_manager_add_boundary(location_manager_h manager, location_bounds_h bounds) { + LOCATIONS_LOGD("location_manager_add_boundary"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(bounds); @@ -474,6 +603,8 @@ EXPORT_API int location_manager_add_boundary(location_manager_h manager, locatio EXPORT_API int location_manager_remove_boundary(location_manager_h manager, location_bounds_h bounds) { + LOCATIONS_LOGD("location_manager_remove_boundary"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(bounds); @@ -490,6 +621,8 @@ EXPORT_API int location_manager_remove_boundary(location_manager_h manager, loca EXPORT_API int location_manager_foreach_boundary(location_manager_h manager, location_bounds_cb callback, void *user_data) { + LOCATIONS_LOGD("location_manager_foreach_boundary"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(callback); @@ -504,43 +637,44 @@ EXPORT_API int location_manager_foreach_boundary(location_manager_h manager, loc return LOCATIONS_ERROR_NONE; } -EXPORT_API int location_manager_get_method(location_manager_h manager, location_method_e * method) +EXPORT_API int location_manager_get_method(location_manager_h manager, location_method_e *method) { + LOCATIONS_LOGD("location_manager_get_method %d", method); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(method); + location_manager_s *handle = (location_manager_s *) manager; LocationMethod _method = LOCATION_METHOD_NONE; g_object_get(handle->object, "method", &_method, NULL); switch (_method) { - case LOCATION_METHOD_NONE: - *method = LOCATIONS_METHOD_NONE; - break; - case LOCATION_METHOD_HYBRID: - *method = LOCATIONS_METHOD_HYBRID; - break; - case LOCATION_METHOD_GPS: - *method = LOCATIONS_METHOD_GPS; - break; - case LOCATION_METHOD_WPS: - *method = LOCATIONS_METHOD_WPS; - break; - case LOCATION_METHOD_CPS: - *method = LOCATIONS_METHOD_CPS; - break; - default: - { - LOCATIONS_LOGE("LOCATIONS_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (location_method_e) - method : %d ", - LOCATIONS_ERROR_INVALID_PARAMETER, method); - return LOCATIONS_ERROR_INVALID_PARAMETER; - } + case LOCATION_METHOD_NONE: + *method = LOCATIONS_METHOD_NONE; + break; + case LOCATION_METHOD_HYBRID: + *method = LOCATIONS_METHOD_HYBRID; + break; + case LOCATION_METHOD_GPS: + *method = LOCATIONS_METHOD_GPS; + break; + case LOCATION_METHOD_WPS: + *method = LOCATIONS_METHOD_WPS; + break; + default: { + LOCATIONS_LOGE("LOCATIONS_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (location_method_e) - method : %d ", + LOCATIONS_ERROR_INVALID_PARAMETER, method); + return LOCATIONS_ERROR_INVALID_PARAMETER; + } } - //*method = handle->method; + /**method = handle->method; */ return LOCATIONS_ERROR_NONE; } EXPORT_API int location_manager_get_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, - time_t * timestamp) + time_t *timestamp) { + LOCATIONS_LOGD("location_manager_get_position"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(altitude); LOCATIONS_NULL_ARG_CHECK(latitude); @@ -557,17 +691,11 @@ EXPORT_API int location_manager_get_position(location_manager_h manager, double } if (pos->status == LOCATION_STATUS_NO_FIX) { - *altitude = -1; - *latitude = -1; - *longitude = -1; + return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } else { - if (pos->status == LOCATION_STATUS_3D_FIX) { - *altitude = pos->altitude; - } else { - *altitude = -1; - } *latitude = pos->latitude; *longitude = pos->longitude; + *altitude = pos->altitude; } *timestamp = pos->timestamp; location_position_free(pos); @@ -577,6 +705,8 @@ EXPORT_API int location_manager_get_position(location_manager_h manager, double EXPORT_API int location_manager_get_location(location_manager_h manager, double *altitude, double *latitude, double *longitude, double *climb, double *direction, double *speed, location_accuracy_level_e *level, double *horizontal, double *vertical, time_t *timestamp) { + LOCATIONS_LOGD("location_manager_get_location"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(altitude); LOCATIONS_NULL_ARG_CHECK(latitude); @@ -600,17 +730,11 @@ EXPORT_API int location_manager_get_location(location_manager_h manager, double } if (pos->status == LOCATION_STATUS_NO_FIX) { - *altitude = -1; - *latitude = -1; - *longitude = -1; + return __convert_error_code(LOCATION_ERROR_NOT_AVAILABLE); } else { - if (pos->status == LOCATION_STATUS_3D_FIX) { - *altitude = pos->altitude; - } else { - *altitude = -1; - } *latitude = pos->latitude; *longitude = pos->longitude; + *altitude = pos->altitude; } *timestamp = pos->timestamp; *climb = vel->climb; @@ -626,8 +750,10 @@ EXPORT_API int location_manager_get_location(location_manager_h manager, double return LOCATIONS_ERROR_NONE; } -EXPORT_API int location_manager_get_velocity(location_manager_h manager, double *climb, double *direction, double *speed, time_t * timestamp) +EXPORT_API int location_manager_get_velocity(location_manager_h manager, double *climb, double *direction, double *speed, time_t *timestamp) { + LOCATIONS_LOGD("location_manager_get_velocity"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(climb); LOCATIONS_NULL_ARG_CHECK(direction); @@ -652,9 +778,11 @@ EXPORT_API int location_manager_get_velocity(location_manager_h manager, double return LOCATIONS_ERROR_NONE; } -EXPORT_API int location_manager_get_accuracy(location_manager_h manager, location_accuracy_level_e * level, double *horizontal, - double *vertical) +EXPORT_API int location_manager_get_accuracy(location_manager_h manager, location_accuracy_level_e *level, double *horizontal, + double *vertical) { + LOCATIONS_LOGD("location_manager_get_accuracy"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(level); LOCATIONS_NULL_ARG_CHECK(horizontal); @@ -682,8 +810,10 @@ EXPORT_API int location_manager_get_accuracy(location_manager_h manager, locatio } EXPORT_API int location_manager_get_last_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, - time_t * timestamp) + time_t *timestamp) { + LOCATIONS_LOGD("location_manager_get_last_position"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(altitude); LOCATIONS_NULL_ARG_CHECK(latitude); @@ -701,17 +831,11 @@ EXPORT_API int location_manager_get_last_position(location_manager_h manager, do } if (last_pos->status == LOCATION_STATUS_NO_FIX) { - *altitude = -1; - *latitude = -1; - *longitude = -1; + return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } else { - if (last_pos->status == LOCATION_STATUS_3D_FIX) { - *altitude = last_pos->altitude; - } else { - *altitude = -1; - } *latitude = last_pos->latitude; *longitude = last_pos->longitude; + *altitude = last_pos->altitude; } *timestamp = last_pos->timestamp; location_position_free(last_pos); @@ -719,8 +843,10 @@ EXPORT_API int location_manager_get_last_position(location_manager_h manager, do return LOCATIONS_ERROR_NONE; } -EXPORT_API int location_manager_get_last_location(location_manager_h manager, double *altitude, double *latitude, double *longitude, double *climb, double *direction, double *speed, location_accuracy_level_e * level, double *horizontal, double *vertical, time_t * timestamp) +EXPORT_API int location_manager_get_last_location(location_manager_h manager, double *altitude, double *latitude, double *longitude, double *climb, double *direction, double *speed, location_accuracy_level_e *level, double *horizontal, double *vertical, time_t *timestamp) { + LOCATIONS_LOGD("location_manager_get_last_location"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(altitude); LOCATIONS_NULL_ARG_CHECK(latitude); @@ -745,17 +871,11 @@ EXPORT_API int location_manager_get_last_location(location_manager_h manager, do } if (last_pos->status == LOCATION_STATUS_NO_FIX) { - *altitude = -1; - *latitude = -1; - *longitude = -1; + return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } else { - if (last_pos->status == LOCATION_STATUS_3D_FIX) { - *altitude = last_pos->altitude; - } else { - *altitude = -1; - } *latitude = last_pos->latitude; *longitude = last_pos->longitude; + *altitude = last_pos->altitude; } *timestamp = last_pos->timestamp; *climb = last_vel->climb; @@ -770,8 +890,10 @@ EXPORT_API int location_manager_get_last_location(location_manager_h manager, do return LOCATIONS_ERROR_NONE; } -EXPORT_API int location_manager_get_last_velocity(location_manager_h manager, double *climb, double *direction, double *speed, time_t * timestamp) +EXPORT_API int location_manager_get_last_velocity(location_manager_h manager, double *climb, double *direction, double *speed, time_t *timestamp) { + LOCATIONS_LOGD("location_manager_get_last_velocity"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(climb); LOCATIONS_NULL_ARG_CHECK(direction); @@ -797,9 +919,11 @@ EXPORT_API int location_manager_get_last_velocity(location_manager_h manager, do return LOCATIONS_ERROR_NONE; } -EXPORT_API int location_manager_get_last_accuracy(location_manager_h manager, location_accuracy_level_e * level, double *horizontal, - double *vertical) +EXPORT_API int location_manager_get_last_accuracy(location_manager_h manager, location_accuracy_level_e *level, double *horizontal, + double *vertical) { + LOCATIONS_LOGD("location_manager_get_last_accuracy"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(level); LOCATIONS_NULL_ARG_CHECK(horizontal); @@ -822,13 +946,15 @@ EXPORT_API int location_manager_get_last_accuracy(location_manager_h manager, lo return LOCATIONS_ERROR_NONE; } -EXPORT_API int location_manager_get_accessibility_state(location_accessibility_state_e* state) +EXPORT_API int location_manager_get_accessibility_state(location_accessibility_state_e *state) { + LOCATIONS_LOGD("location_manager_get_accessibility_state"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(state); int ret = LOCATION_ERROR_NONE; LocationAccessState auth = LOCATION_ACCESS_NONE; - ret = location_get_accessibility_state (&auth); + ret = location_get_accessibility_state(&auth); if (ret != LOCATION_ERROR_NONE) { *state = LOCATIONS_ACCESS_STATE_NONE; return __convert_error_code(ret); @@ -850,10 +976,54 @@ EXPORT_API int location_manager_get_accessibility_state(location_accessibility_s return LOCATIONS_ERROR_NONE; } +EXPORT_API int location_manager_set_distance_based_location_changed_cb(location_manager_h manager, location_changed_cb callback, int interval, double distance, void *user_data) +{ + LOCATIONS_LOGD("location_manager_set_distance_updated_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + LOCATIONS_CHECK_CONDITION(interval >= 1 && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(distance > 0 && distance <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_NULL_ARG_CHECK(manager); + location_manager_s *handle = (location_manager_s *) manager; + g_object_set(handle->object, "min-interval", interval, NULL); + g_object_set(handle->object, "min-distance", distance, NULL); + return __set_callback(_LOCATIONS_EVENT_TYPE_DISTANCE, manager, callback, user_data); +} + +EXPORT_API int location_manager_unset_distance_based_location_changed_cb(location_manager_h manager) +{ + LOCATIONS_LOGD("location_manager_unset_distance_updated_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + LOCATIONS_NULL_ARG_CHECK(manager); + location_manager_s *handle = (location_manager_s *) manager; + g_object_set(handle->object, "min-interval", 0, NULL); + g_object_set(handle->object, "min-distance", 0, NULL); + return __unset_callback(_LOCATIONS_EVENT_TYPE_DISTANCE, manager); +} + +EXPORT_API int location_manager_set_location_changed_cb(location_manager_h manager, location_changed_cb callback, int interval, void *user_data) +{ + LOCATIONS_LOGD("location_manager_set_location_updated_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + LOCATIONS_CHECK_CONDITION(interval >= 1 && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_NULL_ARG_CHECK(manager); + location_manager_s *handle = (location_manager_s *) manager; + g_object_set(handle->object, "loc-interval", interval, NULL); + return __set_callback(_LOCATIONS_EVENT_TYPE_POS_VEL, manager, callback, user_data); +} + +EXPORT_API int location_manager_unset_location_changed_cb(location_manager_h manager) +{ + LOCATIONS_LOGD("location_manager_unset_position_updated_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + return __unset_callback(_LOCATIONS_EVENT_TYPE_POS_VEL, manager); +} + EXPORT_API int location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, int interval, void *user_data) { + LOCATIONS_LOGD("location_manager_set_position_updated_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_CHECK_CONDITION(interval >= 1 - && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); LOCATIONS_NULL_ARG_CHECK(manager); location_manager_s *handle = (location_manager_s *) manager; g_object_set(handle->object, "pos-interval", interval, NULL); @@ -862,13 +1032,16 @@ EXPORT_API int location_manager_set_position_updated_cb(location_manager_h manag EXPORT_API int location_manager_unset_position_updated_cb(location_manager_h manager) { + LOCATIONS_LOGD("location_manager_unset_position_updated_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); return __unset_callback(_LOCATIONS_EVENT_TYPE_POSITION, manager); } EXPORT_API int location_manager_set_velocity_updated_cb(location_manager_h manager, location_velocity_updated_cb callback, int interval, void *user_data) { - LOCATIONS_CHECK_CONDITION(interval >= 1 - && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_LOGD("location_manager_set_velocity_updated_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + LOCATIONS_CHECK_CONDITION(interval >= 1 && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); LOCATIONS_NULL_ARG_CHECK(manager); location_manager_s *handle = (location_manager_s *) manager; g_object_set(handle->object, "vel-interval", interval, NULL); @@ -877,126 +1050,163 @@ EXPORT_API int location_manager_set_velocity_updated_cb(location_manager_h manag EXPORT_API int location_manager_unset_velocity_updated_cb(location_manager_h manager) { + LOCATIONS_LOGD("location_manager_unset_velocity_updated_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); return __unset_callback(_LOCATIONS_EVENT_TYPE_VELOCITY, manager); } EXPORT_API int location_manager_set_service_state_changed_cb(location_manager_h manager, location_service_state_changed_cb callback, - void *user_data) + void *user_data) { + LOCATIONS_LOGD("location_manager_set_service_state_changed_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); return __set_callback(_LOCATIONS_EVENT_TYPE_SERVICE_STATE, manager, callback, user_data); } EXPORT_API int location_manager_unset_service_state_changed_cb(location_manager_h manager) { + LOCATIONS_LOGD("location_manager_unset_service_state_changed_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); return __unset_callback(_LOCATIONS_EVENT_TYPE_SERVICE_STATE, manager); } EXPORT_API int location_manager_set_zone_changed_cb(location_manager_h manager, location_zone_changed_cb callback, void *user_data) { + LOCATIONS_LOGD("location_manager_set_zone_changed_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); return __set_callback(_LOCATIONS_EVENT_TYPE_BOUNDARY, manager, callback, user_data); } EXPORT_API int location_manager_unset_zone_changed_cb(location_manager_h manager) { + LOCATIONS_LOGD("location_manager_unset_zone_changed_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); return __unset_callback(_LOCATIONS_EVENT_TYPE_BOUNDARY, manager); } -EXPORT_API int location_manager_get_distance(double start_latitude, double start_longitude, double end_latitude, double end_longitude, double *distance) +EXPORT_API int location_manager_set_setting_changed_cb(location_method_e method, location_setting_changed_cb callback, void *user_data) { - LOCATIONS_NULL_ARG_CHECK(distance); - LOCATIONS_CHECK_CONDITION(start_latitude>=-90 && start_latitude<=90,LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER"); - LOCATIONS_CHECK_CONDITION(start_longitude>=-180 && start_longitude<=180,LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); - LOCATIONS_CHECK_CONDITION(end_latitude>=-90 && end_latitude<=90,LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); - LOCATIONS_CHECK_CONDITION(end_longitude>=-180 && end_longitude<=180,LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_LOGD("location_manager_set_setting_changed_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + LOCATIONS_NULL_ARG_CHECK(callback); + LocationMethod _method = __convert_LocationMethod(method); int ret = LOCATION_ERROR_NONE; - ulong u_distance; - LocationPosition *start = location_position_new (0, start_latitude, start_longitude, 0, LOCATION_STATUS_2D_FIX); - LocationPosition *end = location_position_new (0, end_latitude, end_longitude, 0, LOCATION_STATUS_2D_FIX); + if (_method == LOCATION_METHOD_NONE) { + return __convert_error_code(LOCATION_ERROR_PARAMETER); + } + + g_location_setting[_method].callback = callback; + g_location_setting[_method].user_data = user_data; - ret = location_get_distance (start, end, &u_distance); + ret = location_add_setting_notify(_method, __setting_changed_cb, &g_location_setting); if (ret != LOCATION_ERROR_NONE) { return __convert_error_code(ret); } - *distance = (double)u_distance; + return LOCATIONS_ERROR_NONE; +} + +EXPORT_API int location_manager_unset_setting_changed_cb(location_method_e method) +{ + LOCATIONS_LOGD("location_manager_unset_setting_changed_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + LocationMethod _method = __convert_LocationMethod(method); + int ret = LOCATION_ERROR_NONE; + + if (_method == LOCATION_METHOD_NONE) { + return __convert_error_code(LOCATION_ERROR_PARAMETER); + } + + ret = location_ignore_setting_notify(_method, __setting_changed_cb); + if (ret != LOCATION_ERROR_NONE) { + LOCATIONS_LOGE("Fail to ignore notify. Error[%d]", ret); + ret = __convert_error_code(ret); + } + + g_location_setting[method].callback = NULL; + g_location_setting[method].user_data = NULL; return LOCATIONS_ERROR_NONE; } -EXPORT_API int location_manager_send_command(const char *cmd) +EXPORT_API int location_manager_get_distance(double start_latitude, double start_longitude, double end_latitude, double end_longitude, double *distance) { - LOCATIONS_NULL_ARG_CHECK(cmd); + LOCATIONS_LOGD("location_manager_get_distance"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + LOCATIONS_NULL_ARG_CHECK(distance); + LOCATIONS_CHECK_CONDITION(start_latitude >= -90 && start_latitude <= 90, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(start_longitude >= -180 && start_longitude <= 180, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(end_latitude >= -90 && end_latitude <= 90, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(end_longitude >= -180 && end_longitude <= 180, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); - int ret; - ret = location_send_command(cmd); + int ret = LOCATION_ERROR_NONE; + ulong u_distance; + + LocationPosition *start = location_position_new(0, start_latitude, start_longitude, 0, LOCATION_STATUS_2D_FIX); + LocationPosition *end = location_position_new(0, end_latitude, end_longitude, 0, LOCATION_STATUS_2D_FIX); + + ret = location_get_distance(start, end, &u_distance); if (ret != LOCATION_ERROR_NONE) { return __convert_error_code(ret); } + *distance = (double)u_distance; + return LOCATIONS_ERROR_NONE; } -///////////////////////////////////////// -// GPS Status & Satellites -//////////////////////////////////////// +/*/////////////////////////////////////// */ +/* GPS Status & Satellites */ +/*////////////////////////////////////// */ EXPORT_API int gps_status_get_nmea(location_manager_h manager, char **nmea) { + LOCATIONS_LOGD("gps_status_get_nmea"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(nmea); location_manager_s *handle = (location_manager_s *) manager; + char *nmea_data; - if (handle->method == LOCATIONS_METHOD_HYBRID) { - LocationMethod _method = LOCATION_METHOD_NONE; - g_object_get(handle->object, "method", &_method, NULL); - if (_method != LOCATION_METHOD_GPS) { - LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", - LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); - return LOCATIONS_ERROR_INCORRECT_METHOD; + int ret = location_get_nmea(handle->object, &nmea_data); + if (ret != LOCATION_ERROR_NONE || nmea == NULL) { + if (ret == LOCATION_ERROR_NOT_ALLOWED) { + LOCATIONS_LOGE("LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED"); + return LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED; } - } else if (handle->method != LOCATIONS_METHOD_GPS) { - LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", - LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); - return LOCATIONS_ERROR_INCORRECT_METHOD; - } - gchar *nmea_data = NULL; - g_object_get(handle->object, "nmea", &nmea_data, NULL); - if (nmea_data == NULL) { - LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : nmea data is NULL ", - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + + LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : NMEA is NULL ", + LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } - *nmea = NULL; - *nmea = strdup(nmea_data); - if (*nmea == NULL) { - LOCATIONS_LOGE("LOCATIONS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to strdup ", - LOCATIONS_ERROR_OUT_OF_MEMORY); - return LOCATIONS_ERROR_OUT_OF_MEMORY; - } + + *nmea = g_strdup(nmea_data); g_free(nmea_data); + return LOCATIONS_ERROR_NONE; } EXPORT_API int gps_status_get_satellite(location_manager_h manager, int *num_of_active, int *num_of_inview, time_t *timestamp) { + LOCATIONS_LOGD("gps_status_get_satellite"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(num_of_active); LOCATIONS_NULL_ARG_CHECK(num_of_inview); LOCATIONS_NULL_ARG_CHECK(timestamp); location_manager_s *handle = (location_manager_s *) manager; LocationSatellite *sat = NULL; - int ret = location_get_satellite (handle->object, &sat); + int ret = location_get_satellite(handle->object, &sat); if (ret != LOCATION_ERROR_NONE || sat == NULL) { - if (ret == LOCATION_ERROR_NOT_SUPPORTED) { - LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", - LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); - return LOCATIONS_ERROR_INCORRECT_METHOD; + if (ret == LOCATION_ERROR_NOT_ALLOWED) { + LOCATIONS_LOGE("LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED"); + return LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED; } LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } @@ -1010,36 +1220,47 @@ EXPORT_API int gps_status_get_satellite(location_manager_h manager, int *num_of_ EXPORT_API int gps_status_set_satellite_updated_cb(location_manager_h manager, gps_status_satellite_updated_cb callback, int interval, void *user_data) { - LOCATIONS_CHECK_CONDITION(interval >= 1 - && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_LOGD("gps_status_set_satellite_updated_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); + LOCATIONS_CHECK_CONDITION(interval >= 1 && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); LOCATIONS_NULL_ARG_CHECK(manager); + LOCATIONS_NULL_ARG_CHECK(callback); + location_manager_s *handle = (location_manager_s *) manager; + location_set_option(handle->object, "USE_SV"); g_object_set(handle->object, "sat-interval", interval, NULL); return __set_callback(_LOCATIONS_EVENT_TYPE_SATELLITE, manager, callback, user_data); } EXPORT_API int gps_status_unset_satellite_updated_cb(location_manager_h manager) { + LOCATIONS_LOGD("gps_status_unset_satellite_updated_cb"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); return __unset_callback(_LOCATIONS_EVENT_TYPE_SATELLITE, manager); } - EXPORT_API int gps_status_foreach_satellites_in_view(location_manager_h manager, gps_status_get_satellites_cb callback, void *user_data) { + LOCATIONS_LOGD("gps_status_foreach_satellites_in_view"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(callback); + location_manager_s *handle = (location_manager_s *) manager; LocationSatellite *sat = NULL; - int ret = location_get_satellite (handle->object, &sat); + int ret = location_get_satellite(handle->object, &sat); if (ret != LOCATION_ERROR_NONE || sat == NULL) { if (ret == LOCATION_ERROR_NOT_SUPPORTED) { LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", - LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); + LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); return LOCATIONS_ERROR_INCORRECT_METHOD; + } else if (ret == LOCATION_ERROR_NOT_ALLOWED) { + LOCATIONS_LOGE("LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED"); + return LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED; } LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } @@ -1061,10 +1282,13 @@ EXPORT_API int gps_status_foreach_satellites_in_view(location_manager_h manager, EXPORT_API int gps_status_get_last_satellite(location_manager_h manager, int *num_of_active, int *num_of_inview, time_t *timestamp) { + LOCATIONS_LOGD("gps_status_get_last_satellite"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(num_of_active); LOCATIONS_NULL_ARG_CHECK(num_of_inview); LOCATIONS_NULL_ARG_CHECK(timestamp); + location_manager_s *handle = (location_manager_s *) manager; int ret = LOCATION_ERROR_NONE; LocationSatellite *last_sat = NULL; @@ -1072,12 +1296,15 @@ EXPORT_API int gps_status_get_last_satellite(location_manager_h manager, int *nu if (ret != LOCATION_ERROR_NONE || last_sat == NULL) { if (ret == LOCATION_ERROR_NOT_SUPPORTED) { LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", - LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); + LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); return LOCATIONS_ERROR_INCORRECT_METHOD; + } else if (ret == LOCATION_ERROR_NOT_ALLOWED) { + LOCATIONS_LOGE("LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED"); + return LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED; } LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } @@ -1089,8 +1316,10 @@ EXPORT_API int gps_status_get_last_satellite(location_manager_h manager, int *nu } EXPORT_API int gps_status_foreach_last_satellites_in_view(location_manager_h manager, gps_status_get_satellites_cb callback, - void *user_data) + void *user_data) { + LOCATIONS_LOGD("gps_status_foreach_last_satellites_in_view"); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(callback); location_manager_s *handle = (location_manager_s *) manager; @@ -1100,12 +1329,12 @@ EXPORT_API int gps_status_foreach_last_satellites_in_view(location_manager_h man if (ret != LOCATION_ERROR_NONE || last_sat == NULL) { if (ret == LOCATION_ERROR_NOT_SUPPORTED) { LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", - LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); + LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); return LOCATIONS_ERROR_INCORRECT_METHOD; } LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index afc523f..475882f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,16 +4,20 @@ SET(fw_test "${fw_name}-test") INCLUDE(FindPkgConfig) pkg_check_modules(${fw_test} REQUIRED ) FOREACH(flag ${${fw_test}_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror") aux_source_directory(. sources) FOREACH(src ${sources}) - GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) - MESSAGE("${src_name}") - ADD_EXECUTABLE(${src_name} ${src}) - TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) + GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) + MESSAGE("${src_name}") + ADD_EXECUTABLE(${src_name} ${src}) + TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) ENDFOREACH() +INSTALL(TARGETS ${src_name} DESTINATION /opt/usr/devel/location/) +INSTALL(FILES ${fw_test}.efl DESTINATION /etc/smack/accesses.d) + + diff --git a/test/capi-location-manager-test.efl b/test/capi-location-manager-test.efl new file mode 100644 index 0000000..0c12eb3 --- /dev/null +++ b/test/capi-location-manager-test.efl @@ -0,0 +1,30 @@ +capi-location-manager-test sys-assert::core rwxat- ------ +org.tizen.crash-popup capi-location-manager-test --x--- ------ +capi-location-manager-test privacy-manager::db rwxa-- ------ +capi-location-manager-test privacy-manager::daemon -w---- ------ +capi-location-manager-test sdbd rwx--l ------ +capi-location-manager-test wrt-security-daemon rwx--l ------ +capi-location-manager-test aul::launch --x--- ------ +capi-location-manager-test org.tizen.browser --x--- ------ +capi-location-manager-test xorg -w---- ------ +capi-location-manager-test aul r----- ------ +capi-location-manager-test isf r----- ------ +capi-location-manager-test pkgmgr::db r----l ------ +capi-location-manager-test pkgmgr::info r----- ------ +capi-location-manager-test ail::db r----- ------ +capi-location-manager-test system::vconf_inhouse r----l ------ +capi-location-manager-test system::vconf_system r----l ------ +capi-location-manager-test system::vconf_setting r----l ------ +capi-location-manager-test system::vconf_multimedia r----l ------ +capi-location-manager-test system::vconf_misc rwx--l ------ +capi-location-manager-test system::vconf_privacy rwx--- ------ +capi-location-manager-test system::vconf rwxat- ------ +capi-location-manager-test system::vconf_network rw---- ------ +capi-location-manager-test system::share rwxat- ------ +capi-location-manager-test system::hwcodec rw---- ------ +capi-location-manager-test system::crash -wx--- ------ +capi-location-manager-test system::use_internet rw---- ------ +capi-location-manager-test system::app_logging -w---- ------ +capi-location-manager-test location_fw::vconf rw---- ------ +capi-location-manager-test location_fw::client rw---- ------ +capi-location-manager-test location_fw::server r----- ------ diff --git a/test/capi-location-manager-test.manifest b/test/capi-location-manager-test.manifest new file mode 100755 index 0000000..be3e59b --- /dev/null +++ b/test/capi-location-manager-test.manifest @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/test/location_test.c b/test/location_test.c old mode 100644 new mode 100755 index 5efd4e5..500a73c --- a/test/location_test.c +++ b/test/location_test.c @@ -21,15 +21,35 @@ #include #include -location_manager_h manager; +static location_manager_h manager; +static GMainLoop *g_mainloop = NULL; +static char *menu; + +static void location_cleanup(); +static int location_test(); +static gboolean exit_program(gpointer data) +{ + g_main_loop_quit(g_mainloop); + + return FALSE; +} + +static gboolean wait_test() +{ + location_cleanup(); + location_test(); + + return FALSE; +} + +#if 0 void zone_event_cb(location_boundary_state_e state, double latitude, double longitude, double altitude, time_t timestamp, - void *user_data) + void *user_data) { if (state == LOCATIONS_BOUNDARY_IN) { printf("Entering zone\n"); - } else // state == LOCATIONS_BOUNDARY_OUT - { + } else { /* state == LOCATIONS_BOUNDARY_OUT */ printf("Leaving zone\n"); } @@ -38,19 +58,20 @@ void zone_event_cb(location_boundary_state_e state, double latitude, double long printf("Time: %s\n", ctime(×tamp)); } -static bool satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use, - void *user_data) +static bool last_satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use, + void *user_data) { - printf("[Satellite information] azimuth : %d, elevation : %d, prn :%d, snr : %d, used: %d\n", azimuth, elevation, prn, - snr, is_in_use); + printf("[Last Satellite information] azimuth : %d, elevation: %d, prn: %d, snr: %d, used: %d\n", azimuth, elevation, + prn, snr, is_in_use); return true; } +#endif -static bool last_satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use, - void *user_data) +static bool satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use, + void *user_data) { - printf("[Last Satellite information] azimuth : %d, elevation : %d, prn :%d, snr : %d, used: %d\n", azimuth, elevation, - prn, snr, is_in_use); + printf("[Satellite information] azimuth : %d, elevation: %d, prn: %d, snr: %d, used: %d\n", azimuth, elevation, prn, + snr, is_in_use); return true; } @@ -66,7 +87,7 @@ static void _state_change_cb(location_service_state_e state, void *user_data) time_t timestamp; ret = location_manager_get_position(lm, &altitude, &latitude, &longitude, ×tamp); if (ret != LOCATIONS_ERROR_NONE) { - printf(" Fail : location_manager_get_position ---> %d \n", ret); + printf(" Fail: location_manager_get_position ---> %d \n", ret); } else { printf("[%ld] alt: %g, lat %g, long %g\n", timestamp, altitude, latitude, longitude); } @@ -76,38 +97,42 @@ static void _state_change_cb(location_service_state_e state, void *user_data) double vertical; ret = location_manager_get_accuracy(lm, &level, &horizontal, &vertical); if (ret != LOCATIONS_ERROR_NONE) { - printf(" Fail : location_manager_get_accuracy ---> %d \n", ret); + printf(" Fail: location_manager_get_accuracy ---> %d \n", ret); } else { - printf("Level : %d, horizontal: %g, vertical %g\n", level, horizontal, vertical); + printf("Level: %d, horizontal: %g, vertical %g\n", level, horizontal, vertical); } char *nmea; ret = gps_status_get_nmea(lm, &nmea); if (ret != LOCATIONS_ERROR_NONE) { - printf(" Fail : gps_status_get_nmea ---> %d \n", ret); + printf(" Fail: gps_status_get_nmea ---> %d \n", ret); } else { - printf("NMEA : %s\n", nmea); + printf("NMEA: %s\n", nmea); free(nmea); } - int num_of_view, num_of_active; + int num_of_view = 0, num_of_active = 0; ret = gps_status_get_satellite(lm, &num_of_active, &num_of_view, ×tamp); if (ret != LOCATIONS_ERROR_NONE) { - printf(" Fail : gps_status_get_satellite_count_in_view ---> %d \n", ret); + printf(" Fail: gps_status_get_satellite_count_in_view ---> %d \n", ret); } else { - printf("[%ld] Satellite number of active : %d, in view : %d\n", timestamp, num_of_active, num_of_view); + printf("[%ld] Satellite number of active: %d, in view: %d\n", timestamp, num_of_active, num_of_view); } - ret = gps_status_foreach_satellites_in_view(lm, satellites_foreach_cb, user_data); - if (ret != LOCATIONS_ERROR_NONE) { - printf(" Fail : gps_status_foreach_satellites_in_view ---> %d \n", ret); + if (num_of_view) { + ret = gps_status_foreach_satellites_in_view(lm, satellites_foreach_cb, user_data); + if (ret != LOCATIONS_ERROR_NONE) { + printf(" Fail: gps_status_foreach_satellites_in_view ---> %d \n", ret); + } } + g_timeout_add_seconds(1, wait_test, NULL); } } +#if 0 static bool __poly_coords_cb(location_coords_s coords, void *user_data) { - printf("location_bounds_foreach_rect_coords(latitude : %lf, longitude: %lf) \n", coords.latitude, coords.longitude); + printf("location_bounds_foreach_rect_coords(latitude: %lf, longitude: %lf) \n", coords.latitude, coords.longitude); return TRUE; } @@ -122,14 +147,14 @@ static bool __location_bounds_cb(location_bounds_h bounds, void *user_data) location_coords_s center; double radius; location_bounds_get_circle_coords(bounds, ¢er, &radius); - printf("location_bounds_get_circle_coords(center : %lf, %lf, radius : %lf) \n", center.latitude, + printf("location_bounds_get_circle_coords(center: %lf, %lf, radius: %lf) \n", center.latitude, center.longitude, radius); } else if (type == LOCATION_BOUNDS_RECT) { location_coords_s left_top; location_coords_s right_bottom; location_bounds_get_rect_coords(bounds, &left_top, &right_bottom); - printf("location_bounds_get_rect_coords(left_top : %lf, %lf - right_bottom : %lf, %lf) \n", + printf("location_bounds_get_rect_coords(left_top: %lf, %lf - right_bottom: %lf, %lf) \n", left_top.latitude, left_top.longitude, right_bottom.latitude, right_bottom.longitude); } else if (type == LOCATION_BOUNDS_POLYGON) { location_bounds_foreach_polygon_coords(bounds, __poly_coords_cb, NULL); @@ -164,10 +189,10 @@ void location_bounds_test() if (ret != LOCATIONS_ERROR_NONE) { printf("location_bounds_get_circle_coords() failed\n"); } else - printf("location_bounds_get_circle_coords(center : %lf, %lf, radius : %lf) \n", center2.latitude, + printf("location_bounds_get_circle_coords(center: %lf, %lf, radius: %lf) \n", center2.latitude, center2.longitude, radius2); - //Add the rect bounds + /*Add the rect bounds */ location_coords_s left_top; left_top.latitude = 30; left_top.longitude = 30; @@ -196,10 +221,10 @@ void location_bounds_test() if (ret != LOCATIONS_ERROR_NONE) { printf("location_bounds_get_rect_coords() failed\n"); } else - printf("location_bounds_get_rect_coords(left_top : %lf, %lf - right_bottom : %lf, %lf) \n", left_top2.latitude, + printf("location_bounds_get_rect_coords(left_top: %lf, %lf - right_bottom: %lf, %lf) \n", left_top2.latitude, left_top2.longitude, right_bottom2.latitude, right_bottom2.longitude); - //Add the polygon bounds + /*Add the polygon bounds */ int poly_size = 3; location_coords_s coord_list[poly_size]; @@ -238,7 +263,7 @@ void location_bounds_test() else printf("location_bounds_contains_coordinates() retrun FALSE \n"); - //print current bounds + /*print current bounds */ ret = location_manager_foreach_boundary(manager, __location_bounds_cb, (void *)manager); if (ret != LOCATIONS_ERROR_NONE) { printf("location_manager_foreach_boundary() failed\n"); @@ -258,82 +283,170 @@ void location_get_last_information_test() ret = location_manager_get_last_position(manager, &altitude, &latitude, &longitude, ×tamp); if (ret != LOCATIONS_ERROR_NONE) { - printf(" Fail : location_manager_get_last_position ---> %d \n", ret); + printf(" Fail: location_manager_get_last_position ---> %d \n", ret); } else { printf("[%ld] alt: %g, lat: %g, long: %g\n", timestamp, altitude, latitude, longitude); } ret = location_manager_get_last_velocity(manager, &climb, &direction, &speed, ×tamp); if (ret != LOCATIONS_ERROR_NONE) { - printf(" Fail : location_manager_get_last_velocity ---> %d \n", ret); + printf(" Fail: location_manager_get_last_velocity ---> %d \n", ret); } else { printf("climb: %f, direction: %f, speed: %f\n", climb, direction, speed); } ret = location_manager_get_last_accuracy(manager, &level, &horizontal, &vertical); if (ret != LOCATIONS_ERROR_NONE) { - printf(" Fail : location_manager_get_last_accuracy ---> %d \n", ret); + printf(" Fail: location_manager_get_last_accuracy ---> %d \n", ret); } else { - printf("Level : %d, horizontal: %g, vertical : %g\n", level, horizontal, vertical); + printf("Level: %d, horizontal: %g, vertical: %g\n", level, horizontal, vertical); } ret = gps_status_get_last_satellite(manager, &num_of_active, &num_of_inview, ×tamp); if (ret != LOCATIONS_ERROR_NONE) { - printf(" Fail : gps_status_get_last_satellite_count_in_view ---> %d \n", ret); + printf(" Fail: gps_status_get_last_satellite_count_in_view ---> %d \n", ret); } else { - printf("[%ld] Satellite number of active : %d, in view : %d\n", timestamp, num_of_active, num_of_inview); + printf("[%ld] Satellite number of active: %d, in view: %d\n", timestamp, num_of_active, num_of_inview); } ret = gps_status_foreach_last_satellites_in_view(manager, last_satellites_foreach_cb, NULL); if (ret != LOCATIONS_ERROR_NONE) { - printf(" Fail : gps_status_foreach_last_satellites_in_view ---> %d \n", ret); + printf(" Fail: gps_status_foreach_last_satellites_in_view ---> %d \n", ret); } } +#endif -int location_test() +void location_cb(int error, double latitude, double longitude, double altitude, time_t timestamp, double speed, double climb, double direction, void *user_data) { - int ret; - ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager); - printf("create : %d\n", ret); + printf("error[%d]\n", error); + printf("location_cb: lat[%f] lon[%f] alt[%f]\n", latitude, longitude, altitude); + printf("speed[%f] climb[%f] direction[%f]\n", speed, climb, direction); - location_bounds_test(); - location_get_last_information_test(); + g_timeout_add_seconds(1, wait_test, NULL); +} - //set zone changed callback - ret = location_manager_set_zone_changed_cb(manager, zone_event_cb, (void *)manager); - printf("set zone callback : %d\n", ret); +static void __setting_cb(location_method_e method, bool enable, void *user_data) +{ + printf("method[%d], enable[%d]\n", method, enable); +} - ret = location_manager_set_service_state_changed_cb(manager, _state_change_cb, (void *)manager); - printf("set state callback : %d\n", ret); +static void select_menu() +{ + char buf[256]; + int len = 0; + char *str = NULL; - ret = location_manager_start(manager); - printf("start : %d\n", ret); - return 1; + str = fgets(buf, 255, stdin); + if (NULL == str) { + printf("fgets return NULL. \n"); + } + len = g_utf8_strlen(buf, -1); + buf[len - 1] = '\0'; + + g_free(menu); + menu = g_strdup(buf); } -static GMainLoop *g_mainloop = NULL; +static void print_menu() +{ + printf("==== LOCATION TEST ======\n"); + printf("[1] LOCATIONS_METHOD_HYBRID: Get location\n"); + printf("[2] LOCATIONS_METHOD_GPS: Get location\n"); + printf("[3] LOCATIONS_METHOD_WPS: Get location\n"); + printf("[4] LOCATIONS_METHOD_HYBRID: Single location\n"); + printf("[5] LOCATIONS_METHOD_GPS: Single location\n"); + printf("[x] Exit!!!\n\n"); + printf("Select menu: "); +} -static gboolean exit_program(gpointer data) +static int location_test() { - if (manager == NULL) { - printf("manager == NULL \n"); + int ret = LOCATIONS_ERROR_NONE; + + printf("==== LOCATION STATUS ======\n"); + bool is_enabled = FALSE; + location_manager_is_enabled_method(LOCATIONS_METHOD_HYBRID, &is_enabled); + printf("hybrid: %d, ", is_enabled); + + location_manager_is_enabled_method(LOCATIONS_METHOD_GPS, &is_enabled); + printf("gps: %d, ", is_enabled); + + location_manager_is_enabled_method(LOCATIONS_METHOD_WPS, &is_enabled); + printf("wps: %d\n", is_enabled); + + location_manager_set_setting_changed_cb(LOCATIONS_METHOD_GPS, __setting_cb, NULL); + location_manager_set_setting_changed_cb(LOCATIONS_METHOD_WPS, __setting_cb, NULL); + + print_menu(); + select_menu(); + + if (strcmp(menu, "1") == 0) { + ret = location_manager_create(LOCATIONS_METHOD_HYBRID, &manager); + printf("LOCATIONS_METHOD_HYBRID create: %d\n", ret); + ret = location_manager_start(manager); + printf("start: %d\n", ret); + } else if (strcmp(menu, "2") == 0) { + ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager); + printf("LOCATIONS_METHOD_GPS create: %d\n", ret); + ret = location_manager_start(manager); + printf("start: %d\n", ret); + } else if (strcmp(menu, "3") == 0) { + ret = location_manager_create(LOCATIONS_METHOD_WPS, &manager); + printf("LOCATIONS_METHOD_WPS create: %d\n", ret); + } else if (strcmp(menu, "4") == 0) { + ret = location_manager_create(LOCATIONS_METHOD_HYBRID, &manager); + printf("LOCATIONS_METHOD_HYBRID create: %d\n", ret); + ret = location_manager_request_single_location(manager, 60, location_cb, manager); + printf("single_location create: %d\n", ret); + } else if (strcmp(menu, "5") == 0) { + ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager); + printf("LOCATIONS_METHOD_HYBRID create: %d\n", ret); + ret = location_manager_request_single_location(manager, 60, location_cb, manager); + printf("single_location create: %d\n", ret); + } else if (strcmp(menu, "x") == 0) { + g_timeout_add_seconds(0.1, exit_program, NULL); + return 0; } else { + printf("Exit!!! Input: %s\n", menu); + g_timeout_add_seconds(0.1, exit_program, NULL); + return 0; + } + + if (ret != LOCATIONS_ERROR_NONE) { + printf("Test Failed!!! [%d]\n", ret); + g_timeout_add_seconds(0.1, exit_program, NULL); + return 0; + } + ret = location_manager_set_service_state_changed_cb(manager, _state_change_cb, (void *)manager); + printf("set state callback: %d\n", ret); + + /* location_bounds_test(); */ + /* set zone changed callback */ + /* + ret = location_manager_set_zone_changed_cb(manager, zone_event_cb, (void *)manager); + printf("set zone callback: %d\n", ret); + */ + return 0; +} + +static void location_cleanup() +{ + if (manager != NULL) { int ret = location_manager_stop(manager); - printf("stop : %d\n", ret); + printf("stop: %d\n", ret); ret = location_manager_destroy(manager); - printf("destroy : %d\n", ret); + printf("destroy: %d\n", ret); + manager = NULL; } - g_main_loop_quit(g_mainloop); - printf("Quit g_main_loop\n"); - return FALSE; + location_manager_unset_setting_changed_cb(LOCATIONS_METHOD_GPS); + location_manager_unset_setting_changed_cb(LOCATIONS_METHOD_WPS); } int main(int argc, char **argv) { - g_setenv("PKG_NAME", "com.samsung.location-test", 1); g_mainloop = g_main_loop_new(NULL, 0); location_test(); - g_timeout_add_seconds(90, exit_program, NULL); g_main_loop_run(g_mainloop); + location_cleanup(); return 0; } -- 2.7.4