...
 
Commits (337)
*~
*.[oa]
*.lo
*.la
Makefile.in
Makefile
stamp-*
config.*
configure
INSTALL
aclocal.m4
autom4te.cache
compile
depcomp
install-sh
libtool
ltmain.sh
missing
.deps
.libs
*-marshal.[ch]
*.service
*.pc
*-glue.h
*-bindings.h
doxygen.conf
example/geoclue-find-example
example/geoclue-geocode-example
example/geoclue-map-example
example/geoclue-map-example-moving
example/geoclue-map-layout-example
example/geoclue-position-example
geoclue/geoclue-master
Keith Preston <keithpre@gmail.com>
Jussi Kukkonen <jku@o-hand.com>
Iain Holmes <Iain@openedhand.com>
This diff is collapsed.
SUBDIRS = interfaces geoclue providers src example test
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = geoclue.pc
DISTCLEANFILES = \
geoclue.pc
EXTRA_DIST = \
geoclue.pc.in
#! /bin/sh
LIBTOOLIZE=libtoolize
AUTOMAKE=automake
ACLOCAL=aclocal
AUTOCONF=autoconf
AUTOHEADER=autoheader
GTKDOCIZE=gtkdocize
# Check for binaries
[ "x$(which ${LIBTOOLIZE})x" = "xx" ] && {
echo "${LIBTOOLIZE} not found. Please install it."
exit 1
}
[ "x$(which ${AUTOMAKE})x" = "xx" ] && {
echo "${AUTOMAKE} not found. Please install it."
exit 1
}
[ "x$(which ${ACLOCAL})x" = "xx" ] && {
echo "${ACLOCAL} not found. Please install it."
exit 1
}
[ "x$(which ${AUTOCONF})x" = "xx" ] && {
echo "${AUTOCONF} not found. Please install it."
exit 1
}
[ "x$(which ${GTKDOCIZE})x" = "xx" ] && {
echo "${GTKDOCIZE} not found. Please install it."
exit 1
}
gtkdocize || exit 1
"${ACLOCAL}" \
&& "${LIBTOOLIZE}" \
&& "${AUTOHEADER}" \
&& "${AUTOMAKE}" --add-missing \
&& "${AUTOCONF}"
$(dirname "${0}")/configure "$@"
AC_PREREQ(2.59)
AC_INIT(geoclue, 0.10, http://geoclue.freedesktop.org)
AC_CONFIG_SRCDIR(geoclue/gc-iface-geoclue.c)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([1.9 foreign])
GEOCLUE_VERSION=0.10
AC_PROG_CC
AC_ISC_POSIX
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_GCC_TRADITIONAL
AM_PROG_LIBTOOL
GTK_DOC_CHECK(1.0)
AC_CHECK_PROGS(XSLT, xsltproc)
AC_ARG_ENABLE(system-bus,
[AC_HELP_STRING([--enable-system-bus],
[Use the system bus instead of session bus])],
enable_system_bus="$enableval",
enable_system_bus=no)
AM_CONDITIONAL(USE_SYSTEM_BUS, test x$enable_system_bus = xyes)
if test x$enable_system_bus = xyes; then
AC_DEFINE(GEOCLUE_DBUS_BUS, DBUS_BUS_SYSTEM, Use the system bus)
else
AC_DEFINE(GEOCLUE_DBUS_BUS, DBUS_BUS_SESSION, Use the session bus)
fi
PKG_CHECK_MODULES(GEOCLUE, [
glib-2.0
gobject-2.0
dbus-glib-1 >= 0.60
libxml-2.0
])
AC_SUBST(GEOCLUE_LIBS)
AC_SUBST(GEOCLUE_CFLAGS)
PKG_CHECK_MODULES(MASTER, [
gconf-2.0
])
AC_SUBST(MASTER_LIBS)
AC_SUBST(MASTER_CFLAGS)
AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool)
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
DBUS_SERVICES_DIR="${datadir}/dbus-1/services"
AC_SUBST(DBUS_SERVICES_DIR)
AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Where services dir for D-Bus is])
CFLAGS="$CFLAGS -g -Wall -Werror -Wno-format"
PKG_CHECK_MODULES(GTK, [
gtk+-2.0
], HAVE_GTK=yes, HAVE_GTK=no)
AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes")
AC_SUBST(GTK_LIBS)
AC_SUBST(GTK_CFLAGS)
CONNECTIVITY="None"
PKG_CHECK_MODULES(CONIC, [
conic
], HAVE_CONIC=yes, HAVE_CONIC=no)
if test "x$HAVE_CONIC" = "xyes"; then
CONNECTIVITY="Maemo LibConIC"
CONNECTIVITY_LIBS=${CONIC_LIBS}
CONNECTIVITY_CFLAGS=${CONIC_CFLAGS}
AC_DEFINE(HAVE_CONIC, 1, [define if libconic is installed])
fi
PKG_CHECK_MODULES(NETWORK_MANAGER, [
NetworkManager
], HAVE_NETWORK_MANAGER=yes, HAVE_NETWORK_MANAGER=no)
if test "x$HAVE_NETWORK_MANAGER" = "xyes"; then
CONNECTIVITY="Network Manager"
CONNECTIVITY_LIBS=${NETWORK_MANAGER_LIBS}
CONNECTIVITY_CFLAGS=${NETWORK_MANAGER_CFLAGS}
AC_DEFINE(HAVE_NETWORK_MANAGER, 1, [define if Network Manager is installed])
fi
AC_SUBST(CONNECTIVITY_LIBS)
AC_SUBST(CONNECTIVITY_CFLAGS)
PROVIDER_SUBDIRS="example hostip geonames manual plazes localnet yahoo"
PKG_CHECK_MODULES(GSMLOC, [
gammu >= 1.12
], HAVE_GSMLOC=yes, HAVE_GSMLOC=no)
if test "x$HAVE_GSMLOC" = "xyes"; then
PROVIDER_SUBDIRS="$PROVIDER_SUBDIRS gsmloc"
else
NO_BUILD_PROVIDERS="$NO_BUILD_PROVIDERS gsmloc"
fi
AC_SUBST(GSMLOC_LIBS)
AC_SUBST(GSMLOC_CFLAGS)
PKG_CHECK_MODULES(GYPSY, [
gypsy
], HAVE_GYPSY=yes,HAVE_GYPSY=no)
if test "x$HAVE_GYPSY" = "xyes"; then
PROVIDER_SUBDIRS="$PROVIDER_SUBDIRS gypsy"
else
NO_BUILD_PROVIDERS="$NO_BUILD_PROVIDERS gypsy"
fi
AC_SUBST(GYPSY_LIBS)
AC_SUBST(GYPSY_CFLAGS)
AC_CHECK_LIB(gps, gps_open,[libgps=yes] )
if test "x$libgps" = xyes; then
PROVIDER_SUBDIRS="$PROVIDER_SUBDIRS gpsd"
GPSD_LIBS="-lgps"
else
NO_BUILD_PROVIDERS="$NO_BUILD_PROVIDERS gpsd"
fi
AC_SUBST(GPSD_LIBS)
AC_SUBST(GPSD_CFLAGS)
AC_SUBST(PROVIDER_SUBDIRS)
AC_CONFIG_FILES([
geoclue.pc
Makefile
docs/Makefile
docs/reference/Makefile
docs/tools/Makefile
interfaces/Makefile
geoclue/Makefile
example/Makefile
test/Makefile
providers/Makefile
providers/example/Makefile
providers/gypsy/Makefile
providers/gpsd/Makefile
providers/hostip/Makefile
providers/geonames/Makefile
providers/manual/Makefile
providers/plazes/Makefile
providers/localnet/Makefile
providers/yahoo/Makefile
providers/gsmloc/Makefile
src/Makefile
])
AC_OUTPUT
echo ""
echo "Geoclue ${VERSION} has been configured as follows: "
echo "---------------------------------------------------"
echo "Source code location: ${srcdir}"
echo "Compiler: ${CC}"
echo "Network connectivity: ${CONNECTIVITY}"
echo "Providers: ${PROVIDER_SUBDIRS}"
echo "Excluded providers: ${NO_BUILD_PROVIDERS}"
echo ""
SUBDIRS = reference tools
## Process this file with automake to produce Makefile.in
# We require automake 1.6 at least.
AUTOMAKE_OPTIONS = 1.6
# This is a blank Makefile.am for using gtk-doc.
# Copy this to your project's API docs directory and modify the variables to
# suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples
# of using the various options.
# The name of the module, e.g. 'glib'.
DOC_MODULE=geoclue
# The top-level SGML file. You can change this if you want to.
DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
# The directory containing the source code. Relative to $(srcdir).
# gtk-doc will search all .c & .h files beneath here for inline comments
# documenting the functions and macros.
# e.g. DOC_SOURCE_DIR=../../../gtk
DOC_SOURCE_DIR=../../geoclue
# Extra options to pass to gtkdoc-scangobj. Not normally needed.
SCANGOBJ_OPTIONS=
# Extra options to supply to gtkdoc-scan.
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
SCAN_OPTIONS=
# Extra options to supply to gtkdoc-mkdb.
# e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml
MKDB_OPTIONS=--sgml-mode --output-format=xml
# Extra options to supply to gtkdoc-mktmpl
# e.g. MKTMPL_OPTIONS=--only-section-tmpl
MKTMPL_OPTIONS=
# Extra options to supply to gtkdoc-fixref. Not normally needed.
# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html
FIXXREF_OPTIONS=
# Used for dependencies. The docs will be rebuilt if any of these change.
# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c
HFILE_GLOB=$(top_srcdir)/geoclue/*.h
CFILE_GLOB=$(top_srcdir)/geoclue/*.c
# Header files to ignore when scanning.
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h
IGNORE_HFILES= \
geoclue-marshal.h \
gc-iface-address-bindings.h \
gc-iface-reverse-geocode-bindings.h \
gc-iface-geoclue-bindings.h \
gc-iface-velocity-bindings.h \
gc-iface-geocode-bindings.h \
gc-iface-position-bindings.h \
gc-iface-address-glue.h \
gc-iface-reverse-geocode-glue.h \
gc-iface-geoclue-glue.h \
gc-iface-velocity-glue.h \
gc-iface-geocode-glue.h \
gc-iface-position-glue.h
# Images to copy into HTML directory.
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
HTML_IMAGES=
dbus_docs = \
gc-iface-master-ref.xml \
gc-iface-master-client-ref.xml \
gc-iface-position-ref.xml \
gc-iface-address-ref.xml \
gc-iface-geocode-ref.xml \
gc-iface-reverse-geocode-ref.xml \
gc-iface-velocity-ref.xml
# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
# e.g. content_files=running.sgml building.sgml changes-2.0.sgml
content_files= \
implementing-providers.xml \
$(dbus_docs)
# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded
# These files must be listed here *and* in content_files
# e.g. expand_content_files=running.sgml
expand_content_files=
# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
# Only needed if you are using gtkdoc-scangobj to dynamically query widget
# signals and properties.
# e.g. INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
INCLUDES=-I$(top_srcdir) $(GEOCLUE_CFLAGS)
GTKDOC_LIBS=$(top_builddir)/geoclue/libgeoclue.la $(GEOCLUE_LIBS)
# This includes the standard gtk-doc make rules, copied by gtkdocize.
include $(top_srcdir)/gtk-doc.make
# Other files to distribute
# e.g. EXTRA_DIST += version.xml.in
EXTRA_DIST +=
CLEAN_FILES = $(dbus_docs)
%-ref.xml: $(top_srcdir)/interfaces/%-full.xml
$(XSLT) -o $@ $(top_srcdir)/docs/tools/spec-to-docbook.xsl $<
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
<bookinfo>
<title>Geoclue Reference Manual</title>
</bookinfo>
<reference>
<title>Geoclue for client applications</title>
<xi:include href="using-geoclue.xml"/>
<chapter>
<title>C API</title>
<xi:include href="xml/geoclue-master.xml"/>
<xi:include href="xml/geoclue-master-client.xml"/>
<xi:include href="xml/geoclue-common.xml"/>
<xi:include href="xml/geoclue-position.xml"/>
<xi:include href="xml/geoclue-address.xml"/>
<xi:include href="xml/geoclue-velocity.xml"/>
<xi:include href="xml/geoclue-geocode.xml"/>
<xi:include href="xml/geoclue-reverse-geocode.xml"/>
<xi:include href="xml/geoclue-types.xml"/>
<xi:include href="xml/geoclue-accuracy.xml"/>
<xi:include href="xml/geoclue-address-details.xml"/>
<xi:include href="xml/geoclue-error.xml"/>
</chapter>
</reference>
<reference>
<title>Geoclue for providers</title>
<xi:include href="implementing-providers.xml"/>
<chapter>
<title>Provider C API</title>
<xi:include href="xml/gc-provider.xml"/>
<xi:include href="xml/gc-web-service.xml"/>
<xi:include href="xml/gc-iface-geoclue.xml"/>
<xi:include href="xml/gc-iface-position.xml"/>
<xi:include href="xml/gc-iface-address.xml"/>
<xi:include href="xml/gc-iface-velocity.xml"/>
<xi:include href="xml/gc-iface-geocode.xml"/>
<xi:include href="xml/gc-iface-reverse-geocode.xml"/>
</chapter>
</reference>
<reference>
<title>D-Bus API</title>
<xi:include href="gc-iface-master-ref.xml"/>
<xi:include href="gc-iface-master-client-ref.xml"/>
<xi:include href="gc-iface-geoclue-ref.xml"/>
<xi:include href="gc-iface-position-ref.xml"/>
<xi:include href="gc-iface-address-ref.xml"/>
<xi:include href="gc-iface-velocity-ref.xml"/>
<xi:include href="gc-iface-geocode-ref.xml"/>
<xi:include href="gc-iface-reverse-geocode-ref.xml"/>
</reference>
</book>
#include <geoclue/geoclue-common.h>
#include <geoclue/geoclue-position.h>
#include <geoclue/geoclue-velocity.h>
#include <geoclue/geoclue-address.h>
#include <geoclue/geoclue-geocode.h>
#include <geoclue/geoclue-reverse-geocode.h>
#include <geoclue/gc-web-service.h>
#include <geoclue/gc-provider.h>
geoclue_common_get_type
geoclue_position_get_type
geoclue_velocity_get_type
geoclue_address_get_type
geoclue_geocode_get_type
geoclue_reverse_geocode_get_type
gc_web_service_get_type
gc_provider_get_type
This diff is collapsed.
EXTRA_DIST = spec-strip-docs.xsl spec-to-docbook.xsl
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"
exclude-result-prefixes="doc">
<xsl:output method="xml"
indent="yes"
encoding="UTF-8"
omit-xml-declaration="no"
doctype-system="http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"
doctype-public="-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" />
<xsl:template match="*">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:if test="not(starts-with(name(.), 'doc:'))">
<xsl:copy/>
</xsl:if>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="node">
<node>
<xsl:for-each select="@*">
<xsl:if test="not(starts-with(name(.), 'xmlns'))">
<xsl:copy/>
</xsl:if>
</xsl:for-each>
<xsl:apply-templates/>
</node>
</xsl:template>
<xsl:template match="doc:*"/>
<xsl:template match="text()"/>
</xsl:stylesheet>
This diff is collapsed.
noinst_PROGRAMS = \
position-example \
position-async-example \
master-example \
address-example \
geocode-example \
revgeocode-example \
common-example
common_example_SOURCES = common-example.c
position_example_SOURCES = position-example.c
position_async_example_SOURCES = position-async-example.c
address_example_SOURCES = address-example.c
geocode_example_SOURCES = geocode-example.c
revgeocode_example_SOURCES = revgeocode-example.c
master_example_SOURCES = master-example.c
AM_CFLAGS = $(GEOCLUE_CFLAGS)
LDADD = \
$(GEOCLUE_LIBS) \
$(top_builddir)/geoclue/libgeoclue.la
/*
* Geoclue
* address-example.c - Example using the Address client API
*
* Author: Jussi Kukkonen <jku@openedhand.com>
* Copyright 2007 by Garmin Ltd. or its subsidiaries
*/
#include <glib.h>
#include <geoclue/geoclue-common.h>
#include <geoclue/geoclue-address.h>
/* GHFunc, use with g_hash_table_foreach */
static void
print_address_key_and_value (char *key, char *value, gpointer user_data)
{
g_print (" %s: %s\n", key, value);
}
static GHashTable *
parse_options (int argc,
char **argv)
{
GHashTable *options;
int i;
options = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 2; i < argc; i += 2) {
g_hash_table_insert (options, argv[i], argv[i + 1]);
}
return options;
}
int main (int argc, char** argv)
{
gchar *service, *path;
GeoclueCommon *common = NULL;
GeoclueAddress *address = NULL;
int timestamp;
GHashTable *details = NULL;
GeoclueAccuracy *accuracy = NULL;
GeoclueAccuracyLevel level;
GError *error = NULL;
g_type_init();
if (argc < 2 || argc % 2 != 0) {
g_printerr ("Usage:\n address-example <provider_name> [option value]\n");
return 1;
}
g_print ("Using provider '%s'\n", argv[1]);
service = g_strdup_printf ("org.freedesktop.Geoclue.Providers.%s", argv[1]);
path = g_strdup_printf ("/org/freedesktop/Geoclue/Providers/%s", argv[1]);
common = geoclue_common_new (service, path);
if (common == NULL) {
g_printerr ("Error while creating GeoclueCommon object.\n");
return 1;
}
/* Create new GeoclueAddress */
address = geoclue_address_new (service, path);
g_free (service);
g_free (path);
if (address == NULL) {
g_printerr ("Error while creating GeoclueAddress object.\n");
return 1;
}
/* Set options */
if (argc > 2) {
GHashTable *options;
options = parse_options (argc, argv);
if (!geoclue_common_set_options (common, options, &error)) {
g_printerr ("Error setting options: %s\n",
error->message);
g_error_free (error);
error = NULL;
}
g_hash_table_destroy (options);
}
/* Query current address */
if (!geoclue_address_get_address (address, &timestamp,
&details, &accuracy,
&error)) {
g_printerr ("Error getting address: %s\n", error->message);
g_error_free (error);
g_object_unref (address);
return 1;
}
geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
/* address data is in GHashTable details, need to turn that into a string */
g_print ("Current address: (accuracy level %d)\n", level);
g_hash_table_foreach (details, (GHFunc)print_address_key_and_value, NULL);
g_hash_table_destroy (details);
geoclue_accuracy_free (accuracy);
g_object_unref (address);
return 0;
}
/*
* Geoclue
* common-example.c - Example using the Geoclue common client API
*
* Author: Jussi Kukkonen <jku@openedhand.com>
* Copyright 2007 by Garmin Ltd. or its subsidiaries
*/
#include <glib.h>
#include <geoclue/geoclue-common.h>
int main (int argc, char** argv)
{
gchar *service, *path;
GeoclueCommon *geoclue = NULL;
gchar *name = NULL;
gchar *desc = NULL;
GeoclueStatus status;
GHashTable *options;
GError *error = NULL;
g_type_init();
if (argc != 2) {
g_printerr ("Usage:\n common-example <provider_name>\n");
return 1;
}
g_print ("Using provider '%s'\n", argv[1]);
service = g_strdup_printf ("org.freedesktop.Geoclue.Providers.%s", argv[1]);
path = g_strdup_printf ("/org/freedesktop/Geoclue/Providers/%s", argv[1]);
/* Create new GeoclueCommon */
geoclue = geoclue_common_new (service, path);
g_free (service);
g_free (path);
if (geoclue == NULL) {
g_printerr ("Error while creating GeoclueGeocode object.\n");
return 1;
}
options = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (options, "GPSProvider", "Gypsy");
g_hash_table_insert (options, "PlaySong", "MGMT-Kids.mp3");
if (!geoclue_common_set_options (geoclue, options, &error)) {
g_printerr ("Error setting options: %s\n\n", error->message);
g_error_free (error);
error = NULL;
} else {
g_print ("Options set correctly\n\n");
}
g_hash_table_destroy (options);
if (!geoclue_common_get_provider_info (geoclue,
&name, &desc,
&error)) {
g_printerr ("Error getting provider info: %s\n\n", error->message);
g_error_free (error);
error = NULL;
} else {
g_print ("Provider info:\n");
g_print ("\tName: %s\n", name);
g_print ("\tDescription: %s\n\n", desc);
g_free (name);
g_free (desc);
}
if (!geoclue_common_get_status (geoclue, &status, &error)) {
g_printerr ("Error getting provider info: %s\n\n", error->message);
g_error_free (error);
error = NULL;
} else {
switch (status) {
case GEOCLUE_STATUS_ERROR:
g_print ("Provider status: error\n");
break;
case GEOCLUE_STATUS_UNAVAILABLE:
g_print ("Provider status: unavailable\n");
break;
case GEOCLUE_STATUS_ACQUIRING:
g_print ("Provider status: acquiring\n");
break;
case GEOCLUE_STATUS_AVAILABLE:
g_print ("Provider status: available\n");
break;
}
}
g_object_unref (geoclue);
g_free (geoclue);
return 0;
}
/*
* Geoclue
* geocode-example.c - Example using the Geocode client API
*
* Provider options are not used in this sample. See other files for
* examples on that.
*
* Author: Jussi Kukkonen <jku@openedhand.com>
* Copyright 2007, 2008 by Garmin Ltd. or its subsidiaries
*/
#include <glib.h>
#include <geoclue/geoclue-geocode.h>
int main (int argc, char** argv)
{
gchar *service, *path;
GeoclueGeocode *geocoder = NULL;
GeocluePositionFields fields;
GHashTable *address = NULL;
double lat, lon;
GeoclueAccuracy *accuracy = NULL;
GError *error = NULL;
g_type_init();
if (argc < 2 || argc > 3) {
g_printerr ("Usage:\n geocode-example <provider_name>\n");
return 1;
}
g_print ("Using provider '%s'\n", argv[1]);
service = g_strdup_printf ("org.freedesktop.Geoclue.Providers.%s", argv[1]);
path = g_strdup_printf ("/org/freedesktop/Geoclue/Providers/%s", argv[1]);
/* Address we'd like geocoded */
address = geoclue_address_details_new();
g_hash_table_insert (address, g_strdup ("postalcode"), g_strdup ("00330"));
g_hash_table_insert (address, g_strdup ("countrycode"), g_strdup ("FI"));
g_hash_table_insert (address, g_strdup ("locality"), g_strdup ("Helsinki"));
g_hash_table_insert (address, g_strdup ("street"), g_strdup ("Solnantie 24"));
/* Create new GeoclueGeocode */
geocoder = geoclue_geocode_new (service, path);
g_free (service);
g_free (path);
if (geocoder == NULL) {
g_printerr ("Error while creating GeoclueGeocode object.\n");
return 1;
}
/* Geocode. We're not interested in altitude
this time, so leave it NULL. */
fields = geoclue_geocode_address_to_position (geocoder, address,
&lat, &lon, NULL,
&accuracy, &error);
if (error) {
g_printerr ("Error while geocoding: %s\n", error->message);
g_error_free (error);
g_hash_table_destroy (address);
g_object_unref (geocoder);
return 1;
}
/* Print out coordinates if they are valid */
if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
GeoclueAccuracyLevel level;
geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
g_print ("Geocoded position (accuracy level %d): \n", level);
g_print ("\t%f, %f\n", lat, lon);
} else {
g_print ("Latitude and longitude not available.\n");
}
g_hash_table_destroy (address);
geoclue_accuracy_free (accuracy);
g_object_unref (geocoder);
return 0;
}
/*
* Geoclue
* master-example.c - Example using the Master client API
*
* Author: Iain Holmes <iain@openedhand.com>
* Copyright 2008 by Garmin Ltd. or its subsidiaries
*/
#include <config.h>
#include <geoclue/geoclue-master.h>
#include <geoclue/geoclue-address.h>
#include <geoclue/geoclue-position.h>
/* Provider methods */
static void
provider_changed_cb (GeoclueMasterClient *client,
char *iface,
char *name,
char *description,
gpointer userdata)
{
g_print ("%s provider changed: %s\n", iface, name);
}
/* Address methods */
static void
print_address_key_and_value (char *key, char *value, gpointer user_data)
{
g_print (" %s: %s\n", key, value);
}
static void
address_changed_cb (GeoclueAddress *address,
int timestamp,
GHashTable *details,
GeoclueAccuracy *accuracy)
{
GeoclueAccuracyLevel level;
geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
g_hash_table_foreach (details, (GHFunc)print_address_key_and_value, NULL);
}
static void
get_address (GeoclueMasterClient *client)
{
GError *error = NULL;
GeoclueAddress *address;
GHashTable *details = NULL;
GeoclueAccuracyLevel level;
GeoclueAccuracy *accuracy = NULL;
int timestamp = 0;
address = geoclue_master_client_address_create (client, &error);
if (!address) {
g_warning ("Creating GeoclueAddress failed: %s", error->message);
g_error_free (error);
return;
}
if (!geoclue_address_get_address (address, &timestamp,
&details, &accuracy,
&error)) {
g_printerr ("Error getting address: %s\n", error->message);
g_error_free (error);
g_object_unref (address);
return;
}
geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
g_print ("Current address: (accuracy level %d)\n", level);
g_hash_table_foreach (details, (GHFunc)print_address_key_and_value, NULL);
g_hash_table_destroy (details);
geoclue_accuracy_free (accuracy);
g_signal_connect (G_OBJECT (address), "address-changed",
G_CALLBACK (address_changed_cb), NULL);
}
/* Position methods */
static void
position_changed_cb (GeocluePosition *position,
GeocluePositionFields fields,
int timestamp,
double latitude,
double longitude,
double altitude,
GeoclueAccuracy *accuracy,
gpointer userdata)
{
if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
GeoclueAccuracyLevel level;
double horiz_acc;
geoclue_accuracy_get_details (accuracy, &level, &horiz_acc, NULL);
g_print ("Current position:\n");
g_print ("\t%f, %f\n", latitude, longitude);
g_print ("\tAccuracy level %d (%.0f meters)\n", level, horiz_acc);
} else {
g_print ("Current position: latitude and longitude not valid.\n");
}
}
static void
get_position (GeoclueMasterClient *client)
{
GeocluePosition *position;
GError *error = NULL;
GeocluePositionFields fields;
int timestamp;
double lat = 0.0, lon = 0.0, alt = 0.0;
GeoclueAccuracy *accuracy = NULL;
position = geoclue_master_client_position_create (client, &error);
if (!position) {
g_warning ("Creating GeocluePosition failed: %s", error->message);
g_error_free (error);
return;
}
fields = geoclue_position_get_position (position, &timestamp,
&lat, &lon, &alt,
&accuracy, &error);
if (error != NULL) {
g_warning ("%s", error->message);
g_error_free (error);
g_object_unref (position);
return;
}
g_print ("lat - %.2f lon - %.2f alt - %.2f\n", lat, lon, alt);
g_signal_connect (G_OBJECT (position), "position-changed",
G_CALLBACK (position_changed_cb), NULL);
}
int
main (int argc,
char **argv)
{
GeoclueMaster *master;
GeoclueMasterClient *client;
GError *error = NULL;
char *path;
GMainLoop *mainloop;
g_type_init ();
master = geoclue_master_get_default ();
client = geoclue_master_create_client (master, &path, &error);
g_signal_connect (G_OBJECT (client), "provider-changed",
G_CALLBACK (provider_changed_cb), NULL);
if (!geoclue_master_client_set_requirements (client,
GEOCLUE_ACCURACY_LEVEL_LOCALITY,
0,
FALSE,
GEOCLUE_RESOURCE_NETWORK,
NULL)){
g_printerr ("set_requirements failed");
}
get_address (client);
get_position (client);
mainloop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (mainloop);
return 0;
}
/*
* Geoclue
* position-example.c - Example using the Position client API
* (asynchronous method call)
*
* Author: Jussi Kukkonen <jku@openedhand.com>
* Copyright 2008 by Garmin Ltd. or its subsidiaries
*/
/* NOTE: provider options are not used in this example */
#include <glib.h>
#include <geoclue/geoclue-common.h>
#include <geoclue/geoclue-position.h>
static void
position_callback (GeocluePosition *pos,
GeocluePositionFields fields,
int timestamp,
double latitude,
double longitude,
double altitude,
GeoclueAccuracy *accuracy,
GError *error,
gpointer userdata)
{
if (error) {
g_printerr ("Error getting position: %s\n", error->message);
g_error_free (error);
g_object_unref (pos);
} else {
if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
GeoclueAccuracyLevel level;
geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
g_print ("Current position (accuracy %d):\n", level);
g_print ("\t%f, %f\n", latitude, longitude);
} else {
g_print ("Current position not available.\n");
}
}
g_main_loop_quit ((GMainLoop *)userdata);
}
int main (int argc, char** argv)
{
gchar *service, *path;
GMainLoop *mainloop;
GeocluePosition *pos = NULL;
if (argc < 2 || argc % 2 != 0) {
g_printerr ("Usage:\n position-example <provider_name>");
return 1;
}
g_type_init();
mainloop = g_main_loop_new (NULL, FALSE);
g_print ("Using provider '%s'\n", argv[1]);
service = g_strdup_printf ("org.freedesktop.Geoclue.Providers.%s", argv[1]);
path = g_strdup_printf ("/org/freedesktop/Geoclue/Providers/%s", argv[1]);
pos = geoclue_position_new (service, path);
g_free (service);
g_free (path);
if (pos == NULL) {
g_printerr ("Error while creating GeocluePosition object.\n");
return 1;
}
geoclue_position_get_position_async (pos,
(GeocluePositionCallback) position_callback,
mainloop);
g_print ("Asynchronous call made, going to main loop now...\n");
g_main_loop_run (mainloop);
g_main_loop_unref (mainloop);
g_object_unref (pos);
return 0;
}
/*
* Geoclue
* position-example.c - Example using the Position client API
*
* Author: Jussi Kukkonen <jku@openedhand.com>
* Copyright 2007 by Garmin Ltd. or its subsidiaries
*/
#include <glib.h>
#include <geoclue/geoclue-common.h>
#include <geoclue/geoclue-position.h>
static void
position_changed_cb (GeocluePosition *position,
GeocluePositionFields fields,
int timestamp,
double latitude,
double longitude,
double altitude,
GeoclueAccuracy *accuracy,
gpointer userdata)
{
if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
GeoclueAccuracyLevel level;
double horiz_acc;
geoclue_accuracy_get_details (accuracy, &level, &horiz_acc, NULL);
g_print ("Current position:\n");
g_print ("\t%f, %f\n", latitude, longitude);
g_print ("\tAccuracy level %d (%.0f meters)\n", level, horiz_acc);
} else {
g_print ("Latitude and longitude not available.\n");
}
}
static GHashTable *
parse_options (int argc,
char **argv)
{
GHashTable *options;
int i;
options = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 2; i < argc; i += 2) {
g_hash_table_insert (options, argv[i], argv[i + 1]);
}
return options;
}
int main (int argc, char** argv)
{
gchar *service, *path;
GeoclueCommon *common = NULL;
GeocluePosition *pos = NULL;
GeocluePositionFields fields;
int timestamp;
double lat, lon;
GeoclueAccuracy *accuracy = NULL;
GMainLoop *mainloop;
GError *error = NULL;
g_type_init();
if (argc < 2 || argc % 2 != 0) {
g_printerr ("Usage:\n position-example <provider_name> [option,value]\n");
return 1;
}
g_print ("Using provider '%s'\n", argv[1]);
service = g_strdup_printf ("org.freedesktop.Geoclue.Providers.%s", argv[1]);
path = g_strdup_printf ("/org/freedesktop/Geoclue/Providers/%s", argv[1]);
mainloop = g_main_loop_new (NULL, FALSE);
common = geoclue_common_new (service, path);
if (common == NULL) {
g_printerr ("Error while creating GeoclueCommon object.\n");
return 1;
}
/* Create new GeocluePosition */
pos = geoclue_position_new (service, path);
if (pos == NULL) {
g_printerr ("Error while creating GeocluePosition object.\n");
return 1;
}
g_free (service);
g_free (path);
if (argc > 2) {
GHashTable *options;
options = parse_options (argc, argv);
if (!geoclue_common_set_options (common, options, &error)) {
g_printerr ("Error setting options: %s\n",
error->message);
g_error_free (error);
error = NULL;
}
g_hash_table_destroy (options);
}
/* Query current position. We're not interested in altitude
this time, so leave it NULL. Same can be done with all other
arguments that aren't interesting to the client */
fields = geoclue_position_get_position (pos, &timestamp,
&lat, &lon, NULL,
&accuracy, &error);
if (error) {
g_printerr ("Error getting position: %s\n", error->message);
g_error_free (error);
g_object_unref (pos);
return 1;
}
/* Print out coordinates if they are valid */
if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
GeoclueAccuracyLevel level;
double horiz_acc;
geoclue_accuracy_get_details (accuracy, &level, &horiz_acc, NULL);
g_print ("Current position:\n");
g_print ("\t%f, %f\n", lat, lon);
g_print ("\tAccuracy level %d (%.0f meters)\n", level, horiz_acc);
} else {
g_print ("Latitude and longitude not available.\n");
}
geoclue_accuracy_free (accuracy);
g_signal_connect (G_OBJECT (pos), "position-changed",
G_CALLBACK (position_changed_cb), NULL);
g_main_loop_run (mainloop);
return 0;
}
/*
* Geoclue
* revgeocode-example.c - Example using the ReverseGeocode client API
*
* Author: Jussi Kukkonen <jku@openedhand.com>
* Copyright 2007 by Garmin Ltd. or its subsidiaries
*/
#include <glib.h>
#include <geoclue/geoclue-common.h>
#include <geoclue/geoclue-reverse-geocode.h>
/* GHFunc, use with g_hash_table_foreach */
static void
print_address_key_and_value (char *key, char *value, gpointer user_data)
{
g_print (" %s: %s\n", key, value);
}
static GHashTable *
parse_options (int argc,
char **argv)
{
GHashTable *options;
int i;
options = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 2; i < argc; i += 2) {
g_hash_table_insert (options, argv[i], argv[i + 1]);
}
return options;
}
int main (int argc, char** argv)
{
gchar *service, *path;
GeoclueCommon *common = NULL;
GeoclueReverseGeocode *revgeocoder = NULL;
GHashTable *address = NULL;
double lat, lon;
GError *error = NULL;
g_type_init();
if (argc != 2) {
g_printerr ("Usage:\n revgeocode-example <provider_name>\n");
return 1;
}
g_print ("Using provider '%s'\n", argv[1]);
service = g_strdup_printf ("org.freedesktop.Geoclue.Providers.%s", argv[1]);
path = g_strdup_printf ("/org/freedesktop/Geoclue/Providers/%s", argv[1]);
common = geoclue_common_new (service, path);
if (common == NULL) {
g_printerr ("Error while creating GeoclueCommon object.\n");
return 1;
}
/* Set options */
if (argc > 2) {
GHashTable *options;
options = parse_options (argc, argv);
if (!geoclue_common_set_options (common, options, &error)) {
g_printerr ("Error setting options: %s\n",
error->message);
g_error_free (error);
error = NULL;
}
g_hash_table_destroy (options);
}
address = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)g_free);
/* Create new GeoclueReverseGeocode */
revgeocoder = geoclue_reverse_geocode_new (service, path);
g_free (service);
g_free (path);
if (revgeocoder == NULL) {
g_printerr ("Error while creating GeoclueGeocode object.\n");
return 1;
}
lat = 60.2;
lon = 24.9;
if (!geoclue_reverse_geocode_position_to_address (revgeocoder,
lat, lon,
&address, &error)) {
g_printerr ("Error while reverse geocoding: %s\n", error->message);
g_error_free (error);
g_free (revgeocoder);
return 1;
}
/* Print out the address */
g_print ("Reverse Geocoded [%.2f, %.2f] to address:\n", lat, lon);
g_hash_table_foreach (address, (GHFunc)print_address_key_and_value, NULL);
g_hash_table_destroy (address);
g_object_unref (revgeocoder);
return 0;
}
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
datarootdir = @datarootdir@
datadir=@datadir@
Name: geoclue
Description: Geoinformation service
Requires: dbus-glib-1 libxml-2.0
Version: @VERSION@
Libs: -L${libdir} -lgeoclue
Cflags: -I${includedir}/geoclue
lib_LTLIBRARIES = libgeoclue.la
BUILT_SOURCES = \
geoclue-marshal.c \
geoclue-marshal.h \
gc-iface-address-bindings.h \
gc-iface-address-glue.h \
gc-iface-geoclue-bindings.h \
gc-iface-geoclue-glue.h \
gc-iface-geocode-bindings.h \
gc-iface-geocode-glue.h \
gc-iface-master-bindings.h \
gc-iface-master-client-bindings.h \
gc-iface-position-bindings.h \
gc-iface-position-glue.h \
gc-iface-reverse-geocode-bindings.h \
gc-iface-reverse-geocode-glue.h \
gc-iface-velocity-bindings.h \
gc-iface-velocity-glue.h
libgeoclue_la_SOURCES = \
$(BUILT_SOURCES) \
geoclue-accuracy.c \
geoclue-address.c \
geoclue-address-details.c \
geoclue-common.c \
geoclue-error.c \
geoclue-geocode.c \
geoclue-master.c \
geoclue-master-client.c \
geoclue-position.c \
geoclue-provider.c \
geoclue-reverse-geocode.c \
geoclue-types.c \
geoclue-velocity.c \
gc-provider.c \
gc-web-service.c \
gc-iface-address.c \
gc-iface-geoclue.c \
gc-iface-geocode.c \
gc-iface-position.c \
gc-iface-reverse-geocode.c \
gc-iface-velocity.c
libgeoclue_la_CFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir) \
$(GEOCLUE_CFLAGS)
geoclue_headers = \
gc-iface-address.h \
gc-iface-geoclue.h \
gc-iface-geocode.h \
gc-iface-position.h \
gc-iface-reverse-geocode.h \
gc-iface-velocity.h \
gc-provider.h \
gc-web-service.h \
geoclue-accuracy.h \
geoclue-address.h \
geoclue-address-details.h \
geoclue-common.h \
geoclue-error.h \
geoclue-geocode.h \
geoclue-master.h \
geoclue-master-client.h \
geoclue-position.h \
geoclue-provider.h \
geoclue-reverse-geocode.h \
geoclue-types.h \
geoclue-velocity.h
libgeoclue_includedir = $(includedir)/geoclue
libgeoclue_include_HEADERS = \
$(geoclue_headers)
EXTRA_DIST = \
geoclue-marshal.list \
$(BUILT_SOURCES)
CLEANFILES = $(BUILT_SOURCES) \
stamp-gc-iface-address-glue.h \
stamp-gc-iface-geoclue-glue.h \
stamp-gc-iface-geocode-glue.h \
stamp-gc-iface-position-glue.h \
stamp-gc-iface-reverse-geocode-glue.h \
stamp-gc-iface-velocity-glue.h
geoclue-marshal.h: geoclue-marshal.list $(GLIB_GENMARSHAL)
$(GLIB_GENMARSHAL) $< --header --prefix=geoclue_marshal > $@
geoclue-marshal.c: geoclue-marshal.list geoclue-marshal.h $(GLIB_GENMARSHAL)
echo "#include \"geoclue-marshal.h\"" > $@ \
&& $(GLIB_GENMARSHAL) --prefix=geoclue_marshal $(srcdir)/geoclue-marshal.list --body >> $@
%-glue.h: stamp-%-glue.h