From 8d656b3257e201de1a631ccbf2df812a99f2a6a5 Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Mon, 13 Jun 2016 11:21:05 +0900 Subject: [PATCH] Code cleanup Change-Id: I09962450155183a21ea1721a63d84f64cf6b78c2 Signed-off-by: kj7.sung --- location/manager/location-gps.c | 30 +- location/manager/location-hybrid-mobile.c | 30 +- location/manager/location-mock.c | 52 +-- location/manager/location-setting.c | 2 - location/manager/location-signaling-util.c | 94 ++-- location/manager/location-signaling-util.h | 6 +- location/manager/location.c | 1 - location/manager/location.h | 682 +++-------------------------- packaging/liblbs-location.changes | 2 +- 9 files changed, 123 insertions(+), 776 deletions(-) diff --git a/location/manager/location-gps.c b/location/manager/location-gps.c index fda3bf6..31802d6 100755 --- a/location/manager/location-gps.c +++ b/location/manager/location-gps.c @@ -193,30 +193,14 @@ static void gps_location_cb(gboolean enabled, LocationPosition *pos, LocationVel g_return_if_fail(priv); if (priv->min_interval != LOCATION_UPDATE_INTERVAL_NONE) { - distance_based_position_signaling(self, signals, enabled, - pos, vel, acc, - priv->min_interval, - priv->min_distance, - &(priv->enabled), &(priv->dist_updated_timestamp), - &(priv->pos), &(priv->vel), &(priv->acc)); + distance_based_position_signaling(self, signals, enabled, pos, vel, acc, + priv->min_interval, priv->min_distance, &(priv->enabled), + &(priv->dist_updated_timestamp),&(priv->pos), &(priv->vel), &(priv->acc)); } - location_signaling(self, - signals, - enabled, /* previous status */ - priv->boundary_list, - pos, - vel, - acc, - priv->pos_interval, - priv->vel_interval, - priv->loc_interval, - &(priv->enabled), - &(priv->pos_updated_timestamp), - &(priv->vel_updated_timestamp), - &(priv->loc_updated_timestamp), - &(priv->pos), - &(priv->vel), - &(priv->acc)); + location_signaling(self, signals, enabled, priv->boundary_list, pos, vel, acc, + priv->pos_interval, priv->vel_interval, priv->loc_interval, &(priv->enabled), + &(priv->pos_updated_timestamp), &(priv->vel_updated_timestamp), + &(priv->loc_updated_timestamp), &(priv->pos), &(priv->vel), &(priv->acc)); } #ifndef TIZEN_DEVICE diff --git a/location/manager/location-hybrid-mobile.c b/location/manager/location-hybrid-mobile.c index 7f1272e..fdb428a 100755 --- a/location/manager/location-hybrid-mobile.c +++ b/location/manager/location-hybrid-mobile.c @@ -95,8 +95,7 @@ static GParamSpec *properties[PROP_MAX] = {NULL, }; static void location_ielement_interface_init(LocationIElementInterface *iface); -G_DEFINE_TYPE_WITH_CODE(LocationHybrid, location_hybrid, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT, location_ielement_interface_init)); +G_DEFINE_TYPE_WITH_CODE(LocationHybrid, location_hybrid, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT, location_ielement_interface_init)); static LocationMethod hybrid_get_current_method(LocationHybridPrivate *priv) @@ -125,11 +124,11 @@ hybrid_set_current_method(LocationHybridPrivate *priv, GType g_type) return TRUE; } - static int hybrid_get_update_method(LocationHybridPrivate *priv) { - if (!priv->gps && !priv->wps & !priv->mock) return -1; + if (!priv->gps && !priv->wps & !priv->mock) + return -1; if (priv->gps_enabled) hybrid_set_current_method(priv, LOCATION_TYPE_GPS); @@ -217,9 +216,9 @@ _location_timeout_cb(gpointer data) g_signal_emit(object, signals[SERVICE_UPDATED], 0, priv->signal_type, pos, vel, acc); priv->signal_type = 0; - location_position_free(pos); - location_velocity_free(vel); - location_accuracy_free(acc); + if (pos) location_position_free(pos); + if (vel) location_velocity_free(vel); + if (acc) location_accuracy_free(acc); return TRUE; } @@ -291,13 +290,9 @@ location_hybrid_gps_cb(keynode_t *key, gpointer self) } static void -hybrid_location_updated(GObject *obj, - guint error, - gpointer position, - gpointer velocity, - gpointer accuracy, - gpointer self) +hybrid_location_updated(GObject *obj, guint error, gpointer position, gpointer velocity, gpointer accuracy, gpointer self) { + LOC_FUNC_LOG LocationPosition *pos = (LocationPosition *)position; LocationVelocity *vel = (LocationVelocity *)velocity; LocationAccuracy *acc = (LocationAccuracy *)accuracy; @@ -351,12 +346,6 @@ hybrid_service_updated(GObject *obj, gint type, gpointer data, gpointer velocity return; } } - /* TODO: Why we need this logic? */ - else if (g_type == LOCATION_TYPE_WPS && - location_setting_get_int(VCONFKEY_LOCATION_WPS_STATE) == VCONFKEY_LOCATION_WPS_SEARCHING) { - LOCATION_LOGD("Searching WPS"); - return; - } if (hybrid_compare_g_type_method(priv, g_type)) { if (priv->pos) location_position_free(priv->pos); @@ -390,8 +379,7 @@ hybrid_service_updated(GObject *obj, gint type, gpointer data, gpointer velocity LOC_COND_VOID(ret != LOCATION_ERROR_NONE, _E, "Fail hyhrid location_stop : [%s]", err_msg(ret)); } - } else if (g_type == LOCATION_TYPE_WPS - && location_setting_get_int(VCONFKEY_LOCATION_GPS_STATE) == VCONFKEY_LOCATION_GPS_SEARCHING) { + } else if (g_type == LOCATION_TYPE_WPS && location_setting_get_int(VCONFKEY_LOCATION_GPS_STATE) == VCONFKEY_LOCATION_GPS_SEARCHING) { LOCATION_LOGD("g_type is LOCATION_TYPE_WPS and GPS is searching"); hybrid_set_current_method(priv, g_type); diff --git a/location/manager/location-mock.c b/location/manager/location-mock.c index 0f05271..d17c623 100755 --- a/location/manager/location-mock.c +++ b/location/manager/location-mock.c @@ -86,10 +86,7 @@ static GParamSpec *properties[PROP_MAX] = {NULL, }; #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), LOCATION_TYPE_MOCK, LocationMockPrivate)) static void location_ielement_interface_init(LocationIElementInterface *iface); - -G_DEFINE_TYPE_WITH_CODE(LocationMock, location_mock, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT, - location_ielement_interface_init)); +G_DEFINE_TYPE_WITH_CODE(LocationMock, location_mock, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT, location_ielement_interface_init)); static void __reset_pos_data_from_priv(LocationMockPrivate *priv) @@ -161,40 +158,17 @@ mock_location_cb(gboolean enabled, LocationPosition *pos, LocationVelocity *vel, g_return_if_fail(priv); if (priv->min_interval != LOCATION_UPDATE_INTERVAL_NONE) { - distance_based_position_signaling(self, - signals, - enabled, - pos, - vel, - acc, - priv->min_interval, - priv->min_distance, - &(priv->enabled), - &(priv->dist_updated_timestamp), - &(priv->pos), - &(priv->vel), - &(priv->acc)); + distance_based_position_signaling(self, signals, enabled, + pos, vel, acc, priv->min_interval, priv->min_distance, &(priv->enabled), + &(priv->dist_updated_timestamp), &(priv->pos), &(priv->vel), &(priv->acc)); } LOCATION_LOGD("Calling location_signaling, status =%d", pos->status); - location_signaling(self, - signals, - enabled, - priv->boundary_list, - pos, - vel, - acc, - priv->pos_interval, - priv->vel_interval, - priv->loc_interval, - &(priv->enabled), - &(priv->pos_updated_timestamp), - &(priv->vel_updated_timestamp), - &(priv->loc_updated_timestamp), - &(priv->pos), - &(priv->vel), - &(priv->acc)); + location_signaling(self, signals, enabled, priv->boundary_list, pos, vel, acc, + priv->pos_interval, priv->vel_interval, priv->loc_interval, &(priv->enabled), + &(priv->pos_updated_timestamp), &(priv->vel_updated_timestamp), &(priv->loc_updated_timestamp), + &(priv->pos), &(priv->vel), &(priv->acc)); } static void @@ -305,7 +279,6 @@ location_mock_dispose(GObject *gobject) if (priv->app_type != CPPAPP && priv->set_noti == TRUE) { location_setting_ignore_notify(VCONFKEY_LOCATION_MOCK_ENABLED, location_setting_mock_cb); priv->set_noti = FALSE; - } G_OBJECT_CLASS(location_mock_parent_class)->dispose(gobject); @@ -736,10 +709,13 @@ __set_mock_location_cb(gboolean enabled, LocationStatus status, gpointer self) g_return_if_fail(priv); LOCATION_LOGD("ENTER >>>"); - LOCATION_LOGD("status = %d"); + LOCATION_LOGD("Mock status = %d"); if (status == LOCATION_STATUS_MOCK_FAIL) { - /* g_signal_emit(obj, signals[SERVICE_DISABLED], 0, LOCATION_STATUS_NO_FIX); */ - g_signal_emit(obj, signals[STATUS_CHANGED], 0, LOCATION_STATUS_MOCK_FAIL); + /* + if (priv->enabled == TRUE && status == LOCATION_STATUS_MOCK_FAIL) { + __set_started(self, FALSE); */ + g_signal_emit(obj, signals[SERVICE_DISABLED], 0, LOCATION_STATUS_NO_FIX); + /* g_signal_emit(obj, signals[STATUS_CHANGED], 0, LOCATION_STATUS_MOCK_FAIL); */ } LOCATION_LOGD("EXIT <<<"); diff --git a/location/manager/location-setting.c b/location/manager/location-setting.c index 0b9ab32..1097686 100644 --- a/location/manager/location-setting.c +++ b/location/manager/location-setting.c @@ -112,7 +112,6 @@ gint location_setting_add_notify(const gchar *path, SettingCB setting_cb, gpoint if (eventsystem_register_event(event_name, &g_event_req_id, (eventsystem_handler) __event_handler, NULL) != ES_R_OK) { LOCATION_SECLOG("eventsystem_register_event failed"); - return -1; } if (vconf_notify_key_changed(path, setting_cb, self)) { @@ -130,7 +129,6 @@ gint location_setting_ignore_notify(const gchar *path, SettingCB setting_cb) if (eventsystem_unregister_event(g_event_req_id) != ES_R_OK) { LOCATION_SECLOG("eventsystem_unregister_event failed"); - return -1; } if (vconf_ignore_key_changed(path, setting_cb)) { diff --git a/location/manager/location-signaling-util.c b/location/manager/location-signaling-util.c index a623e22..cdd0f38 100755 --- a/location/manager/location-signaling-util.c +++ b/location/manager/location-signaling-util.c @@ -56,22 +56,16 @@ enable_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolean *pr } void -position_velocity_signaling(LocationObject *obj, - guint32 signals[LAST_SIGNAL], - guint pos_interval, - guint vel_interval, - guint loc_interval, - guint *pos_updated_timestamp, - guint *vel_updated_timestamp, - guint *loc_updated_timestamp, - GList *prev_bound, - LocationPosition *pos, - LocationVelocity *vel, - LocationAccuracy *acc) +position_velocity_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], + guint pos_interval, guint vel_interval, guint loc_interval, + guint *pos_last_timestamp, guint *vel_last_timestamp, guint *loc_last_timestamp, + GList *prev_bound, LocationPosition *cur_pos, LocationVelocity *cur_vel, LocationAccuracy *cur_acc) { g_return_if_fail(obj); g_return_if_fail(signals); - g_return_if_fail(pos); + g_return_if_fail(cur_pos); + g_return_if_fail(cur_vel); + g_return_if_fail(cur_acc); int index = 0; int signal_type = 0; @@ -79,48 +73,48 @@ position_velocity_signaling(LocationObject *obj, GList *boundary_list = prev_bound; LocationBoundaryPrivate *priv = NULL; - if (pos && !pos->timestamp) { + if (cur_pos && !cur_pos->timestamp) { LOCATION_LOGW("Invalid location with timestamp, 0"); return; } if (pos_interval > 0) { - if (pos->timestamp - *pos_updated_timestamp >= pos_interval) { + if (cur_pos->timestamp - *pos_last_timestamp >= pos_interval) { signal_type |= POSITION_UPDATED; - *pos_updated_timestamp = pos->timestamp; + *pos_last_timestamp = cur_pos->timestamp; } } if (vel_interval > 0) { - if (vel && (vel->timestamp - *vel_updated_timestamp >= vel_interval)) { + if (cur_vel && (cur_vel->timestamp - *vel_last_timestamp >= vel_interval)) { signal_type |= VELOCITY_UPDATED; - *vel_updated_timestamp = vel->timestamp; + *vel_last_timestamp = cur_vel->timestamp; } } if (loc_interval > 0) { - if (pos->timestamp - *loc_updated_timestamp >= loc_interval) { + if (cur_pos->timestamp - *loc_last_timestamp >= loc_interval) { signal_type |= LOCATION_CHANGED; - *loc_updated_timestamp = pos->timestamp; + *loc_last_timestamp = cur_pos->timestamp; } } if (signal_type != 0) - g_signal_emit(obj, signals[SERVICE_UPDATED], 0, signal_type, pos, vel, acc); + g_signal_emit(obj, signals[SERVICE_UPDATED], 0, signal_type, cur_pos, cur_vel, cur_acc); if (boundary_list) { while ((priv = (LocationBoundaryPrivate *)g_list_nth_data(boundary_list, index)) != NULL) { - is_inside = location_boundary_if_inside(priv->boundary, pos); + is_inside = location_boundary_if_inside(priv->boundary, cur_pos); if (is_inside) { if (priv->zone_status != ZONE_STATUS_IN) { LOCATION_LOGD("Signal emit: ZONE IN"); - g_signal_emit(obj, signals[ZONE_IN], 0, priv->boundary, pos, acc); + g_signal_emit(obj, signals[ZONE_IN], 0, priv->boundary, cur_pos, cur_acc); priv->zone_status = ZONE_STATUS_IN; } } else { if (priv->zone_status != ZONE_STATUS_OUT) { LOCATION_LOGD("Signal emit : ZONE_OUT"); - g_signal_emit(obj, signals[ZONE_OUT], 0, priv->boundary, pos, acc); + g_signal_emit(obj, signals[ZONE_OUT], 0, priv->boundary, cur_pos, cur_acc); priv->zone_status = ZONE_STATUS_OUT; } } @@ -130,20 +124,12 @@ position_velocity_signaling(LocationObject *obj, } void -distance_based_position_signaling(LocationObject *obj, - guint32 signals[LAST_SIGNAL], - gboolean enabled, - LocationPosition *cur_pos, - LocationVelocity *cur_vel, - LocationAccuracy *cur_acc, - guint min_interval, - gdouble min_distance, - gboolean *prev_enabled, - guint *prev_dist_timestamp, - LocationPosition **prev_pos, /* prev : keeping lastest info. */ - LocationVelocity **prev_vel, - LocationAccuracy **prev_acc) +distance_based_position_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolean enabled, + LocationPosition *cur_pos, LocationVelocity *cur_vel, LocationAccuracy *cur_acc, + guint min_interval, gdouble min_distance, gboolean *prev_enabled, guint *prev_dist_timestamp, + LocationPosition **prev_pos, LocationVelocity **prev_vel, LocationAccuracy **prev_acc) { + LOC_FUNC_LOG g_return_if_fail(obj); g_return_if_fail(signals); g_return_if_fail(cur_pos); @@ -191,27 +177,17 @@ distance_based_position_signaling(LocationObject *obj, } void -location_signaling(LocationObject *obj, - guint32 signals[LAST_SIGNAL], - gboolean enabled, - GList *boundary_list, - LocationPosition *cur_pos, - LocationVelocity *cur_vel, - LocationAccuracy *cur_acc, - guint pos_interval, /* interval : support an update interval */ - guint vel_interval, - guint loc_interval, - gboolean *prev_enabled, - guint *prev_pos_timestamp, - guint *prev_vel_timestamp, - guint *prev_loc_timestamp, - LocationPosition **prev_pos, /* prev : keeping lastest info. */ - LocationVelocity **prev_vel, - LocationAccuracy **prev_acc) +location_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolean enabled, GList *boundary_list, + LocationPosition *cur_pos, LocationVelocity *cur_vel, LocationAccuracy *cur_acc, + guint pos_interval, guint vel_interval, guint loc_interval, gboolean *prev_enabled, + guint *prev_pos_timestamp, guint *prev_vel_timestamp, guint *prev_loc_timestamp, + LocationPosition **prev_pos, LocationVelocity **prev_vel, LocationAccuracy **prev_acc) { g_return_if_fail(obj); g_return_if_fail(signals); g_return_if_fail(cur_pos); + g_return_if_fail(cur_vel); + g_return_if_fail(cur_acc); if (!cur_pos->timestamp) { LOCATION_LOGD("Invalid location with timestamp, 0"); @@ -226,14 +202,14 @@ location_signaling(LocationObject *obj, *prev_vel = location_velocity_copy(cur_vel); *prev_acc = location_accuracy_copy(cur_acc); - LOCATION_LOGD("status = %d", cur_pos->status); + LOCATION_LOGD("cur_pos->status = %d", cur_pos->status); enable_signaling(obj, signals, prev_enabled, enabled, cur_pos->status); position_velocity_signaling(obj, signals, pos_interval, vel_interval, loc_interval, prev_pos_timestamp, prev_vel_timestamp, prev_loc_timestamp, boundary_list, cur_pos, cur_vel, cur_acc); } void -satellite_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolean *prev_enabled, - int interval, gboolean emit, guint *updated_timestamp, LocationSatellite **prev_sat, LocationSatellite *sat) +satellite_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolean *prev_enabled, int interval, + gboolean emit, guint *last_timestamp, LocationSatellite **prev_sat, LocationSatellite *sat) { g_return_if_fail(obj); g_return_if_fail(signals); @@ -244,9 +220,9 @@ satellite_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolean if (*prev_sat) location_satellite_free(*prev_sat); *prev_sat = location_satellite_copy(sat); - if (emit && sat->timestamp - *updated_timestamp >= interval) { + if (emit && sat->timestamp - *last_timestamp >= interval) { g_signal_emit(obj, signals[SERVICE_UPDATED], 0, SATELLITE_UPDATED, sat, NULL, NULL); - *updated_timestamp = sat->timestamp; + *last_timestamp = sat->timestamp; } } diff --git a/location/manager/location-signaling-util.h b/location/manager/location-signaling-util.h index ffb953e..32d81b4 100644 --- a/location/manager/location-signaling-util.h +++ b/location/manager/location-signaling-util.h @@ -36,12 +36,12 @@ void enable_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolea void position_velocity_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], guint pos_interval, guint vel_interval, guint loc_interval, - guint *pos_updated_timestamp, guint *vel_updated_timestamp, guint *loc_updated_timestamp, - GList *prev_bound, LocationPosition *pos, LocationVelocity *vel, LocationAccuracy *acc); + guint *pos_last_timestamp, guint *vel_last_timestamp, guint *loc_last_timestamp, + GList *prev_bound, LocationPosition *cur_pos, LocationVelocity *cur_vel, LocationAccuracy *cur_acc); void satellite_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolean *prev_enabled, int interval, gboolean emit, - guint *updated_timestamp, LocationSatellite **pre_sat, + guint *last_timestamp, LocationSatellite **pre_sat, LocationSatellite *sat); void location_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], diff --git a/location/manager/location.c b/location/manager/location.c index 33ac017..33de067 100755 --- a/location/manager/location.c +++ b/location/manager/location.c @@ -25,7 +25,6 @@ #include #include -#include #include #include "location.h" diff --git a/location/manager/location.h b/location/manager/location.h index 84d3ee7..61669e5 100755 --- a/location/manager/location.h +++ b/location/manager/location.h @@ -51,30 +51,23 @@ G_BEGIN_DECLS */ /** - * @brief - * Initialize location sub module. - * @remarks None. - * This API should be called before any other Location APIs. + * @brief Initialize location sub module. + * @remarks None. This API should be called before any other Location APIs. * @pre None. * @post None. * @return int * @retval 0 Success - * * Please refer #LocationError for more information. * @see None. */ int location_init(void); /** - * @brief - * Create a new #LocationObject by using given #LocationMethod. - * @remarks - * Returned object is necessary for other APIs. - * @pre - * #location_init should be called before. + * @brief Create a new #LocationObject by using given #LocationMethod. + * @remarks Returned object is necessary for other APIs. + * @pre #location_init should be called before. * @post None. - * @param [in] - * method - Location method to be used. + * @param [in] method - Location method to be used. * @return a new #LocationObject * @retval NULL if error occured * @see location_free @@ -82,244 +75,53 @@ int location_init(void); LocationObject *location_new(LocationMethod method); /** - * @brief - * Free memory of given #LocationObject. + * @brief Free memory of given #LocationObject. * @remarks None. - * @pre - * #location_init should be called before. + * @pre #location_init should be called before. * @post None. - * @param [in] - * obj - a #LocationObject created by #location_new. + * @param [in] obj - a #LocationObject created by #location_new. * @return int * @retval 0 Success. - * * Please refer #LocationError for more information. - * @see location_new - * @par Example - * @code -#include -int main (int argc, char *argv[]) -{ - LocationObject *loc = NULL; - location_init (); - loc = location_new (LOCATION_METHOD_GPS); - if(!loc) - return -1; - - // ... Implement your code - - location_free (loc); - // You must free LocationObject when you don't need to use anymore. - return 0; -} - * @endcode */ int location_free(LocationObject *obj); /** - * @brief - * Start the location service by using given #LocationObject. - * @remarks - * If you want to recieve signals, you should use this API. - * @pre - * #location_init should be called before. + * @brief Start the location service by using given #LocationObject. + * @remarks If you want to recieve signals, you should use this API. + * @pre #location_init should be called before. * @post None. - * @param [in] - * obj - a #LocationObject created by #location_new + * @param [in] obj - a #LocationObject created by #location_new * @return int * @retval 0 Success. - * * Please refer #LocationError for more information. - * @see location_stop - * @par Example - * @code -#include -static GMainLoop *loop = NULL; - -static void cb_service_enabled (GObject *self, guint status, gpointer userdata) -{ - LocationObject *loc = (LocationObject*)userdata; - LocationAccuracy *acc = NULL; - LocationPosition *pos = NULL; - LocationVelocity *vel = NULL; - LocationAddress *addr = NULL; - LocationMethod method; - - g_object_get(loc, "method", &method, NULL); - g_debug("Get property>> method:%d", method); - - if (status == LOCATION_STATUS_2D_FIX || status == LOCATION_STATUS_3D_FIX) { - if (LOCATION_ERROR_NONE == location_get_position (loc, &pos, &acc)) { - g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d", - pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status); - g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", - acc->level, acc->horizontal_accuracy, acc->vertical_accuracy); - location_position_free(pos); - location_accuracy_free(acc); - } else g_warning ("SYNC>> Current position> failed"); - - if (LOCATION_ERROR_NONE == location_get_velocity (loc, &vel, &acc)) { - g_debug ("SYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f", - vel->timestamp, vel->speed, vel->direction, vel->climb); - g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", - acc->level, acc->horizontal_accuracy, acc->vertical_accuracy); - location_velocity_free(vel); - location_accuracy_free(acc); - } else g_warning ("SYNC>> Current velocity> failed"); - } -} - -static void -cb_service_updated (GObject *self, - guint type, - gpointer data, - gpointer accuracy, - gpointer userdata) -{ - LocationAccuracy *acc = (LocationAccuracy*) accuracy; - switch (type) { - case POSITION_UPDATED: { - LocationPosition *pos = (LocationPosition*) data; - g_debug ("ASYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d", - pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status); - g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", - acc->level, acc->horizontal_accuracy, acc->vertical_accuracy); - } - break; - case VELOCITY_UPDATED: { - LocationVelocity *vel = (LocationVelocity*) data; - g_debug ("ASYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f", - vel->timestamp, vel->speed, vel->direction, vel->climb); - g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", - acc->level, acc->horizontal_accuracy, acc->vertical_accuracy); - } - break; - case SATELLITE_UPDATED: { - int idx = 0; - guint prn; - gboolean used; - guint elevation; - guint azimuth; - gint snr; - - LocationSatellite *sat = (LocationSatellite *)data; - g_debug ("ASYNC>> Current Satellite> time: %d, satellite in view = %d, satellite in used = %d", sat->timestamp, sat->num_of_sat_inview, sat->num_of_sat_used); - g_debug ("\tinview satellite information = "); - for (idx=0; idxnum_of_sat_inview; idx++) { - location_satellite_get_satellite_details(sat, idx, &prn, &used, &elevation, &azimuth, &snr); - g_debug ("\t\t[%02d] used: %d, prn: %d, elevation: %d, azimuth: %d, snr: %d", idx, used, prn, elevation, azimuth, snr); - } - } - break; - - default: - g_warning ("ASYNC>> Undefined update type"); - break; - } -} - - -int main (int argc, char *argv[]) -{ - LocationObject *loc = NULL; - int interval = 6; //seconds - location_init (); - - loc = location_new (LOCATION_METHOD_GPS); - if(!loc) - return -1; - - g_object_set(loc, "update-interval", interval, NULL); - - g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc); - g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc); - - location_start(loc); - loop = g_main_loop_new (NULL, TRUE); - g_main_loop_run (loop); // GMainLoop is needed for receiving signals. - - // ... - return 0; -} - * @endcode */ int location_start(LocationObject *obj); /** - * @brief - * Stop the location service by using given #LocationObject. - * @remarks - * After call this API, you can not recieve signals. - * @pre - * #location_init should be called before.\n + * @brief Stop the location service by using given #LocationObject. + * @remarks After call this API, you can not recieve signals. + * @pre #location_init should be called before.\n * #location_start should be called before. * @post None. - * @param [in] - * obj - a #LocationObject created by #location_new + * @param [in] obj - a #LocationObject created by #location_new * @return int * @retval 0 Success - * * Please refer #LocationError for more information. - * @see location_start - * @par Example - * @code -#include -static GMainLoop *loop = NULL; - -int main (int argc, char *argv[]) -{ - LocationObject *loc = NULL; - location_init (); - loc = location_new (LOCATION_METHOD_GPS); - if(!loc) - return -1; - - location_start(loc); - loop = g_main_loop_new (NULL, TRUE); - g_main_loop_run (loop); - - // .... - - location_stop (loc); - // you can not receive signals anymore. - return 0; -} - * @endcode */ int location_stop(LocationObject *obj); int location_request_single_location(LocationObject *obj, int timeout); /** - * @brief - * Check wheither a method is available. + * @brief Check wheither a method is available. * @remarks - * @pre - * #location_init should be called before.\n + * @pre #location_init should be called before.\n * @post None. * @param [in] method - a #LocationMethod * @return int * @retval True Supported * False Not supported - * @par Example - #include -static GMainLoop *loop = NULL; - -int main (int argc, char *argv[]) -{ - gboolean is_supported = FALSE; - - // .... - - is_supported = location_is_supported_method(LOCATION_METHOD_HYBRID); - if(is_supported == TRUE) - g_printf("Hybrid Method is supported.\n"); - else - g_printf("Hybrid Method is not supported.\n"); - - return 0; -}* @code - * @endcode */ gboolean location_is_supported_method(LocationMethod method); @@ -329,82 +131,23 @@ int location_enable_method(const LocationMethod method, const int enable); /** - * @brief - * Get current position information with estimate of the accuracy. + * @brief Get current position information with estimate of the accuracy. * @remarks Out parameters are should be freed. - * @pre - * #location_init should be called before.\n - * #location_start should be called before. + * @pre #location_init should be called before.\n #location_start should be called before. * @post None. - * @param [in] - * obj - a #LocationObject created by #location_new - * @param [out] - * position - a new #LocationPosition - * @param [out] - * accuracy - a new #LocationAccuracy + * @param [in] obj - a #LocationObject created by #location_new + * @param [out] position - a new #LocationPosition + * @param [out] accuracy - a new #LocationAccuracy * @return int * @retval 0 Success - * * Please refer #LocationError for more information. - * @see location_get_velocity - * @par Example - * @code -#include -static GMainLoop *loop = NULL; - -static void cb_service_enabled (GObject *self, guint status, gpointer userdata) -{ - g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata); - - LocationObject *loc = (LocationObject*)userdata; - LocationAccuracy *acc = NULL; - LocationPosition *pos = NULL; - - // This function works properly after service is enabled. - if (LOCATION_ERROR_NONE == location_get_position (loc, &pos, &acc)) { - g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d", - pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status); - g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", - acc->level, acc->horizontal_accuracy, acc->vertical_accuracy); - location_position_free(pos); - location_accuracy_free(acc); - } else g_warning ("SYNC>> Current position> failed"); -} - -int main (int argc, char *argv[]) -{ - LocationObject *loc = NULL; - gulong handler_id = 0; - - location_init (); - loop = g_main_loop_new (NULL, TRUE); - loc = location_new (LOCATION_METHOD_GPS); - if(!loc){ - g_debug("location_new failed"); - return -1; - } - - handler_id = g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc); - location_start (loc); - g_main_loop_run (loop); - - g_signal_handler_disconnect(loc, handler_id); - location_stop (loc); - location_free (loc); - - return 0; -} - * @endcode */ int location_get_position(LocationObject *obj, LocationPosition **position, LocationAccuracy **accuracy); /** - * @brief - * Get current position & velocity information with estimate of the accuracy. + * @brief Get current position & velocity information with estimate of the accuracy. * @remarks Out parameters are should be freed. - * @pre - * #location_init should be called before.\n - * #location_start should be called before. + * @pre #location_init should be called before.\n #location_start should be called before. * @post None. * @param [in] obj - a #LocationObject created by #location_new * @param [out] position - a new #LocationPosition @@ -412,115 +155,26 @@ int location_get_position(LocationObject *obj, LocationPosition **position, Loca * @param [out] accuracy - a new #LocationAccuracy * @return int * @retval 0 Success - * * Please refer #LocationError for more information. - * @see location_get_position - * @par Example - * @code -#include -static GMainLoop *loop = NULL; - -static void cb_service_enabled (GObject *self, guint status, gpointer userdata) -{ - g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata); - - LocationObject *loc = (LocationObject*)userdata; - - LocationPosition *pos = NULL; - LocationVelocity *vel = NULL; - LocationAccuracy *acc = NULL; - - // This function works properly after service is enabled. - if (LOCATION_ERROR_NONE == location_get_position_ext (loc, &pos, &vel, &acc)) { - g_debug ("SYNC>> Current position> time: %d, lat: %f, long: %f, alt: %f, status: %d, speed: %f, direction: %f", - pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status, vel->speed, vel->direction); - g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", - acc->level, acc->horizontal_accuracy, acc->vertical_accuracy); - location_position_free(pos); - location_accuracy_free(acc); - } else g_warning ("SYNC>> Current position_ext > failed"); -} - -int main (int argc, char *argv[]) -{ - LocationObject *loc = NULL; - gulong handler_id = 0; - - location_init (); - loop = g_main_loop_new (NULL, TRUE); - loc = location_new (LOCATION_METHOD_GPS); - if(!loc){ - g_debug("location_new failed"); - return -1; - } - - handler_id = g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc); - location_start (loc); - g_main_loop_run (loop); - - g_signal_handler_disconnect(loc, handler_id); - location_stop (loc); - location_free (loc); - - return 0; -} - * @endcode */ int location_get_position_ext(LocationObject *obj, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy); /** - * @brief - * Get last position information with estimate of the accuracy. + * @brief Get last position information with estimate of the accuracy. * @remarks Out parameters are should be freed. * @pre #location_init should be called before. * @post None. - * @param [in] - * obj - a #LocationObject created by #location_new + * @param [in] obj - a #LocationObject created by #location_new * @param [out] position - a new #LocationPosition * @param [out] accuracy - a new #LocationAccuracy * @return int * @retval 0 Success - * * Please refer #LocationError for more information. - * @see location_get_position - * @par Example - * @code -#include - -int main (int argc, char *argv[]) -{ - LocationObject *loc = NULL; - int ret = 0; - LocationPosition *last_pos = NULL; - LocationAccuracy *last_acc = NULL; - - location_init (); - loc = location_new (LOCATION_METHOD_GPS); - if(!loc){ - g_debug("location_new failed"); - return -1; - } - - if (LOCATION_ERROR_NONE == location_get_last_position (loc, &last_pos, &last_acc)) { - g_debug ("SYNC>> Last position> time: %d, lat: %f, long: %f, alt: %f, status: %d", - last_pos->timestamp, last_pos->latitude, last_pos->longitude, last_pos->altitude, last_pos->status); - g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", - last_acc->level, last_acc->horizontal_accuracy, last_acc->vertical_accuracy); - location_position_free(last_pos); - location_accuracy_free(last_acc); - } else g_warning ("SYNC>> Last position> failed"); - - location_free (loc); - - return 0; -} - * @endcode */ int location_get_last_position(LocationObject *obj, LocationPosition **position, LocationAccuracy **accuracy); /** - * @brief - * Get last position & velocity information with estimate of the accuracy. + * @brief Get last position & velocity information with estimate of the accuracy. * @remarks Out parameters are should be freed. * @pre #location_init should be called before. * @post None. @@ -530,97 +184,19 @@ int location_get_last_position(LocationObject *obj, LocationPosition **position, * @param [out] accuracy - a new #LocationAccuracy * @return int * @retval 0 Success - * * Please refer #LocationError for more information. - * @see location_get_position_ext - * @par Example - * @code -#include - -int main (int argc, char *argv[]) -{ - LocationObject *loc = NULL; - int ret = 0; - LocationPosition *last_pos = NULL; - LocationVelocity *last_vel = NULL; - LocationAccuracy *last_acc = NULL; - - location_init (); - loc = location_new (LOCATION_METHOD_GPS); - if(!loc){ - g_debug("location_new failed"); - return -1; - } - - if (LOCATION_ERROR_NONE == location_get_last_position_ext (loc, &last_pos, &last_vel, &last_acc)) { - g_debug ("SYNC>> Last position> time: %d, lat: %f, long: %f, alt: %f, status: %d, speed: %f, direction: %f", - last_pos->timestamp, last_pos->latitude, last_pos->longitude, last_pos->altitude, last_pos->status, last_vel->speed, last_vel->direction); - g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", - last_acc->level, last_acc->horizontal_accuracy, last_acc->vertical_accuracy); - location_position_free(last_pos); - location_velocity_free(last_vel); - location_accuracy_free(last_acc); - } else g_warning ("SYNC>> Last position_ext > failed"); - - location_free (loc); - - return 0; -} - * @endcode */ int location_get_last_position_ext(LocationObject *obj, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy); /** - * @brief - * Get last satellite information. - * @remarks This API is not implemented now. \n - * Out parameters are should be freed. - * @pre - * #location_init should be called before. + * @brief Get last satellite information. + * @remarks This API is not implemented now. \n Out parameters are should be freed. + * @pre #location_init should be called before. * @post None. - * @param [in] - * obj - a #LocationObject created by #location_new + * @param [in] obj - a #LocationObject created by #location_new * @param [out] satellite - a new #LocationSatellite * @return int * @retval 0 Success * Please refer #LocationError for more information. - * @see location_get_last_satellite - * @par Example - * @code -#include - -int main (int argc, char *argv[]) -{ - LocationObject *loc = NULL; - int ret = 0, idx = 0; - LocationSatellite *sat = NULL; - guint prn; - gboolean used; - guint elevation; - guint azimuth; - gint snr; - - location_init (); - loc = location_new (LOCATION_METHOD_GPS); - if(!loc){ - g_debug("location_new failed"); - return -1; - } - - if (LOCATION_ERROR_NONE == location_get_satellite (loc, &sat)) { - g_debug ("SYNC>> Current Sattelite> satellite in view = %d, satellite in used = %d", sat->num_of_sat_inview, sat->num_of_sat_used); - g_debug ("\tinview satellite information = "); - for (idx=0; idxnum_of_sat_inview; idx++) { - location_satellite_get_satellite_details(sat, idx, &prn, &used, &elevation, &azimuth, &snr); - g_debug ("\t\t[%02d] used: %d, prn: %d, elevation: %d, azimuth: %d, snr: %d", idx, used, prn, elevation, azimuth, snr); - } - location_satellite_free (sat); - } else g_warning ("SYNC>> Current satellite> failed"); - - location_free (loc); - - return 0; -} - * @endcode */ int location_get_satellite(LocationObject *obj, LocationSatellite **satellite); @@ -633,223 +209,74 @@ int location_get_batch(LocationObject *obj, LocationBatch **batch); /** - * @brief - * Get last satellite information. - * @remarks This API is not implemented now. \n - * Out parameters are should be freed. - * @pre - * #location_init should be called before. + * @brief Get last satellite information. + * @remarks This API is not implemented now. \n Out parameters are should be freed. + * @pre #location_init should be called before. * @post None. - * @param [in] - * obj - a #LocationObject created by #location_new - * @param [out] - * satellite - a new #LocationSatellite + * @param [in] obj - a #LocationObject created by #location_new + * @param [out] satellite - a new #LocationSatellite * @return int * @retval 0 Success - * * Please refer #LocationError for more information. - * @par Example - * @code -#include - -int main (int argc, char *argv[]) -{ - LocationObject *loc = NULL; - int ret = 0, idx = 0; - LocationSatellite *last_sat = NULL; - guint prn; - gboolean used; - guint elevation; - guint azimuth; - gint snr; - - location_init (); - loc = location_new (LOCATION_METHOD_GPS); - if(!loc){ - g_debug("location_new failed"); - return -1; - } - - if (LOCATION_ERROR_NONE == location_get_last_satellite (loc, &last_sat)) { - g_debug ("SYNC>> Last Sattelite> satellite in view = %d, satellite in used = %d", last_sat->num_of_sat_inview, last_sat->num_of_sat_used); - g_debug ("\tinview satellite information = "); - for (idx=0; idxnum_of_sat_inview; idx++) { - location_satellite_get_satellite_details(last_sat, idx, &prn, &used, &elevation, &azimuth, &snr); - g_debug ("\t\t[%02d] used: %d, prn: %d, elevation: %d, azimuth: %d, snr: %d", idx, used, prn, elevation, azimuth, snr); - } - location_satellite_free (last_sat); - } else g_warning ("SYNC>> Last satellite> failed"); - - location_free (loc); - - return 0; -} - * @endcode */ int location_get_last_satellite(LocationObject *obj, LocationSatellite **satellite); /** - * @brief - * Get current velocity information with estimate of the accuracy. + * @brief Get current velocity information with estimate of the accuracy. * @remarks Out parameters are should be freed. - * @pre - * #location_init should be called before.\n - * #location_start should be called before. + * @pre #location_init should be called before.\n #location_start should be called before. * @post None. - * @param [in] - * obj - a #LocationObject created by #location_new - * @param [out] - * velocity - a new #LocationVelocity - * @param [out] - * accuracy - a new #LocationAccuracy + * @param [in] obj - a #LocationObject created by #location_new + * @param [out] velocity - a new #LocationVelocity + * @param [out] accuracy - a new #LocationAccuracy * @return int * @retval 0 Success - * * Please refer #LocationError for more information. - * @see location_get_position - * @par Example - * @code -#include -static GMainLoop *loop = NULL; - -static void cb_service_enabled (GObject *self, guint status, gpointer userdata) -{ - g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata); - - LocationObject *loc = (LocationObject*)userdata; - LocationAccuracy *acc = NULL; - LocationVelocity *vel = NULL; - - if (LOCATION_ERROR_NONE == location_get_velocity (loc, &vel, &acc)) { - g_debug ("SYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f", - vel->timestamp, vel->speed, vel->direction, vel->climb); - g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", - acc->level, acc->horizontal_accuracy, acc->vertical_accuracy); - location_velocity_free(vel); - location_accuracy_free(acc); - } else g_warning ("SYNC>> Current velocity> failed"); -} - -int main (int argc, char *argv[]) -{ - LocationObject *loc = NULL; - gulong hander_id = 0; - location_init (); - - loop = g_main_loop_new (NULL, TRUE); - - loc = location_new (LOCATION_METHOD_GPS); - if(!loc){ - g_debug("location_new failed"); - return -1; - } - - handler_id = g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc); - location_start (loc); - g_main_loop_run (loop); - - g_signal_handler_disconnect(loc, handler_id); - location_stop (loc); - location_free (loc); - - return 0; -} - - * @endcode */ int location_get_velocity(LocationObject *obj, LocationVelocity **velocity, LocationAccuracy **accuracy); /** - * @brief - * Get last velocity information with estimate of the accuracy. + * @brief Get last velocity information with estimate of the accuracy. * @remarks Out parameters are should be freed. - * @pre - * #location_init should be called before. + * @pre #location_init should be called before. * @post None. - * @param [in] - * obj - a #LocationObject created by #location_new - * @param [out] - * velocity - a new #LocationVelocity - * @param [out] - * accuracy - a new #LocationAccuracy + * @param [in] obj - a #LocationObject created by #location_new + * @param [out] velocity - a new #LocationVelocity + * @param [out] accuracy - a new #LocationAccuracy * @return int * @retval 0 Success - * * Please refer #LocationError for more information. - * @see location_get_position - * @par Example - * @code -#include - -int main (int argc, char *argv[]) -{ - int ret = 0; - LocationObject *loc = NULL; - LocationVelocity *vel = NULL; - LocationAccuracy *acc = NULL; - gulong hander_id = 0; - - location_init (); - - loc = location_new (LOCATION_METHOD_GPS); - if(!loc){ - g_debug("location_new failed"); - return -1; - } - - ret = location_get_last_velocity (loc, &vel, &acc); - if (ret == LOCATION_ERROR_NONE) { - g_debug ("SYNC>> Last velocity> time: %d, speed: %f, direction:%f, climb:%f", - vel->timestamp, vel->speed, vel->direction, vel->climb); - g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)", - acc->level, acc->horizontal_accuracy, acc->vertical_accuracy); - location_velocity_free(vel); - location_accuracy_free(acc); - } - - location_free (loc); - return 0; -} - * @endcode */ int location_get_last_velocity(LocationObject *obj, LocationVelocity **velocity, LocationAccuracy **accuracy); /** - * @brief - * Get the accessibility state of an application + * @brief Get the accessibility state of an application * @remarks None. - * @pre - * #location_init should be called before.\n + * @pre #location_init should be called before.\n * @post None. * @param [out] state - a #LocationAccessState * @return int * @retval 0 Success - * * Please refer #LocationError for more information. */ int location_get_accessibility_state(LocationAccessState *state); /** - * @brief - * Send command to the server. - * @pre - * #location_init should be called before.\n + * @brief Send command to the server. + * @pre #location_init should be called before.\n * Calling application must have glib or ecore main loop.\n * Calling application must have an active data connection. * @post None. * @param [in] cmd - a #char * @return int * @retval 0 Success - * * Please refer #LocationError for more information. */ int location_send_command(const char *cmd); /** - * @brief - * Set option of server. - * @pre - * #location_init should be called before.\n + * @brief Set option of server. + * @pre #location_init should be called before.\n * Calling application must have glib or ecore main loop.\n * Calling application must have an active data connection. * @post None. @@ -857,7 +284,6 @@ int location_send_command(const char *cmd); * @param [in] option - a #char * @return int * @retval 0 Success - * * Please refer #LocationError for more information. */ int location_set_option(LocationObject *obj, const char *option); diff --git a/packaging/liblbs-location.changes b/packaging/liblbs-location.changes index 950e9ee..d2f7f2f 100644 --- a/packaging/liblbs-location.changes +++ b/packaging/liblbs-location.changes @@ -1,4 +1,4 @@ -[Version] libslp-location_1.3.0 +[Version] libslp-location_1.3.1 [Date] 3 Jun 2016 [Changes] Change service state behavior when GPS/WPS searching mode [Developer] Kyoungjun Sung -- 2.7.4