summaryrefslogtreecommitdiff
path: root/src
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 /src
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.
Diffstat (limited to 'src')
-rw-r--r--src/locations.c68
1 files changed, 67 insertions, 1 deletions
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);
}