sync : Fused location 2nd version(August) 18/88718/2
authorkj7.sung <kj7.sung@samsung.com>
Tue, 20 Sep 2016 09:56:40 +0000 (18:56 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Wed, 21 Sep 2016 01:56:52 +0000 (10:56 +0900)
Change-Id: I08a0d458140f15ce35131c36601bb17315dfafc0
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
lbs-server/src/debug_util.h
lbs-server/src/lbs_server.c
module/CMakeLists.txt
module/fused_module.c
module/mock_module.c [deleted file]
module/passive_module.c [new file with mode: 0644]
packaging/lbs-server.changes
packaging/lbs-server.spec

index 01c591315ed527c8b399b5bfc3502924963ca45b..1a75355028324bba3ac93f09f12588e6ac6d515d 100644 (file)
@@ -32,7 +32,7 @@ extern "C" {
 #include <dlog.h>
 #define TAG_GPS_MANAGER                "LOCATION_SERVER_GPS"
 #define TAG_NPS_MANAGER                "LOCATION_SERVER_WPS"
-#define TAG_MOCK_MANAGER       "LOCATION_SERVER_MOK"
+#define TAG_MOCK_MANAGER       "LOCATION_SERVER_MOCK"
 
 #define DBG_LOW                LOG_DEBUG
 #define DBG_INFO       LOG_INFO
index a9bde254033f405eaf3315b8c06f5b135390d140..be1fa54292c484f50b2fcd64a29fdac773ea6fcd 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 f0585b9aba2e2187e7a1f1ae6caa79f0fe7b36e0..d293ccd34cf2b620c9e19b1af029d0e3ac44b237 100644 (file)
@@ -3,6 +3,7 @@ PROJECT(client C)
 
 SET(gps_module "gps")
 SET(nps_module "wps")
+SET(passive_module "passive")
 SET(fused_module "fused")
 
 SET(CLIENT_SRCS_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
@@ -24,8 +25,14 @@ 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)
+
 ADD_LIBRARY(${fused_module} SHARED ${CLIENT_SRCS_DIR}/fused_module.c)
 TARGET_LINK_LIBRARIES(${fused_module} ${module_pkgs_LDFLAGS})
 SET_TARGET_PROPERTIES(${fused_module} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER} CLEAN_DIRECT_OUTPUT 1)
 SET_TARGET_PROPERTIES(${fused_module} PROPERTIES COMPILE_FLAGS ${MODULE_EXTRA_CFLAGS})
-INSTALL(TARGETS ${fused_module} DESTINATION ${LIB_DIR}/location/module)
+INSTALL(TARGETS ${fused_module} DESTINATION ${LIB_DIR}/location/module)
\ No newline at end of file
index d75983ae27381118c9a6f8021031c1738a2e49de..bcfcd0d4a63af09b7ac2fe6f596ddaae402eaa4a 100644 (file)
@@ -113,9 +113,9 @@ static void on_signal_callback(const gchar *sig, GVariant *param, gpointer user_
 //     }
 }
 
-static int start(gpointer handle, guint pos_update_interval, LocModStatusCB status_cb, LocModPositionExtCB pos_cb, LocModSatelliteCB sat_cb, gpointer userdata)
+static int start_gps(gpointer handle, guint pos_update_interval, LocModStatusCB status_cb, LocModPositionExtCB pos_cb, LocModSatelliteCB sat_cb, gpointer userdata)
 {
-       MOD_LOGD("start");
+       MOD_LOGD("start_gps");
        ModFusedData *mod_fused = (ModFusedData *) handle;
        g_return_val_if_fail(mod_fused, LOCATION_ERROR_NOT_AVAILABLE);
 //     g_return_val_if_fail(status_cb, LOCATION_ERROR_NOT_AVAILABLE);
@@ -141,7 +141,44 @@ static int start(gpointer handle, guint pos_update_interval, LocModStatusCB stat
                        MOD_LOGE("Access denied[%d]", ret);
                        return LOCATION_ERROR_NOT_ALLOWED;
                }
-               MOD_LOGE("Fail to start lbs_client_h. Error[%d]", ret);
+               MOD_LOGE("Fail to start_gps lbs_client_h. Error[%d]", ret);
+               lbs_client_destroy(mod_fused->lbs_client);
+               mod_fused->lbs_client = NULL;
+
+               return LOCATION_ERROR_NOT_AVAILABLE;
+       }
+       return LOCATION_ERROR_NONE;
+}
+
+static int start_wps(gpointer handle, LocModStatusCB status_cb, LocModPositionExtCB pos_cb, LocModSatelliteCB sat_cb, gpointer userdata)
+{
+       MOD_LOGD("start_wps");
+       ModFusedData *mod_fused = (ModFusedData *) handle;
+       g_return_val_if_fail(mod_fused, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail(status_cb, LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail(pos_cb, LOCATION_ERROR_NOT_AVAILABLE);
+       MOD_LOGD("---------------------------");
+
+//     mod_fused->status_cb = status_cb;
+       mod_fused->pos_cb = pos_cb;
+       mod_fused->userdata = userdata;
+
+       MOD_LOGD("---------------------------");
+       int ret = LBS_CLIENT_ERROR_NONE;
+       ret = lbs_client_create(LBS_CLIENT_METHOD_NPS , &(mod_fused->lbs_client));
+       if (ret != LBS_CLIENT_ERROR_NONE || !mod_fused->lbs_client) {
+               MOD_LOGE("Fail to create lbs_client_h. Error[%d]", ret);
+               return LOCATION_ERROR_NOT_AVAILABLE;
+       }
+       MOD_LOGD("wps-manger(%p) pos_cb (%p) user_data(%p)", mod_fused, mod_fused->pos_cb, mod_fused->userdata);
+
+       ret = lbs_client_start(mod_fused->lbs_client, 1, LBS_CLIENT_LOCATION_CB | LBS_CLIENT_LOCATION_STATUS_CB, on_signal_callback, mod_fused);
+       if (ret != LBS_CLIENT_ERROR_NONE) {
+               if (ret == LBS_CLIENT_ERROR_ACCESS_DENIED) {
+                       MOD_LOGE("Access denied[%d]", ret);
+                       return LOCATION_ERROR_NOT_ALLOWED;
+               }
+               MOD_LOGE("Fail to start_wps lbs_client_h. Error[%d]", ret);
                lbs_client_destroy(mod_fused->lbs_client);
                mod_fused->lbs_client = NULL;
 
@@ -288,7 +325,8 @@ LOCATION_MODULE_API gpointer init(LocModFusedOps *ops)
        MOD_LOGD("init");
 
        g_return_val_if_fail(ops, NULL);
-       ops->start = start;
+       ops->start_gps = start_gps;
+       ops->start_wps = start_wps;
        ops->stop = stop;
        ops->get_last_position = get_last_position;
 
@@ -322,76 +360,3 @@ LOCATION_MODULE_API void shutdown(gpointer handle)
        mod_fused = NULL;
 }
 
-#if 0
-static void satellite_callback(GVariant *param, void *user_data)
-{
-       ModFusedData *mod_fused = (ModFusedData *)user_data;
-       g_return_if_fail(mod_fused);
-       g_return_if_fail(mod_fused->sat_cb);
-
-       guint idx;
-       guint used_idx;
-       guint *used_prn_array = NULL;
-       gboolean ret = FALSE;
-       int timestamp = 0, satellite_used = 0, satellite_visible = 0;
-
-       LocationSatellite *sat = NULL;
-       GVariant *used_prn = NULL;
-       GVariantIter *used_prn_iter = NULL;
-       GVariant *sat_info = NULL;
-       GVariantIter *sat_iter = NULL;
-       int prn = 0, elev = 0, azim = 0, snr = 0;
-
-       g_variant_get(param, "(iii@ai@a(iiii))", &timestamp, &satellite_used, &satellite_visible, &used_prn, &sat_info);
-       g_variant_get(used_prn, "ai", &used_prn_iter);
-       g_variant_get(sat_info, "a(iiii)", &sat_iter);
-       MOD_LOGD("timestamp [%d], satellite_used [%d], satellite_visible[%d]", timestamp, satellite_used, satellite_visible);
-       int tmp_prn = 0;
-       int num_of_used_prn = g_variant_iter_n_children(used_prn_iter);
-       if (num_of_used_prn > 0) {
-               used_prn_array = (guint *)g_new0(guint, num_of_used_prn);
-               for (idx = 0; idx < num_of_used_prn; idx++) {
-                       ret = g_variant_iter_next(used_prn_iter, "i", &tmp_prn);
-                       if (ret == FALSE)
-                               break;
-                       used_prn_array[idx] = tmp_prn;
-               }
-       }
-       sat = location_satellite_new(satellite_visible);
-
-       sat->timestamp = timestamp;
-       sat->num_of_sat_inview = satellite_visible;
-       sat->num_of_sat_used = satellite_used;
-
-       GVariant *tmp_var = NULL;
-       for (idx = 0; idx < satellite_visible; idx++) {
-               gboolean used = FALSE;
-               tmp_var = g_variant_iter_next_value(sat_iter);
-               g_variant_get(tmp_var, "(iiii)", &prn, &elev, &azim, &snr);
-               if (used_prn_array != NULL) {
-                       for (used_idx = 0; used_idx < satellite_used; used_idx++) {
-                               if (prn == used_prn_array[used_idx]) {
-                                       used = TRUE;
-                                       break;
-                               }
-                       }
-               }
-               location_satellite_set_satellite_details(sat, idx, prn, used, elev, azim, snr);
-               g_variant_unref(tmp_var);
-       }
-
-       mod_fused->sat_cb(TRUE, sat, mod_fused->userdata);
-       location_satellite_free(sat);
-       g_variant_iter_free(used_prn_iter);
-       g_variant_iter_free(sat_iter);
-       g_variant_unref(used_prn);
-       g_variant_unref(sat_info);
-
-
-       if (used_prn_array) {
-               g_free(used_prn_array);
-               used_prn_array = NULL;
-       }
-}
-#endif
-
diff --git a/module/mock_module.c b/module/mock_module.c
deleted file mode 100755 (executable)
index bf33e59..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * 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>
-
-#include "log.h"
-
-#define MOCK_LOCATION_CLEAR_VALUE 999
-
-typedef struct {
-       lbs_client_dbus_h lbs_client;
-       LocModStatusCB mock_status_cb;
-       LocModStatusCB status_cb;
-       LocModPositionExtCB pos_cb;
-       gpointer userdata;
-       gboolean is_started;
-       LocationPosition *last_pos;
-       LocationVelocity *last_vel;
-       LocationAccuracy *last_acc;
-} ModMockData;
-
-typedef enum {
-       LBS_STATUS_ERROR,               /* from lbs-server */
-       LBS_STATUS_UNAVAILABLE,
-       LBS_STATUS_ACQUIRING,
-       LBS_STATUS_AVAILABLE,
-       LBS_STATUS_BATCH,
-       LBS_STATUS_MOCK_SET,    /* from lbs-dbus status for mock location */
-       LBS_STATUS_MOCK_FAIL,
-} LbsStatus;
-
-static void status_callback(GVariant *param, void *user_data)
-{
-       ModMockData *mod_mock = (ModMockData *) user_data;
-       g_return_if_fail(param);
-       g_return_if_fail(mod_mock);
-       g_return_if_fail(mod_mock->status_cb);
-
-       int status = 0, method = 0;
-       g_variant_get(param, "(ii)", &method, &status);
-       MOD_MOCK_LOGD("method(%d) status(%d)", method, status);
-
-       if (method != LBS_CLIENT_METHOD_MOCK)
-               return;
-
-       if (status == LBS_STATUS_AVAILABLE) {
-               MOD_MOCK_LOGD("LBS_STATUS_AVAILABLE : mock_module");
-               mod_mock->status_cb(TRUE, LOCATION_STATUS_3D_FIX, mod_mock->userdata);
-       } else {
-               MOD_LOGD("LBS_STATUS_ACQUIRING/ERROR/UNAVAILABLE. Status[%d]", status);
-               mod_mock->status_cb(FALSE, LOCATION_STATUS_NO_FIX, mod_mock->userdata);
-       }
-}
-
-static void position_callback(GVariant *param, void *user_data)
-{
-       ModMockData *mod_mock = (ModMockData *)user_data;
-       g_return_if_fail(mod_mock);
-       g_return_if_fail(mod_mock->pos_cb);
-
-       int method = 0, fields = 0 , timestamp = 0 , level = 0;
-       double latitude = 0.0, longitude = 0.0, altitude = 0.0, speed = 0.0, direction = 0.0, climb = 0.0, horizontal = 0.0, vertical = 0.0;
-       GVariant *accuracy = NULL;
-
-       g_variant_get(param, "(iiidddddd@(idd))", &method, &fields, &timestamp, &latitude, &longitude, &altitude, &speed, &direction, &climb, &accuracy);
-
-       MOD_MOCK_LOGD("position_callback [method: %d, field: %d]", method, fields);
-       if (method != LBS_CLIENT_METHOD_MOCK) {
-               MOD_LOGD("Method is not LBS_CLIENT_METHOD_MOCK: %d", method);
-               return;
-       }
-
-       g_variant_get(accuracy, "(idd)", &level, &horizontal, &vertical);
-
-       LocationPosition *pos = NULL;
-       LocationVelocity *vel = NULL;
-       LocationAccuracy *acc = NULL;
-
-       pos = location_position_new(timestamp, latitude, longitude, altitude, LOCATION_STATUS_3D_FIX);
-       vel = location_velocity_new(timestamp, speed, direction, climb);
-       acc = location_accuracy_new(LOCATION_ACCURACY_LEVEL_DETAILED, horizontal, vertical);
-
-       mod_mock->pos_cb(TRUE, pos, vel, acc, mod_mock->userdata);
-
-       mod_mock->last_pos = location_position_copy(pos);
-       mod_mock->last_vel = location_velocity_copy(vel);
-       mod_mock->last_acc = location_accuracy_copy(acc);
-
-       location_position_free(pos);
-       location_velocity_free(vel);
-       location_accuracy_free(acc);
-       g_variant_unref(accuracy);
-}
-
-static void on_signal_callback(const gchar *sig, GVariant *param, gpointer user_data)
-{
-       if (!g_strcmp0(sig, "PositionChanged"))
-               position_callback(param, user_data);
-       else if (!g_strcmp0(sig, "StatusChanged"))
-               status_callback(param, user_data);
-       else
-               MOD_MOCK_LOGD("Invaild signal[%s]", sig);
-}
-
-static int start(gpointer handle, LocModStatusCB status_cb, LocModPositionExtCB pos_cb, gpointer userdata)
-{
-       MOD_MOCK_LOGD("ENTER >>>");
-       ModMockData *mod_mock = (ModMockData *) handle;
-       g_return_val_if_fail(mod_mock, LOCATION_ERROR_NOT_AVAILABLE);
-       g_return_val_if_fail(status_cb, LOCATION_ERROR_NOT_AVAILABLE);
-       g_return_val_if_fail(pos_cb, LOCATION_ERROR_NOT_AVAILABLE);
-
-       mod_mock->status_cb = status_cb;
-       mod_mock->pos_cb = pos_cb;
-       mod_mock->userdata = userdata;
-
-       int ret = LBS_CLIENT_ERROR_NONE;
-       if (mod_mock->lbs_client == NULL) {
-               ret = lbs_client_create(LBS_CLIENT_METHOD_MOCK , &(mod_mock->lbs_client));
-               if (ret != LBS_CLIENT_ERROR_NONE || !mod_mock->lbs_client) {
-                       MOD_MOCK_LOGE("Fail to create lbs_client_h. Error[%d]", ret);
-                       return LOCATION_ERROR_NOT_AVAILABLE;
-               }
-       }
-       MOD_MOCK_LOGD("mod_mock(%p) pos_cb(%p) user_data(%p)", mod_mock, mod_mock->pos_cb, mod_mock->userdata);
-
-       ret = lbs_client_start(mod_mock->lbs_client, 1, LBS_CLIENT_LOCATION_CB | LBS_CLIENT_LOCATION_STATUS_CB, on_signal_callback, mod_mock);
-       if (ret != LBS_CLIENT_ERROR_NONE) {
-               if (ret == LBS_CLIENT_ERROR_ACCESS_DENIED) {
-                       MOD_MOCK_LOGE("Access denied[%d]", ret);
-                       return LOCATION_ERROR_NOT_ALLOWED;
-               }
-               MOD_MOCK_LOGE("Fail to start lbs_client_h. Error[%d]", ret);
-               lbs_client_destroy(mod_mock->lbs_client);
-               mod_mock->lbs_client = NULL;
-
-               return LOCATION_ERROR_NOT_AVAILABLE;
-       }
-       MOD_MOCK_LOGD("EXIT <<<");
-
-       return LOCATION_ERROR_NONE;
-}
-
-static int stop(gpointer handle)
-{
-       MOD_MOCK_LOGD("stop");
-       ModMockData *mod_mock = (ModMockData *) handle;
-       g_return_val_if_fail(mod_mock, LOCATION_ERROR_NOT_AVAILABLE);
-       g_return_val_if_fail(mod_mock->lbs_client, LOCATION_ERROR_NOT_AVAILABLE);
-       g_return_val_if_fail(mod_mock->status_cb, LOCATION_ERROR_NOT_AVAILABLE);
-
-       int ret = LBS_CLIENT_ERROR_NONE;
-
-       ret = lbs_client_stop(mod_mock->lbs_client);
-       if (ret != LBS_CLIENT_ERROR_NONE) {
-               MOD_MOCK_LOGE("Fail to stop. Error[%d]", ret);
-               lbs_client_destroy(mod_mock->lbs_client);
-               mod_mock->lbs_client = NULL;
-               return LOCATION_ERROR_NOT_AVAILABLE;
-       }
-
-       ret = lbs_client_destroy(mod_mock->lbs_client);
-       if (ret != LBS_CLIENT_ERROR_NONE) {
-               MOD_MOCK_LOGE("Fail to destroy. Error[%d]", ret);
-               return LOCATION_ERROR_NOT_AVAILABLE;
-       }
-       mod_mock->lbs_client = NULL;
-
-       if (mod_mock->status_cb)
-               mod_mock->status_cb(FALSE, LOCATION_STATUS_NO_FIX, mod_mock->userdata);
-
-       mod_mock->status_cb = NULL;
-       mod_mock->pos_cb = NULL;
-
-       return LOCATION_ERROR_NONE;
-}
-
-static int get_last_position(gpointer handle, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
-{
-       MOD_MOCK_LOGD("get_last_position");
-       ModMockData *mod_mock = (ModMockData *) handle;
-       g_return_val_if_fail(mod_mock, 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);
-
-       *position = NULL;
-       *velocity = NULL;
-       *accuracy = NULL;
-
-       if (mod_mock->last_pos)
-               *position = location_position_copy(mod_mock->last_pos);
-
-       if (mod_mock->last_vel)
-               *velocity = location_velocity_copy(mod_mock->last_vel);
-
-       if (mod_mock->last_acc)
-               *accuracy = location_accuracy_copy(mod_mock->last_acc);
-
-       return LOCATION_ERROR_NONE;
-}
-
-static int set_option(gpointer handle, const char *option)
-{
-       ModMockData *mod_mock = (ModMockData *) handle;
-       g_return_val_if_fail(mod_mock, LOCATION_ERROR_NOT_AVAILABLE);
-       g_return_val_if_fail(option, LOCATION_ERROR_PARAMETER);
-       MOD_MOCK_LOGD("set_option : %s", option);
-
-       int ret = LBS_CLIENT_ERROR_NONE;
-       ret = lbs_set_option(option);
-       if (ret != LBS_AGPS_ERROR_NONE) {
-               MOD_MOCK_LOGE("Fail to lbs_set_option [%d]", ret);
-               return LOCATION_ERROR_NOT_AVAILABLE;
-       }
-
-       return LOCATION_ERROR_NONE;
-}
-
-#if 0
-static int set_position_update_interval(gpointer handle, guint interval)
-{
-       MOD_LOGD("set_position_update_interval [%d]", interval);
-       ModMockData *mod_mock = (ModMockData *) handle;
-       g_return_val_if_fail(mod_mock, LOCATION_ERROR_NOT_AVAILABLE);
-       g_return_val_if_fail(mod_mock->lbs_client, LOCATION_ERROR_NOT_AVAILABLE);
-
-       int ret;
-       ret = lbs_client_set_position_update_interval(mod_mock->lbs_client, interval);
-       if (ret != LBS_CLIENT_ERROR_NONE) {
-               if (ret == LBS_CLIENT_ERROR_ACCESS_DENIED) {
-                       MOD_LOGE("Access denied[%d]", ret);
-                       return LOCATION_ERROR_NOT_ALLOWED;
-               }
-               MOD_LOGE("Failed lbs_client_set_position_update_interval. Error[%d]", ret);
-               return LOCATION_ERROR_NOT_AVAILABLE;
-       }
-
-       return LOCATION_ERROR_NONE;
-}
-#endif
-
-
-/* Tizen 3.0 Mock Location */
-
-static void on_set_mock_location_callback(const gchar *sig, GVariant *param, gpointer userdata)
-{
-       ModMockData *mod_mock = (ModMockData *) userdata;
-       g_return_if_fail(param);
-       g_return_if_fail(mod_mock);
-       g_return_if_fail(mod_mock);
-
-       MOD_MOCK_LOGD("ENTER >>>");
-
-       int method = 0, status = 0;
-       g_variant_get(param, "(ii)", &method, &status);
-       MOD_MOCK_LOGD("mock_module: method(%d) status(%d)", method, status);
-
-       if (method != LBS_CLIENT_METHOD_MOCK) {
-               MOD_MOCK_LOGI("mock_module Invalid(%d)", method);
-               return;
-       }
-
-       if (status == LBS_STATUS_MOCK_FAIL) {   /* LBS_STATUS_BATCH + 2 */
-               MOD_MOCK_LOGD("LBS_STATUS_MOCK_FAIL");
-               mod_mock->mock_status_cb(FALSE, LOCATION_STATUS_MOCK_FAIL, mod_mock->userdata);
-       } else {
-               MOD_MOCK_LOGD("Others. Status[%d]", status); /* Nothing to do */
-       }
-       MOD_MOCK_LOGD("EXIT <<<");
-
-       return;
-}
-
-static int set_mock_location(gpointer handle, LocationPosition *position, LocationVelocity *velocity,
-                                                       LocationAccuracy *accuracy, LocModStatusCB mock_status_cb, gpointer userdata)
-{
-       MOD_MOCK_LOGD("ENTER >>> set_mock_location");
-       ModMockData *mod_mock = (ModMockData *) handle;
-       g_return_val_if_fail(mod_mock, LOCATION_ERROR_NOT_AVAILABLE);
-       g_return_val_if_fail(mock_status_cb, LOCATION_ERROR_NOT_AVAILABLE);
-
-       int ret = LBS_CLIENT_ERROR_NONE;
-
-       if (mod_mock->lbs_client == NULL) {
-               ret = lbs_client_create(LBS_CLIENT_METHOD_MOCK, &(mod_mock->lbs_client));
-               if (ret != LBS_CLIENT_ERROR_NONE || !mod_mock->lbs_client) {
-                       MOD_MOCK_LOGE("Fail to create lbs_client_h. Error[%d]", ret);
-                       return LOCATION_ERROR_NOT_AVAILABLE;
-               }
-       }
-       MOD_MOCK_LOGD("mod_mock(%p)", mod_mock);
-
-       mod_mock->mock_status_cb = mock_status_cb;
-       mod_mock->userdata = userdata;
-
-       ret = lbs_client_set_mock_location_async(mod_mock->lbs_client, LBS_CLIENT_METHOD_MOCK, position->latitude, position->longitude, position->altitude,
-               velocity->speed, velocity->direction, accuracy->horizontal_accuracy, on_set_mock_location_callback, mod_mock);
-
-       if (ret != LBS_CLIENT_ERROR_NONE) {
-               if (ret == LBS_CLIENT_ERROR_ACCESS_DENIED) {
-                       MOD_MOCK_LOGE("Access denied[%d]", ret);
-                       return LOCATION_ERROR_NOT_ALLOWED;
-               }
-               MOD_MOCK_LOGE("Fail to start lbs_client_h. Error[%d]", ret);
-               lbs_client_destroy(mod_mock->lbs_client);
-               mod_mock->lbs_client = NULL;
-
-               return LOCATION_ERROR_NOT_AVAILABLE;
-       }
-
-       return LOCATION_ERROR_NONE;
-}
-
-static int clear_mock_location(gpointer handle,        LocModStatusCB mock_status_cb, gpointer userdata)
-{
-       MOD_MOCK_LOGD("ENTER >>>");
-       ModMockData *mod_mock = (ModMockData *) handle;
-       g_return_val_if_fail(mod_mock, LOCATION_ERROR_NOT_AVAILABLE);
-       g_return_val_if_fail(mock_status_cb, LOCATION_ERROR_NOT_AVAILABLE);
-
-       int ret = LBS_CLIENT_ERROR_NONE;
-
-       if (mod_mock->lbs_client == NULL) {
-               ret = lbs_client_create(LBS_CLIENT_METHOD_MOCK, &(mod_mock->lbs_client));
-               if (ret != LBS_CLIENT_ERROR_NONE || !mod_mock->lbs_client) {
-                       MOD_MOCK_LOGE("Fail to create lbs_client_h. Error[%d]", ret);
-                       return LOCATION_ERROR_NOT_AVAILABLE;
-               }
-       }
-       MOD_MOCK_LOGD("mod_mock(%p)", mod_mock);
-
-       mod_mock->mock_status_cb = mock_status_cb;
-       mod_mock->userdata = userdata;
-
-       ret = lbs_client_set_mock_location_async(mod_mock->lbs_client, LBS_CLIENT_METHOD_MOCK,
-                                                                                       MOCK_LOCATION_CLEAR_VALUE, 0, 0, 0, 0, 0, on_set_mock_location_callback, mod_mock);
-
-       if (ret != LBS_CLIENT_ERROR_NONE) {
-               if (ret == LBS_CLIENT_ERROR_ACCESS_DENIED) {
-                       MOD_MOCK_LOGE("Access denied[%d]", ret);
-                       return LOCATION_ERROR_NOT_ALLOWED;
-               }
-               MOD_MOCK_LOGE("Fail to start lbs_client_h. Error[%d]", ret);
-               lbs_client_destroy(mod_mock->lbs_client);
-               mod_mock->lbs_client = NULL;
-
-               return LOCATION_ERROR_NOT_AVAILABLE;
-       }
-
-       return LOCATION_ERROR_NONE;
-}
-
-LOCATION_MODULE_API gpointer init(LocModMockOps *ops)
-{
-       MOD_MOCK_LOGD("init");
-
-       g_return_val_if_fail(ops, NULL);
-       ops->start = start;
-       ops->stop = stop;
-       ops->get_last_position = get_last_position;
-       ops->set_option = set_option;
-
-       /*
-       ops->start_batch = NULL;
-       ops->stop_batch = NULL;
-       ops->set_position_update_interval = set_position_update_interval;
-       */
-
-       /* Tien 3.0 */
-       ops->set_mock_location = set_mock_location;
-       ops->clear_mock_location = clear_mock_location;
-
-       ModMockData *mod_mock = g_new0(ModMockData, 1);
-       g_return_val_if_fail(mod_mock, NULL);
-
-       return (gpointer) mod_mock;
-}
-
-LOCATION_MODULE_API void shutdown(gpointer handle)
-{
-       MOD_MOCK_LOGD("shutdown");
-       g_return_if_fail(handle);
-       ModMockData *mod_mock = (ModMockData *) handle;
-       if (mod_mock->lbs_client) {
-               lbs_client_stop(mod_mock->lbs_client);
-               lbs_client_destroy(mod_mock->lbs_client);
-               mod_mock->lbs_client = NULL;
-       }
-
-       mod_mock->status_cb = NULL;
-       mod_mock->pos_cb = NULL;
-
-       if (mod_mock->last_pos) location_position_free(mod_mock->last_pos);
-       if (mod_mock->last_vel) location_velocity_free(mod_mock->last_vel);
-       if (mod_mock->last_acc) location_accuracy_free(mod_mock->last_acc);
-
-       mod_mock->last_pos = NULL;
-       mod_mock->last_vel = NULL;
-       mod_mock->last_acc = NULL;
-
-       g_free(mod_mock);
-       mod_mock = NULL;
-}
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 5fc262b130d0c52fa8a74f5e7a7048cdf7c2cf10..8742859e1f1d20fee904c938eecfd57e0ac706f7 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 95816101da0dbfaf0b7c3f6d6d36f210d637f420..111512ad2e3cabc16c37a15192d799e85c41056b 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*
 %{_libdir}/location/module/libfused.so*
 
 %if 0%{?model_build_feature_location_position_wps}