diff options
author | jk7744.park <jk7744.park@samsung.com> | 2015-02-01 13:30:21 +0900 |
---|---|---|
committer | jk7744.park <jk7744.park@samsung.com> | 2015-02-01 13:30:21 +0900 |
commit | 5bd798a6d40b798b464f90efde0b079c20961a73 (patch) | |
tree | 623197fd8a1c961af788aacb578b9f0da1ec5700 | |
parent | a6e5bd2b3a95c55116a12ad2656e0f55d0a6def3 (diff) | |
download | location-manager-tizen_2.3.tar.gz location-manager-tizen_2.3.tar.bz2 location-manager-tizen_2.3.zip |
tizen 2.3 releasetizen_2.3_releasesubmit/tizen_2.3/20150202.060839tizen_2.3
-rwxr-xr-x | CMakeLists.txt | 80 | ||||
-rw-r--r-- | capi-location-manager.pc.in | 4 | ||||
-rwxr-xr-x | doc/location-manager-doc.h | 228 | ||||
-rw-r--r-- | include/location_batch.h | 101 | ||||
-rw-r--r-- | include/location_bounds.h | 172 | ||||
-rw-r--r--[-rwxr-xr-x] | include/location_internal.h (renamed from include/locations_private.h) | 32 | ||||
-rw-r--r-- | include/location_preference.h | 417 | ||||
-rw-r--r-- | include/locations.h | 916 | ||||
-rwxr-xr-x | packaging/capi-location-manager.spec | 39 | ||||
-rw-r--r--[-rwxr-xr-x] | src/location_bounds.c | 15 | ||||
-rwxr-xr-x | src/location_preference.c | 557 | ||||
-rwxr-xr-x | src/locations.c | 753 | ||||
-rw-r--r-- | test/CMakeLists.txt | 10 | ||||
-rw-r--r-- | test/location_test.c | 123 |
14 files changed, 1787 insertions, 1660 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f9efb7..3bb2c65 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,41 +16,41 @@ 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}") + 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}) -INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(TARGETS ${fw_name} DESTINATION lib) INSTALL( - DIRECTORY ${INC_DIR}/ DESTINATION include/location - FILES_MATCHING - PATTERN "*_private.h" EXCLUDE - PATTERN "${INC_DIR}/*.h" - ) + DIRECTORY ${INC_DIR}/ DESTINATION include/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 lib/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..03acd6e 100644 --- a/capi-location-manager.pc.in +++ b/capi-location-manager.pc.in @@ -3,13 +3,13 @@ prefix=@PREFIX@ exec_prefix=/usr -libdir=@LIB_INSTALL_DIR@ +libdir=/usr/lib includedir=/usr/include/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 100755 index 0000000..6fcd465 --- /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 <locations.h> + * + * @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 <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * + */ + +/** +* @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 <locations.h> +* +* @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 <a href = "http://en.wikipedia.org/wiki/NMEA_0183">NMEA_0183</a>. +* +* 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 <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * +*/ + +/** + * @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 <locations.h> + * + * @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 <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * + */ + +/** + * @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 <location_preference_product.h> + * + * @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 <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * @} + * + */ + +#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..a5310ae --- /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 <locations.h> + +#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..b5d43fe 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,7 +32,8 @@ extern "C" { */ /** - * @brief Represents a coordinates with latitude and longitude. + * @brief The structure type to represent coordinates with latitude and longitude. + * @since_tizen 2.3 */ typedef struct { @@ -41,45 +42,50 @@ typedef struct } 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 */ - 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_IS_ADDED = LOCATION_BOUNDS_ERROR_CLASS | 0x02, /**< Cannot remove bounds handle from location manager */ + 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_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 2.3 */ 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_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 2.3 */ typedef enum { - LOCATIONS_BOUNDARY_IN, /**< Boundary In (Zone In) */ - LOCATIONS_BOUNDARY_OUT /**< Boundary Out (Zone Out) */ + 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 2.3 */ 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 2.3 + * @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 +94,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 2.3 + * @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,14 +105,16 @@ 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 2.3 + * @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() */ @@ -113,14 +122,16 @@ int location_bounds_create_rect(location_coords_s top_left, location_coords_s bo /** * @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 2.3 + * @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() */ @@ -128,26 +139,33 @@ int location_bounds_create_circle(location_coords_s center, double radius, locat /** * @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 2.3 + * @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); /** - * @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 2.3 + * @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 +173,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 2.3 + * @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 +188,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 2.3 + * @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 2.3 + * @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 2.3 + * @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 +236,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 2.3 + * @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,13 +249,15 @@ 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 2.3 + * @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() @@ -236,10 +266,12 @@ int location_bounds_set_state_changed_cb(location_bounds_h bounds, location_boun /** * @brief Unregisters the callback function. - * @param[in] bounds The location bounds handle - * @return 0 on success, otherwise a negative error value. + * @since_tizen 2.3 + * @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/locations_private.h b/include/location_internal.h index 5dd0063..25b540b 100755..100644 --- a/include/locations_private.h +++ b/include/location_internal.h @@ -14,10 +14,10 @@ * limitations under the License. */ -#ifndef __TIZEN_LOCATION_LOCATIONS_PRIVATE_H__ -#define __TIZEN_LOCATION_LOCATIONS_PRIVATE_H__ +#ifndef __TIZEN_LOCATION_INTERNAL_H__ +#define __TIZEN_LOCATION_INTERNAL_H__ -#include <location/location.h> +#include <location.h> #include <locations.h> #include <dlog.h> @@ -29,10 +29,11 @@ /* * 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_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 { \ @@ -62,6 +63,9 @@ typedef enum { _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_NUM } _location_event_e; @@ -71,6 +75,9 @@ typedef enum { _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; @@ -80,7 +87,9 @@ typedef struct _location_manager_s { 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; @@ -90,8 +99,15 @@ typedef struct _location_bounds_s { 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; + + #ifdef __cplusplus } #endif -#endif //__TIZEN_LOCATION_LOCATIONS_PRIVATE_H__ +#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 <tizen_type.h> -#include <tizen_error.h> - -#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..92063ee 100644 --- a/include/locations.h +++ b/include/locations.h @@ -32,68 +32,75 @@ extern "C" { */ /** - * @brief Enumerations of error code for Location manager. + * @brief Enumeration for 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 */ + 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 2.3 */ 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. */ + 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 2.3 */ 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. */ + 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 2.3 */ typedef enum { - LOCATIONS_SERVICE_DISABLED, /**< Service is disabled */ - LOCATIONS_SERVICE_ENABLED /**< Service is enabled */ + LOCATIONS_SERVICE_DISABLED, /**< Service is disabled */ + LOCATIONS_SERVICE_ENABLED, /**< Service is enabled */ + LOCATIONS_SERVICE_HOST_SETTING_OFF /**< Setting for location-service has turned off from host device */ } location_service_state_e; /** - * @brief Enumerations of the location service accessibility state. + * @brief Enumeration for the location service accessibility state. + * @since_tizen 2.3 */ typedef enum { - LOCATIONS_ACCESS_STATE_NONE, /**< Not determined yet */ - LOCATIONS_ACCESS_STATE_DENIED, /**< Access denied */ - LOCATIONS_ACCESS_STATE_ALLOWED, /**< Access authorized */ + 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 2.3 */ typedef struct location_manager_s *location_manager_h; @@ -109,12 +116,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 2.3 + * @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 +130,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 2.3 + * @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 2.3 + * @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 2.3 + * @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 +174,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 2.3 + * @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 +189,137 @@ 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 2.3 + * @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 2.3 + * @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 Checks whether the given location method is available. + * @since_tizen 2.3 + * @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 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 + * @brief Checks whether the given location method is enabled or not on setting. + * @since_tizen 2.3 + * @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_OUT_OF_MEMORY Out of memory + * @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. + * @since_tizen 2.3 + * @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); /** * @brief Releases the location manager. + * @since_tizen 2.3 * @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 2.3 + * @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 2.3 + * @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 + * @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_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 +337,20 @@ int location_manager_start(location_manager_h manager); /** * @brief Stops the location service. + * @since_tizen 2.3 * @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 + * @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_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 +359,154 @@ 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 2.3 + * @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 2.3 + * @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 2.3 + * @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 2.3 + * @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) + * @since_tizen 2.3 + * @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_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. + * @details The result contains the current altitude, latitude, longitude, climb, direction, speed, level, horizontal and vertical 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. - * - * @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) + * @since_tizen 2.3 + * @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 - * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() + * @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 2.3 + * @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) + * @since_tizen 2.3 + * @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_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 +514,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 2.3 + * @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 +534,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 2.3 + * @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() * @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 +560,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 2.3 + * @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() * @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) + * @since_tizen 2.3 + * @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_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. + * @since_tizen 2.3 + * @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_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); /** * @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 2.3 + * @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 +629,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 2.3 + * @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 2.3 + * @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 +658,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 2.3 + * @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 2.3 + * @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 +689,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 2.3 + * @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 +702,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 2.3 + * @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 +719,58 @@ 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 + * @since_tizen 2.3 + * @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_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 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) + * @brief Registers a callback function to be invoked when the location setting is changed. + * @since_tizen 2.3 + * @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 argument + * @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_get_distance(double start_latitude, double start_longitude, double end_latitude, double end_longitude, double *distance); +int location_manager_set_setting_changed_cb(location_method_e method, location_setting_changed_cb callback, void *user_data); /** - * @brief Sends command to the server. - * @param[in] cmd The command string to be sent + * @brief Unregisters the callback function. + * @since_tizen 2.3 + * @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_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_send_command(const char *cmd); +int location_manager_unset_setting_changed_cb(location_method_e method); + +/** + * @brief Gets the distance in meters between two locations. + * @since_tizen 2.3 + * @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); /** * @} @@ -628,13 +786,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 2.3 + * @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 +803,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 2.3 + * @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 2.3 + * @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 +835,134 @@ int gps_status_get_nmea(location_manager_h manager, char **nmea); /** * @brief Gets the information of satellites. + * @since_tizen 2.3 + * @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 + * @since_tizen 2.3 + * @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 - * @post gps_status_satellite_updated_cb() will be invoked + * @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 2.3 + * @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 2.3 + * @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 2.3 + * @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 2.3 + * @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/packaging/capi-location-manager.spec b/packaging/capi-location-manager.spec index fd1f669..eab2b1c 100755 --- a/packaging/capi-location-manager.spec +++ b/packaging/capi-location-manager.spec @@ -1,15 +1,16 @@ #sbs-git:slp/api/location-manager capi-location-manager 0.1.0 d1ee09a32e8bc0e9ed48ece37c641a7393c086c5 -Name: capi-location-manager -Summary: A Location Manager library in Tizen Native API -Version: 0.1.11 -Release: 1 -Group: System/Libraries -License: Apache License, Version 2.0 -Source0: %{name}-%{version}.tar.gz +Name: capi-location-manager +Summary: A Location Manager library in Tizen Native API +Version: 0.4.0 +Release: 1 +Group: System/Libraries +License: Apache License, Version 2.0 +Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(location) BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(vconf) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -17,8 +18,8 @@ Requires(postun): /sbin/ldconfig %package devel -Summary: A Location Manager library in Tizen Native API (Development) -Group: TO_BE/FILLED_IN +Summary: A Location Manager library in Tizen Native API (Development) +Group: TO_BE/FILLED_IN Requires: %{name} = %{version}-%{release} %description devel @@ -30,18 +31,26 @@ Requires: %{name} = %{version}-%{release} %build +#%if "%{_repository}" == "wearable“ +#export CFLAGS="$CFLAGS -DTIZEN_WEARABLE" +#%endif + +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} +cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} make %{?jobs:-j%jobs} %install rm -rf %{buildroot} -mkdir -p %{buildroot}/usr/share/license -cp %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{name} - %make_install +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -49,10 +58,12 @@ cp %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{name %files %manifest capi-location-manager.manifest -/usr/share/license/%{name} %{_libdir}/libcapi-location-manager.so.* +/usr/share/license/%{name} %files devel %{_includedir}/location/*.h %{_libdir}/pkgconfig/*.pc %{_libdir}/libcapi-location-manager.so + + diff --git a/src/location_bounds.c b/src/location_bounds.c index 1819f27..45555d3 100755..100644 --- a/src/location_bounds.c +++ b/src/location_bounds.c @@ -17,8 +17,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <location_bounds.h> -#include <locations_private.h> +#include "location_bounds.h" +#include "location_internal.h" #define LOCATIONS_NULL_ARG_CHECK(arg) \ @@ -191,21 +191,28 @@ 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 (!bounds) { + set_last_result(LOCATION_BOUNDS_ERROR_INVALID_PARAMETER); return FALSE; + } - if (coords.latitude < -90 || coords.latitude > 90 || coords.longitude < -180 || coords.longitude > 180) + 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; } 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 <location_preference.h> -#include <location-map-service.h> -#include <stdlib.h> -#include <string.h> -#include <locations_private.h> - -#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..c369c82 100755 --- a/src/locations.c +++ b/src/locations.c @@ -17,8 +17,15 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <locations_private.h> -#include <location_bounds.h> +#ifdef TIZEN_WEARABLE +#include <unistd.h> +#include <package_manager.h> +#include <app_manager.h> +#include <app_control.h> +#endif +#include "location_internal.h" +#include "location_bounds.h" +#include "location_batch.h" #define LOCATIONS_NULL_ARG_CHECK(arg) \ @@ -28,6 +35,8 @@ * Internal Implementation */ +static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_WPS+1]; + static int __convert_error_code(int code) { int ret; @@ -62,42 +71,115 @@ static int __convert_error_code(int code) 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); + if (ret != LOCATIONS_ERROR_NONE) + LOCATIONS_LOGE("%s(0x%08x) : core fw error(0x%x)", msg, ret, code); return ret; } +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 LocationMethod __convert_LocationMethod(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_NONE: + default: + _method = LOCATION_METHOD_NONE; + break; + } + return _method; +} + static void __cb_service_updated(GObject * self, guint type, gpointer data, 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); + LOCATIONS_LOGD("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]); + vel->climb, vel->timestamp, + handle->user_data + [_LOCATIONS_EVENT_TYPE_VELOCITY]); } else if (type == POSITION_UPDATED && handle->user_cb[_LOCATIONS_EVENT_TYPE_POSITION]) { LocationPosition *pos = (LocationPosition *) data; - LOCATIONS_LOGI("Current position: timestamp : %d", pos->timestamp); + LOCATIONS_LOGD("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]); + pos->altitude, pos->timestamp, + handle->user_data + [_LOCATIONS_EVENT_TYPE_POSITION]); } 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); + 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]); } } +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]); + } +} + +#if 0 +static gboolean __cb_single_service_stop(gpointer user_data) +{ + location_manager_s *handle = (location_manager_s *) user_data; + + if (handle->timeout) { + g_source_remove(handle->timeout); + handle->timeout = 0; + } + + location_stop(handle->object); + + return FALSE; +} +#endif + 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) @@ -108,7 +190,7 @@ static void __cb_service_enabled(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) @@ -116,6 +198,86 @@ static void __cb_service_disabled(GObject * self, guint status, gpointer userdat handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]); } +#ifdef TIZEN_WEARABLE +static void __show_popup_host_setting_off() +{ + app_control_h app_control_handle = NULL; + int ret; + do { + ret = app_control_create(&app_control_handle); + if (ret != APP_CONTROL_ERROR_NONE) { + LOCATIONS_LOGD("app_control_create failed. Error %d", ret); + break; + } + + ret = app_control_set_operation(app_control_handle, "http://tizen.org/appcontrol/operation/configure/location"); + if (ret != APP_CONTROL_ERROR_NONE) { + LOCATIONS_LOGD("app_control_set_operation failed. Error %d", ret); + break; + } + + ret = app_control_set_app_id(app_control_handle, "com.samsung.setting-location"); + if (ret != APP_CONTROL_ERROR_NONE) { + LOCATIONS_LOGD("app_control_set_app_id failed. Error %d", ret); + break; + } + + ret = app_control_add_extra_data(app_control_handle, "popup", "provider_setting_off"); + if (ret != APP_CONTROL_ERROR_NONE) { + LOCATIONS_LOGD("app_control_add_extra_data failed. Error %d", ret); + break; + } + + ret = app_control_send_launch_request(app_control_handle, NULL, NULL); + if (ret != APP_CONTROL_ERROR_NONE) { + LOCATIONS_LOGD("app_control_send_launch_request failed. Error %d", ret); + break; + } + } while(0); + + if (app_control_handle != NULL) { + ret = app_control_destroy(app_control_handle); + if (ret != APP_CONTROL_ERROR_NONE) { + LOCATIONS_LOGD("app_control_destroy failed. Error %d", ret); + } + } +} + +static void __cb_service_error_emitted(GObject * self, guint error_code, gpointer userdata) +{ + LOCATIONS_LOGD("Error[%d] Callback function has been invoked. ", error_code); + location_manager_s *handle = (location_manager_s *) userdata; + const char *svoice = "com.samsung.svoice"; + + if (handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]) { + switch (error_code) { + case LOCATION_ERROR_SETTING_OFF: { + pid_t pid = 0; + char *app_id = NULL; + int ret = 0; + + pid = getpid(); + ret = app_manager_get_app_id (pid, &app_id); + if (ret == APP_MANAGER_ERROR_NONE && app_id && strncmp(app_id, svoice, strlen(svoice)) != 0) { + __show_popup_host_setting_off(); + } else { + LOCATIONS_LOGD("########## SVoice ################"); + } + ((location_service_state_changed_cb)handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]) + (LOCATIONS_SERVICE_HOST_SETTING_OFF, + handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]); + break; + } + + default: { + break; + } + } + } + +} +#endif + static int __compare_position (gconstpointer a, gconstpointer b) { if(location_position_equal((LocationPosition*) a, (LocationPosition *)b) == TRUE) { @@ -158,7 +320,8 @@ static int __boundary_compare(LocationBoundary * bound1, LocationBoundary * boun if (boundary2_next == NULL) boundary2_next = g_list_first(bound2->polygon.position_list); boundary1_next = g_list_next(bound1->polygon.position_list); - if (location_position_equal((LocationPosition*)boundary1_next->data, (LocationPosition*)boundary2_prev->data) == TRUE) { + 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); @@ -169,7 +332,8 @@ static int __boundary_compare(LocationBoundary * bound1, LocationBoundary * boun boundary1_next = g_list_next(boundary1_next); } ret = 0; - } else if (location_position_equal((LocationPosition*)boundary1_next->data, (LocationPosition*)boundary2_next->data) == TRUE) { + } 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); @@ -194,15 +358,15 @@ static int __boundary_compare(LocationBoundary * bound1, LocationBoundary * boun static void __cb_zone_in(GObject * self, gpointer boundary, gpointer position, 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 (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]); + pos->latitude, pos->longitude, + pos->altitude, pos->timestamp, + handle->user_data + [_LOCATIONS_EVENT_TYPE_BOUNDARY]); } location_bounds_s *bounds; @@ -210,7 +374,7 @@ 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"); + LOCATIONS_LOGD("Find zone in boundary"); ((location_bounds_state_changed_cb) bounds->user_cb) (LOCATIONS_BOUNDARY_IN, bounds->user_data); break; } @@ -220,15 +384,15 @@ static void __cb_zone_in(GObject * self, gpointer boundary, gpointer position, g static void __cb_zone_out(GObject * self, gpointer boundary, gpointer position, 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 (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]); + pos->latitude, pos->longitude, + pos->altitude, pos->timestamp, + handle->user_data + [_LOCATIONS_EVENT_TYPE_BOUNDARY]); } location_bounds_s *bounds; @@ -236,7 +400,7 @@ 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"); + LOCATIONS_LOGD("Find zone out boundary"); ((location_bounds_state_changed_cb) bounds->user_cb) (LOCATIONS_BOUNDARY_OUT, bounds->user_data); break; } @@ -251,7 +415,7 @@ static int __set_callback(_location_event_e type, location_manager_h manager, vo 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); + LOCATIONS_LOGD("event type : %d. ", type); return LOCATIONS_ERROR_NONE; } @@ -261,7 +425,7 @@ static int __unset_callback(_location_event_e type, location_manager_h 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); + LOCATIONS_LOGD("event type : %d. ", type); return LOCATIONS_ERROR_NONE; } @@ -309,15 +473,30 @@ 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"); + } +} + +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; + } + + if (_setting_changed[_method].callback != NULL) { + _setting_changed[_method].callback(_method, enable, _setting_changed[_method].user_data); } } @@ -325,61 +504,192 @@ static void __foreach_boundary(LocationBoundary * boundary, void *user_data) // Location Manager //////////////////////////////////////// +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]); + } +} + +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_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"); + 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_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_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_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; +} + /* * Public Implementation */ 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); + 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_is_enabled_method(location_method_e method, bool *enable) +{ + 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_create(location_method_e method, location_manager_h * manager) { + LOCATIONS_LOGD("location_manager_create (method : %d)", method); + + 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 +702,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 +710,16 @@ 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); + + #ifdef TIZEN_WEARABLE + if (!handle->sig_id[_LOCATION_SIGNAL_ERROR_EMITTED]) + handle->sig_id[_LOCATION_SIGNAL_ERROR_EMITTED] = g_signal_connect(handle->object, "error-emitted", G_CALLBACK(__cb_service_error_emitted), handle); + #endif *manager = (location_manager_h) handle; return LOCATIONS_ERROR_NONE; @@ -410,11 +727,26 @@ 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_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; + } + + #ifdef TIZEN_WEARABLE + if (handle->sig_id[_LOCATION_SIGNAL_ERROR_EMITTED]) { + g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_ERROR_EMITTED]); + handle->sig_id[_LOCATION_SIGNAL_ERROR_EMITTED] = 0; + } + #endif int ret = location_free(handle->object); if (ret != LOCATIONS_ERROR_NONE) { @@ -426,12 +758,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_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 +788,57 @@ 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_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_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 +849,7 @@ 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(bounds); @@ -474,6 +866,7 @@ 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(bounds); @@ -490,6 +883,7 @@ 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(callback); @@ -506,6 +900,7 @@ EXPORT_API int location_manager_foreach_boundary(location_manager_h manager, loc EXPORT_API int location_manager_get_method(location_manager_h manager, location_method_e * method) { + LOCATIONS_LOGD("location_manager_get_method %d", method); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(method); location_manager_s *handle = (location_manager_s *) manager; @@ -524,13 +919,10 @@ EXPORT_API int location_manager_get_method(location_manager_h manager, location_ 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); + LOCATIONS_ERROR_INVALID_PARAMETER, method); return LOCATIONS_ERROR_INVALID_PARAMETER; } } @@ -539,8 +931,9 @@ EXPORT_API int location_manager_get_method(location_manager_h manager, location_ } 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(altitude); LOCATIONS_NULL_ARG_CHECK(latitude); @@ -557,17 +950,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 +964,7 @@ 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(altitude); LOCATIONS_NULL_ARG_CHECK(latitude); @@ -600,17 +988,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; @@ -628,6 +1010,7 @@ EXPORT_API int location_manager_get_location(location_manager_h manager, double 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(climb); LOCATIONS_NULL_ARG_CHECK(direction); @@ -653,8 +1036,9 @@ EXPORT_API int location_manager_get_velocity(location_manager_h manager, double } EXPORT_API int location_manager_get_accuracy(location_manager_h manager, location_accuracy_level_e * level, double *horizontal, - double *vertical) + double *vertical) { + LOCATIONS_LOGD("location_manager_get_accuracy"); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(level); LOCATIONS_NULL_ARG_CHECK(horizontal); @@ -682,8 +1066,9 @@ 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(altitude); LOCATIONS_NULL_ARG_CHECK(latitude); @@ -701,17 +1086,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); @@ -721,6 +1100,7 @@ EXPORT_API int location_manager_get_last_position(location_manager_h manager, do 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(altitude); LOCATIONS_NULL_ARG_CHECK(latitude); @@ -745,17 +1125,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; @@ -772,6 +1146,7 @@ EXPORT_API int location_manager_get_last_location(location_manager_h manager, do 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(climb); LOCATIONS_NULL_ARG_CHECK(direction); @@ -798,8 +1173,9 @@ EXPORT_API int location_manager_get_last_velocity(location_manager_h manager, do } EXPORT_API int location_manager_get_last_accuracy(location_manager_h manager, location_accuracy_level_e * level, double *horizontal, - double *vertical) + double *vertical) { + LOCATIONS_LOGD("location_manager_get_last_accuracy"); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(level); LOCATIONS_NULL_ARG_CHECK(horizontal); @@ -824,6 +1200,7 @@ EXPORT_API int location_manager_get_last_accuracy(location_manager_h manager, lo EXPORT_API int location_manager_get_accessibility_state(location_accessibility_state_e* state) { + LOCATIONS_LOGD("location_manager_get_accessibility_state"); LOCATIONS_NULL_ARG_CHECK(state); int ret = LOCATION_ERROR_NONE; @@ -852,8 +1229,9 @@ EXPORT_API int location_manager_get_accessibility_state(location_accessibility_s 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_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 +1240,15 @@ 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"); 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_LOGD("location_manager_set_velocity_updated_cb"); 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, "vel-interval", interval, NULL); @@ -877,32 +1257,81 @@ 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"); 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"); 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"); 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"); 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"); return __unset_callback(_LOCATIONS_EVENT_TYPE_BOUNDARY, manager); } +EXPORT_API int location_manager_set_setting_changed_cb(location_method_e method, location_setting_changed_cb callback, void *user_data) +{ + LOCATIONS_LOGD("location_manager_set_setting_changed_cb"); + LOCATIONS_NULL_ARG_CHECK(callback); + + LocationMethod _method = __convert_LocationMethod(method); + int ret = LOCATION_ERROR_NONE; + + if (_method == LOCATION_METHOD_NONE) { + return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; + } + + g_location_setting[_method].callback = callback; + g_location_setting[_method].user_data = user_data; + + ret = location_add_setting_notify(_method, __setting_changed_cb, &g_location_setting); + return __convert_error_code(ret); +} + +EXPORT_API int location_manager_unset_setting_changed_cb(location_method_e method /*, location_setting_changed_cb callback */) +{ + LOCATIONS_LOGD("location_manager_unset_setting_changed_cb"); +// LOCATIONS_NULL_ARG_CHECK(callback); + LocationMethod _method = __convert_LocationMethod(method); + int ret = LOCATION_ERROR_NONE; +/* + if (g_location_setting[method].callback != callback) { + LOCATIONS_LOGE("Invalid parameter"); + return LOCATIONS_ERROR_INVALID_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_get_distance(double start_latitude, double start_longitude, double end_latitude, double end_longitude, double *distance) { + LOCATIONS_LOGD("location_manager_get_distance"); 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"); @@ -925,25 +1354,13 @@ EXPORT_API int location_manager_get_distance(double start_latitude, double start return LOCATIONS_ERROR_NONE; } -EXPORT_API int location_manager_send_command(const char *cmd) -{ - LOCATIONS_NULL_ARG_CHECK(cmd); - - int ret; - ret = location_send_command(cmd); - if (ret != LOCATION_ERROR_NONE) { - return __convert_error_code(ret); - } - - return LOCATIONS_ERROR_NONE; -} - ///////////////////////////////////////// // GPS Status & Satellites //////////////////////////////////////// EXPORT_API int gps_status_get_nmea(location_manager_h manager, char **nmea) { + LOCATIONS_LOGD("gps_status_get_nmea"); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(nmea); location_manager_s *handle = (location_manager_s *) manager; @@ -953,26 +1370,26 @@ EXPORT_API int gps_status_get_nmea(location_manager_h manager, char **nmea) 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); + LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); return LOCATIONS_ERROR_INCORRECT_METHOD; } } else if (handle->method != LOCATIONS_METHOD_GPS) { 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; } 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_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); + LOCATIONS_ERROR_OUT_OF_MEMORY); return LOCATIONS_ERROR_OUT_OF_MEMORY; } g_free(nmea_data); @@ -981,6 +1398,7 @@ EXPORT_API int gps_status_get_nmea(location_manager_h manager, char **nmea) 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(num_of_active); LOCATIONS_NULL_ARG_CHECK(num_of_inview); @@ -991,12 +1409,15 @@ EXPORT_API int gps_status_get_satellite(location_manager_h manager, int *num_of_ 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; } @@ -1010,22 +1431,26 @@ 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_LOGD("gps_status_set_satellite_updated_cb"); 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); + 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"); 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(callback); location_manager_s *handle = (location_manager_s *) manager; @@ -1034,12 +1459,15 @@ EXPORT_API int gps_status_foreach_satellites_in_view(location_manager_h manager, 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,6 +1489,7 @@ 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(num_of_active); LOCATIONS_NULL_ARG_CHECK(num_of_inview); @@ -1072,12 +1501,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 +1521,9 @@ 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_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(callback); location_manager_s *handle = (location_manager_s *) manager; @@ -1100,12 +1533,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..8f3f798 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,16 +4,16 @@ 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() diff --git a/test/location_test.c b/test/location_test.c index 5efd4e5..3679d0e 100644 --- a/test/location_test.c +++ b/test/location_test.c @@ -21,10 +21,13 @@ #include <locations.h> #include <location_bounds.h> + +//#define COMPANION_TEST location_manager_h manager; +#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"); @@ -39,18 +42,18 @@ void zone_event_cb(location_boundary_state_e state, double latitude, double long } static bool satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use, - void *user_data) + 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("[Satellite information] azimuth : %d, elevation : %d, prn :%d, snr : %d, used: %d\n", azimuth, elevation, prn, + snr, is_in_use); return true; } static bool last_satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use, - void *user_data) + 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("[Last Satellite information] azimuth : %d, elevation : %d, prn :%d, snr : %d, used: %d\n", azimuth, elevation, + prn, snr, is_in_use); return true; } @@ -123,14 +126,14 @@ static bool __location_bounds_cb(location_bounds_h bounds, void *user_data) double radius; location_bounds_get_circle_coords(bounds, ¢er, &radius); printf("location_bounds_get_circle_coords(center : %lf, %lf, radius : %lf) \n", center.latitude, - center.longitude, radius); + 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", - left_top.latitude, left_top.longitude, right_bottom.latitude, right_bottom.longitude); + 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); } @@ -165,7 +168,7 @@ void location_bounds_test() printf("location_bounds_get_circle_coords() failed\n"); } else printf("location_bounds_get_circle_coords(center : %lf, %lf, radius : %lf) \n", center2.latitude, - center2.longitude, radius2); + center2.longitude, radius2); //Add the rect bounds location_coords_s left_top; @@ -197,7 +200,7 @@ void location_bounds_test() 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, - left_top2.longitude, right_bottom2.latitude, right_bottom2.longitude); + left_top2.longitude, right_bottom2.latitude, right_bottom2.longitude); //Add the polygon bounds @@ -289,25 +292,95 @@ void location_get_last_information_test() printf(" Fail : gps_status_foreach_last_satellites_in_view ---> %d \n", ret); } } +#endif + +#ifdef COMPANION_TEST +static void select_menu(char* buf) +{ + int len = 0; + char *str = NULL; + str = fgets(buf, 255, stdin); + if (NULL == str) { + printf("fgets return NULL. \n"); + } + len = g_utf8_strlen(buf, -1); + buf[len-1] = '\0'; +} + +void print_menu() +{ + printf("==== companion gps/wps test ======\n"); + printf("[1] LOCATIONS_METHOD_COMPANION_WPS, request_single_location\n"); + printf("[2] LOCATIONS_METHOD_COMPANION_GPS, request_single_location\n"); +} +#endif + +void location_cb(int error, double latitude, double longitude, double altitude, time_t timestamp, double speed, double climb, double direction, void *user_data) +{ + 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); +} + +static void __setting_cb(location_method_e method, bool enable, void *user_data) +{ + printf("method[%d], enable[%d]\n", method, enable); +} int location_test() { - int ret; - ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager); - printf("create : %d\n", ret); +// char menu[255]; + /* + while(1) { + print_menu(); + printf("Select menu :"); + select_menu(menu); + if (strcmp(menu, "1") == 0) { + int ret; + ret = location_manager_create(LOCATIONS_METHOD_COMPANION_WPS, &manager); + printf("LOCATIONS_METHOD_COMPANION_WPS create : %d\n", ret); + ret = location_manager_request_single_location(manager, 30, location_cb, manager); + printf("request single : %d\n", ret); + return 0; + } else if (strcmp(menu, "2") == 0) { + int ret; + ret = location_manager_create(LOCATIONS_METHOD_COMPANION_GPS, &manager); + printf("LOCATIONS_METHOD_COMPANION_GPS create : %d\n", ret); + ret = location_manager_request_single_location(manager, 30, location_cb, manager); + printf("request single : %d\n", ret); + return 0 ; + } + } + */ +// location_bounds_test(); +// location_get_last_information_test(); + printf("location_manager_is_enabled_method TEST\n"); + bool is_enabled = FALSE; + location_manager_is_enabled_method(LOCATIONS_METHOD_HYBRID, &is_enabled); + printf("hybrid : %d\n", is_enabled); + + location_manager_is_enabled_method(LOCATIONS_METHOD_GPS, &is_enabled); + printf("gps : %d\n", 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); - location_bounds_test(); - location_get_last_information_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); +// ret = location_manager_set_zone_changed_cb(manager, zone_event_cb, (void *)manager); +// printf("set zone callback : %d\n", ret); + +// ret = location_manager_set_service_state_changed_cb(manager, _state_change_cb, (void *)manager); +// printf("set state callback : %d\n", ret); + +// ret = location_manager_start(manager); +// printf("start : %d\n", ret); + - ret = location_manager_set_service_state_changed_cb(manager, _state_change_cb, (void *)manager); - printf("set state callback : %d\n", ret); - ret = location_manager_start(manager); - printf("start : %d\n", ret); return 1; } @@ -319,12 +392,14 @@ static gboolean exit_program(gpointer data) printf("manager == NULL \n"); } else { 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); } g_main_loop_quit(g_mainloop); printf("Quit g_main_loop\n"); + location_manager_unset_setting_changed_cb(LOCATIONS_METHOD_GPS); + location_manager_unset_setting_changed_cb(LOCATIONS_METHOD_WPS); return FALSE; } |