Fixed SVACE defects. 94/54894/1 accepted/tizen/mobile/20151221.102034 accepted/tizen/tv/20151221.101838 accepted/tizen/wearable/20151221.102022 submit/tizen/20151221.085557 submit/tizen_common/20151229.144031 submit/tizen_common/20151229.154718
authorYoung-Ae Kang <youngae.kang@samsung.com>
Fri, 18 Dec 2015 11:43:04 +0000 (20:43 +0900)
committerYoung-Ae Kang <youngae.kang@samsung.com>
Fri, 18 Dec 2015 11:43:31 +0000 (20:43 +0900)
Change-Id: I076e156281d1a3f6e4b8939804c1b5b8f978fdfa

lbs-server/src/last_position.c [changed mode: 0644->0755]
lbs-server/src/lbs_server.c
lbs-server/src/server.c
module/gps_module.c

old mode 100644 (file)
new mode 100755 (executable)
index b876459..1da5dbc
@@ -97,22 +97,37 @@ void gps_get_last_position(pos_data_t *last_pos)
        snprintf(location, sizeof(location), "%s", str);
        free(str);
 
+       index = 0;
        last_location[index] = (char *)strtok_r(location, ";", &last);
-       while (last_location[index++] != NULL) {
-               if (index == MAX_GPS_LOC_ITEM)
-                       break;
+       while (last_location[index] != NULL) {
+               switch (index) {
+                       case 0:
+                               last_pos->latitude = strtod(last_location[index], NULL);
+                               break;
+                       case 1:
+                               last_pos->longitude = strtod(last_location[index], NULL);
+                               break;
+                       case 2:
+                               last_pos->altitude = strtod(last_location[index], NULL);
+                               break;
+                       case 3:
+                               last_pos->speed = strtod(last_location[index], NULL);
+                               break;
+                       case 4:
+                               last_pos->bearing = strtod(last_location[index], NULL);
+                               break;
+                       case 5:
+                               last_pos->hor_accuracy = strtod(last_location[index], NULL);
+                               break;
+                       case 6:
+                               last_pos->ver_accuracy = strtod(last_location[index], NULL);
+                               break;
+                       default:
+                               break;
+               }
+               if (++index == MAX_GPS_LOC_ITEM) break;
                last_location[index] = (char *)strtok_r(NULL, ";", &last);
        }
-       index = 0;
-
-       last_pos->timestamp = timestamp;
-       last_pos->latitude = strtod(last_location[index++], NULL);
-       last_pos->longitude = strtod(last_location[index++], NULL);
-       last_pos->altitude = strtod(last_location[index++], NULL);
-       last_pos->speed = strtod(last_location[index++], NULL);
-       last_pos->bearing = strtod(last_location[index++], NULL);
-       last_pos->hor_accuracy = strtod(last_location[index++], NULL);
-       last_pos->ver_accuracy = strtod(last_location[index], NULL);
 
        LOG_GPS(DBG_LOW, "get_last_position[%d]", last_pos->timestamp);
 }
index b605c00..91e0d43 100644 (file)
@@ -1207,21 +1207,34 @@ static void nps_get_last_position(lbs_server_s *lbs_server_nps)
        free(str);
 
        last_location[index] = (char *)strtok_r(location, ";", &last);
-       while (last_location[index++] != NULL) {
-               if (index == MAX_NPS_LOC_ITEM)
-                       break;
-               last_location[index] = (char *)strtok_r(NULL, ";", &last);
-       }
-       index = 0;
-
        lbs_server_nps->last_pos.timestamp = timestamp;
-       lbs_server_nps->last_pos.latitude = strtod(last_location[index++], NULL);
-       lbs_server_nps->last_pos.longitude = strtod(last_location[index++], NULL);
-       lbs_server_nps->last_pos.altitude = strtod(last_location[index++], NULL);
-       lbs_server_nps->last_pos.speed = strtod(last_location[index++], NULL);
-       lbs_server_nps->last_pos.direction = strtod(last_location[index++], NULL);
-       lbs_server_nps->last_pos.hor_accuracy = strtod(last_location[index], NULL);
 
+       while (last_location[index] != NULL) {
+               switch (index) {
+                       case 0:
+                               lbs_server_nps->last_pos.latitude = strtod(last_location[index], NULL);
+                               break;
+                       case 1:
+                               lbs_server_nps->last_pos.longitude = strtod(last_location[index], NULL);
+                               break;
+                       case 2:
+                               lbs_server_nps->last_pos.altitude = strtod(last_location[index], NULL);
+                               break;
+                       case 3:
+                               lbs_server_nps->last_pos.speed = strtod(last_location[index], NULL);
+                               break;
+                       case 4:
+                               lbs_server_nps->last_pos.direction = strtod(last_location[index], NULL);
+                               break;
+                       case 5:
+                               lbs_server_nps->last_pos.hor_accuracy = strtod(last_location[index], NULL);
+                               break;
+                       default:
+                               break;
+               }
+               if (++index == MAX_NPS_LOC_ITEM) break;
+               last_location[index] = (char *)strtok_r(NULL, ";", &last);
+       }
        LOG_NPS(DBG_LOW, "get nps_last_position timestamp : %d", lbs_server_nps->last_pos.timestamp);
 }
 
index db42efd..1a38ca4 100644 (file)
@@ -1182,6 +1182,8 @@ static gps_server_t *_initialize_gps_data(void)
 
 static void _deinitialize_gps_data(void)
 {
+       if (g_gps_server == NULL) return;
+
        if (g_gps_server->pos_data != NULL) {
                free(g_gps_server->pos_data);
                g_gps_server->pos_data = NULL;
@@ -1206,10 +1208,8 @@ static void _deinitialize_gps_data(void)
                g_gps_server->nmea_data = NULL;
        }
 
-       if (g_gps_server != NULL) {
-               free(g_gps_server);
-               g_gps_server = NULL;
-       }
+       free(g_gps_server);
+       g_gps_server = NULL;
 }
 
 int initialize_server(int argc, char **argv)
index 61ee823..48a06b7 100644 (file)
@@ -146,12 +146,6 @@ static void satellite_callback(GVariant *param, void *user_data)
        }
 }
 
-#if 0
-static void nmea_callback(GeoclueNmea *nmea, int timestamp, char *data, gpointer userdata)
-{
-}
-#endif
-
 static void position_callback(GVariant *param, void *user_data)
 {
        MOD_LOGD("position_callback");
@@ -279,8 +273,8 @@ static int start(gpointer handle, guint pos_update_interval, LocModStatusCB stat
                MOD_LOGE("Fail to create lbs_client_h. Error[%d]", ret);
                return LOCATION_ERROR_NOT_AVAILABLE;
        }
-       MOD_LOGD("gps-manger(%x)", gps_manager);
-       MOD_LOGD("pos_cb (%x), user_data(%x)", gps_manager->pos_cb, gps_manager->userdata);
+       MOD_LOGD("gps-manger(%p)", gps_manager);
+       MOD_LOGD("pos_cb (%p), user_data(%p)", gps_manager->pos_cb, gps_manager->userdata);
 
        ret = lbs_client_start(gps_manager->lbs_client, pos_update_interval, LBS_CLIENT_LOCATION_CB | LBS_CLIENT_LOCATION_STATUS_CB | LBS_CLIENT_SATELLITE_CB | LBS_CLIENT_NMEA_CB, on_signal_callback, gps_manager);
        if (ret != LBS_CLIENT_ERROR_NONE) {
@@ -430,24 +424,37 @@ static int get_last_position(gpointer handle, LocationPosition **position, Locat
                        snprintf(location, sizeof(location), "%s", str);
                        free(str);
 
+                       index = 0;
                        last_location[index] = (char *)strtok_r(location, ";", &last);
-                       while (last_location[index++] != NULL) {
-                               if (index == MAX_GPS_LOC_ITEM)
-                                       break;
+                       while (last_location[index] != NULL) {
+                               switch (index) {
+                                       case 0:
+                                               latitude = strtod(last_location[index], NULL);
+                                               break;
+                                       case 1:
+                                               longitude = strtod(last_location[index], NULL);
+                                               break;
+                                       case 2:
+                                               altitude = strtod(last_location[index], NULL);
+                                               break;
+                                       case 3:
+                                               speed = strtod(last_location[index], NULL);
+                                               break;
+                                       case 4:
+                                               direction = strtod(last_location[index], NULL);
+                                               break;
+                                       case 5:
+                                               hor_accuracy = strtod(last_location[index], NULL);
+                                               break;
+                                       case 6:
+                                               ver_accuracy = strtod(last_location[index], NULL);
+                                               break;
+                                       default:
+                                               break;
+                               }
+                               if (++index == MAX_GPS_LOC_ITEM) break;
                                last_location[index] = (char *)strtok_r(NULL, ";", &last);
                        }
-                       if (index != MAX_GPS_LOC_ITEM) {
-                               return LOCATION_ERROR_NOT_AVAILABLE;
-                       }
-                       index = 0;
-
-                       latitude = strtod(last_location[index++], NULL);
-                       longitude = strtod(last_location[index++], NULL);
-                       altitude = strtod(last_location[index++], NULL);
-                       speed = strtod(last_location[index++], NULL);
-                       direction = strtod(last_location[index++], NULL);
-                       hor_accuracy = strtod(last_location[index++], NULL);
-                       ver_accuracy = strtod(last_location[index], NULL);
                }
        }