summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinkun Jang <jinkun.jang@samsung.com>2013-03-13 11:53:08 +0900
committerJinkun Jang <jinkun.jang@samsung.com>2013-03-13 11:53:08 +0900
commit5790c58e9374ee2edc94bdf45b5a2f6bd271f343 (patch)
tree7d96d35b4fc723bfdae5795612f1f82ecf55bd28
parent968b98834dbda48bc8ad58defa7c5fc8443aae16 (diff)
downloadlocation-module-5790c58e9374ee2edc94bdf45b5a2f6bd271f343.tar.gz
location-module-5790c58e9374ee2edc94bdf45b5a2f6bd271f343.tar.bz2
location-module-5790c58e9374ee2edc94bdf45b5a2f6bd271f343.zip
sync
-rw-r--r--debian/changelog191
-rw-r--r--debian/compat1
-rwxr-xr-xdebian/control18
-rwxr-xr-xdebian/location-geoclue-gpsd.install.in1
-rw-r--r--debian/location-geoclue-gpsd.postinst8
-rw-r--r--debian/location-geoclue-nominatim.install.in1
-rwxr-xr-xdebian/rules115
-rwxr-xr-xmodules/geoclue-gpsd.c402
-rw-r--r--modules/geoclue-nominatim.c490
9 files changed, 0 insertions, 1227 deletions
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index b37c2ed..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,191 +0,0 @@
-location-module (0.1.18-2) unstable; urgency=low
-
- * rollback
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.18-2
-
- -- Minjune Kim <sena06.kim@samsung.com> Thu, 23 Feb 2012 14:25:43 +0900
-
-location-module (0.1.18-1) unstable; urgency=low
-
- * remove location-geoclue-gpsd
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.18-1
-
- -- Genie Kim <daejins.kim@samsung.com> Fri, 10 Feb 2012 16:18:30 +0900
-
-location-module (0.1.17-1) unstable; urgency=low
-
- * Support multiple result of geocode but it is workaround.
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.17-1
-
- -- Minjune Kim <sena06.kim@samsung.com> Thu, 09 Feb 2012 11:46:50 +0900
-
-location-module (0.1.16-4) unstable; urgency=low
-
- * Modify lib path on postinst
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.16-4
-
- -- Minjune Kim <sena06.kim@samsung.com> Wed, 01 Feb 2012 14:26:56 +0900
-
-location-module (0.1.16-3) unstable; urgency=low
-
- * Fix bug while using WPS module.
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.16-3
-
- -- Minjune Kim <sena06.kim@samsung.com> Mon, 19 Dec 2011 18:59:35 +0900
-
-location-module (0.1.16-2) unstable; urgency=low
-
- * generate link file to support wps method on SDK.
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.16-2
-
- -- Minjune Kim <sena06.kim@samsung.com> Fri, 09 Dec 2011 20:15:04 +0900
-
-location-module (0.1.16-1) unstable; urgency=low
-
- * add geoclue gpsd module
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.16-1
-
- -- Genie Kim <daejins.kim@samsung.com> Wed, 07 Dec 2011 16:50:31 +0900
-
-location-module (0.1.15-1) unstable; urgency=low
-
- * remove not using packages(hostip/opencellid)
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.15-1
-
- -- Genie Kim <daejins.kim@samsung.com> Tue, 06 Dec 2011 22:40:14 +0900
-
-location-module (0.1.14-1) unstable; urgency=low
-
- * move gpsd module to geoclue-providers for last knonw position
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.14-1
-
- -- Genie Kim <daejins.kim@samsung.com> Sat, 26 Nov 2011 12:17:29 +0900
-
-location-module (0.1.13-1) unstable; urgency=low
-
- * use time_t for timestamp
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.13-1
-
- -- Genie Kim <daejins.kim@samsung.com> Mon, 17 Oct 2011 13:36:42 +0900
-
-location-module (0.1.12-1) unstable; urgency=low
-
- * fixed BS about gmtime_r()
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.12-1
-
- -- Genie Kim <daejins.kim@samsung.com> Thu, 01 Sep 2011 14:04:33 +0900
-
-location-module (0.1.11-1) unstable; urgency=low
-
- * fixed prevent defect
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.11-1
-
- -- Genie Kim <daejins.kim@samsung.com> Fri, 26 Aug 2011 13:38:29 +0900
-
-location-module (0.1.10-2) unstable; urgency=low
-
- * change boilerplate
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.10-2
-
- -- Genie Kim <daejins.kim@samsung.com> Wed, 20 Jul 2011 17:52:15 +0900
-
-location-module (0.1.10-1) unstable; urgency=low
-
- * Package: Release new location-geoclue-nominatim package
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.10-1
-
- -- Tae-Hwan Kim <the81.kim@samsung.com> Wed, 01 Jun 2011 21:14:33 +0900
-
-location-module (0.1.9-1) unstable; urgency=low
-
- * Remove callbacks when location stops
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.9-1
-
- -- Tae-Hwan Kim <the81.kim@samsung.com> Fri, 13 May 2011 19:28:42 +0900
-
-location-module (0.1.8-2) unstable; urgency=low
-
- * Apply New Location APIs
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.8-2
-
- -- Tae-Hwan Kim <the81.kim@samsung.com> Wed, 20 Apr 2011 11:16:12 +0900
-
-location-module (0.1.7-1) unstable; urgency=low
-
- * Fix depends & timestamp
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.7-1
-
- -- Tae-Hwan Kim <the81.kim@samsung.com> Wed, 16 Feb 2011 21:02:21 +0900
-
-location-module (0.1.6-1) unstable; urgency=low
-
- * Add geoclue-hostip module & geoclue-opencellid & geoclue-opencellid module
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.6-1
-
- -- Tae-Hwan Kim <the81.kim@samsung.com> Wed, 19 Jan 2011 13:32:18 +0900
-
-location-module (0.1.5-1) unstable; urgency=low
-
- * Adapt to plug change again
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.5-1
-
- -- Tae-Hwan Kim <the81.kim@samsung.com> Tue, 21 Dec 2010 17:31:07 +0900
-
-location-module (0.1.4-0) unstable; urgency=low
-
- * Adapt to plugin change
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.4-0
-
- -- Tae-Hwan Kim <the81.kim@samsung.com> Mon, 13 Dec 2010 10:32:35 +0900
-
-location-module (0.1.3-0) unstable; urgency=low
-
- * Initialize is_started to FALSE
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.3-0
-
- -- Tae-Hwan Kim <the81.kim@samsung.com> Thu, 02 Dec 2010 13:36:02 +0900
-
-location-module (0.1.2-0) unstable; urgency=low
-
- * Prevent duplicate start
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.2-0
-
- -- Tae-Hwan Kim <the81.kim@samsung.com> Mon, 29 Nov 2010 11:17:46 +0900
-
-location-module (0.1.1-0) unstable; urgency=low
-
- * Add debug pkg & disable geoclue-skyhook
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.1-0
-
- -- Tae-Hwan Kim <the81.kim@samsung.com> Wed, 24 Nov 2010 22:21:17 +0900
-
-location-module (0.1.0-1) unstable; urgency=low
-
- * Initial release
- * Git: slp/pkgs/l/location-module
- * Tag: location-module_0.1.0-1
-
- -- Tae-Hwan Kim <the81.kim@samsung.com> Tue, 02 Nov 2010 20:10:07 +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 100755
index 7db09a1..0000000
--- a/debian/control
+++ /dev/null
@@ -1,18 +0,0 @@
-Source: location-module
-Section: libs
-Priority: extra
-Maintainer: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>, Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
-Build-Depends: debhelper (>= 5), libglib2.0-dev, libslp-location-dev, libgeoclue-dev, libvconf-dev
-Standards-Version: 3.7.2
-
-Package: location-geoclue-nominatim
-Section: utils
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: geoclue-nominatim geocode module for location
-
-Package: location-module-dbg
-Section: libs
-Architecture: any
-Depends: ${misc:Depends}, location-geoclue-nominatim (=${binary:Version})
-Description: debug package for location-geoclue-nominatim
diff --git a/debian/location-geoclue-gpsd.install.in b/debian/location-geoclue-gpsd.install.in
deleted file mode 100755
index 212ab82..0000000
--- a/debian/location-geoclue-gpsd.install.in
+++ /dev/null
@@ -1 +0,0 @@
-@PREFIX@/lib/location/module/libgps0.so*
diff --git a/debian/location-geoclue-gpsd.postinst b/debian/location-geoclue-gpsd.postinst
deleted file mode 100644
index 6ab6d36..0000000
--- a/debian/location-geoclue-gpsd.postinst
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-if [ ! -e /usr/lib/location/module/libwps0.so ] ; then
- cp -f /usr/lib/location/module/libgps0.so /usr/lib/location/module/libwps0.so
-fi
-
-sync
-
diff --git a/debian/location-geoclue-nominatim.install.in b/debian/location-geoclue-nominatim.install.in
deleted file mode 100644
index 2ede3ae..0000000
--- a/debian/location-geoclue-nominatim.install.in
+++ /dev/null
@@ -1 +0,0 @@
-@PREFIX@/lib/location/module/libgeocode0.so*
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 4298e5d..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,115 +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
-
-LDFLAGS ?=
-PREFIX ?= /usr
-DATADIR ?= /opt
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
- CXXFLAGS += -O0
-else
- CFLAGS += -O2
- CXXFLAGS += -O2
-endif
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- ./autogen.sh
- # Add here commands to configure the package.
- ./configure --prefix=$(PREFIX) --enable-dlog --enable-debug
-
- touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
-
- # Add here commands to compile the package.
- $(MAKE)
-
- 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.
- - $(MAKE) clean
-
- rm -rf CMakeCache.txt
- rm -rf CMakeFiles
- rm -rf cmake_install.cmake
- rm -rf Makefile
- rm -rf install_manifest.txt
- rm -rf *.so
-
- for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
- rm -f $${f%.in}; \
- done
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- # Add here commands to install the package into debian/wavplayer.
- $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-# 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=location-module-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 configure
diff --git a/modules/geoclue-gpsd.c b/modules/geoclue-gpsd.c
deleted file mode 100755
index fda27e2..0000000
--- a/modules/geoclue-gpsd.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * location-geoclue-gpsd
- *
- * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
- * Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <glib.h>
-
-#include <location-module.h>
-
-#include <geoclue/geoclue-position.h>
-#include <geoclue/geoclue-velocity.h>
-#include <geoclue/geoclue-provider.h>
-#include <dlfcn.h>
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "log.h"
-
-typedef struct{
- char devname[256];
- GeocluePosition *pos;
- GeoclueVelocity *vel;
- LocModStatusCB status_cb;
- LocModPositionCB pos_cb;
- LocModVelocityCB vel_cb;
- gpointer userdata;
- gboolean is_started;
-} GeoclueGpsdData;
-
-static void
-status_callback (GeoclueProvider *provider,
- gint status,
- gpointer userdata)
-{
- GeoclueGpsdData* gpsd = (GeoclueGpsdData*)userdata;
- g_return_if_fail(gpsd->status_cb);
-
- switch(status){
- case GEOCLUE_STATUS_ERROR:
- case GEOCLUE_STATUS_UNAVAILABLE:
- case GEOCLUE_STATUS_ACQUIRING:
- MOD_LOGD("Status callback>> GEOCLUE_STATUS_ACQUIRING/ERROR/UNAVAILABLE");
- gpsd->status_cb(FALSE, LOCATION_STATUS_NO_FIX, gpsd->userdata);
- break;
- case GEOCLUE_STATUS_AVAILABLE:
- MOD_LOGD("Status callback>> GEOCLUE_STATUS_AVAILABLE");
- gpsd->status_cb(TRUE, LOCATION_STATUS_3D_FIX, gpsd->userdata);
- break;
- default:
- break;
- }
-}
-
-static void
-position_callback (GeocluePosition *position,
- GeocluePositionFields fields,
- int timestamp,
- double latitude,
- double longitude,
- double altitude,
- GeoclueAccuracy *accuracy,
- gpointer userdata)
-{
- GeoclueGpsdData* gpsd = (GeoclueGpsdData*)userdata;
- g_return_if_fail(gpsd->pos_cb);
-
- GeoclueAccuracyLevel level;
- double horiz_acc;
- double vert_acc;
- geoclue_accuracy_get_details (accuracy, &level, &horiz_acc, &vert_acc);
-
- LocationPosition *pos = NULL;
- LocationAccuracy *acc = NULL;
-
- if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
- fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
- if(fields & GEOCLUE_POSITION_FIELDS_ALTITUDE)
- pos = location_position_new (timestamp, latitude, longitude, altitude, LOCATION_STATUS_3D_FIX);
- else pos = location_position_new (timestamp, latitude, longitude, 0, LOCATION_STATUS_2D_FIX);
- } else pos = 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);
- acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_DETAILED, horiz_acc, vert_acc);
- } else acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_NONE, horiz_acc, vert_acc);
-
- MOD_LOGD("Position callback>> time(%d) lat(%f) long(%f) alt(%f) status(%d) acc_level(%d) hoz_acc(%f) vert_acc(%f)",
- pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status,
- acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
- gpsd->pos_cb(TRUE, pos, acc, gpsd->userdata);
- location_position_free (pos);
- location_accuracy_free (acc);
-}
-
-static void
-velocity_callback (GeoclueVelocity *velocity,
- GeoclueVelocityFields fields,
- int timestamp,
- double speed,
- double direction,
- double climb,
- gpointer userdata)
-{
- GeoclueGpsdData* gpsd = (GeoclueGpsdData*)userdata;
- g_return_if_fail(gpsd->vel_cb);
-
- LocationVelocity *vel = NULL;
- LocationAccuracy *acc = NULL;
-
- if (fields & GEOCLUE_VELOCITY_FIELDS_SPEED &&
- fields & GEOCLUE_VELOCITY_FIELDS_DIRECTION) {
- if (fields & GEOCLUE_VELOCITY_FIELDS_CLIMB) vel = location_velocity_new (timestamp, speed, direction, climb);
- else vel = location_velocity_new (timestamp, speed, direction, 0);
- acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_DETAILED, 0, 0);
- } else {
- vel = location_velocity_new (0, 0, 0, 0);
- acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_NONE, 0, 0);
- }
- MOD_LOGD("Velocity callback>> timestamp(%d) speed(%f) direction(%f) climb(%f) acc_level(%d) hoz_acc(%f) vert_acc(%f)",
- vel->timestamp, vel->speed, vel->direction, vel->climb,
- acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
-
- gpsd->vel_cb(TRUE, vel, acc, gpsd->userdata);
- location_velocity_free (vel);
- location_accuracy_free (acc);
-}
-
-static void
-_unref_geoclue(GeoclueGpsdData* gpsd)
-{
- if(gpsd->pos) {
- g_signal_handlers_disconnect_by_func(G_OBJECT (GEOCLUE_PROVIDER(gpsd->pos)), G_CALLBACK (status_callback), gpsd);
- g_signal_handlers_disconnect_by_func(G_OBJECT (GEOCLUE_PROVIDER(gpsd->pos)), G_CALLBACK (position_callback), gpsd);
- g_object_unref (gpsd->pos);
- gpsd->pos = NULL;
- }
-
- if( gpsd->vel != NULL){
- g_signal_handlers_disconnect_by_func(G_OBJECT (GEOCLUE_PROVIDER(gpsd->vel)), G_CALLBACK (velocity_callback), gpsd);
- g_object_unref (gpsd->vel);
- gpsd->vel = NULL;
- }
- gpsd->is_started = FALSE;
-}
-
-static gboolean
-_ref_geoclue(GeoclueGpsdData* gpsd)
-{
- if(gpsd->is_started == TRUE){
- MOD_LOGW ("geoclue-gpsd is alredy started");
- return TRUE;
- }
-
- gchar *service, *path;
- service = g_strdup_printf ("org.freedesktop.Geoclue.Providers.Gpsd");
- path = g_strdup_printf ("/org/freedesktop/Geoclue/Providers/Gpsd");
-
- if(!gpsd->pos){
- gpsd->pos = geoclue_position_new (service, path);
- }
- if(!gpsd->vel){
- gpsd->vel = geoclue_velocity_new (service, path);
- }
- g_free (service);
- g_free (path);
- if(!gpsd->pos || !gpsd->vel){
- MOD_LOGW ("Error while creating Geoclue object.");
- _unref_geoclue(gpsd);
- return FALSE;
- }
-
- gpsd->is_started = TRUE;
- g_signal_connect (G_OBJECT (GEOCLUE_PROVIDER(gpsd->pos)), "status-changed", G_CALLBACK (status_callback), gpsd);
- g_signal_connect (G_OBJECT (GEOCLUE_PROVIDER(gpsd->pos)), "position-changed", G_CALLBACK (position_callback), gpsd);
- g_signal_connect (G_OBJECT (GEOCLUE_PROVIDER(gpsd->vel)), "velocity-changed", G_CALLBACK (velocity_callback), gpsd);
-
- return TRUE;
-}
-
-static int
-start(gpointer handle, LocModStatusCB status_cb, LocModPositionCB pos_cb, LocModVelocityCB vel_cb, gpointer userdata)
-{
- MOD_LOGD("start");
- GeoclueGpsdData* gpsd = (GeoclueGpsdData*)handle;
- g_return_val_if_fail(gpsd, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(status_cb, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(pos_cb, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(vel_cb, LOCATION_ERROR_NOT_AVAILABLE);
-
- gpsd->status_cb = status_cb;
- gpsd->pos_cb = pos_cb;
- gpsd->vel_cb = vel_cb;
- gpsd->userdata = userdata;
- if (!_ref_geoclue(gpsd)) return LOCATION_ERROR_NOT_AVAILABLE;
- return LOCATION_ERROR_NONE;
-}
-
-static int
-stop(gpointer handle)
-{
- MOD_LOGD("stop");
- GeoclueGpsdData* gpsd = (GeoclueGpsdData*)handle;
- g_return_val_if_fail(gpsd, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(gpsd->status_cb, LOCATION_ERROR_NOT_AVAILABLE);
- _unref_geoclue(gpsd);
- gpsd->status_cb(FALSE, LOCATION_STATUS_NO_FIX, gpsd->userdata);
- return LOCATION_ERROR_NONE;
-}
-
-static int
-get_position(
- gpointer handle,
- LocationPosition **position,
- LocationAccuracy **accuracy)
-{
- GeoclueGpsdData* gpsd = (GeoclueGpsdData*)handle;
- g_return_val_if_fail(gpsd, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(gpsd->pos, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
-
- GeocluePositionFields fields;
- int timestamp;
- double lat, lon, alt;
- GeoclueAccuracy *_accuracy = NULL;
- GError *error = NULL;
-
- fields = geoclue_position_get_position (gpsd->pos, &timestamp,
- &lat, &lon, &alt,
- &_accuracy, &error);
- if (error) {
- MOD_LOGD ("Error getting position: %s", error->message);
- g_error_free (error);
- 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);
-
- return LOCATION_ERROR_NONE;
-}
-
-static int
-get_velocity(
- gpointer handle,
- LocationVelocity **velocity,
- LocationAccuracy **accuracy)
-{
- GeoclueGpsdData* gpsd = (GeoclueGpsdData*)handle;
- g_return_val_if_fail(gpsd, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(gpsd->vel, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
-
- GeoclueVelocityFields fields;
- int timestamp;
- double spd, dir, climb;
- GError *error = NULL;
-
- fields = geoclue_velocity_get_velocity (gpsd->vel, &timestamp,
- &spd, &dir, &climb,
- &error);
- if (error) {
- MOD_LOGD ("Error getting velocity: %s", error->message);
- g_error_free (error);
- 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);
- }
- return LOCATION_ERROR_NONE;
-}
-
-static int
-get_nmea(gpointer handle,
- char **nmea_data)
-{
- MOD_LOGD("get_nmea: not available");
- return LOCATION_ERROR_NOT_AVAILABLE;
-}
-
-static int
-get_satellite(gpointer handle,
- LocationSatellite **satellite)
-{
- MOD_LOGD("get_satellite: not available");
- return LOCATION_ERROR_NOT_AVAILABLE;
-}
-
-static int
-set_devname(gpointer handle,
- const char *devname)
-{
- GeoclueGpsdData* gpsd = (GeoclueGpsdData*)handle;
- g_return_val_if_fail(gpsd, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(gpsd->devname, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(devname, LOCATION_ERROR_PARAMETER);
- MOD_LOGD("set_devname: %s --> %s", gpsd->devname, devname);
- g_stpcpy(gpsd->devname, devname);
-
- return LOCATION_ERROR_NONE;
-}
-
-
-static int
-get_devname(gpointer handle,
- char **devname)
-{
- GeoclueGpsdData* gpsd = (GeoclueGpsdData*)handle;
- g_return_val_if_fail(gpsd, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(gpsd->devname, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(devname, LOCATION_ERROR_PARAMETER);
-
- *devname = g_strdup(gpsd->devname);
- MOD_LOGD("get_devname: %s", *devname);
-
- return LOCATION_ERROR_NONE;
-}
-
-LOCATION_MODULE_API gpointer
-init(LocModGpsOps* ops)
-{
- MOD_LOGD("init");
- g_return_val_if_fail(ops, NULL);
- ops->start = start;
- ops->stop = stop ;
- ops->get_position = get_position;
- ops->get_velocity = get_velocity;
- Dl_info info;
- if (dladdr(&get_position, &info) == 0) {
- MOD_LOGD("failed to get module name");
- } else if (g_str_has_prefix(info.dli_fname, "gps")) {
- ops->get_nmea = get_nmea;
- ops->get_satellite = get_satellite;
- ops->set_devname = set_devname;
- ops->get_devname = get_devname;
- }
-
- GeoclueGpsdData* gpsd = g_new0(GeoclueGpsdData, 1);
- g_return_val_if_fail(gpsd, NULL);
-
- g_stpcpy(gpsd->devname, "/dev/rfcomm0");
- gpsd->pos = NULL;
- gpsd->vel = NULL;
- gpsd->status_cb= NULL;
- gpsd->pos_cb = NULL;
- gpsd->vel_cb = NULL;
- gpsd->userdata = NULL;
- gpsd->is_started = FALSE;
-
- return (gpointer)gpsd;
-}
-
-LOCATION_MODULE_API void
-shutdown(gpointer handle)
-{
- MOD_LOGD("shutdown");
- GeoclueGpsdData* gpsd = (GeoclueGpsdData*)handle;
- g_return_if_fail(gpsd);
- _unref_geoclue(gpsd);
- if(gpsd->status_cb) gpsd->status_cb(FALSE, LOCATION_STATUS_NO_FIX, gpsd->userdata);
- g_free(gpsd);
-}
diff --git a/modules/geoclue-nominatim.c b/modules/geoclue-nominatim.c
deleted file mode 100644
index 2a10156..0000000
--- a/modules/geoclue-nominatim.c
+++ /dev/null
@@ -1,490 +0,0 @@
-/*
- * location-geoclue-nominatim
- *
- * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
- * Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <glib.h>
-
-#include <location-module.h>
-
-#include <geoclue/geoclue-geocode.h>
-#include <geoclue/geoclue-reverse-geocode.h>
-#include <geoclue/geoclue-provider.h>
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "log.h"
-
-typedef struct {
- char* service_name;
- GeoclueGeocode* geocoder;
- GeoclueReverseGeocode* rev_geocoder;
-} NominatimHandle;
-
-typedef struct {
- LocationPositionCB pos_cb;
- LocationAddressCB addr_cb;
- gpointer userdata;
-} NominatimData;
-
-static GHashTable*
-get_geoclue_addr_from_location_addr (const LocationAddress *address)
-{
- if (!address) return NULL;
-
- GHashTable *geoclue_addr = geoclue_address_details_new();
- if (address->street) {
- if (address->building_number) {
- char *street_addr = g_strdup_printf ("%s %s", address->building_number, address->street);
- geoclue_address_details_insert (geoclue_addr, GEOCLUE_ADDRESS_KEY_STREET, street_addr);
- g_free (street_addr);
- } else geoclue_address_details_insert (geoclue_addr, GEOCLUE_ADDRESS_KEY_STREET, address->street);
- }
- if (address->district) geoclue_address_details_insert (geoclue_addr, GEOCLUE_ADDRESS_KEY_AREA, address->district);
- if (address->city) geoclue_address_details_insert (geoclue_addr, GEOCLUE_ADDRESS_KEY_LOCALITY, address->city);
- if (address->state) geoclue_address_details_insert (geoclue_addr, GEOCLUE_ADDRESS_KEY_REGION, address->state);
- if (address->country_code) geoclue_address_details_insert (geoclue_addr, GEOCLUE_ADDRESS_KEY_COUNTRY, address->country_code);
- if (address->postal_code) geoclue_address_details_insert (geoclue_addr, GEOCLUE_ADDRESS_KEY_POSTALCODE, address->postal_code);
-
- return geoclue_addr;
-}
-
-static LocationAddress*
-get_location_addr_from_geoclue_addr (GHashTable *geoclue_addr)
-{
- if (!geoclue_addr) return NULL;
-
- LocationAddress *addr = NULL;
-
- gchar *country, *region, *locality, *postalcode, *area, *street;
-
- country = g_hash_table_lookup (geoclue_addr, GEOCLUE_ADDRESS_KEY_COUNTRY);
- region = g_hash_table_lookup (geoclue_addr, GEOCLUE_ADDRESS_KEY_REGION);
- locality = g_hash_table_lookup (geoclue_addr, GEOCLUE_ADDRESS_KEY_LOCALITY);
- area = g_hash_table_lookup (geoclue_addr, GEOCLUE_ADDRESS_KEY_AREA);
- postalcode = g_hash_table_lookup (geoclue_addr, GEOCLUE_ADDRESS_KEY_POSTALCODE);
- street = g_hash_table_lookup (geoclue_addr, GEOCLUE_ADDRESS_KEY_STREET);
-
- addr = location_address_new (NULL, street, area, locality, region, country, postalcode);
- return addr;
-}
-
-static LocationAccuracy *
-get_location_acc_from_geoclue_acc (GeoclueAccuracy *acc)
-{
- if (!acc) return NULL;
-
- LocationAccuracy *accuracy = NULL;
- GeoclueAccuracyLevel level;
- double horiz_acc;
- double vert_acc;
- geoclue_accuracy_get_details (acc, &level, &horiz_acc, &vert_acc);
-
- if (level == GEOCLUE_ACCURACY_LEVEL_DETAILED) accuracy = location_accuracy_new (LOCATION_ACCURACY_LEVEL_DETAILED, horiz_acc, vert_acc);
- else if (level == GEOCLUE_ACCURACY_LEVEL_STREET) accuracy = location_accuracy_new (LOCATION_ACCURACY_LEVEL_STREET, horiz_acc, vert_acc);
- else if (level == GEOCLUE_ACCURACY_LEVEL_POSTALCODE) accuracy = location_accuracy_new (LOCATION_ACCURACY_LEVEL_POSTALCODE, horiz_acc, vert_acc);
- else if (level == GEOCLUE_ACCURACY_LEVEL_LOCALITY) accuracy = location_accuracy_new (LOCATION_ACCURACY_LEVEL_LOCALITY, horiz_acc, vert_acc);
- else if (level == GEOCLUE_ACCURACY_LEVEL_REGION) accuracy = location_accuracy_new (LOCATION_ACCURACY_LEVEL_REGION, horiz_acc, vert_acc);
- else if (level == GEOCLUE_ACCURACY_LEVEL_COUNTRY) accuracy = location_accuracy_new (LOCATION_ACCURACY_LEVEL_COUNTRY, horiz_acc, vert_acc);
- else accuracy = location_accuracy_new (LOCATION_ACCURACY_LEVEL_NONE, 0, 0);
-
- return accuracy;
-}
-
-static void
-_unref_geoclue(NominatimHandle* handle)
-{
- if (handle->geocoder) {
- g_object_unref (handle->geocoder);
- handle->geocoder = NULL;
- }
- if (handle->rev_geocoder) {
- g_object_unref (handle->rev_geocoder);
- handle->rev_geocoder = NULL;
- }
-}
-
-static gboolean
-_ref_geoclue(NominatimHandle* handle)
-{
- gchar *service, *path;
- service = g_strdup_printf ("org.freedesktop.Geoclue.Providers.Nominatim");
- path = g_strdup_printf ("/org/freedesktop/Geoclue/Providers/Nominatim");
-
- if (!handle->geocoder) handle->geocoder = geoclue_geocode_new (service, path);
- if (!handle->rev_geocoder) handle->rev_geocoder = geoclue_reverse_geocode_new (service, path);
-
- if(!handle->geocoder || !handle->rev_geocoder){
- MOD_LOGW ("Error while creating Geoclue object.");
- _unref_geoclue(handle);
- return FALSE;
- }
- return TRUE;
-}
-
-static void
-address_cb (GeoclueReverseGeocode *revgeocode,
- GHashTable *details,
- GeoclueAccuracy *accuracy,
- GError *error,
- gpointer userdata)
-{
- NominatimData* data = (NominatimData*)userdata;
- g_return_if_fail(data->addr_cb);
-
- LocationAddress *addr = NULL;
- LocationAccuracy *acc = NULL;
- LocationError err = LOCATION_ERROR_NONE;
-
- if (error) {
- MOD_LOGW ("Error getting reverse geocode: %s", error->message);
- err = LOCATION_ERROR_NOT_AVAILABLE;
- } else {
- if (accuracy) acc = get_location_acc_from_geoclue_acc (accuracy);
- else acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_NONE, 0, 0);
-
- if (details) addr = get_location_addr_from_geoclue_addr (details);
- }
-
- data->addr_cb (err, addr, acc, data->userdata);
- if (addr) location_address_free (addr);
- if (acc) location_accuracy_free (acc);
- g_free (data);
-}
-
-static void _free_pos_list_item(gpointer data)
-{
- g_return_if_fail(data);
-
- LocationPosition *position = (LocationPosition *)data;
- location_position_free(position);
-}
-
-static void _free_acc_list_item(gpointer data)
-{
- g_return_if_fail(data);
-
- LocationAccuracy *accuracy = (LocationAccuracy *)data;
- location_accuracy_free(accuracy);
-}
-
-static void position_cb (GeoclueGeocode *geocode,
- GeocluePositionFields fields,
- double latitude,
- double longitude,
- double altitude,
- GeoclueAccuracy *accuracy,
- GError *error,
- gpointer userdata)
-{
- NominatimData* data = (NominatimData*)userdata;
- GList *pos_list = NULL;
- GList *acc_list = NULL;
-
- g_return_if_fail(data->pos_cb);
-
- LocationPosition *pos = NULL;
- LocationAccuracy *acc = NULL;
- LocationError err = LOCATION_ERROR_NONE;
-
- if (error) {
- MOD_LOGW ("Error getting geocode: %s", error->message);
- err = LOCATION_ERROR_NOT_AVAILABLE;
- } else {
- if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
- fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
- if(fields & GEOCLUE_POSITION_FIELDS_ALTITUDE) pos = location_position_new (0, latitude, longitude, altitude, LOCATION_STATUS_3D_FIX);
- else pos = location_position_new (0, latitude, longitude, 0, LOCATION_STATUS_2D_FIX);
-
- pos_list = g_list_append(pos_list, pos);
- } else {
- err = LOCATION_ERROR_NOT_FOUND;
- }
-
- if (accuracy) {
- acc = get_location_acc_from_geoclue_acc (accuracy);
- acc_list = g_list_append(acc_list, acc);
- }
- }
- data->pos_cb (err, pos_list, acc_list, data->userdata);
-
- if (pos_list) g_list_free_full(pos_list, _free_pos_list_item);
- if (acc_list) g_list_free_full(pos_list, _free_acc_list_item);
- g_free (data);
-
-}
-
-
-static int
-get_geocode (gpointer handle,
- const LocationAddress *addr,
- GList **pos_list,
- GList **acc_list)
-{
- NominatimHandle *nominatim = (NominatimHandle *)handle;
- g_return_val_if_fail(nominatim, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(addr, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(pos_list, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(acc_list, LOCATION_ERROR_PARAMETER);
-
- double lat, lon, alt;
- GeoclueAccuracy *geoclue_acc = NULL;
- GError *error = NULL;
- LocationPosition *pos = NULL;
- LocationAccuracy *acc = NULL;
- LocationError err = LOCATION_ERROR_NONE;
-
- GHashTable* geoclue_addr = get_geoclue_addr_from_location_addr (addr);
- GeocluePositionFields fields = geoclue_geocode_address_to_position (nominatim->geocoder, geoclue_addr,
- &lat, &lon, &alt,
- &geoclue_acc, &error);
- g_hash_table_destroy (geoclue_addr);
-
- if (error) {
- MOD_LOGW ("Error getting geocode: %s", error->message);
- g_error_free (error);
- return LOCATION_ERROR_NOT_AVAILABLE;
- }
-
- if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
- fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
- if(fields & GEOCLUE_POSITION_FIELDS_ALTITUDE) pos = location_position_new (0, lat, lon, alt, LOCATION_STATUS_3D_FIX);
- else pos = location_position_new (0, lat, lon, 0, LOCATION_STATUS_2D_FIX);
-
- *pos_list = g_list_append(*pos_list, pos);
- }
- else {
- err = LOCATION_ERROR_NOT_FOUND;
- }
-
- if (geoclue_acc) {
- acc = get_location_acc_from_geoclue_acc (geoclue_acc);
- geoclue_accuracy_free (geoclue_acc);
-
- *acc_list = g_list_append(*acc_list, acc);
- }
-
- if (pos) location_position_free (pos);
- if (acc) location_accuracy_free (acc);
-
- return err;
-}
-
-
-static int
-get_geocode_async (gpointer handle,
- const LocationAddress * addr,
- LocationPositionCB callback,
- gpointer userdata)
-{
- NominatimHandle *nominatim = (NominatimHandle *)handle;
- g_return_val_if_fail(nominatim, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(addr, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(callback, LOCATION_ERROR_PARAMETER);
-
- GHashTable* geoclue_addr = get_geoclue_addr_from_location_addr (addr);
- NominatimData *data = g_new0 (NominatimData, 1);
- data->pos_cb = callback;
- data->userdata = userdata;
- geoclue_geocode_address_to_position_async (nominatim->geocoder, geoclue_addr, position_cb, data);
- g_hash_table_destroy (geoclue_addr);
-
- return LOCATION_ERROR_NONE;
-}
-
-static int
-get_geocode_freetext(gpointer handle,
- const const gchar* addr,
- GList **pos_list,
- GList **acc_list)
-{
- NominatimHandle *nominatim = (NominatimHandle *)handle;
- g_return_val_if_fail(nominatim, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(addr, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(pos_list, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(acc_list, LOCATION_ERROR_PARAMETER);
-
- double lat, lon, alt;
- GeoclueAccuracy *geoclue_acc = NULL;
- GError *error = NULL;
- LocationPosition *pos = NULL;
- LocationAccuracy *acc = NULL;
- LocationError err = LOCATION_ERROR_NONE;
-
- GeocluePositionFields fields = geoclue_geocode_freeform_address_to_position (nominatim->geocoder, addr,
- &lat, &lon, &alt,
- &geoclue_acc, &error);
- if (error) {
- MOD_LOGW ("Error getting geocode: %s", error->message);
- g_error_free (error);
- return LOCATION_ERROR_NOT_AVAILABLE;
- }
-
- if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
- fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
- if(fields & GEOCLUE_POSITION_FIELDS_ALTITUDE) pos = location_position_new (0, lat, lon, alt, LOCATION_STATUS_3D_FIX);
- else pos = location_position_new (0, lat, lon, 0, LOCATION_STATUS_2D_FIX);
- *pos_list = g_list_append(*pos_list, pos);
- }
- else {
- err = LOCATION_ERROR_NOT_FOUND;
- }
-
- if (geoclue_acc) {
- acc = get_location_acc_from_geoclue_acc (geoclue_acc);
- geoclue_accuracy_free (geoclue_acc);
- *acc_list = g_list_append(*acc_list, acc);
- }
-
- if (pos) location_position_free (pos);
- if (acc) location_accuracy_free (acc);
- return err;
-}
-
-
-static int
-get_geocode_freetext_async (gpointer handle,
- const gchar* addr,
- LocationPositionCB callback,
- gpointer userdata)
-{
- NominatimHandle *nominatim = (NominatimHandle *)handle;
- g_return_val_if_fail(nominatim, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(addr, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(callback, LOCATION_ERROR_PARAMETER);
-
- NominatimData *data = g_new0 (NominatimData, 1);
- data->pos_cb = callback;
- data->userdata = userdata;
- geoclue_geocode_freeform_address_to_position_async (nominatim->geocoder, addr, position_cb, data);
-
- return LOCATION_ERROR_NONE;
-}
-
-static int
-get_reverse_geocode(gpointer handle,
- const LocationPosition *pos,
- LocationAddress **addr,
- LocationAccuracy **acc)
-{
- NominatimHandle *nominatim = (NominatimHandle *)handle;
- g_return_val_if_fail(nominatim, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(pos, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(addr, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(acc, LOCATION_ERROR_PARAMETER);
-
- GeoclueAccuracy *addr_acc = NULL;
- GError *error = NULL;
- GHashTable* geoclue_addr = NULL;
-
- double lat = pos->latitude;
- double lon = pos->longitude;
- GeoclueAccuracy *pos_acc = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_DETAILED, 0.0, 0.0);
-
- gboolean success = geoclue_reverse_geocode_position_to_address (nominatim->rev_geocoder, lat, lon,
- pos_acc, &geoclue_addr,
- &addr_acc, &error);
- geoclue_accuracy_free (pos_acc);
-
- if (!success || error) {
- MOD_LOGW ("Error getting reverse geocode: %s", error->message);
- g_error_free (error);
- return LOCATION_ERROR_NOT_AVAILABLE;
- }
-
- if (addr_acc) {
- *acc = get_location_acc_from_geoclue_acc (addr_acc);
- geoclue_accuracy_free (addr_acc);
- } else *acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_NONE, 0, 0);
- if (geoclue_addr) {
- *addr = get_location_addr_from_geoclue_addr (geoclue_addr);
- g_hash_table_destroy (geoclue_addr);
- }
-
- return LOCATION_ERROR_NONE;
-}
-
-static int
-get_reverse_geocode_async (gpointer handle,
- const LocationPosition *pos,
- LocationAddressCB callback,
- gpointer userdata)
-{
- NominatimHandle *nominatim = (NominatimHandle *)handle;
- g_return_val_if_fail(nominatim, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail(pos, LOCATION_ERROR_PARAMETER);
- g_return_val_if_fail(callback, LOCATION_ERROR_PARAMETER);
-
- double lat = pos->latitude;
- double lon = pos->longitude;
- GeoclueAccuracy *pos_acc = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_DETAILED, 0.0, 0.0);;
- NominatimData *data = g_new0 (NominatimData, 1);
- data->addr_cb = callback;
- data->userdata = userdata;
- geoclue_reverse_geocode_position_to_address_async (nominatim->rev_geocoder,
- lat, lon, pos_acc,
- address_cb, data);
- geoclue_accuracy_free (pos_acc);
-
- return LOCATION_ERROR_NONE;
-}
-
-static int
-get_service_name (gpointer handle,
- gchar **service_name)
-{
- NominatimHandle *nominatim = (NominatimHandle *)handle;
- g_return_val_if_fail(nominatim, LOCATION_ERROR_NOT_AVAILABLE);
- g_return_val_if_fail (service_name, LOCATION_ERROR_PARAMETER);
- *service_name = g_strdup (nominatim->service_name);
- return LOCATION_ERROR_NONE;
-}
-
-LOCATION_MODULE_API gpointer
-init (LocModGeoOps* ops)
-{
- MOD_LOGD("init");
- g_return_val_if_fail(ops, NULL);
- NominatimHandle *handle = g_new0 (NominatimHandle, 1);
- if (!_ref_geoclue(handle)) {
- g_free (handle);
- return NULL;
- }
- handle->service_name = g_strdup ("Nominatim");
- ops->get_service_name = get_service_name;
- ops->get_geocode = get_geocode;
- ops->get_geocode_freetext = get_geocode_freetext;
- ops->get_reverse_geocode = get_reverse_geocode;
- ops->get_geocode_async = get_geocode_async;
- ops->get_geocode_freetext_async = get_geocode_freetext_async;
- ops->get_reverse_geocode_async = get_reverse_geocode_async;
- return (gpointer)handle;
-}
-
-LOCATION_MODULE_API void
-shutdown (gpointer handle)
-{
- MOD_LOGD("shutdown");
- g_return_if_fail(handle);
- NominatimHandle *nominatim = (NominatimHandle *)handle;
- g_free (nominatim->service_name);
- _unref_geoclue(nominatim);
- g_free (nominatim);
-}