Commit 2ce41f92 authored by Zeeshan Ali's avatar Zeeshan Ali

Import geoip code from geocode-glib

geocode-glib is meant to only do (reverse-)geocoding and all geolocation
code belongs to us.

This means we now drop our geocode-glib dep and instead directly depend
on:

json-glib-1.0 >= 0.14
libsoup-2.4
geoip (Only needed by geoip server)
parent 8829c243
GTESTER = gtester # in $PATH for non-GLIB packages
GTESTER_REPORT = gtester-report # in $PATH for non-GLIB packages
# initialize variables for unconditional += appending
TEST_PROGS =
# test: run all tests in cwd and subdirs
test: ${TEST_PROGS}
@test -z "${TEST_PROGS}" || ${GTESTER} --verbose ${TEST_PROGS}
@ for subdir in $(SUBDIRS) . ; do \
test "$$subdir" = "." -o "$$subdir" = "po" || \
( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
done
# test-report: run tests in subdirs and generate report
# perf-report: run tests in subdirs with -m perf and generate report
# full-report: like test-report: with -m perf and -m slow
test-report perf-report full-report: ${TEST_PROGS}
@test -z "${TEST_PROGS}" || { \
case $@ in \
test-report) test_options="-k";; \
perf-report) test_options="-k -m=perf";; \
full-report) test_options="-k -m=perf -m=slow";; \
esac ; \
if test -z "$$GTESTER_LOGDIR" ; then \
${GTESTER} --verbose $$test_options -o test-report.xml ${TEST_PROGS} ; \
elif test -n "${TEST_PROGS}" ; then \
${GTESTER} --verbose $$test_options -o `mktemp "$$GTESTER_LOGDIR/log-XXXXXX"` ${TEST_PROGS} ; \
fi ; \
}
@ ignore_logdir=true ; \
if test -z "$$GTESTER_LOGDIR" ; then \
GTESTER_LOGDIR=`mktemp -d "\`pwd\`/.testlogs-XXXXXX"`; export GTESTER_LOGDIR ; \
ignore_logdir=false ; \
fi ; \
for subdir in $(SUBDIRS) . ; do \
test "$$subdir" = "." -o "$$subdir" = "po" || \
( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
done ; \
$$ignore_logdir || { \
echo '<?xml version="1.0"?>' > $@.xml ; \
echo '<report-collection>' >> $@.xml ; \
for lf in `ls -L "$$GTESTER_LOGDIR"/.` ; do \
sed '1,1s/^<?xml\b[^>?]*?>//' <"$$GTESTER_LOGDIR"/"$$lf" >> $@.xml ; \
done ; \
echo >> $@.xml ; \
echo '</report-collection>' >> $@.xml ; \
rm -rf "$$GTESTER_LOGDIR"/ ; \
${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $@.xml >$@.html ; \
}
.PHONY: test test-report perf-report full-report
# run make test as part of make check
check-local: test
......@@ -45,16 +45,33 @@ YELP_HELP_INIT
# GSettings support
GLIB_GSETTINGS
GLIB_MIN_VERSION=2.32.0
GEOCODE_MIN_VERSION=0.99.1
GLIB_MIN_VERSION=2.34.0
JSON_GLIB_MIN_VERSION=0.14
AC_CHECK_LIB([m],[sin])
PKG_CHECK_MODULES(GEOCLUE, [
glib-2.0 >= $GLIB_MIN_VERSION
gio-2.0 >= $GLIB_MIN_VERSION
gio-unix-2.0 >= $GLIB_MIN_VERSION
geocode-glib-1.0 >= $GEOCODE_MIN_VERSION
json-glib-1.0 >= $JSON_GLIB_MIN_VERSION
libsoup-2.4
])
# Requires for the geoip server
PKG_CHECK_MODULES(GEOIP_SERVER,
gio-2.0 >= $GLIB_MIN_VERSION
json-glib-1.0 >= $JSON_GLIB_MIN_VERSION
libsoup-2.4
geoip)
# Requires for the database update
PKG_CHECK_MODULES(GEOIP_DBUPDATE,
gio-2.0 >= $GLIB_MIN_VERSION)
GEOIP_DATABASE_PATH=`$PKG_CONFIG --variable=databasedir geoip`
AC_SUBST(GEOIP_DATABASE_PATH)
dnl Strict compiler
AC_ARG_ENABLE([strict-cc],
AS_HELP_STRING([--enable-strict-cc],[Enable strict C compiler]))
......@@ -85,6 +102,7 @@ AC_CONFIG_FILES([
Makefile
src/Makefile
src/geoclue-2.0.pc
src/geoip-server/Makefile
po/Makefile.in
data/Makefile
demo/Makefile
......
include $(top_srcdir)/Makefile.decl
libexec_PROGRAMS = geoclue
SUBDIRS = geoip-server
dbus_built_sources = geoclue-interface.c geoclue-interface.h
geoclue-interface.c: geoclue-interface.h
geoclue-interface.h: Makefile.am geoclue-interface.xml
......@@ -16,6 +20,12 @@ BUILT_SOURCES = \
geoclue_SOURCES = \
$(BUILT_SOURCES) \
gclue-main.c \
gclue-error.h \
gclue-error.c \
gclue-ipclient.h \
gclue-ipclient.c \
gclue-location-info.h \
gclue-location-info.c \
gclue-locator.h \
gclue-locator.c \
gclue-service-manager.h \
......@@ -28,7 +38,7 @@ geoclue_SOURCES = \
geoclue_CFLAGS = $(GEOCLUE_CFLAGS) \
-DLOCALEDIR="\"$(datadir)/locale\""
geoclue_LDADD = $(GEOCLUE_LIBS)
geoclue_LDADD = $(GEOCLUE_LIBS) $(LIBS)
lib_LTLIBRARIES = libgeoclue-1.0.la
libgeoclue_1_0_ladir = $(includedir)/geoclue-1.0
......@@ -76,7 +86,8 @@ Geoclue-1.0.typelib: Geoclue-1.0.gir $(INTROSPECTION_COMPILER)
$(INTROSPECTION_COMPILER) $< -o $@
CLEANFILES += $(gir_DATA) $(typelibs_DATA)
EXTRA_DIST = geoclue-interface.xml
EXTRA_DIST = geoclue-interface.xml \
test-data/freegeoip-results.json
endif # HAVE_INTROSPECTION
......
/* vim: set et ts=8 sw=8: */
/* gclue-error.c
*
* Copyright (C) 2013 Red Hat, Inc.
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Bastien Nocera <hadess@hadess.net>
*/
#include "gclue-error.h"
/**
* SECTION:gclue-error
* @short_description: Error helper functions
* @include: gclue-glib/gclue-glib.h
*
* Contains helper functions for reporting errors to the user.
**/
/**
* gclue_error_quark:
*
* Gets the gclue-glib error quark.
*
* Return value: a #GQuark.
**/
GQuark
gclue_error_quark (void)
{
static GQuark quark;
if (!quark)
quark = g_quark_from_static_string ("gclue_error");
return quark;
}
/* vim: set et ts=8 sw=8: */
/* gclue-error.c
*
* Copyright (C) 2013 Red Hat, Inc.
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Bastien Nocera <hadess@hadess.net>
*/
#ifndef GCLUE_ERROR_H
#define GCLUE_ERROR_H
#include <glib.h>
G_BEGIN_DECLS
/**
* GCLUE_ERROR:
*
* Error domain for gclue-glib. Errors from this domain will be from
* the #GClueError enumeration.
* See #GError for more information on error domains.
**/
#define GCLUE_ERROR (gclue_error_quark ())
/**
* GClueError:
* @GCLUE_ERROR_PARSE: An error occured parsing the response from the web service.
* @GCLUE_ERROR_NOT_SUPPORTED: The request made was not supported.
* @GCLUE_ERROR_NO_MATCHES: The requests made didn't have any matches.
* @GCLUE_ERROR_INVALID_ARGUMENTS: The request made contained invalid arguments.
* @GCLUE_ERROR_INTERNAL_SERVER: The server encountered an (possibly unrecoverable) internal error.
*
* Error codes returned by gclue-glib functions.
**/
typedef enum {
GCLUE_ERROR_PARSE,
GCLUE_ERROR_NOT_SUPPORTED,
GCLUE_ERROR_NO_MATCHES,
GCLUE_ERROR_INVALID_ARGUMENTS,
GCLUE_ERROR_INTERNAL_SERVER
} GClueError;
GQuark gclue_error_quark (void);
G_END_DECLS
#endif /* GCLUE_ERROR_H */
This diff is collapsed.
/* vim: set et ts=8 sw=8: */
/*
* Copyright (C) 2013 Red Hat, Inc.
Copyright (C) 2013 Satabdi Das
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Satabdi Das <satabdidas@gmail.com>
* Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
*/
#ifndef GCLUE_IPCLIENT_H
#define GCLUE_IPCLIENT_H
#include <glib.h>
#include <gio/gio.h>
#include "gclue-location-info.h"
G_BEGIN_DECLS
GType gclue_ipclient_get_type (void) G_GNUC_CONST;
#define GCLUE_TYPE_IPCLIENT (gclue_ipclient_get_type ())
#define GCLUE_IPCLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCLUE_TYPE_IPCLIENT, GClueIpclient))
#define GCLUE_IS_IPCLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCLUE_TYPE_IPCLIENT))
#define GCLUE_IPCLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCLUE_TYPE_IPCLIENT, GClueIpclientClass))
#define GCLUE_IS_IPCLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCLUE_TYPE_IPCLIENT))
#define GCLUE_IPCLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCLUE_TYPE_IPCLIENT, GClueIpclientClass))
/**
* GClueIpclient:
*
* All the fields in the #GClueIpclient structure are private and should never be accessed directly.
**/
typedef struct _GClueIpclient GClueIpclient;
typedef struct _GClueIpclientClass GClueIpclientClass;
typedef struct _GClueIpclientPrivate GClueIpclientPrivate;
struct _GClueIpclient {
/* <private> */
GObject parent_instance;
GClueIpclientPrivate *priv;
};
/**
* GClueIpclientClass:
*
* All the fields in the #GClueIpclientClass structure are private and should never be accessed directly.
**/
struct _GClueIpclientClass {
/* <private> */
GObjectClass parent_class;
};
GClueIpclient *gclue_ipclient_new (void);
GClueIpclient *gclue_ipclient_new_for_ip (const char *str);
void gclue_ipclient_search_async (GClueIpclient *ipclient,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GClueLocationInfo *gclue_ipclient_search_finish (GClueIpclient *ipclient,
GAsyncResult *res,
GError **error);
GClueLocationInfo *gclue_ipclient_search (GClueIpclient *ipclient,
GError **error);
G_END_DECLS
#endif /* GCLUE_IPCLIENT_H */
This diff is collapsed.
/* vim: set et ts=8 sw=8: */
/* main.c
*
* Copyright (C) 2013 Red Hat, Inc.
* Copyright (C) 2012 Bastien Nocera
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Bastien Nocera <hadess@hadess.net>
* Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
*/
#ifndef GCLUE_LOCATION_INFO_H
#define GCLUE_LOCATION_INFO_H
#include <glib-object.h>
G_BEGIN_DECLS
GType gclue_location_info_get_type (void) G_GNUC_CONST;
#define GCLUE_TYPE_LOCATION_INFO (gclue_location_info_get_type ())
#define GCLUE_LOCATION_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCLUE_TYPE_LOCATION_INFO, GClueLocationInfo))
#define GCLUE_IS_LOCATION_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCLUE_TYPE_LOCATION_INFO))
#define GCLUE_LOCATION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCLUE_TYPE_LOCATION_INFO, GClueLocationInfoClass))
#define GCLUE_IS_LOCATION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCLUE_TYPE_LOCATION_INFO))
#define GCLUE_LOCATION_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCLUE_TYPE_LOCATION_INFO, GClueLocationInfoClass))
typedef struct _GClueLocationInfo GClueLocationInfo;
typedef struct _GClueLocationInfoClass GClueLocationInfoClass;
typedef struct _GClueLocationInfoPrivate GClueLocationInfoPrivate;
/**
* GClueLocationInfo:
*
* All the fields in the #GClueLocationInfo structure are private and should never be accessed directly.
**/
struct _GClueLocationInfo {
/* <private> */
GObject parent_instance;
GClueLocationInfoPrivate *priv;
};
/**
* GClueLocationInfoClass:
*
* All the fields in the #GClueLocationInfoClass structure are private and should never be accessed directly.
**/
struct _GClueLocationInfoClass {
/* <private> */
GObjectClass parent_class;
};
#define GCLUE_LOCATION_INFO_ACCURACY_UNKNOWN -1
#define GCLUE_LOCATION_INFO_ACCURACY_STREET 1000 /* 1 km */
#define GCLUE_LOCATION_INFO_ACCURACY_CITY 15000 /* 15 km */
#define GCLUE_LOCATION_INFO_ACCURACY_REGION 50000 /* 50 km */
#define GCLUE_LOCATION_INFO_ACCURACY_COUNTRY 300000 /* 300 km */
#define GCLUE_LOCATION_INFO_ACCURACY_CONTINENT 3000000 /* 3000 km */
GClueLocationInfo *gclue_location_info_new (gdouble latitude,
gdouble longitude,
gdouble accuracy);
GClueLocationInfo *gclue_location_info_new_with_description (gdouble latitude,
gdouble longitude,
gdouble accuracy,
const char *description);
double gclue_location_info_get_distance_from (GClueLocationInfo *loca,
GClueLocationInfo *locb);
void gclue_location_info_set_description (GClueLocationInfo *loc,
const char *description);
const char *gclue_location_info_get_description (GClueLocationInfo *loc);
gdouble gclue_location_info_get_latitude (GClueLocationInfo *loc);
gdouble gclue_location_info_get_longitude (GClueLocationInfo *loc);
gdouble gclue_location_info_get_accuracy (GClueLocationInfo *loc);
guint64 gclue_location_info_get_timestamp (GClueLocationInfo *loc);
G_END_DECLS
#endif /* GCLUE_LOCATION_INFO_H */
......@@ -2,6 +2,7 @@
#include <glib/gi18n.h>
#include "gclue-locator.h"
#include "gclue-ipclient.h"
/* This class will be responsible for doing the actual geolocating. */
......@@ -9,12 +10,9 @@ G_DEFINE_TYPE (GClueLocator, gclue_locator, G_TYPE_OBJECT)
struct _GClueLocatorPrivate
{
/* Perhaps we should move this class from geocode-glib to geoclue in the
* near future.
*/
GeocodeIpclient *ipclient;
GClueIpclient *ipclient;
GeocodeLocation *location;
GClueLocationInfo *location;
};
enum
......@@ -70,7 +68,7 @@ gclue_locator_class_init (GClueLocatorClass *klass)
gParamSpecs[PROP_LOCATION] = g_param_spec_object ("location",
"Location",
"Location",
GEOCODE_TYPE_LOCATION,
GCLUE_TYPE_LOCATION_INFO,
G_PARAM_READABLE);
g_object_class_install_property (object_class,
PROP_LOCATION,
......@@ -96,15 +94,15 @@ void on_ipclient_search_ready (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GeocodeIpclient *ipclient = GEOCODE_IPCLIENT (source_object);
GClueIpclient *ipclient = GCLUE_IPCLIENT (source_object);
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
GClueLocator *locator;
GError *error = NULL;
locator = g_simple_async_result_get_op_res_gpointer (simple);
locator->priv->location = geocode_ipclient_search_finish (ipclient,
res,
&error);
locator->priv->location = gclue_ipclient_search_finish (ipclient,
res,
&error);
if (locator->priv->location == NULL) {
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete_in_idle (simple);
......@@ -128,7 +126,7 @@ gclue_locator_start (GClueLocator *locator,
g_return_if_fail (GCLUE_IS_LOCATOR (locator));
locator->priv->ipclient = geocode_ipclient_new ();
locator->priv->ipclient = gclue_ipclient_new ();
g_object_set (locator->priv->ipclient,
"server", "http://freegeoip.net/json/",
"compatibility-mode", TRUE,
......@@ -140,7 +138,7 @@ gclue_locator_start (GClueLocator *locator,
gclue_locator_start);
g_simple_async_result_set_op_res_gpointer (simple, locator, NULL);
geocode_ipclient_search_async (locator->priv->ipclient,
gclue_ipclient_search_async (locator->priv->ipclient,
cancellable,
on_ipclient_search_ready,
simple);
......@@ -200,7 +198,7 @@ gclue_locator_stop_finish (GClueLocator *locator,
return TRUE;
}
GeocodeLocation * gclue_locator_get_location (GClueLocator *locator)
GClueLocationInfo * gclue_locator_get_location (GClueLocator *locator)
{
g_return_val_if_fail (GCLUE_IS_LOCATOR (locator), NULL);
......
......@@ -2,8 +2,8 @@
#ifndef GCLUE_LOCATOR_H
#define GCLUE_LOCATOR_H
#include <glib-object.h>
#include <geocode-glib/geocode-glib.h>
#include <gio/gio.h>
#include "gclue-location-info.h"
G_BEGIN_DECLS
......@@ -34,22 +34,22 @@ struct _GClueLocatorClass
GType gclue_locator_get_type (void) G_GNUC_CONST;
GClueLocator * gclue_locator_new (void);
void gclue_locator_start (GClueLocator *locator,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean gclue_locator_start_finish (GClueLocator *locator,
GAsyncResult *res,
GError **error);
void gclue_locator_stop (GClueLocator *locator,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean gclue_locator_stop_finish (GClueLocator *locator,
GAsyncResult *res,
GError **error);
GeocodeLocation * gclue_locator_get_location (GClueLocator *locator);
GClueLocator * gclue_locator_new (void);
void gclue_locator_start (GClueLocator *locator,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean gclue_locator_start_finish (GClueLocator *locator,
GAsyncResult *res,
GError **error);
void gclue_locator_stop (GClueLocator *locator,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean gclue_locator_stop_finish (GClueLocator *locator,
GAsyncResult *res,
GError **error);
GClueLocationInfo * gclue_locator_get_location (GClueLocator *locator);
G_END_DECLS
......
......@@ -147,7 +147,7 @@ on_start_ready (GObject *source_object,
GClueServiceClientPrivate *priv = data->client->priv;
GClueLocator *locator = GCLUE_LOCATOR (source_object);
GClueServiceLocation *service_location;
GeocodeLocation *location;
GClueLocationInfo *location;
char *path;
GError *error = NULL;
......
......@@ -87,16 +87,16 @@ gclue_service_location_get_property (GObject *object,
case PROP_LOCATION:
{
GeocodeLocation *loc;
GClueLocationInfo *loc;
const char *desc;
loc = geocode_location_new
loc = gclue_location_info_new
(gclue_location_get_latitude (location),
gclue_location_get_longitude (location),
gclue_location_get_accuracy (location));
desc = gclue_location_get_description (location);
if (desc != NULL)
geocode_location_set_description (loc, desc);
gclue_location_info_set_description (loc, desc);
g_value_take_object (value, loc);
break;
......@@ -130,17 +130,17 @@ gclue_service_location_set_property (GObject *object,
case PROP_LOCATION:
{
GeocodeLocation *loc;
GClueLocationInfo *loc;
loc = g_value_get_object (value);
gclue_location_set_latitude
(location, geocode_location_get_latitude (loc));
(location, gclue_location_info_get_latitude (loc));
gclue_location_set_longitude
(location, geocode_location_get_longitude (loc));
(location, gclue_location_info_get_longitude (loc));
gclue_location_set_accuracy
(location, geocode_location_get_accuracy (loc));
(location, gclue_location_info_get_accuracy (loc));
gclue_location_set_description
(location, geocode_location_get_description (loc));
(location, gclue_location_info_get_description (loc));
break;
}
......@@ -312,7 +312,7 @@ gclue_service_location_class_init (GClueServiceLocationClass *klass)
gParamSpecs[PROP_LOCATION] = g_param_spec_object ("location",
"Location",
"Location",
GEOCODE_TYPE_LOCATION,
GCLUE_TYPE_LOCATION_INFO,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class,
......@@ -347,11 +347,11 @@ gclue_service_location_initable_iface_init (GInitableIface *iface)
}
GClueServiceLocation *
gclue_service_location_new (const char *peer,
const char *path,
GDBusConnection *connection,
GeocodeLocation *location,
GError **error)
gclue_service_location_new (const char *peer,
const char *path,
GDBusConnection *connection,
GClueLocationInfo *location,
GError **error)
{
return g_initable_new (GCLUE_TYPE_SERVICE_LOCATION,
NULL,
......
......@@ -23,7 +23,7 @@
#define GCLUE_SERVICE_LOCATION_H
#include <glib-object.h>
#include <geocode-glib/geocode-glib.h>
#include "gclue-location-info.h"
#include "geoclue-interface.h"
G_BEGIN_DECLS
......@@ -55,11 +55,11 @@ struct _GClueServiceLocationClass
GType gclue_service_location_get_type (void) G_GNUC_CONST;
GClueServiceLocation * gclue_service_location_new (const char *peer,
const char *path,
GDBusConnection *connection,
GeocodeLocation *location,
GError **error);
GClueServiceLocation * gclue_service_location_new (const char *peer,
const char *path,
GDBusConnection *connection,
GClueLocationInfo *location,
GError **error);
const char * gclue_service_location_get_path (GClueServiceLocation *location);
G_END_DECLS
......
......@@ -6,4 +6,4 @@ includedir=@includedir@
Name: Geoclue
Description: The Geoinformation Service
Version: @VERSION@
Requires: gio-unix-2.0 geocode-glib
Requires: gio-unix-2.0 libsoup json-glib-1.0
1. What does the server do?
The server performs IP address and Wi-Fi based geolocation search.
2. How to set up the server?
After building geoclue, you will get a geoip-lookup binary that you can install
as a cgi-bin script inside your web server, or use the test application
("launch-web-server.sh") as below.
$ ./launch-web-server.sh start - to start the server
$ ./launch-web-server.sh stop - to stop the server
The script will set up the server at your http://localhost:12345.
And the URL will be - http://localhost:12345/cgi-bin/geoip-lookup
3. How should one query the server for IP address based Geolocation search?
There are 2 ways -
a. You can provide a query string in the format of "?ip=<IP address>". After
installing the server at your localhost using the script, you can use -
http://localhost:12345/cgi-bin/geoip-lookup?ip=123.23.23.23
b. If you do not provide the query string, the server will autodetect
the client's external IP address.
If you have used launch-web-server.sh script to launch the server, the script
sets HTTP_CLIENT_IP (one of the many proxy variables checked by the server to
guess client's IP address) and thus a simple
http://localhost:12345/cgi-bin/geoip-lookup works.
4. How should one query the server for Wi-Fi based geolocation search?
The query string should be in the format of -
?wifi=mac:<mac address>|ssid:<ssid>|ss:<signal strength>[&...]
The server installed by the script at your localhost can be queried using the
following URL -
http://localhost:12345/cgi-bin/geoip-lookup?wifi=mac:01-24-7c-bc-51-46%7Cssid:3x2x%7Css:-37&wifi=mac:09-86-3b-31-97-b2%7Cssid:belkin.7b2%7Css:-47&wifi=mac:28-cf-da-ba-be-13%7Cssid:HERESIARCH%20NETWORK%7Css:-49&wifi=mac:2b-cf-da-ba-be-10%7Cssid:%20ARCH%20GUESTS%7Css:-52&wifi=mac:08-56-3b-2b-e1-a8%7Cssid:belkin.1a8%7Css:-59&wifi=mac:02-1e-64-fd-df-67%7Cssid:Brown%20Cow%7Css:-59&wifi=mac:2a-cf-df-ba-be-10%7Cssid:%20ARCH%20GUESTS%7Css:-59
5. What is the output format of the server?
The server provides Geolocation information in JSON format.
An IP address based query would return -
{"ip":"123.23.23.23","latitude":10.25,"longitude":105.96669769287109,
"country_name":"Vietnam","country_code":"VN","region_name":"Phu Yen",
"city":"Vinh Long","accuracy":"city","timezone":"Asia/Phnom_Penh",
"attribution":"This product includes GeoLite data created by MaxMind,
available from http://www.maxmind.com\n"}
An Wi-Fi based query would return -
{"latitude":40.060449299999988,"longitude":-105.2094195,"accuracy":24}
6. What are the possible error scenarios and error messages?
The server gives the following errors in the following cases -
a. Invalid IP address -
{"error_code":0, "error_message":"Invalid IP address '123.23.23'"}
b. Reserved IP address -
{"error_code":1, "error_message":"Can not find the IP address '127.0.0.1' in the
database"}
c. Database not found by the server -
{"error_code":2, "error_message":"Can not open GeoLiteCity/GeoIP Binary database.
Set GEOIP_DATABASE_PATH env variable."}
The error codes in the JSON output shown above are enum values.
typedef enum {
INVALID_IP_ADDRESS_ERR = 0,
INVALID_ENTRY_ERR,
DATABASE_ERR