From 209c999100c1fd37e4e7c91b94608bd43abf0147 Mon Sep 17 00:00:00 2001 From: Genie Kim Date: Tue, 21 Aug 2012 18:30:02 +0900 Subject: [PATCH] Release Tizen2.0 beta Change-Id: I67cb00f16e4a7997da9795ee68d69ca7ad1c1d27 --- AUTHORS | 2 +- configure.ac | 6 +- debian/changelog | 124 +++++++++++-- debian/control | 4 +- debian/gps-manager.postinst.in | 9 +- gps-manager/gps-manager-plugin.pc.in | 2 +- gps-manager/gps_manager.c | 241 +++++++++++--------------- gps-manager/include/gps_manager_plugin_intf.h | 3 +- gps-manager/last_position.c | 34 ++-- gps-manager/nmea_logger.c | 39 +++-- gps-manager/plugin_module.c | 6 +- gps-manager/plugin_module.h | 6 +- gps-manager/server.c | 193 ++++++++++++--------- gps-manager/setting.h | 34 +--- module/module_gps_manager.c | 175 ++++++------------- packaging/gps-manager.spec | 27 +-- 16 files changed, 450 insertions(+), 455 deletions(-) diff --git a/AUTHORS b/AUTHORS index cc7be1c..01fda69 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,3 @@ Youngae Kang -Yunhan Kim +Minjune Kim Genie Kim diff --git a/configure.ac b/configure.ac index 8d25d28..b91fbd3 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,7 @@ AC_COMPILE_IFELSE( AC_MSG_RESULT($has_visibility) # Check required libraries -PKG_CHECK_MODULES(PROVIDERS, [glib-2.0 dbus-glib-1 >= 0.60 geoclue network tapi vconf heynoti sysman msg-service gthread-2.0 dlog pmapi]) +PKG_CHECK_MODULES(PROVIDERS, [glib-2.0 dbus-glib-1 >= 0.60 geoclue network tapi vconf vconf-internal-keys heynoti sysman msg-service gthread-2.0 dlog pmapi]) AC_SUBST(PRIVIDERS_CFLAGS) AC_SUBST(PROVIDERS_LIBS) @@ -73,7 +73,7 @@ AC_ARG_ENABLE([gps], no) gps=no ;; *) AC_MSG_ERROR([Bad value ${enableval} for --enable-gps]) ;; esac],[gps=no]) -AM_CONDITIONAL([GPS], [test "x$gps" = xyes]) +AM_CONDITIONAL([GPS], [test "x$gps" = xyes]) AC_MSG_CHECKING([whether host GPS]) if ([test "x$gps" = xyes]) then @@ -81,7 +81,7 @@ then else AC_MSG_RESULT([no]) fi -AM_CONDITIONAL([HAVE_GPS], [test "x$gps" = xyes]) +AM_CONDITIONAL([HAVE_GPS], [test "x$gps" = xyes]) # Check DBus configuration path DBUS_CONF_DIR="${sysconfdir}/dbus-1/system.d" diff --git a/debian/changelog b/debian/changelog index 369a067..70271d6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,112 @@ +gps-manager (0.2.1-12) unstable; urgency=low + + * Apply the modification of msg-service. + * Tag: gps-manager_0.2.1-12 + + -- Minjune Kim Tue, 07 Aug 2012 11:22:00 +0900 + +gps-manager (0.2.1-11) unstable; urgency=low + + * Update velocity before a position. + * Tag: gps-manager_0.2.1-11 + + -- Minjune Kim Fri, 03 Aug 2012 16:43:19 +0900 + +gps-manager (0.2.1-10) unstable; urgency=low + + * Support wps for an emulator. + * Tag: gps-manager_0.2.1-10 + + -- Minjune Kim Fri, 13 Jul 2012 14:52:34 +0900 + +gps-manager (0.2.1-9) unstable; urgency=low + + * Strip /usr/libexec/gps-manager + * Tag: gps-manager_0.2.1-9 + + -- Minjune Kim Wed, 11 Jul 2012 21:43:02 +0900 + +gps-manager (0.2.1-8) unstable; urgency=low + + * change NMEA saved directory and prevent saving NMEA log for each session while running TTFF test + * Tag: gps-manager_0.2.1-8 + + -- sunggyu lee Fri, 29 Jun 2012 18:10:42 +0900 + +gps-manager (0.2.1-7) unstable; urgency=low + + * Apply new glib + * Tag: gps-manager_0.2.1-7 + + -- Minjune Kim Mon, 18 Jun 2012 21:14:04 +0900 + +gps-manager (0.2.1-6) unstable; urgency=low + + * adjust broadcom supl server + * change directory path of config files to /etc(for FOTA) + * Tag: gps-manager_0.2.1-6 + + -- Genie Kim Fri, 15 Jun 2012 14:27:30 +0900 + +gps-manager (0.2.1-5) unstable; urgency=low + + * remove sensor module and disable sensor aiding + * Tag: gps-manager_0.2.1-5 + + -- Genie Kim Tue, 12 Jun 2012 20:31:41 +0900 + +gps-manager (0.2.1-4) unstable; urgency=low + + * change to set gps status for indicator(separate position/gps/wps status) + * Tag: gps-manager_0.2.1-4 + + -- Genie Kim Thu, 07 Jun 2012 23:23:00 +0900 + +gps-manager (0.2.1-3) unstable; urgency=low + + * changes start & stop gps-manager to use set_options + * Tag: gps-manager_0.2.1-3 + + -- Genie Kim Sun, 03 Jun 2012 20:56:56 +0900 + +gps-manager (0.2.1-2) unstable; urgency=low + + * remove vconf depends in plugin dev pc file + * Tag: gps-manager_0.2.1-2 + + -- Genie Kim Fri, 25 May 2012 22:56:24 +0900 + +gps-manager (0.2.1-1) unstable; urgency=low + + * load gps-manager sensor plugin(pdr) + * Tag: gps-manager_0.2.1-1 + + -- Genie Kim Thu, 24 May 2012 21:26:05 +0900 + +gps-manager (0.2.0-3) unstable; urgency=low + + * fix bug for vconf key(gps/wps state) + * Tag: gps-manager_0.2.0-3 + + -- Genie Kim Thu, 24 May 2012 11:45:16 +0900 + +gps-manager (0.2.0-2) unstable; urgency=low + + * fix build break in i386(remove pdr feature) + * Tag: gps-manager_0.2.0-2 + + -- Genie Kim Wed, 16 May 2012 11:49:51 +0900 + +gps-manager (0.2.0-1) unstable; urgency=low + + * add pdr feature and change vconf key + * Tag: gps-manager_0.2.0-1 + + -- Genie Kim Tue, 15 May 2012 20:03:33 +0900 + gps-manager (0.1.6-7) unstable; urgency=low * fixed bug for setting replay mode on emulator - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.6-7 -- Genie Kim Fri, 06 Apr 2012 11:16:43 +0900 @@ -9,7 +114,6 @@ gps-manager (0.1.6-7) unstable; urgency=low gps-manager (0.1.6-6) unstable; urgency=low * check abnormal value of speed and direction in last velocity - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.6-6 -- Genie Kim Mon, 02 Apr 2012 17:12:29 +0900 @@ -17,7 +121,6 @@ gps-manager (0.1.6-6) unstable; urgency=low gps-manager (0.1.6-5) unstable; urgency=low * Read vconf to get last_position and last_velocity on module - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.6-5 -- Minjune Kim Tue, 27 Mar 2012 11:14:08 +0900 @@ -25,7 +128,6 @@ gps-manager (0.1.6-5) unstable; urgency=low gps-manager (0.1.6-4) unstable; urgency=low * fixed bug for setting replay mode - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.6-4 -- Genie Kim Fri, 23 Mar 2012 10:56:10 +0900 @@ -33,7 +135,6 @@ gps-manager (0.1.6-4) unstable; urgency=low gps-manager (0.1.6-3) unstable; urgency=low * Move object_new to ref_gps_mananger in last_pos, last_vel and last_sat - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.6-3 -- Minjune Kim Tue, 20 Mar 2012 13:14:23 +0900 @@ -41,7 +142,6 @@ gps-manager (0.1.6-3) unstable; urgency=low gps-manager (0.1.6-2) unstable; urgency=low * Fix the bug that timestamp in satellite info had been wrong. - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.6-2 -- Minjune Kim Mon, 19 Mar 2012 16:43:05 +0900 @@ -49,7 +149,6 @@ gps-manager (0.1.6-2) unstable; urgency=low gps-manager (0.1.6-1) unstable; urgency=low * bug fix for last_pos/vel/sat functions - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.6-1 -- Genie Kim Thu, 08 Mar 2012 22:15:53 +0900 @@ -57,7 +156,6 @@ gps-manager (0.1.6-1) unstable; urgency=low gps-manager (0.1.5-3) unstable; urgency=low * Delete useless . in gps-manager.postinst.in - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.5-3 -- Youngae Kang Thu, 08 Mar 2012 10:16:39 +0900 @@ -65,7 +163,6 @@ gps-manager (0.1.5-3) unstable; urgency=low gps-manager (0.1.5-2) unstable; urgency=low * Remove checking a sat_cb to support an emulator. - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.5-2 -- Minjune Kim Wed, 07 Mar 2012 10:57:03 +0900 @@ -74,7 +171,6 @@ gps-manager (0.1.5-1) unstable; urgency=low * add feature for pos/vel/sat * add satellite callback in module - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.5-1 -- Genie Kim Mon, 27 Feb 2012 21:54:47 +0900 @@ -82,7 +178,6 @@ gps-manager (0.1.5-1) unstable; urgency=low gps-manager (0.1.4-2) unstable; urgency=low * Fix a crash while init WPS module on emulator - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.4-2 -- Minjune Kim Mon, 20 Feb 2012 22:36:47 +0900 @@ -90,7 +185,6 @@ gps-manager (0.1.4-2) unstable; urgency=low gps-manager (0.1.4-1) unstable; urgency=low * change indicator state to using gps and wps - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.4-1 -- Minjune Kim Fri, 17 Feb 2012 17:08:22 +0900 @@ -98,7 +192,6 @@ gps-manager (0.1.4-1) unstable; urgency=low gps-manager (0.1.3-2) unstable; urgency=low * add qcom plugin in script - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.3-2 -- Genie Kim Thu, 16 Feb 2012 11:18:58 +0900 @@ -106,7 +199,6 @@ gps-manager (0.1.3-2) unstable; urgency=low gps-manager (0.1.3-1) unstable; urgency=low * fixed bug at snprintf - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.3-1 -- Genie Kim Mon, 13 Feb 2012 12:37:29 +0900 @@ -114,7 +206,6 @@ gps-manager (0.1.3-1) unstable; urgency=low gps-manager (0.1.2-1) unstable; urgency=low * adjust replay plugin - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.2-1 -- Genie Kim Wed, 01 Feb 2012 16:30:55 +0900 @@ -122,7 +213,6 @@ gps-manager (0.1.2-1) unstable; urgency=low gps-manager (0.1.1-0) unstable; urgency=low * add last position and change setting key path - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.1-0 -- Genie Kim Thu, 26 Jan 2012 17:30:31 +0900 @@ -130,7 +220,6 @@ gps-manager (0.1.1-0) unstable; urgency=low gps-manager (0.1.0-1) unstable; urgency=low * Refactor source code. - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.0-1 -- Yunhan Kim Wed, 21 Dec 2011 17:01:05 +0900 @@ -138,7 +227,6 @@ gps-manager (0.1.0-1) unstable; urgency=low gps-manager (0.1.0-0) unstable; urgency=low * Initial release - * Git: slp/pkgs/g/gps-manager * Tag: gps-manager_0.1.0-0 -- Yunhan Kim Thu, 06 Oct 2011 14:41:51 +0900 diff --git a/debian/control b/debian/control index 86d4841..5d2eb65 100644 --- a/debian/control +++ b/debian/control @@ -2,13 +2,13 @@ Source: gps-manager Section: devel Priority: extra Maintainer: Youngae Kang , Yunhan Kim , Minjune Kim , Genie Kim -Build-Depends: debhelper (>= 4.0.0), autotools-dev, libslp-tapi-dev, libnetwork-dev, libglib2.0-dev, libdbus-glib-1-dev, dlog-dev, libslp-msg-service-dev, libslp-pm-dev, libheynoti-dev, libslp-sysman-dev, libgeoclue-dev, libslp-location-dev, libvconf-dev +Build-Depends: debhelper (>= 4.0.0), autotools-dev, libslp-tapi-dev, libnetwork-dev, libglib2.0-dev, libdbus-glib-1-dev, dlog-dev, libslp-msg-service-dev, libslp-pm-dev, libheynoti-dev, libslp-sysman-dev, libgeoclue-dev, libslp-location-dev, libvconf-dev, vconf-internal-keys-dev Package: gps-manager Section: net Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libslp-tapi-0, libnetwork-0, libglib2.0-0, libdlog-0, libslp-msg-service-0, libslp-pm-0, libheynoti-0, libslp-sysman -Description: GPS Manager for SLP +Description: GPS Manager for Tizen Package: location-gps-manager Section: libs diff --git a/debian/gps-manager.postinst.in b/debian/gps-manager.postinst.in index f10afcb..113be78 100644 --- a/debian/gps-manager.postinst.in +++ b/debian/gps-manager.postinst.in @@ -17,8 +17,9 @@ then fi #GPS Indicator value -vconftool set -t int memory/gps/state 0 -i -vconftool set -t int memory/wps/state 0 -i +vconftool set -t int memory/location/position/state 0 -i +vconftool set -t int memory/location/gps/state 0 -i +vconftool set -t int memory/location/wps/state 0 -i #GPS_SETTING vconftool set -t int db/location/gps/Operation "1" -f @@ -26,9 +27,9 @@ vconftool set -t int db/location/gps/Starting "0" -f vconftool set -t int db/location/gps/Session "1" -f #SUPL_SETTING -vconftool set -t string db/location/supl/Server "your.supl-server.com" -f +vconftool set -t string db/location/supl/Server "bcmls2.glpals.com" -f vconftool set -t int db/location/supl/Port "7275" -f -vconftool set -t int db/location/supl/SslEnabled "1" -f +vconftool set -t int db/location/supl/SslEnabled "0" -f #NMEA_SETTING vconftool set -t int db/location/nmea/LoggingEnabled "0" -f diff --git a/gps-manager/gps-manager-plugin.pc.in b/gps-manager/gps-manager-plugin.pc.in index 75703e0..7dde1e7 100644 --- a/gps-manager/gps-manager-plugin.pc.in +++ b/gps-manager/gps-manager-plugin.pc.in @@ -5,6 +5,6 @@ includedir=${prefix}/include Name: gps-manager-plugin Description: gps-manager plugin -Requires: vconf dlog +Requires: dlog Version: @VERSION@ Cflags: -I${includedir} -I${includedir}/gps-manager-plugin diff --git a/gps-manager/gps_manager.c b/gps-manager/gps_manager.c index 5e976f3..4dcb23a 100644 --- a/gps-manager/gps_manager.c +++ b/gps-manager/gps_manager.c @@ -43,6 +43,7 @@ #include "server.h" #include "last_position.h" +#include "debug_util.h" #define GEOCLUE_GPSMANAGER_DBUS_SERVICE "org.freedesktop.Geoclue.Providers.GpsManager" #define GEOCLUE_GPSMANAGER_DBUS_PATH "/org/freedesktop/Geoclue/Providers/GpsManager" @@ -50,6 +51,7 @@ typedef struct { GcProvider parent; GMainLoop *loop; + GMutex *mutex; GeoclueStatus status; pos_data_t position; @@ -59,7 +61,8 @@ typedef struct { pos_data_t last_position; sv_data_t last_satellite; - GHashTable *connections; + gboolean is_running; + gint client_count; } GeoclueGpsManager; typedef struct { @@ -82,19 +85,13 @@ G_DEFINE_TYPE_WITH_CODE(GeoclueGpsManager, geoclue_gpsmanager, GC_TYPE_PROVIDER, G_IMPLEMENT_INTERFACE(GC_TYPE_IFACE_SATELLITE, init_satellite) G_IMPLEMENT_INTERFACE(GC_TYPE_IFACE_GEOCLUE, init_geoclue)); -static void constructed(GObject * object) +static GObject* constructor (GType type, guint n_props, GObjectConstructParam *props) { - GeoclueGpsManager *gps_manager = GEOCLUE_GPSMANAGER(object); + GObject *object; - gps_manager->connections = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + object = ((GObjectClass *) geoclue_gpsmanager_parent_class)->constructor(type, n_props, props); - gps_manager->status = GEOCLUE_STATUS_UNAVAILABLE; - - memset(&gps_manager->position, 0x00, sizeof(pos_data_t)); - memset(&gps_manager->satellite, 0x00, sizeof(sv_data_t)); - memset(&gps_manager->nmea, 0x00, sizeof(nmea_data_t)); - - ((GObjectClass *) geoclue_gpsmanager_parent_class)->constructed(object); + return object; } static void finalize(GObject * object) @@ -105,9 +102,7 @@ static void finalize(GObject * object) static void dispose(GObject * object) { GeoclueGpsManager *gpsmanager = GEOCLUE_GPSMANAGER(object); - - g_hash_table_destroy(gpsmanager->connections); - + g_mutex_free(gpsmanager->mutex); ((GObjectClass *) geoclue_gpsmanager_parent_class)->dispose(object); } @@ -131,33 +126,87 @@ static gboolean get_provider_info(GcIfaceGeoclue * geoclue, gchar ** name, gchar return TRUE; } -static void print_option(gpointer key, gpointer value, gpointer data) +static void start_tracking(GeoclueGpsManager * gpsmanager) { - g_print(" %s - %s\n", (char *)key, (char *)value); + LOG_GPS(DBG_LOW, "start_tracking"); + gpsmanager->status = GEOCLUE_STATUS_ACQUIRING; + g_mutex_lock(gpsmanager->mutex); + if (request_start_session() == TRUE) { + gpsmanager->is_running = TRUE; + } else { + LOG_GPS(DBG_ERR, "Fail to request_start_session"); + } + g_mutex_unlock(gpsmanager->mutex); } -static gboolean set_options(GcIfaceGeoclue * gc, GHashTable * options, GError ** error) +static void stop_tracking(GeoclueGpsManager * gpsmanager) { - g_print("Options received---\n"); - g_hash_table_foreach(options, print_option, NULL); - return TRUE; + LOG_GPS(DBG_LOW, "stop_tracking"); + g_mutex_lock(gpsmanager->mutex); + if (request_stop_session() == TRUE) { + gpsmanager->is_running = FALSE; + } + g_mutex_unlock(gpsmanager->mutex); + gpsmanager->status = GEOCLUE_STATUS_UNAVAILABLE; } -static void shutdown(GcProvider * provider) +static gboolean set_options(GcIfaceGeoclue * gc, GHashTable * options, GError ** error) { - /* No shutdown!! */ + LOG_GPS(DBG_LOW, "set_options"); + + GeoclueGpsManager *gpsmanager = (GEOCLUE_GPSMANAGER(gc)); + gchar *value = NULL; + + value = g_hash_table_lookup(options, "CMD"); + + if (value) { + if (!g_strcmp0(value, "START")) { + g_mutex_lock(gpsmanager->mutex); + gpsmanager->client_count++; + g_mutex_unlock(gpsmanager->mutex); + + if (gpsmanager->is_running == TRUE) { + LOG_GPS(DBG_LOW, "gps-manager is already running"); + return TRUE; + } + start_tracking(gpsmanager); + } else if (!g_strcmp0(value, "STOP")) { + g_mutex_lock(gpsmanager->mutex); + gpsmanager->client_count--; + g_mutex_unlock(gpsmanager->mutex); + + if (gpsmanager->is_running == FALSE) { + return TRUE; + } + if (gpsmanager->client_count <= 0 ) { + stop_tracking(gpsmanager); + } + } + } + return TRUE; } -static void start_tracking(GeoclueGpsManager * gpsmanager) +static gboolean remove_all_clients(GeoclueGpsManager * gpsmanager) { - gpsmanager->status = GEOCLUE_STATUS_ACQUIRING; - request_start_session(); + if (gpsmanager->client_count <= 0) { + return FALSE; + } + + gpsmanager->client_count = 0; + stop_tracking(gpsmanager); + + return TRUE; } -static void stop_tracking(GeoclueGpsManager * gpsmanager) +static void shutdown(GcProvider * provider) { - request_stop_session(); - gpsmanager->status = GEOCLUE_STATUS_UNAVAILABLE; + GeoclueGpsManager *gpsmanager = (GEOCLUE_GPSMANAGER(provider)); + + if (gpsmanager->is_running) { + if (remove_all_clients(gpsmanager)) { + LOG_GPS(DBG_ERR, "<<<< Abnormal shutdown >>>>"); + } + } } static void update_position_cb(pos_data_t * pos, gps_error_t error, void *user_data) @@ -171,18 +220,16 @@ static void update_position_cb(pos_data_t * pos, gps_error_t error, void *user_d gpsmanager->status = GEOCLUE_STATUS_AVAILABLE; - fields = (GEOCLUE_POSITION_FIELDS_LATITUDE | GEOCLUE_POSITION_FIELDS_LONGITUDE | GEOCLUE_POSITION_FIELDS_ALTITUDE); - accuracy = geoclue_accuracy_new(GEOCLUE_ACCURACY_LEVEL_DETAILED, pos->hor_accuracy, pos->ver_accuracy); - gc_iface_position_emit_position_changed(GC_IFACE_POSITION(gpsmanager), - fields, pos->timestamp, pos->latitude, pos->longitude, pos->altitude, accuracy); - fields = (GEOCLUE_VELOCITY_FIELDS_SPEED | GEOCLUE_VELOCITY_FIELDS_DIRECTION); - gc_iface_velocity_emit_velocity_changed(GC_IFACE_VELOCITY(gpsmanager), fields, pos->timestamp, pos->speed, pos->bearing, 0.0); + fields = (GEOCLUE_POSITION_FIELDS_LATITUDE | GEOCLUE_POSITION_FIELDS_LONGITUDE | GEOCLUE_POSITION_FIELDS_ALTITUDE); + gc_iface_position_emit_position_changed(GC_IFACE_POSITION(gpsmanager), + fields, pos->timestamp, pos->latitude, pos->longitude, pos->altitude, accuracy); + geoclue_accuracy_free(accuracy); gc_iface_geoclue_emit_status_changed(GC_IFACE_GEOCLUE(gpsmanager), GEOCLUE_STATUS_AVAILABLE); @@ -238,100 +285,19 @@ static void update_nmea_cb(nmea_data_t * nmea, void *user_data) g_memmove(gpsmanager->nmea.data, nmea->data, nmea->len); gpsmanager->nmea.data[nmea->len] = '\0'; + timestamp = gpsmanager->position.timestamp; + gc_iface_nmea_emit_nmea_changed(GC_IFACE_NMEA(gpsmanager), timestamp, gpsmanager->nmea.data); g_free(gpsmanager->nmea.data); } -static void add_reference(GcIfaceGeoclue * gc, DBusGMethodInvocation * context) -{ - GeoclueGpsManager *gpsmanager = (GEOCLUE_GPSMANAGER(gc)); - char *sender; - int *pcount; - - sender = dbus_g_method_get_sender(context); - if (g_hash_table_size(gpsmanager->connections) == 0) { - start_tracking(gpsmanager); - } - pcount = g_hash_table_lookup(gpsmanager->connections, sender); - if (!pcount) { - pcount = g_malloc0(sizeof(int)); - g_hash_table_insert(gpsmanager->connections, sender, pcount); - } - (*pcount)++; - - g_debug("add_reference (%s) (%d)", sender, (*pcount)); - - dbus_g_method_return(context); -} - -static gboolean remove_client(GeoclueGpsManager * gpsmanager, const char *client) -{ - int *pcount; - - pcount = g_hash_table_lookup(gpsmanager->connections, client); - if (!pcount) { - return FALSE; - } - (*pcount)--; - if (*pcount == 0) { - g_hash_table_remove(gpsmanager->connections, client); - } - if (g_hash_table_size(gpsmanager->connections) == 0) { - g_debug("There is no connections!"); - stop_tracking(gpsmanager); - } - return TRUE; -} - -static gboolean remove_all_clients(GeoclueGpsManager * gpsmanager, const char *client) -{ - int *pcount; - - pcount = g_hash_table_lookup(gpsmanager->connections, client); - if (!pcount) { - return FALSE; - } - g_hash_table_remove(gpsmanager->connections, client); - if (g_hash_table_size(gpsmanager->connections) == 0) { - g_debug("There is no connections!"); - stop_tracking(gpsmanager); - } - return TRUE; -} - -static void remove_reference(GcIfaceGeoclue * gc, DBusGMethodInvocation * context) -{ - GeoclueGpsManager *gpsmanager = (GEOCLUE_GPSMANAGER(gc)); - char *sender; - - sender = dbus_g_method_get_sender(context); - if (!remove_client(gpsmanager, sender)) { - g_warning("Unreffed by client taht has not been referenced"); - } - - g_free(sender); - - dbus_g_method_return(context); -} - -static void name_owner_changed(DBusGProxy * proxy, const char *name, const char *prev_owner, const char *new_owner, void *gc) -{ - GeoclueGpsManager *gpsmanager = (GEOCLUE_GPSMANAGER(gc)); - g_debug("name_owner_changed, name:%s, prev_owner:%s, new_owner:%s", name, prev_owner, new_owner); - if (strcmp(new_owner, "") == 0 && strcmp(name, prev_owner) == 0) { - if (remove_all_clients(gpsmanager, prev_owner)) { - g_warning("Impolite client %s disconnected without unreferencing\n", prev_owner); - } - } -} - static void geoclue_gpsmanager_class_init(GeoclueGpsManagerClass * klass) { GObjectClass *o_class = (GObjectClass *) klass; GcProviderClass *p_class = (GcProviderClass *) klass; - o_class->constructed = constructed; + o_class->constructor = constructor; o_class->finalize = finalize; o_class->dispose = dispose; p_class->get_status = get_status; @@ -341,34 +307,22 @@ static void geoclue_gpsmanager_class_init(GeoclueGpsManagerClass * klass) static void geoclue_gpsmanager_init(GeoclueGpsManager * gpsmanager) { - GError *error = NULL; - DBusGProxy *driver; - guint request_ret; - GcProvider *provider; - g_debug("geoclue_gpsmanager_init"); - - g_return_if_fail(GC_IS_PROVIDER(gpsmanager)); - provider = GC_PROVIDER(gpsmanager); - g_return_if_fail(provider->connection != NULL); - - driver = dbus_g_proxy_new_for_name(provider->connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); - - if (!org_freedesktop_DBus_request_name(driver, GEOCLUE_GPSMANAGER_DBUS_SERVICE, 0, &request_ret, &error)) { - g_warning("%s was unable to register service %s: %s", - G_OBJECT_TYPE_NAME(provider), GEOCLUE_GPSMANAGER_DBUS_SERVICE, error->message); - g_error_free(error); - return; - } + LOG_GPS(DBG_LOW, "geoclue_gpsmanager_init"); - dbus_g_proxy_add_signal(driver, "NameOwnerChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - - dbus_g_proxy_connect_signal(driver, "NameOwnerChanged", G_CALLBACK(name_owner_changed), provider, NULL); - - dbus_g_connection_register_g_object(provider->connection, GEOCLUE_GPSMANAGER_DBUS_PATH, G_OBJECT(provider)); + gpsmanager->status = GEOCLUE_STATUS_UNAVAILABLE; + gpsmanager->mutex = g_mutex_new(); + memset(&gpsmanager->position, 0x00, sizeof(pos_data_t)); + memset(&gpsmanager->satellite, 0x00, sizeof(sv_data_t)); + memset(&gpsmanager->nmea, 0x00, sizeof(nmea_data_t)); memset(&gpsmanager->last_position, 0x00, sizeof(pos_data_t)); memset(&gpsmanager->last_satellite, 0x00, sizeof(sv_data_t)); + gpsmanager->is_running = FALSE; + gpsmanager->client_count = 0; + + gc_provider_set_details(GC_PROVIDER(gpsmanager), GEOCLUE_GPSMANAGER_DBUS_SERVICE, GEOCLUE_GPSMANAGER_DBUS_PATH, "gps-manager", "GPS Manager"); + gps_manager_get_last_position(&gpsmanager->last_position); } @@ -697,8 +651,6 @@ static void init_satellite(GcIfaceSatelliteClass * iface) static void init_geoclue(GcIfaceGeoclueClass * iface) { iface->get_provider_info = get_provider_info; - iface->add_reference = add_reference; - iface->remove_reference = remove_reference; } int main(int argc, char **argv) @@ -709,9 +661,12 @@ int main(int argc, char **argv) cb.sv_cb = update_satellite_cb; cb.nmea_cb = update_nmea_cb; +#if !GLIB_CHECK_VERSION (2, 31, 0) if (!g_thread_supported()) { g_thread_init(NULL); } +#endif + dbus_g_thread_init(); g_type_init(); diff --git a/gps-manager/include/gps_manager_plugin_intf.h b/gps-manager/include/gps_manager_plugin_intf.h index 182066a..71c99ab 100644 --- a/gps-manager/include/gps_manager_plugin_intf.h +++ b/gps-manager/include/gps_manager_plugin_intf.h @@ -279,7 +279,7 @@ typedef int (*gps_event_cb) (gps_event_info_t *gps_event_info); * GPS action type */ typedef enum { - GPS_ACTION_SEND_PARAMS = 0x00, + GPS_ACTION_SEND_PARAMS = 0x000, GPS_ACTION_START_SESSION, GPS_ACTION_STOP_SESSION, @@ -288,7 +288,6 @@ typedef enum { GPS_ACTION_START_FACTTEST, GPS_ACTION_STOP_FACTTEST, - GPS_ACTION_REQUEST_SUPL_NI } gps_action_t; diff --git a/gps-manager/last_position.c b/gps-manager/last_position.c index 77baee3..ffd9a13 100644 --- a/gps-manager/last_position.c +++ b/gps-manager/last_position.c @@ -31,7 +31,7 @@ void gps_manager_set_last_position(pos_data_t * last_pos) { LOG_GPS(DBG_LOW, "set Latitude = %f Longitude = %f Altitude = %f", last_pos->latitude, last_pos->longitude, last_pos->altitude); LOG_GPS(DBG_LOW, "set Speed = %f Direction = %f", last_pos->speed, last_pos->bearing); - LOG_GPS(DBG_LOW, "set H_Accuracy = %f V_Accuracy = %f", last_pos->hor_accuracy, last_pos->ver_accuracy); + LOG_GPS(DBG_LOW, "set H_Accuracy = %d V_Accuracy = %d", last_pos->hor_accuracy, last_pos->ver_accuracy); int timestamp = last_pos->timestamp; double lat = last_pos->latitude; @@ -42,14 +42,14 @@ void gps_manager_set_last_position(pos_data_t * last_pos) double h_acc = last_pos->hor_accuracy; double v_acc = last_pos->ver_accuracy; - setting_set_int(LAST_TIMESTAMP, timestamp); - setting_set_double(LAST_LATITUDE, lat); - setting_set_double(LAST_LONGITUDE, lon); - setting_set_double(LAST_ALTITUDE, alt); - setting_set_double(LAST_SPEED, spd); - setting_set_double(LAST_DIRECTION, dir); - setting_set_double(LAST_HOR_ACCURACY, h_acc); - setting_set_double(LAST_VER_ACCURACY, v_acc); + setting_set_int(VCONFKEY_LOCATION_LAST_GPS_TIMESTAMP, timestamp); + setting_set_double(VCONFKEY_LOCATION_LAST_GPS_LATITUDE, lat); + setting_set_double(VCONFKEY_LOCATION_LAST_GPS_LONGITUDE, lon); + setting_set_double(VCONFKEY_LOCATION_LAST_GPS_ALTITUDE, alt); + setting_set_double(VCONFKEY_LOCATION_LAST_GPS_SPEED, spd); + setting_set_double(VCONFKEY_LOCATION_LAST_GPS_DIRECTION, dir); + setting_set_double(VCONFKEY_LOCATION_LAST_GPS_HOR_ACCURACY, h_acc); + setting_set_double(VCONFKEY_LOCATION_LAST_GPS_VER_ACCURACY, v_acc); } void gps_manager_get_last_position(pos_data_t * last_pos) @@ -59,14 +59,14 @@ void gps_manager_get_last_position(pos_data_t * last_pos) double spd, dir; double h_acc, v_acc; - setting_get_int(LAST_TIMESTAMP, ×tamp); - setting_get_double(LAST_LATITUDE, &lat); - setting_get_double(LAST_LONGITUDE, &lon); - setting_get_double(LAST_ALTITUDE, &alt); - setting_get_double(LAST_SPEED, &spd); - setting_get_double(LAST_DIRECTION, &dir); - setting_get_double(LAST_HOR_ACCURACY, &h_acc); - setting_get_double(LAST_VER_ACCURACY, &v_acc); + setting_get_int(VCONFKEY_LOCATION_LAST_GPS_TIMESTAMP, ×tamp); + setting_get_double(VCONFKEY_LOCATION_LAST_GPS_LATITUDE, &lat); + setting_get_double(VCONFKEY_LOCATION_LAST_GPS_LONGITUDE, &lon); + setting_get_double(VCONFKEY_LOCATION_LAST_GPS_ALTITUDE, &alt); + setting_get_double(VCONFKEY_LOCATION_LAST_GPS_SPEED, &spd); + setting_get_double(VCONFKEY_LOCATION_LAST_GPS_DIRECTION, &dir); + setting_get_double(VCONFKEY_LOCATION_LAST_GPS_HOR_ACCURACY, &h_acc); + setting_get_double(VCONFKEY_LOCATION_LAST_GPS_VER_ACCURACY, &v_acc); last_pos->timestamp = timestamp; last_pos->latitude = lat; diff --git a/gps-manager/nmea_logger.c b/gps-manager/nmea_logger.c index d23ff9a..fd14e6f 100644 --- a/gps-manager/nmea_logger.c +++ b/gps-manager/nmea_logger.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include "nmea_logger.h" @@ -30,17 +32,32 @@ #define MAX_NMEA_RAW_DATA_LOG_FILE_CNT (999) #define MAX_NMEA_LOG_FILE_PATH (100) -#define NMEA_LOGGING_FILE_PATH "/opt/data/gps-manager/res/nmea_data" + +#define PHONE_FOLDER "/opt/media" +#define GPSMANAGER_FOLDER PHONE_FOLDER"/gps-manager" +#define NMEA_FOLDER GPSMANAGER_FOLDER"/NMEA" +#define NMEA_LOGGING_FILE_PATH NMEA_FOLDER"/nmea_data" int raw_nmea_fd = -1; -static int open_nmea_log_file(const char *); +static int generate_nmea_log_file(char *); void start_nmea_log() { char filepath[MAX_NMEA_LOG_FILE_PATH]; - if (open_nmea_log_file(filepath) == -1) { + // File Open + struct stat st = {0}; + + if (stat(GPSMANAGER_FOLDER, &st) == -1) { + mkdir(GPSMANAGER_FOLDER, 0777); + } + + if(stat(NMEA_FOLDER, &st) == -1) + mkdir(NMEA_FOLDER, 0777); + + + if (generate_nmea_log_file(filepath) == -1) { LOG_GPS(DBG_ERR, "Starting LBS Logging for RAW NMEA data FAILED!"); raw_nmea_fd = -1; return; @@ -48,10 +65,10 @@ void start_nmea_log() raw_nmea_fd = open(filepath, O_RDWR | O_APPEND | O_CREAT, 0644); - if (raw_nmea_fd < -1) { + if (raw_nmea_fd < 0) { LOG_GPS(DBG_ERR, "FAILED to open [%s], error[%d]", filepath, errno); } else { - LOG_GPS(DBG_LOW, "%s raw_nmea_fd [%d]", filepath, raw_nmea_fd); + LOG_GPS(DBG_LOW, "Success :: %s raw_nmea_fd [%d]", filepath, raw_nmea_fd); } return; @@ -88,20 +105,18 @@ void write_nmea_log(char *data, int len) return; } -static int open_nmea_log_file(const char *filepath) +static int generate_nmea_log_file(char *filepath) { int idx = 0; int fd = 0; char fn[MAX_NMEA_LOG_FILE_PATH]; for (idx = 0; idx < MAX_NMEA_RAW_DATA_LOG_FILE_CNT; idx++) { - snprintf(fn, MAX_NMEA_LOG_FILE_PATH, "%s%03d.log", NMEA_LOGGING_FILE_PATH, idx); - fd = open(fn, O_RDONLY); - if (fd == -1) { - LOG_GPS(DBG_LOW, "next log file [%s]", fn); + snprintf(fn, MAX_NMEA_LOG_FILE_PATH, "%s%03d.txt", NMEA_LOGGING_FILE_PATH, idx); + if ((fd = access(fn, R_OK)) == -1) { + LOG_GPS(DBG_LOW, "Next log file [%s]", fn); + strcpy(filepath, fn); return 0; - } else { - close(fd); } } LOG_GPS(DBG_LOW, "All NMEA RAW Data logging files are used. New log file can not be created"); diff --git a/gps-manager/plugin_module.c b/gps-manager/plugin_module.c index 93824ed..af492bb 100644 --- a/gps-manager/plugin_module.c +++ b/gps-manager/plugin_module.c @@ -28,9 +28,9 @@ #include "debug_util.h" #define SPECIFIC_PLUGIN_PATH_PREFIX "/usr/lib/libSLP-lbs-plugin-" -#define SPECIFIC_PLUGIN_PATH_POSTFIX ".so" +#define SPECIFIC_PLUGIN_PATH_POSTFIX ".so" -static const gps_plugin_interface *g_plugin; +static const gps_plugin_interface *g_plugin = NULL; int load_plugin_module(char *specific_name, void **plugin_handle) { @@ -48,7 +48,7 @@ int load_plugin_module(char *specific_name, void **plugin_handle) if (access (plugin_path, R_OK) != 0) { strncpy(plugin_path, GPS_MANAGER_PLUGIN_PATH, sizeof(plugin_path)); - setting_set_int(REPLAY_ENABLED, 1); + setting_set_int(VCONFKEY_LOCATION_REPLAY_ENABLED, 1); } *plugin_handle = dlopen(plugin_path, RTLD_NOW); diff --git a/gps-manager/plugin_module.h b/gps-manager/plugin_module.h index 2f72746..1fb1440 100644 --- a/gps-manager/plugin_module.h +++ b/gps-manager/plugin_module.h @@ -19,8 +19,8 @@ * limitations under the License. */ -#ifndef _GEOCLUE_AGPS_PLUGIN_MODULE_H_ -#define _GEOCLUE_AGPS_PLUGIN_MODULE_H_ +#ifndef _GPS_MANAGER_PLUGIN_MODULE_H_ +#define _GPS_MANAGER_PLUGIN_MODULE_H_ #include "gps_manager_plugin_intf.h" @@ -28,4 +28,4 @@ int load_plugin_module(char *specific_name, void **plugin_handle); int unload_plugin_module(void *plugin_handle); const gps_plugin_interface *get_plugin_module(void); -#endif /* _GEOCLUE_AGPS_PLUGIN_MODULE_H_ */ +#endif /* _GPS_MANAGER_PLUGIN_MODULE_H_ */ diff --git a/gps-manager/server.c b/gps-manager/server.c index 31c12dd..3383e20 100644 --- a/gps-manager/server.c +++ b/gps-manager/server.c @@ -41,9 +41,8 @@ #include "debug_util.h" #include "last_position.h" -#include -#include -#include +#include +#include #include #include @@ -54,7 +53,9 @@ #include #include +#if !GLIB_CHECK_VERSION (2, 31, 0) #include +#endif #include #define GPS_NI_POPUP "/usr/bin/gps_popup" @@ -98,20 +99,20 @@ static void _gps_mode_changed_cb(keynode_t * key, void *data) { int int_val; - if (setting_get_int(GPS_SESSION, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//ERROR!! GPS_SESSION setting get failed"); + if (setting_get_int(VCONFKEY_LOCATION_GPS_SESSION, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_GPS_SESSION setting"); int_val = GPS_SESSION_TRACKING_MODE; } g_gps_params.session_type = int_val; - if (setting_get_int(GPS_OPERATION, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//ERROR!! GPS_OPERATION setting get failed"); + if (setting_get_int(VCONFKEY_LOCATION_GPS_OPERATION, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_GPS_OPERATION setting"); int_val = GPS_OPERATION_STANDALONE; } g_gps_params.operation_mode = int_val; - if (setting_get_int(GPS_STARTING, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//ERROR!! GPS_STARTING setting get failed"); + if (setting_get_int(VCONFKEY_LOCATION_GPS_STARTING, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_GPS_STARTING setting"); int_val = GPS_STARTING_HOT_; } g_gps_params.starting_type = int_val; @@ -124,7 +125,7 @@ static void _gps_supl_changed_cb(keynode_t * key, void *data) int int_val; char *str; - str = setting_get_string(SUPL_SERVER); + str = setting_get_string(VCONFKEY_LOCATION_SUPL_SERVER); if (str == NULL) { snprintf(g_gps_params.supl_url, MAX_SUPL_URL_LEN, "%s", SUPL_SERVER_URL_DEFAULT); @@ -133,8 +134,8 @@ static void _gps_supl_changed_cb(keynode_t * key, void *data) snprintf(g_gps_params.supl_url, MAX_SUPL_URL_LEN, "%s", str); } - if (setting_get_int(SUPL_PORT, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//ERROR!! SUPL_PORT setting get failed"); + if (setting_get_int(VCONFKEY_LOCATION_SUPL_PORT, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_SUPL_PORT setting"); int_val = SUPL_SERVER_PORT_DEFAULT; } g_gps_params.supl_port = int_val; @@ -146,8 +147,8 @@ static void _gps_setting_changed_cb(keynode_t * key, void *data) { int int_val; - if (setting_get_int(SUPL_SSL, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//ERROR!! SUPL_SSL setting get failed"); + if (setting_get_int(VCONFKEY_LOCATION_SUPL_SSL, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_SUPL_SSL setting"); int_val = 0; } g_gps_params.ssl_mode = int_val; @@ -157,8 +158,8 @@ static void _gps_setting_changed_cb(keynode_t * key, void *data) static void _gps_nmea_changed_cb(keynode_t * key, void *data) { int int_val; - if (setting_get_int(NMEA_LOGGING, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "NMEA_LOGGING get Failed."); + if (setting_get_int(VCONFKEY_LOCATION_NMEA_LOGGING, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_NMEA_LOGGING setting"); int_val = 0; } logging_enabled = (int_val == 1) ? TRUE : FALSE; @@ -170,8 +171,8 @@ static gboolean get_replay_enabled() int int_val; gboolean ret; - if (setting_get_int(REPLAY_ENABLED, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "REPLAY_ENABLED get Failed."); + if (setting_get_int(VCONFKEY_LOCATION_REPLAY_ENABLED, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR get VCONFKEY_LOCATION_REPLAY_ENABLED setting"); int_val = 0; } @@ -210,31 +211,54 @@ static void reload_plugin_module() static void _gps_replay_changed_cb(keynode_t * key, void *data) { - replay_enabled = get_replay_enabled(); reload_plugin_module(); return; } -static void _gps_server_set_indicator(int gps_state) +static void _position_state_changed_cb(keynode_t * key, void *data) { int ret; + int gps_state = 0; int wps_state = 0; - setting_get_int(VCONFKEY_WPS_STATE, &wps_state); + setting_get_int(VCONFKEY_LOCATION_GPS_STATE, &gps_state); + setting_get_int(VCONFKEY_LOCATION_WPS_STATE, &wps_state); LOG_GPS(DBG_LOW, "gps state : [%d], wps state : [%d]", gps_state, wps_state); if (gps_state == POSITION_CONNECTED || wps_state == POSITION_CONNECTED) { - ret = setting_set_int(VCONFKEY_GPS_STATE, POSITION_CONNECTED); + ret = setting_set_int(VCONFKEY_LOCATION_POSITION_STATE, POSITION_CONNECTED); } else { if (gps_state == POSITION_OFF && wps_state == POSITION_OFF) { - ret = setting_set_int(VCONFKEY_GPS_STATE, POSITION_OFF); + ret = setting_set_int(VCONFKEY_LOCATION_POSITION_STATE, POSITION_OFF); } else { - ret = setting_set_int(VCONFKEY_GPS_STATE, POSITION_SEARCHING); + ret = setting_set_int(VCONFKEY_LOCATION_POSITION_STATE, POSITION_SEARCHING); } } + return; +} + +static void _gps_server_set_gps_state(int gps_state) +{ + int ret; + + switch (gps_state) { + case POSITION_CONNECTED: + ret = setting_set_int(VCONFKEY_LOCATION_GPS_STATE, POSITION_CONNECTED); + break; + case POSITION_SEARCHING: + ret = setting_set_int(VCONFKEY_LOCATION_GPS_STATE, POSITION_SEARCHING); + break; + case POSITION_OFF: + ret = setting_set_int(VCONFKEY_LOCATION_GPS_STATE, POSITION_OFF); + break; + default: + ret = setting_set_int(VCONFKEY_LOCATION_GPS_STATE, POSITION_OFF); + break; + } + if (ret == 1) { LOG_GPS(DBG_LOW, "Succesee to set indicator"); } else { @@ -289,7 +313,7 @@ static gboolean _initialize_data() int request_start_session() { - int status = TRUE; + gboolean status = TRUE; gps_failure_reason_t reason_code = GPS_FAILURE_CAUSE_NORMAL; if (gps_session_state != GPS_SESSION_STOPPED && gps_session_state != GPS_SESSION_STOPPING) { @@ -297,6 +321,8 @@ int request_start_session() return TRUE; } + gps_session_state = GPS_SESSION_STARTING; + LOG_GPS(DBG_LOW, "==GPSSessionState[%d]", gps_session_state); status = get_plugin_module()->request(GPS_ACTION_START_SESSION, &g_gps_params, &reason_code); if (status == FALSE) { @@ -307,16 +333,14 @@ int request_start_session() LOG_GPS(DBG_LOW, "Main: sending GPS_ACTION_START_SESSION OK !"); _initialize_data(); - gps_session_state = GPS_SESSION_STARTING; - LOG_GPS(DBG_LOW, "==GPSSessionState[%d]", gps_session_state); - setting_ignore_key_changed(REPLAY_ENABLED, _gps_replay_changed_cb); + setting_ignore_key_changed(VCONFKEY_LOCATION_REPLAY_ENABLED, _gps_replay_changed_cb); return TRUE; } int request_stop_session() { - unsigned int status = TRUE; + gboolean status = TRUE; gboolean cur_replay_enabled = FALSE; gps_failure_reason_t reason_code = GPS_FAILURE_CAUSE_NORMAL; @@ -331,7 +355,7 @@ int request_stop_session() replay_enabled = cur_replay_enabled; reload_plugin_module(); } - setting_notify_key_changed(REPLAY_ENABLED, _gps_replay_changed_cb); + setting_notify_key_changed(VCONFKEY_LOCATION_REPLAY_ENABLED, _gps_replay_changed_cb); } else { LOG_GPS(DBG_LOW, " plugin->request to LBS_GPS_STOP_SESSION Failed, reasonCode =%d", reason_code); } @@ -349,15 +373,15 @@ static void _gps_plugin_handler_init(char *module_name) g_gps_plugin.name = (char *)malloc(strlen(module_name) + 1); snprintf(g_gps_plugin.name, strlen(module_name) + 1, "%s", module_name); if (strcmp(REPLAY_MODULE, g_gps_plugin.name) == 0) { - setting_set_int(REPLAY_ENABLED, 1); + setting_set_int(VCONFKEY_LOCATION_REPLAY_ENABLED, 1); } else { - setting_set_int(REPLAY_ENABLED, 0); + setting_set_int(VCONFKEY_LOCATION_REPLAY_ENABLED, 0); } } static void _gps_plugin_handler_deinit() { - setting_set_int(REPLAY_ENABLED, 0); + setting_set_int(VCONFKEY_LOCATION_REPLAY_ENABLED, 0); if (g_gps_plugin.handle != NULL) { g_gps_plugin.handle = NULL; @@ -374,27 +398,27 @@ static void _gps_read_params() int int_val = 0; char *str; - if (setting_get_int(GPS_SESSION, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//ERROR!! GPS_SESSION setting get failed"); + if (setting_get_int(VCONFKEY_LOCATION_GPS_SESSION, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_GPS_SESSION setting"); int_val = GPS_SESSION_TRACKING_MODE; } g_gps_params.session_type = int_val; - if (setting_get_int(GPS_OPERATION, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//ERROR!! GPS_OPERATION setting get failed"); + if (setting_get_int(VCONFKEY_LOCATION_GPS_OPERATION, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_GPS_OPERATION setting"); int_val = GPS_OPERATION_STANDALONE; } g_gps_params.operation_mode = int_val; - if (setting_get_int(GPS_STARTING, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//ERROR!! TING_MODE setting get failed"); + if (setting_get_int(VCONFKEY_LOCATION_GPS_STARTING, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_GPS_STATING setting"); int_val = GPS_STARTING_HOT_; } g_gps_params.starting_type = int_val; g_gps_params.time_bn_fixes = 1; - str = setting_get_string(SUPL_SERVER); + str = setting_get_string(VCONFKEY_LOCATION_SUPL_SERVER); if (str == NULL) { snprintf(g_gps_params.supl_url, MAX_SUPL_URL_LEN, "%s", SUPL_SERVER_URL_DEFAULT); LOG_GPS(DBG_ERR, "vconf fail to get Server URL [Default URL]"); @@ -402,28 +426,28 @@ static void _gps_read_params() snprintf(g_gps_params.supl_url, MAX_SUPL_URL_LEN, "%s", str); } - if (setting_get_int(SUPL_PORT, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//ERROR!! SUPL_PORT setting get failed"); + if (setting_get_int(VCONFKEY_LOCATION_SUPL_PORT, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_SUPL_PORT setting"); int_val = SUPL_SERVER_PORT_DEFAULT; } g_gps_params.supl_port = int_val; LOG_GPS(DBG_LOW, "First Read!! SUPL server:%s, port:%d", g_gps_params.supl_url, g_gps_params.supl_port); - if (setting_get_int(SUPL_SSL, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//ERROR!! SUPL_SSL setting get failed"); + if (setting_get_int(VCONFKEY_LOCATION_SUPL_SSL, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_SUPL_SSL setting"); int_val = 0; } g_gps_params.ssl_mode = int_val; - if (setting_get_int(NMEA_LOGGING, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//NMEA_LOGGING get Failed."); + if (setting_get_int(VCONFKEY_LOCATION_NMEA_LOGGING, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_NMEA_LOGGING setting"); int_val = 0; } logging_enabled = (int_val == 1) ? TRUE : FALSE; - if (setting_get_int(REPLAY_ENABLED, &int_val) == FALSE) { - LOG_GPS(DBG_ERR, "//REPLAY_ENABLED get Failed."); + if (setting_get_int(VCONFKEY_LOCATION_REPLAY_ENABLED, &int_val) == FALSE) { + LOG_GPS(DBG_ERR, "//ERROR!! get VCONFKEY_LOCATION_REPLAY_ENABLED setting"); int_val = 0; } replay_enabled = (int_val == 1) ? TRUE : FALSE; @@ -431,26 +455,30 @@ static void _gps_read_params() static void _gps_notify_params() { - setting_notify_key_changed(GPS_SESSION, _gps_mode_changed_cb); - setting_notify_key_changed(GPS_OPERATION, _gps_mode_changed_cb); - setting_notify_key_changed(GPS_STARTING, _gps_mode_changed_cb); - setting_notify_key_changed(SUPL_SERVER, _gps_supl_changed_cb); - setting_notify_key_changed(SUPL_PORT, _gps_supl_changed_cb); - setting_notify_key_changed(SUPL_SSL, _gps_setting_changed_cb); - setting_notify_key_changed(NMEA_LOGGING, _gps_nmea_changed_cb); - setting_notify_key_changed(REPLAY_ENABLED, _gps_replay_changed_cb); + setting_notify_key_changed(VCONFKEY_LOCATION_GPS_SESSION, _gps_mode_changed_cb); + setting_notify_key_changed(VCONFKEY_LOCATION_GPS_OPERATION, _gps_mode_changed_cb); + setting_notify_key_changed(VCONFKEY_LOCATION_GPS_STARTING, _gps_mode_changed_cb); + setting_notify_key_changed(VCONFKEY_LOCATION_SUPL_SERVER, _gps_supl_changed_cb); + setting_notify_key_changed(VCONFKEY_LOCATION_SUPL_PORT, _gps_supl_changed_cb); + setting_notify_key_changed(VCONFKEY_LOCATION_SUPL_SSL, _gps_setting_changed_cb); + setting_notify_key_changed(VCONFKEY_LOCATION_NMEA_LOGGING, _gps_nmea_changed_cb); + setting_notify_key_changed(VCONFKEY_LOCATION_REPLAY_ENABLED, _gps_replay_changed_cb); + setting_notify_key_changed(VCONFKEY_LOCATION_GPS_STATE, _position_state_changed_cb); + setting_notify_key_changed(VCONFKEY_LOCATION_WPS_STATE, _position_state_changed_cb); } static void _gps_ignore_params() { - setting_ignore_key_changed(GPS_SESSION, _gps_mode_changed_cb); - setting_ignore_key_changed(GPS_OPERATION, _gps_mode_changed_cb); - setting_ignore_key_changed(GPS_STARTING, _gps_mode_changed_cb); - setting_ignore_key_changed(SUPL_SERVER, _gps_supl_changed_cb); - setting_ignore_key_changed(SUPL_PORT, _gps_supl_changed_cb); - setting_ignore_key_changed(SUPL_SSL, _gps_setting_changed_cb); - setting_ignore_key_changed(NMEA_LOGGING, _gps_nmea_changed_cb); - setting_ignore_key_changed(REPLAY_ENABLED, _gps_replay_changed_cb); + setting_ignore_key_changed(VCONFKEY_LOCATION_GPS_SESSION, _gps_mode_changed_cb); + setting_ignore_key_changed(VCONFKEY_LOCATION_GPS_OPERATION, _gps_mode_changed_cb); + setting_ignore_key_changed(VCONFKEY_LOCATION_GPS_STARTING, _gps_mode_changed_cb); + setting_ignore_key_changed(VCONFKEY_LOCATION_SUPL_SERVER, _gps_supl_changed_cb); + setting_ignore_key_changed(VCONFKEY_LOCATION_SUPL_PORT, _gps_supl_changed_cb); + setting_ignore_key_changed(VCONFKEY_LOCATION_SUPL_SSL, _gps_setting_changed_cb); + setting_ignore_key_changed(VCONFKEY_LOCATION_NMEA_LOGGING, _gps_nmea_changed_cb); + setting_ignore_key_changed(VCONFKEY_LOCATION_REPLAY_ENABLED, _gps_replay_changed_cb); + setting_ignore_key_changed(VCONFKEY_LOCATION_GPS_STATE, _position_state_changed_cb); + setting_ignore_key_changed(VCONFKEY_LOCATION_WPS_STATE, _position_state_changed_cb); } static void _gps_server_start_event() @@ -459,6 +487,7 @@ static void _gps_server_start_event() gps_session_state = GPS_SESSION_STARTED; if (logging_enabled) { + LOG_GPS(DBG_LOW, "NMEA STARTED"); start_nmea_log(); } @@ -497,7 +526,7 @@ static void _gps_server_start_event() } } - _gps_server_set_indicator(POSITION_SEARCHING); + _gps_server_set_gps_state(POSITION_SEARCHING); pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0); } @@ -507,10 +536,11 @@ static void _gps_server_stop_event() gps_session_state = GPS_SESSION_STOPPED; LOG_GPS(DBG_LOW, "==GPSSessionState[%d]", gps_session_state); - _gps_server_set_indicator(POSITION_OFF); + _gps_server_set_gps_state(POSITION_OFF); pm_unlock_state(LCD_NORMAL, PM_RESET_TIMER); if (logging_enabled) { + LOG_GPS(DBG_LOW, "NMEA STOPPED"); stop_nmea_log(); } @@ -541,7 +571,7 @@ static void _report_pos_event(gps_event_info_t * gps_event) gps_manager_set_last_position(gps_last_pos); memset(gps_pos_data, 0x00, sizeof(pos_data_t)); } else { - LOG_GPS(DBG_ERR, "gps_sv_data is NULL"); + LOG_GPS(DBG_ERR, "gps_pos_data is NULL"); } } @@ -714,9 +744,9 @@ static int _gps_server_gps_event_cb(gps_event_info_t * gps_event_info) LOG_GPS(DBG_LOW, "<<::::::::::: GPS_EVENT_SATELLITE :::::::::::::::"); if (gps_event_info->event_data.sv_ind.error == GPS_ERR_NONE) { if (gps_event_info->event_data.sv_ind.sv.pos_valid) { - _gps_server_set_indicator(POSITION_CONNECTED); + _gps_server_set_gps_state(POSITION_CONNECTED); } else { - _gps_server_set_indicator(POSITION_SEARCHING); + _gps_server_set_gps_state(POSITION_SEARCHING); } _report_sv_event(gps_event_info); } else { @@ -831,16 +861,16 @@ static void *_gps_launch_popup(void *data) } -static void _gps_supl_networkinit_smscb(MSG_HANDLE_T hMsgHandle, msg_message_t msg, void *user_param) +static void _gps_supl_networkinit_smscb(msg_handle_t hMsgHandle, msg_struct_t msg, void *user_param) { LOG_GPS(DBG_ERR, "_gps_supl_networkinit_smscb is called"); - LOG_GPS(DBG_ERR, "SUPLNI MSG size is [ %d ]", msg_get_message_body_size(msg)); gps_ni_popup_data_t new_message; memset(&new_message, 0x00, sizeof(new_message)); - new_message.msg_body = (char *)msg_sms_get_message_body(msg); - new_message.msg_size = msg_get_message_body_size(msg); + msg_get_int_value(msg, MSG_MESSAGE_DATA_SIZE_INT, &new_message.msg_size); + msg_get_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, new_message.msg_body, new_message.msg_size); + // TODO: Button number of LBS Popup new_message.num_btn = 2; @@ -854,7 +884,7 @@ static void _gps_supl_networkinit_smscb(MSG_HANDLE_T hMsgHandle, msg_message_t m } -static void _gps_supl_networkinit_wappushcb(MSG_HANDLE_T hMsgHandle, const char *pPushHeader, const char *pPushBody, +static void _gps_supl_networkinit_wappushcb(msg_handle_t hMsgHandle, const char *pPushHeader, const char *pPushBody, int pushBodyLen, void *user_param) { LOG_GPS(DBG_ERR, "_gps_supl_networkinit_wappushcb is called"); @@ -880,8 +910,8 @@ static void _gps_supl_networkinit_wappushcb(MSG_HANDLE_T hMsgHandle, const char static void *_gps_register_msgfwcb() { - MSG_HANDLE_T msgHandle = NULL; - MSG_ERROR_T err = MSG_SUCCESS; + msg_handle_t msgHandle = NULL; + msg_error_t err = MSG_SUCCESS; int setValue = 0; int ret; @@ -1003,16 +1033,15 @@ int initialize_server(int argc, char **argv) _gps_notify_params(); if (!load_plugin_module(g_gps_plugin.name, &g_gps_plugin.handle)) { - LOG_GPS(DBG_ERR, "Failed to load plugin module."); + LOG_GPS(DBG_ERR, "Fail to load plugin module."); return -1; } - LOG_GPS(DBG_LOW, "after read parameters......"); - if (!get_plugin_module()->init(_gps_server_gps_event_cb, &g_gps_params)) { - LOG_GPS(DBG_WARN, "//GPS Initialization failed"); + LOG_GPS(DBG_WARN, "Fail to gps-manager module initialization"); return -1; } + // Register SUPL NI cb to MSG server if (pthread_create(&msg_thread, NULL, _gps_register_msgfwcb, NULL) != 0) { LOG_GPS(DBG_WARN, "Can not make pthread......"); @@ -1039,10 +1068,10 @@ int deinitialize_server() _gps_ignore_params(); if (!get_plugin_module()->deinit(&ReasonCode)) { - LOG_GPS(DBG_WARN, "GPS De-Initialization failed."); + LOG_GPS(DBG_WARN, "Fail to gps-manager module de-initialization"); } - unload_plugin_module(g_gps_plugin.handle); + _gps_plugin_handler_deinit(); return 0; diff --git a/gps-manager/setting.h b/gps-manager/setting.h index b938af0..2e640a6 100644 --- a/gps-manager/setting.h +++ b/gps-manager/setting.h @@ -23,39 +23,7 @@ #define _GPS_MANAGER_SETTING_H_ #include -#include - -#define VCONFKEY_WPS_STATE "memory/wps/state" - -#define LOCATION_SETTING_PATH "db/location" - -#define GPS_SETTING LOCATION_SETTING_PATH"/gps" -#define GPS_OPERATION GPS_SETTING"/Operation" -#define GPS_STARTING GPS_SETTING"/Starting" -#define GPS_SESSION GPS_SETTING"/Session" - -#define SUPL_SETTING LOCATION_SETTING_PATH"/supl" -#define SUPL_SERVER SUPL_SETTING"/Server" -#define SUPL_PORT SUPL_SETTING"/Port" -#define SUPL_SSL SUPL_SETTING"/SslEnabled" - -#define NMEA_SETTING LOCATION_SETTING_PATH"/nmea" -#define NMEA_LOGGING NMEA_SETTING"/LoggingEnabled" - -#define REPLAY_SETTING LOCATION_SETTING_PATH"/replay" -#define REPLAY_ENABLED REPLAY_SETTING"/ReplayEnabled" - -#define LAST_POSITION LOCATION_SETTING_PATH"/last" -#define METHOD_GPS LAST_POSITION"/gps" - -#define LAST_TIMESTAMP METHOD_GPS"/Timestamp" -#define LAST_LATITUDE METHOD_GPS"/Latitude" -#define LAST_LONGITUDE METHOD_GPS"/Longitude" -#define LAST_ALTITUDE METHOD_GPS"/Altitude" -#define LAST_SPEED METHOD_GPS"/Speed" -#define LAST_DIRECTION METHOD_GPS"/Direction" -#define LAST_HOR_ACCURACY METHOD_GPS"/HorAccuracy" -#define LAST_VER_ACCURACY METHOD_GPS"/VerAccuracy" +#include typedef enum { POSITION_OFF = 0, diff --git a/module/module_gps_manager.c b/module/module_gps_manager.c index e92ea4e..98fb603 100644 --- a/module/module_gps_manager.c +++ b/module/module_gps_manager.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -37,19 +38,6 @@ #include "log.h" -#define VCONF_LOCATION_PATH "db/location" -#define LOCATION_LAST_PATH VCONF_LOCATION_PATH"/last" -#define GPS_LAST_PATH LOCATION_LAST_PATH"/gps" -#define GPS_LAST_TIMESTAMP GPS_LAST_PATH"/Timestamp" -#define GPS_LAST_LATITUDE GPS_LAST_PATH"/Latitude" -#define GPS_LAST_LONGITUDE GPS_LAST_PATH"/Longitude" -#define GPS_LAST_ALTITUDE GPS_LAST_PATH"/Altitude" -#define GPS_LAST_HORACCURACY GPS_LAST_PATH"/HorAccuracy" -#define GPS_LAST_VERACCURACY GPS_LAST_PATH"/VerAccuracy" -#define GPS_LAST_SPEED GPS_LAST_PATH"/Speed" -#define GPS_LAST_DIRECTION GPS_LAST_PATH"/Direction" - - typedef struct { char devname[256]; GeocluePosition *pos; @@ -99,6 +87,7 @@ static void satellite_callback(GeoclueSatellite * satellite, int timestamp, g_return_if_fail(gps_manager->sat_cb); guint idx; + guint used_idx; LocationSatellite *sat = NULL; sat = location_satellite_new(satellite_visible); @@ -107,8 +96,7 @@ static void satellite_callback(GeoclueSatellite * satellite, int timestamp, sat->num_of_sat_inview = satellite_visible; sat->num_of_sat_used = satellite_used; for (idx = 0; idx < satellite_visible; idx++) { - guint used_idx; - gboolean used; + gboolean used = FALSE; GValueArray *vals = (GValueArray *) g_ptr_array_index(sat_info, idx); gint prn = g_value_get_int(g_value_array_get_nth(vals, 0)); gint elev = g_value_get_int(g_value_array_get_nth(vals, 1)); @@ -118,8 +106,6 @@ static void satellite_callback(GeoclueSatellite * satellite, int timestamp, if (prn == g_array_index(used_prn, guint, idx)) { used = TRUE; break; - } else { - used = FALSE; } } MOD_LOGD("prn[%d] : used %d elev %d azim %d snr %d", prn, used, elev, azim, snr); @@ -291,23 +277,23 @@ static gboolean ref_gps_manager(GpsManagerData * gps_manager) ret = g_signal_connect(G_OBJECT(GEOCLUE_PROVIDER(gps_manager->pos)), "status-changed", G_CALLBACK(status_callback), gps_manager); - g_debug("gsignal_connect status-changed %d", ret); + MOD_LOGD("gsignal_connect status-changed %d", ret); ret = g_signal_connect(G_OBJECT(GEOCLUE_PROVIDER(gps_manager->pos)), "position-changed", G_CALLBACK(position_callback), gps_manager); - g_debug("gsignal_connect position-changed %d", ret); + MOD_LOGD("gsignal_connect position-changed %d", ret); ret = g_signal_connect(G_OBJECT(GEOCLUE_PROVIDER(gps_manager->vel)), "velocity-changed", G_CALLBACK(velocity_callback), gps_manager); - g_debug("gsignal_connect velocity-changed %d", ret); + MOD_LOGD("gsignal_connect velocity-changed %d", ret); ret = g_signal_connect(G_OBJECT(GEOCLUE_PROVIDER(gps_manager->sat)), "satellite-changed", G_CALLBACK(satellite_callback), gps_manager); - g_debug("gsignal_connect satellite-changed %d", ret); + MOD_LOGD("gsignal_connect satellite-changed %d", ret); ret = g_signal_connect(G_OBJECT(GEOCLUE_PROVIDER(gps_manager->nmea)), "nmea-changed", G_CALLBACK(nmea_callback), gps_manager); - g_debug("gsignal_connect nmea-changed %d", ret); + MOD_LOGD("gsignal_connect nmea-changed %d", ret); return TRUE; } @@ -329,6 +315,24 @@ static int start(gpointer handle, LocModStatusCB status_cb, LocModPositionCB pos if (!ref_gps_manager(gps_manager)) return LOCATION_ERROR_NOT_AVAILABLE; + + GHashTable *options; + GError *error = NULL; + + options = g_hash_table_new(g_str_hash, g_str_equal); + g_hash_table_insert(options, "CMD", "START"); + + if (!geoclue_provider_set_options(GEOCLUE_PROVIDER(gps_manager->pos), options, &error)) { + MOD_LOGE("Error geoclue_provider_set_options(START) : %s", error->message); + g_error_free(error); + error = NULL; + g_hash_table_destroy(options); + return LOCATION_ERROR_NOT_AVAILABLE; + } else { + MOD_LOGD("Success to geoclue_provider_set_options(START)"); + } + g_hash_table_destroy(options); + return LOCATION_ERROR_NONE; } @@ -338,6 +342,24 @@ static int stop(gpointer handle) GpsManagerData *gps_manager = (GpsManagerData *) handle; g_return_val_if_fail(gps_manager, LOCATION_ERROR_NOT_AVAILABLE); g_return_val_if_fail(gps_manager->status_cb, LOCATION_ERROR_NOT_AVAILABLE); + + GHashTable *options; + GError *error = NULL; + + options = g_hash_table_new(g_str_hash, g_str_equal); + g_hash_table_insert(options, "CMD", "STOP"); + + if (!geoclue_provider_set_options(GEOCLUE_PROVIDER(gps_manager->pos), options, &error)) { + MOD_LOGE("Error geoclue_provider_set_options(STOP) : %s", error->message); + g_error_free(error); + error = NULL; + g_hash_table_destroy(options); + return LOCATION_ERROR_NOT_AVAILABLE; + } else { + MOD_LOGD("Success to geoclue_provider_set_options(STOP)"); + } + g_hash_table_destroy(options); + unref_gps_manager(gps_manager); gps_manager->status_cb(FALSE, LOCATION_STATUS_NO_FIX, gps_manager->userdata); return LOCATION_ERROR_NONE; @@ -503,64 +525,18 @@ static int get_last_position(gpointer handle, LocationPosition ** position, Loca g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER); g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER); -#if 0 /* replaced by reading vconf directly */ - GeocluePositionFields fields; - int timestamp; - double lat, lon, alt; - GeoclueAccuracy *_accuracy = NULL; - GError *error = NULL; - - gchar *service = g_strdup_printf(GPS_MANAGER_SERVICE_NAME); - gchar *path = g_strdup_printf(GPS_MANAGER_SERVICE_PATH); - - GeocluePosition *last_pos = geoclue_position_new(service, path); - - fields = geoclue_position_get_last_position(last_pos, ×tamp, &lat, &lon, &alt, &_accuracy, &error); - if (error) { - MOD_LOGD("Error getting last position: %s", error->message); - g_error_free(error); - g_object_unref(last_pos); - g_free (service); - g_free (path); - return LOCATION_ERROR_NOT_AVAILABLE; - } - - if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { - if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE) - *position = location_position_new(timestamp, lat, lon, alt, LOCATION_STATUS_3D_FIX); - else - *position = location_position_new(timestamp, lat, lon, 0, LOCATION_STATUS_2D_FIX); - } else - *position = location_position_new(0, 0, 0, 0, LOCATION_STATUS_NO_FIX); - - if (_accuracy) { - GeoclueAccuracyLevel level; - double horiz_acc; - double vert_acc; - geoclue_accuracy_get_details(_accuracy, &level, &horiz_acc, &vert_acc); - *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_DETAILED, horiz_acc, vert_acc); - geoclue_accuracy_free(_accuracy); - } else - *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0, 0); - - g_object_unref(last_pos); - g_free (service); - g_free (path); - - return LOCATION_ERROR_NONE; -#else int timestamp = 0; double longitude = 0.0, latitude = 0.0, altitude = 0.0; double hor_accuracy = 0.0, ver_accuracy = 0.0; LocationStatus status = LOCATION_STATUS_NO_FIX; LocationAccuracyLevel level = LOCATION_ACCURACY_LEVEL_NONE; - if (vconf_get_int(GPS_LAST_TIMESTAMP, ×tamp) || - vconf_get_dbl(GPS_LAST_LATITUDE, &latitude) || - vconf_get_dbl(GPS_LAST_LONGITUDE, &longitude) || - vconf_get_dbl(GPS_LAST_ALTITUDE, &altitude) || - vconf_get_dbl(GPS_LAST_HORACCURACY, &hor_accuracy) || - vconf_get_dbl(GPS_LAST_VERACCURACY, &ver_accuracy)) { + if (vconf_get_int(VCONFKEY_LOCATION_LAST_GPS_TIMESTAMP, ×tamp) || + 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_HOR_ACCURACY, &hor_accuracy) || + vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_VER_ACCURACY, &ver_accuracy)) { *position = NULL; *accuracy = NULL; return LOCATION_ERROR_NOT_AVAILABLE; @@ -581,8 +557,6 @@ static int get_last_position(gpointer handle, LocationPosition ** position, Loca *accuracy = location_accuracy_new(level, hor_accuracy, ver_accuracy); return LOCATION_ERROR_NONE; - -#endif } static int get_last_velocity(gpointer handle, LocationVelocity ** velocity, LocationAccuracy ** accuracy) @@ -593,53 +567,15 @@ static int get_last_velocity(gpointer handle, LocationVelocity ** velocity, Loca g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER); g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER); -#if 0 /* replaced by reading vconf directly */ - GeoclueVelocityFields fields; - int timestamp; - double spd, dir, climb; - GError *error = NULL; - - gchar *service = g_strdup_printf(GPS_MANAGER_SERVICE_NAME); - gchar *path = g_strdup_printf(GPS_MANAGER_SERVICE_PATH); - - GeoclueVelocity *last_vel = geoclue_velocity_new(service, path); - - fields = geoclue_velocity_get_last_velocity(last_vel, ×tamp, &spd, &dir, &climb, &error); - if (error) { - MOD_LOGD("Error getting last velocity: %s", error->message); - g_error_free(error); - g_object_unref(last_vel); - g_free (service); - g_free (path); - return LOCATION_ERROR_NOT_AVAILABLE; - } - - if (fields & GEOCLUE_VELOCITY_FIELDS_SPEED && fields & GEOCLUE_VELOCITY_FIELDS_DIRECTION) { - if (fields & GEOCLUE_VELOCITY_FIELDS_CLIMB) - *velocity = location_velocity_new(timestamp, spd, dir, climb); - else - *velocity = location_velocity_new(timestamp, spd, dir, 0); - *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_DETAILED, 0, 0); - } else { - *velocity = location_velocity_new(0, 0, 0, 0); - *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0, 0); - } - - g_object_unref(last_vel); - g_free (service); - g_free (path); - - return LOCATION_ERROR_NONE; -#else gint timestamp = 0; gdouble speed = 0.0, direction = 0.0; gdouble hor_accuracy = 0.0, ver_accuracy = 0.0; - if (vconf_get_int(GPS_LAST_TIMESTAMP, ×tamp) || - vconf_get_dbl(GPS_LAST_SPEED, &speed) || - vconf_get_dbl(GPS_LAST_DIRECTION, &direction) || - vconf_get_dbl(GPS_LAST_HORACCURACY, &hor_accuracy) || - vconf_get_dbl(GPS_LAST_VERACCURACY, &ver_accuracy)) { + if (vconf_get_int(VCONFKEY_LOCATION_LAST_GPS_TIMESTAMP, ×tamp) || + 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)) { *velocity = NULL; *accuracy = NULL; return LOCATION_ERROR_NOT_AVAILABLE;; @@ -655,7 +591,6 @@ static int get_last_velocity(gpointer handle, LocationVelocity ** velocity, Loca *accuracy = location_accuracy_new (LOCATION_ACCURACY_LEVEL_DETAILED, hor_accuracy, ver_accuracy); return LOCATION_ERROR_NONE; -#endif } static int get_last_satellite(gpointer handle, LocationSatellite ** satellite) diff --git a/packaging/gps-manager.spec b/packaging/gps-manager.spec index 21b4df0..1b862a1 100644 --- a/packaging/gps-manager.spec +++ b/packaging/gps-manager.spec @@ -1,11 +1,10 @@ Name: gps-manager -Summary: GPS Manager for Tizen -Version: 0.1.6 +Summary: GPS Manager for Tizen +Version: 0.2.1 Release: 1 Group: TO_BE/FILLED_IN License: TO_BE/FILLED_IN Source0: %{name}-%{version}.tar.gz -BuildRequires: cmake BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(geoclue) @@ -23,12 +22,12 @@ BuildRequires: pkgconfig(location) GPS Manager for Tizen %package -n location-gps-manager -Summary: GPS Manager for Tizen +Summary: GPS Manager for Tizen Group: Development/Libraries Requires: %{name} = %{version}-%{release} %description -n location-gps-manager -libslp-location module for gps-manager +GPS Manager for Tizen %package -n gps-manager-plugin-devel @@ -41,7 +40,7 @@ GPS Manager for Tizen (development files) %prep -%setup -q +%setup -q %ifarch %{arm} %define GPS_ENABLER --enable-gps @@ -52,7 +51,7 @@ GPS Manager for Tizen (development files) %endif ./autogen.sh -CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix=%{_prefix} %{GPS_ENABLER} +./configure --prefix=%{_prefix} %{GPS_ENABLER} %build @@ -69,8 +68,9 @@ rm -rf %{buildroot} %post #GPS Indicator value -vconftool set -t int memory/gps/state 0 -i -vconftool set -t int memory/wps/state 0 -i +vconftool set -t int memory/location/position/state 0 -i +vconftool set -t int memory/location/gps/state 0 -i +vconftool set -t int memory/location/wps/state 0 -i #GPS_SETTING vconftool set -t int db/location/gps/Operation "1" -f @@ -78,9 +78,9 @@ vconftool set -t int db/location/gps/Starting "0" -f vconftool set -t int db/location/gps/Session "1" -f #SUPL_SETTING -vconftool set -t string db/location/supl/Server "your.supl-server.com" -f +vconftool set -t string db/location/supl/Server "bcmls2.glpals.com" -f vconftool set -t int db/location/supl/Port "7275" -f -vconftool set -t int db/location/supl/SslEnabled "1" -f +vconftool set -t int db/location/supl/SslEnabled "0" -f #NMEA_SETTING vconftool set -t int db/location/nmea/LoggingEnabled "0" -f @@ -98,6 +98,11 @@ vconftool set -t double db/location/replay/ManualLatitude "0.0" -f vconftool set -t double db/location/replay/ManualLongitude "0.0" -f vconftool set -t double db/location/replay/ManualAltitude "0.0" -f +%post -n location-gps-manager +%ifnarch %arm + cp -f /usr/lib/location/module/libgps.so /usr/lib/location/module/libwps0.so +%endif + %postun -p /sbin/ldconfig %files -- 2.7.4