...
 
Commits (408)
*~
*.[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>
Geoclue is licensed under the GNU LPGL Version 2
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
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.11.1, 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.11.1
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 manual plazes localnet yahoo"
# -----------------------------------------------------------
# gsmloc / gypsy / gpsd / skyhook
# -----------------------------------------------------------
AC_ARG_ENABLE(gsmloc,
AS_HELP_STRING([--enable-gsmloc=@<:@no/yes/auto@:>@],
[build with gsmloc support]), ,
enable_gsmloc=auto)
if test "x$enable_gsmloc" != "xno"; then
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
else
have_gsmloc=no
fi
if test "x$enable_gsmloc" = "xyes" -a "x$have_gsmloc" != "xyes"; then
AC_MSG_ERROR([Couldn't find gsmloc dependencies.])
fi
AC_SUBST(GSMLOC_LIBS)
AC_SUBST(GSMLOC_CFLAGS)
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
PKG_CHECK_MODULES(GPSD, [libgps >= 2.91], have_gpsd="yes", have_gpsd="no")
if test "x$have_gpsd" = "xyes"; then
PROVIDER_SUBDIRS="$PROVIDER_SUBDIRS gpsd"
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 - libgps >= 2.90.])
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/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
<?xml version="1.0"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<chapter>
<title>Developing a Geoclue provider</title>
<section id="overview">
<title>Overview</title>
<para>
Geoclue providers are D-Bus services that provide geoinformation services
by implementing defined interfaces (such as Position, Address or Geocode).
Writing a provider is possible in any language with D-Bus, but
Geoclue bindings are provided only for C. This how-to will outline the steps
needed to write a provider for Geoclue and provides
source code in C. The full source code for an exmple provider and several
other providers can be found in providers/ directory in the Geoclue source tree.
</para>
<para>
The only must-have requirements for providers are:
<itemizedlist>
<listitem>Must implement the *Geoclue*-interface. This interface has
some generic methods and signals for getting information about the
provider and its status </listitem>
<listitem>Must provide a service file. This is used by D-Bus to start the
service when needed.</listitem>
</itemizedlist>
</para>
<para>
A useful provider will also implement one, or several, other interfaces. It should
also have a .provider-file so GeoclueMaster can use it.
This howto will use "Position"-interface as an example. Possible interfaces
are listed here:
</para>
<variablelist>
<varlistentry>
<term>Geoclue</term>
<listitem><para>Methods and signals common to all providers.</para></listitem>
</varlistentry>
<varlistentry>
<term>Position</term>
<listitem><para>Methods and signals for acquiring current position
(latitude, longitude and altitude).</para></listitem>
</varlistentry>
<varlistentry>
<term>Velocity</term>
<listitem><para>Methods and signals for acquiring current velocity.</para></listitem>
</varlistentry>
<varlistentry>
<term>Address</term>
<listitem><para>Methods and signals for acquiring current address
(e.g. country, city, street address).</para></listitem>
</varlistentry>
<varlistentry>
<term>Geocode</term>
<listitem><para>Method for geocoding a known address to position.</para></listitem>
</varlistentry>
<varlistentry>
<term>ReverseGeocode</term>
<listitem><para>Method for reverse geocoding a known position to an address.</para></listitem>
</varlistentry>
</variablelist>
</section>
<section id="example_in_c">
<title>Minimal example in C</title>
<para>
In this chapter we'll look at implementing a minimal provider (which just implements
Geoclue-interface). Next chapter will show how other interface implementations can
be added using GObject interfaces.
</para>
<sect2 id="service_file">
<title>Service file</title>
<para>
Once your provider is installed, the service file allows D-Bus to start it
on demand. This is what your
org.freedesktop.Geoclue.Providers.MyExample.service.in should look like
(see Makefile.am for the processing):
</para>
<programlisting>
[D-BUS Service]
Name=org.freedesktop.Geoclue.Providers.MyExample
Exec=@libexecdir@/geoclue-my-example
</programlisting>
</sect2>
<sect2 id="provider_file">
<title>Provider file</title>
<para>
Provider files describe the provider for Geoclue Master. This is still
somewhat experimental, but a .provider-file for MyExample should look like this:
</para>
<programlisting>
[Geoclue Provider]
Name=My Example
Service=org.freedesktop.Geoclue.Providers.MyExample
Path=/org/freedesktop/Geoclue/Providers/MyExample
Interfaces=org.freedesktop.Geoclue.Position
Accuracy=0
Provides=ProvidesUpdates
Requires=
</programlisting>
<para>
TODO: list accuracylevels, Requires, Provides...
</para>
</sect2>
<sect2>
<subtitle>Makefile.am and configure.ac</subtitle>
<para>
A typical provider can be implemented in a single c-file with a very short
Makefile.am. This snippet assumes the code is built inside the geoclue source
tree:
</para>
<programlisting>
libexec_PROGRAMS = geoclue-my-example
geoclue_my_example_CFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir) \
$(GEOCLUE_CFLAGS)
geoclue_my_example_LDADD = \
$(GEOCLUE_LIBS) \
$(top_builddir)/geoclue/libgeoclue-provider.la
geoclue_my_example_SOURCES = \
geoclue-example.c
providersdir = $(datadir)/geoclue-providers
providers_DATA = geoclue-my-example.provider
servicedir = $(DBUS_SERVICES_DIR)
service_in_files = org.freedesktop.Geoclue.Providers.MyExample.service.in
service_DATA = $(service_in_files:.service.in=.service)
$(service_DATA): $(service_in_files) Makefile
@sed -e "s|\@libexecdir\@|$(libexecdir)|" $&lt; &gt; $@
</programlisting>
<para>
To get the provider built along with everything else in Geoclue, configure.ac
must be edited: The Makefile filename needs to be added into $AC_CONFIG_FILES
and the provider directory needs to be added to $PROVIDER_SUBDIRS.
</para>
</sect2>
<sect2>
<subtitle>The code</subtitle>
<para>
When coding in C, providers should be implemented as GObjects derived from
GcProvider, as GcProvider will take care of the D-Bus service setup (name
request and object registration). It will also partially implement the
Geoclue-interface.
</para>
<para>
First, include gc-provider.h:
</para>
<programlisting>
#include &lt;config.h&gt;
#include &lt;geoclue/gc-provider.h&gt;
</programlisting>
<para>
Define our ExampleProvider GObject (derive from GcProvider):
</para>
<programlisting>
typedef struct {
GcProvider parent;
GMainLoop *loop;
} GeoclueExample;
typedef struct {
GcProviderClass parent_class;
} GeoclueExampleClass;
#define GEOCLUE_TYPE_EXAMPLE (geoclue_example_get_type ())
#define GEOCLUE_EXAMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEOCLUE_TYPE_EXAMPLE, GeoclueExample))
G_DEFINE_TYPE (GeoclueExample, geoclue_example, GC_TYPE_PROVIDER)
</programlisting>
<para>
Next, implement Geoclue-interface functions (take a look at gc-iface-geoclue.h)
and use them to override GcProvider:
</para>
<programlisting>
static gboolean
get_status (GcIfaceGeoclue *gc,
gboolean *available,
GError **error)
{
*available = TRUE;
return TRUE;
}
static gboolean
shutdown (GcIfaceGeoclue *gc,
GError **error)
{
GeoclueExample *example = GEOCLUE_EXAMPLE (gc);
g_main_loop_quit (example->loop);
return TRUE;
}
static void
geoclue_example_class_init (GeoclueExampleClass *klass)
{
GcProviderClass *p_class = (GcProviderClass *) klass;
p_class->get_status = get_status;
p_class->shutdown = shutdown;
}
</programlisting>
<para>
get_status() and shutdown() return TRUE as an indication that the method
was succesfully invoked. The actual return values are set in pointer
arguments such as "available" in get_status(). See the interface
documentation to find out how the functions should behave.
</para>
<para>
Next, write a initialization function for the provider:
</para>
<programlisting>
static void
geoclue_example_init (GeoclueExample *example)
{
gc_provider_set_details (GC_PROVIDER (example),
"org.freedesktop.Geoclue.Providers.MyExample",
"/org/freedesktop/Geoclue/Providers/MyExample",
"My Example", "Example provider");
}
</programlisting>
<para>
GcProvider will use the service name and path to setup the D-Bus service.
Name and description (the last two arguments) will be used to implement
get_provider_info().
</para>
<para>
That's pretty much it. We still need a main() function to run the code:
</para>
<programlisting>
int
main (int argc,
char **argv)
{
GeoclueExample *example;
g_type_init ();
example = g_object_new (GEOCLUE_TYPE_EXAMPLE, NULL);
example->loop = g_main_loop_new (NULL, TRUE);
g_main_loop_run (example->loop);
g_main_loop_unref (example->loop);
g_object_unref (example);
return 0;
}
</programlisting>
<para>
The provider should compile and run now. Start it and test with a D-Bus call:
</para>
<programlisting>
dbus-send --print-reply \
--dest="org.freedesktop.Geoclue.Providers.MyExample" \
/org/freedesktop/Geoclue/Providers/MyExample \
org.freedesktop.Geoclue.GetProviderInfo
</programlisting>
</sect2>
</section>
<section>
<title>Adding functionality by implementing other interfaces</title>
<para>
Adding functionality to the (so far fairly impotent) provider is not
difficult. These are the steps needed to implement interface X:
</para>
<itemizedlist>
<listitem>Include the interface header (gc-iface-X.h)</listitem>
<listitem>Use G_IMPLEMENT_INTERFACE in your provider type definition</listitem>
<listitem>Implement the methods and signals defined in gc-iface-X.h</listitem>
<listitem>Implement a interface initialization function</listitem>
</itemizedlist>
<para>
In our example we're implementing the Position interface:
</para>
<programlisting>
#include &lt;geoclue/gc-iface-position.h&gt;
</programlisting>
<para>
The type definition should now look like this:
</para>
<programlisting>
static void geoclue_example_position_init (GcIfacePositionClass *iface);
G_DEFINE_TYPE_WITH_CODE (GeoclueExample, geoclue_example, GC_TYPE_PROVIDER,
G_IMPLEMENT_INTERFACE (GC_TYPE_IFACE_POSITION,
geoclue_example_position_init))
</programlisting>
<para>
Next, take a look at the interface header (gc-iface-position.h). Implement
the interface method and write some signal emission code:
</para>
<programlisting>
static gboolean
get_position (GcIfacePosition *gc,
GeocluePositionFields *fields,
int *timestamp,
double *latitude,
double *longitude,
double *altitude,
GeoclueAccuracy **accuracy,
GError **error)
{
*fields = GEOCLUE_POSITION_FIELDS_LATITUDE | GEOCLUE_POSITION_FIELDS_LONGITUDE,
*accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0.0, 0.0);
*latitude = 60.0;
*longitude = 25.0;
return TRUE;
}
static gboolean
emit_position_signal (GeoclueExample *example)
{
static GeoclueAccuracy *accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0, 0);
/ * make up some coordinates * /
static double lat = 60.0;
static double lon = 25.0;
lat += 0.1;
lon -= 0.1;
g_debug ("Emitting position\n");
gc_iface_position_emit_position_changed
(GC_IFACE_POSITION (example),
GEOCLUE_POSITION_FIELDS_LATITUDE | GEOCLUE_POSITION_FIELDS_LONGITUDE,
time (NULL),
lat, lon, 0,
accuracy);
geoclue_accuracy_free (accuracy);
return TRUE;
}
</programlisting>
<para>
Yes, this implementation is too useful... For more realistic
examples see the included providers in providers/-directory. Note the
use of convenience function gc_iface_position_emit_position_changed() for
signal emission.
</para>
<para>
The example does not have a real position data source, so we'll
emulate signal emission: add a g_timeout_add call in main(), before running the
main loop.
</para>
<programlisting>
g_timeout_add (5000, (GSourceFunc)emit_position_signal, example);
</programlisting>
<para>
Finally, the interface method needs to be initialized to the implementation we just defined:
</para>
<programlisting>
static void
geoclue_example_position_init (GcIfacePositionClass *iface)
{
iface->get_position = get_position;
}
</programlisting>
<para>
You can try your provider out by starting it and running
"example/position-example MyExample"
</para>
</section>
</chapter>
<?xml version="1.0"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<chapter>
<title>Using Geoclue in applications</title>
<section id="overview">
<title>Overview</title>
<sect2>
<subtitle>Why use Geoclue</subtitle>
<para>
Building context-sensitive applications is difficult. Location-sensitivy is no
exception, but Geoclue tries to help there. With Geoclue it is possible to build
location-aware applications with less work and less knowledge about the actual
geoinformation sources.
</para>
<para> Main features of Geoclue are:
<itemizedlist>
<listitem>Standardized D-Bus (and GObject) interfaces to various geographical data sources</listitem>
<listitem>Easy and fast to implement: Need to get data from provider XYZ?
Chances are, Geoclue is the easiest way to do that...</listitem>
<listitem>Geoclue Master provider (experimental at the moment) makes things eaven easier:
you don't even have to choose a data provider, just let Geoclue choose the
best possible provider for you.</listitem>
<listitem>Adding new providers (data sources) is straight-forward: Even when the geoinformation
source you want is not already in Geoclue, Implementing a Geoclue provider may
well turn out to be the easiest way forward.</listitem>
</itemizedlist>
</para>
</sect2>
<sect2>
<subtitle>Requirements</subtitle>
<para>
Geoclue is a collection of D-Bus APIs. Internally it's implemented with GLib and GObject (as is the C wrapper library).
Several included providers also use Libxml2, and the master provider uses GConf.
</para>
<para>
There is a GObject-based C API, but using Geoclue is possible from any programming language
with D-Bus support.
</para>
</sect2>
<sect2>
<subtitle>Using basic Geoclue providers</subtitle>
<para>
D-Bus can automatically start services as they're needed so basic method calls
can be made without any preparation. However, geoclue providers may shut down when
they're not used. This means that clients using signals and clients that set any options
should always use AddReference() and RemoveReference() methods to ensure server
persistence. In C the wrapper takes care of this.
</para>
<para>
Clients should not assume that method calls will return instantly or that the
response will contain valid data. Examples of possible problems
<itemizedlist>
<listitem>Many geoclue providers use web services so method calls may take seconds or even time out.</listitem>
<listitem>GPS providers usually respond instantly, but will not have a valid data until after getting a fix (which may take anything from a few seconds to minutes)</listitem>
</itemizedlist>
Using signals should be the first option whenever the used provider supports them.
When signals are not available, asynchronous method calls can be used in
applications where UI responsiveness is important.
</para>
</sect2>
<sect2>
<subtitle>Using Geoclue Master</subtitle>
<para>Master provider was designed to solve the following problems:
<itemizedlist>
<listitem>A single provider cannot be the best solution to all problems</listitem>
<listitem>The "best" providers will be different depending on the user</listitem>
<listitem>Supporting a single geodata source can be a big job for an application developer, supporting several would be a nightmare</listitem>
</itemizedlist>
</para>
<para>
Master provider implements the same interfaces as regular providers, but internally
it uses whichever regular provider happens to be the best one (with "best" defined as
a provider that fulfills the accuracy requirements and does not surpass resource restrictions).
The internally used provider may change over time -- this does not interrupt clients use in any way,
but the changes can be observed using the MasterClient API.
</para>
<para>
A typical Master provider use includes:
<itemizedlist>
<listitem>Getting a client-specific GeoclueMasterClient from GeoclueMaster</listitem>
<listitem>Setting GeoclueMasterClient requirements (such as accuracy)</listitem>
<listitem>Starting the wanted interfaces (such as Position) </listitem>
<listitem>Using the client just like a regular provider</listitem>
</itemizedlist>
</para>
<para>
Master provider is fairly new and may not be as stable as the rest of Geoclue.
</para>
</sect2>
<sect2>
<subtitle>Current providers</subtitle>
TODO: list the providers shipped with geoclue, shortly explain their features.
</sect2>
</section>
<section id="simple-example">
<title>Using basic Geoclue providers: simple example in C</title>
<para>There are several examples in the geoclue source, these are included here to
give a quick overview.
</para>
<para>
Here is a very simple example of using a specific Geoclue Position provider.
Note that we're using the synchronous version of the method call here, so
geoclue_position_get_position() will block until the response comes (or until D-Bus timeouts).
</para>
<programlisting>
#include &lt;geoclue/geoclue-position.h&gt;
int main()
{
GeocluePosition *pos;
GeocluePositionFields fields;
double lat, lon;
GError *error = NULL;
g_type_init ();
/ * Create the position object * /
pos = geoclue_position_new ("org.freedesktop.Geoclue.Providers.Hostip",
"/org/freedesktop/Geoclue/Providers/Hostip");
/ * call get_position. Note that unneeded output variables (here
timestamp, altitude and accuracy) can be left NULL * /
fields = geoclue_position_get_position (pos, NULL,
&amp;lat, &amp;lon, NULL,
NULL, &amp;error);
if (error) {
g_printerr ("Error in get_position: %s.\n", error->message);
g_error_free (error);
g_object_unref (pos);
return 1;
}
if (fields &amp; GEOCLUE_POSITION_FIELDS_LATITUDE &amp;&amp;
fields &amp; GEOCLUE_POSITION_FIELDS_LONGITUDE) {
g_print ("According to Hostip.info we're at %.3f, %.3f.\n",
lat, lon);
} else {
g_print ("Hostip does not have a valid location available.\nVisit http://www.hostip.info/ to correct this");
}
g_object_unref (pos);
return 0;
}
</programlisting>
<para>Save as test-hostip.c and compile with
</para>
<programlisting>
gcc `pkg-config --libs --cflags geoclue` -o test-hostip test-hostip.c
</programlisting>
<para>Here is a similarly simple example using GLib mainloop and Gypsy provider with
position-changed signals:
</para>
<programlisting>
#include &lt;geoclue/geoclue-position.h&gt;
/ * device name or bluetooth address * /
#define GPS_DEVICE_NAME "00:02:76:C5:81:BF"
static void
position_changed (GeocluePosition *position,
GeocluePositionFields fields,
int timestamp,
double latitude,
double longitude,
double altitude,
GeoclueAccuracy *accuracy,
gpointer userdata)
{
g_print ("Position changed:\n");
if (fields &amp; GEOCLUE_POSITION_FIELDS_LATITUDE &amp;&amp;
fields &amp; GEOCLUE_POSITION_FIELDS_LONGITUDE) {
g_print ("\t%f, %f\n\n", latitude, longitude);
} else {
g_print ("\tLatitude and longitude not available.\n\n");
}