From 0e0e40cd412dc0b4700d339716e8e45d51f2ef9b Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Mon, 25 Sep 2017 13:08:20 +0900 Subject: [PATCH] batch : Fix for emulator - batch changed to dbus (file logging removed) Change-Id: Ibb90476e895520c6bb95604bd4c1d5e61f1701bc Signed-off-by: kj7.sung --- location/manager/location-batch.c | 121 ++++---------------------------------- location/manager/location-batch.h | 3 - location/manager/location-gps.c | 5 +- location/module/location-module.h | 2 +- packaging/liblbs-location.spec | 2 +- 5 files changed, 16 insertions(+), 117 deletions(-) diff --git a/location/manager/location-batch.c b/location/manager/location-batch.c index d4acd47..cfd532f 100644 --- a/location/manager/location-batch.c +++ b/location/manager/location-batch.c @@ -43,88 +43,6 @@ location_batch_new(int num_of_location) return batch; } -EXPORT_API gboolean -location_set_batch_parse_details(LocationBatch *batch, char *location_info, int i) -{ - g_return_val_if_fail(batch, FALSE); - g_return_val_if_fail(batch->batch_data, FALSE); - - char location[128] = {0,}; - char *last_location[MAX_BATCH_ITEM] = {0,}; - char *last = NULL; - int index = 0; - - snprintf(location, sizeof(location), "%s", location_info); - - last_location[index] = (char *)strtok_r(location, ";", &last); - while (last_location[index] != NULL) { - switch (index) { - case 0: - batch->batch_data[i].timestamp = strtod(last_location[index], NULL); - break; - case 1: - batch->batch_data[i].latitude = strtod(last_location[index], NULL); - break; - case 2: - batch->batch_data[i].longitude = strtod(last_location[index], NULL); - break; - case 3: - batch->batch_data[i].altitude = strtod(last_location[index], NULL); - break; - case 4: - batch->batch_data[i].speed = strtod(last_location[index], NULL); - break; - case 5: - batch->batch_data[i].direction = strtod(last_location[index], NULL); - break; - case 6: - batch->batch_data[i].horizontal_accuracy = strtod(last_location[index], NULL); - break; - case 7: - batch->batch_data[i].vertical_accuracy = strtod(last_location[index], NULL); - break; - default: - break; - } - if (++index == MAX_BATCH_ITEM) break; - last_location[index] = (char *)strtok_r(NULL, ";", &last); - } - - return TRUE; -} - -EXPORT_API LocationBatch * -location_get_batch_file(int num_of_location) -{ - LOCATION_LOGD("location_get_batch_file [num_of_location = %d]", num_of_location); - LocationBatch *batch = location_batch_new(num_of_location); - batch->num_of_location = num_of_location; - - const char *batch_path = tzplatform_mkpath(TZ_SYS_MEDIA, "lbs-server/location_batch.log"); - FILE *fd = fopen(batch_path, "r"); - - if (fd != NULL) { - char buf[BATCH_SENTENCE_SIZE] = { 0, }; - int i = 0; - - for (i = 0; i < num_of_location; i++) { - if (fgets(buf, BATCH_SENTENCE_SIZE, fd) != NULL) - location_set_batch_parse_details(batch, buf, i); - else - LOCATION_LOGE("Batch fgets failed"); - } - - if (fd != 0) { - if (fclose(fd) != 0) - LOCATION_LOGE("Batch fclose failed"); - fd = NULL; - } - } else { - LOCATION_LOGE("Batch fopen failed. fd is NULL"); - } - return batch; -} - #if defined(TIZEN_DEVICE) EXPORT_API gboolean location_set_sensor_batch(LocationBatch *batch, sensor_event_s *event) { @@ -160,28 +78,18 @@ location_batch_copy(const LocationBatch *batch) int i = 0; for (i = 0 ; i < batch_dup->num_of_location; i++) location_set_batch_details(batch_dup, i, - batch->batch_data[i].latitude, - batch->batch_data[i].longitude, - batch->batch_data[i].altitude, - batch->batch_data[i].speed, - batch->batch_data[i].direction, - batch->batch_data[i].horizontal_accuracy, - batch->batch_data[i].vertical_accuracy, - batch->batch_data[i].timestamp); + batch->batch_data[i].latitude, batch->batch_data[i].longitude, batch->batch_data[i].altitude, + batch->batch_data[i].speed, batch->batch_data[i].direction, + batch->batch_data[i].horizontal_accuracy, batch->batch_data[i].vertical_accuracy, + batch->batch_data[i].timestamp); + return batch_dup; } EXPORT_API gboolean -location_get_batch_details(const LocationBatch *batch, - guint index, - gdouble *latitude, - gdouble *longitude, - gdouble *altitude, - gdouble *speed, - gdouble *direction, - gdouble *h_accuracy, - gdouble *v_accuracy, - guint *timestamp) +location_get_batch_details(const LocationBatch *batch, guint index, + gdouble *latitude, gdouble *longitude, gdouble *altitude, + gdouble *speed, gdouble *direction, gdouble *h_accuracy, gdouble *v_accuracy, guint *timestamp) { g_return_val_if_fail(batch, FALSE); g_return_val_if_fail(latitude, FALSE); @@ -207,16 +115,9 @@ location_get_batch_details(const LocationBatch *batch, } EXPORT_API gboolean -location_set_batch_details(LocationBatch *batch, - guint index, - gdouble latitude, - gdouble longitude, - gdouble altitude, - gdouble speed, - gdouble direction, - gdouble h_accuracy, - gdouble v_accuracy, - guint timestamp) +location_set_batch_details(LocationBatch *batch, guint index, + gdouble latitude, gdouble longitude, gdouble altitude, + gdouble speed, gdouble direction, gdouble h_accuracy, gdouble v_accuracy, guint timestamp) { g_return_val_if_fail(batch, FALSE); g_return_val_if_fail(batch->batch_data, FALSE); diff --git a/location/manager/location-batch.h b/location/manager/location-batch.h index 6f17d83..02b149f 100644 --- a/location/manager/location-batch.h +++ b/location/manager/location-batch.h @@ -61,7 +61,6 @@ struct _LocationBatch { LocationBatch *location_batch_new(int num_of_location); -gboolean location_set_batch_parse_details(LocationBatch *batch, char *location_info, int i); gboolean location_get_batch_details(const LocationBatch *batch, guint index, gdouble *latitude, gdouble *longitude, gdouble *altitude, gdouble *speed, gdouble *direction, gdouble *h_accuracy, gdouble *v_accuracy, guint *timestamp); @@ -69,8 +68,6 @@ gboolean location_set_batch_details(LocationBatch *batch, guint index, gdouble l LocationBatch *location_batch_copy(const LocationBatch *batch); -LocationBatch *location_get_batch_file(int num_of_location); - void location_batch_free(LocationBatch *batch); #ifdef TIZEN_DEVICE diff --git a/location/manager/location-gps.c b/location/manager/location-gps.c index 7991c0f..9372b82 100644 --- a/location/manager/location-gps.c +++ b/location/manager/location-gps.c @@ -207,8 +207,9 @@ gps_location_cb(gboolean enabled, LocationPosition *pos, LocationVelocity *vel, #ifndef TIZEN_DEVICE static void -gps_batch_cb(gboolean enabled, guint num_of_location, gpointer self) +gps_batch_cb(gboolean enabled, guint num_of_location, LocationBatch *batch, gpointer self) { + LOC_FUNC_LOG g_return_if_fail(self); LocationGpsPrivate *priv = GET_PRIVATE(self); g_return_if_fail(priv); @@ -216,7 +217,7 @@ gps_batch_cb(gboolean enabled, guint num_of_location, gpointer self) if (priv->batch != NULL) location_batch_free(priv->batch); - priv->batch = location_get_batch_file(num_of_location); + priv->batch = location_batch_copy(batch); g_signal_emit(self, signals[BATCH_UPDATED], 0, num_of_location); } diff --git a/location/module/location-module.h b/location/module/location-module.h index cb4b2a3..3fbb172 100644 --- a/location/module/location-module.h +++ b/location/module/location-module.h @@ -57,7 +57,7 @@ typedef void (*LocModPositionExtCB)(gboolean enabled, LocationPosition *position /** * @brief This represents a batch callback function for a plug-in. */ -typedef void (*LocModBatchExtCB)(gboolean enabled, guint num_of_location, gpointer userdata); +typedef void (*LocModBatchExtCB)(gboolean enabled, guint num_of_location, LocationBatch *batch, gpointer userdata); /** * @brief This represents a velocity callback function for a plug-in. diff --git a/packaging/liblbs-location.spec b/packaging/liblbs-location.spec index dddc78c..f411277 100755 --- a/packaging/liblbs-location.spec +++ b/packaging/liblbs-location.spec @@ -1,6 +1,6 @@ Name: liblbs-location Summary: Location Based Service Library -Version: 1.4.3 +Version: 1.4.4 Release: 1 Group: Location/Libraries License: Apache-2.0 -- 2.7.4