From 3daf58ebb43eaa120f4d21666e821c9256b47d33 Mon Sep 17 00:00:00 2001 From: "jk7744.park" Date: Tue, 8 Sep 2015 22:25:29 +0900 Subject: [PATCH] tizen 2.3.1 release --- AUTHORS | 2 +- Makefile.am | 3 +- configure.ac | 13 +- debian/changelog | 103 ------- debian/compat | 1 - debian/control | 19 -- debian/copyright | 0 debian/dirs | 0 debian/docs | 0 debian/libslp-lbs-plugin-replay.install.in | 3 - debian/libslp-lbs-plugin-replay.postinst.in | 13 - debian/rules | 128 --------- {replay-plugin => gps-plugin}/Makefile.am | 12 +- gps-plugin/include/gps_plugin_debug.h | 53 ++++ .../include/nmea_parser.h | 8 +- {replay-plugin => gps-plugin}/include/setting.h | 23 +- .../src/gps_plugin_replay.c | 320 ++++++++++++++++++--- {replay-plugin => gps-plugin}/src/nmea_parser.c | 87 +++--- {replay-plugin => gps-plugin}/src/setting.c | 8 +- libslp-lbsplugin-replay.manifest | 8 + libslp-xpsplugin-replay.manifest | 5 + ...in-replay.spec => libslp-lbsplugin-replay.spec} | 25 +- xps-plugin/Makefile.am | 15 + .../include/geoclue_plugin_debug.h | 22 +- xps-plugin/src/geoclue_xps_plugin_replay.c | 271 +++++++++++++++++ xps-plugin/src/geoclue_xps_plugin_test.c | 271 +++++++++++++++++ 26 files changed, 1017 insertions(+), 396 deletions(-) delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/dirs delete mode 100644 debian/docs delete mode 100644 debian/libslp-lbs-plugin-replay.install.in delete mode 100644 debian/libslp-lbs-plugin-replay.postinst.in delete mode 100755 debian/rules rename {replay-plugin => gps-plugin}/Makefile.am (70%) create mode 100644 gps-plugin/include/gps_plugin_debug.h rename {replay-plugin => gps-plugin}/include/nmea_parser.h (74%) rename {replay-plugin => gps-plugin}/include/setting.h (70%) rename {replay-plugin => gps-plugin}/src/gps_plugin_replay.c (61%) mode change 100644 => 100755 rename {replay-plugin => gps-plugin}/src/nmea_parser.c (82%) rename {replay-plugin => gps-plugin}/src/setting.c (86%) create mode 100644 libslp-lbsplugin-replay.manifest create mode 100644 libslp-xpsplugin-replay.manifest rename packaging/{libslp-lbs-plugin-replay.spec => libslp-lbsplugin-replay.spec} (55%) create mode 100755 xps-plugin/Makefile.am rename replay-plugin/include/gps_plugin_debug.h => xps-plugin/include/geoclue_plugin_debug.h (59%) mode change 100644 => 100755 create mode 100755 xps-plugin/src/geoclue_xps_plugin_replay.c create mode 100755 xps-plugin/src/geoclue_xps_plugin_test.c diff --git a/AUTHORS b/AUTHORS index cc7be1c..a879250 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,3 @@ Youngae Kang -Yunhan Kim +Minjune Kim Genie Kim diff --git a/Makefile.am b/Makefile.am index 67c6e73..9ca34b2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,4 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = . replay-plugin +SUBDIRS = . gps-plugin +#SUBDIRS = . gps-plugin xps-plugin diff --git a/configure.ac b/configure.ac index e6605ad..a1a4864 100644 --- a/configure.ac +++ b/configure.ac @@ -5,6 +5,7 @@ AC_PREREQ(2.61) AC_INIT([libslp-lbs-plugin-replay], [0.1], [daejins.kim@samsung.com]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([foreign -Wall -Werror]) +AC_CONFIG_HEADER([config.h]) AC_CONFIG_MACRO_DIR([m4]) ###### Checks for programs. @@ -19,10 +20,18 @@ AC_PROG_LN_S AC_PROG_RANLIB ###### Checks for libraries. -PKG_CHECK_MODULES(GPS_MANAGER_PLUGIN, gps-manager-plugin) +PKG_CHECK_MODULES(DEVICED, deviced) +AC_SUBST(DEVICED_CFLAGS) +AC_SUBST(DEVICED_LIBS) + +PKG_CHECK_MODULES(GPS_MANAGER_PLUGIN, lbs-server-plugin) AC_SUBST(GPS_MANAGER_PLUGIN_CFLAGS) AC_SUBST(GPS_MANAGER_PLUGIN_LIBS) +#PKG_CHECK_MODULES(GEOCLUE_XPS_PLUGIN, geoclue-xps-plugin) +#AC_SUBST(GEOCLUE_XPS_PLUGIN_CFLAGS) +#AC_SUBST(GEOCLUE_XPS_PLUGIN_LIBS) + PKG_CHECK_MODULES(VCONF, vconf) AC_SUBST(VCONF_CFLAGS) AC_SUBST(VCONF_LIBS) @@ -34,7 +43,7 @@ AC_SUBST(DLOG_LIBS) ####### Config files AC_CONFIG_FILES([ Makefile - replay-plugin/Makefile + gps-plugin/Makefile ]) AC_OUTPUT diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 9a4d643..0000000 --- a/debian/changelog +++ /dev/null @@ -1,103 +0,0 @@ -libslp-lbs-plugin-replay (0.1.3-10) unstable; urgency=low - - * Reduce the size of the NMEA logging file - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.3-9 - - -- Minjune Kim Tue, 17 Jul 2012 13:23:35 +0900 - -libslp-lbs-plugin-replay (0.1.3-9) unstable; urgency=low - - * strip - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.3-9 - - -- Minjune Kim Wed, 11 Jul 2012 22:00:45 +0900 - -libslp-lbs-plugin-replay (0.1.3-8) unstable; urgency=low - - * change directory path of config files to /etc(for FOTA) - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.3-8 - - -- Genie Kim Fri, 15 Jun 2012 14:35:18 +0900 - -libslp-lbs-plugin-replay (0.1.3-7) unstable; urgency=low - - * change to use vconf location internal keys - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.3-7 - - -- Genie Kim Tue, 15 May 2012 19:53:25 +0900 - -libslp-lbs-plugin-replay (0.1.3-6) unstable; urgency=low - - * add gpgll nmea sentence - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.3-6 - - -- Genie Kim Wed, 09 May 2012 17:01:41 +0900 - -libslp-lbs-plugin-replay (0.1.3-5) unstable; urgency=low - - * Bug fix : eof of nmea log - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.3-5 - - -- Genie Kim Mon, 16 Apr 2012 16:29:00 +0900 - -libslp-lbs-plugin-replay (0.1.3-4) unstable; urgency=low - - * Bug fix: replay mode key - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.3-4 - - -- Genie Kim Fri, 13 Apr 2012 16:41:43 +0900 - -libslp-lbs-plugin-replay (0.1.3-3) unstable; urgency=low - - * Bug fix: NMEA log file path - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.3-3 - - -- Youngae Kang Sat, 07 Apr 2012 14:49:22 +0900 - -libslp-lbs-plugin-replay (0.1.3-2) unstable; urgency=low - - * change spec file - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.3-2 - - -- Genie Kim Tue, 21 Feb 2012 20:04:52 +0900 - -libslp-lbs-plugin-replay (0.1.3-1) unstable; urgency=low - - * add position valid data in sv_data - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.3-1 - - -- Minjune Kim Fri, 17 Feb 2012 17:12:01 +0900 - -libslp-lbs-plugin-replay (0.1.2-1) unstable; urgency=low - - * bug fix for fclose - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.2-1 - - -- Genie Kim Wed, 15 Feb 2012 11:10:09 +0900 - -libslp-lbs-plugin-replay (0.1.1-1) unstable; urgency=low - - * Add manual replay mode for SDK - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.1-1 - - -- Genie Kim Wed, 01 Feb 2012 16:18:43 +0900 - -libslp-lbs-plugin-replay (0.1.0-1) unstable; urgency=low - - * Initial Release. - * Git: framework/location/libslp-lbs-plugin-replay - * Tag: libslp-lbs-plugin-replay_0.1.0-1 - - -- Genie Kim Mon, 26 Sep 2011 00:00:00 +0900 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 7ed6ff8..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/debian/control b/debian/control deleted file mode 100644 index ce7b202..0000000 --- a/debian/control +++ /dev/null @@ -1,19 +0,0 @@ -Source: libslp-lbs-plugin-replay -Section: devel -Priority: extra -Maintainer: Youngae Kang , Yunhan Kim , Genie Kim -Uploaders: Genie Kim -Build-Depends: debhelper (>= 4.0.0), autotools-dev, gps-manager-plugin-dev, libglib2.0-dev, libvconf-dev, vconf-internal-keys-dev, dlog-dev -Standards-Version: 0.1.0 - -Package: libslp-lbs-plugin-replay -Section: libs -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libglib2.0-0, libvconf-0, libdlog-0 -Description: GPS manager plugin library for replay mode - -Package: libslp-lbs-plugin-replay-dbg -Section: debug -Architecture: any -Depends: libslp-lbs-plugin-replay (= ${Source-Version}) -Description: GPS manager plugin library for replay mode (for debugging) diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index e69de29..0000000 diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index e69de29..0000000 diff --git a/debian/docs b/debian/docs deleted file mode 100644 index e69de29..0000000 diff --git a/debian/libslp-lbs-plugin-replay.install.in b/debian/libslp-lbs-plugin-replay.install.in deleted file mode 100644 index 8be8875..0000000 --- a/debian/libslp-lbs-plugin-replay.install.in +++ /dev/null @@ -1,3 +0,0 @@ -debian/tmp@PREFIX@/lib/libSLP-lbs-plugin-replay.so -debian/tmp@PREFIX@/lib/libSLP-lbs-plugin-replay.so.* -debian/tmp/etc/gps-manager/replay/* diff --git a/debian/libslp-lbs-plugin-replay.postinst.in b/debian/libslp-lbs-plugin-replay.postinst.in deleted file mode 100644 index 60c9f83..0000000 --- a/debian/libslp-lbs-plugin-replay.postinst.in +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -rm -rf /usr/lib/libSLP-lbs-plugin.so -ln -sf /usr/lib/libSLP-lbs-plugin-replay.so /usr/lib/libSLP-lbs-plugin.so - - -if [ "${USER}" = "root" ] -then -#Change File owner - chown root:root /etc/gps-manager/replay/nmea_replay.log - -#Change File Permission - chmod 666 /etc/gps-manager/replay/nmea_replay.log -fi diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 795f28a..0000000 --- a/debian/rules +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -export DH_VERBOSE=1 - - -# These are used for cross-compiling and for saving the configure script -# from having to guess our platform (since we know it already) - -CFLAGS ?= -Wall -g -LDFLAGS ?= -PREFIX ?= /usr -DESTDIR ?= $(CURDIR)/debian/tmp -DATADIR ?= $(DESTDIR)/etc/gps-manager - -#CFLAGS += -O0 -#CXXFLAGS += -O0 -CFLAGS += -fvisibility=hidden -Wall -fPIC -CXXFLAGS += -fvisibility=hidden -Wall -fPIC -LDFLAGS += -Wl,--as-needed -Wl,--hash-style=both - -configure: configure-stamp -configure-stamp: - dh_testdir - # Add here commands to configure the package. - ./autogen.sh - mkdir -p build - cd build && CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" ../configure --prefix=$(PREFIX) --datadir=$(DATADIR) - - touch $@ - -build: build-stamp -build-stamp: configure-stamp - dh_testdir - - # Add here commands to compile the package. - mkdir -p build - cd build && $(MAKE) - #docbook-to-man debian/ncurses.sgml > ncurses.1 - - for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ - cat $$f > $${f%.in}; \ - sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \ - sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \ - done - - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # Add here commands to clean up after the build process. - mkdir -p build - cd build - -$(MAKE) clean - -$(MAKE) distclean - cd .. - - for f in `find $(CURDIR)/debian/ -name "*.in"`; do \ - rm -f $${f%.in}; \ - done - - find $(CURDIR) -name "Makefile.in" -exec rm -f {} \; - - dh_clean - rm -rf build - rm -rf build-aux - rm -rf m4 - rm -f aclocal.m4 config.h.in configure - -install: build - dh_testdir - dh_testroot -# dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/ncurses. - mkdir -p build - cd build && $(MAKE) DESTDIR=$(DESTDIR) install - - mkdir -p $(DATADIR)/replay - cp -a nmea-log/*.log $(DATADIR)/replay - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs - dh_installexamples - dh_install #--sourcedir=debian/tmp -# dh_installmenu -# dh_installdebconf -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_python -# dh_installinit -# dh_installcron -# dh_installinfo - dh_installman - dh_link - dh_strip --dbg-package=libslp-lbs-plugin-replay-dbg - dh_compress - dh_fixperms -# dh_perl - dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install diff --git a/replay-plugin/Makefile.am b/gps-plugin/Makefile.am similarity index 70% rename from replay-plugin/Makefile.am rename to gps-plugin/Makefile.am index 4a699dd..239a0c5 100644 --- a/replay-plugin/Makefile.am +++ b/gps-plugin/Makefile.am @@ -3,15 +3,17 @@ lib_LTLIBRARIES = libSLP-lbs-plugin-replay.la libSLP_lbs_plugin_replay_la_SOURCES = \ $(srcdir)/src/nmea_parser.c \ - $(srcdir)/src/gps_plugin_replay.c \ - $(srcdir)/src/setting.c + $(srcdir)/src/gps_plugin_replay.c \ + $(srcdir)/src/setting.c libSLP_lbs_plugin_replay_la_CFLAGS = -Wall -fPIC -fvisibility=hidden -DEXPORT_API="__attribute__((visibility(\"default\")))" \ - -I$(srcdir)/include \ + -I$(srcdir)/include \ $(GPS_MANAGER_PLUGIN_CFLAGS) \ $(VCONF_CFLAGS) \ - $(DLOG_CFLAGS) + $(DLOG_CFLAGS) \ + $(DEVICED_CFLAGS) libSLP_lbs_plugin_replay_la_LDFLAGS = -Wl,--hash-style=both -Wl,--as-needed \ $(VCONF_LIBS) \ - $(DLOG_LIBS) + $(DLOG_LIBS) \ + $(DEVICED_LIBS) diff --git a/gps-plugin/include/gps_plugin_debug.h b/gps-plugin/include/gps_plugin_debug.h new file mode 100644 index 0000000..bdc75ee --- /dev/null +++ b/gps-plugin/include/gps_plugin_debug.h @@ -0,0 +1,53 @@ +/* + * gps-manager replay plugin + * + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Youngae Kang , Minjune Kim + * Genie Kim + * + * 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. + */ + +#ifndef __GPS_PLUGIN_DEBUG_H__ +#define __GPS_PLUGIN_DEBUG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define GPS_DLOG +#define GPS_DLOG_DEBUG // filename and line number will be shown + +#ifdef GPS_DLOG +#include +#define TAG_GPS_PLUGIN "gps-plugin" + +#define DBG_LOW LOG_DEBUG +#define DBG_INFO LOG_INFO +#define DBG_WARN LOG_WARN +#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 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) +#define SECLOG_PLUGIN(dbg_lvl,fmt,args...) SECURE_SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) +#endif +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/replay-plugin/include/nmea_parser.h b/gps-plugin/include/nmea_parser.h similarity index 74% rename from replay-plugin/include/nmea_parser.h rename to gps-plugin/include/nmea_parser.h index a86c533..4e3e941 100644 --- a/replay-plugin/include/nmea_parser.h +++ b/gps-plugin/include/nmea_parser.h @@ -1,10 +1,10 @@ /* - * GPS manager replay plugin + * gps-manager replay plugin * - * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Yunhan Kim , - * Genie Kim , Minjune Kim + * Contact: Youngae Kang , Minjune Kim + * Genie Kim * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/replay-plugin/include/setting.h b/gps-plugin/include/setting.h similarity index 70% rename from replay-plugin/include/setting.h rename to gps-plugin/include/setting.h index 257d99d..578c022 100644 --- a/replay-plugin/include/setting.h +++ b/gps-plugin/include/setting.h @@ -1,10 +1,10 @@ /* - * GPS manager replay plugin + * gps-manager replay plugin * - * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Yunhan Kim , - * Genie Kim , Minjune Kim + * Contact: Youngae Kang , Minjune Kim + * Genie Kim * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,8 +25,8 @@ #include #include -#define NMEA_FILE_PATH "/opt/media/gps-manager/replay/" -#define DEFAULT_NMEA_LOG "/etc/gps-manager/replay/nmea_replay.log" +#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, @@ -36,9 +36,14 @@ typedef enum { } replay_mode_t; typedef enum { - READ_ERROR = -1, - READ_SUCCESS = 0, - READ_NOT_FIXED = 1, + BATCH_MODE_OFF = 0, + BATCH_MODE_ON +} batch_mode_t; + +typedef enum { + READ_ERROR = -1, + READ_SUCCESS = 0, + READ_NOT_FIXED = 1, } read_error_t; int setting_get_int(const char *path, int *val); diff --git a/replay-plugin/src/gps_plugin_replay.c b/gps-plugin/src/gps_plugin_replay.c old mode 100644 new mode 100755 similarity index 61% rename from replay-plugin/src/gps_plugin_replay.c rename to gps-plugin/src/gps_plugin_replay.c index 8f828d5..8661cc4 --- a/replay-plugin/src/gps_plugin_replay.c +++ b/gps-plugin/src/gps_plugin_replay.c @@ -1,10 +1,10 @@ /* - * GPS manager replay plugin + * gps replay plugin * - * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Yunhan Kim , - * Genie Kim , Minjune Kim + * Contact: Youngae Kang , Minjune Kim + * Genie Kim * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,12 @@ #include #include #include +#include #include +#include -#include +#include +#include #include "gps_plugin_debug.h" #include "nmea_parser.h" @@ -35,14 +38,25 @@ #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; typedef struct { FILE *fd; + FILE *batch_fd; int interval; int replay_mode; + int batch_mode; + int batch_period; + int num_of_batch; + time_t batch_start_time; + pos_data_t *pos_data; + batch_data_t *batch_data; sv_data_t *sv_data; nmea_data_t *nmea_data; @@ -52,9 +66,9 @@ typedef struct { replay_timeout *g_replay_timer = NULL; -int gps_plugin_replay_gps_init(gps_event_cb gps_event_cb, gps_server_param_t * gps_params); +int gps_plugin_replay_gps_init(gps_event_cb gps_event_cb, void *user_data); int gps_plugin_replay_gps_deinit(gps_failure_reason_t * reason_code); -int gps_plugin_replay_gps_request(gps_action_t gps_action, void *data, gps_failure_reason_t * reason_code); +int gps_plugin_replay_gps_request(gps_action_t gps_action, void *gps_action_data, gps_failure_reason_t * reason_code); static const gps_plugin_interface g_gps_plugin_replay_interface = { gps_plugin_replay_gps_init, @@ -87,10 +101,77 @@ void gps_plugin_replay_pos_event(pos_data_t * data) gps_event.event_data.pos_ind.pos.ver_accuracy = data->ver_accuracy; } - //LOG_PLUGIN(DBG_LOW, "%d / %f / %f / %f", gps_event.event_data.pos_ind.pos.timestamp, gps_event.event_data.pos_ind.pos.latitude, gps_event.event_data.pos_ind.pos.longitude, gps_event.event_data.pos_ind.pos.altitude); - if (g_gps_event_cb != NULL) { - g_gps_event_cb(&gps_event); + g_gps_event_cb(&gps_event, g_user_data); + } +} + +void gps_plugin_replay_batch_event(pos_data_t * data, replay_timeout * timer) +{ + time_t timestamp; + time(×tamp); + + 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) { + LOG_PLUGIN(DBG_ERR, "Fail to create lbs-server folder"); + return ; + } + } + + timer->batch_fd = fopen(BATCH_LOG, "w+"); + if (timer->batch_fd == NULL) { + LOG_PLUGIN(DBG_ERR, "Fail to open file [Not available batch_fd]"); + return ; + } + } + } + + if (data != NULL) { + if (timer->batch_mode == BATCH_MODE_ON) { + int ret = -1; + char buf[256] = {0, }; + + g_snprintf(buf, 256, "%ld;%.6lf;%.6lf;%.2lf;%.2lf;%.2lf;%.2lf;%.2lf;\n", timestamp, data->latitude, data->longitude, data->altitude, data->speed, data->bearing, data->hor_accuracy, data->ver_accuracy); + LOG_PLUGIN(DBG_LOW, "Add location info to batch file [%s]", buf); + + ret = fwrite(buf, 1, strlen(buf), timer->batch_fd); + if (ret != strlen(buf)) { + LOG_PLUGIN(DBG_ERR, "Fail to write file[%s]", BATCH_LOG); + } + + (timer->num_of_batch)++ ; + } + } + + if ((timestamp - timer->batch_start_time) >= timer->batch_period) { + LOG_PLUGIN(DBG_LOW, "Batch invoked, Batch interval is expired or Batch stopped"); + gps_event_info_t gps_event; + memset(&gps_event, 0, sizeof(gps_event_info_t)); + + gps_event.event_id = GPS_EVENT_REPORT_BATCH; + timer->batch_start_time = timestamp; + + if (timer->num_of_batch < 1) { + LOG_PLUGIN(DBG_ERR, "There is no Batch data"); + gps_event.event_data.batch_ind.error = GPS_ERR_COMMUNICATION; + } else { + gps_event.event_data.batch_ind.error = GPS_ERR_NONE; + gps_event.event_data.batch_ind.batch.num_of_location = timer->num_of_batch; + } + + if (g_gps_event_cb != NULL) { + 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; + } } } @@ -122,7 +203,7 @@ void gps_plugin_replay_sv_event(sv_data_t * data) } if (g_gps_event_cb != NULL) { - g_gps_event_cb(&gps_event); + g_gps_event_cb(&gps_event, g_user_data); } } @@ -150,13 +231,14 @@ void gps_plugin_replay_nmea_event(nmea_data_t * data) gps_event.event_data.nmea_ind.nmea.timestamp = timestamp; gps_event.event_data.nmea_ind.nmea.len = data->len; gps_event.event_data.nmea_ind.nmea.data = (char *)malloc(data->len); + g_return_if_fail(gps_event.event_data.nmea_ind.nmea.data); + memset(gps_event.event_data.nmea_ind.nmea.data, 0x00, data->len); memcpy(gps_event.event_data.nmea_ind.nmea.data, data->data, data->len); - //LOG_PLUGIN(DBG_LOW, "NMEA[%d] : %s", gps_event.event_data.nmea_ind.nmea.len, gps_event.event_data.nmea_ind.nmea.data); } if (g_gps_event_cb != NULL) { - g_gps_event_cb(&gps_event); + g_gps_event_cb(&gps_event, g_user_data); } if (gps_event.event_data.nmea_ind.nmea.data != NULL) { @@ -177,7 +259,7 @@ void gps_plugin_respond_start_session(gboolean ret) } if (g_gps_event_cb != NULL) { - g_gps_event_cb(&gps_event); + g_gps_event_cb(&gps_event, g_user_data); } } @@ -189,7 +271,7 @@ void gps_plugin_respond_stop_session(void) gps_event.event_data.stop_session_rsp.error = GPS_ERR_NONE; if (g_gps_event_cb != NULL) { - g_gps_event_cb(&gps_event); + g_gps_event_cb(&gps_event, g_user_data); } } @@ -270,10 +352,16 @@ gboolean gps_plugin_replay_timeout_cb(gpointer data) { gboolean ret = FALSE; read_error_t err = READ_SUCCESS; - replay_timeout *timer = (replay_timeout *) data; char nmea_data[REPLAY_NMEA_SET_SIZE] = { 0, }; + replay_timeout *timer = (replay_timeout *) data; + + if (timer == NULL) { + LOG_PLUGIN(DBG_ERR, "replay handel[timer] is NULL"); + return FALSE; + } memset(timer->pos_data, 0, sizeof(pos_data_t)); + memset(timer->batch_data, 0, sizeof(batch_data_t)); memset(timer->sv_data, 0, sizeof(sv_data_t)); if (timer->replay_mode == REPLAY_NMEA) { @@ -284,7 +372,7 @@ gboolean gps_plugin_replay_timeout_cb(gpointer data) err = nmea_parser(nmea_data, timer->pos_data, timer->sv_data); if (err == READ_ERROR) { LOG_PLUGIN(DBG_ERR, "Fail to parser nmea data from file"); - return FALSE; + //return FALSE; } else if (err == READ_NOT_FIXED) { LOG_PLUGIN(DBG_LOW, "GPS position is not fixed"); timer->sv_data->pos_valid = FALSE; @@ -305,15 +393,66 @@ gboolean gps_plugin_replay_timeout_cb(gpointer data) timer->sv_data->pos_valid = FALSE; } - if (timer != NULL) { - if (g_gps_event_cb != NULL) { - if (err != READ_NOT_FIXED) { - gps_plugin_replay_pos_event(timer->pos_data); + if (g_gps_event_cb != NULL) { + if (err != READ_NOT_FIXED) { + gps_plugin_replay_pos_event(timer->pos_data); + } + gps_plugin_replay_sv_event(timer->sv_data); + } + ret = TRUE; + return ret; +} + +gboolean gps_plugin_batch_replay_timeout_cb(gpointer data) +{ + gboolean ret = FALSE; + read_error_t err = READ_SUCCESS; + char nmea_data[REPLAY_NMEA_SET_SIZE] = { 0, }; + replay_timeout *timer = (replay_timeout *) data; + + if (timer == NULL) { + LOG_PLUGIN(DBG_ERR, "replay handel[timer] is NULL"); + return FALSE; + } + + memset(timer->pos_data, 0, sizeof(pos_data_t)); + memset(timer->batch_data, 0, sizeof(batch_data_t)); + memset(timer->sv_data, 0, sizeof(sv_data_t)); + + if (timer->replay_mode == REPLAY_NMEA) { + if (gps_plugin_replay_read_nmea(timer, nmea_data) == FALSE) { + LOG_PLUGIN(DBG_ERR, "Fail to read nmea data from file"); + return FALSE; + } else { + err = nmea_parser(nmea_data, timer->pos_data, timer->sv_data); + if (err == READ_ERROR) { + LOG_PLUGIN(DBG_ERR, "Fail to parser nmea data from file"); + } else if (err == READ_NOT_FIXED) { + LOG_PLUGIN(DBG_LOW, "GPS position is not fixed"); + timer->sv_data->pos_valid = FALSE; } - gps_plugin_replay_sv_event(timer->sv_data); } - ret = TRUE; + } else if (timer->replay_mode == REPLAY_MANUAL) { + if (gps_plugin_replay_read_manual(timer->pos_data) == FALSE) { + LOG_PLUGIN(DBG_ERR, "Fail to read manual data"); + err = READ_ERROR; + return FALSE; + } else { + timer->sv_data->pos_valid = TRUE; + err = READ_SUCCESS; + } + } else if (timer->replay_mode == REPLAY_OFF) { + LOG_PLUGIN(DBG_WARN, "replay_mode is OFF"); + err = READ_NOT_FIXED; + timer->sv_data->pos_valid = FALSE; + } + + if (g_gps_event_cb != NULL) { + if (timer->batch_mode == BATCH_MODE_ON){ + gps_plugin_replay_batch_event(timer->pos_data, timer); + } } + ret = TRUE; return ret; } @@ -330,7 +469,7 @@ void gps_plugin_stop_replay_mode(replay_timeout * timer) LOG_PLUGIN(DBG_LOW, "g_source_destroy timeout_src"); } else { LOG_PLUGIN(DBG_WARN, "timer->timeout_src is attatched to 0x%x (actual 0x%x)", - g_source_get_context(timer->timeout_src), timer->default_context); + g_source_get_context(timer->timeout_src), timer->default_context); } timer->timeout_src = NULL; timer->default_context = NULL; @@ -338,21 +477,30 @@ void gps_plugin_stop_replay_mode(replay_timeout * timer) LOG_PLUGIN(DBG_WARN, "timeout_src or default_context is NULL or timeout_src is already destroyed"); } gps_plugin_respond_stop_session(); + + display_unlock_state(LCD_OFF, PM_RESET_TIMER); + LOG_PLUGIN(DBG_LOW, "display_unlock_state(LCD_OFF, PM_RESET_TIMER);"); } gboolean gps_plugin_get_nmea_fd(replay_timeout * timer) { char replay_file_path[256]; + char *str; - snprintf(replay_file_path, sizeof(replay_file_path), NMEA_FILE_PATH"%s", setting_get_string(VCONFKEY_LOCATION_NMEA_FILE_NAME)); - LOG_PLUGIN(DBG_ERR, "replay file name : %s", replay_file_path); + str = setting_get_string(VCONFKEY_LOCATION_NMEA_FILE_NAME); + if (str == NULL) { + return FALSE; + } + snprintf(replay_file_path, sizeof(replay_file_path), NMEA_FILE_PATH"%s", 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) { - LOG_PLUGIN(DBG_ERR, "fopen(%s) failed", replay_file_path); + SECLOG_PLUGIN(DBG_ERR, "fopen(%s) failed", replay_file_path); timer->fd = fopen(DEFAULT_NMEA_LOG, "r"); if (timer->fd == NULL) { - LOG_PLUGIN(DBG_ERR, "fopen(%s) failed", DEFAULT_NMEA_LOG); + SECLOG_PLUGIN(DBG_ERR, "fopen(%s) failed", DEFAULT_NMEA_LOG); return FALSE; } } @@ -385,7 +533,7 @@ gboolean gps_plugin_start_replay_mode(replay_timeout * timer) g_source_set_callback(timer->timeout_src, &gps_plugin_replay_timeout_cb, timer, NULL); if (g_source_attach(timer->timeout_src, timer->default_context) > 0) { LOG_PLUGIN(DBG_LOW, "timeout_src(0x%x) is created & attatched to 0x%x", timer->timeout_src, - timer->default_context); + timer->default_context); ret = TRUE; } else { gps_plugin_stop_replay_mode(timer); @@ -393,11 +541,73 @@ gboolean gps_plugin_start_replay_mode(replay_timeout * timer) } } } + + display_lock_state(LCD_OFF, STAY_CUR_STATE, 0); + LOG_PLUGIN(DBG_LOW, "display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);"); + gps_plugin_respond_start_session(ret); return ret; } +gboolean gps_plugin_start_batch_mode(replay_timeout * timer, int batch_interval, int batch_period) +{ + gboolean ret = FALSE; + time_t timestamp; + time(×tamp); + + if (timer->replay_mode == REPLAY_NMEA) { + if (gps_plugin_get_nmea_fd(timer) == FALSE) { + return FALSE; + } + } + + if (timer->default_context == NULL) { + timer->default_context = g_main_context_default(); + if (timer->default_context == NULL) { + return ret; + } + } + + if (timer->timeout_src != NULL) { + LOG_PLUGIN(DBG_ERR, "timeout_src is already existed"); + ret = FALSE; + } else { + timer->timeout_src = g_timeout_source_new_seconds(batch_interval); + if (timer->timeout_src != NULL) { + g_source_set_callback(timer->timeout_src, &gps_plugin_batch_replay_timeout_cb, timer, NULL); + if (g_source_attach(timer->timeout_src, timer->default_context) > 0) { + LOG_PLUGIN(DBG_LOW, "timeout_src(0x%x) is created & attatched to 0x%x", timer->timeout_src, timer->default_context); + ret = TRUE; + } else { + gps_plugin_stop_replay_mode(timer); + ret = FALSE; + } + } + } + + gps_plugin_respond_start_session(ret); + + timer->batch_mode = BATCH_MODE_ON; + timer->batch_period = batch_period; + timer->batch_start_time = timestamp; + + return ret; +} + +void gps_plugin_stop_batch_mode(replay_timeout * timer) +{ + if (timer->batch_mode == BATCH_MODE_ON) { + timer->batch_mode = BATCH_MODE_OFF; + } + + if (timer->batch_fd != NULL) { + fclose(timer->batch_fd); + timer->batch_fd = NULL; + timer->num_of_batch = 0; + } +} + static void replay_mode_changed_cb(keynode_t * key, void *data) { if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &g_replay_timer->replay_mode) == FALSE) { @@ -429,17 +639,47 @@ replay_timeout *gps_plugin_replay_timer_init() timer->fd = NULL; timer->interval = 1; + + timer->batch_fd = NULL; + timer->num_of_batch = 0; + timer->batch_mode = BATCH_MODE_OFF; + if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &timer->replay_mode) == FALSE) { timer->replay_mode = REPLAY_OFF; } setting_notify_key_changed(VCONFKEY_LOCATION_REPLAY_MODE, replay_mode_changed_cb); timer->pos_data = (pos_data_t *) malloc(sizeof(pos_data_t)); + if (timer->pos_data == NULL) { + LOG_PLUGIN(DBG_ERR, "pos_data allocation is failed."); + free(timer); + return NULL; + } + + timer->batch_data = (batch_data_t *) malloc(sizeof(batch_data_t)); + if (timer->batch_data == NULL) { + LOG_PLUGIN(DBG_ERR, "batch_data allocation is failed."); + free(timer->pos_data); + free(timer); + return NULL; + } + timer->sv_data = (sv_data_t *) malloc(sizeof(sv_data_t)); - timer->nmea_data = (nmea_data_t *) malloc(sizeof(nmea_data_t)); + if (timer->sv_data == NULL) { + LOG_PLUGIN(DBG_ERR, "sv_data allocation is failed."); + free(timer->pos_data); + free(timer->batch_data); + free(timer); + return NULL; + } - if (timer->pos_data == NULL || timer->sv_data == NULL || timer->nmea_data == NULL) { - LOG_PLUGIN(DBG_ERR, "pos_data or sv_data or nmea_data allocation is failed."); + timer->nmea_data = (nmea_data_t *) malloc(sizeof(nmea_data_t)); + if (timer->nmea_data == NULL) { + LOG_PLUGIN(DBG_ERR, "nmea_data allocation is failed."); + free(timer->pos_data); + free(timer->batch_data); + free(timer->sv_data); + free(timer); return NULL; } @@ -474,10 +714,11 @@ void gps_plugin_replay_timer_deinit(replay_timeout * timer) timer = NULL; } -int gps_plugin_replay_gps_init(gps_event_cb gps_event_cb, gps_server_param_t * gps_params) +int gps_plugin_replay_gps_init(gps_event_cb gps_event_cb, void *user_data) { g_gps_event_cb = gps_event_cb; g_replay_timer = gps_plugin_replay_timer_init(); + g_user_data = user_data; return TRUE; } @@ -485,12 +726,16 @@ int gps_plugin_replay_gps_init(gps_event_cb gps_event_cb, gps_server_param_t * g int gps_plugin_replay_gps_deinit(gps_failure_reason_t * reason_code) { gps_plugin_replay_timer_deinit(g_replay_timer); + g_gps_event_cb = NULL; + g_user_data = NULL; return TRUE; } -int gps_plugin_replay_gps_request(gps_action_t gps_action, void *data, gps_failure_reason_t * reason_code) +int gps_plugin_replay_gps_request(gps_action_t gps_action, void *gps_action_data, gps_failure_reason_t * reason_code) { + gps_action_start_data_t *gps_start_data = gps_action_data; + switch (gps_action) { case GPS_ACTION_SEND_PARAMS: break; @@ -500,6 +745,13 @@ int gps_plugin_replay_gps_request(gps_action_t gps_action, void *data, gps_failu case GPS_ACTION_STOP_SESSION: gps_plugin_stop_replay_mode(g_replay_timer); break; + case GPS_ACTION_START_BATCH: + gps_plugin_start_batch_mode(g_replay_timer, gps_start_data->interval, gps_start_data->period); + break; + case GPS_ACTION_STOP_BATCH: + gps_plugin_stop_batch_mode(g_replay_timer); + gps_plugin_stop_replay_mode(g_replay_timer); + break; case GPS_INDI_SUPL_VERIFICATION: case GPS_INDI_SUPL_DNSQUERY: case GPS_ACTION_START_FACTTEST: diff --git a/replay-plugin/src/nmea_parser.c b/gps-plugin/src/nmea_parser.c similarity index 82% rename from replay-plugin/src/nmea_parser.c rename to gps-plugin/src/nmea_parser.c index fc92c3c..4a75932 100644 --- a/replay-plugin/src/nmea_parser.c +++ b/gps-plugin/src/nmea_parser.c @@ -1,10 +1,10 @@ /* - * GPS manager replay plugin + * gps replay plugin * - * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Yunhan Kim , - * Genie Kim , Minjune Kim + * Contact: Youngae Kang , Minjune Kim + * Genie Kim * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,23 +23,23 @@ #include #include #include -#include +#include #include "gps_plugin_debug.h" #include "nmea_parser.h" #include "setting.h" -#define MAX_NMEA_SENTENCES 32 -#define MAX_TOEKNS 25 +#define MAX_NMEA_SENTENCES 32 +#define MAX_TOEKNS 25 -#define DECIMAL_TO_DEGREE 60.0 -#define METER_TO_FEET 3.2808399 -#define KNOT_TO_MPS 0.5144444 -#define KMPH_TO_MPS 0.2777778 +#define DECIMAL_TO_DEGREE 60.0 +#define METER_TO_FEET 3.2808399 +#define KNOT_TO_MPS 0.5144444 +#define KMPH_TO_MPS 0.2777778 -#define NORTH 1 +#define NORTH 1 #define SOUTH -1 -#define EAST 1 +#define EAST 1 #define WEST -1 int used_sat[MAX_GPS_NUM_SAT_USED] = { 0, }; @@ -104,9 +104,6 @@ int nmea_parser_tokenize(char input[], char *token[]) state = 0; } break; - default: - state = 0; - break; } s++; } @@ -171,8 +168,8 @@ static double nmea_parser_get_altitude(const char *alt, const char *unit) static int nmea_parser_gpgga(char *token[], pos_data_t * pos, sv_data_t * sv) { - double latitude, longitude, altitude, eph, geoid; - int utctime, num_of_sat_used, quality; + double latitude, longitude, altitude; + int quality; quality = atoi(token[6]); @@ -182,13 +179,13 @@ static int nmea_parser_gpgga(char *token[], pos_data_t * pos, sv_data_t * sv) return READ_NOT_FIXED; } - utctime = atoi(token[1]); +// utctime = atoi(token[1]); latitude = nmea_parser_get_latitude(token[2], token[3]); longitude = nmea_parser_get_longitude(token[4], token[5]); altitude = nmea_parser_get_altitude(token[9], token[10]); - num_of_sat_used = atoi(token[7]); - eph = atof(token[8]); - geoid = nmea_parser_get_altitude(token[11], token[12]); +// num_of_sat_used = atoi(token[7]); +// eph = atof(token[8]); +// geoid = nmea_parser_get_altitude(token[11], token[12]); pos->latitude = latitude; pos->longitude = longitude; @@ -201,9 +198,8 @@ static int nmea_parser_gpgga(char *token[], pos_data_t * pos, sv_data_t * sv) static int nmea_parser_gprmc(char *token[], pos_data_t * pos) { - int date, utctime; char *status; - double latitude, longitude, speed, bearing, magvar; + double latitude, longitude, speed, bearing; status = token[2]; //warn = *token[2]; if (strcmp(status, "V") == 0) { @@ -211,13 +207,13 @@ static int nmea_parser_gprmc(char *token[], pos_data_t * pos) return READ_NOT_FIXED; } - utctime = atoi(token[1]); +// utctime = atoi(token[1]); latitude = nmea_parser_get_latitude(token[3], token[4]); longitude = nmea_parser_get_longitude(token[5], token[6]); speed = atof(token[7]); bearing = atof(token[8]); - date = atoi(token[9]); - magvar = atof(token[10]); +// date = atoi(token[9]); +// magvar = atof(token[10]); pos->latitude = latitude; pos->longitude = longitude; @@ -238,20 +234,18 @@ static int nmea_parser_gpgll(char *token[], pos_data_t * pos) return READ_NOT_FIXED; } - latitude = nmea_parser_get_latitude(token[1], token[2]); - longitude = nmea_parser_get_longitude(token[3], token[4]); + latitude = nmea_parser_get_latitude(token[1], token[2]); + longitude = nmea_parser_get_longitude(token[3], token[4]); - pos->latitude = latitude; - pos->longitude = longitude; + pos->latitude = latitude; + pos->longitude = longitude; - return READ_SUCCESS; + return READ_SUCCESS; } static int nmea_parser_gpgsa(char *token[], pos_data_t * pos) { - char selection_type; int i, fix_type; - double pdop, hdop, vdop; fix_type = atoi(token[2]); if (fix_type == 1) { @@ -259,27 +253,27 @@ static int nmea_parser_gpgsa(char *token[], pos_data_t * pos) return READ_NOT_FIXED; } - selection_type = *token[1]; +// selection_type = *token[1]; memset(used_sat, 0, sizeof(used_sat)); for (i = 0; i < MAX_GPS_NUM_SAT_USED; i++) { used_sat[i] = atoi(token[i + 3]); } - pdop = atof(token[15]); - hdop = atof(token[16]); - vdop = atof(token[17]); +// pdop = atof(token[15]); +// hdop = atof(token[16]); +// vdop = atof(token[17]); return READ_SUCCESS; } static int nmea_parser_gpvtg(char *token[], pos_data_t * pos) { - double true_course, magnetic_course, knot_speed, kmh_speed; + double true_course, kmh_speed; true_course = atof(token[1]); - magnetic_course = atof(token[3]); - knot_speed = atof(token[5]); +// magnetic_course = atof(token[3]); +// knot_speed = atof(token[5]); kmh_speed = atof(token[7]); pos->speed = kmh_speed * KMPH_TO_MPS; @@ -292,9 +286,9 @@ static int nmea_parser_gpgsv(char *token[], sv_data_t * sv) { int i, j; int p, q, iter; - int num_sen, msg_num, num_sv; + int msg_num, num_sv; - num_sen = atoi(token[1]); +// num_sen = atoi(token[1]); msg_num = atoi(token[2]); if (msg_num < 1) { LOG_PLUGIN(DBG_LOW, "There is not GSV message"); @@ -325,7 +319,7 @@ static int nmea_parser_gpgsv(char *token[], sv_data_t * sv) int nmea_parser_sentence(char *sentence, char *token[], pos_data_t * pos, sv_data_t * sv) { - int ret; + int ret = READ_SUCCESS; if (strcmp(sentence, "GPGGA") == 0) { ret = nmea_parser_gpgga(token, pos, sv); } else if (strcmp(sentence, "GPRMC") == 0) { @@ -369,9 +363,8 @@ int nmea_parser(char *data, pos_data_t * pos, sv_data_t * sv) if (err == READ_NOT_FIXED) { LOG_PLUGIN(DBG_LOW, "NOT Fixed"); ret = err; - } else if (ret == READ_ERROR) { + } else if (err == READ_ERROR) { ret = err; - break; } } else { LOG_PLUGIN(DBG_ERR, "[NMEA Parser] %dth sentense : Invalid Checksum\n", count); @@ -379,6 +372,6 @@ int nmea_parser(char *data, pos_data_t * pos, sv_data_t * sv) count++; num_sen--; } - + return ret; } diff --git a/replay-plugin/src/setting.c b/gps-plugin/src/setting.c similarity index 86% rename from replay-plugin/src/setting.c rename to gps-plugin/src/setting.c index 32ed340..135fa57 100644 --- a/replay-plugin/src/setting.c +++ b/gps-plugin/src/setting.c @@ -1,10 +1,10 @@ /* - * GPS manager replay plugin + * gps-manager replay plugin * - * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Yunhan Kim , - * Genie Kim , Minjune Kim + * Contact: Youngae Kang , Minjune Kim + * Genie Kim * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/libslp-lbsplugin-replay.manifest b/libslp-lbsplugin-replay.manifest new file mode 100644 index 0000000..d75ae1b --- /dev/null +++ b/libslp-lbsplugin-replay.manifest @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/libslp-xpsplugin-replay.manifest b/libslp-xpsplugin-replay.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/libslp-xpsplugin-replay.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/libslp-lbs-plugin-replay.spec b/packaging/libslp-lbsplugin-replay.spec similarity index 55% rename from packaging/libslp-lbs-plugin-replay.spec rename to packaging/libslp-lbsplugin-replay.spec index a73cc92..5f1af32 100644 --- a/packaging/libslp-lbs-plugin-replay.spec +++ b/packaging/libslp-lbsplugin-replay.spec @@ -1,29 +1,32 @@ -Name: libslp-lbs-plugin-replay -Summary: gps-manager plugin library for replay mode -Version: 0.1.3 +Name: libslp-lbsplugin-replay +Summary: lbs-server plugin library for replay mode +Version: 0.2.1 Release: 1 -Group: TO_BE/FILLED_IN -License: TO_BE/FILLED_IN +Group: Framework/Location +License: Apache-2.0 Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(gps-manager-plugin) +BuildRequires: pkgconfig(lbs-server-plugin) +BuildRequires: pkgconfig(deviced) %description -gps-manager plugin library for replay mode +lbs-server plugin library for replay mode -%define DATADIR /etc/gps-manager +%define DATADIR /etc/lbs-server %prep -%setup -q +%setup -q ./autogen.sh ./configure --prefix=%{_prefix} --datadir=%{DATADIR} %build +./autogen.sh +./configure --prefix=%{_prefix} --datadir=%{DATADIR} make %{?jobs:-j%jobs} %install @@ -38,7 +41,7 @@ rm -rf /usr/lib/libSLP-lbs-plugin.so ln -sf /usr/lib/libSLP-lbs-plugin-replay.so /usr/lib/libSLP-lbs-plugin.so %files +%manifest libslp-lbsplugin-replay.manifest %defattr(-,root,root,-) -%{_libdir}/libSLP-lbs-plugin-replay.so -%{_libdir}/libSLP-lbs-plugin-replay.so.* +%{_libdir}/libSLP-lbs-plugin-replay.so* %{DATADIR}/replay/* diff --git a/xps-plugin/Makefile.am b/xps-plugin/Makefile.am new file mode 100755 index 0000000..5a03dff --- /dev/null +++ b/xps-plugin/Makefile.am @@ -0,0 +1,15 @@ +################# Build library ################ +lib_LTLIBRARIES = libSLP-xps-plugin-replay.la + +libSLP_xps_plugin_replay_la_SOURCES = \ + $(srcdir)/src/geoclue_xps_plugin_replay.c + +libSLP_xps_plugin_replay_la_CFLAGS = -Wall -fPIC -fvisibility=hidden -DEXPORT_API="__attribute__((visibility(\"default\")))" \ + -I$(srcdir)/include \ + $(GEOCLUE_XPS_PLUGIN_CFLAGS) \ + $(VCONF_CFLAGS) \ + $(DLOG_CFLAGS) + +libSLP_xps_plugin_replay_la_LDFLAGS = -Wl,--hash-style=both -Wl,--as-needed \ + $(VCONF_LIBS) \ + $(DLOG_LIBS) diff --git a/replay-plugin/include/gps_plugin_debug.h b/xps-plugin/include/geoclue_plugin_debug.h old mode 100644 new mode 100755 similarity index 59% rename from replay-plugin/include/gps_plugin_debug.h rename to xps-plugin/include/geoclue_plugin_debug.h index daef1c7..930cbe0 --- a/replay-plugin/include/gps_plugin_debug.h +++ b/xps-plugin/include/geoclue_plugin_debug.h @@ -1,10 +1,10 @@ /* - * GPS manager replay plugin + * gps-manager replay plugin * - * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Yunhan Kim , - * Genie Kim , Minjune Kim + * Contact: Youngae Kang , Minjune Kim + * Genie Kim * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,17 +31,17 @@ extern "C" { #ifdef GPS_DLOG #include -#define TAG_GPS_PLUGIN "gps-plugin" +#define TAG_GPS_PLUGIN "xps-plugin" -#define DBG_LOW LOG_DEBUG -#define DBG_INFO LOG_INFO -#define DBG_WARN LOG_WARN -#define DBG_ERR LOG_ERROR +#define DBG_LOW LOG_DEBUG +#define DBG_INFO LOG_INFO +#define DBG_WARN LOG_WARN +#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, "[%-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) +#define LOG_PLUGIN(dbg_lvl,fmt,args...) SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args) #endif #endif diff --git a/xps-plugin/src/geoclue_xps_plugin_replay.c b/xps-plugin/src/geoclue_xps_plugin_replay.c new file mode 100755 index 0000000..dd6b01d --- /dev/null +++ b/xps-plugin/src/geoclue_xps_plugin_replay.c @@ -0,0 +1,271 @@ +/* + * gps-manager replay plugin + * + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Youngae Kang , Minjune Kim + * Genie Kim + * + * 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 +#include +#include +#include +#include +#include + +#include + +#include "geoclue_plugin_debug.h" + + +int geoclue_plugin_test_load(void); +int geoclue_plugin_test_unload(void); +int geoclue_plugin_test_location(unsigned long period, LocationCallback cb, void *arg, void **handle); +int geoclue_plugin_test_cancel(void *handle, CancelCallback cb, void *arg); +void geoclue_plugin_test_get_offline_token(const unsigned char *key, + unsigned int keyLengh, + OfflineTokenCallback cb, + void *arg); +int geoclue_plugin_test_offline_location(const unsigned char *key, + unsigned int keyLength, + const unsigned char *token, + unsigned int tokenSize, + LocationCallback cb, + void *arg); + +static const geoclue_plugin_interface g_geoclue_plugin_interface_test_interface = { + geoclue_plugin_test_load, + geoclue_plugin_test_unload, + geoclue_plugin_test_location, + geoclue_plugin_test_cancel, + geoclue_plugin_test_get_offline_token, + geoclue_plugin_test_offline_location +}; + +typedef struct { + int index; // used for handle + plugin_LocationInfo *location; + unsigned long period; + LocationCallback location_cb; // save from location + void *arg; // save from location +} GeoclueXpsPluginTest; + +static GeoclueXpsPluginTest *xps_plugint_test = NULL; + +static gboolean update_fake_position(gpointer data) +{ + GeoclueXpsPluginTest *xps_plugin = data; + + if (xps_plugin) { + if (xps_plugin->location) { + if (xps_plugin->location->latitude < 90) { + xps_plugin->location->latitude++; + } else { + xps_plugin->location->latitude = 0; + } + if (xps_plugin->location->longitude< 180) { + xps_plugin->location->longitude++; + } else { + xps_plugin->location->longitude = 0; + } + if (xps_plugin->location->age < 10000) { + xps_plugin->location->age++; + } else { + xps_plugin->location->age = 0; + } + if (xps_plugin->location->altitude < 5000) { + xps_plugin->location->altitude++; + } else { + xps_plugin->location->altitude = 0; + } + if (xps_plugin->location->bearing < 90) { + xps_plugin->location->bearing++; + } else { + xps_plugin->location->bearing = 0; + } + if (xps_plugin->location->hpe < 100) { + xps_plugin->location->hpe++; + } else { + xps_plugin->location->hpe = 0; + } + if (xps_plugin->location->speed < 250) { + xps_plugin->location->speed++; + } else { + xps_plugin->location->speed = 0; + } + } + + // called intervals + if (xps_plugin->location_cb) { + xps_plugin->location_cb(xps_plugin->arg, xps_plugin->location, NULL); + } + } + + return TRUE; +} + +int geoclue_plugin_test_load(void) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_load called"); + + + // create plugin_LocationInfo *location + if (NULL == xps_plugint_test) { + xps_plugint_test = g_new0(GeoclueXpsPluginTest, 1); + if (NULL == xps_plugint_test) { + LOG_PLUGIN(LOG_ERROR, "[ERROR] GeoclueXpsPluginTest create fail"); + return FALSE; + } else { + xps_plugint_test->index = 0; + xps_plugint_test->period = 5000; // 5s + xps_plugint_test->location = g_new0(plugin_LocationInfo, 1); + if (NULL == xps_plugint_test->location) { + LOG_PLUGIN(LOG_ERROR, "[ERROR] plugin_LocationInfo create fail"); + g_free(xps_plugint_test); + return FALSE; + } + xps_plugint_test->location->latitude = 10; + xps_plugint_test->location->longitude = 10; + xps_plugint_test->location->hpe = 10; + xps_plugint_test->location->altitude= 10; + xps_plugint_test->location->age = 10; + xps_plugint_test->location->speed = 10; + xps_plugint_test->location->bearing = 10; + } + } + + // create the timer + //g_timeout_add (xps_plugint_test->period, update_fake_position, xps_plugint_test); + g_timeout_add (5000, update_fake_position, xps_plugint_test); + + return TRUE; +} +int geoclue_plugin_test_unload(void) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_unload called"); + + // free plugin_LocationInfo *location + if (xps_plugint_test) { + if (xps_plugint_test->location) { + g_free(xps_plugint_test->location); + xps_plugint_test->location = NULL; + } + g_free(xps_plugint_test); + xps_plugint_test = NULL; + } + + // kill the timer + return TRUE; +} +int geoclue_plugin_test_location(unsigned long period, LocationCallback cb, void *arg, void **handle) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_location called"); + + // update the plugin_LocationInfo *location in the timer + + // update handle + if (xps_plugint_test) { + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_location: before set handle"); + xps_plugint_test->index++; + gchar *tmp = g_strdup_printf("%d", xps_plugint_test->index); + *handle = (void *)tmp; + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_location: after set handle, set[%s], handle[%s]", tmp, *handle); + + // call LocationCallback + if (cb) { + cb(arg, xps_plugint_test->location, NULL); + xps_plugint_test->location_cb = cb; + xps_plugint_test->arg = arg; + } + + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_location after call callback"); + } + + return TRUE; // to test online + //return FALSE; // to test the offline +} +int geoclue_plugin_test_cancel(void *handle, CancelCallback cb, void *arg) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_cancel called"); + // check handle + if (handle) { + LOG_PLUGIN(LOG_DEBUG, "canel handle %s", handle); + g_free(handle); + handle = NULL; + } + + // call CancelCallback + if (cb) { + cb(arg); + } + return TRUE; +} + +void geoclue_plugin_test_get_offline_token(const unsigned char *key, + unsigned int keyLengh, + OfflineTokenCallback cb, + void *arg) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_get_offline_token called"); + + unsigned char *key_copied = NULL; + if (key && keyLengh > 0) { + key_copied = g_memdup(key, keyLengh); + key_copied[keyLengh - 1] = '\0'; + if (key_copied) { + LOG_PLUGIN(LOG_DEBUG, "key_copied [%s]", key_copied); + + // call OfflineTokenCallback + if (cb) { + char *token = g_strdup("samsung_token"); + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_get_offline_token: before callback"); + cb(arg, token, strlen(token)); + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_get_offline_token: after callback"); + } + } else { + LOG_PLUGIN(LOG_ERROR, "[ERROR] key copy fail"); + } + } else { + LOG_PLUGIN(LOG_ERROR, "[ERROR] key or keyLengh parameter error"); + } + +} +int geoclue_plugin_test_offline_location(const unsigned char *key, + unsigned int keyLength, + const unsigned char *token, + unsigned int tokenSize, + LocationCallback cb, + void *arg) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_offline_location called"); + + if (cb) { + if (xps_plugint_test) { + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_offline_location: before callback"); + cb(arg, xps_plugint_test->location, NULL); + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_offline_location: before callback"); + xps_plugint_test->location_cb = cb; + xps_plugint_test->arg = arg; + } + } + return TRUE; +} + +EXPORT_API const geoclue_plugin_interface *get_geoclue_plugin_interface() +{ + LOG_PLUGIN(LOG_DEBUG, "get_geoclue_plugin_interface called"); + return &g_geoclue_plugin_interface_test_interface; +} diff --git a/xps-plugin/src/geoclue_xps_plugin_test.c b/xps-plugin/src/geoclue_xps_plugin_test.c new file mode 100755 index 0000000..9e5c8a6 --- /dev/null +++ b/xps-plugin/src/geoclue_xps_plugin_test.c @@ -0,0 +1,271 @@ +/* + * gps-manager replay plugin + * + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Youngae Kang , Minjune Kim + * Genie Kim + * + * 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 +#include +#include +#include +#include +#include + +#include + +#include "geoclue_plugin_debug.h" + + +int geoclue_plugin_test_load(void); +int geoclue_plugin_test_unload(void); +int geoclue_plugin_test_location(unsigned long period, LocationCallback cb, void *arg, void **handle); +int geoclue_plugin_test_cancel(void *handle, CancelCallback cb, void *arg); +void geoclue_plugin_test_get_offline_token(const unsigned char *key, + unsigned int keyLengh, + OfflineTokenCallback cb, + void *arg); +int geoclue_plugin_test_offline_location(const unsigned char *key, + unsigned int keyLength, + const unsigned char *token, + unsigned int tokenSize, + LocationCallback cb, + void *arg); + +static const geoclue_plugin_interface g_geoclue_plugin_interface_test_interface = { + geoclue_plugin_test_load, + geoclue_plugin_test_unload, + geoclue_plugin_test_location, + geoclue_plugin_test_cancel, + geoclue_plugin_test_get_offline_token, + geoclue_plugin_test_offline_location +}; + +typedef struct { + int index; // used for handle + plugin_LocationInfo *location; + unsigned long period; + LocationCallback location_cb; // save from location + void *arg; // save from location +} GeoclueXpsPluginTest; + +static GeoclueXpsPluginTest *xps_plugint_test = NULL; + +static gboolean update_fake_position(gpointer data) +{ + GeoclueXpsPluginTest *xps_plugin = data; + + if (xps_plugin) { + if (xps_plugin->location) { + if (xps_plugin->location->latitude < 90) { + xps_plugin->location->latitude++; + } else { + xps_plugin->location->latitude = 0; + } + if (xps_plugin->location->longitude< 180) { + xps_plugin->location->longitude++; + } else { + xps_plugin->location->longitude = 0; + } + if (xps_plugin->location->age < 10000) { + xps_plugin->location->age++; + } else { + xps_plugin->location->age = 0; + } + if (xps_plugin->location->altitude < 5000) { + xps_plugin->location->altitude++; + } else { + xps_plugin->location->altitude = 0; + } + if (xps_plugin->location->bearing < 90) { + xps_plugin->location->bearing++; + } else { + xps_plugin->location->bearing = 0; + } + if (xps_plugin->location->hpe < 100) { + xps_plugin->location->hpe++; + } else { + xps_plugin->location->hpe = 0; + } + if (xps_plugin->location->speed < 250) { + xps_plugin->location->speed++; + } else { + xps_plugin->location->speed = 0; + } + } + + // called intervals + if (xps_plugin->location_cb) { + xps_plugin->location_cb(xps_plugin->arg, xps_plugin->location, NULL); + } + } + + return TRUE; +} + +int geoclue_plugin_test_load(void) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_load called"); + + + // create plugin_LocationInfo *location + if (NULL == xps_plugint_test) { + xps_plugint_test = g_new0(GeoclueXpsPluginTest, 1); + if (NULL == xps_plugint_test) { + LOG_PLUGIN(LOG_ERROR, "[ERROR] GeoclueXpsPluginTest create fail"); + return FALSE; + } else { + xps_plugint_test->index = 0; + xps_plugint_test->period = 5000; // 5s + xps_plugint_test->location = g_new0(plugin_LocationInfo, 1); + if (NULL == xps_plugint_test->location) { + LOG_PLUGIN(LOG_ERROR, "[ERROR] plugin_LocationInfo create fail"); + g_free(xps_plugint_test); + return FALSE; + } + xps_plugint_test->location->latitude = 10; + xps_plugint_test->location->longitude = 10; + xps_plugint_test->location->hpe = 10; + xps_plugint_test->location->altitude= 10; + xps_plugint_test->location->age = 10; + xps_plugint_test->location->speed = 10; + xps_plugint_test->location->bearing = 10; + } + } + + // create the timer + //g_timeout_add (xps_plugint_test->period, update_fake_position, xps_plugint_test); + g_timeout_add (5000, update_fake_position, xps_plugint_test); + + return TRUE; +} +int geoclue_plugin_test_unload(void) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_unload called"); + + // free plugin_LocationInfo *location + if (xps_plugint_test) { + if (xps_plugint_test->location) { + g_free(xps_plugint_test->location); + xps_plugint_test->location = NULL; + } + g_free(xps_plugint_test); + xps_plugint_test = NULL; + } + + // kill the timer + return TRUE; +} +int geoclue_plugin_test_location(unsigned long period, LocationCallback cb, void *arg, void **handle) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_location called"); + + // update the plugin_LocationInfo *location in the timer + + // update handle + if (xps_plugint_test) { + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_location: before set handle"); + xps_plugint_test->index++; + gchar *tmp = g_strdup_printf("%d", xps_plugint_test->index); + *handle = (void *)tmp; + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_location: after set handle, set[%s], handle[%s]", tmp, *handle); + + // call LocationCallback + if (cb) { + cb(arg, xps_plugint_test->location, NULL); + xps_plugint_test->location_cb = cb; + xps_plugint_test->arg = arg; + } + + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_location after call callback"); + } + + return TRUE; // to test online + //return FALSE; // to test the offline +} +int geoclue_plugin_test_cancel(void *handle, CancelCallback cb, void *arg) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_cancel called"); + // check handle + if (handle) { + LOG_PLUGIN(LOG_DEBUG, "canel handle %s", handle); + g_free(handle); + handle = NULL; + } + + // call CancelCallback + if (cb) { + cb(arg); + } + return TRUE; +} + +void geoclue_plugin_test_get_offline_token(const unsigned char *key, + unsigned int keyLengh, + OfflineTokenCallback cb, + void *arg) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_get_offline_token called"); + + unsigned char *key_copied = NULL; + if (key && keyLengh > 0) { + key_copied = g_memdup(key, keyLengh); + key_copied[keyLengh - 1] = '\0'; + if (key_copied) { + LOG_PLUGIN(LOG_DEBUG, "key_copied [%s]", key_copied); + + // call OfflineTokenCallback + if (cb) { + char *token = g_strdup("samsung_token"); + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_get_offline_token: before callback"); + cb(arg, token, strlen(token)); + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_get_offline_token: after callback"); + } + } else { + LOG_PLUGIN(LOG_ERROR, "[ERROR] key copy fail"); + } + } else { + LOG_PLUGIN(LOG_ERROR, "[ERROR] key or keyLengh parameter error"); + } + +} +int geoclue_plugin_test_offline_location(const unsigned char *key, + unsigned int keyLength, + const unsigned char *token, + unsigned int tokenSize, + LocationCallback cb, + void *arg) +{ + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_offline_location called"); + + if (cb) { + if (xps_plugint_test) { + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_offline_location: before callback"); + cb(arg, xps_plugint_test->location, NULL); + LOG_PLUGIN(LOG_DEBUG, "geoclue_plugin_test_offline_location: before callback"); + xps_plugint_test->location_cb = cb; + xps_plugint_test->arg = arg; + } + } + return TRUE; +} + +EXPORT_API const geoclue_plugin_interface *get_geoclue_plugin_interface() +{ + LOG_PLUGIN(LOG_DEBUG, "get_geoclue_plugin_interface called"); + return &g_geoclue_plugin_interface_test_interface; +} -- 2.7.4