upload tizen1.0 source
authorKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 07:58:26 +0000 (16:58 +0900)
committerKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 07:58:26 +0000 (16:58 +0900)
14 files changed:
.gitignore [deleted file]
CMakeLists.txt
capi-location-manager.pc.in
debian/changelog
debian/control
include/location_bounds.h [new file with mode: 0644]
include/location_preference.h [new file with mode: 0644]
include/locations.h
include/locations_private.h
packaging/capi-location-manager.spec
src/location_bounds.c [new file with mode: 0644]
src/location_preference.c [new file with mode: 0644]
src/locations.c
test/location_test.c

diff --git a/.gitignore b/.gitignore
deleted file mode 100644 (file)
index a6d8f19..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-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
index 7b6ff02..3d00fcc 100755 (executable)
@@ -11,6 +11,7 @@ SET(INC_DIR include)
 INCLUDE_DIRECTORIES(${INC_DIR})
 
 SET(dependents "dlog location capi-base-common")
+SET(pc_dependents "capi-base-common")
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(${fw_name} REQUIRED ${dependents})
@@ -51,7 +52,7 @@ INSTALL(
         )
 
 SET(PC_NAME ${fw_name})
-SET(PC_REQUIRED ${dependents})
+SET(PC_REQUIRED ${pc_dependents})
 SET(PC_LDFLAGS -l${fw_name})
 SET(PC_CFLAGS -I\${includedir}/location)
 
index d935ba8..150e613 100644 (file)
@@ -11,5 +11,5 @@ Description: @PACKAGE_DESCRIPTION@
 Version: @VERSION@
 Requires: @PC_REQUIRED@ 
 Libs: -L${libdir} @PC_LDFLAGS@
-Cflags: -I${includedir} @PC_CFLAGS@
+Cflags: -I${includedir}
 
index a381c67..923732b 100644 (file)
+capi-location-manager (0.1.0-18) unstable; urgency=low
+
+  * Fix return value for location_bounds_is_contains_coordinates()
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-18
+
+ -- Minjune Kim <sena06.kim@samsung.com>  Tue, 03 Apr 2012 11:24:16 +0900
+
+capi-location-manager (0.1.0-17) unstable; urgency=low
+
+  * fixed TC results
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-17
+
+ -- Genie Kim <daejins.kim@samsung.com>  Thu, 22 Mar 2012 17:22:01 +0900
+
+capi-location-manager (0.1.0-16) unstable; urgency=low
+
+  * Correct bugs in location preference
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-16 
+
+ -- ByungWoo Lee <bw1212.lee@samsung.com>  Tue, 20 Mar 2012 21:02:48 +0900
+
+capi-location-manager (0.1.0-15) unstable; urgency=low
+
+  * Add location preference
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-15
+
+ -- ByungWoo Lee <bw1212.lee@samsung.com>  Mon, 19 Mar 2012 19:37:00 +0900
+
+capi-location-manager (0.1.0-14) unstable; urgency=low
+
+  * change gps_status_get_satellite functions 
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-14
+
+ -- Genie Kim <daejins.kim@samsung.com>  Wed, 14 Mar 2012 20:41:44 +0900
+
+capi-location-manager (0.1.0-13) unstable; urgency=low
+
+  * Remove the unneccesary structure (location_bounds_s)
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-13
+ -- Kangho Hur <kangho.hur@samsung.com>  Tue, 13 Mar 2012 16:03:12 +0900
+
+capi-location-manager (0.1.0-12) unstable; urgency=low
+
+  * Add the last position, velocity, accuracy and satellite
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-12
+
+ -- Genie Kim <daejins.kim@samsung.com>  Thu, 08 Mar 2012 14:56:28 +0900
+
+capi-location-manager (0.1.0-11) unstable; urgency=low
+
+  * Support to multiple boundaries
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-11
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Tue, 06 Mar 2012 20:21:26 +0900
+
+capi-location-manager (0.1.0-10) unstable; urgency=low
+
+  * Add the location_bounds.
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-10 
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Fri, 02 Mar 2012 20:52:01 +0900
+
 capi-location-manager (0.1.0-9) unstable; urgency=low
 
-  * Use 'static' to local function which is limited to the current source file. 
+  * Use 'static' to local function which is limited to the current source file.
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-9 
 
- -- Kangho Hur <kangho.hur@samsung.com>  Tue, 21 Feb 2012 10:22:17 +0900
+ -- Kangho Hur <kangho.hur@samsung.com>  Tue, 21 Feb 2012 10:11:16 +0900
 
 capi-location-manager (0.1.0-8) unstable; urgency=low
 
-  * Apply the SOVERSION 
+  * Apply the SOVERSION
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-8 
 
- -- Kangho Hur <kangho.hur@samsung.com>  Tue, 14 Feb 2012 18:24:02 +0900
+ -- Kangho Hur <kangho.hur@samsung.com>  Tue, 14 Feb 2012 17:53:09 +0900
 
 capi-location-manager (0.1.0-7) unstable; urgency=low
 
-  * Support to  location_manager_get_last_known_position(), location_manager_is_supported_method(), and interval setting.
+  * Add the location_manager_get_last_known_position(), location_manager_is_supported_method(), and interval setting.
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-7
 
- -- Kangho Hur <kangho.hur@samsung.com>  Fri, 10 Feb 2012 15:40:01 +0900
+ -- Kangho Hur <kangho.hur@samsung.com>  Thu, 26 Jan 2012 20:08:56 +0900
 
 capi-location-manager (0.1.0-6) unstable; urgency=low
 
-  * Initial release.
+  * Apply Location Boundary changes
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-6
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Wed, 07 Dec 2011 11:44:27 +0900
+
+capi-location-manager (0.1.0-5) unstable; urgency=low
+
+  * Changes the value of ERROR_NONE
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-5
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Mon, 05 Dec 2011 11:18:34 +0900
+
+capi-location-manager (0.1.0-4) unstable; urgency=low
+
+  * Apply the Tizen
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-4
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Wed, 23 Nov 2011 15:09:01 +0900
+
+capi-location-manager (0.1.0-3) unstable; urgency=low
+
+  * Repackage for SDK
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-3 
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Mon, 07 Nov 2011 21:40:30 +0900
+
+capi-location-manager (0.1.0-2) unstable; urgency=low
+
+  * Apply the error messages
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-2 
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Fri, 07 Oct 2011 13:28:33 +0900
+
+capi-location-manager (0.1.0-1) unstable; urgency=low
+
+  * Alpha Release
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.1.0-1 
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Tue, 27 Sep 2011 20:03:39 +0900
+
+capi-location-manager (0.0.1-5) unstable; urgency=low
+
+  * Add the location_manager_is_boundary_contains_coordinate()
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.0.1-5
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Mon, 26 Sep 2011 19:41:49 +0900
+
+capi-location-manager (0.0.1-4) unstable; urgency=low
+
+  * gps_status_get_used_satellite_count() API name changes.
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.0.1-4
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Fri, 09 Sep 2011 16:58:25 +0900
+
+capi-location-manager (0.0.1-3) unstable; urgency=low
+
+  * Remove IPS, CPS location method type
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.0.1-3
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Mon, 05 Sep 2011 14:19:50 +0900
+
+capi-location-manager (0.0.1-2) unstable; urgency=low
+
+  * Rename the callback prototype
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.0.1-2
+
+ -- Kangho Hur <kangho.hur@samsung.com>  Mon, 08 Aug 2011 10:15:11 +0900
+
+capi-location-manager (0.0.1-1) unstable; urgency=low
+
+  * Initial Upload
+  * Git: slp-source.sec.samsung.net:slp/api/location-manager
+  * Tag: capi-location-manager_0.0.1-1
 
- -- Kangho Hur <kangho.hur@samsung.com>  Wed, 07 Dec 2011 12:44:12 +0900
+ -- Kangho Hur <kangho.hur@samsung.com>  Thu, 04 Aug 2011 16:51:02 +0900
index 72792e1..1e6dcd7 100644 (file)
@@ -1,18 +1,17 @@
-
 Source: capi-location-manager
 Section: libs
 Priority: extra
-Maintainer: Kangho Hur <kangho.hur@samsung.com>
+Maintainer: Kangho Hur <kangho.hur@samsung.com>, ByungWoo Lee <bw1212.lee@samsung.com>, wYoungae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>, Genie Kim <daejins.kim@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}
+Depends: ${shlibs: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
+Depends: ${shlibs:Depends}, ${misc:Depends}, capi-location-manager (= ${Source-Version}), capi-base-common-dev
 Description: A Location Manager library in Tizen Native API (DEV)
 
 Package: capi-location-manager-dbg
diff --git a/include/location_bounds.h b/include/location_bounds.h
new file mode 100644 (file)
index 0000000..59ee72c
--- /dev/null
@@ -0,0 +1,213 @@
+/*
+* 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_BOUNDS_H__
+#define __TIZEN_LOCATION_BOUNDS_H__
+
+#include <tizen_type.h>
+#include <tizen_error.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define LOCATION_BOUNDS_ERROR_CLASS          TIZEN_ERROR_LOCATION_CLASS | 0x20
+
+/**
+ * @addtogroup CAPI_LOCATION_BOUNDS_MODULE
+ * @{
+ */
+
+/**
+ * @brief Represents a coordinates with latitude and longitude.
+ */
+typedef struct
+{
+       double latitude;        /**< The latitude [-90.0 ~ 90.0] (degrees) */
+       double longitude;       /**< The longitude [-180.0 ~ 180.0] (degrees) */
+} location_coords_s;
+
+/**
+ * @brief The location boundary handle.
+ */
+ typedef void *location_bounds_h;
+
+/**
+ * @brief Enumerations of 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_bound_error_e;
+
+
+/**
+ * @brief Location boundary type.
+ */
+typedef enum
+{
+    LOCATION_BOUNDS_RECT=1,    /**< Rectangular geographical area type. */
+    LOCATION_BOUNDS_CIRCLE,       /**< Circle geographical area type.. */
+    LOCATION_BOUNDS_POLYGON,       /**< Polygon geographical area type.. */
+} location_bounds_type_e;
+
+/**
+ * @brief 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
+ * @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() 
+ */
+typedef bool (*polygon_coords_cb)(location_coords_s coords, void *user_data);
+
+
+/**
+ * @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.
+ * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
+ * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @see location_bounds_get_rect_coords() 
+ * @see location_bounds_destroy()
+ */
+int location_bounds_create_rect(location_coords_s top_left, location_coords_s bottom_right, location_bounds_h* bounds);
+
+/**
+ * @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.
+ * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
+ * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @see location_bounds_get_circle_coords()
+ * @see location_bounds_destroy()
+ */
+int location_bounds_create_circle(location_coords_s center, double radius, location_bounds_h* bounds);
+
+/**
+ * @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.
+ * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
+ * @retval #LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @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
+ * @see location_bounds_create_rect()
+ * @see location_bounds_create_circle()
+ * @see location_bounds_create_polygon()
+ */
+bool location_bounds_is_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.
+ * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
+ * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @see location_bounds_create_rect()
+ * @see location_bounds_create_circle()
+ * @see location_bounds_create_polygon()
+ */
+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.
+ * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
+ * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @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);
+
+/**
+ * @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.
+ * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
+ * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @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);
+
+/**
+ * @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.
+ * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
+ * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @retval #LOCATION_BOUNDS_ERROR_INCORRECT_TYPE Incorrect bounds type
+ * @post It invokes polygon_coords_cb() to get coordinates of polygon.
+ * @see polygon_coords_cb()
+ * @see location_bounds_create_polygon()
+ */
+int location_bounds_foreach_polygon_coords(location_bounds_h bounds, polygon_coords_cb callback, void *user_data);
+
+/**
+ * @brief Releases the location bounds.
+ * @param[in] bounds The location bounds handle
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #LOCATION_BOUNDS_ERROR_NONE Successful
+ * @retval #LOCATION_BOUNDS_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @see location_bounds_create_rect()
+ * @see location_bounds_create_circle()
+ * @see location_bounds_create_polygon()
+*/
+int location_bounds_destroy(location_bounds_h bounds);
+
+/**
+ * @}
+ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_LOCATION_BOUNDS_H__ */
+
diff --git a/include/location_preference.h b/include/location_preference.h
new file mode 100644 (file)
index 0000000..29d44e4
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+* 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_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 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 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 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);
+
+/**
+ * @brief Gets the provider name 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()
+ */
+int location_preference_get_provider_name(location_service_h service, char** provider);
+
+/**
+ * @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);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_LOCATION_LOCATION_PREFERENCE_H__ */
index bda7960..9d9cfcb 100644 (file)
@@ -11,7 +11,7 @@
 * 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. 
+* limitations under the License.
 */
 
 #ifndef __TIZEN_LOCATION_LOCATIONS_H__
@@ -19,6 +19,7 @@
 
 #include <tizen_type.h>
 #include <tizen_error.h>
+#include <location_bounds.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -115,7 +116,7 @@ typedef enum
  * @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);
+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.
@@ -128,7 +129,7 @@ typedef void(*location_position_updated_cb )(double latitude, double longitude,
  * @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);
+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.
@@ -140,7 +141,7 @@ typedef void(*location_velocity_updated_cb )(double speed, double direction, dou
  * @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);
+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.
@@ -155,7 +156,16 @@ typedef void(*location_service_state_changed_cb )(location_service_state_e state
  * @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);
+typedef void(*location_zone_changed_cb)(location_boundary_state_e state, double latitude, double longitude, double altitude, time_t timestamp, 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
+ * @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.
@@ -192,18 +202,18 @@ int location_manager_create(location_method_e method, location_manager_h* manage
 int location_manager_destroy(location_manager_h manager);
 
 /**
- * @brief Starts the location service. 
+ * @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 
+ * 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().
+ * 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.
  *
@@ -253,54 +263,46 @@ int location_manager_start(location_manager_h manager);
 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)
+ * @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.
  * @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_remove_boundary()
  * @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);
+int location_manager_add_boundary(location_manager_h manager, const location_bounds_h bounds);
 
 /**
- * @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)
+ * @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
- * @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()
+ * @see location_manager_add_boundary()
  */
-int location_manager_set_boundary_circle(location_manager_h manager, double center_latitude, double center_longitude, double radius);
+int location_manager_remove_boundary(location_manager_h manager, const location_bounds_h bounds);
 
 /**
- * @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.
+ * @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
- * @retval #LOCATIONS_ERROR_OUT_OF_MEMORY Out of memory
- * @see location_manager_set_boundary_rect()
- * @see location_manager_set_boundary_circle()
+ * @post  location_bounds_cb() will be invoked
+ * @see location_manager_add_boundary()
+ * @see location_manager_remove_boundary()
+ * @see location_bounds_cb()
  */
-int location_manager_is_boundary_contains_coordinate(location_manager_h manager, double latitude, double longitude, bool *contained);
+int location_manager_foreach_boundary(location_manager_h manager,  location_bounds_cb callback, void *user_data);
 
 /**
  * @brief Gets the given location manager's method.
@@ -332,7 +334,7 @@ int location_manager_get_method(location_manager_h manager, location_method_e *m
  * @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() 
+ * @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);
 
@@ -351,7 +353,7 @@ int location_manager_get_position(location_manager_h manager, double *altitude,
  * @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() 
+ * @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);
 
@@ -366,26 +368,56 @@ int location_manager_get_velocity(location_manager_h manager, int *climb, int *d
  * @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() 
+ * @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 Gets the last known position information which is recorded.
+ * @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)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #LOCATIONS_ERROR_NONE Successful
+ * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument
+ * @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);
+
+/**
+ * @brief Gets the last velocity information which is recorded.
  * @details
- * The @altitude, @latitude, @longitude, and @timestamp values should be 0, if there is no record of any previous position information.
+ * The @a climb, @a direction and @a speed values should be 0, if there is no record of any previous velocity information.
+ *
  * @param[in]   manager     The location manager handle
- * @param[out]  altitude    The last known altitude (meters)
- * @param[out]  latitude    The last known latitude [-90.0 ~ 90.0] (degrees)
- * @param[out]  longitude   The last known longitude [-180.0 ~ 180.0] (degrees)
+ * @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)
  * @return 0 on success, otherwise a negative error value.
  * @retval #LOCATIONS_ERROR_NONE Successful
  * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument
+ * @pre The location manager handle must be created by location_manager_create()
+ */
+int location_manager_get_last_velocity(location_manager_h manager, int *climb, int *direction, int *speed, time_t *timestamp);
+
+/**
+ * @brief Gets the last accuracy information which is recorded.
+ * @param[in]   manager        The location manager handle
+ * @param[out]  level          The last accuracy level
+ * @param[out]  horizontal     The last horizontal accuracy (meters)
+ * @param[out]  vertical       The last vertical accuracy (meters)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #LOCATIONS_ERROR_NONE Successful
  * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument
- * @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_known_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, time_t *timestamp);
+int location_manager_get_last_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.
@@ -493,6 +525,16 @@ int location_manager_set_zone_changed_cb(location_manager_h manager, location_zo
  * @see location_manager_set_zone_changed_cb()
  */
 int location_manager_unset_zone_changed_cb(location_manager_h manager);
+
+/**
+ * @brief      Sends command to the server.
+ * @param[in]  cmd The command string to be sent
+ * @return 0 on success, otherwise a negative error value.
+ * @retval  #LOCATIONS_ERROR_NONE      Successful
+ * @retval  #LOCATIONS_ERROR_INVALID_PARAMETER  Invalid parameter
+ */
+int location_manager_send_command(const char *cmd);
+
 /**
  * @}
  */
@@ -516,17 +558,15 @@ int location_manager_unset_zone_changed_cb(location_manager_h manager);
  * @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.
  * @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
+ * @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.
@@ -535,35 +575,31 @@ typedef bool(*gps_status_get_satellites_cb)(unsigned int azimuth, unsigned int e
  * @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() 
+ * @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.
- *
+ * @brief Gets the information of satellites.
+ * @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
+ * @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)
  * @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() 
+ * @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);
+int  gps_status_get_satellite(location_manager_h manager, int *num_of_active, int *num_of_inview, time_t *timestamp);
 
 /**
  * @brief Invokes the callback function for each satellite.
- *
- * @remarks
- * This function is valid only for location managers with the #LOCATIONS_METHOD_GPS method.
- *
+ * @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
@@ -572,30 +608,48 @@ int  gps_status_get_satellite_count_in_view(location_manager_h manager, int *cou
  * @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() 
+ * @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_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);
 
 /**
- * @brief Gets the number of satellites available to be used.
- *
- * @remarks
- * This call is valid only for location managers with #LOCATIONS_METHOD_GPS method.
- *
+ * @brief Gets the last information of satellites.
+ * @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
+ * @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)
+ * @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_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
- * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() 
- * @see   gps_status_get_satellite_count_in_view()
+ * @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()
  */
-int  gps_status_get_active_satellite_count(location_manager_h manager, int *count);
+int gps_status_foreach_last_satellites_in_view(location_manager_h manager, gps_status_get_satellites_cb callback, void *user_data);
+
 /**
  * @}
  */
index 99f7ece..cdcde84 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <location/location.h>
 #include <locations.h>
+#include <location_bounds.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -29,6 +30,7 @@ typedef enum {
        _LOCATIONS_EVENT_TYPE_POSITION,
        _LOCATIONS_EVENT_TYPE_VELOCITY,
        _LOCATIONS_EVENT_TYPE_BOUNDARY,
+       _LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS,
        _LOCATIONS_EVENT_TYPE_NUM
 }_location_event_e;
 
@@ -37,7 +39,7 @@ typedef struct _location_manager_s{
        const void* user_cb[_LOCATIONS_EVENT_TYPE_NUM];
        void* user_data[_LOCATIONS_EVENT_TYPE_NUM];
        location_method_e method;
-       LocationBoundary* boundary;
+       bool is_continue_foreach_bounds;
 } location_manager_s;
 
 #ifdef __cplusplus
index 0fa633f..c17a93d 100644 (file)
@@ -1,7 +1,7 @@
 Name:       capi-location-manager
 Summary:    A Location Manager library in Tizen Native API
 Version:    0.1.0
-Release:    1
+Release:    17
 Group:      TO_BE/FILLED_IN
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
@@ -29,10 +29,8 @@ Requires: %{name} = %{version}-%{release}
 
 
 %build
-FULLVER=%{version}
-MAJORVER=`echo ${FULLVER} | cut -d '.' -f 1`
-cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=${FULLVER} -DMAJORVER=${MAJORVER}
-
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
 
 make %{?jobs:-j%jobs}
 
@@ -46,10 +44,11 @@ rm -rf %{buildroot}
 
 
 %files
-%{_libdir}/libcapi-location-manager.so*
+%{_libdir}/libcapi-location-manager.so.*
 
 %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
new file mode 100644 (file)
index 0000000..caf66cd
--- /dev/null
@@ -0,0 +1,271 @@
+/*
+* 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,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER") \
+
+static void __free_position_list(gpointer data)
+{
+       if (data == NULL) return;
+
+       LocationPosition *position = (LocationPosition*) data;
+       location_position_free(position);
+}
+
+static location_bounds_type_e __convert_bounds_type(LocationBoundaryType type)
+{
+       location_bounds_type_e ret;
+       switch(type)
+       {
+       case LOCATION_BOUNDARY_NONE:
+       case LOCATION_BOUNDARY_RECT:
+               ret = LOCATION_BOUNDS_RECT;
+               break;
+       case LOCATION_BOUNDARY_CIRCLE:
+               ret = LOCATION_BOUNDS_CIRCLE;
+               break;
+       case LOCATION_BOUNDARY_POLYGON:
+               ret = LOCATION_BOUNDS_POLYGON;
+               break;
+       }
+       return ret;
+}
+
+int location_bounds_create_rect(location_coords_s top_left, location_coords_s bottom_right, location_bounds_h* bounds)
+{
+       LOCATIONS_NULL_ARG_CHECK(bounds);
+       LOCATIONS_CHECK_CONDITION(top_left.latitude>=-90 && top_left.latitude<=90,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER");
+       LOCATIONS_CHECK_CONDITION(top_left.longitude>=-180 && top_left.longitude<=180,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER");
+       LOCATIONS_CHECK_CONDITION(bottom_right.latitude>=-90 && bottom_right.latitude<=90,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER");
+       LOCATIONS_CHECK_CONDITION(bottom_right.longitude>=-180 && bottom_right.longitude<=180,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER");
+
+       LocationPosition *lt = location_position_new(0, top_left.latitude, top_left.longitude, 0, LOCATION_STATUS_2D_FIX);
+       if (lt ==NULL)
+       {
+               LOGE("[%s] LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_position_new", __FUNCTION__, LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY);
+               return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY;
+       }
+
+       LocationPosition *rb = location_position_new(0, bottom_right.latitude, bottom_right.longitude, 0, LOCATION_STATUS_2D_FIX);
+       if (rb ==NULL)
+       {
+               LOGE("[%s] LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_position_new", __FUNCTION__, LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY);
+               location_position_free (lt);
+               return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY;
+       }
+
+       LocationBoundary *boundary = location_boundary_new_for_rect(lt, rb);
+       location_position_free (rb);
+       location_position_free (lt);
+
+       if(!boundary)
+       {
+               LOGE("[%s] LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_rect", __FUNCTION__, LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY);
+               return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY;
+       }
+
+       *bounds = (location_bounds_h)boundary;
+       return LOCATION_BOUNDS_ERROR_NONE;
+}
+
+int location_bounds_create_circle(location_coords_s center, double radius, location_bounds_h* bounds)
+{
+       LOCATIONS_NULL_ARG_CHECK(bounds);
+       LOCATIONS_CHECK_CONDITION(radius>=0,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER");
+       LOCATIONS_CHECK_CONDITION(center.latitude>=-90 && center.latitude<=90,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER");
+       LOCATIONS_CHECK_CONDITION(center.longitude>=-180 && center.longitude<=180,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER");
+
+       LocationPosition *ct = location_position_new(0, center.latitude, center.longitude, 0, LOCATION_STATUS_2D_FIX);
+       if (ct ==NULL)
+       {
+               LOGE("[%s] LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_position_new", __FUNCTION__, LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY);
+               return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY;
+       }
+
+       LocationBoundary *boundary = location_boundary_new_for_circle(ct,radius);
+       location_position_free (ct);
+
+       if(!boundary)
+       {
+               LOGE("[%s] LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_circle", __FUNCTION__, LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY);
+               return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY;
+       }
+
+       *bounds = (location_bounds_h)boundary;
+       return LOCATION_BOUNDS_ERROR_NONE;
+}
+
+int location_bounds_create_polygon(location_coords_s* coords_list, int length, location_bounds_h* bounds)
+{
+       LOCATIONS_NULL_ARG_CHECK(coords_list);
+       LOCATIONS_NULL_ARG_CHECK(bounds);
+       LOCATIONS_CHECK_CONDITION(length>=3,LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER");
+
+       int i;
+       GList* position_list = NULL;
+       LocationPosition *position = NULL;
+       bool isValid;
+       
+       for(i=0;i<length;i++)
+       {
+               if(coords_list[i].latitude < -90 || coords_list[i].latitude > 90 || coords_list[i].longitude < -180 || coords_list[i].longitude > 180)
+               {
+                       LOGE("[%s] LOCATION_BOUNDS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER);
+                       isValid = FALSE;
+                       break;
+               }       
+
+               position = location_position_new(0, coords_list[i].latitude, coords_list[i].longitude, 0.0, LOCATION_STATUS_2D_FIX);
+               position_list = g_list_append(position_list,position);
+               location_position_free(position);
+               isValid = TRUE;
+       }
+
+       if(!isValid)
+       {
+               g_list_free_full(position_list, (GDestroyNotify)__free_position_list);
+               return LOCATION_BOUNDS_ERROR_INVALID_PARAMETER;
+       }
+               
+       if (position_list ==NULL)
+       {
+               LOGE("[%s] LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_position_new", __FUNCTION__, LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY);
+               return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY;
+       }
+
+       LocationBoundary *boundary =  location_boundary_new_for_polygon(position_list);
+
+       if(!boundary)
+       {
+               LOGE("[%s] LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_rect", __FUNCTION__, LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY);
+               return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY;
+       }
+
+       *bounds = (location_bounds_h)boundary;
+       return LOCATION_BOUNDS_ERROR_NONE;
+}
+
+bool location_bounds_is_contains_coordinates(location_bounds_h bounds, location_coords_s coords)
+{
+       if (!bounds)
+               return FALSE;
+
+       if (coords.latitude < -90 ||  coords.latitude > 90 || coords.longitude < -180 || coords.longitude > 180)
+               return FALSE;
+
+       LocationPosition *pos = location_position_new(0, coords.latitude, coords.longitude, 0, LOCATION_STATUS_2D_FIX);
+       if (!pos)
+               return FALSE;
+
+       gboolean is_inside = location_boundary_if_inside((LocationBoundary*)bounds, pos);
+       location_position_free (pos);
+       bool result = is_inside?TRUE:FALSE;
+       return result;
+}
+
+int location_bounds_get_type(location_bounds_h bounds, location_bounds_type_e *type)
+{
+       LOCATIONS_NULL_ARG_CHECK(bounds);
+       LOCATIONS_NULL_ARG_CHECK(type); 
+       *type = __convert_bounds_type(((LocationBoundary*)bounds)->type);
+       return LOCATION_BOUNDS_ERROR_NONE;
+}
+
+int location_bounds_get_rect_coords(location_bounds_h bounds, location_coords_s  *top_left, location_coords_s  *bottom_right)
+{
+       LOCATIONS_NULL_ARG_CHECK(bounds);
+       LOCATIONS_NULL_ARG_CHECK(top_left);
+       LOCATIONS_NULL_ARG_CHECK(bottom_right);
+       if( __convert_bounds_type(((LocationBoundary*)bounds)->type) != LOCATION_BOUNDS_RECT)
+       {
+               LOGE("[%s] LOCATION_BOUNDS_ERROR_INCORRECT_TYPE(0x%08x)", __FUNCTION__, LOCATION_BOUNDS_ERROR_INCORRECT_TYPE);
+       }
+
+       top_left->latitude = ((LocationBoundary*)bounds)->rect.left_top->latitude;
+       top_left->longitude = ((LocationBoundary*)bounds)->rect.left_top->longitude;
+       bottom_right->latitude =((LocationBoundary*)bounds)->rect.right_bottom->latitude;
+       bottom_right->longitude = ((LocationBoundary*)bounds)->rect.right_bottom->longitude;
+       return LOCATION_BOUNDS_ERROR_NONE;
+}
+
+int location_bounds_get_circle_coords(location_bounds_h bounds, location_coords_s  *center, double *radius)
+{
+       LOCATIONS_NULL_ARG_CHECK(bounds);
+       LOCATIONS_NULL_ARG_CHECK(center);
+       LOCATIONS_NULL_ARG_CHECK(radius);
+       if( __convert_bounds_type(((LocationBoundary*)bounds)->type) != LOCATION_BOUNDS_CIRCLE)
+       {
+               LOGE("[%s] LOCATION_BOUNDS_ERROR_INCORRECT_TYPE(0x%08x)", __FUNCTION__, LOCATION_BOUNDS_ERROR_INCORRECT_TYPE);
+       }
+
+       center->latitude = ((LocationBoundary*)bounds)->circle.center->latitude;
+       center->longitude =((LocationBoundary*)bounds)->circle.center->longitude;
+       *radius = ((LocationBoundary*)bounds)->circle.radius;
+       return LOCATION_BOUNDS_ERROR_NONE;
+}
+
+int location_bounds_foreach_polygon_coords(location_bounds_h bounds, polygon_coords_cb callback, void *user_data)
+{
+       LOCATIONS_NULL_ARG_CHECK(bounds);
+       LOCATIONS_NULL_ARG_CHECK(callback);     
+       if( __convert_bounds_type(((LocationBoundary*)bounds)->type) != LOCATION_BOUNDS_POLYGON)
+       {
+               LOGE("[%s] LOCATION_BOUNDS_ERROR_INCORRECT_TYPE(0x%08x)", __FUNCTION__, LOCATION_BOUNDS_ERROR_INCORRECT_TYPE);
+       }
+
+       GList *list = ((LocationBoundary*)bounds)->polygon.position_list;
+       while(list)
+       {
+               LocationPosition *pos = list->data;
+               location_coords_s coords;
+               coords.latitude = pos->latitude;
+               coords.longitude = pos->longitude;
+               
+               if ( callback(coords, user_data) != TRUE )
+               {
+                       LOGI("[%s] User quit the loop ",  __FUNCTION__);
+                       break;
+               }
+               list = g_list_next(list);
+       }
+       return LOCATION_BOUNDS_ERROR_NONE;
+}
+
+int location_bounds_destroy(location_bounds_h bounds)
+{
+       LOCATIONS_NULL_ARG_CHECK(bounds);
+       location_boundary_free((LocationBoundary*)bounds);
+       return LOCATION_BOUNDS_ERROR_NONE;
+}
+
diff --git a/src/location_preference.c b/src/location_preference.c
new file mode 100644 (file)
index 0000000..64ca623
--- /dev/null
@@ -0,0 +1,368 @@
+/*
+* 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 <location_preference.h>
+#include <dlog.h>
+#include <location.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_LOCATION_PREFERENCE"
+
+/*
+* Internal Macros
+*/
+#define LOCATION_PREFERENCE_CHECK_CONDITION(condition, error, msg)  \
+    if(condition) {} else  \
+        { LOGE("[%s] %s(0x%08x)", __FUNCTION__, msg, error); return error; };
+
+#define LOCATION_PREFERENCE_NULL_ARG_CHECK(arg)  \
+    LOCATION_PREFERENCE_CHECK_CONDITION(arg != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER")
+
+#define LOCATION_PREFERENCE_PRINT_ERROR_CODE(error, msg)  \
+    LOGE("[%s] %s(0x%08x)",__FUNCTION__, msg, error); return error;
+
+#define LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service) *((LocationObject**)service)
+
+
+/*
+* Internal Implementation
+*/
+
+static int __convert_error_code(int code, char* func_name)
+{
+       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;       
+       }
+       LOGE("[%s] %s(0x%08x)", func_name, msg, ret);
+       return ret;     
+}
+
+
+/*
+* Public Implementation
+*/
+int location_preference_foreach_available_property_keys(location_service_h service, location_preference_available_property_key_cb callback, void* user_data)
+{
+    LocationObject* 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_get_map_provider_capability_key(object, MAP_SERVICE_PREF_PROPERTY, &keys);
+    if(ret != LOCATION_ERROR_NONE)
+    {
+        return __convert_error_code(ret, (char*)__FUNCTION__);
+    }
+    else
+    {
+        while(keys) {
+            key = keys->data;
+            if(!callback(key, user_data))
+                break;
+            keys = keys->next;
+        }
+
+        return LOCATION_PREFERENCE_ERROR_NONE;
+    }
+}
+
+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;
+}
+
+int location_preference_foreach_available_languages(location_service_h service, location_preference_available_language_cb callback, void* user_data)
+{
+    LocationObject* 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_get_map_provider_capability_key(object, MAP_SERVICE_PREF_LANGUAGE, &keys);
+    if(ret != LOCATION_ERROR_NONE)
+    {
+        return __convert_error_code(ret, (char*)__FUNCTION__);
+    }
+    else
+    {
+        while(keys) {
+            key = keys->data;
+            if(!callback(key, user_data))
+                break;
+            keys = keys->next;
+        }
+
+        return LOCATION_PREFERENCE_ERROR_NONE;
+    }
+}
+
+
+int location_preference_foreach_properties(location_service_h service, location_preference_property_cb callback, void* user_data)
+{
+    LocationPreference* pref = NULL;
+    LocationObject* 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_get_map_service_pref(object);
+    LOCATION_PREFERENCE_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER");
+
+    keys = location_pref_get_property_key(pref);
+    while(keys) {
+        key = keys->data;
+        value = (char*)location_pref_get_property(pref, key);
+        if(!callback(key, value, user_data))
+               break;
+        keys = keys->next;
+    }
+
+    location_pref_free(pref);
+    return LOCATION_PREFERENCE_ERROR_NONE;
+}
+
+int location_preference_set(location_service_h service, const char* key, const char* value)
+{
+    LocationPreference* pref = NULL;
+    LocationObject* 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_get_map_service_pref(object);
+    LOCATION_PREFERENCE_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER");
+
+    location_pref_set_property(pref, (gconstpointer)key, (gconstpointer)value);
+    location_set_map_service_pref(object, pref);
+    location_pref_free(pref);
+
+    return LOCATION_PREFERENCE_ERROR_NONE;
+}
+
+int location_preference_get(location_service_h service, const char* key, char** value)
+{
+    LocationPreference* pref = NULL;
+    LocationObject* 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_get_map_service_pref(object);
+    LOCATION_PREFERENCE_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER");
+
+    ret = (char*)location_pref_get_property(pref, (gconstpointer)key);
+    if(ret != NULL)
+    {
+        *value = strdup(ret);
+        location_pref_free(pref);
+        return LOCATION_PREFERENCE_ERROR_NONE;
+    }
+    else
+    {
+        *value = NULL;
+        location_pref_free(pref);
+        LOCATION_PREFERENCE_PRINT_ERROR_CODE(LOCATION_PREFERENCE_ERROR_INVALID_KEY, "LOCATION_PREFERENCE_ERROR_INVALID_KEY");
+    }
+}
+
+int location_preference_get_provider_name(location_service_h service, char** provider)
+{
+    LocationPreference* pref = NULL;
+    LocationObject* 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_get_map_service_pref(object);
+    LOCATION_PREFERENCE_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER");
+
+    ret = location_pref_get_provider_name(pref);
+    if(ret != NULL)
+        *provider = strdup(ret);
+    else
+        *provider = NULL;
+
+    location_pref_free(pref);
+    return LOCATION_PREFERENCE_ERROR_NONE;
+}
+
+int location_preference_get_distance_unit(location_service_h service, location_preference_distance_unit_e* unit)
+{
+    LocationPreference* pref = NULL;
+    LocationObject* 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_get_map_service_pref(object);
+    LOCATION_PREFERENCE_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER");
+
+    ret = location_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_pref_free(pref);
+        return LOCATION_PREFERENCE_ERROR_NONE;
+    }
+    else
+    {
+        location_pref_free(pref);
+        LOCATION_PREFERENCE_PRINT_ERROR_CODE(LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND, "LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND");
+    }
+}
+
+int location_preference_set_distance_unit(location_service_h service, location_preference_distance_unit_e unit)
+{
+    LocationPreference* pref = NULL;
+    LocationObject* 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 :
+            LOCATION_PREFERENCE_PRINT_ERROR_CODE(LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER");
+    }
+
+    object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service);
+    pref = location_get_map_service_pref(object);
+    LOCATION_PREFERENCE_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER");
+
+    location_pref_set_distance_unit(pref, distance);
+    location_set_map_service_pref(object, pref);
+    location_pref_free(pref);
+
+    return LOCATION_PREFERENCE_ERROR_NONE;
+}
+
+int location_preference_get_language(location_service_h service, char** language)
+{
+    LocationPreference* pref = NULL;
+    LocationObject* 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_get_map_service_pref(object);
+    LOCATION_PREFERENCE_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER");
+
+    ret = location_pref_get_language(pref);
+    if(ret != NULL)
+        *language = strdup(ret);
+    else
+        *language = NULL;
+
+    location_pref_free(pref);
+    return LOCATION_PREFERENCE_ERROR_NONE;
+}
+
+int location_preference_set_language(location_service_h service, const char* language)
+{
+    LocationPreference* pref = NULL;
+    LocationObject* object = NULL;
+
+    LOCATION_PREFERENCE_NULL_ARG_CHECK(service);
+    LOCATION_PREFERENCE_NULL_ARG_CHECK(language);
+
+    object = LOCATION_PREFERENCE_GET_LOCATION_OBJECT(service);
+    pref = location_get_map_service_pref(object);
+    LOCATION_PREFERENCE_CHECK_CONDITION(pref != NULL, LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER, "LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER");
+
+    location_pref_set_language(pref, language);
+    location_set_map_service_pref(object, pref);
+    location_pref_free(pref);
+
+    return LOCATION_PREFERENCE_ERROR_NONE;
+}
+
+
index c9762c6..7667808 100644 (file)
                { 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")
-
+       LOCATIONS_CHECK_CONDITION(arg != NULL,LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER") \
 
 /*
 * Internal Implementation
 */
 
-static int __convert_error_code(int code,char *func_name)
+static 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:
-               case LOCATION_ERROR_NETWORK_NOT_CONNECTED:
-                       ret = LOCATIONS_ERROR_NETWORK_FAILED;
-                       msg = "LOCATIONS_ERROR_NETWORK_FAILED";
-                       break;
-               case LOCATION_ERROR_NOT_ALLOWED:
-                       ret = LOCATIONS_ERROR_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;     
-}
-
-static 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]);
-       }
-}
-
-static 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]);
-       }
-}
-
-static 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]);
-}
-
-static 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]); 
-       }
-}
-
-static 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]); 
-       }
-}
-
-static int __set_callback(_location_event_e type, location_manager_h manager, void* callback, void *user_data)
+       char *msg = "LOCATIONS_ERROR_NONE";
+       switch (code) {
+       case LOCATION_ERROR_NONE:
+               ret = LOCATIONS_ERROR_NONE;
+               msg = "LOCATIONS_ERROR_NONE";
+               break;
+       case LOCATION_ERROR_NETWORK_FAILED:
+       case LOCATION_ERROR_NETWORK_NOT_CONNECTED:
+               ret = LOCATIONS_ERROR_NETWORK_FAILED;
+               msg = "LOCATIONS_ERROR_NETWORK_FAILED";
+               break;
+       case LOCATION_ERROR_NOT_ALLOWED:
+               ret = LOCATIONS_ERROR_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;
+}
+
+static 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]);
+       }
+}
+
+static 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]);
+       }
+}
+
+static 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]);
+}
+
+static 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]);
+       }
+}
+
+static 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]);
+       }
+}
+
+static int __set_callback(_location_event_e type, location_manager_h manager, void *callback, void *user_data)
 {
        LOCATIONS_NULL_ARG_CHECK(manager);
        LOCATIONS_NULL_ARG_CHECK(callback);
-       location_manager_s * handle = (location_manager_s *) manager; 
+       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; 
+       LOGI("[%s] event type : %d. ", __FUNCTION__, type);
+       return LOCATIONS_ERROR_NONE;
 }
 
 static int __unset_callback(_location_event_e type, location_manager_h manager)
 {
        LOCATIONS_NULL_ARG_CHECK(manager);
-       location_manager_s * handle = (location_manager_s *) manager; 
+       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; 
+       LOGI("[%s] event type : %d. ", __FUNCTION__, type);
+       return LOCATIONS_ERROR_NONE;
 }
 
-static 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);
+static void __foreach_boundary(LocationBoundary * boundary, void *user_data)
+{
+       location_manager_s *handle = (location_manager_s *) user_data;
+
+       if (handle != NULL && boundary != NULL) {
+               int ret = -1;
+               location_bounds_h bounds;
+               if (boundary->type == LOCATION_BOUNDARY_CIRCLE) {
+                       location_coords_s center;
+                       center.latitude = boundary->circle.center->latitude;
+                       center.longitude = boundary->circle.center->longitude;
+                       ret = location_bounds_create_circle(center, boundary->circle.radius, &bounds);
+               } else if (boundary->type == LOCATION_BOUNDARY_RECT) {
+                       location_coords_s left_top;
+                       location_coords_s right_bottom;
+                       left_top.latitude = boundary->rect.left_top->latitude;
+                       left_top.longitude = boundary->rect.left_top->longitude;
+                       right_bottom.latitude = boundary->rect.right_bottom->latitude;
+                       right_bottom.longitude = boundary->rect.right_bottom->longitude;
+                       ret = location_bounds_create_rect(left_top, right_bottom, &bounds);
+               } else if (boundary->type == LOCATION_BOUNDARY_POLYGON) {
+                       GList *list = boundary->polygon.position_list;
+                       int size = g_list_length(list);
+                       if (size > 0) {
+                               location_coords_s coords[size];
+                               int cnt = 0;
+                               while (list) {
+                                       LocationPosition *pos = list->data;
+                                       coords[cnt].latitude = pos->latitude;
+                                       coords[cnt].longitude = pos->longitude;
+                                       list = g_list_next(list);
+                                       cnt++;
+                               }
+                               ret = location_bounds_create_polygon(coords, size, &bounds);
+                       }
+               } else {
+                       LOGI("[%s] Invalid boundary type : %d", __FUNCTION__, boundary->type);
                }
-               else
-               {
-                       LOGI("[%s] Delete previous boundary - type : %d ",__FUNCTION__, boundary->type);
+
+               if (ret != LOCATIONS_ERROR_NONE) {
+                       LOGI("[%s] Failed to create location_bounds : (0x%08x) ", __FUNCTION__, ret);
+               } 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_destroy(bounds);
                }
+       } else {
+               LOGI("[%s]  __foreach_boundary() has been failed", __FUNCTION__);
        }
 }
 
@@ -176,307 +228,194 @@ static void  __remove_boundary(LocationBoundary *boundary, void *user_data)
 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_SPS :
-                       _method = LOCATION_METHOD_SPS;
-                       break;
-               default :
-                       _method = LOCATION_METHOD_NONE;
-                       break;
-               }
+       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_SPS:
+               _method = LOCATION_METHOD_SPS;
+               break;
+       default:
+               _method = LOCATION_METHOD_NONE;
+               break;
+       }
        return location_is_supported_method(_method);
 }
 
-int    location_manager_create(location_method_e method, location_manager_h* manager)
+int location_manager_create(location_method_e method, location_manager_h * manager)
 {
        LOCATIONS_NULL_ARG_CHECK(manager);
-       if(location_init()!=LOCATION_ERROR_NONE)
+       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 :
+       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);
+                       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)
-       {
+       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));
-       
+       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);
+       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;
+       handle->is_continue_foreach_bounds = TRUE;
+       *manager = (location_manager_h) handle;
        return LOCATIONS_ERROR_NONE;
 }
 
-int    location_manager_destroy(location_manager_h manager)
+int location_manager_destroy(location_manager_h manager)
 {
        LOCATIONS_NULL_ARG_CHECK(manager);
-       location_manager_s *handle = (location_manager_s*)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__);
+       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)
+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__);
+       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)
+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__);
+       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)
+int location_manager_add_boundary(location_manager_h manager, const location_bounds_h bounds)
 {
        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);
-       }
+       LOCATIONS_NULL_ARG_CHECK(bounds);
 
-       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;
-       }
+       location_manager_s *handle = (location_manager_s *) manager;
+       int ret = location_boundary_add(handle->object,(LocationBoundary*)bounds);
 
-       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;
+       if (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
        }
        return LOCATIONS_ERROR_NONE;
 }
 
-int    location_manager_set_boundary_circle(location_manager_h manager, double center_latitude,double center_longitude, double radius)
+int location_manager_remove_boundary(location_manager_h manager, const location_bounds_h bounds)
 {
        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;      
+       LOCATIONS_NULL_ARG_CHECK(bounds);
 
-       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);
-       }
+       location_manager_s *handle = (location_manager_s *) manager;
+       int ret = location_boundary_remove(handle->object, (LocationBoundary*)bounds);
 
-       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;
+       if (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
        }
        return LOCATIONS_ERROR_NONE;
 }
 
-int location_manager_is_boundary_contains_coordinate(location_manager_h manager, double latitude, double longitude, bool *contained)
+int location_manager_foreach_boundary(location_manager_h manager, location_bounds_cb callback, void *user_data)
 {
        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;
-       }
+       LOCATIONS_NULL_ARG_CHECK(callback);
 
-       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_manager_s *handle = (location_manager_s *) manager;
+       handle->user_cb[_LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS] = callback;
+       handle->user_data[_LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS] = user_data;
+       handle->is_continue_foreach_bounds = TRUE;
+       int ret = location_boundary_foreach(handle->object, __foreach_boundary, handle);
+       if (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
        }
-       location_position_free (pos);
        return LOCATIONS_ERROR_NONE;
 }
 
-int    location_manager_get_method(location_manager_h manager, location_method_e* method)
+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;  
+       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 :
+       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);
+                       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;
                }
        }
@@ -484,8 +423,8 @@ int location_manager_get_method(location_manager_h manager, location_method_e* m
        return LOCATIONS_ERROR_NONE;
 }
 
-
-int    location_manager_get_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, time_t *timestamp)
+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);
@@ -493,42 +432,35 @@ int       location_manager_get_position(location_manager_h manager, double *altitude,
        LOCATIONS_NULL_ARG_CHECK(longitude);
        LOCATIONS_NULL_ARG_CHECK(timestamp);
 
-       location_manager_s *handle = (location_manager_s*)manager;
+       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 (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
        }
 
-       if(pos->status == LOCATION_STATUS_NO_FIX)
-       {
+       if (pos->status == LOCATION_STATUS_NO_FIX) {
                *altitude = -1;
                *latitude = -1;
-               *longitude =-1;
-       }
-       else
-       {
-               if(pos->status == LOCATION_STATUS_3D_FIX)
-               {
+               *longitude = -1;
+       } else {
+               if (pos->status == LOCATION_STATUS_3D_FIX) {
                        *altitude = pos->altitude;
-               }
-               else
-               {
+               } else {
                        *altitude = -1;
                }
                *latitude = pos->latitude;
                *longitude = pos->longitude;
        }
        *timestamp = pos->timestamp;
-       location_position_free (pos);
-       location_accuracy_free (acc);
+       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)
+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);
@@ -536,14 +468,13 @@ int       location_manager_get_velocity(location_manager_h manager, int *climb, int *d
        LOCATIONS_NULL_ARG_CHECK(speed);
        LOCATIONS_NULL_ARG_CHECK(timestamp);
 
-       location_manager_s *handle = (location_manager_s*)manager;
+       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__);
+       if (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
        }
 
        *climb = vel->climb;
@@ -555,32 +486,33 @@ int       location_manager_get_velocity(location_manager_h manager, int *climb, int *d
        return LOCATIONS_ERROR_NONE;
 }
 
-int    location_manager_get_accuracy(location_manager_h manager, location_accuracy_level_e *level, double *horizontal, double *vertical)
+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;
+       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 (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
        }
-       
+
        *level = acc->level;
-       *horizontal = acc->horizontal_accuracy; 
+       *horizontal = acc->horizontal_accuracy;
        *vertical = acc->vertical_accuracy;
        location_position_free(pos);
        location_accuracy_free(acc);
-       return LOCATIONS_ERROR_NONE;                    
+       return LOCATIONS_ERROR_NONE;
 }
 
-int location_manager_get_last_known_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, time_t *timestamp)
+int location_manager_get_last_position(location_manager_h manager, double *altitude, double *latitude, double *longitude,
+                                      time_t * timestamp)
 {
        LOCATIONS_NULL_ARG_CHECK(manager);
        LOCATIONS_NULL_ARG_CHECK(altitude);
@@ -588,235 +520,342 @@ int location_manager_get_last_known_position(location_manager_h manager, double
        LOCATIONS_NULL_ARG_CHECK(longitude);
        LOCATIONS_NULL_ARG_CHECK(timestamp);
 
-       location_manager_s *handle = (location_manager_s*)manager;
+       location_manager_s *handle = (location_manager_s *) manager;
 
-       LocationMethod _method = LOCATION_METHOD_NONE;  
-       g_object_get(handle->object, "method", &_method, NULL);
-       
        int ret;
-       LocationPosition *pos = NULL;
-       LocationAccuracy *acc = NULL;
-       ret = location_get_last_position(handle->object, _method, &pos,&acc);
-       if (ret == LOCATION_ERROR_UNKNOWN)
-       {
-               *altitude = 0;
-               *latitude = 0;
-               *longitude =0;
-               *timestamp = 0;
-               LOGI("[%s] There is no record of any previous position information. ",__FUNCTION__);
-               return LOCATIONS_ERROR_NONE;
-       }       
-       else if( ret != LOCATION_ERROR_NONE)
-       {
-               return __convert_error_code(ret,(char*)__FUNCTION__);
-       }
-       
-       *altitude = pos->altitude;
-       *latitude = pos->latitude;
-       *longitude = pos->longitude;
-       *timestamp = pos->timestamp;
-       location_position_free(pos);
-       location_accuracy_free(acc);
+       LocationPosition *last_pos = NULL;
+       LocationAccuracy *last_acc = NULL;
+       ret = location_get_last_position(handle->object, &last_pos, &last_acc);
+       if (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       }
+
+       if (last_pos->status == LOCATION_STATUS_NO_FIX) {
+               *altitude = -1;
+               *latitude = -1;
+               *longitude = -1;
+       } else {
+               if (last_pos->status == LOCATION_STATUS_3D_FIX) {
+                       *altitude = last_pos->altitude;
+               } else {
+                       *altitude = -1;
+               }
+               *latitude = last_pos->latitude;
+               *longitude = last_pos->longitude;
+       }
+       *timestamp = last_pos->timestamp;
+       location_position_free(last_pos);
+       location_accuracy_free(last_acc);
        return LOCATIONS_ERROR_NONE;
 }
 
-int    location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, int interval, void *user_data)
+int location_manager_get_last_velocity(location_manager_h manager, int *climb, int *direction, int *speed, time_t * timestamp)
 {
-       LOCATIONS_CHECK_CONDITION(interval>=1 && interval<=120, LOCATIONS_ERROR_INVALID_PARAMETER,"LOCATIONS_ERROR_INVALID_PARAMETER");
        LOCATIONS_NULL_ARG_CHECK(manager);
-       location_manager_s *handle = (location_manager_s*)manager;
+       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 *last_vel = NULL;
+       LocationAccuracy *last_acc = NULL;
+       ret = location_get_last_velocity(handle->object, &last_vel, &last_acc);
+       if (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       }
+
+       *climb = last_vel->climb;
+       *direction = last_vel->direction;
+       *speed = last_vel->speed;
+       *timestamp = last_vel->timestamp;
+       location_velocity_free(last_vel);
+       location_accuracy_free(last_acc);
+       return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_get_last_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 *last_pos = NULL;
+       LocationAccuracy *last_acc = NULL;
+       ret = location_get_last_position(handle->object, &last_pos, &last_acc);
+       if (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       }
+
+       *level = last_acc->level;
+       *horizontal = last_acc->horizontal_accuracy;
+       *vertical = last_acc->vertical_accuracy;
+       location_position_free(last_pos);
+       location_accuracy_free(last_acc);
+       return LOCATIONS_ERROR_NONE;
+}
+
+int location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, int interval,
+                                            void *user_data)
+{
+       LOCATIONS_CHECK_CONDITION(interval >= 1
+                                 && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
+       LOCATIONS_NULL_ARG_CHECK(manager);
+       location_manager_s *handle = (location_manager_s *) manager;
        g_object_set(handle->object, "update-interval", interval, NULL);
-       return __set_callback(_LOCATIONS_EVENT_TYPE_POSITION,manager,callback,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_unset_position_updated_cb(location_manager_h manager)
+int location_manager_set_velocity_updated_cb(location_manager_h manager, location_velocity_updated_cb callback, void *user_data)
 {
-       return __unset_callback(_LOCATIONS_EVENT_TYPE_POSITION,manager);
+       return __set_callback(_LOCATIONS_EVENT_TYPE_VELOCITY, manager, callback, user_data);
 }
 
-int    location_manager_set_velocity_updated_cb(location_manager_h manager, location_velocity_updated_cb callback, void *user_data)
+int location_manager_unset_velocity_updated_cb(location_manager_h manager)
 {
-       return __set_callback(_LOCATIONS_EVENT_TYPE_VELOCITY,manager,callback,user_data);
+       return __unset_callback(_LOCATIONS_EVENT_TYPE_VELOCITY, manager);
 }
 
-int    location_manager_unset_velocity_updated_cb(location_manager_h manager)
+int location_manager_set_service_state_changed_cb(location_manager_h manager, location_service_state_changed_cb callback,
+                                                 void *user_data)
 {
-       return __unset_callback(_LOCATIONS_EVENT_TYPE_VELOCITY,manager);
+       return __set_callback(_LOCATIONS_EVENT_TYPE_SERVICE_STATE, manager, callback, user_data);
 }
 
-int    location_manager_set_service_state_changed_cb(location_manager_h manager, location_service_state_changed_cb callback, void *user_data)
+int location_manager_unset_service_state_changed_cb(location_manager_h manager)
 {
-       return __set_callback(_LOCATIONS_EVENT_TYPE_SERVICE_STATE,manager,callback,user_data);
+       return __unset_callback(_LOCATIONS_EVENT_TYPE_SERVICE_STATE, manager);
 }
 
-int    location_manager_unset_service_state_changed_cb(location_manager_h manager)
+int location_manager_set_zone_changed_cb(location_manager_h manager, location_zone_changed_cb callback, void *user_data)
 {
-       return __unset_callback(_LOCATIONS_EVENT_TYPE_SERVICE_STATE,manager);
+       return __set_callback(_LOCATIONS_EVENT_TYPE_BOUNDARY, manager, callback, user_data);
 }
 
-int    location_manager_set_zone_changed_cb(location_manager_h manager, location_zone_changed_cb callback, void *user_data)
+int location_manager_unset_zone_changed_cb(location_manager_h manager)
 {
-       return __set_callback(_LOCATIONS_EVENT_TYPE_BOUNDARY,manager,callback,user_data);
+       return __unset_callback(_LOCATIONS_EVENT_TYPE_BOUNDARY, manager);
 }
 
-int    location_manager_unset_zone_changed_cb(location_manager_h manager)
+int location_manager_send_command(const char *cmd)
 {
-       return __unset_callback(_LOCATIONS_EVENT_TYPE_BOUNDARY,manager);
+       LOCATIONS_NULL_ARG_CHECK(cmd);
+
+       int ret;
+       ret = location_send_command(cmd);
+       if (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
+       }
+
+       return LOCATIONS_ERROR_NONE;
 }
 
 /////////////////////////////////////////
 // GPS Status & Satellites
 ////////////////////////////////////////
 
-int    gps_status_get_nmea(location_manager_h manager, char** nmea)
+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;
+       location_manager_s *handle = (location_manager_s *) manager;
 
-       if(handle->method == LOCATIONS_METHOD_HYBRID)
-       {
-               LocationMethod _method = LOCATION_METHOD_NONE;  
+       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);
+               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);
+               }
+       } 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;
        }
-       gcharnmea_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);
+       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);
+       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)
+int gps_status_get_satellite(location_manager_h manager, int *num_of_active, int *num_of_inview, time_t *timestamp)
 {
        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;  
+       LOCATIONS_NULL_ARG_CHECK(num_of_active);
+       LOCATIONS_NULL_ARG_CHECK(num_of_inview);
+       LOCATIONS_NULL_ARG_CHECK(timestamp);
+       location_manager_s *handle = (location_manager_s *) manager;
+       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);
+               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);
+               }
+       } 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);
+       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);
+
+       *num_of_active = sat->num_of_sat_used;
+       *num_of_inview = sat->num_of_sat_inview;
+       *timestamp = sat->timestamp;
+       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)
+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;  
+       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);
+               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);
+               }
+       } 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);
+       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++) 
-       {
+       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 )
+               if (callback(azimuth, elevation, prn, snr, used, user_data) != TRUE)
                        break;
        }
-       location_satellite_free (sat);  
+       location_satellite_free(sat);
        sat = NULL;
        return LOCATIONS_ERROR_NONE;
 }
 
-int  gps_status_get_active_satellite_count(location_manager_h manager, int *count)
+int gps_status_get_last_satellite(location_manager_h manager, int *num_of_active, int *num_of_inview, time_t *timestamp)
 {
        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;  
+       LOCATIONS_NULL_ARG_CHECK(num_of_active);
+       LOCATIONS_NULL_ARG_CHECK(num_of_inview);
+       LOCATIONS_NULL_ARG_CHECK(timestamp);
+       location_manager_s *handle = (location_manager_s *) manager;
+       int ret;
+       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);
+               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 *last_sat = NULL;
+       ret = location_get_last_satellite(handle->object, &last_sat);
+       if (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
        }
-       else if(handle->method != LOCATIONS_METHOD_GPS)
-       {
-               LOGE("[%s] LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", __FUNCTION__, LOCATIONS_ERROR_INCORRECT_METHOD, handle->method);
+
+       *num_of_active = last_sat->num_of_sat_used;
+       *num_of_inview = last_sat->num_of_sat_inview;
+       *timestamp = last_sat->timestamp;
+       location_satellite_free(last_sat);
+       return LOCATIONS_ERROR_NONE;
+}
+
+int gps_status_foreach_last_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;
+       int ret;
+       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;
+
+       LocationSatellite *last_sat = NULL;
+       ret = location_get_last_satellite(handle->object, &last_sat);
+       if (ret != LOCATION_ERROR_NONE) {
+               return __convert_error_code(ret, (char *)__FUNCTION__);
        }
-       *count = sat->num_of_sat_used;
-       location_satellite_free (sat);
-       sat = NULL;
+
+       int i;
+       for (i = 0; i < last_sat->num_of_sat_inview; i++) {
+               guint prn;
+               gboolean used;
+               guint elevation;
+               guint azimuth;
+               gint snr;
+               location_satellite_get_satellite_details(last_sat, i, &prn, &used, &elevation, &azimuth, &snr);
+               if (callback(azimuth, elevation, prn, snr, used, user_data) != TRUE) {
+                       break;
+               }
+       }
+       location_satellite_free(last_sat);
        return LOCATIONS_ERROR_NONE;
 }
index cdf73c9..995338b 100755 (executable)
 
 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)
+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));
+       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 bool  satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use, void *user_data)
+static bool last_satellites_foreach_cb(unsigned int azimuth, unsigned int elevation, unsigned int prn, int snr, bool is_in_use,
+                                      void *user_data)
 {
-       printf("[Satellite information]  azimuth  : %d, elevation : %d, prn :%d, snr : %d, used: %d\n",azimuth, elevation, prn, snr, is_in_use);
+       printf("[Last Satellite information]  azimuth  : %d, elevation : %d, prn :%d, snr : %d, used: %d\n", azimuth, elevation,
+              prn, snr, is_in_use);
        return true;
 }
 
 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)
-       {
+       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);
+               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("[%ld] alt: %g, lat %g, long %g\n", timestamp, 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);
+               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);
+               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);
+               int num_of_view, num_of_active;
+               ret = gps_status_get_satellite(lm, &num_of_active, &num_of_view, &timestamp);
+               if (ret != LOCATIONS_ERROR_NONE) {
+                       printf(" Fail : gps_status_get_satellite_count_in_view ---> %d \n", ret);
+               } else {
+                       printf("[%ld] Satellite number of active : %d, in view : %d\n", timestamp, num_of_active, num_of_view);
                }
-       
-               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);
                }
+       }
+}
 
-               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);
+static bool __poly_coords_cb(location_coords_s coords, void *user_data)
+{
+       printf("location_bounds_foreach_rect_coords(latitude : %lf, longitude: %lf) \n", coords.latitude, coords.longitude);
+       return TRUE;
+}
+
+static bool __location_bounds_cb(location_bounds_h bounds, void *user_data)
+{
+       if (bounds == NULL)
+               printf("bounds ==NULL\n");
+       else {
+               location_bounds_type_e type;
+               location_bounds_get_type(bounds, &type);
+               if (type == LOCATION_BOUNDS_CIRCLE) {
+                       location_coords_s center;
+                       double radius;
+                       location_bounds_get_circle_coords(bounds, &center, &radius);
+                       printf("location_bounds_get_circle_coords(center : %lf, %lf, radius : %lf) \n", center.latitude,
+                              center.longitude, radius);
+
+               } else if (type == LOCATION_BOUNDS_RECT) {
+                       location_coords_s left_top;
+                       location_coords_s right_bottom;
+                       location_bounds_get_rect_coords(bounds, &left_top, &right_bottom);
+                       printf("location_bounds_get_rect_coords(left_top : %lf, %lf - right_bottom : %lf, %lf) \n",
+                              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);
                }
-               
        }
+       return TRUE;
 }
 
-int location_test()
+void location_bounds_test()
 {
-       int ret ;
-       ret=  location_manager_create(LOCATIONS_METHOD_GPS,&manager);
-       printf("create : %d\n",ret);
+       int ret;
+       location_coords_s center;
+       center.latitude = 37.258;
+       center.longitude = 127.056;
+       double radius = 30;
+       location_bounds_h bounds_circle;
+       ret = location_bounds_create_circle(center, radius, &bounds_circle);
+       if (ret != LOCATION_BOUNDS_ERROR_NONE) {
+               printf("location_bounds_create_circle() failed\n");
+       } else
+               printf("Bounds(circle) has been created successfully.\n");
+
+       ret = location_manager_add_boundary(manager, bounds_circle);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf("Setting boundary failed\n");
+       } else
+               printf("Boundary set\n");
+
+       location_coords_s center2;
+       double radius2;
+       ret = location_bounds_get_circle_coords(bounds_circle, &center2, &radius2);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf("location_bounds_get_circle_coords() failed\n");
+       } else
+               printf("location_bounds_get_circle_coords(center : %lf, %lf, radius : %lf) \n", center2.latitude,
+                      center2.longitude, radius2);
 
+       //Add the rect bounds
+       location_coords_s left_top;
+       left_top.latitude = 30;
+       left_top.longitude = 30;
 
-       double center_latitude = 37.258;
-    double center_longitude = 127.056;
-    double radius = 30;
+       location_coords_s right_bottom;
+       right_bottom.latitude = 10;
+       right_bottom.longitude = 50;
 
-    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");
+       location_bounds_h bounds_rect;
+       ret = location_bounds_create_rect(left_top, right_bottom, &bounds_rect);
+       if (ret != LOCATION_BOUNDS_ERROR_NONE) {
+               printf("location_bounds_create_rect() failed\n");
+       } else
+               printf("Bounds(rect) has been created successfully.\n");
 
-       ret = location_manager_set_zone_changed_cb(manager, zone_event_cb, (void*)manager);
-       printf("set zone callback : %d\n",ret);         
-       
+       ret = location_manager_add_boundary(manager, bounds_rect);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf("Setting boundary failed\n");
+       } else
+               printf("Boundary set\n");
 
-       ret = location_manager_set_service_state_changed_cb(manager, _state_change_cb, (void*)manager);
-       printf("set state callback : %d\n",ret);        
+       location_coords_s left_top2;
+       location_coords_s right_bottom2;
+
+       ret = location_bounds_get_rect_coords(bounds_rect, &left_top2, &right_bottom2);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf("location_bounds_get_rect_coords() failed\n");
+       } else
+               printf("location_bounds_get_rect_coords(left_top : %lf, %lf - right_bottom : %lf, %lf) \n", left_top2.latitude,
+                      left_top2.longitude, right_bottom2.latitude, right_bottom2.longitude);
+
+       //Add the polygon bounds
+
+       int poly_size = 3;
+       location_coords_s coord_list[poly_size];
+
+       coord_list[0].latitude = 10;
+       coord_list[0].longitude = 10;
+       coord_list[1].latitude = 20;
+       coord_list[1].longitude = 20;
+       coord_list[2].latitude = 30;
+       coord_list[2].longitude = 30;
+
+       location_bounds_h bounds_poly;
+       ret = location_bounds_create_polygon(coord_list, poly_size, &bounds_poly);
+       if (ret != LOCATION_BOUNDS_ERROR_NONE) {
+               printf("location_bounds_create_polygon() failed\n");
+       } else
+               printf("Bounds(polygon) has been created successfully.\n");
+
+       ret = location_manager_add_boundary(manager, bounds_poly);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf("Setting boundary failed\n");
+       } else
+               printf("Boundary set\n");
+
+       ret = location_bounds_foreach_polygon_coords(bounds_poly, __poly_coords_cb, NULL);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf("location_bounds_get_rect_coords() failed\n");
+       }
+
+       location_coords_s test_coords;
+       test_coords.latitude = 12;
+       test_coords.longitude = 12;
+
+       if (location_bounds_is_contains_coordinates(bounds_poly, test_coords))
+               printf("location_bounds_is_contains_coordinates() retrun TRUE \n");
+       else
+               printf("location_bounds_is_contains_coordinates() retrun FALSE \n");
+
+       //print current bounds
+       ret = location_manager_foreach_boundary(manager, __location_bounds_cb, (void *)manager);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf("location_manager_foreach_boundary() failed\n");
+       }
+
+}
+
+void location_get_last_information_test()
+{
+       int ret;
+       double altitude, latitude, longitude;
+       int climb, direction, speed;
+       double horizontal, vertical;
+       location_accuracy_level_e level;
+       time_t timestamp;
+       int num_of_inview, num_of_active;
+
+       ret = location_manager_get_last_position(manager, &altitude, &latitude, &longitude, &timestamp);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf(" Fail : location_manager_get_last_position ---> %d \n", ret);
+       } else {
+               printf("[%ld] alt: %g, lat: %g, long: %g\n", timestamp, altitude, latitude, longitude);
+       }
+
+       ret = location_manager_get_last_velocity(manager, &climb, &direction, &speed, &timestamp);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf(" Fail : location_manager_get_last_velocity ---> %d \n", ret);
+       } else {
+               printf("climb: %d, direction: %d, speed: %d\n", climb, direction, speed);
+       }
+
+       ret = location_manager_get_last_accuracy(manager, &level, &horizontal, &vertical);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf(" Fail : location_manager_get_last_accuracy ---> %d \n", ret);
+       } else {
+               printf("Level : %d, horizontal: %g, vertical : %g\n", level, horizontal, vertical);
+       }
+
+       ret = gps_status_get_last_satellite(manager, &num_of_active, &num_of_inview, &timestamp);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf(" Fail : gps_status_get_last_satellite_count_in_view ---> %d \n", ret);
+       } else {
+               printf("[%ld] Satellite number of active : %d, in view : %d\n", timestamp, num_of_active, num_of_inview);
+       }
+
+       ret = gps_status_foreach_last_satellites_in_view(manager, last_satellites_foreach_cb, NULL);
+       if (ret != LOCATIONS_ERROR_NONE) {
+               printf(" Fail : gps_status_foreach_last_satellites_in_view ---> %d \n", ret);
+       }
+}
+
+int location_test()
+{
+       int ret;
+       ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager);
+       printf("create : %d\n", ret);
+
+       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_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);    
+       printf("start :  %d\n", ret);
        return 1;
 }
 
 static GMainLoop *g_mainloop = NULL;
 
-static gboolean exit_program (gpointer data)
+static gboolean exit_program(gpointer data)
 {
-       if(manager==NULL)
-       {
-               printf("manager == NULL \n");   
+       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);
        }
-       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);
+       g_main_loop_quit(g_mainloop);
        printf("Quit g_main_loop\n");
        return FALSE;
 }
 
-
-int main(int argc, char ** argv)
+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_mainloop = g_main_loop_new(NULL, 0);
+       location_test();
        g_timeout_add_seconds(90, exit_program, NULL);
-       g_main_loop_run (g_mainloop);
+       g_main_loop_run(g_mainloop);
        return 0;
 }
-