summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKibum Kim <kb0929.kim@samsung.com>2012-01-07 00:42:42 +0900
committerKibum Kim <kb0929.kim@samsung.com>2012-01-07 00:42:42 +0900
commitd9303afdffcb455a1dd83676998528a6359df885 (patch)
treea4a39fbc1ea9449447beafb5bd180fd98c601c8b
parent6fefcfb3259ce0088331bcb92224dfecd29fe898 (diff)
downloadlocation-manager-d9303afdffcb455a1dd83676998528a6359df885.tar.gz
location-manager-d9303afdffcb455a1dd83676998528a6359df885.tar.bz2
location-manager-d9303afdffcb455a1dd83676998528a6359df885.zip
Git init
-rw-r--r--.gitignore26
-rw-r--r--AUTHORS1
-rwxr-xr-xCMakeLists.txt90
-rw-r--r--LICENSE206
-rw-r--r--capi-location-manager.pc.in15
-rw-r--r--debian/README0
-rw-r--r--debian/capi-location-manager-dev.install4
-rw-r--r--debian/capi-location-manager-dev.postinst1
-rw-r--r--debian/capi-location-manager.install1
-rw-r--r--debian/capi-location-manager.postinst1
-rw-r--r--debian/changelog5
-rw-r--r--debian/compat1
-rw-r--r--debian/control22
-rwxr-xr-xdebian/rules65
-rwxr-xr-xinclude/locations.h578
-rw-r--r--include/locations_private.h47
-rw-r--r--packaging/capi-location-manager.spec53
-rw-r--r--src/locations.c753
-rw-r--r--test/CMakeLists.txt19
-rwxr-xr-xtest/location_test.c185
20 files changed, 2073 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a6d8f19
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,26 @@
+CMakeCache.txt
+*/CMakeFiles/*
+*.cmake
+CMakeFiles*
+*.a
+*.so
+Testing
+cmake.depends
+cmake.check_depends
+cmake.check_cache
+core
+core.*
+gmon.out
+install_manifest.txt
+*~
+.kdev_include_paths
+src.kdev4
+.cproject
+.project
+tet_captured
+tet_lock
+*.pc
+Makefile
+*-test
+*-test_*
+*tester.c
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..111161d
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Kangho Hur <kanho.hur@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755
index 0000000..f2d956d
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,90 @@
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-location-manager")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(dependents "dlog location capi-base-common")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+FOREACH(flag ${${fw_name}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(
+ DIRECTORY ${INC_DIR}/ DESTINATION include/location
+ FILES_MATCHING
+ PATTERN "*_private.h" EXCLUDE
+ PATTERN "${INC_DIR}/*.h"
+ )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${dependents})
+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
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+
+ADD_SUBDIRECTORY(test)
+
+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
+)
+
+ENDIF(UNIX)
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..bbe9d02
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+
+
diff --git a/capi-location-manager.pc.in b/capi-location-manager.pc.in
new file mode 100644
index 0000000..d935ba8
--- /dev/null
+++ b/capi-location-manager.pc.in
@@ -0,0 +1,15 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/location
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir} @PC_CFLAGS@
+
diff --git a/debian/README b/debian/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/debian/README
diff --git a/debian/capi-location-manager-dev.install b/debian/capi-location-manager-dev.install
new file mode 100644
index 0000000..761a28b
--- /dev/null
+++ b/debian/capi-location-manager-dev.install
@@ -0,0 +1,4 @@
+/usr/include/*
+/usr/include/*/*
+/usr/lib/pkgconfig/*.pc
+
diff --git a/debian/capi-location-manager-dev.postinst b/debian/capi-location-manager-dev.postinst
new file mode 100644
index 0000000..1a24852
--- /dev/null
+++ b/debian/capi-location-manager-dev.postinst
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/debian/capi-location-manager.install b/debian/capi-location-manager.install
new file mode 100644
index 0000000..4a755a4
--- /dev/null
+++ b/debian/capi-location-manager.install
@@ -0,0 +1 @@
+/usr/lib/lib*.so*
diff --git a/debian/capi-location-manager.postinst b/debian/capi-location-manager.postinst
new file mode 100644
index 0000000..1a24852
--- /dev/null
+++ b/debian/capi-location-manager.postinst
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..652c976
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+capi-location-manager (0.1.0-6) unstable; urgency=low
+
+ * Initial release.
+
+ -- Kangho Hur <kangho.hur@samsung.com> Wed, 07 Dec 2011 12:44:12 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..72792e1
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,22 @@
+
+Source: capi-location-manager
+Section: libs
+Priority: extra
+Maintainer: Kangho Hur <kangho.hur@samsung.com>
+Build-Depends: debhelper (>= 5), dlog-dev, libslp-location-dev, capi-base-common-dev
+
+Package: capi-location-manager
+Architecture: any
+Depends: ${shilbs:Depends}, ${misc:Depends}
+Description: A Location Manager library in Tizen Native API
+
+Package: capi-location-manager-dev
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, capi-location-manager (= ${Source-Version}), dlog-dev, libslp-location-dev, capi-base-common-dev
+Description: A Location Manager library in Tizen Native API (DEV)
+
+Package: capi-location-manager-dbg
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, capi-location-manager (= ${Source-Version})
+Description: A Location Manager library in Tizen Native API (DBG)
+
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..4944343
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,65 @@
+#!/usr/bin/make -f
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+CMAKE_ROOT_DIR ?= $(CURDIR)
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake ..
+ touch configure-stamp
+
+
+build: build-stamp
+build-stamp: configure-stamp
+ dh_testdir
+ cd $(CMAKE_BUILD_DIR) && $(MAKE)
+ touch $@
+
+clean:
+ cd $(CMAKE_ROOT_DIR)
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+ rm -f `find . -name *.pc`
+ rm -rf $(CMAKE_BUILD_DIR)
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+binary-indep: build install
+
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+ dh_install --sourcedir=debian/tmp
+ dh_installman
+ dh_link
+ dh_strip --dbg-package=capi-location-manager-dbg
+ dh_fixperms
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
+
diff --git a/include/locations.h b/include/locations.h
new file mode 100755
index 0000000..7f1467d
--- /dev/null
+++ b/include/locations.h
@@ -0,0 +1,578 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_LOCATION_LOCATIONS_H__
+#define __TIZEN_LOCATION_LOCATIONS_H__
+
+#include <tizen_type.h>
+#include <tizen_error.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup CAPI_LOCATION_MANAGER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations of error code for Location manager.
+ */
+typedef enum
+{
+ LOCATIONS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ LOCATIONS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ LOCATIONS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ LOCATIONS_ERROR_INCORRECT_METHOD = TIZEN_ERROR_LOCATION_CLASS | 0x01, /**< Location manager contains incorrect method for a given call */
+ LOCATIONS_ERROR_NETWORK_FAILED = TIZEN_ERROR_LOCATION_CLASS | 0x02, /**< Network unavailable */
+ LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE = TIZEN_ERROR_LOCATION_CLASS | 0x03, /**< Service unavailable */
+ LOCATIONS_ERROR_GPS_SETTING_OFF = TIZEN_ERROR_LOCATION_CLASS | 0x04, /**< GPS is not enabled */
+} location_error_e;
+
+
+
+/**
+ * @brief Location method type.
+ */
+typedef enum
+{
+ LOCATIONS_METHOD_NONE=0, /**< 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_SPS /**< This method uses sensor. */
+} location_method_e;
+
+/**
+ * @brief Approximate accuracy level of given information.
+ */
+typedef enum
+{
+ LOCATIONS_ACCURACY_NONE=0, /**< Invalid data. */
+ LOCATIONS_ACCURACY_COUNTRY, /**< Country accuracy level. */
+ LOCATIONS_ACCURACY_REGION, /**< Regional accuracy level. */
+ LOCATIONS_ACCURACY_LOCALITY, /**< Local accuracy level. */
+ LOCATIONS_ACCURACY_POSTALCODE, /**< Postal accuracy level. */
+ LOCATIONS_ACCURACY_STREET, /**< Street accuracy level. */
+ LOCATIONS_ACCURACY_DETAILED, /**< Detailed accuracy level. */
+} location_accuracy_level_e;
+
+/**
+ * @brief Enumerations of the state of the location service.
+ */
+typedef enum
+{
+ LOCATIONS_SERVICE_DISABLED, /**< Service is disabled */
+ LOCATIONS_SERVICE_ENABLED /**< Service is enabled */
+} location_service_state_e;
+
+/**
+ * @brief Enumerations of the boundary state.
+ */
+typedef enum
+{
+ LOCATIONS_BOUNDARY_IN, /**< Boundary In (Zone In) */
+ LOCATIONS_BOUNDARY_OUT /**< Boundary Out (Zone Out) */
+} location_boundary_state_e;
+
+/**
+ * @brief The location manager handle.
+ */
+ typedef struct location_manager_s *location_manager_h;
+
+/**
+ * @}
+ */
+/*
+ * Location Manager
+*/
+/**
+ * @addtogroup CAPI_LOCATION_MANAGER_MODULE
+ * @{
+ */
+/**
+ * @brief Called every 1 second 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)
+ * @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(*location_position_updated_cb )(double latitude, double longitude, double altitude, time_t timestamp, void *user_data);
+
+/**
+ * @brief Called every 1 second 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)
+ * @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 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
+ * @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()
+ * @see location_manager_set_service_state_changed_cb()
+ * @see #location_service_state_e
+ */
+typedef void(*location_service_state_changed_cb )(location_service_state_e state, void *user_data);
+
+/**
+ * @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)
+ * @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()
+ */
+typedef void(*location_zone_changed_cb )(location_boundary_state_e state, double latitude, double longitude, double altitude, time_t timestamp, void *user_data);
+
+/**
+ * @brief Creates a new location manager.
+ * @remarks @a manager must be released location_manager_destroy() by you.
+ * @param[in] method The location method
+ * @param[out] manager A location manager handle to be newly created on success
+ * @return 0 on success, otherwise a negative error value.
+ * @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
+ * @see location_manager_destroy()
+ */
+int location_manager_create(location_method_e method, location_manager_h* manager);
+
+/**
+ * @brief Releases the location manager.
+ * @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
+ * @see location_manager_create()
+*/
+int location_manager_destroy(location_manager_h manager);
+
+/**
+ * @brief Starts the location service.
+ *
+ * @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:
+ *
+ * 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().
+ *
+ * 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).
+ *
+ * @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
+ * @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()
+ * @see location_manager_get_velocity()
+ * @see location_manager_get_accuracy()
+ * @see location_manager_set_service_state_changed_cb()
+ * @see location_manager_set_position_updated_cb()
+ * @see location_position_updated_cb()
+ * @see location_manager_set_velocity_updated_cb()
+ * @see location_velocity_updated_cb()
+ * @see location_manager_set_zone_changed_cb()
+ * @see location_zone_changed_cb()
+ */
+int location_manager_start(location_manager_h manager);
+
+/**
+ * @brief Stops the location service.
+ * @remarks This function initiates the process of stopping the service. When the process is finished, callback set using
+ * #location_manager_set_service_state_changed_cb() will be called, with #LOCATIONS_SERVICE_DISABLED as first argument.
+ * When that happens, the service is stopped and the user is notified.
+ *
+ * You can stop and start the location manager as needed.
+ *
+ * @param[in] manager The location manager handle
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #LOCATIONS_ERROR_NONE Successful
+ * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available
+ * @retval #LOCATIONS_ERROR_NETWORK_FAILED Network failed
+ * @see location_manager_start()
+ * @see location_manager_set_service_state_changed_cb()
+ * @see location_service_state_changed_cb()
+ */
+int location_manager_stop(location_manager_h manager);
+
+/**
+ * @brief Sets a rectangular boundary for a given location manager.
+ * @param[in] manager The location manager handle
+ * @param[in] top_left_latitude The latitude of area's top left corner [-90.0 ~ 90.0] (degrees)
+ * @param[in] top_left_longitude The longitude of area's top left corner [-180.0 ~ 180.0] (degrees)
+ * @param[in] bottom_right_latitude The latitude of area's bottom right corner [-90.0 ~ 90.0] (degrees)
+ * @param[in] bottom_right_longitude The longitude of area's bottom right corner [-180.0 ~ 180.0] (degrees)
+ * @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
+ * @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_set_boundary_circle()
+ * @see location_manager_set_zone_changed_cb()
+ * @see location_manager_is_boundary_contains_coordinate()
+ */
+int location_manager_set_boundary_rect(location_manager_h manager, double top_left_latitude, double top_left_longitude, double bottom_right_latitude, double bottom_right_longitude);
+
+/**
+ * @brief Sets a circular boundary for a given location manager.
+ * @param[in] manager The location manager handle
+ * @param[in] center_latitude The latitude of circle's center [-90.0 ~ 90.0] (degrees)
+ * @param[in] center_longitude The longitude of circle's center [-180.0 ~ 180.0] (degrees)
+ * @param[in] radius The radius of a circle (meters)
+ * @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
+ * @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_set_boundary_rect()
+ * @see location_manager_set_zone_changed_cb()
+ * @see location_manager_is_boundary_contains_coordinate()
+ */
+int location_manager_set_boundary_circle(location_manager_h manager, double center_latitude, double center_longitude, double radius);
+
+/**
+ * @brief Check if the boundary contains the specified latitude and longitude.
+ * @param[in] manager The location manager handle
+ * @param[in] latitude The latitude to test against boundary [-90.0 ~ 90.0] (degrees)
+ * @param[in] longitude The longitude to test against boundary [-180.0 ~ 180.0] (degrees)
+ * @param[out] contained The result indicating whether the boundary contains the specified coordinate (@c true = contained, @c false = not contained )
+ * @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
+ * @see location_manager_set_boundary_rect()
+ * @see location_manager_set_boundary_circle()
+ */
+int location_manager_is_boundary_contains_coordinate(location_manager_h manager, double latitude, double longitude, bool *contained);
+
+/**
+ * @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
+ * @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 altitude is negative, only altitude and latitude are available (fix status is 2D).
+ * If 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] timestamp The timestamp (time when measurement took place)
+ * @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()
+ */
+int location_manager_get_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, time_t *timestamp);
+
+/**
+ * @brief Gets the current velocity information.
+ * @details
+ * The result is 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)
+ * @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()
+ */
+int location_manager_get_velocity(location_manager_h manager, int *climb, int *direction, int *speed, time_t *timestamp);
+
+/**
+ * @brief Gets the current accuracy information.
+ * @param[in] manager The location manager handle
+ * @param[out] level The accuracy level
+ * @param[out] horizontal The horizontal accuracy (meters)
+ * @param[out] vertical The vertical accuracy (meters)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #LOCATIONS_ERROR_NONE Successful
+ * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available
+ * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled
+ * @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);
+
+/**
+ * @brief Registers a callback function to be invoked every 1 second with updated position information.
+ *
+ * @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_position_updated_cb() will be invoked
+ * @see location_manager_unset_position_updated_cb()
+ * @see location_position_updated_cb()
+ */
+int location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, 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
+ * @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 every 1 second with updated velocity information.
+ *
+ * @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_velocity_updated_cb() will be invoked
+ * @see location_manager_unset_velocity_updated_cb()
+ * @see location_velocity_updated_cb()
+ */
+int location_manager_set_velocity_updated_cb(location_manager_h manager, location_velocity_updated_cb callback, 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
+ * @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
+ * @see location_manager_unset_service_state_changed_cb()
+ * @see location_service_state_changed_cb()
+ * @see location_manager_start()
+ * @see location_manager_stop()
+ * @see #location_service_state_e
+*/
+int location_manager_set_service_state_changed_cb(location_manager_h manager, location_service_state_changed_cb callback, 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
+ * @see location_manager_set_service_state_changed_cb()
+ */
+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
+ * @see location_manager_unset_zone_changed_cb()
+ * @see location_zone_changed_cb()
+ */
+int location_manager_set_zone_changed_cb(location_manager_h manager, location_zone_changed_cb callback, 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
+ * @see location_manager_set_zone_changed_cb()
+ */
+int location_manager_unset_zone_changed_cb(location_manager_h manager);
+/**
+ * @}
+ */
+
+/*
+ * GPS Status & Satellites
+ */
+
+/**
+ * @addtogroup CAPI_LOCATION_GPS_STATUS_MODULE
+ * @{
+ */
+
+/**
+ * @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
+ * @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.
+ * @see gps_status_foreach_satellites_in_view()
+ */
+typedef bool(*gps_status_get_satellites_cb)(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_active, 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
+ * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start()
+ * @see location_manager_start()
+ */
+int gps_status_get_nmea(location_manager_h manager, char **nmea);
+
+/**
+ * @brief Gets the number of satellites in view.
+ *
+ * @remarks
+ * This call is valid only for location managers with #LOCATIONS_METHOD_GPS method.
+ *
+ * @param[in] manager The location manager handle
+ * @param[out] count The number of satellites in view
+ * @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
+ * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start()
+ * @see gps_status_foreach_satellites_in_view()
+ */
+int gps_status_get_satellite_count_in_view(location_manager_h manager, int *count);
+
+/**
+ * @brief Invokes the callback function for each satellite.
+ *
+ * @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
+ * @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_count_in_view()
+ * @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);
+
+/**
+ * @brief Gets the number of satellites available to be used.
+ *
+ * @remarks
+ * This call is valid only for location managers with #LOCATIONS_METHOD_GPS method.
+ *
+ * @param[in] manager The location manager handle
+ * @param[out] count The number of active satellites
+ * @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
+ * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start()
+ * @see gps_status_get_satellite_count_in_view()
+ */
+int gps_status_get_active_satellite_count(location_manager_h manager, int *count);
+/**
+ * @}
+ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_LOCATION_LOCATIONS_H__ */
diff --git a/include/locations_private.h b/include/locations_private.h
new file mode 100644
index 0000000..99f7ece
--- /dev/null
+++ b/include/locations_private.h
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_LOCATION_LOCATIONS_PRIVATE_H__
+#define __TIZEN_LOCATION_LOCATIONS_PRIVATE_H__
+
+#include <location/location.h>
+#include <locations.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ _LOCATIONS_EVENT_TYPE_SERVICE_STATE,
+ _LOCATIONS_EVENT_TYPE_POSITION,
+ _LOCATIONS_EVENT_TYPE_VELOCITY,
+ _LOCATIONS_EVENT_TYPE_BOUNDARY,
+ _LOCATIONS_EVENT_TYPE_NUM
+}_location_event_e;
+
+typedef struct _location_manager_s{
+ LocationObject* object;
+ const void* user_cb[_LOCATIONS_EVENT_TYPE_NUM];
+ void* user_data[_LOCATIONS_EVENT_TYPE_NUM];
+ location_method_e method;
+ LocationBoundary* boundary;
+} location_manager_s;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__TIZEN_LOCATION_LOCATIONS_PRIVATE_H__
diff --git a/packaging/capi-location-manager.spec b/packaging/capi-location-manager.spec
new file mode 100644
index 0000000..82cfb96
--- /dev/null
+++ b/packaging/capi-location-manager.spec
@@ -0,0 +1,53 @@
+Name: capi-location-manager
+Summary: A Location Manager library in Tizen Native API
+Version: 0.0.1
+Release: 1
+Group: TO_BE/FILLED_IN
+License: TO BE FILLED IN
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(location)
+BuildRequires: pkgconfig(capi-base-common)
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+
+
+%package devel
+Summary: A Location Manager library in Tizen Native API (Development)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+
+
+
+%prep
+%setup -q
+
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%{_libdir}/libcapi-location-manager.so
+
+%files devel
+%{_includedir}/location/*.h
+%{_libdir}/pkgconfig/*.pc
+
+
diff --git a/src/locations.c b/src/locations.c
new file mode 100644
index 0000000..a00ef11
--- /dev/null
+++ b/src/locations.c
@@ -0,0 +1,753 @@
+/*
+* Copyright (c) 2011 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locations_private.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_LOCATION_MANAGER"
+
+/*
+* Internal Macros
+*/
+#define LOCATIONS_CHECK_CONDITION(condition,error,msg) \
+ if(condition) {} else \
+ { LOGE("[%s] %s(0x%08x)",__FUNCTION__, msg,error); return error;}; \
+
+#define LOCATIONS_NULL_ARG_CHECK(arg) \
+ LOCATIONS_CHECK_CONDITION(arg != NULL,LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER")
+
+
+/*
+* Internal Implementation
+*/
+
+int _convert_error_code(int code,char *func_name)
+{
+ int ret;
+ char* msg = "LOCATIONS_ERROR_NONE";
+ switch(code)
+ {
+ case LOCATION_ERROR_NONE:
+ ret = LOCATIONS_ERROR_NONE;
+ msg = "LOCATIONS_ERROR_NONE";
+ break;
+ case LOCATION_ERROR_NETWORK_FAILED:
+ ret = LOCATIONS_ERROR_NETWORK_FAILED;
+ msg = "LOCATIONS_ERROR_NETWORK_FAILED";
+ break;
+ case LOCATION_ERROR_NOT_ALLOWED:
+ ret = LOCATIONS_ERROR_GPS_SETTING_OFF;
+ msg = "LOCATIONS_ERROR_GPS_SETTING_OFF";
+ break;
+ case LOCATION_ERROR_NOT_AVAILABLE:
+ case LOCATION_ERROR_CONFIGURATION:
+ case LOCATION_ERROR_PARAMETER:
+ case LOCATION_ERROR_UNKNOWN:
+ default:
+ msg = "LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE";
+ ret = LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+ LOGE("[%s] %s(0x%08x) : core fw error(0x%x)",func_name,msg, ret, code);
+ return ret;
+}
+
+void cb_service_updated (GObject *self, guint type, gpointer data, gpointer accuracy, gpointer userdata)
+{
+ LOGI("[%s] Callback function has been invoked. ",__FUNCTION__);
+ location_manager_s * handle = (location_manager_s*)userdata;
+ if( type == VELOCITY_UPDATED && handle->user_cb[_LOCATIONS_EVENT_TYPE_VELOCITY])
+ {
+ LocationVelocity *vel = (LocationVelocity*) data;
+ LOGI("[%s] Current velocity: timestamp : %d, speed: %f, direction : %f, climb : %f", __FUNCTION__ , vel->timestamp, vel->speed, vel->direction, vel->climb);
+ ((location_velocity_updated_cb)handle->user_cb[_LOCATIONS_EVENT_TYPE_VELOCITY])(vel->speed, vel->direction,vel->climb, vel->timestamp ,handle->user_data[_LOCATIONS_EVENT_TYPE_VELOCITY]);
+ }
+ if( type == POSITION_UPDATED && handle->user_cb[_LOCATIONS_EVENT_TYPE_POSITION])
+ {
+ LocationPosition *pos = (LocationPosition*) data;
+ LOGI("[%s] Current position: timestamp : %d, latitude : %f, altitude: %f, longitude: %f", __FUNCTION__ , pos->timestamp, pos->latitude, pos->altitude, pos->longitude);
+ ((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]);
+ }
+}
+
+void cb_service_enabled (GObject *self, guint status, gpointer userdata)
+{
+ LOGI("[%s] Callback function has been invoked. ",__FUNCTION__);
+ location_manager_s * handle = (location_manager_s*)userdata;
+ if(handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])
+ {
+ ((location_service_state_changed_cb)handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])(LOCATIONS_SERVICE_ENABLED,handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]);
+ }
+}
+
+void cb_service_disabled (GObject *self, guint status, gpointer userdata)
+{
+ LOGI("[%s] Callback function has been invoked. ",__FUNCTION__);
+ location_manager_s * handle = (location_manager_s*)userdata;
+ if( handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE] )
+ ((location_service_state_changed_cb)handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])(LOCATIONS_SERVICE_DISABLED,handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]);
+}
+
+void cb_zone_in (GObject *self, guint type, gpointer position, gpointer accuracy, gpointer userdata)
+{
+ 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]);
+ }
+}
+
+void cb_zone_out (GObject *self, guint type, gpointer position, gpointer accuracy, gpointer userdata)
+{
+ 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]);
+ }
+}
+
+int _set_callback(_location_event_e type, location_manager_h manager, void* callback, void *user_data)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(callback);
+ location_manager_s * handle = (location_manager_s *) manager;
+ handle->user_cb[type] = callback;
+ handle->user_data[type] = user_data;
+ LOGI("[%s] event type : %d. ",__FUNCTION__, type);
+ return LOCATIONS_ERROR_NONE;
+}
+
+int _unset_callback(_location_event_e type, location_manager_h manager)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ location_manager_s * handle = (location_manager_s *) manager;
+ handle->user_cb[type] = NULL;
+ handle->user_data[type] = NULL;
+ LOGI("[%s] event type : %d. ",__FUNCTION__, type);
+ return LOCATIONS_ERROR_NONE;
+}
+
+void _remove_boundary(LocationBoundary *boundary, void *user_data)
+{
+ LocationObject* loc = (LocationObject*) user_data;
+ if (loc != NULL && boundary != NULL)
+ {
+ int ret = location_boundary_remove(loc, boundary);
+ if(ret != LOCATION_ERROR_NONE)
+ {
+ LOGI("[%s] Failed to remove boundary : 0x%x. ",__FUNCTION__, ret);
+ }
+ else
+ {
+ LOGI("[%s] Delete previous boundary - type : %d ",__FUNCTION__, boundary->type);
+ }
+ }
+}
+
+/////////////////////////////////////////
+// Location Manager
+////////////////////////////////////////
+
+/*
+* Public Implementation
+*/
+
+int location_manager_create(location_method_e method, location_manager_h* manager)
+{
+ 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_NONE :
+ _method = LOCATION_METHOD_NONE;
+ break;
+ 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_SPS :
+ _method = LOCATION_METHOD_SPS;
+ break;
+ default :
+ {
+ LOGE("[%s] LOCATIONS_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (location_method_e) - method : %d ",__FUNCTION__,LOCATIONS_ERROR_INVALID_PARAMETER, method);
+ return LOCATIONS_ERROR_INVALID_PARAMETER;
+ }
+ }
+
+ location_manager_s *handle = (location_manager_s*)malloc(sizeof(location_manager_s));
+ if(handle==NULL)
+ {
+ LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, LOCATIONS_ERROR_OUT_OF_MEMORY);
+ return LOCATIONS_ERROR_OUT_OF_MEMORY;
+ }
+
+ memset(handle, 0 , sizeof(location_manager_s));
+
+ handle->object = location_new(_method);
+ if(handle->object == NULL)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : fail to location_new", __FUNCTION__, LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE);
+ free(handle);
+ return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+ handle->method = method;
+ handle->boundary= NULL;
+ *manager = (location_manager_h)handle;
+ return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_destroy(location_manager_h manager)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ location_manager_s *handle = (location_manager_s*)manager;
+
+ if(handle->boundary)
+ {
+ location_boundary_free(handle->boundary);
+ }
+
+ int ret = location_free(handle->object);
+ if(ret!=LOCATIONS_ERROR_NONE)
+ {
+ return _convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ free(handle);
+ return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_start(location_manager_h manager)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ location_manager_s *handle = (location_manager_s*)manager;
+
+ g_signal_connect (handle->object, "service-enabled", G_CALLBACK(cb_service_enabled), handle);
+ g_signal_connect (handle->object, "service-disabled", G_CALLBACK(cb_service_disabled), handle);
+ g_signal_connect (handle->object, "service-updated", G_CALLBACK(cb_service_updated), handle);
+ g_signal_connect (handle->object, "zone-in", G_CALLBACK(cb_zone_in), handle);
+ g_signal_connect (handle->object, "zone-out", G_CALLBACK(cb_zone_out), handle);
+
+ int ret = location_start (handle->object);
+ if( ret != LOCATION_ERROR_NONE)
+ {
+ return _convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_stop(location_manager_h manager)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ location_manager_s *handle = (location_manager_s*)manager;
+
+ int ret = location_stop (handle->object);
+ if( ret != LOCATION_ERROR_NONE)
+ {
+ return _convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_set_boundary_rect(location_manager_h manager, double top_left_latitude,double top_left_longitude,double bottom_right_latitude,double bottom_right_longitude)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_CHECK_CONDITION(top_left_latitude>=-90 && top_left_latitude<=90,LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER");
+ LOCATIONS_CHECK_CONDITION(top_left_longitude>=-180 && bottom_right_longitude<=180,LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
+ LOCATIONS_CHECK_CONDITION(bottom_right_latitude>=-90 && bottom_right_latitude<=90,LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
+ LOCATIONS_CHECK_CONDITION(bottom_right_longitude>=-180 && bottom_right_longitude<=180,LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
+
+ location_manager_s *handle = (location_manager_s*)manager;
+
+ int ret;
+ ret = location_boundary_foreach(handle->object, _remove_boundary,handle->object );
+ if(ret != LOCATION_ERROR_NONE)
+ {
+ LOGI("[%s] Failed to foreach boundary : 0x%x. ",__FUNCTION__, ret);
+ }
+
+ LocationPosition *rb = location_position_new(0, bottom_right_latitude, bottom_right_longitude, 0, LOCATION_STATUS_2D_FIX);
+ if (rb ==NULL)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_position_new", __FUNCTION__, LOCATIONS_ERROR_OUT_OF_MEMORY);
+ return LOCATIONS_ERROR_OUT_OF_MEMORY;
+ }
+ LocationPosition *lt = location_position_new(0, top_left_latitude, top_left_longitude, 0, LOCATION_STATUS_2D_FIX);
+ if (lt ==NULL)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_position_new", __FUNCTION__, LOCATIONS_ERROR_OUT_OF_MEMORY);
+ location_position_free (rb);
+ return LOCATIONS_ERROR_OUT_OF_MEMORY;
+ }
+
+ LocationBoundary* bound = NULL;
+ bound = location_boundary_new_for_rect(lt, rb);
+ location_position_free (rb);
+ location_position_free (lt);
+
+ if(bound)
+ {
+ ret = location_boundary_add(handle->object, bound);
+ if(handle->boundary)
+ {
+ location_boundary_free(handle->boundary);
+ handle->boundary = NULL;
+ }
+ handle->boundary = location_boundary_copy(bound);
+ location_boundary_free(bound);
+ if( ret != LOCATION_ERROR_NONE)
+ {
+ return _convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ }
+ else
+ {
+ LOGE("[%s] LOCATIONS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_rect", __FUNCTION__, LOCATIONS_ERROR_OUT_OF_MEMORY);
+ return LOCATIONS_ERROR_OUT_OF_MEMORY;
+ }
+ return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_set_boundary_circle(location_manager_h manager, double center_latitude,double center_longitude, double radius)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+
+ LOCATIONS_CHECK_CONDITION(center_latitude>=-90 && center_latitude<=90,LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER");
+ LOCATIONS_CHECK_CONDITION(center_longitude>=-180 && center_longitude<=180,LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER");
+ LOCATIONS_CHECK_CONDITION(radius>=0,LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER");
+
+ location_manager_s *handle = (location_manager_s*)manager;
+
+ int ret;
+ ret = location_boundary_foreach(handle->object, _remove_boundary, handle->object);
+ if(ret != LOCATION_ERROR_NONE)
+ {
+ LOGI("[%s] Failed to foreach boundary : 0x%x. ",__FUNCTION__, ret);
+ }
+
+ LocationPosition *center = location_position_new(0, center_latitude, center_longitude, 0, LOCATION_STATUS_2D_FIX);
+ if (center ==NULL)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_position_new", __FUNCTION__, LOCATIONS_ERROR_OUT_OF_MEMORY);
+ return LOCATIONS_ERROR_OUT_OF_MEMORY;
+ }
+
+ LocationBoundary* bound = NULL;
+ bound = location_boundary_new_for_circle(center,radius);
+ location_position_free (center);
+ if(bound)
+ {
+ ret = location_boundary_add(handle->object, bound);
+ if(handle->boundary)
+ {
+ location_boundary_free(handle->boundary);
+ handle->boundary = NULL;
+ }
+ handle->boundary = location_boundary_copy(bound);
+ location_boundary_free(bound);
+ if( ret != LOCATION_ERROR_NONE)
+ {
+ return _convert_error_code(ret,(char*)__FUNCTION__);
+ }
+ }
+ else
+ {
+ LOGE("[%s] LOCATIONS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_circle", __FUNCTION__, LOCATIONS_ERROR_OUT_OF_MEMORY);
+ return LOCATIONS_ERROR_OUT_OF_MEMORY;
+ }
+ return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_is_boundary_contains_coordinate(location_manager_h manager, double latitude, double longitude, bool *contained)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(contained);
+
+ LOCATIONS_CHECK_CONDITION(latitude>=-90 && latitude<=90,LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER");
+ LOCATIONS_CHECK_CONDITION(longitude>=-180 && longitude<=180,LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER");
+
+ location_manager_s *handle = (location_manager_s*)manager;
+
+ if(handle->boundary==NULL)
+ {
+ LOGI("[%s] There is no boundary ",__FUNCTION__);
+ *contained = FALSE;
+ return LOCATIONS_ERROR_NONE;
+ }
+
+ LocationPosition *pos = location_position_new(0, latitude, longitude, 0, LOCATION_STATUS_2D_FIX);
+ if (pos ==NULL)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_position_new", __FUNCTION__, LOCATIONS_ERROR_OUT_OF_MEMORY);
+ *contained = FALSE;
+ return LOCATIONS_ERROR_OUT_OF_MEMORY;
+ }
+ gboolean is_inside = location_boundary_if_inside(handle->boundary, pos);
+
+ if(is_inside)
+ {
+ *contained = TRUE;
+ }
+ else
+ {
+ *contained = FALSE;
+ }
+ location_position_free (pos);
+ return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_get_method(location_manager_h manager, location_method_e* method)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(method);
+ location_manager_s *handle = (location_manager_s*)manager;
+ LocationMethod _method = LOCATION_METHOD_NONE;
+ g_object_get(handle->object, "method", &_method, NULL);
+ switch(_method)
+ {
+ case LOCATION_METHOD_NONE :
+ *method = LOCATIONS_METHOD_NONE;
+ break;
+ case LOCATION_METHOD_HYBRID :
+ case LOCATION_METHOD_CPS:
+ case LOCATION_METHOD_IPS :
+ *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_SPS :
+ *method = LOCATIONS_METHOD_SPS;
+ break;
+ default :
+ {
+ LOGE("[%s] LOCATIONS_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (location_method_e) - method : %d ",__FUNCTION__,LOCATIONS_ERROR_INVALID_PARAMETER, method);
+ return LOCATIONS_ERROR_INVALID_PARAMETER;
+ }
+ }
+ //*method = handle->method;
+ return LOCATIONS_ERROR_NONE;
+}
+
+
+int location_manager_get_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, time_t *timestamp)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(altitude);
+ LOCATIONS_NULL_ARG_CHECK(latitude);
+ LOCATIONS_NULL_ARG_CHECK(longitude);
+ LOCATIONS_NULL_ARG_CHECK(timestamp);
+
+ location_manager_s *handle = (location_manager_s*)manager;
+ int ret;
+ LocationPosition *pos = NULL;
+ LocationAccuracy *acc = NULL;
+ ret = location_get_position(handle->object, &pos, &acc);
+ if( ret != LOCATION_ERROR_NONE)
+ {
+ return _convert_error_code(ret,(char*)__FUNCTION__);
+ }
+
+ if(pos->status == LOCATION_STATUS_NO_FIX)
+ {
+ *altitude = -1;
+ *latitude = -1;
+ *longitude =-1;
+ }
+ else
+ {
+ if(pos->status == LOCATION_STATUS_3D_FIX)
+ {
+ *altitude = pos->altitude;
+ }
+ else
+ {
+ *altitude = -1;
+ }
+ *latitude = pos->latitude;
+ *longitude = pos->longitude;
+ }
+ *timestamp = pos->timestamp;
+ location_position_free (pos);
+ location_accuracy_free (acc);
+ return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_get_velocity(location_manager_h manager, int *climb, int *direction, int *speed, time_t *timestamp)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(climb);
+ LOCATIONS_NULL_ARG_CHECK(direction);
+ LOCATIONS_NULL_ARG_CHECK(speed);
+ LOCATIONS_NULL_ARG_CHECK(timestamp);
+
+ location_manager_s *handle = (location_manager_s*)manager;
+ int ret;
+ LocationVelocity *vel = NULL;
+ LocationAccuracy *acc = NULL;
+ ret = location_get_velocity(handle->object, &vel, &acc);
+ if( ret != LOCATION_ERROR_NONE)
+ {
+ return _convert_error_code(ret,(char*)__FUNCTION__);
+ }
+
+ *climb = vel->climb;
+ *direction = vel->direction;
+ *speed = vel->speed;
+ *timestamp = vel->timestamp;
+ location_velocity_free(vel);
+ location_accuracy_free(acc);
+ return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_get_accuracy(location_manager_h manager, location_accuracy_level_e *level, double *horizontal, double *vertical)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(level);
+ LOCATIONS_NULL_ARG_CHECK(horizontal);
+ LOCATIONS_NULL_ARG_CHECK(vertical);
+ location_manager_s *handle = (location_manager_s*)manager;
+
+ int ret;
+ LocationPosition *pos = NULL;
+ LocationAccuracy *acc = NULL;
+ ret = location_get_position(handle->object, &pos, &acc);
+ if( ret != LOCATION_ERROR_NONE)
+ {
+ return _convert_error_code(ret,(char*)__FUNCTION__);
+ }
+
+ *level = acc->level;
+ *horizontal = acc->horizontal_accuracy;
+ *vertical = acc->vertical_accuracy;
+ location_position_free(pos);
+ location_accuracy_free(acc);
+ return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, void *user_data)
+{
+ return _set_callback(_LOCATIONS_EVENT_TYPE_POSITION,manager,callback,user_data);
+}
+
+int location_manager_unset_position_updated_cb(location_manager_h manager)
+{
+ return _unset_callback(_LOCATIONS_EVENT_TYPE_POSITION,manager);
+}
+
+int location_manager_set_velocity_updated_cb(location_manager_h manager, location_velocity_updated_cb callback, void *user_data)
+{
+ return _set_callback(_LOCATIONS_EVENT_TYPE_VELOCITY,manager,callback,user_data);
+}
+
+int location_manager_unset_velocity_updated_cb(location_manager_h manager)
+{
+ return _unset_callback(_LOCATIONS_EVENT_TYPE_VELOCITY,manager);
+}
+
+int location_manager_set_service_state_changed_cb(location_manager_h manager, location_service_state_changed_cb callback, void *user_data)
+{
+ return _set_callback(_LOCATIONS_EVENT_TYPE_SERVICE_STATE,manager,callback,user_data);
+}
+
+int location_manager_unset_service_state_changed_cb(location_manager_h manager)
+{
+ return _unset_callback(_LOCATIONS_EVENT_TYPE_SERVICE_STATE,manager);
+}
+
+int location_manager_set_zone_changed_cb(location_manager_h manager, location_zone_changed_cb callback, void *user_data)
+{
+ return _set_callback(_LOCATIONS_EVENT_TYPE_BOUNDARY,manager,callback,user_data);
+}
+
+int location_manager_unset_zone_changed_cb(location_manager_h manager)
+{
+ return _unset_callback(_LOCATIONS_EVENT_TYPE_BOUNDARY,manager);
+}
+
+/////////////////////////////////////////
+// GPS Status & Satellites
+////////////////////////////////////////
+
+int gps_status_get_nmea(location_manager_h manager, char** nmea)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(nmea);
+ location_manager_s *handle = (location_manager_s*)manager;
+
+ if(handle->method == LOCATIONS_METHOD_HYBRID)
+ {
+ LocationMethod _method = LOCATION_METHOD_NONE;
+ g_object_get(handle->object, "method", &_method, NULL);
+ if(_method!=LOCATION_METHOD_GPS)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", __FUNCTION__, LOCATIONS_ERROR_INCORRECT_METHOD, handle->method);
+ return LOCATIONS_ERROR_INCORRECT_METHOD;
+ }
+ }
+ else if(handle->method != LOCATIONS_METHOD_GPS)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", __FUNCTION__, 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)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : nmea data is NULL ",__FUNCTION__,LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE);
+ return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+ *nmea = NULL;
+ *nmea = strdup(nmea_data);
+ if(*nmea == NULL)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to strdup ",__FUNCTION__,LOCATIONS_ERROR_OUT_OF_MEMORY);
+ return LOCATIONS_ERROR_OUT_OF_MEMORY;
+ }
+ g_free(nmea_data);
+ return LOCATIONS_ERROR_NONE;
+}
+
+int gps_status_get_satellite_count_in_view(location_manager_h manager, int *count)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(count);
+ location_manager_s *handle = (location_manager_s*)manager;
+ if(handle->method == LOCATIONS_METHOD_HYBRID)
+ {
+ LocationMethod _method = LOCATION_METHOD_NONE;
+ g_object_get(handle->object, "method", &_method, NULL);
+ if(_method!=LOCATION_METHOD_GPS)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", __FUNCTION__, LOCATIONS_ERROR_INCORRECT_METHOD, handle->method);
+ return LOCATIONS_ERROR_INCORRECT_METHOD;
+ }
+ }
+ else if(handle->method != LOCATIONS_METHOD_GPS)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", __FUNCTION__, LOCATIONS_ERROR_INCORRECT_METHOD, handle->method);
+ return LOCATIONS_ERROR_INCORRECT_METHOD;
+ }
+
+ LocationSatellite *sat = NULL;
+ g_object_get (handle->object, "satellite", &sat, NULL);
+ if (sat == NULL)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ",__FUNCTION__,LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE);
+ return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+ *count = sat->num_of_sat_inview;
+ location_satellite_free (sat);
+ sat = NULL;
+ return LOCATIONS_ERROR_NONE;
+}
+
+int gps_status_foreach_satellites_in_view (location_manager_h manager, gps_status_get_satellites_cb callback, void *user_data)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(callback);
+ location_manager_s *handle = (location_manager_s*)manager;
+ if(handle->method == LOCATIONS_METHOD_HYBRID)
+ {
+ LocationMethod _method = LOCATION_METHOD_NONE;
+ g_object_get(handle->object, "method", &_method, NULL);
+ if(_method!=LOCATION_METHOD_GPS)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", __FUNCTION__, LOCATIONS_ERROR_INCORRECT_METHOD, handle->method);
+ return LOCATIONS_ERROR_INCORRECT_METHOD;
+ }
+ }
+ else if(handle->method != LOCATIONS_METHOD_GPS)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", __FUNCTION__, LOCATIONS_ERROR_INCORRECT_METHOD, handle->method);
+ return LOCATIONS_ERROR_INCORRECT_METHOD;
+ }
+
+ LocationSatellite *sat = NULL;
+ g_object_get (handle->object, "satellite", &sat, NULL);
+ if (sat == NULL)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ",__FUNCTION__,LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE);
+ return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+
+ int i;
+ for (i=0; i<sat->num_of_sat_inview; i++)
+ {
+ guint prn;
+ gboolean used;
+ guint elevation;
+ guint azimuth;
+ gint snr;
+ location_satellite_get_satellite_details(sat, i, &prn, &used, &elevation, &azimuth, &snr);
+ if ( callback(azimuth, elevation, prn, snr, used, user_data) != TRUE )
+ break;
+ }
+ location_satellite_free (sat);
+ sat = NULL;
+ return LOCATIONS_ERROR_NONE;
+}
+
+int gps_status_get_active_satellite_count(location_manager_h manager, int *count)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(count);
+ location_manager_s *handle = (location_manager_s*)manager;
+ if(handle->method == LOCATIONS_METHOD_HYBRID)
+ {
+ LocationMethod _method = LOCATION_METHOD_NONE;
+ g_object_get(handle->object, "method", &_method, NULL);
+ if(_method!=LOCATION_METHOD_GPS)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", __FUNCTION__, LOCATIONS_ERROR_INCORRECT_METHOD, handle->method);
+ return LOCATIONS_ERROR_INCORRECT_METHOD;
+ }
+ }
+ else if(handle->method != LOCATIONS_METHOD_GPS)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", __FUNCTION__, LOCATIONS_ERROR_INCORRECT_METHOD, handle->method);
+ return LOCATIONS_ERROR_INCORRECT_METHOD;
+ }
+
+ LocationSatellite *sat = NULL;
+ g_object_get (handle->object, "satellite", &sat, NULL);
+ if (sat == NULL)
+ {
+ LOGE("[%s] LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ",__FUNCTION__,LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE);
+ return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+ *count = sat->num_of_sat_used;
+ location_satellite_free (sat);
+ sat = NULL;
+ return LOCATIONS_ERROR_NONE;
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..afc523f
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,19 @@
+
+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}")
+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})
+ENDFOREACH()
+
diff --git a/test/location_test.c b/test/location_test.c
new file mode 100755
index 0000000..cdf73c9
--- /dev/null
+++ b/test/location_test.c
@@ -0,0 +1,185 @@
+/*
+* Copyright (c) 2011 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <locations.h>
+
+location_manager_h manager;
+
+void zone_event_cb(location_boundary_state_e state, double latitude, double longitude, double altitude, time_t timestamp, void *user_data)
+{
+ if (state == LOCATIONS_BOUNDARY_IN)
+ {
+ printf("Entering zone\n");
+ }
+ else // state == LOCATIONS_BOUNDARY_OUT
+ {
+ printf("Leaving zone\n");
+ }
+
+ printf("Latitude: %lf, longitude: %lf, altitude: %lf\n", latitude, longitude, altitude);
+
+ printf("Time: %s\n", ctime(&timestamp));
+}
+
+
+static bool satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use, void *user_data)
+{
+ printf("[Satellite information] azimuth : %d, elevation : %d, prn :%d, snr : %d, used: %d\n",azimuth, elevation, prn, snr, is_in_use);
+ return true;
+}
+
+static void _state_change_cb(location_service_state_e state, void *user_data)
+{
+ fprintf(stderr, "--------------------------state change %d---------\n", state);
+ location_manager_h lm = (location_manager_h)user_data;
+ if(state == LOCATIONS_SERVICE_ENABLED)
+ {
+ int ret;
+ double altitude;
+ double latitude;
+ double longitude;
+ time_t timestamp;
+ ret = location_manager_get_position(lm, &altitude,&latitude,&longitude, &timestamp);
+ if (ret != LOCATIONS_ERROR_NONE)
+ {
+ printf(" Fail : location_manager_get_position ---> %d \n",ret);
+ }
+ else
+ {
+ printf("alt: %g, lat %g, long %g\n", altitude,latitude, longitude);
+ }
+
+ location_accuracy_level_e level;
+ double horizontal;
+ double vertical;
+ ret = location_manager_get_accuracy(lm, &level, &horizontal, &vertical );
+ if (ret != LOCATIONS_ERROR_NONE)
+ {
+ printf(" Fail : location_manager_get_accuracy ---> %d \n",ret);
+ }
+ else
+ {
+ printf("Level : %d, horizontal: %g, vertical %g\n", level, horizontal,vertical);
+ }
+
+ char *nmea;
+ ret = gps_status_get_nmea(lm,&nmea);
+ if (ret != LOCATIONS_ERROR_NONE)
+ {
+ printf(" Fail : gps_status_get_nmea ---> %d \n",ret);
+ }
+ else
+ {
+ printf("NMEA : %s\n",nmea);
+ free(nmea);
+ }
+
+ int count_in_view, count_in_used;
+ ret = gps_status_get_satellite_count_in_view (lm,&count_in_view);
+ if (ret != LOCATIONS_ERROR_NONE)
+ {
+ printf(" Fail : gps_status_get_satellite_count_in_view ---> %d \n",ret);
+ }
+ else
+ {
+ printf("Satellite count in view : %d\n",count_in_view);
+ }
+
+ ret = gps_status_get_active_satellite_count(lm,&count_in_used);
+ if (ret != LOCATIONS_ERROR_NONE)
+ {
+ printf(" Fail : gps_status_get_active_satellite_count ---> %d \n",ret);
+ }
+ else
+ {
+ printf("Satellite count in used : %d\n",count_in_used);
+ }
+
+ ret = gps_status_foreach_satellites_in_view(lm,satellites_foreach_cb ,user_data);
+ if (ret != LOCATIONS_ERROR_NONE)
+ {
+ printf(" Fail : gps_status_foreach_satellites_in_view ---> %d \n",ret);
+ }
+
+ }
+}
+
+int location_test()
+{
+ int ret ;
+ ret= location_manager_create(LOCATIONS_METHOD_GPS,&manager);
+ printf("create : %d\n",ret);
+
+
+ double center_latitude = 37.258;
+ double center_longitude = 127.056;
+ double radius = 30;
+
+ ret = location_manager_set_boundary_circle(manager, center_latitude, center_longitude, radius);
+ if (ret != LOCATIONS_ERROR_NONE)
+ {
+ // Setting boundary failed, handle the error
+ // ...
+ printf("Setting boundary failed\n");
+ } else printf("Boundary set\n");
+
+ 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);
+ return 1;
+}
+
+static GMainLoop *g_mainloop = NULL;
+
+static gboolean exit_program (gpointer data)
+{
+ if(manager==NULL)
+ {
+ printf("manager == NULL \n");
+ }
+ else
+ {
+ int ret =location_manager_stop(manager);
+ printf("stop : %d\n",ret);
+ ret =location_manager_destroy(manager);
+ printf("destroy : %d\n",ret);
+ }
+ g_main_loop_quit (g_mainloop);
+ printf("Quit g_main_loop\n");
+ return FALSE;
+}
+
+
+int main(int argc, char ** argv)
+{
+ g_setenv("PKG_NAME", "com.samsung.location-test", 1);
+ g_mainloop = g_main_loop_new (NULL, 0);
+ location_test();
+ g_timeout_add_seconds(90, exit_program, NULL);
+ g_main_loop_run (g_mainloop);
+ return 0;
+}
+