[ACR-746] Passive Location 83/81083/5 accepted/tizen/3.0/common/20161114.105745 accepted/tizen/3.0/ivi/20161011.044255 accepted/tizen/3.0/mobile/20161015.033405 accepted/tizen/3.0/wearable/20161015.083158 accepted/tizen/common/20160907.154304 accepted/tizen/ivi/20160908.004811 accepted/tizen/mobile/20160908.004706 accepted/tizen/wearable/20160908.004735 submit/tizen/20160907.014728 submit/tizen_3.0_common/20161104.104000 submit/tizen_3.0_ivi/20161010.000003 submit/tizen_3.0_mobile/20161015.000003 submit/tizen_3.0_wearable/20161015.000003
authorkj7.sung <kj7.sung@samsung.com>
Fri, 22 Jul 2016 02:26:25 +0000 (11:26 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Tue, 6 Sep 2016 02:49:50 +0000 (11:49 +0900)
Change-Id: Ie32261b44bec39dc455a28bb8294cdde9ae42f87
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
lbs-server/src/lbs_server.c
module/CMakeLists.txt
module/passive_module.c [new file with mode: 0644]
packaging/lbs-server.changes
packaging/lbs-server.spec

index a9bde25..be1fa54 100755 (executable)
@@ -320,7 +320,7 @@ static void __nps_callback(void *arg, const Plugin_LocationInfo *location, const
 
        if (!location) {
                LOG_NPS(DBG_LOW, "NULL is returned from plugin...");
-               nps_set_status(lbs_server , LBS_STATUS_ACQUIRING);
+               nps_set_status(lbs_server, LBS_STATUS_ACQUIRING);
                return;
        }
 
index 02d8964..22647de 100644 (file)
@@ -3,6 +3,7 @@ PROJECT(client C)
 
 SET(gps_module "gps")
 SET(nps_module "wps")
+SET(passive_module "passive")
 
 SET(CLIENT_SRCS_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
 SET(module_pkgs_LDFLAGS "${module_pkgs_LDFLAGS} -ldl")
@@ -25,3 +26,9 @@ IF (ENABLE_WPS)
        INSTALL(TARGETS ${nps_module} DESTINATION ${LIB_DIR}/location/module)
 ENDIF (ENABLE_WPS)
 
+ADD_LIBRARY(${passive_module} SHARED ${CLIENT_SRCS_DIR}/passive_module.c)
+TARGET_LINK_LIBRARIES(${passive_module} ${module_pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${passive_module} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER} CLEAN_DIRECT_OUTPUT 1)
+SET_TARGET_PROPERTIES(${passive_module} PROPERTIES COMPILE_FLAGS ${MODULE_EXTRA_CFLAGS})
+
+INSTALL(TARGETS ${passive_module} DESTINATION ${LIB_DIR}/location/module)
diff --git a/module/passive_module.c b/module/passive_module.c
new file mode 100644 (file)
index 0000000..7adfba6
--- /dev/null
@@ -0,0 +1,266 @@
+/*
+ * lbs-server
+ *
+ * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
+ *          Genie Kim <daejins.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <vconf.h>
+#include <vconf-internal-location-keys.h>
+#include <location-module.h>
+
+#include <dlfcn.h>
+#include <lbs_dbus_client.h>
+#include <lbs_agps.h>
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "log.h"
+
+#define MAX_GPS_LOC_ITEM       7
+#define MAX_NPS_LOC_ITEM       6
+
+typedef struct {
+       gpointer userdata;
+} ModPassiveData;
+
+static int get_last_position(gpointer handle, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
+{
+       MOD_LOGD("get_last_position");
+       ModPassiveData *mod_passive = (ModPassiveData *) handle;
+       g_return_val_if_fail(mod_passive, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
+
+       int timestamp = 0;
+       char location[128] = {0,};
+       char *last_location[MAX_GPS_LOC_ITEM] = {0,};
+       char *last = NULL;
+       char *str = NULL;
+       double longitude = 0.0, latitude = 0.0, altitude = 0.0;
+       double speed = 0.0, direction = 0.0;
+       double hor_accuracy = 0.0, ver_accuracy = 0.0;
+       int index = 0;
+       LocationStatus status = LOCATION_STATUS_NO_FIX;
+       LocationAccuracyLevel level = LOCATION_ACCURACY_LEVEL_NONE;
+
+       *position = NULL;
+       *velocity = NULL;
+       *accuracy = NULL;
+
+       if (vconf_get_int(VCONFKEY_LOCATION_LAST_GPS_TIMESTAMP, &timestamp)) {
+               MOD_LOGD("Error to get VCONFKEY_LOCATION_LAST_GPS_TIMESTAMP");
+               return LOCATION_ERROR_NOT_AVAILABLE;
+       } else {
+               if (timestamp != 0) {
+                       if (vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_LATITUDE, &latitude) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_LONGITUDE, &longitude) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_ALTITUDE, &altitude) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_SPEED, &speed) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_DIRECTION, &direction) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_HOR_ACCURACY, &hor_accuracy) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_VER_ACCURACY, &ver_accuracy)) {
+                               return LOCATION_ERROR_NOT_AVAILABLE;
+                       }
+               } else {
+                       if (vconf_get_int(VCONFKEY_LOCATION_NV_LAST_GPS_TIMESTAMP, &timestamp))
+                               return LOCATION_ERROR_NOT_AVAILABLE;
+
+                       str = vconf_get_str(VCONFKEY_LOCATION_NV_LAST_GPS_LOCATION);
+                       if (str == NULL)
+                               return LOCATION_ERROR_NOT_AVAILABLE;
+
+                       snprintf(location, sizeof(location), "%s", str);
+                       free(str);
+
+                       index = 0;
+                       last_location[index] = (char *)strtok_r(location, ";", &last);
+                       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 (timestamp)
+               status = LOCATION_STATUS_3D_FIX;
+       else
+               return LOCATION_ERROR_NOT_AVAILABLE;
+
+       level = LOCATION_ACCURACY_LEVEL_DETAILED;
+       *position = location_position_new(timestamp, latitude, longitude, altitude, status);
+       *velocity = location_velocity_new((guint) timestamp, speed, direction, 0.0);
+       *accuracy = location_accuracy_new(level, hor_accuracy, ver_accuracy);
+
+       return LOCATION_ERROR_NONE;
+}
+
+static int get_last_wps_position(gpointer handle, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
+{
+       MOD_LOGD("get_last_wps_position");
+       ModPassiveData *mod_passive = (ModPassiveData *) handle;
+       g_return_val_if_fail(mod_passive, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
+
+       int timestamp = 0;
+       char location[128] = {0,};
+       char *last_location[MAX_NPS_LOC_ITEM] = {0,};
+       char *last = NULL;
+       char *str = NULL;
+       double latitude = 0.0, longitude = 0.0, altitude = 0.0;
+       double speed = 0.0, direction = 0.0;
+       double hor_accuracy = 0.0;
+       int index = 0;
+       LocationStatus status = LOCATION_STATUS_NO_FIX;
+       LocationAccuracyLevel level = LOCATION_ACCURACY_LEVEL_NONE;
+
+       *position = NULL;
+       *velocity = NULL;
+       *accuracy = NULL;
+
+       if (vconf_get_int(VCONFKEY_LOCATION_LAST_WPS_TIMESTAMP, &timestamp)) {
+               MOD_LOGD("Error to get VCONFKEY_LOCATION_LAST_WPS_TIMESTAMP");
+               return LOCATION_ERROR_NOT_AVAILABLE;
+       } else {
+               if (timestamp != 0) {
+                       if (vconf_get_int(VCONFKEY_LOCATION_LAST_WPS_TIMESTAMP, &timestamp) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_WPS_LATITUDE, &latitude) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_WPS_LONGITUDE, &longitude) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_WPS_ALTITUDE, &altitude) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_WPS_SPEED, &speed) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_WPS_DIRECTION, &direction) ||
+                               vconf_get_dbl(VCONFKEY_LOCATION_LAST_WPS_HOR_ACCURACY, &hor_accuracy)) {
+                               return LOCATION_ERROR_NOT_AVAILABLE;
+                       }
+               } else {
+                       if (vconf_get_int(VCONFKEY_LOCATION_NV_LAST_WPS_TIMESTAMP, &timestamp)) {
+                               MOD_LOGD("Last timestamp failed");
+                               return LOCATION_ERROR_NOT_AVAILABLE;
+                       }
+                       str = vconf_get_str(VCONFKEY_LOCATION_NV_LAST_WPS_LOCATION);
+                       if (str == NULL) {
+                               MOD_LOGD("Last wps is null");
+                               return LOCATION_ERROR_NOT_AVAILABLE;
+                       }
+                       snprintf(location, sizeof(location), "%s", str);
+                       free(str);
+
+                       index = 0;
+                       last_location[index] = (char *)strtok_r(location, ";", &last);
+                       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;
+                               default:
+                                       break;
+                               }
+                               if (++index == MAX_NPS_LOC_ITEM) break;
+                               last_location[index] = (char *)strtok_r(NULL, ";", &last);
+                       }
+               }
+       }
+
+       if (timestamp)
+               status = LOCATION_STATUS_3D_FIX;
+       else
+               return LOCATION_ERROR_NOT_AVAILABLE;
+
+       level = LOCATION_ACCURACY_LEVEL_STREET;
+       *position = location_position_new((guint) timestamp, latitude, longitude, altitude, status);
+       *velocity = location_velocity_new((guint) timestamp, speed, direction, 0.0);
+       *accuracy = location_accuracy_new(level, hor_accuracy, -1.0);
+
+       return LOCATION_ERROR_NONE;
+}
+
+LOCATION_MODULE_API gpointer init(LocModPassiveOps *ops)
+{
+       MOD_LOGD("init");
+
+       g_return_val_if_fail(ops, NULL);
+       ops->get_last_position = get_last_position;
+       ops->get_last_wps_position = get_last_wps_position;
+
+       ModPassiveData *mod_passive = g_new0(ModPassiveData, 1);
+       g_return_val_if_fail(mod_passive, NULL);
+
+       mod_passive->userdata = NULL;
+
+       return (gpointer) mod_passive;
+}
+
+LOCATION_MODULE_API void shutdown(gpointer handle)
+{
+       MOD_LOGD("shutdown");
+       g_return_if_fail(handle);
+       ModPassiveData *mod_passive = (ModPassiveData *) handle;
+
+       g_free(mod_passive);
+       mod_passive = NULL;
+
+}
index 5fc262b..8742859 100644 (file)
@@ -1,3 +1,9 @@
+[Version]      lbs-server_1.0.8
+[Date]         6 Sep 2016
+[Changes]      Passive location.
+[Developer]    Kyoungjun Sung <kj7.sung@samsung.com>
+
+================================================================================
 [Version]      lbs-server_1.0.7
 [Date]         16 Aug 2016
 [Changes]      Mock location.
index b230b91..515ece5 100644 (file)
@@ -1,6 +1,6 @@
 Name:    lbs-server
 Summary: LBS Server for Tizen
-Version: 1.0.7
+Version: 1.0.8
 Release: 1
 Group:   Location/Service
 License: Apache-2.0
@@ -126,6 +126,7 @@ rm -rf %{buildroot}
 %files -n location-lbs-server
 %manifest location-lbs-server.manifest
 %{_libdir}/location/module/libgps.so*
+%{_libdir}/location/module/libpassive.so*
 
 %if 0%{?model_build_feature_location_position_wps}
 %{_libdir}/location/module/libwps.so*