From: kj7.sung Date: Tue, 26 Apr 2016 04:30:24 +0000 (+0900) Subject: 1. Change replay file path X-Git-Tag: submit/tizen/20160427.074725^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e7f2ceffb10324e7f05e5f5be58d380bf6d1675;p=platform%2Fcore%2Flocation%2Flbs-server-plugin-replay.git 1. Change replay file path 2. Fixed Svace defect 3. Fixed batch file timing issue Change-Id: I9e229042f38f1309c5480d423526e94f648e2612 Signed-off-by: kj7.sung --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c74b2e0..993eb14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) # Set required packages INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED glib-2.0 vconf dlog lbs-server-plugin deviced) +pkg_check_modules(pkgs REQUIRED glib-2.0 vconf dlog lbs-server-plugin deviced libtzplatform-config) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/gps-plugin/include/gps_plugin_debug.h b/gps-plugin/include/gps_plugin_debug.h index be0792f..ac6278d 100644 --- a/gps-plugin/include/gps_plugin_debug.h +++ b/gps-plugin/include/gps_plugin_debug.h @@ -39,7 +39,7 @@ extern "C" { #define DBG_ERR LOG_ERROR #ifdef GPS_DLOG_DEBUG /* Debug mode */ -#define LOG_PLUGIN(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, "[%-40s: %-4d] "fmt, __FILE__, __LINE__, ##args) +#define LOG_PLUGIN(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) #define SECLOG_PLUGIN(dbg_lvl,fmt,args...) SECURE_SLOG(dbg_lvl, TAG_GPS_PLUGIN, "[%-40s: %-4d] "fmt, __FILE__, __LINE__, ##args) #else /* Release(commercial) mode */ #define LOG_PLUGIN(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) diff --git a/gps-plugin/include/setting.h b/gps-plugin/include/setting.h index f2339f7..4436c31 100644 --- a/gps-plugin/include/setting.h +++ b/gps-plugin/include/setting.h @@ -25,8 +25,6 @@ #include #include -#define NMEA_FILE_PATH "/opt/usr/media/lbs-server/replay/" -#define DEFAULT_NMEA_LOG "/etc/lbs-server/replay/nmea_replay.log" typedef enum { REPLAY_OFF = 0, diff --git a/gps-plugin/src/gps_plugin_replay.c b/gps-plugin/src/gps_plugin_replay.c index 95895ff..c5a44a9 100644 --- a/gps-plugin/src/gps_plugin_replay.c +++ b/gps-plugin/src/gps_plugin_replay.c @@ -30,6 +30,7 @@ #include #include +#include #include "gps_plugin_debug.h" #include "nmea_parser.h" @@ -38,8 +39,6 @@ #define REPLAY_NMEA_SET_SIZE 4096 #define REPLAY_NMEA_SENTENCE_SIZE 128 -#define LBS_SERVER_FOLDER "/opt/usr/media/lbs-server" -#define BATCH_LOG LBS_SERVER_FOLDER"/location_batch.log" gps_event_cb g_gps_event_cb = NULL; void *g_user_data = NULL; @@ -114,18 +113,20 @@ void gps_plugin_replay_batch_event(pos_data_t *data, replay_timeout *timer) time_t timestamp; time(×tamp); + const char *batch_path = tzplatform_mkpath(TZ_SYS_MEDIA, "lbs-server/location_batch.log"); if (timer->batch_fd == NULL) { if (timer->batch_mode == BATCH_MODE_ON) { struct stat st = {0}; - if (stat(LBS_SERVER_FOLDER, &st) == -1) { - if (mkdir(LBS_SERVER_FOLDER, 0777) == -1) { + const char *lbs_server_path = tzplatform_mkpath(TZ_SYS_MEDIA, "lbs-server"); + if (stat(lbs_server_path, &st) == -1) { + if (mkdir(lbs_server_path, 0777) == -1) { LOG_PLUGIN(DBG_ERR, "Fail to create lbs-server folder"); return ; } } - timer->batch_fd = fopen(BATCH_LOG, "w+"); + timer->batch_fd = fopen(batch_path, "w+"); if (timer->batch_fd == NULL) { LOG_PLUGIN(DBG_ERR, "Fail to open file [Not available batch_fd]"); return ; @@ -143,7 +144,7 @@ void gps_plugin_replay_batch_event(pos_data_t *data, replay_timeout *timer) ret = fwrite(buf, 1, strlen(buf), timer->batch_fd); if (ret != strlen(buf)) { - LOG_PLUGIN(DBG_ERR, "Fail to write file[%s]", BATCH_LOG); + LOG_PLUGIN(DBG_ERR, "Fail to write file[%s]", batch_path); } (timer->num_of_batch)++ ; @@ -165,6 +166,12 @@ void gps_plugin_replay_batch_event(pos_data_t *data, replay_timeout *timer) gps_event_info_t gps_event; memset(&gps_event, 0, sizeof(gps_event_info_t)); + if (timer->batch_fd != NULL) { + if (fclose(timer->batch_fd) != 0) + LOG_PLUGIN(DBG_ERR, "Fail to close file"); + timer->batch_fd = NULL; + } + gps_event.event_id = GPS_EVENT_REPORT_BATCH; timer->batch_start_time = timestamp; timer->is_flush = FALSE; @@ -181,11 +188,6 @@ void gps_plugin_replay_batch_event(pos_data_t *data, replay_timeout *timer) g_gps_event_cb(&gps_event, g_user_data); timer->num_of_batch = 0; } - - if (timer->batch_fd != NULL) { - fclose(timer->batch_fd); - timer->batch_fd = NULL; - } } } @@ -505,16 +507,18 @@ gboolean gps_plugin_get_nmea_fd(replay_timeout *timer) if (str == NULL) { return FALSE; } - snprintf(replay_file_path, sizeof(replay_file_path), NMEA_FILE_PATH"%s", str); + const char *nmea_file_path = tzplatform_mkpath(TZ_SYS_MEDIA, "lbs-server/replay/"); + snprintf(replay_file_path, sizeof(replay_file_path), "%s%s", nmea_file_path, str); SECLOG_PLUGIN(DBG_ERR, "replay file name : %s", replay_file_path); free(str); timer->fd = fopen(replay_file_path, "r"); if (timer->fd == NULL) { SECLOG_PLUGIN(DBG_ERR, "fopen(%s) failed", replay_file_path); - timer->fd = fopen(DEFAULT_NMEA_LOG, "r"); + const char *default_nmea_log = tzplatform_mkpath(TZ_SYS_RO_ETC, "lbs-server/replay/nmea_replay.log"); + timer->fd = fopen(default_nmea_log, "r"); if (timer->fd == NULL) { - SECLOG_PLUGIN(DBG_ERR, "fopen(%s) failed", DEFAULT_NMEA_LOG); + SECLOG_PLUGIN(DBG_ERR, "fopen(%s) failed", default_nmea_log); return FALSE; } } diff --git a/gps-plugin/src/nmea_parser.c b/gps-plugin/src/nmea_parser.c index b36a5e1..3ebee56 100644 --- a/gps-plugin/src/nmea_parser.c +++ b/gps-plugin/src/nmea_parser.c @@ -301,6 +301,10 @@ static int nmea_parser_gpgsv(char *token[], sv_data_t *sv) for (i = 0; i < iter; i++) { q = (i + 1) * 4; p = i + 4 * (msg_num - 1); + if (p > 31) { + LOG_PLUGIN(DBG_LOW, "Out of bounds"); + return READ_ERROR; + } sv->sat[p].prn = atoi(token[q]); for (j = 0; j < MAX_GPS_NUM_SAT_USED; j++) { if (sv->sat[p].prn == used_sat[j]) { diff --git a/packaging/lbs-server-plugin-replay.spec b/packaging/lbs-server-plugin-replay.spec index 2066e4b..3df890c 100644 --- a/packaging/lbs-server-plugin-replay.spec +++ b/packaging/lbs-server-plugin-replay.spec @@ -1,6 +1,6 @@ Name: lbs-server-plugin-replay Summary: LBS Server plugin library for replay mode -Version: 0.2.3 +Version: 0.2.4 Release: 1 Group: Location/Libraries License: Apache-2.0 @@ -12,6 +12,7 @@ BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(lbs-server-plugin) BuildRequires: pkgconfig(deviced) +BuildRequires: pkgconfig(libtzplatform-config) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig