summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangho Hur <kangho.hur@samsung.com>2012-02-10 15:40:36 +0900
committerKangho Hur <kangho.hur@samsung.com>2012-02-10 15:40:36 +0900
commit7b3e5b52906bfd248b1b5b7e2fc6f1401d87f3c0 (patch)
treedc3cdafda0a52bf53788d6e4cef53e0b18491301
parentd9303afdffcb455a1dd83676998528a6359df885 (diff)
downloadlocation-manager-7b3e5b52906bfd248b1b5b7e2fc6f1401d87f3c0.tar.gz
location-manager-7b3e5b52906bfd248b1b5b7e2fc6f1401d87f3c0.tar.bz2
location-manager-7b3e5b52906bfd248b1b5b7e2fc6f1401d87f3c0.zip
Support to location_manager_get_last_known_position(), location_manager_is_supported_method(), and interval setting.
-rw-r--r--debian/changelog6
-rw-r--r--[-rwxr-xr-x]include/locations.h36
-rw-r--r--src/locations.c68
3 files changed, 105 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog
index 652c976..79789cb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+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.
+
+ -- Kangho Hur <kangho.hur@samsung.com> Fri, 10 Feb 2012 15:40:01 +0900
+
capi-location-manager (0.1.0-6) unstable; urgency=low
* Initial release.
diff --git a/include/locations.h b/include/locations.h
index 7f1467d..bda7960 100755..100644
--- a/include/locations.h
+++ b/include/locations.h
@@ -50,7 +50,7 @@ typedef enum
*/
typedef enum
{
- LOCATIONS_METHOD_NONE=0, /**< Undefined method. */
+ LOCATIONS_METHOD_NONE=-1, /**< Undefined method. */
LOCATIONS_METHOD_HYBRID, /**< This method selects the best method available at the moment. */
LOCATIONS_METHOD_GPS, /**< This method uses Global Positioning System. */
LOCATIONS_METHOD_WPS, /**< This method uses Wifi Positioning System. */
@@ -158,6 +158,16 @@ typedef void(*location_service_state_changed_cb )(location_service_state_e state
typedef void(*location_zone_changed_cb )(location_boundary_state_e state, double latitude, double longitude, double altitude, time_t timestamp, void *user_data);
/**
+ * @brief Checks whether the given location method is avaliable or not.
+ * @param[in] method The location method to be checked
+ * @return @c true if the specified location method is supported, \n else @c false
+ * @see location_manager_create()
+ * @see location_manager_get_method()
+ */
+bool location_manager_is_supported_method(location_method_e method);
+
+
+/**
* @brief Creates a new location manager.
* @remarks @a manager must be released location_manager_destroy() by you.
* @param[in] method The location method
@@ -309,8 +319,8 @@ int location_manager_get_method(location_manager_h manager, location_method_e *m
* @details
* The result is current altitude, latitude, and longitude, with a measurement timestamp.
*
- * If altitude is negative, only altitude and latitude are available (fix status is 2D).
- * If altitude is positive, fix status is 3D and returned altitude value is the result of measurement.
+ * If @a altitude is negative, only altitude and latitude are available (fix status is 2D).
+ * If @a altitude is positive, fix status is 3D and returned altitude value is the result of measurement.
*
* @param[in] manager The location manager handle
* @param[out] altitude The current altitude (meters)
@@ -361,10 +371,28 @@ int location_manager_get_velocity(location_manager_h manager, int *climb, int *d
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.
+ * @details
+ * The @altitude, @latitude, @longitude, and @timestamp values should be 0, if there is no record of any previous position 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] 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_INVALID_PARAMETER Invalid argument
+ * @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);
+
+/**
* @brief Registers a callback function to be invoked every 1 second with updated position information.
*
* @param[in] manager The location manager handle
* @param[in] callback The callback function to register
+ * @param[in] interval The interval [1 ~ 120] (seconds)
* @param[in] user_data The user data to be passed to the callback function
* @return 0 on success, otherwise a negative error value.
* @retval #LOCATIONS_ERROR_NONE Successful
@@ -373,7 +401,7 @@ int location_manager_get_accuracy(location_manager_h manager, location_accuracy_
* @see location_manager_unset_position_updated_cb()
* @see location_position_updated_cb()
*/
-int location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, void *user_data);
+int location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, int interval, void *user_data);
/**
* @brief Unregisters the callback function.
diff --git a/src/locations.c b/src/locations.c
index a00ef11..8bb5ba2 100644
--- a/src/locations.c
+++ b/src/locations.c
@@ -51,6 +51,7 @@ int _convert_error_code(int code,char *func_name)
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;
@@ -172,6 +173,30 @@ void _remove_boundary(LocationBoundary *boundary, void *user_data)
* Public Implementation
*/
+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;
+ }
+ return location_is_supported_method(_method);
+}
+
int location_manager_create(location_method_e method, location_manager_h* manager)
{
LOCATIONS_NULL_ARG_CHECK(manager);
@@ -555,8 +580,49 @@ int location_manager_get_accuracy(location_manager_h manager, location_accuracy_
return LOCATIONS_ERROR_NONE;
}
-int location_manager_set_position_updated_cb(location_manager_h manager, location_position_updated_cb callback, void *user_data)
+int location_manager_get_last_known_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, time_t *timestamp)
+{
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(altitude);
+ LOCATIONS_NULL_ARG_CHECK(latitude);
+ LOCATIONS_NULL_ARG_CHECK(longitude);
+ LOCATIONS_NULL_ARG_CHECK(timestamp);
+
+ location_manager_s *handle = (location_manager_s*)manager;
+
+ LocationMethod _method = LOCATION_METHOD_NONE;
+ g_object_get(handle->object, "method", &_method, NULL);
+
+ int ret;
+ LocationLastPosition pos;
+ ret = location_get_last_known_position(handle->object, _method, &pos);
+ 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;
+ 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);
}