1. Change replay file path 40/67240/2 accepted/tizen/common/20160427.144230 accepted/tizen/ivi/20160428.002609 accepted/tizen/mobile/20160428.004756 accepted/tizen/wearable/20160428.002640 submit/tizen/20160427.074725
authorkj7.sung <kj7.sung@samsung.com>
Tue, 26 Apr 2016 04:30:24 +0000 (13:30 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Wed, 27 Apr 2016 06:59:57 +0000 (15:59 +0900)
2. Fixed Svace defect
3. Fixed batch file timing issue

Change-Id: I9e229042f38f1309c5480d423526e94f648e2612
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
CMakeLists.txt
gps-plugin/include/gps_plugin_debug.h
gps-plugin/include/setting.h
gps-plugin/src/gps_plugin_replay.c
gps-plugin/src/nmea_parser.c
packaging/lbs-server-plugin-replay.spec

index c74b2e0cd31df7c07855976ddf35b02f4933cb3f..993eb1432b54e594bb5de1b8b6dc628b87805d93 100644 (file)
@@ -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}")
index be0792f2ef1d68dfab21ed2ab2da907dc10056d1..ac6278d2fb6416e88bf5de3fec8a55abefc81463 100644 (file)
@@ -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)
index f2339f7799f3ff2a251d721ef106857b7835619a..4436c31433ff6eded0bfaabadffb44bed7308729 100644 (file)
@@ -25,8 +25,6 @@
 #include <vconf.h>
 #include <vconf-internal-location-keys.h>
 
-#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,
index 95895ff04592a990160e33dff101d6fa162ab00c..c5a44a9bbab1566d4d20b6a0f21fbaed10de36a3 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <gps_plugin_intf.h>
 #include <dd-display.h>
+#include <tzplatform_config.h>
 
 #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(&timestamp);
 
+       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;
                }
        }
index b36a5e14a5a5681a6babf8a74c61476c6cfad88f..3ebee56b8b8968694d5045cd2c15f0202f1bb77f 100644 (file)
@@ -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]) {
index 2066e4b3dd3f74ad1639f379efacbf19aadc6423..3df890c80feadae658d84e48ecbb2783a3288e1c 100644 (file)
@@ -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