...
 
Commits (419)
*~
*.[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
geoclue/geoclue-enum-types.h
geoclue/geoclue-enum-types.c
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 docs
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = geoclue.pc
DISTCLEANFILES = \
geoclue.pc
EXTRA_DIST = \
geoclue.pc.in
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
Current providers recognise these options:
* org.freedesktop.Geoclue.GPSDevice
Gypsy provider will use this device name
(e.g. "00:02:76:C5:81:BF" or "/dev/pgps")
* org.freedesktop.Geoclue.GPSHost
Gpsd provider will contact gpsd on this host.
Default is NULL (localhost)
* org.freedesktop.Geoclue.GPSPort
Gpsd provider will contact gpsd on this port.
Default is "2947".
Provider options can be set with SetOptions-method. Geoclue-master
reads options from gconf (/apps/geoclue/master): as an example, the
Gypsy device for geoclue master can be set with
gconftool-2 \
-t string \
-s /apps/geoclue/master/org.freedesktop.Geoclue.GPSDevice 00:02:76:C5:81:BF
#! /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.12.0, 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.12.0
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"
# -----------------------------------------------------------
# gtk+
# -----------------------------------------------------------
AC_ARG_ENABLE(gtk,
AS_HELP_STRING([--enable-gtk=@<:@no/yes/auto@:>@],
[build with gtk support]), ,
enable_gtk=auto)
if test "x$enable_gtk" != "xno"; then
PKG_CHECK_MODULES(GTK,
[
gtk+-2.0
], have_gtk="yes", have_gtk="no")
if test "x$have_gtk" = "xyes"; then
AC_DEFINE(HAVE_GTK, 1, [Define if you have gtk+])
fi
else
have_gtk=no
fi
if test "x$enable_gtk" = "xyes" -a "x$have_gtk" != "xyes"; then
AC_MSG_ERROR([Couldn't find gtk dependencies.])
fi
AM_CONDITIONAL(HAVE_GTK, test "x$have_gtk" = "xyes")
AC_SUBST(GTK_LIBS)
AC_SUBST(GTK_CFLAGS)
# -----------------------------------------------------------
# connectivity
# -----------------------------------------------------------
CONNECTIVITY="None"
AC_ARG_ENABLE(conic,
AS_HELP_STRING([--enable-conic=@<:@no/yes/auto@:>@],
[build with conic support]), ,
enable_conic=auto)
if test "x$enable_conic" != "xno"; then
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
else
have_conic=no
fi
if test "x$enable_conic" = "xyes" -a "x$have_conic" != "xyes"; then
AC_MSG_ERROR([Couldn't find conic dependencies.])
fi
AC_ARG_ENABLE(networkmanager,
AS_HELP_STRING([--enable-networkmanager=@<:@no/yes/auto@:>@],
[build with NetworkManager support]), ,
enable_networkmanager=auto)
if test "x$enable_networkmanager" != "xno"; then
PKG_CHECK_MODULES(NETWORK_MANAGER,
[
NetworkManager libnm_glib
], have_networkmanager="yes", have_networkmanager="no")
if test "x$have_networkmanager" = "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
else
have_networkmanager=no
fi
if test "x$enable_networkmanager" = "xyes" -a "x$have_networkmanager" != "xyes"; then
AC_MSG_ERROR([Couldn't find Network Manager dependencies.])
fi
AC_SUBST(CONNECTIVITY_LIBS)
AC_SUBST(CONNECTIVITY_CFLAGS)
PROVIDER_SUBDIRS="example hostip geonames nominatim manual plazes localnet yahoo gsmloc"
# -----------------------------------------------------------
# gypsy / gpsd / skyhook
# -----------------------------------------------------------
AC_ARG_ENABLE(gypsy,
AS_HELP_STRING([--enable-gypsy=@<:@no/yes/auto@:>@],
[build with gypsy support]), ,
enable_gypsy=auto)
if test "x$enable_gypsy" != "xno"; then
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
else
have_gypsy=no
fi
if test "x$enable_gypsy" = "xyes" -a "x$have_gypsy" != "xyes"; then
AC_MSG_ERROR([Couldn't find gypsy dependencies.])
fi
AC_SUBST(GYPSY_LIBS)
AC_SUBST(GYPSY_CFLAGS)
AC_ARG_ENABLE(gpsd,
AS_HELP_STRING([--enable-gpsd=@<:@no/yes/auto@:>@],
[build with gpsd support]), ,
enable_gpsd=auto)
if test "x$enable_gpsd" != "xno"; then
AC_CHECK_LIB(gps, gps_open,[libgps=yes] )
if test "x$have_gpsd" = "xyes"; then
PROVIDER_SUBDIRS="$PROVIDER_SUBDIRS gpsd"
GPSD_LIBS="-lgps"
else
NO_BUILD_PROVIDERS="$NO_BUILD_PROVIDERS gpsd"
fi
else
have_gpsd=no
fi
if test "x$enable_gpsd" = "xyes" -a "x$have_gpsd" != "xyes"; then
AC_MSG_ERROR([Couldn't find gpsd dependencies.])
fi
AC_SUBST(GPSD_LIBS)
AC_SUBST(GPSD_CFLAGS)
AC_ARG_ENABLE(skyhook,
AS_HELP_STRING([--enable-skyhook=@<:@no/yes/auto@:>@],
[build with skyhook support]), ,
enable_skyhook=auto)
if test "x$enable_skyhook" != "xno"; then
PKG_CHECK_MODULES(SKYHOOK, [
libsoup-gnome-2.4
], have_skyhook=yes, have_skyhook=no)
if test "x$have_skyhook" = "xyes"; then
PROVIDER_SUBDIRS="$PROVIDER_SUBDIRS skyhook"
GPSD_LIBS="-lgps"
else
NO_BUILD_PROVIDERS="$NO_BUILD_PROVIDERS skyhook"
fi
else
have_skyhook=no
fi
if test "x$enable_skyhook" = "xyes" -a "x$have_skyhook" != "xyes"; then
AC_MSG_ERROR([Couldn't find gpsd dependencies.])
fi
AC_SUBST(SKYHOOK_LIBS)
AC_SUBST(SKYHOOK_CFLAGS)
AC_SUBST(PROVIDER_SUBDIRS)
AC_SUBST(NO_BUILD_PROVIDERS)
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/nominatim/Makefile
providers/plazes/Makefile
providers/localnet/Makefile
providers/yahoo/Makefile
providers/gsmloc/Makefile
providers/skyhook/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-geoclue-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 \
using-geoclue.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>
<xi:include href="using-geoclue.xml"/>
<reference>
<title>C API</title>
<xi:include href="xml/geoclue-master.xml"/>
<xi:include href="xml/geoclue-master-client.xml"/>
<xi:include href="xml/geoclue-provider.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"/>
</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-master.h>
#include <geoclue/geoclue-master-client.h>
#include <geoclue/geoclue-provider.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/geoclue-accuracy.h>
#include <geoclue/geoclue-address-details.h>
#include <geoclue/geoclue-error.h>
#include <geoclue/geoclue-types.h>
#include <geoclue/gc-web-service.h>
#include <geoclue/gc-provider.h>
geoclue_master_get_type
geoclue_master_client_get_type
geoclue_provider_get_type
geoclue_position_get_type
geoclue_velocity_get_type
geoclue_address_get_type
geoclue_geocode_get_type
geoclue_reverse_geocode_get_type
geoclue_error_get_type
gc_web_service_get_type
gc_provider_get_type
This diff is collapsed.
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 \
master-pos-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
master_pos_example_SOURCES = master-pos-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
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include <glib.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;
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]);
/* 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_provider_set_options (GEOCLUE_PROVIDER (address), 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
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include <glib.h>
#include <geoclue/geoclue-position.h>
int main (int argc, char** argv)
{
gchar *service, *path;
GeocluePosition *pos = 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 */
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;
}
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_provider_set_options (GEOCLUE_PROVIDER (pos), 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_provider_get_provider_info (GEOCLUE_PROVIDER (pos),
&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_provider_get_status (GEOCLUE_PROVIDER (pos), &status, &error)) {
g_printerr ("Error getting status: %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 (pos);
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
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include <glib.h>
#include <geoclue/geoclue-geocode.h>
int main (int argc, char** argv)
{
gchar *service, *path;
GeoclueGeocode *geocoder = NULL;
GeocluePositionFields fields;
double lat, lon;
GeoclueAccuracy *accuracy = NULL;
GError *error = NULL;
g_type_init();
if (argc < 2) {
g_printerr ("Usage:\n geocode-example <provider_name> [\"freeform address\"]\n\n"
" If freeform address is not given, a hard coded address hash "
"will be used.\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 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;
}
if (argc == 2) {
GHashTable *address = NULL;
/* Address we'd like geocoded */
address = geoclue_address_details_new();
geoclue_address_details_insert (address, "locality", "Helsinki");
geoclue_address_details_insert (address, "postalcode", "00330");
geoclue_address_details_insert (address, "countrycode", "FI");
geoclue_address_details_insert (address, "street", "Solnantie 24");
/* 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);
g_hash_table_destroy (address);
} else {
char *str;
str = g_strjoinv (" ", &argv[2]);
fields = geoclue_geocode_freeform_address_to_position
(geocoder, str,
&lat, &lon, NULL,
&accuracy, &error);
g_free (str);
}
if (error) {
g_printerr ("Error while geocoding: %s\n", error->message);
g_error_free (error);
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");
}
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
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/* This example uses geoclue master to get approximate position
* and address signals. Following params are
* given to geoclue_master_client_set_requirements():
* min_accuracy = GEOCLUE_ACCURACY_LEVEL_LOCALITY
* Locality means a city or a town. Expect coordinates
* to routinely have 10-20 km error.
* min_time = 0
* No limit on frequency of position-changed signals
* (this is not actually implemented yet)
* require_updates = TRUE
* We want position-changed and address-changed signals
* allowed_resources = GEOCLUE_RESOURCE_NETWORK
* Web services may be used but e.g. GPS is off limits
*
* To ensure at least one working provider for your testing, visit
* hostip.info and define your IPs location if it's not set or is
* marked as "guessed"
*
* */
#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 *name,
char *description,
char *service,
char *path,
gpointer userdata)
{
g_print ("%s provider changed: %s\n", (char *)userdata, name);
}
/* Address methods */
static void
print_address_key_and_value (char *key, char *value, gpointer user_data)
{
g_print ("\t%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_print ("New address (accuracy level %d):\n", level);
g_hash_table_foreach (details, (GHFunc)print_address_key_and_value, NULL);
g_print ("\n");
}
static GeoclueAddress *
init_address (GeoclueMasterClient *client)
{
GError *error = NULL;
GeoclueAddress *address;
GHashTable *details = NULL;
GeoclueAccuracyLevel level;
GeoclueAccuracy *accuracy = NULL;
int timestamp = 0;
/* create the object and connect to signal */
address = geoclue_master_client_create_address (client, &error);
if (!address) {
g_warning ("Creating GeoclueAddress failed: %s", error->message);
g_error_free (error);
return NULL;
}
g_signal_connect (G_OBJECT (address), "address-changed",
G_CALLBACK (address_changed_cb), NULL);
/* print initial address */
if (!geoclue_address_get_address (address, &timestamp,
&details, &accuracy,
&error)) {
g_printerr ("Error getting address: %s\n", error->message);
g_error_free (error);
} else {
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_print ("\n");
g_hash_table_destroy (details);
geoclue_accuracy_free (accuracy);
}
return address;
}
/* Position methods */
static void
position_changed_cb (GeocluePosition *position,
GeocluePositionFields fields,
int timestamp,
double latitude,
double longitude,
double altitude,
GeoclueAccuracy *accuracy,
gpointer userdata)
{
GeoclueAccuracyLevel level;
geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
g_print ("New position (accuracy level %d):\n", level);
if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
g_print ("\t%f, %f\n\n", latitude, longitude);
} else {
g_print ("\nlatitude and longitude not valid.\n");
}
}
static GeocluePosition *
init_position (GeoclueMasterClient *client)
{
GeocluePosition *position;
GError *error = NULL;
GeocluePositionFields fields;
double lat = 0.0, lon = 0.0;
GeoclueAccuracy *accuracy;
position = geoclue_master_client_create_position (client, &error);
if (!position) {
g_warning ("Creating GeocluePosition failed: %s", error->message);
g_error_free (error);
return NULL;
}
g_signal_connect (G_OBJECT (position), "position-changed",
G_CALLBACK (position_changed_cb), NULL);
/*print initial position */
fields = geoclue_position_get_position (position, NULL,
&lat, &lon, NULL,
&accuracy, &error);
if (error != NULL) {
g_warning ("%s", error->message);
g_error_free (error);
} else {
GeoclueAccuracyLevel level;
geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
g_print ("New position (accuracy level %d):\n", level);
if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
g_print ("\t%f, %f\n\n", lat, lon);
} else {
g_print ("\nlatitude and longitude not valid.\n");
}
geoclue_accuracy_free (accuracy);
}
return position;
}
int
main (int argc,
char **argv)
{
GeoclueMaster *master;
GeoclueMasterClient *client;
GeocluePosition *pos;
GeoclueAddress *addr;
GMainLoop *mainloop;
g_type_init ();
master = geoclue_master_get_default ();
client = geoclue_master_create_client (master, NULL, NULL);
g_object_unref (master);
g_signal_connect (G_OBJECT (client), "address-provider-changed",
G_CALLBACK (provider_changed_cb), "Address");
g_signal_connect (G_OBJECT (client), "position-provider-changed",
G_CALLBACK (provider_changed_cb), "Position");
if (!geoclue_master_client_set_requirements (client,
GEOCLUE_ACCURACY_LEVEL_LOCALITY,
0,
TRUE,
GEOCLUE_RESOURCE_NETWORK,
NULL)){
g_printerr ("set_requirements failed");
g_object_unref (client);
return 1;
}
addr = init_address (client);
pos = init_position (client);
mainloop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (mainloop);
g_main_loop_unref (mainloop);
g_object_unref (pos);
g_object_unref (addr);
g_object_unref (client);
return 0;
}
/*
* Geoclue
* master-example.c - Example using the Master client API
*
* Authors: Iain Holmes <iain@openedhand.com>
* Jussi Kukkonen <jku@o-hand.com>
* Copyright 2008 by Garmin Ltd. or its subsidiaries
* 2008 OpenedHand Ltd
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/* This example shows typical GPS-like usage. Following params are
* given to geoclue_master_client_set_requirements():
* min_accuracy = GEOCLUE_ACCURACY_LEVEL_DETAILED
* We require the highest level of accuracy
* min_time = 0
* No limit on frequency of position-changed signals
* (this is not actually implemented yet)
* require_updates = TRUE
* We need position-changed signals
* allowed_resources = GEOCLUE_RESOURCE_ALL
* Any available resource can be used
*
* Geoclue master will try to select a suitable provider based on these
* requirements -- currently only Gypsy and Gpsd providers fulfill
* the above requiremens. Gpsd-provider should work out-of-the-box as
* long as gpsd is running in the default port. Gypsy provider requires
* that you set device name in the options: see README for details.
*
*/
#include <string.h>
#include <geoclue/geoclue-master.h>
#include <geoclue/geoclue-position.h>
static void
provider_changed_cb (GeoclueMasterClient *client,
char *iface,
char *name,
char *description,
gpointer userdata)
{
if (strlen (name) == 0) {
g_print ("No provider available\n");
} else {
g_print ("now using provider: %s\n", name);
}
}
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;
geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
g_print ("got position (accuracy level %d):\n", level);
g_print ("\t%f, %f\n", latitude, longitude);
} else {
g_print ("position emitted, but latitude and longitude are not valid.\n");
}
}
int
main (int argc,
char **argv)
{
GError *error = NULL;
GMainLoop *mainloop;
GeoclueMaster *master;
GeoclueMasterClient *client;
GeocluePosition *position;
g_type_init ();
master = geoclue_master_get_default ();
client = geoclue_master_create_client (master, NULL, NULL);
g_object_unref (master);
g_signal_connect (G_OBJECT (client), "position-provider-changed",
G_CALLBACK (provider_changed_cb), NULL);
/* We want provider that has detailed accuracy and emits signals.
* The provider is allowed to use any resources available. */
if (!geoclue_master_client_set_requirements (client,
GEOCLUE_ACCURACY_LEVEL_DETAILED,
0, TRUE,
GEOCLUE_RESOURCE_ALL,
NULL)){
g_printerr ("Setting requirements failed");
g_object_unref (client);
return 1;
}
position = geoclue_master_client_create_position (client, &error);
if (!position) {
g_warning ("Creating GeocluePosition failed: %s", error->message);
g_error_free (error);
g_object_unref (client);
return 1;
}
g_signal_connect (G_OBJECT (position), "position-changed",
G_CALLBACK (position_changed_cb), NULL);
mainloop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (mainloop);
g_main_loop_unref (mainloop);
g_object_unref (client);
g_object_unref (position);
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
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/* NOTE: provider options are not used in this example */
#include <glib.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);
} 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,