From 7f14998e22ff64b85bd4fd11b8def8c0a346b1ec Mon Sep 17 00:00:00 2001 From: Minjune Kim Date: Fri, 10 Feb 2012 19:47:48 +0900 Subject: [PATCH] remove geoclue-gpsd --- Makefile.am | 2 +- configure.ac | 22 - debian/changelog | 16 + debian/control | 17 +- debian/patches/geoclue_0.12.0-20slp2.patch | 0 debian/patches/geoclue_0.12.0-21slp2.patch | 762 +++++++++++++++++++++ debian/patches/geoclue_0.12.0-22slp2.patch | 76 ++ debian/patches/series | 2 + debian/patches/tizen.patch | 0 debian/rules | 2 +- docs/Makefile.am | 0 docs/reference/Makefile.am | 4 +- docs/reference/geoclue-docs.sgml | 8 +- docs/reference/geoclue.types | 0 docs/reference/implementing-providers.xml | 114 +-- docs/reference/using-geoclue.xml | 100 +-- docs/tools/Makefile.am | 0 docs/tools/spec-strip-docs.xsl | 14 +- docs/tools/spec-to-docbook.xsl | 0 example/address-example.c | 22 +- example/common-example.c | 20 +- example/geocode-example.c | 24 +- example/master-example.c | 62 +- example/master-pos-example.c | 38 +- example/position-async-example.c | 24 +- example/position-example.c | 36 +- example/revgeocode-example.c | 24 +- geoclue/Makefile.am | 2 +- geoclue/gc-iface-address.c | 14 +- geoclue/gc-iface-address.h | 2 +- geoclue/gc-iface-geoclue.c | 16 +- geoclue/gc-iface-geoclue.h | 2 +- geoclue/gc-iface-geocode.c | 12 +- geoclue/gc-iface-geocode.h | 2 +- geoclue/gc-iface-nmea.c | 12 +- geoclue/gc-iface-nmea.h | 2 +- geoclue/gc-iface-position.c | 12 +- geoclue/gc-iface-position.h | 0 geoclue/gc-iface-reverse-geocode.c | 14 +- geoclue/gc-iface-reverse-geocode.h | 2 +- geoclue/gc-iface-satellite.c | 10 +- geoclue/gc-iface-satellite.h | 2 +- geoclue/gc-iface-velocity.c | 10 +- geoclue/gc-iface-velocity.h | 0 geoclue/gc-provider.c | 88 +-- geoclue/gc-provider.h | 6 +- geoclue/gc-web-service.c | 150 ++-- geoclue/gc-web-service.h | 2 +- geoclue/geoclue-accuracy.c | 34 +- geoclue/geoclue-accuracy.h | 0 geoclue/geoclue-address-details.c | 30 +- geoclue/geoclue-address-details.h | 2 +- geoclue/geoclue-address.c | 72 +- geoclue/geoclue-address.h | 2 +- geoclue/geoclue-error.c | 2 +- geoclue/geoclue-error.h | 0 geoclue/geoclue-geocode.c | 58 +- geoclue/geoclue-geocode.h | 4 +- geoclue/geoclue-master-client.c | 166 ++--- geoclue/geoclue-master-client.h | 0 geoclue/geoclue-master.c | 42 +- geoclue/geoclue-master.h | 0 geoclue/geoclue-nmea.c | 30 +- geoclue/geoclue-nmea.h | 4 +- geoclue/geoclue-position.c | 46 +- geoclue/geoclue-position.h | 2 +- geoclue/geoclue-provider.c | 140 ++-- geoclue/geoclue-provider.h | 6 +- geoclue/geoclue-reverse-geocode.c | 52 +- geoclue/geoclue-reverse-geocode.h | 4 +- geoclue/geoclue-satellite-info.h | 2 +- geoclue/geoclue-satellite.c | 10 +- geoclue/geoclue-satellite.h | 4 +- geoclue/geoclue-types.c | 8 +- geoclue/geoclue-types.h | 68 +- geoclue/geoclue-velocity.c | 46 +- geoclue/geoclue-velocity.h | 2 +- interfaces/gc-iface-address-full.xml | 2 +- interfaces/gc-iface-geoclue-full.xml | 16 +- interfaces/gc-iface-geocode-full.xml | 2 +- interfaces/gc-iface-master-client-full.xml | 6 +- interfaces/gc-iface-master-full.xml | 2 +- interfaces/gc-iface-nmea-full.xml | 6 +- interfaces/gc-iface-position-full.xml | 6 +- interfaces/gc-iface-reverse-geocode-full.xml | 8 +- interfaces/gc-iface-velocity-full.xml | 0 packaging/geoclue.spec | 22 +- providers/example/geoclue-example.c | 8 +- providers/example/geoclue-example.provider | 0 ...reedesktop.Geoclue.Providers.Example.service.in | 0 providers/geonames/Makefile.am | 2 +- providers/geonames/geoclue-geonames.c | 90 +-- providers/geonames/geoclue-geonames.h | 4 +- providers/geonames/geoclue-geonames.provider | 0 ...eedesktop.Geoclue.Providers.Geonames.service.in | 0 providers/gpsd/Makefile.am | 0 providers/gpsd/geoclue-gpsd.c | 441 +++++------- providers/gpsd/geoclue-gpsd.provider | 0 ...g.freedesktop.Geoclue.Providers.Gpsd.service.in | 0 providers/gpsd/setting.c | 58 +- providers/gpsd/setting.h | 31 +- providers/gsmloc/Makefile.am | 2 +- providers/gsmloc/geoclue-gsmloc-ofono.c | 10 +- providers/gsmloc/geoclue-gsmloc-ofono.h | 0 providers/gsmloc/geoclue-gsmloc.c | 36 +- providers/gsmloc/geoclue-gsmloc.provider | 0 providers/gsmloc/mcc.h | 2 +- providers/gsmloc/ofono-manager.xml | 0 providers/gsmloc/ofono-marshal.list | 0 providers/gsmloc/ofono-modem.xml | 0 providers/gsmloc/ofono-network-operator.xml | 0 providers/gsmloc/ofono-network-registration.xml | 0 ...freedesktop.Geoclue.Providers.Gsmloc.service.in | 0 providers/gypsy/geoclue-gypsy.c | 40 +- providers/gypsy/geoclue-gypsy.provider | 0 ....freedesktop.Geoclue.Providers.Gypsy.service.in | 0 providers/hostip/Makefile.am | 2 +- providers/hostip/geoclue-hostip.c | 54 +- providers/hostip/geoclue-hostip.h | 0 providers/hostip/geoclue-hostip.provider | 0 ...freedesktop.Geoclue.Providers.Hostip.service.in | 0 providers/localnet/Makefile.am | 2 +- providers/localnet/geoclue-localnet.c | 190 ++--- providers/localnet/geoclue-localnet.provider | 0 providers/localnet/geoclue-localnet.xml | 0 ...eedesktop.Geoclue.Providers.Localnet.service.in | 0 providers/manual/Makefile.am | 2 +- providers/manual/geoclue-manual.c | 98 +-- providers/manual/geoclue-manual.provider | 0 providers/manual/geoclue-manual.xml | 0 ...freedesktop.Geoclue.Providers.Manual.service.in | 0 providers/nominatim/Makefile.am | 2 +- providers/nominatim/geoclue-nominatim.c | 54 +- providers/nominatim/geoclue-nominatim.h | 2 +- providers/nominatim/geoclue-nominatim.provider | 0 ...edesktop.Geoclue.Providers.Nominatim.service.in | 0 providers/plazes/Makefile.am | 2 +- providers/plazes/geoclue-plazes.c | 130 ++-- providers/plazes/geoclue-plazes.provider | 0 ...freedesktop.Geoclue.Providers.Plazes.service.in | 0 providers/skyhook/Makefile.am | 2 +- providers/skyhook/geoclue-skyhook.c | 46 +- ...reedesktop.Geoclue.Providers.Skyhook.service.in | 0 providers/yahoo/Makefile.am | 2 +- providers/yahoo/geoclue-yahoo.c | 58 +- providers/yahoo/geoclue-yahoo.provider | 0 ....freedesktop.Geoclue.Providers.Yahoo.service.in | 0 src/client.c | 272 ++++---- src/client.h | 0 src/connectivity-conic.c | 34 +- src/connectivity-conic.h | 2 +- src/connectivity-networkmanager.c | 40 +- src/connectivity-networkmanager.h | 2 +- src/connectivity.c | 14 +- src/connectivity.h | 6 +- src/main.c | 6 +- src/main.h | 0 src/master-provider.c | 396 +++++------ src/master-provider.h | 14 +- src/master.c | 40 +- src/master.h | 4 +- src/org.freedesktop.Geoclue.Master.service.in | 0 test/geoclue-test-gui.c | 334 ++++----- 163 files changed, 2962 insertions(+), 2227 deletions(-) mode change 100755 => 100644 configure.ac mode change 100755 => 100644 debian/patches/geoclue_0.12.0-20slp2.patch create mode 100644 debian/patches/geoclue_0.12.0-21slp2.patch create mode 100644 debian/patches/geoclue_0.12.0-22slp2.patch mode change 100755 => 100644 debian/patches/series mode change 100755 => 100644 debian/patches/tizen.patch mode change 100644 => 100755 docs/Makefile.am mode change 100644 => 100755 docs/reference/Makefile.am mode change 100644 => 100755 docs/reference/geoclue-docs.sgml mode change 100644 => 100755 docs/reference/geoclue.types mode change 100644 => 100755 docs/reference/implementing-providers.xml mode change 100644 => 100755 docs/reference/using-geoclue.xml mode change 100644 => 100755 docs/tools/Makefile.am mode change 100644 => 100755 docs/tools/spec-strip-docs.xsl mode change 100644 => 100755 docs/tools/spec-to-docbook.xsl mode change 100644 => 100755 example/address-example.c mode change 100644 => 100755 example/common-example.c mode change 100644 => 100755 example/geocode-example.c mode change 100644 => 100755 example/master-example.c mode change 100644 => 100755 example/position-async-example.c mode change 100644 => 100755 example/revgeocode-example.c mode change 100644 => 100755 geoclue/gc-iface-address.c mode change 100644 => 100755 geoclue/gc-iface-address.h mode change 100644 => 100755 geoclue/gc-iface-geoclue.c mode change 100644 => 100755 geoclue/gc-iface-geoclue.h mode change 100644 => 100755 geoclue/gc-iface-geocode.c mode change 100644 => 100755 geoclue/gc-iface-geocode.h mode change 100644 => 100755 geoclue/gc-iface-position.c mode change 100644 => 100755 geoclue/gc-iface-position.h mode change 100644 => 100755 geoclue/gc-iface-reverse-geocode.c mode change 100644 => 100755 geoclue/gc-iface-reverse-geocode.h mode change 100644 => 100755 geoclue/gc-iface-velocity.c mode change 100644 => 100755 geoclue/gc-iface-velocity.h mode change 100644 => 100755 geoclue/gc-provider.h mode change 100644 => 100755 geoclue/gc-web-service.h mode change 100644 => 100755 geoclue/geoclue-accuracy.c mode change 100644 => 100755 geoclue/geoclue-accuracy.h mode change 100644 => 100755 geoclue/geoclue-address-details.c mode change 100644 => 100755 geoclue/geoclue-address-details.h mode change 100644 => 100755 geoclue/geoclue-address.c mode change 100644 => 100755 geoclue/geoclue-address.h mode change 100644 => 100755 geoclue/geoclue-error.c mode change 100644 => 100755 geoclue/geoclue-error.h mode change 100644 => 100755 geoclue/geoclue-geocode.c mode change 100644 => 100755 geoclue/geoclue-geocode.h mode change 100644 => 100755 geoclue/geoclue-master-client.h mode change 100644 => 100755 geoclue/geoclue-master.c mode change 100644 => 100755 geoclue/geoclue-master.h mode change 100644 => 100755 geoclue/geoclue-position.c mode change 100644 => 100755 geoclue/geoclue-position.h mode change 100644 => 100755 geoclue/geoclue-provider.h mode change 100644 => 100755 geoclue/geoclue-reverse-geocode.c mode change 100644 => 100755 geoclue/geoclue-reverse-geocode.h mode change 100644 => 100755 geoclue/geoclue-velocity.c mode change 100644 => 100755 geoclue/geoclue-velocity.h mode change 100644 => 100755 interfaces/gc-iface-address-full.xml mode change 100644 => 100755 interfaces/gc-iface-geocode-full.xml mode change 100644 => 100755 interfaces/gc-iface-master-client-full.xml mode change 100644 => 100755 interfaces/gc-iface-master-full.xml mode change 100644 => 100755 interfaces/gc-iface-position-full.xml mode change 100644 => 100755 interfaces/gc-iface-reverse-geocode-full.xml mode change 100644 => 100755 interfaces/gc-iface-velocity-full.xml mode change 100755 => 100644 packaging/geoclue.spec mode change 100644 => 100755 providers/example/geoclue-example.provider mode change 100644 => 100755 providers/example/org.freedesktop.Geoclue.Providers.Example.service.in mode change 100644 => 100755 providers/geonames/geoclue-geonames.c mode change 100644 => 100755 providers/geonames/geoclue-geonames.h mode change 100644 => 100755 providers/geonames/geoclue-geonames.provider mode change 100644 => 100755 providers/geonames/org.freedesktop.Geoclue.Providers.Geonames.service.in mode change 100755 => 100644 providers/gpsd/Makefile.am mode change 100755 => 100644 providers/gpsd/geoclue-gpsd.c mode change 100755 => 100644 providers/gpsd/geoclue-gpsd.provider mode change 100755 => 100644 providers/gpsd/org.freedesktop.Geoclue.Providers.Gpsd.service.in mode change 100755 => 100644 providers/gpsd/setting.c mode change 100755 => 100644 providers/gpsd/setting.h mode change 100644 => 100755 providers/gsmloc/geoclue-gsmloc-ofono.c mode change 100644 => 100755 providers/gsmloc/geoclue-gsmloc-ofono.h mode change 100644 => 100755 providers/gsmloc/geoclue-gsmloc.provider mode change 100644 => 100755 providers/gsmloc/mcc.h mode change 100644 => 100755 providers/gsmloc/ofono-manager.xml mode change 100644 => 100755 providers/gsmloc/ofono-marshal.list mode change 100644 => 100755 providers/gsmloc/ofono-modem.xml mode change 100644 => 100755 providers/gsmloc/ofono-network-operator.xml mode change 100644 => 100755 providers/gsmloc/ofono-network-registration.xml mode change 100644 => 100755 providers/gsmloc/org.freedesktop.Geoclue.Providers.Gsmloc.service.in mode change 100644 => 100755 providers/gypsy/geoclue-gypsy.provider mode change 100644 => 100755 providers/gypsy/org.freedesktop.Geoclue.Providers.Gypsy.service.in mode change 100644 => 100755 providers/hostip/geoclue-hostip.c mode change 100644 => 100755 providers/hostip/geoclue-hostip.h mode change 100644 => 100755 providers/hostip/geoclue-hostip.provider mode change 100644 => 100755 providers/hostip/org.freedesktop.Geoclue.Providers.Hostip.service.in mode change 100644 => 100755 providers/localnet/geoclue-localnet.provider mode change 100644 => 100755 providers/localnet/geoclue-localnet.xml mode change 100644 => 100755 providers/localnet/org.freedesktop.Geoclue.Providers.Localnet.service.in mode change 100644 => 100755 providers/manual/geoclue-manual.provider mode change 100644 => 100755 providers/manual/geoclue-manual.xml mode change 100644 => 100755 providers/manual/org.freedesktop.Geoclue.Providers.Manual.service.in mode change 100644 => 100755 providers/nominatim/geoclue-nominatim.c mode change 100644 => 100755 providers/nominatim/geoclue-nominatim.h mode change 100644 => 100755 providers/nominatim/geoclue-nominatim.provider mode change 100644 => 100755 providers/nominatim/org.freedesktop.Geoclue.Providers.Nominatim.service.in mode change 100644 => 100755 providers/plazes/geoclue-plazes.provider mode change 100644 => 100755 providers/plazes/org.freedesktop.Geoclue.Providers.Plazes.service.in mode change 100644 => 100755 providers/skyhook/org.freedesktop.Geoclue.Providers.Skyhook.service.in mode change 100644 => 100755 providers/yahoo/geoclue-yahoo.c mode change 100644 => 100755 providers/yahoo/geoclue-yahoo.provider mode change 100644 => 100755 providers/yahoo/org.freedesktop.Geoclue.Providers.Yahoo.service.in mode change 100644 => 100755 src/client.h mode change 100644 => 100755 src/connectivity-conic.c mode change 100644 => 100755 src/connectivity-conic.h mode change 100644 => 100755 src/main.h mode change 100644 => 100755 src/master-provider.h mode change 100644 => 100755 src/master.h mode change 100644 => 100755 src/org.freedesktop.Geoclue.Master.service.in diff --git a/Makefile.am b/Makefile.am index b629df0..58a1235 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = interfaces geoclue providers src +SUBDIRS = interfaces geoclue providers src pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = geoclue.pc diff --git a/configure.ac b/configure.ac old mode 100755 new mode 100644 index e692553..145ad25 --- a/configure.ac +++ b/configure.ac @@ -145,28 +145,6 @@ AC_SUBST(CONNECTIVITY_CFLAGS) PROVIDER_SUBDIRS="nominatim" -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, [vconf 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_SUBST(PROVIDER_SUBDIRS) AC_SUBST(NO_BUILD_PROVIDERS) diff --git a/debian/changelog b/debian/changelog index 4aba281..df6ef84 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,19 @@ +geoclue (0.12.0-22slp3) unstable; urgency=low + + * remove geoclue-gpsd + * Git : pkgs/g/geoclue + * Tag : geoclue_0.12.0-22slp3 + + -- Genie Kim Fri, 10 Feb 2012 17:58:42 +0900 + +geoclue (0.12.0-21slp2) unstable; urgency=low + + * add altitude / h_accuracy / v_accurcy in last position(geoclue_0.12.0-21slp2.patch) + * Git : pkgs/g/geoclue + * Tag : geoclue_0.12.0-21slp2 + + -- Genie Kim Tue, 10 Jan 2012 19:48:21 +0900 + geoclue (0.12.0-20slp2) unstable; urgency=low * use quilt for patch(tizen.patch) diff --git a/debian/control b/debian/control index 996a62a..11bf439 100755 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: utils Priority: extra Maintainer: Youngae Kang , Yunhan Kim , Genie kim Uploaders: Genie Kim -Build-Depends: debhelper (>= 5), autotools-dev, libglib2.0-dev, libdbus-glib-1-dev, libxml2-dev, libgconf-dbus-dev, libgps-dev, libslp-setting-dev +Build-Depends: debhelper (>= 5), autotools-dev, libglib2.0-dev, libdbus-glib-1-dev, libxml2-dev, libgconf-dbus-dev, libslp-setting-dev Standards-Version: 3.7.2 Homepage: http://www.freedesktop.org/wiki/Software/GeoClue @@ -29,9 +29,9 @@ Description: C API for GeoClue Package: libgeoclue-dbg Section: debug Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libgeoclue(=${Source-Version}), geoclue(=${Source-Version}), geoclue-gpsd(=${Source-Version}) +Depends: ${shlibs:Depends}, ${misc:Depends}, libgeoclue(=${Source-Version}), geoclue(=${Source-Version}) Suggests: geoclue -Description: Debug package for libgeoclue, geoclue, geoclue-gpsd +Description: Debug package for libgeoclue, geoclue Package: libgeoclue-dev Section: libdevel @@ -41,17 +41,6 @@ Description: C API for GeoClue (development files) libgeoclue is a convenience wrapper for the GeoClue service, and the recommended way to use GeoClue in the C language. -Package: geoclue-gpsd -Section: utils -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, geoclue (= ${binary:Version}), gpsd, libgps19 -Description: Position server for GeoClue (GPS) - GeoClue provides applications access to various geographical information - sources using a D-Bus API or a C library. - . - This package provides a positioning backend for GeoClue. The - location information comes from a GPS receiver through gpsd - Package: geoclue-nominatim Section: utils Architecture: any diff --git a/debian/patches/geoclue_0.12.0-20slp2.patch b/debian/patches/geoclue_0.12.0-20slp2.patch old mode 100755 new mode 100644 diff --git a/debian/patches/geoclue_0.12.0-21slp2.patch b/debian/patches/geoclue_0.12.0-21slp2.patch new file mode 100644 index 0000000..e576e82 --- /dev/null +++ b/debian/patches/geoclue_0.12.0-21slp2.patch @@ -0,0 +1,762 @@ +Index: geoclue/providers/gpsd/geoclue-gpsd.c +=================================================================== +--- geoclue.orig/providers/gpsd/geoclue-gpsd.c 2012-01-10 19:47:47.587095982 +0900 ++++ geoclue/providers/gpsd/geoclue-gpsd.c 2012-01-19 23:53:59.655726459 +0900 +@@ -45,9 +45,6 @@ + + #include "setting.h" + +-#define LAST_POS_PRECESION 10000 +-#define POSITION_LENGTH 16 +- + typedef struct gps_data_t gps_data; + typedef struct gps_fix_t gps_fix; + +@@ -64,7 +61,9 @@ + int timestamp; + double latitude; + double longitude; +- double accuracy; ++ double altitude; ++ double hor_accuracy; ++ double ver_accuracy; + } GeoclueGpsdsLastPosition; + + typedef struct { +@@ -90,48 +89,40 @@ + GcProviderClass parent_class; + } GeoclueGpsdClass; + +-static void geoclue_gpsd_position_init (GcIfacePositionClass *iface); +-static void geoclue_gpsd_velocity_init (GcIfaceVelocityClass *iface); ++static void geoclue_gpsd_position_init(GcIfacePositionClass * iface); ++static void geoclue_gpsd_velocity_init(GcIfaceVelocityClass * iface); + + #define GEOCLUE_TYPE_GPSD (geoclue_gpsd_get_type ()) + #define GEOCLUE_GPSD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEOCLUE_TYPE_GPSD, GeoclueGpsd)) + +-G_DEFINE_TYPE_WITH_CODE (GeoclueGpsd, geoclue_gpsd, GC_TYPE_PROVIDER, +- G_IMPLEMENT_INTERFACE (GC_TYPE_IFACE_POSITION, +- geoclue_gpsd_position_init) +- G_IMPLEMENT_INTERFACE (GC_TYPE_IFACE_VELOCITY, +- geoclue_gpsd_velocity_init)) +- +-static void geoclue_gpsd_stop_gpsd (GeoclueGpsd *self); +-static gboolean geoclue_gpsd_start_gpsd (GeoclueGpsd *self); ++G_DEFINE_TYPE_WITH_CODE(GeoclueGpsd, geoclue_gpsd, GC_TYPE_PROVIDER, ++ G_IMPLEMENT_INTERFACE(GC_TYPE_IFACE_POSITION, geoclue_gpsd_position_init) ++ G_IMPLEMENT_INTERFACE(GC_TYPE_IFACE_VELOCITY, geoclue_gpsd_velocity_init)) + ++static void geoclue_gpsd_stop_gpsd(GeoclueGpsd * self); ++static gboolean geoclue_gpsd_start_gpsd(GeoclueGpsd * self); + + /* defining global GeoclueGpsd because gpsd does not support "user_data" + * pointers in callbacks */ + GeoclueGpsd *gpsd; + + /* Geoclue interface */ +-static gboolean +-get_status (GcIfaceGeoclue *gc, +- GeoclueStatus *status, +- GError **error) ++static gboolean get_status(GcIfaceGeoclue * gc, GeoclueStatus * status, GError ** error) + { +- GeoclueGpsd *gpsd = GEOCLUE_GPSD (gc); ++ GeoclueGpsd *gpsd = GEOCLUE_GPSD(gc); + + *status = gpsd->last_status; + return TRUE; + } + +-static void +-shutdown (GcProvider *provider) ++static void shutdown(GcProvider * provider) + { +- GeoclueGpsd *gpsd = GEOCLUE_GPSD (provider); ++ GeoclueGpsd *gpsd = GEOCLUE_GPSD(provider); + +- g_main_loop_quit (gpsd->loop); ++ g_main_loop_quit(gpsd->loop); + } + +-static void +-geoclue_gpsd_set_status (GeoclueGpsd *self, GeoclueStatus status) ++static void geoclue_gpsd_set_status(GeoclueGpsd * self, GeoclueStatus status) + { + if (status != self->last_status) { + self->last_status = status; +@@ -142,32 +133,25 @@ + self->last_velo_fields = GEOCLUE_VELOCITY_FIELDS_NONE; + } + g_debug("status changed [%d]", status); +- gc_iface_geoclue_emit_status_changed (GC_IFACE_GEOCLUE (self), +- status); ++ gc_iface_geoclue_emit_status_changed(GC_IFACE_GEOCLUE(self), status); + } + } + +-static gboolean +-set_options (GcIfaceGeoclue *gc, +- GHashTable *options, +- GError **error) ++static gboolean set_options(GcIfaceGeoclue * gc, GHashTable * options, GError ** error) + { +- GeoclueGpsd *gpsd = GEOCLUE_GPSD (gc); ++ GeoclueGpsd *gpsd = GEOCLUE_GPSD(gc); + char *port, *host; + gboolean changed = FALSE; + +- host = g_hash_table_lookup (options, +- "org.freedesktop.Geoclue.GPSHost"); +- port = g_hash_table_lookup (options, +- "org.freedesktop.Geoclue.GPSPort"); ++ host = g_hash_table_lookup(options, "org.freedesktop.Geoclue.GPSHost"); ++ port = g_hash_table_lookup(options, "org.freedesktop.Geoclue.GPSPort"); + + if (port == NULL) { + port = DEFAULT_GPSD_PORT; + } + + /* new values? */ +- if (g_strcmp0 (host, gpsd->host) != 0 || +- g_strcmp0 (port, gpsd->port) != 0) { ++ if (g_strcmp0(host, gpsd->host) != 0 || g_strcmp0(port, gpsd->port) != 0) { + changed = TRUE; + } + +@@ -176,47 +160,44 @@ + } + + /* update private values with new ones, restart gpsd */ +- g_free (gpsd->port); ++ g_free(gpsd->port); + gpsd->port = NULL; +- g_free (gpsd->host); ++ g_free(gpsd->host); + gpsd->host = NULL; + +- geoclue_gpsd_stop_gpsd (gpsd); ++ geoclue_gpsd_stop_gpsd(gpsd); + + if (host == NULL) { + return TRUE; + } + +- gpsd->port = g_strdup (port); +- gpsd->host = g_strdup (host); +- if (!geoclue_gpsd_start_gpsd (gpsd)) { +- geoclue_gpsd_set_status (gpsd, GEOCLUE_STATUS_ERROR); +- g_set_error (error, GEOCLUE_ERROR, +- GEOCLUE_ERROR_FAILED, "Gpsd not found"); ++ gpsd->port = g_strdup(port); ++ gpsd->host = g_strdup(host); ++ if (!geoclue_gpsd_start_gpsd(gpsd)) { ++ geoclue_gpsd_set_status(gpsd, GEOCLUE_STATUS_ERROR); ++ g_set_error(error, GEOCLUE_ERROR, GEOCLUE_ERROR_FAILED, "Gpsd not found"); + return FALSE; + } + return TRUE; + } + +-static void +-finalize (GObject *object) ++static void finalize(GObject * object) + { +- GeoclueGpsd *gpsd = GEOCLUE_GPSD (object); ++ GeoclueGpsd *gpsd = GEOCLUE_GPSD(object); + +- geoclue_gpsd_stop_gpsd (gpsd); +- g_free (gpsd->last_fix); +- geoclue_accuracy_free (gpsd->last_accuracy); ++ geoclue_gpsd_stop_gpsd(gpsd); ++ g_free(gpsd->last_fix); ++ geoclue_accuracy_free(gpsd->last_accuracy); + +- g_free (gpsd->port); ++ g_free(gpsd->port); + if (gpsd->host) { +- g_free (gpsd->host); ++ g_free(gpsd->host); + } + +- ((GObjectClass *) geoclue_gpsd_parent_class)->finalize (object); ++ ((GObjectClass *) geoclue_gpsd_parent_class)->finalize(object); + } + +-static void +-geoclue_gpsd_class_init (GeoclueGpsdClass *klass) ++static void geoclue_gpsd_class_init(GeoclueGpsdClass * klass) + { + GObjectClass *o_class = (GObjectClass *) klass; + GcProviderClass *p_class = (GcProviderClass *) klass; +@@ -228,75 +209,20 @@ + p_class->shutdown = shutdown; + } + +- +-static gboolean +-equal_or_nan (double a, double b) ++static gboolean equal_or_nan(double a, double b) + { +- if (isnan (a) && isnan (b)) { ++ if (isnan(a) && isnan(b)) { + return TRUE; + } + return a == b; + } + +-static void +-geoclue_gpsd_position_i2a(char *position, int lat, int lon) +-{ +- g_debug("geoclue_xps_position_i2a Lat : %d, Long : %d", lat, lon); +- char latitude[POSITION_LENGTH/2 + 1] = { 0, }; +- char longitude[POSITION_LENGTH/2 + 1] = { 0, }; +- +- if (lat < 0) { +- snprintf(latitude, POSITION_LENGTH/2 + 1, "S%07d", abs(lat)); +- } else { +- snprintf(latitude, POSITION_LENGTH/2 + 1, "N%07d", lat); +- } +- +- if (lon < 0) { +- snprintf(longitude, POSITION_LENGTH/2 + 1, "W%07d", abs(lon)); +- } else { +- snprintf(longitude, POSITION_LENGTH/2 + 1, "E%07d", lon); +- } +- +- strncpy(position, latitude, POSITION_LENGTH/2); +- strncat(position, longitude, POSITION_LENGTH/2); +- g_debug("i_to_a position : %s", position); +-} +- +-static void +-geoclue_gpsd_position_a2i(char *position, int *lat, int *lon) +-{ +- g_debug("geoclue_xps_position_a2i position : %s", position); +- char *d_lat, *d_lon; +- +- char latitude[POSITION_LENGTH/2]; +- char longitude[POSITION_LENGTH/2]; +- memcpy(latitude, position + 1, POSITION_LENGTH/2 - 1); +- memcpy(longitude, position + POSITION_LENGTH/2 + 1, POSITION_LENGTH/2 - 1); +- latitude[POSITION_LENGTH/2 - 1] = '\0'; +- longitude[POSITION_LENGTH/2 - 1] = '\0'; +- d_lat = position; +- d_lon = position + POSITION_LENGTH/2; +- +- *lat = atoi(latitude); +- *lon = atoi(longitude); +- +- if (*d_lat == 'S') { +- *lat = *lat * -1; +- } +- if (*d_lon == 'W') { +- *lon = *lon * -1; +- } +- g_debug("a_to_i Lat : %d, Long : %d", *lat, *lon); +-} +- +-double +-deg2rad(double deg) ++double deg2rad(double deg) + { + return (deg * M_PI / 180); + } + +-static int +-geoclue_gpsd_distance_to_last_position(GeoclueGpsd * gpsd, const gps_fix * last_fix) ++static int geoclue_gpsd_distance_to_last_position(GeoclueGpsd * gpsd, const gps_fix * last_fix) + { + double delta_lat, delta_long; + double dist; +@@ -319,164 +245,153 @@ + } + } + +-static void +-geoclue_gpsd_get_last_position(GeoclueGpsd * gpsd) ++static void geoclue_gpsd_get_last_position(GeoclueGpsd * gpsd) + { +- int lat, lon, acc; +- char position[POSITION_LENGTH + 1] = { 0, }; +- +- snprintf(position, POSITION_LENGTH + 1, "%s", setting_get_string(LAST_POSITION)); +- geoclue_gpsd_position_a2i(position, &lat, &lon); +- acc = setting_get_int(LAST_ACCURACY); +- +- gpsd->last_position.timestamp = setting_get_int(LAST_TIMESTAMP); +- gpsd->last_position.latitude = lat * (1.0 / LAST_POS_PRECESION); +- gpsd->last_position.longitude = lon * (1.0 / LAST_POS_PRECESION); +- gpsd->last_position.accuracy = acc * (1.0 / LAST_POS_PRECESION); +- g_debug("get Last Latitude = %f Longitude = %f Accuracy = %f", +- gpsd->last_position.latitude, gpsd->last_position.longitude, +- gpsd->last_position.accuracy); ++ setting_get_int(LAST_GPS_TIMESTAMP, &gpsd->last_position.timestamp); ++ setting_get_double(LAST_GPS_LATITUDE, &gpsd->last_position.latitude); ++ setting_get_double(LAST_GPS_LATITUDE, &gpsd->last_position.longitude); ++ setting_get_double(LAST_GPS_LONGITUDE, &gpsd->last_position.altitude); ++ setting_get_double(LAST_GPS_HOR_ACCURACY, &gpsd->last_position.hor_accuracy); ++ setting_get_double(LAST_GPS_VER_ACCURACY, &gpsd->last_position.ver_accuracy); ++ g_debug ++ ("get Last Latitude = %f Longitude = %f Altitude = %f H_Accuracy = %f V_Accuracy = %f", ++ gpsd->last_position.latitude, gpsd->last_position.longitude, ++ gpsd->last_position.altitude, gpsd->last_position.hor_accuracy, gpsd->last_position.ver_accuracy); ++} ++ ++static void geoclue_gpsd_set_last_position(GeoclueGpsd * gpsd) ++{ ++ g_debug ++ ("set GPSD Last Latitude = %d Longitude = %d Altitude = %d H_Accuracy = %d V_Accuracy = %f", ++ gpsd->last_position.latitude, gpsd->last_position.longitude, ++ gpsd->last_position.altitude, gpsd->last_position.hor_accuracy, gpsd->last_position.ver_accuracy); ++ setting_set_int(LAST_GPS_TIMESTAMP, gpsd->last_position.timestamp); ++ setting_set_double(LAST_GPS_LATITUDE, gpsd->last_position.latitude); ++ setting_set_double(LAST_GPS_LONGITUDE, gpsd->last_position.longitude); ++ setting_set_double(LAST_GPS_ALTITUDE, gpsd->last_position.altitude); ++ setting_set_double(LAST_GPS_HOR_ACCURACY, gpsd->last_position.hor_accuracy); ++ setting_set_double(LAST_GPS_VER_ACCURACY, gpsd->last_position.ver_accuracy); ++ ++ setting_set_int(LAST_WPS_TIMESTAMP, gpsd->last_position.timestamp); ++ setting_set_double(LAST_WPS_LATITUDE, gpsd->last_position.latitude); ++ setting_set_double(LAST_WPS_LONGITUDE, gpsd->last_position.longitude); ++ setting_set_double(LAST_WPS_ALTITUDE, gpsd->last_position.altitude); ++ setting_set_double(LAST_WPS_HOR_ACCURACY, gpsd->last_position.hor_accuracy); ++ setting_set_double(LAST_WPS_VER_ACCURACY, gpsd->last_position.ver_accuracy); + } + +-static void +-geoclue_gpsd_set_last_position(GeoclueGpsd * gpsd) ++static void geoclue_gpsd_update_last_position(GeoclueGpsd * gpsd, const const gps_fix * last_fix) + { +- int lat, lon, acc; +- char position[POSITION_LENGTH + 1] = { 0, }; +- +- lat = gpsd->last_position.latitude * LAST_POS_PRECESION; +- lon = gpsd->last_position.longitude * LAST_POS_PRECESION; +- acc = gpsd->last_position.accuracy * LAST_POS_PRECESION; +- g_debug("set GPSD Last Latitude = %d Longitude = %d Accuracy = %d", lat, lon, acc); +- geoclue_gpsd_position_i2a(position, lat, lon); +- +- setting_set_int(LAST_TIMESTAMP, gpsd->last_position.timestamp); +- setting_set_string(LAST_POSITION, position); +- setting_set_int(LAST_ACCURACY, acc); +-} +- +-static void +-geoclue_gpsd_update_last_position(GeoclueGpsd * gpsd, const const gps_fix * last_fix, +- int accuracy) +-{ +- g_debug("geoclue_xps_update_last_position"); ++ g_debug("geoclue_gpsd_update_last_position"); + gpsd->last_position.timestamp = last_fix->time + 0.5; + gpsd->last_position.latitude = last_fix->latitude; + gpsd->last_position.longitude = last_fix->longitude; +- gpsd->last_position.accuracy = accuracy; ++ gpsd->last_position.altitude = last_fix->altitude; ++ gpsd->last_position.hor_accuracy = sqrt(pow(last_fix->epx, 2) + pow(last_fix->epy, 2)); ++ gpsd->last_position.ver_accuracy = last_fix->epv; ++ + geoclue_gpsd_set_last_position(gpsd); + } + +-static void +-geoclue_gpsd_update_position (GeoclueGpsd *gpsd) ++static void geoclue_gpsd_update_position(GeoclueGpsd * gpsd) + { +- if(gpsd->last_status != GEOCLUE_STATUS_AVAILABLE) ++ if (gpsd->last_status != GEOCLUE_STATUS_AVAILABLE) + return; + + gps_fix *fix = &gpsd->gpsdata->fix; + gps_fix *last_fix = gpsd->last_fix; + +- if (isnan(fix->time)==0){ ++ if (isnan(fix->time) == 0) { + last_fix->time = fix->time; +- } +- if (equal_or_nan (fix->latitude, last_fix->latitude) && +- equal_or_nan (fix->longitude, last_fix->longitude) && +- equal_or_nan (fix->altitude, last_fix->altitude)) { ++ } ++ if (equal_or_nan(fix->latitude, last_fix->latitude) && equal_or_nan(fix->longitude, last_fix->longitude) ++ && equal_or_nan(fix->altitude, last_fix->altitude)) { + return; + } + /* save values */ +- if (fix->mode >= MODE_2D && isnan(fix->latitude)==0) { ++ if (fix->mode >= MODE_2D && isnan(fix->latitude) == 0) { + last_fix->latitude = fix->latitude; + } +- if (fix->mode >= MODE_2D && isnan(fix->longitude)==0) { ++ if (fix->mode >= MODE_2D && isnan(fix->longitude) == 0) { + last_fix->longitude = fix->longitude; + } +- if (fix->mode == MODE_3D && isnan(fix->altitude)==0){ ++ if (fix->mode == MODE_3D && isnan(fix->altitude) == 0) { + last_fix->altitude = fix->altitude; + } + +- if (isnan(fix->epx)==0){ ++ if (isnan(fix->epx) == 0) { + last_fix->epx = fix->epx; + } +- if (isnan(fix->epy)==0){ ++ if (isnan(fix->epy) == 0) { + last_fix->epy = fix->epy; + } +- if (isnan(fix->epv)==0){ ++ if (isnan(fix->epv) == 0) { + last_fix->epv = fix->epv; + } +- geoclue_accuracy_set_details (gpsd->last_accuracy, +- GEOCLUE_ACCURACY_LEVEL_DETAILED, +- sqrt(pow(last_fix->epx, 2)+pow(last_fix->epy, 2)), fix->epv); ++ geoclue_accuracy_set_details(gpsd->last_accuracy, ++ GEOCLUE_ACCURACY_LEVEL_DETAILED, ++ sqrt(pow(last_fix->epx, 2) + pow(last_fix->epy, 2)), fix->epv); + gpsd->last_pos_fields = GEOCLUE_POSITION_FIELDS_NONE; +- gpsd->last_pos_fields |= (isnan (fix->latitude)) ? +- 0 : GEOCLUE_POSITION_FIELDS_LATITUDE; +- gpsd->last_pos_fields |= (isnan (fix->longitude)) ? +- 0 : GEOCLUE_POSITION_FIELDS_LONGITUDE; +- gpsd->last_pos_fields |= (isnan (fix->altitude)) ? +- 0 : GEOCLUE_POSITION_FIELDS_ALTITUDE; ++ gpsd->last_pos_fields |= (isnan(fix->latitude)) ? 0 : GEOCLUE_POSITION_FIELDS_LATITUDE; ++ gpsd->last_pos_fields |= (isnan(fix->longitude)) ? 0 : GEOCLUE_POSITION_FIELDS_LONGITUDE; ++ gpsd->last_pos_fields |= (isnan(fix->altitude)) ? 0 : GEOCLUE_POSITION_FIELDS_ALTITUDE; + + if (geoclue_gpsd_distance_to_last_position(gpsd, last_fix) == 0) { +- geoclue_gpsd_update_last_position(gpsd, last_fix, +- (int)floor(sqrt(pow(last_fix->epx, 2) + pow(last_fix->epy, 2)))); ++ geoclue_gpsd_update_last_position(gpsd, last_fix); + } else { + g_debug("Last position is not updated"); + } + +- g_debug("Update position: %lf, %lf, %lf, fields:0x%x, Accuracy level: %d, vert:%lf hori:%lf", +- last_fix->latitude, last_fix->longitude, last_fix->altitude, gpsd->last_pos_fields, +- GEOCLUE_ACCURACY_LEVEL_DETAILED, sqrt(pow(last_fix->epx, 2)+pow(last_fix->epy, 2)), fix->epv); +- gc_iface_position_emit_position_changed +- (GC_IFACE_POSITION (gpsd), gpsd->last_pos_fields, +- (int)(last_fix->time+0.5), +- last_fix->latitude, last_fix->longitude, last_fix->altitude, +- gpsd->last_accuracy); ++ g_debug ++ ("Update position: %lf, %lf, %lf, fields:0x%x, Accuracy level: %d, hori:%lf vert:%lf", ++ last_fix->latitude, last_fix->longitude, last_fix->altitude, ++ gpsd->last_pos_fields, GEOCLUE_ACCURACY_LEVEL_DETAILED, ++ sqrt(pow(last_fix->epx, 2) + pow(last_fix->epy, 2)), fix->epv); ++ gc_iface_position_emit_position_changed(GC_IFACE_POSITION(gpsd), ++ gpsd->last_pos_fields, ++ (int)(last_fix->time + 0.5), ++ last_fix->latitude, ++ last_fix->longitude, last_fix->altitude, gpsd->last_accuracy); + + } + +-static void +-geoclue_gpsd_update_velocity (GeoclueGpsd *gpsd) ++static void geoclue_gpsd_update_velocity(GeoclueGpsd * gpsd) + { +- if(gpsd->last_status != GEOCLUE_STATUS_AVAILABLE) ++ if (gpsd->last_status != GEOCLUE_STATUS_AVAILABLE) + return; + + gps_fix *fix = &gpsd->gpsdata->fix; + gps_fix *last_fix = gpsd->last_fix; + +- if (isnan(fix->time)==0){ ++ if (isnan(fix->time) == 0) { + last_fix->time = fix->time; +- } +- if (equal_or_nan (fix->track, last_fix->track) && +- equal_or_nan (fix->speed, last_fix->speed) && +- equal_or_nan (fix->climb, last_fix->climb)) { ++ } ++ if (equal_or_nan(fix->track, last_fix->track) && equal_or_nan(fix->speed, last_fix->speed) ++ && equal_or_nan(fix->climb, last_fix->climb)) { + return; + } +- if (fix->mode >= MODE_2D && isnan(fix->track)==0){ ++ if (fix->mode >= MODE_2D && isnan(fix->track) == 0) { + last_fix->track = fix->track; + } +- if (fix->mode >= MODE_2D && isnan(fix->speed)==0){ ++ if (fix->mode >= MODE_2D && isnan(fix->speed) == 0) { + last_fix->speed = fix->speed; + } +- if (fix->mode >= MODE_3D && isnan(fix->climb)==0){ ++ if (fix->mode >= MODE_3D && isnan(fix->climb) == 0) { + last_fix->climb = fix->climb; + } + + g_debug("Update velocity: %lf, %lf, %lf", last_fix->track, last_fix->speed, last_fix->climb); + gpsd->last_velo_fields = GEOCLUE_VELOCITY_FIELDS_NONE; +- gpsd->last_velo_fields |= (isnan (last_fix->track)) ? +- 0 : GEOCLUE_VELOCITY_FIELDS_DIRECTION; +- gpsd->last_velo_fields |= (isnan (last_fix->speed)) ? +- 0 : GEOCLUE_VELOCITY_FIELDS_SPEED; +- gpsd->last_velo_fields |= (isnan (last_fix->climb)) ? +- 0 : GEOCLUE_VELOCITY_FIELDS_CLIMB; ++ gpsd->last_velo_fields |= (isnan(last_fix->track)) ? 0 : GEOCLUE_VELOCITY_FIELDS_DIRECTION; ++ gpsd->last_velo_fields |= (isnan(last_fix->speed)) ? 0 : GEOCLUE_VELOCITY_FIELDS_SPEED; ++ gpsd->last_velo_fields |= (isnan(last_fix->climb)) ? 0 : GEOCLUE_VELOCITY_FIELDS_CLIMB; + + gc_iface_velocity_emit_velocity_changed +- (GC_IFACE_VELOCITY (gpsd), gpsd->last_velo_fields, +- (int)(last_fix->time+0.5), +- last_fix->speed, last_fix->track, last_fix->climb); ++ (GC_IFACE_VELOCITY(gpsd), gpsd->last_velo_fields, ++ (int)(last_fix->time + 0.5), last_fix->speed, last_fix->track, last_fix->climb); + } + +-static void +-geoclue_gpsd_update_status (GeoclueGpsd *gpsd) ++static void geoclue_gpsd_update_status(GeoclueGpsd * gpsd) + { + GeoclueStatus status; + +@@ -495,50 +410,46 @@ + return; + } + +- geoclue_gpsd_set_status (gpsd, status); ++ geoclue_gpsd_set_status(gpsd, status); + } + +-static void +-gpsd_raw_hook (gps_data *gpsdata, char *message, size_t len) ++static void gpsd_raw_hook(gps_data * gpsdata, char *message, size_t len) + { +- if(gpsdata == NULL) ++ if (gpsdata == NULL) + return; + +- geoclue_gpsd_update_status (gpsd); +- geoclue_gpsd_update_position (gpsd); +- geoclue_gpsd_update_velocity (gpsd); ++ geoclue_gpsd_update_status(gpsd); ++ geoclue_gpsd_update_position(gpsd); ++ geoclue_gpsd_update_velocity(gpsd); + } + +-static void +-geoclue_gpsd_stop_gpsd (GeoclueGpsd *self) ++static void geoclue_gpsd_stop_gpsd(GeoclueGpsd * self) + { + if (self->gpsdata) { +- gps_close (self->gpsdata); ++ gps_close(self->gpsdata); + self->gpsdata = NULL; + } + } + +-static gboolean +-geoclue_gpsd_start_gpsd (GeoclueGpsd *self) ++static gboolean geoclue_gpsd_start_gpsd(GeoclueGpsd * self) + { +- self->gpsdata = gps_open (self->host, self->port); ++ self->gpsdata = gps_open(self->host, self->port); + if (self->gpsdata) { + gps_stream(self->gpsdata, WATCH_ENABLE | WATCH_NEWSTYLE, NULL); +- gps_set_raw_hook (self->gpsdata, gpsd_raw_hook); ++ gps_set_raw_hook(self->gpsdata, gpsd_raw_hook); + return TRUE; + } else { +- g_warning ("gps_open() failed, is gpsd running (host=%s,port=%s)?", self->host, self->port); ++ g_warning("gps_open() failed, is gpsd running (host=%s,port=%s)?", self->host, self->port); + return FALSE; + } + } + +-gboolean +-gpsd_poll(gpointer data) ++gboolean gpsd_poll(gpointer data) + { +- GeoclueGpsd *self = (GeoclueGpsd*)data; ++ GeoclueGpsd *self = (GeoclueGpsd *) data; + if (self->gpsdata) { + if (gps_poll(self->gpsdata) < 0) { +- geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ERROR); ++ geoclue_gpsd_set_status(self, GEOCLUE_STATUS_ERROR); + geoclue_gpsd_stop_gpsd(self); + return FALSE; + } +@@ -546,72 +457,60 @@ + return TRUE; + } + +-static void +-geoclue_gpsd_init (GeoclueGpsd *self) ++static void geoclue_gpsd_init(GeoclueGpsd * self) + { + self->gpsdata = NULL; +- self->last_fix = g_new0 (gps_fix, 1); ++ self->last_fix = g_new0(gps_fix, 1); + + self->last_pos_fields = GEOCLUE_POSITION_FIELDS_NONE; + self->last_velo_fields = GEOCLUE_VELOCITY_FIELDS_NONE; +- self->last_accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0, 0); ++ self->last_accuracy = geoclue_accuracy_new(GEOCLUE_ACCURACY_LEVEL_NONE, 0, 0); + +- gc_provider_set_details (GC_PROVIDER (self), +- "org.freedesktop.Geoclue.Providers.Gpsd", +- "/org/freedesktop/Geoclue/Providers/Gpsd", +- "Gpsd", "Gpsd provider"); +- +- self->port = g_strdup (DEFAULT_GPSD_PORT); +- self->host = g_strdup ("localhost"); +- +- geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ACQUIRING); +- if (!geoclue_gpsd_start_gpsd (self)) { +- geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ERROR); ++ gc_provider_set_details(GC_PROVIDER(self), ++ "org.freedesktop.Geoclue.Providers.Gpsd", ++ "/org/freedesktop/Geoclue/Providers/Gpsd", "Gpsd", "Gpsd provider"); ++ ++ self->port = g_strdup(DEFAULT_GPSD_PORT); ++ self->host = g_strdup("localhost"); ++ ++ geoclue_gpsd_set_status(self, GEOCLUE_STATUS_ACQUIRING); ++ if (!geoclue_gpsd_start_gpsd(self)) { ++ geoclue_gpsd_set_status(self, GEOCLUE_STATUS_ERROR); + } + + geoclue_gpsd_get_last_position(self); + } + + static gboolean +-get_position (GcIfacePosition *gc, +- GeocluePositionFields *fields, +- int *timestamp, +- double *latitude, +- double *longitude, +- double *altitude, +- GeoclueAccuracy **accuracy, +- GError **error) ++get_position(GcIfacePosition * gc, ++ GeocluePositionFields * fields, ++ int *timestamp, ++ double *latitude, double *longitude, double *altitude, GeoclueAccuracy ** accuracy, GError ** error) + { +- GeoclueGpsd *gpsd = GEOCLUE_GPSD (gc); ++ GeoclueGpsd *gpsd = GEOCLUE_GPSD(gc); + +- *timestamp = (int)(gpsd->last_fix->time+0.5); ++ *timestamp = (int)(gpsd->last_fix->time + 0.5); + *latitude = gpsd->last_fix->latitude; + *longitude = gpsd->last_fix->longitude; + *altitude = gpsd->last_fix->altitude; + *fields = gpsd->last_pos_fields; +- *accuracy = geoclue_accuracy_copy (gpsd->last_accuracy); ++ *accuracy = geoclue_accuracy_copy(gpsd->last_accuracy); + + return TRUE; + } + +-static void +-geoclue_gpsd_position_init (GcIfacePositionClass *iface) ++static void geoclue_gpsd_position_init(GcIfacePositionClass * iface) + { + iface->get_position = get_position; + } + + static gboolean +-get_velocity (GcIfaceVelocity *gc, +- GeoclueVelocityFields *fields, +- int *timestamp, +- double *speed, +- double *direction, +- double *climb, +- GError **error) ++get_velocity(GcIfaceVelocity * gc, ++ GeoclueVelocityFields * fields, int *timestamp, double *speed, double *direction, double *climb, GError ** error) + { +- GeoclueGpsd *gpsd = GEOCLUE_GPSD (gc); ++ GeoclueGpsd *gpsd = GEOCLUE_GPSD(gc); + +- *timestamp = (int)(gpsd->last_fix->time+0.5); ++ *timestamp = (int)(gpsd->last_fix->time + 0.5); + *speed = gpsd->last_fix->speed; + *direction = gpsd->last_fix->track; + *climb = gpsd->last_fix->climb; +@@ -620,27 +519,24 @@ + return TRUE; + } + +-static void +-geoclue_gpsd_velocity_init (GcIfaceVelocityClass *iface) ++static void geoclue_gpsd_velocity_init(GcIfaceVelocityClass * iface) + { + iface->get_velocity = get_velocity; + } + +-int +-main (int argc, +- char **argv) ++int main(int argc, char **argv) + { +- g_type_init (); ++ g_type_init(); + +- gpsd = g_object_new (GEOCLUE_TYPE_GPSD, NULL); ++ gpsd = g_object_new(GEOCLUE_TYPE_GPSD, NULL); + +- gpsd->loop = g_main_loop_new (NULL, TRUE); +- g_timeout_add(500, gpsd_poll, (gpointer)gpsd); ++ gpsd->loop = g_main_loop_new(NULL, TRUE); ++ g_timeout_add(500, gpsd_poll, (gpointer) gpsd); + +- g_main_loop_run (gpsd->loop); ++ g_main_loop_run(gpsd->loop); + +- g_main_loop_unref (gpsd->loop); +- g_object_unref (gpsd); ++ g_main_loop_unref(gpsd->loop); ++ g_object_unref(gpsd); + + return 0; + } +Index: geoclue/providers/gpsd/setting.h +=================================================================== +--- geoclue.orig/providers/gpsd/setting.h 2012-01-10 19:47:47.607095980 +0900 ++++ geoclue/providers/gpsd/setting.h 2012-01-19 23:54:05.579726360 +0900 +@@ -28,16 +28,28 @@ + #ifndef __SETTING_H__ + #define __SETTING_H__ + +-// Sync VCONFKEY_GPS_STATE +-#define VCONF_LOCATION_PATH "db/location" ++#define VCONF_LOCATION_PATH "db/location" + +-#define LOCATION_POSITION_PATH VCONF_LOCATION_PATH"/position" +-#define LAST_TIMESTAMP LOCATION_POSITION_PATH"/Timestamp" +-#define LAST_POSITION LOCATION_POSITION_PATH"/LastPosition" +-#define LAST_ACCURACY LOCATION_POSITION_PATH"/LastAccuracy" ++#define LAST_POSITION_PATH VCONF_LOCATION_PATH"/lastposition" ++#define METHOD_GPS LAST_POSITION_PATH"/gps" ++#define METHOD_WPS LAST_POSITION_PATH"/wps" + +-int setting_get_int(const char* path); +-int setting_set_int(const char* path, int val); +-char* setting_get_string(const char* path); +-int setting_set_string(const char* path, const char* val); ++#define LAST_GPS_TIMESTAMP METHOD_GPS"/Timestamp" ++#define LAST_GPS_LATITUDE METHOD_GPS"/Latitude" ++#define LAST_GPS_LONGITUDE METHOD_GPS"/Longitude" ++#define LAST_GPS_ALTITUDE METHOD_GPS"/Altitude" ++#define LAST_GPS_HOR_ACCURACY METHOD_GPS"/HorAccuracy" ++#define LAST_GPS_VER_ACCURACY METHOD_GPS"/VerAccuracy" ++ ++#define LAST_WPS_TIMESTAMP METHOD_WPS"/Timestamp" ++#define LAST_WPS_LATITUDE METHOD_WPS"/Latitude" ++#define LAST_WPS_LONGITUDE METHOD_WPS"/Longitude" ++#define LAST_WPS_ALTITUDE METHOD_WPS"/Altitude" ++#define LAST_WPS_HOR_ACCURACY METHOD_WPS"/HorAccuracy" ++#define LAST_WPS_VER_ACCURACY METHOD_WPS"/VerAccuracy" ++ ++int setting_get_int(const char *path, int *val); ++int setting_set_int(const char *path, int val); ++int setting_get_double(const char *path, double *val); ++int setting_set_double(const char *path, double val); + #endif diff --git a/debian/patches/geoclue_0.12.0-22slp2.patch b/debian/patches/geoclue_0.12.0-22slp2.patch new file mode 100644 index 0000000..3036589 --- /dev/null +++ b/debian/patches/geoclue_0.12.0-22slp2.patch @@ -0,0 +1,76 @@ +Index: geoclue/configure.ac +=================================================================== +--- geoclue.orig/configure.ac 2012-02-10 18:07:59.405431953 +0900 ++++ geoclue/configure.ac 2012-02-10 18:08:34.217431419 +0900 +@@ -145,28 +145,6 @@ + + PROVIDER_SUBDIRS="nominatim" + +-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, [vconf 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_SUBST(PROVIDER_SUBDIRS) + AC_SUBST(NO_BUILD_PROVIDERS) + +Index: geoclue/packaging/geoclue.spec +=================================================================== +--- geoclue.orig/packaging/geoclue.spec 2012-02-10 18:07:55.549432010 +0900 ++++ geoclue/packaging/geoclue.spec 2012-02-10 18:08:26.249431541 +0900 +@@ -10,7 +10,6 @@ + BuildRequires: pkgconfig(dbus-glib-1) + BuildRequires: pkgconfig(libxml-2.0) + BuildRequires: pkgconfig(gconf-2.0) +-BuildRequires: pkgconfig(libgps) + BuildRequires: pkgconfig(libxslt) + + +@@ -44,18 +43,6 @@ + the recommended way to use GeoClue in the C language. + + +-%package -n geoclue-gpsd +-Summary: Position server for GeoClue (GPS) +-Group: TO_BE/FILLED +-Requires: %{name} = %{version}-%{release} +- +-%description -n geoclue-gpsd +-GeoClue provides applications access to various geographical information +-sources using a D-Bus API or a C library. +-. +-This package provides a positioning backend for GeoClue. The +-location information comes from a GPS receiver through gpsd +- + %package -n geoclue-nominatim + Summary: Geocode server for GeoClue (OpenStreetMap) + Group: TO_BE/FILLED +@@ -105,11 +92,6 @@ + #/usr/lib/libgeoclue.*a + /usr/lib/libgeoclue.so + +-%files -n geoclue-gpsd +-/usr/libexec/geoclue-gpsd +-/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Gpsd.service +-/usr/share/geoclue-providers/geoclue-gpsd.provider +- + %files -n geoclue-nominatim + /usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Nominatim.service + /usr/share/geoclue-providers/geoclue-nominatim.provider diff --git a/debian/patches/series b/debian/patches/series old mode 100755 new mode 100644 index 43feb46..9b21b49 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1,4 @@ tizen.patch geoclue_0.12.0-20slp2.patch +geoclue_0.12.0-21slp2.patch +geoclue_0.12.0-22slp2.patch diff --git a/debian/patches/tizen.patch b/debian/patches/tizen.patch old mode 100755 new mode 100644 diff --git a/debian/rules b/debian/rules index 5ed1f32..5b8d286 100755 --- a/debian/rules +++ b/debian/rules @@ -34,7 +34,7 @@ else DEB_BUILD_GNU_TYPE = endif -LDFLAGS += -Wl,-z,defs -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -Wl,--hash-style=both +LDFLAGS += -Wl,-z,defs -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -Wl,--hash-style=both %: dh $@ --with quilt diff --git a/docs/Makefile.am b/docs/Makefile.am old mode 100644 new mode 100755 diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am old mode 100644 new mode 100755 index faa535e..1d4265f --- a/docs/reference/Makefile.am +++ b/docs/reference/Makefile.am @@ -24,7 +24,7 @@ DOC_SOURCE_DIR=../../geoclue SCANGOBJ_OPTIONS= # Extra options to supply to gtkdoc-scan. -# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" +# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" SCAN_OPTIONS= # Extra options to supply to gtkdoc-mkdb. @@ -102,7 +102,7 @@ include $(top_srcdir)/gtk-doc.make # Other files to distribute # e.g. EXTRA_DIST += version.xml.in -EXTRA_DIST += +EXTRA_DIST += CLEAN_FILES = $(dbus_docs) diff --git a/docs/reference/geoclue-docs.sgml b/docs/reference/geoclue-docs.sgml old mode 100644 new mode 100755 index 52368f1..4554c85 --- a/docs/reference/geoclue-docs.sgml +++ b/docs/reference/geoclue-docs.sgml @@ -1,5 +1,5 @@ - @@ -7,7 +7,7 @@ - + C API @@ -23,7 +23,7 @@ - + D-Bus API @@ -35,5 +35,5 @@ - + diff --git a/docs/reference/geoclue.types b/docs/reference/geoclue.types old mode 100644 new mode 100755 diff --git a/docs/reference/implementing-providers.xml b/docs/reference/implementing-providers.xml old mode 100644 new mode 100755 index 1ecbb7a..38f4f9b --- a/docs/reference/implementing-providers.xml +++ b/docs/reference/implementing-providers.xml @@ -6,28 +6,28 @@
Overview - 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 + 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. The only must-have requirements for providers are: - Must implement the *Geoclue*-interface. This interface has - some generic methods and signals for getting information about the + Must implement the *Geoclue*-interface. This interface has + some generic methods and signals for getting information about the provider and its status - Must provide a service file. This is used by D-Bus to start the + Must provide a service file. This is used by D-Bus to start the service when needed. - A useful provider will also implement one, or several, other interfaces. It should + 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 + This howto will use "Position"-interface as an example. Possible interfaces are listed here: @@ -49,7 +49,7 @@ Address - Methods and signals for acquiring current address + Methods and signals for acquiring current address (e.g. country, city, street address). @@ -64,19 +64,19 @@
- +
Minimal example in C - 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 + 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. Service file Once your provider is installed, the service file allows D-Bus to start it - on demand. This is what your + on demand. This is what your org.freedesktop.Geoclue.Providers.MyExample.service.in should look like (see Makefile.am for the processing): @@ -85,13 +85,13 @@ Name=org.freedesktop.Geoclue.Providers.MyExample Exec=@libexecdir@/geoclue-my-example - + - + Provider file - Provider files describe the provider for Geoclue Master. This is still + Provider files describe the provider for Geoclue Master. This is still somewhat experimental, but a .provider-file for MyExample should look like this: @@ -112,8 +112,8 @@ Requires= Makefile.am and configure.ac - 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 + 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: @@ -142,18 +142,18 @@ $(service_DATA): $(service_in_files) Makefile @sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ - 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 + 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. - + The code - 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 + 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. @@ -184,11 +184,11 @@ G_DEFINE_TYPE (GeoclueExample, geoclue_example, GC_TYPE_PROVIDER) - Next, implement Geoclue-interface functions (take a look at gc-iface-geoclue.h) + Next, implement Geoclue-interface functions (take a look at gc-iface-geoclue.h) and use them to override GcProvider: -static gboolean +static gboolean get_status (GcIfaceGeoclue *gc, gboolean *available, GError **error) @@ -218,9 +218,9 @@ geoclue_example_class_init (GeoclueExampleClass *klass) } - 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 + 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. @@ -238,8 +238,8 @@ geoclue_example_init (GeoclueExample *example) } - 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 + 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(). @@ -252,17 +252,17 @@ 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; } @@ -282,7 +282,7 @@ dbus-send --print-reply \ Adding functionality by implementing other interfaces - Adding functionality to the (so far fairly impotent) provider is not + Adding functionality to the (so far fairly impotent) provider is not difficult. These are the steps needed to implement interface X: @@ -310,7 +310,7 @@ G_DEFINE_TYPE_WITH_CODE (GeoclueExample, geoclue_example, GC_TYPE_PROVIDER, - Next, take a look at the interface header (gc-iface-position.h). Implement + Next, take a look at the interface header (gc-iface-position.h). Implement the interface method and write some signal emission code: @@ -330,7 +330,7 @@ get_position (GcIfacePosition *gc, *accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0.0, 0.0); *latitude = 60.0; *longitude = 25.0; - + return TRUE; } @@ -340,21 +340,21 @@ 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), + + gc_iface_position_emit_position_changed + (GC_IFACE_POSITION (example), GEOCLUE_POSITION_FIELDS_LATITUDE | GEOCLUE_POSITION_FIELDS_LONGITUDE, - time (NULL), - lat, lon, 0, + time (NULL), + lat, lon, 0, accuracy); geoclue_accuracy_free (accuracy); @@ -363,21 +363,21 @@ emit_position_signal (GeoclueExample *example) } - 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. + 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. - 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 + 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. g_timeout_add (5000, (GSourceFunc)emit_position_signal, example); - + Finally, the interface method needs to be initialized to the implementation we just defined: @@ -389,7 +389,7 @@ geoclue_example_position_init (GcIfacePositionClass *iface) } - You can try your provider out by starting it and running + You can try your provider out by starting it and running "example/position-example MyExample"
diff --git a/docs/reference/using-geoclue.xml b/docs/reference/using-geoclue.xml old mode 100644 new mode 100755 index 51e7a64..f06efe1 --- a/docs/reference/using-geoclue.xml +++ b/docs/reference/using-geoclue.xml @@ -8,17 +8,17 @@ Why use Geoclue - Building context-sensitive applications is difficult. Location-sensitivy is no + 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 + location-aware applications with less work and less knowledge about the actual geoinformation sources. Main features of Geoclue are: Standardized D-Bus (and GObject) interfaces to various geographical data sources - Easy and fast to implement: Need to get data from provider XYZ? + Easy and fast to implement: Need to get data from provider XYZ? Chances are, Geoclue is the easiest way to do that... - Geoclue Master provider (experimental at the moment) makes things eaven easier: + 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. Adding new providers (data sources) is straight-forward: Even when the geoinformation @@ -30,32 +30,32 @@ Requirements - 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. + 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. - There is a GObject-based C API, but using Geoclue is possible from any programming language - with D-Bus support. + There is a GObject-based C API, but using Geoclue is possible from any programming language + with D-Bus support. Using basic Geoclue providers 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 + 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. - Clients should not assume that method calls will return instantly or that the + Clients should not assume that method calls will return instantly or that the response will contain valid data. Examples of possible problems Many geoclue providers use web services so method calls may take seconds or even time out. 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) 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 + When signals are not available, asynchronous method calls can be used in applications where UI responsiveness is important. @@ -69,8 +69,8 @@ - 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 + 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. @@ -84,7 +84,7 @@ Using the client just like a regular provider - + Master provider is fairly new and may not be as stable as the rest of Geoclue. @@ -96,31 +96,31 @@
Using basic Geoclue providers: simple example in C - There are several examples in the geoclue source, these are included here to + There are several examples in the geoclue source, these are included here to give a quick overview. - 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 + 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). #include <geoclue/geoclue-position.h> -int main() +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 + + / * call get_position. Note that unneeded output variables (here timestamp, altitude and accuracy) can be left NULL * / fields = geoclue_position_get_position (pos, NULL, &lat, &lon, NULL, @@ -131,7 +131,7 @@ int main() g_object_unref (pos); return 1; } - + if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { g_print ("According to Hostip.info we're at %.3f, %.3f.\n", @@ -140,23 +140,23 @@ int main() g_print ("Hostip does not have a valid location available.\nVisit http://www.hostip.info/ to correct this"); } g_object_unref (pos); - + return 0; } - Save as test-hostip.c and compile with + Save as test-hostip.c and compile with gcc `pkg-config --libs --cflags geoclue` -o test-hostip test-hostip.c - Here is a similarly simple example using GLib mainloop and Gypsy provider with - position-changed signals: + Here is a similarly simple example using GLib mainloop and Gypsy provider with + position-changed signals: #include <geoclue/geoclue-position.h> / * device name or bluetooth address * / -#define GPS_DEVICE_NAME "00:02:76:C5:81:BF" +#define GPS_DEVICE_NAME "00:02:76:C5:81:BF" static void position_changed (GeocluePosition *position, @@ -177,19 +177,19 @@ position_changed (GeocluePosition *position, } } -int main() +int main() { GMainLoop *loop; GHashTable *options; GeocluePosition *pos; GError *error = NULL; - + g_type_init (); - + / * Create the position object * / pos = geoclue_position_new ("org.freedesktop.Geoclue.Providers.Gypsy", "/org/freedesktop/Geoclue/Providers/Gypsy"); - + / * Set GPS device name option for Gypsy * / options = g_hash_table_new (g_str_hash, g_str_equal); g_hash_table_insert (options, "org.freedesktop.Geoclue.GPSDevice", GPS_DEVICE_NAME); @@ -201,18 +201,18 @@ int main() return 1; } g_hash_table_destroy (options); - + / * connect to signal * / g_signal_connect (G_OBJECT (pos), "position-changed", G_CALLBACK (position_changed), NULL); - + g_print ("Waiting for position change signals...\n"); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); - + g_main_loop_unref (loop); g_object_unref (pos); - + return 0; } @@ -220,7 +220,7 @@ int main()
Master provider: simple example in C - Here is the "Hello World" for Geoclue Master. It shows one of the advantages of + Here is the "Hello World" for Geoclue Master. It shows one of the advantages of using the Master provider: Even most web service providers can be used as signal emitting providers (master queries them whenever network connection changes). @@ -257,21 +257,21 @@ int main() GeocluePositionFields fields; double lat, lon; GError *error = NULL; - + g_type_init (); - + / * create a MasterClient using Master * / master = geoclue_master_get_default (); client = geoclue_master_create_client (master, NULL, &error); g_object_unref (master); - + if (!client) { g_printerr ("Error creating GeoclueMasterClient: %s\n", error->message); g_error_free (error); return 1; } - - / * Set our requirements: We want at least city level accuracy, require signals, + + / * Set our requirements: We want at least city level accuracy, require signals, and allow the use of network (but not e.g. GPS) * / if (!geoclue_master_client_set_requirements (client, GEOCLUE_ACCURACY_LEVEL_LOCALITY, @@ -282,9 +282,9 @@ int main() g_error_free (error); g_object_unref (client); return 1; - + } - + / * Get a Position object * / pos = geoclue_master_client_create_position (client, NULL); if (!pos) { @@ -292,8 +292,8 @@ int main() g_object_unref (client); return 1; } - - / * call get_position. We do not know which provider actually provides + + / * call get_position. We do not know which provider actually provides the answer (although we could find out using MasterClient API) * / fields = geoclue_position_get_position (pos, NULL, &lat, &lon, NULL, @@ -308,15 +308,15 @@ int main() g_print ("We're at %.3f, %.3f.\n", lat, lon); } } - - + + g_signal_connect (G_OBJECT (pos), "position-changed", G_CALLBACK (position_changed), NULL); - + g_print ("Waiting for position change signals...\n"); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); - + g_main_loop_unref (loop); g_object_unref (pos); g_object_unref (client); diff --git a/docs/tools/Makefile.am b/docs/tools/Makefile.am old mode 100644 new mode 100755 diff --git a/docs/tools/spec-strip-docs.xsl b/docs/tools/spec-strip-docs.xsl old mode 100644 new mode 100755 index 92e578d..1025814 --- a/docs/tools/spec-strip-docs.xsl +++ b/docs/tools/spec-strip-docs.xsl @@ -1,16 +1,16 @@ - - - - + @@ -21,7 +21,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/docs/tools/spec-to-docbook.xsl b/docs/tools/spec-to-docbook.xsl old mode 100644 new mode 100755 diff --git a/example/address-example.c b/example/address-example.c old mode 100644 new mode 100755 index 02dda17..68946fe --- a/example/address-example.c +++ b/example/address-example.c @@ -56,9 +56,9 @@ int main (int argc, char** argv) GeoclueAccuracy *accuracy = NULL; GeoclueAccuracyLevel level; GError *error = NULL; - + g_type_init(); - + if (argc < 2 || argc % 2 != 0) { g_printerr ("Usage:\n address-example [option value]\n"); return 1; @@ -66,7 +66,7 @@ int main (int argc, char** argv) 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); @@ -75,24 +75,24 @@ int main (int argc, char** argv) 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", + 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, ×tamp, - &details, &accuracy, + if (!geoclue_address_get_address (address, ×tamp, + &details, &accuracy, &error)) { g_printerr ("Error getting address: %s\n", error->message); g_error_free (error); @@ -100,14 +100,14 @@ int main (int argc, char** argv) 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; } diff --git a/example/common-example.c b/example/common-example.c old mode 100644 new mode 100755 index de90905..aec1ede --- a/example/common-example.c +++ b/example/common-example.c @@ -34,9 +34,9 @@ int main (int argc, char** argv) GeoclueStatus status; GHashTable *options; GError *error = NULL; - + g_type_init(); - + if (argc != 2) { g_printerr ("Usage:\n common-example \n"); return 1; @@ -44,8 +44,8 @@ int main (int argc, char** argv) 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); @@ -54,8 +54,8 @@ int main (int argc, char** argv) 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"); @@ -69,7 +69,7 @@ int main (int argc, char** argv) } g_hash_table_destroy (options); - if (!geoclue_provider_get_provider_info (GEOCLUE_PROVIDER (pos), + if (!geoclue_provider_get_provider_info (GEOCLUE_PROVIDER (pos), &name, &desc, &error)) { g_printerr ("Error getting provider info: %s\n\n", error->message); @@ -82,7 +82,7 @@ int main (int argc, char** argv) 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); @@ -103,8 +103,8 @@ int main (int argc, char** argv) break; } } - + g_object_unref (pos); - + return 0; } diff --git a/example/geocode-example.c b/example/geocode-example.c old mode 100644 new mode 100755 index 8366765..322a2bf --- a/example/geocode-example.c +++ b/example/geocode-example.c @@ -4,7 +4,7 @@ * * Provider options are not used in this sample. See other files for * examples on that. - * + * * Author: Jussi Kukkonen * Copyright 2007, 2008 by Garmin Ltd. or its subsidiaries * @@ -36,9 +36,9 @@ int main (int argc, char** argv) double lat, lon; GeoclueAccuracy *accuracy = NULL; GError *error = NULL; - + g_type_init(); - + if (argc < 2) { g_printerr ("Usage:\n geocode-example [\"freeform address\"]\n\n" " If freeform address is not given, a hard coded address hash " @@ -67,10 +67,10 @@ int main (int argc, char** argv) geoclue_address_details_insert (address, "countrycode", "FI"); geoclue_address_details_insert (address, "street", "Solnantie 24"); - /* Geocode. We're not interested in altitude + /* Geocode. We're not interested in altitude this time, so leave it NULL. */ - fields = geoclue_geocode_address_to_position (geocoder, address, - &lat, &lon, NULL, + fields = geoclue_geocode_address_to_position (geocoder, address, + &lat, &lon, NULL, &accuracy, &error); g_hash_table_destroy (address); } else { @@ -87,26 +87,26 @@ int main (int argc, char** argv) 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; - + } diff --git a/example/master-example.c b/example/master-example.c old mode 100644 new mode 100755 index 89b5abc..c10192f --- a/example/master-example.c +++ b/example/master-example.c @@ -23,8 +23,8 @@ */ /* This example uses geoclue master to get approximate position - * and address signals. Following params are - * given to geoclue_master_client_set_requirements(): + * 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. @@ -35,11 +35,11 @@ * 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 + * + * 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 @@ -50,9 +50,9 @@ static void provider_changed_cb (GeoclueMasterClient *client, char *name, - char *description, - char *service, - char *path, + char *description, + char *service, + char *path, gpointer userdata) { g_print ("%s provider changed: %s\n", (char *)userdata, name); @@ -88,7 +88,7 @@ init_address (GeoclueMasterClient *client) 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) { @@ -98,10 +98,10 @@ init_address (GeoclueMasterClient *client) } g_signal_connect (G_OBJECT (address), "address-changed", G_CALLBACK (address_changed_cb), NULL); - + /* print initial address */ - if (!geoclue_address_get_address (address, ×tamp, - &details, &accuracy, + if (!geoclue_address_get_address (address, ×tamp, + &details, &accuracy, &error)) { g_printerr ("Error getting address: %s\n", error->message); g_error_free (error); @@ -129,10 +129,10 @@ position_changed_cb (GeocluePosition *position, 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); @@ -149,17 +149,17 @@ init_position (GeoclueMasterClient *client) 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, @@ -169,20 +169,20 @@ init_position (GeoclueMasterClient *client) 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; } @@ -195,19 +195,19 @@ main (int argc, 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, + + if (!geoclue_master_client_set_requirements (client, GEOCLUE_ACCURACY_LEVEL_LOCALITY, 0, TRUE, @@ -217,17 +217,17 @@ main (int argc, 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; } diff --git a/example/master-pos-example.c b/example/master-pos-example.c index d5c6e67..94fa84a 100644 --- a/example/master-pos-example.c +++ b/example/master-pos-example.c @@ -25,7 +25,7 @@ */ -/* This example shows typical GPS-like usage. Following params are +/* 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 @@ -36,13 +36,13 @@ * 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 + * 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 @@ -54,7 +54,7 @@ static void provider_changed_cb (GeoclueMasterClient *client, char *iface, char *name, - char *description, + char *description, gpointer userdata) { if (strlen (name) == 0) { @@ -77,11 +77,11 @@ position_changed_cb (GeocluePosition *position, 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"); } @@ -96,19 +96,19 @@ main (int argc, 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, + if (!geoclue_master_client_set_requirements (client, GEOCLUE_ACCURACY_LEVEL_DETAILED, 0, TRUE, GEOCLUE_RESOURCE_ALL, @@ -117,7 +117,7 @@ main (int argc, g_object_unref (client); return 1; } - + position = geoclue_master_client_create_position (client, &error); if (!position) { g_warning ("Creating GeocluePosition failed: %s", error->message); @@ -125,16 +125,16 @@ main (int argc, 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; } diff --git a/example/position-async-example.c b/example/position-async-example.c old mode 100644 new mode 100755 index db637fc..50ffbcf --- a/example/position-async-example.c +++ b/example/position-async-example.c @@ -1,6 +1,6 @@ /* * Geoclue - * position-example.c - Example using the Position client API + * position-example.c - Example using the Position client API * (asynchronous method call) * * Author: Jussi Kukkonen @@ -46,7 +46,7 @@ position_callback (GeocluePosition *pos, 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); @@ -62,20 +62,20 @@ 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 "); return 1; } - + g_type_init(); mainloop = g_main_loop_new (NULL, FALSE); - + g_print ("Using provider '%s'\n", argv[1]); service = g_strdup_printf ("org.freedesktop.Geoclue.Providers.%s", argv[1]); path = g_strdup_printf ("/org/freedesktop/Geoclue/Providers/%s", argv[1]); - - + + pos = geoclue_position_new (service, path); g_free (service); g_free (path); @@ -83,15 +83,15 @@ int main (int argc, char** argv) g_printerr ("Error while creating GeocluePosition object.\n"); return 1; } - - geoclue_position_get_position_async (pos, - (GeocluePositionCallback) position_callback, + + geoclue_position_get_position_async (pos, + (GeocluePositionCallback) position_callback, mainloop); g_print ("Asynchronous call made, going to main loop now...\n"); g_main_loop_run (mainloop); - + g_main_loop_unref (mainloop); g_object_unref (pos); - + return 0; } diff --git a/example/position-example.c b/example/position-example.c index 839d169..a2b7d2e 100644 --- a/example/position-example.c +++ b/example/position-example.c @@ -37,15 +37,15 @@ position_changed_cb (GeocluePosition *position, { if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { - + GeoclueAccuracyLevel level; double horiz_acc; - + geoclue_accuracy_get_details (accuracy, &level, &horiz_acc, NULL); g_print ("Current position:\n"); g_print ("\t%f, %f\n", latitude, longitude); g_print ("\tAccuracy level %d (%.0f meters)\n", level, horiz_acc); - + } else { g_print ("Latitude and longitude not available.\n"); } @@ -76,9 +76,9 @@ int main (int argc, char** argv) GeoclueAccuracy *accuracy = NULL; GMainLoop *mainloop; GError *error = NULL; - + g_type_init(); - + if (argc < 2 || argc % 2 != 0) { g_printerr ("Usage:\n position-example [option,value]\n"); return 1; @@ -87,9 +87,9 @@ int main (int argc, char** argv) g_print ("Using provider '%s'\n", argv[1]); service = g_strdup_printf ("org.freedesktop.Geoclue.Providers.%s", argv[1]); path = g_strdup_printf ("/org/freedesktop/Geoclue/Providers/%s", argv[1]); - + mainloop = g_main_loop_new (NULL, FALSE); - + /* Create new GeocluePosition */ pos = geoclue_position_new (service, path); if (pos == NULL) { @@ -99,25 +99,25 @@ int main (int argc, char** argv) g_free (service); g_free (path); - + if (argc > 2) { GHashTable *options; options = parse_options (argc, argv); if (!geoclue_provider_set_options (GEOCLUE_PROVIDER (pos), options, &error)) { - g_printerr ("Error setting options: %s\n", + g_printerr ("Error setting options: %s\n", error->message); g_error_free (error); error = NULL; } g_hash_table_destroy (options); } - - /* Query current position. We're not interested in altitude + + /* Query current position. We're not interested in altitude this time, so leave it NULL. Same can be done with all other arguments that aren't interesting to the client */ - fields = geoclue_position_get_position (pos, ×tamp, - &lat, &lon, NULL, + fields = geoclue_position_get_position (pos, ×tamp, + &lat, &lon, NULL, &accuracy, &error); if (error) { g_printerr ("Error getting position: %s\n", error->message); @@ -125,19 +125,19 @@ int main (int argc, char** argv) g_object_unref (pos); return 1; } - + /* Print out coordinates if they are valid */ if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { - + GeoclueAccuracyLevel level; double horiz_acc; - + geoclue_accuracy_get_details (accuracy, &level, &horiz_acc, NULL); g_print ("Current position:\n"); g_print ("\t%f, %f\n", lat, lon); g_print ("\tAccuracy level %d (%.0f meters)\n", level, horiz_acc); - + } else { g_print ("Latitude and longitude not available.\n"); } @@ -149,5 +149,5 @@ int main (int argc, char** argv) g_main_loop_run (mainloop); return 0; - + } diff --git a/example/revgeocode-example.c b/example/revgeocode-example.c old mode 100644 new mode 100755 index 52a8ea8..2207234 --- a/example/revgeocode-example.c +++ b/example/revgeocode-example.c @@ -56,9 +56,9 @@ int main (int argc, char** argv) GHashTable *address = NULL; double lat, lon; GError *error = NULL; - + g_type_init(); - + if (argc < 4) { g_printerr ("Usage:\n revgeocode-example \n"); return 1; @@ -66,7 +66,7 @@ int main (int argc, char** argv) 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 GeoclueReverseGeocode */ revgeocoder = geoclue_reverse_geocode_new (service, path); g_free (service); @@ -80,25 +80,25 @@ int main (int argc, char** argv) /* Set options */ if (argc > 4) { GHashTable *options; - + options = parse_options (argc, argv); if (!geoclue_provider_set_options (GEOCLUE_PROVIDER (revgeocoder), options, &error)) { - g_printerr ("Error setting options: %s\n", + g_printerr ("Error setting options: %s\n", error->message); g_error_free (error); error = NULL; } g_hash_table_destroy (options); } - + address = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify)g_free, + (GDestroyNotify)g_free, (GDestroyNotify)g_free); - + lat = atof (argv[2]); lon = atof (argv[3]); accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_STREET, 0.0, 0.0); - if (!geoclue_reverse_geocode_position_to_address (revgeocoder, + if (!geoclue_reverse_geocode_position_to_address (revgeocoder, lat, lon, accuracy, &address, &out_accuracy, &error)) { g_printerr ("Error while reverse geocoding: %s\n", error->message); @@ -106,15 +106,15 @@ int main (int argc, char** argv) g_object_unref (revgeocoder); return 1; } - + /* Print out the address */ GeoclueAccuracyLevel level; geoclue_accuracy_get_details (out_accuracy, &level, NULL, NULL); g_print ("Reverse Geocoded [%f, %f] to address (accuracy %d):\n", lat, lon, level); g_hash_table_foreach (address, (GHFunc)print_address_key_and_value, NULL); - + g_hash_table_destroy (address); g_object_unref (revgeocoder); return 0; - + } diff --git a/geoclue/Makefile.am b/geoclue/Makefile.am index 6443f70..186155d 100644 --- a/geoclue/Makefile.am +++ b/geoclue/Makefile.am @@ -61,7 +61,7 @@ libgeoclue_la_CFLAGS = \ -I$(top_srcdir) \ -I$(top_builddir) \ $(GEOCLUE_CFLAGS) - + geoclue_headers = \ gc-iface-address.h \ gc-iface-geoclue.h \ diff --git a/geoclue/gc-iface-address.c b/geoclue/gc-iface-address.c old mode 100644 new mode 100755 index dc61009..2cfa018 --- a/geoclue/gc-iface-address.c +++ b/geoclue/gc-iface-address.c @@ -1,7 +1,7 @@ /* * Geoclue * gc-iface-address.c - GInterface for org.freedesktop.Address - * + * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries * @@ -36,7 +36,7 @@ enum { static guint signals[LAST_SIGNAL] = {0}; -static gboolean +static gboolean gc_iface_address_get_address (GcIfaceAddress *gc, int *timestamp, GHashTable **address, @@ -53,14 +53,14 @@ gc_iface_address_base_init (gpointer klass) return; } initialized = TRUE; - + signals[ADDRESS_CHANGED] = g_signal_new ("address-changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, geoclue_marshal_VOID__INT_POINTER_BOXED, G_TYPE_NONE, 3, - G_TYPE_INT, + G_TYPE_INT, DBUS_TYPE_G_STRING_STRING_HASHTABLE, GEOCLUE_ACCURACY_TYPE); dbus_g_object_type_install_info (gc_iface_address_get_type (), @@ -71,7 +71,7 @@ GType gc_iface_address_get_type (void) { static GType type = 0; - + if (!type) { const GTypeInfo info = { sizeof (GcIfaceAddressClass), @@ -86,14 +86,14 @@ gc_iface_address_get_type (void) return type; } -static gboolean +static gboolean gc_iface_address_get_address (GcIfaceAddress *gc, int *timestamp, GHashTable **address, GeoclueAccuracy **accuracy, GError **error) { - return GC_IFACE_ADDRESS_GET_CLASS (gc)->get_address + return GC_IFACE_ADDRESS_GET_CLASS (gc)->get_address (gc, timestamp, address, accuracy, error); } diff --git a/geoclue/gc-iface-address.h b/geoclue/gc-iface-address.h old mode 100644 new mode 100755 index 9d93513..dafcc09 --- a/geoclue/gc-iface-address.h +++ b/geoclue/gc-iface-address.h @@ -1,7 +1,7 @@ /* * Geoclue * gc-iface-address.h - GInterface for org.freedesktop.Address - * + * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries * diff --git a/geoclue/gc-iface-geoclue.c b/geoclue/gc-iface-geoclue.c old mode 100644 new mode 100755 index d202991..238f2f0 --- a/geoclue/gc-iface-geoclue.c +++ b/geoclue/gc-iface-geoclue.c @@ -1,7 +1,7 @@ /* * Geoclue * gc-iface-geoclue.c - GInterface for org.freedesktop.Geoclue - * + * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries * @@ -62,10 +62,10 @@ gc_iface_geoclue_base_init (gpointer klass) return; } initialized = TRUE; - + signals[STATUS_CHANGED] = g_signal_new ("status-changed", G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GcIfaceGeoclueClass, status_changed), NULL, NULL, g_cclosure_marshal_VOID__INT, @@ -79,7 +79,7 @@ GType gc_iface_geoclue_get_type (void) { static GType type = 0; - + if (!type) { const GTypeInfo info = { sizeof (GcIfaceGeoclueClass), @@ -100,7 +100,7 @@ gc_iface_geoclue_get_provider_info (GcIfaceGeoclue *gc, gchar **description, GError **error) { - return GC_IFACE_GEOCLUE_GET_CLASS (gc)->get_provider_info (gc, + return GC_IFACE_GEOCLUE_GET_CLASS (gc)->get_provider_info (gc, name, description, error); @@ -120,17 +120,17 @@ gc_iface_geoclue_set_options (GcIfaceGeoclue *gc, GHashTable *options, GError **error) { - return GC_IFACE_GEOCLUE_GET_CLASS (gc)->set_options (gc, options, + return GC_IFACE_GEOCLUE_GET_CLASS (gc)->set_options (gc, options, error); } -static void +static void gc_iface_geoclue_add_reference (GcIfaceGeoclue *gc, DBusGMethodInvocation *context) { GC_IFACE_GEOCLUE_GET_CLASS (gc)->add_reference (gc, context); } -static void +static void gc_iface_geoclue_remove_reference (GcIfaceGeoclue *gc, DBusGMethodInvocation *context) { diff --git a/geoclue/gc-iface-geoclue.h b/geoclue/gc-iface-geoclue.h old mode 100644 new mode 100755 index f2be57b..8b6393c --- a/geoclue/gc-iface-geoclue.h +++ b/geoclue/gc-iface-geoclue.h @@ -1,7 +1,7 @@ /* * Geoclue * gc-iface-geoclue.h - GInterface for org.freedesktop.Geoclue - * + * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries * diff --git a/geoclue/gc-iface-geocode.c b/geoclue/gc-iface-geocode.c old mode 100644 new mode 100755 index 1c87e8d..73db3b6 --- a/geoclue/gc-iface-geocode.c +++ b/geoclue/gc-iface-geocode.c @@ -1,7 +1,7 @@ /* * Geoclue * gc-iface-geocode.c - GInterface for org.freedesktop.Geocode - * + * * Authors: Iain Holmes * Jussi Kukkonen * Copyright 2007 by Garmin Ltd. or its subsidiaries @@ -33,7 +33,7 @@ #include #include -static gboolean +static gboolean gc_iface_geocode_address_to_position (GcIfaceGeocode *gc, GHashTable *address, int *fields, @@ -63,7 +63,7 @@ gc_iface_geocode_base_init (gpointer klass) return; } initialized = TRUE; - + dbus_g_object_type_install_info (gc_iface_geocode_get_type (), &dbus_glib_gc_iface_geocode_object_info); } @@ -72,7 +72,7 @@ GType gc_iface_geocode_get_type (void) { static GType type = 0; - + if (!type) { const GTypeInfo info = { sizeof (GcIfaceGeocodeClass), @@ -87,7 +87,7 @@ gc_iface_geocode_get_type (void) return type; } -static gboolean +static gboolean gc_iface_geocode_address_to_position (GcIfaceGeocode *gc, GHashTable *address, int *fields, @@ -97,7 +97,7 @@ gc_iface_geocode_address_to_position (GcIfaceGeocode *gc, GeoclueAccuracy **accuracy, GError **error) { - return GC_IFACE_GEOCODE_GET_CLASS (gc)->address_to_position + return GC_IFACE_GEOCODE_GET_CLASS (gc)->address_to_position (gc, address, (GeocluePositionFields *) fields, latitude, longitude, altitude, accuracy, error); } diff --git a/geoclue/gc-iface-geocode.h b/geoclue/gc-iface-geocode.h old mode 100644 new mode 100755 index 9b0dd85..c7bf7c7 --- a/geoclue/gc-iface-geocode.h +++ b/geoclue/gc-iface-geocode.h @@ -1,7 +1,7 @@ /* * Geoclue * gc-iface-geocode.h - GInterface for org.freedesktop.Geocode - * + * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries * diff --git a/geoclue/gc-iface-nmea.c b/geoclue/gc-iface-nmea.c index 6b72024..3a15656 100644 --- a/geoclue/gc-iface-nmea.c +++ b/geoclue/gc-iface-nmea.c @@ -2,7 +2,7 @@ * Geoclue * gc-iface-nmea.c - GInterface for org.freedesktop.Geoclue.Nmea * - * Author: Tae-Hwan Kim , Youngae Kang , + * Author: Tae-Hwan Kim , Youngae Kang , * Yunhan Kim , Genie Kim * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * @@ -35,7 +35,7 @@ enum { static guint signals[LAST_SIGNAL] = {0}; -static gboolean +static gboolean gc_iface_nmea_get_nmea (GcIfaceNmea *nmea, int *timestamp, char **nmea_data, @@ -52,7 +52,7 @@ gc_iface_nmea_base_init (gpointer klass) return; } initialized = TRUE; - + signals[NMEA_CHANGED] = g_signal_new ("nmea-changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, @@ -61,7 +61,7 @@ gc_iface_nmea_base_init (gpointer klass) G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING); - + dbus_g_object_type_install_info (gc_iface_nmea_get_type (), &dbus_glib_gc_iface_nmea_object_info); } @@ -70,7 +70,7 @@ GType gc_iface_nmea_get_type (void) { static GType type = 0; - + if (!type) { const GTypeInfo info = { sizeof (GcIfaceNmeaClass), @@ -85,7 +85,7 @@ gc_iface_nmea_get_type (void) return type; } -static gboolean +static gboolean gc_iface_nmea_get_nmea (GcIfaceNmea *gc, int *timestamp, char **nmea_data, diff --git a/geoclue/gc-iface-nmea.h b/geoclue/gc-iface-nmea.h index 6483a8f..0f5ec20 100644 --- a/geoclue/gc-iface-nmea.h +++ b/geoclue/gc-iface-nmea.h @@ -2,7 +2,7 @@ * Geoclue * gc-iface-nmea.h - GInterface for org.freedesktop.Geoclue.Nmea * - * Author: Tae-Hwan Kim , Youngae Kang , + * Author: Tae-Hwan Kim , Youngae Kang , * Yunhan Kim , Genie Kim * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * diff --git a/geoclue/gc-iface-position.c b/geoclue/gc-iface-position.c old mode 100644 new mode 100755 index da036a3..a246bbe --- a/geoclue/gc-iface-position.c +++ b/geoclue/gc-iface-position.c @@ -36,7 +36,7 @@ enum { static guint signals[LAST_SIGNAL] = {0}; -static gboolean +static gboolean gc_iface_position_get_position (GcIfacePosition *position, int *fields, int *timestamp, @@ -57,7 +57,7 @@ gc_iface_position_base_init (gpointer klass) return; } initialized = TRUE; - + signals[POSITION_CHANGED] = g_signal_new ("position-changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, @@ -70,7 +70,7 @@ gc_iface_position_base_init (gpointer klass) G_TYPE_DOUBLE, G_TYPE_DOUBLE, GEOCLUE_ACCURACY_TYPE); - + dbus_g_object_type_install_info (gc_iface_position_get_type (), &dbus_glib_gc_iface_position_object_info); } @@ -79,7 +79,7 @@ GType gc_iface_position_get_type (void) { static GType type = 0; - + if (!type) { const GTypeInfo info = { sizeof (GcIfacePositionClass), @@ -94,7 +94,7 @@ gc_iface_position_get_type (void) return type; } -static gboolean +static gboolean gc_iface_position_get_position (GcIfacePosition *gc, int *fields, int *timestamp, @@ -104,7 +104,7 @@ gc_iface_position_get_position (GcIfacePosition *gc, GeoclueAccuracy **accuracy, GError **error) { - return GC_IFACE_POSITION_GET_CLASS (gc)->get_position + return GC_IFACE_POSITION_GET_CLASS (gc)->get_position (gc, (GeocluePositionFields *) fields, timestamp, latitude, longitude, altitude, accuracy, error); } diff --git a/geoclue/gc-iface-position.h b/geoclue/gc-iface-position.h old mode 100644 new mode 100755 diff --git a/geoclue/gc-iface-reverse-geocode.c b/geoclue/gc-iface-reverse-geocode.c old mode 100644 new mode 100755 index 3435d85..517d903 --- a/geoclue/gc-iface-reverse-geocode.c +++ b/geoclue/gc-iface-reverse-geocode.c @@ -1,7 +1,7 @@ /* * Geoclue * gc-iface-reverse-geocode.c - GInterface for org.freedesktop.ReverseGeocode - * + * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries * @@ -29,7 +29,7 @@ #include #include -static gboolean +static gboolean gc_iface_reverse_geocode_position_to_address (GcIfaceReverseGeocode *gc, double latitude, double longitude, @@ -48,7 +48,7 @@ gc_iface_reverse_geocode_base_init (gpointer klass) return; } initialized = TRUE; - + dbus_g_object_type_install_info (gc_iface_reverse_geocode_get_type (), &dbus_glib_gc_iface_reverse_geocode_object_info); } @@ -57,7 +57,7 @@ GType gc_iface_reverse_geocode_get_type (void) { static GType type = 0; - + if (!type) { const GTypeInfo info = { sizeof (GcIfaceReverseGeocodeClass), @@ -72,7 +72,7 @@ gc_iface_reverse_geocode_get_type (void) return type; } -static gboolean +static gboolean gc_iface_reverse_geocode_position_to_address (GcIfaceReverseGeocode *gc, double latitude, double longitude, @@ -81,7 +81,7 @@ gc_iface_reverse_geocode_position_to_address (GcIfaceReverseGeocode *gc, GeoclueAccuracy **address_accuracy, GError **error) { - return GC_IFACE_REVERSE_GEOCODE_GET_CLASS (gc)->position_to_address - (gc, latitude, longitude, position_accuracy, + return GC_IFACE_REVERSE_GEOCODE_GET_CLASS (gc)->position_to_address + (gc, latitude, longitude, position_accuracy, address, address_accuracy, error); } diff --git a/geoclue/gc-iface-reverse-geocode.h b/geoclue/gc-iface-reverse-geocode.h old mode 100644 new mode 100755 index 90f9656..835225a --- a/geoclue/gc-iface-reverse-geocode.h +++ b/geoclue/gc-iface-reverse-geocode.h @@ -1,7 +1,7 @@ /* * Geoclue * gc-iface-reverse_geocode.h - GInterface for org.freedesktop.Reverse_Geocode - * + * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries * diff --git a/geoclue/gc-iface-satellite.c b/geoclue/gc-iface-satellite.c index b2fd4ff..de0215d 100644 --- a/geoclue/gc-iface-satellite.c +++ b/geoclue/gc-iface-satellite.c @@ -2,7 +2,7 @@ * Geoclue * gc-iface-satellite.c - GInterface for org.freedesktop.Geoclue.Satellite * - * Author: Sagnho Park , Youngae Kang , + * Author: Sagnho Park , Youngae Kang , * Yunhan Kim , Genie Kim * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * @@ -36,7 +36,7 @@ enum { static guint signals[LAST_SIGNAL] = {0}; -static gboolean +static gboolean gc_iface_satellite_get_satellite (GcIfaceSatellite *satellite, int *timestamp, int *satellite_used, @@ -56,7 +56,7 @@ gc_iface_satellite_base_init (gpointer klass) return; } initialized = TRUE; - + signals[SATELLITE_CHANGED] = g_signal_new ("satellite-changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, @@ -76,7 +76,7 @@ GType gc_iface_satellite_get_type (void) { static GType type = 0; - + if (!type) { const GTypeInfo info = { sizeof (GcIfaceSatelliteClass), @@ -91,7 +91,7 @@ gc_iface_satellite_get_type (void) return type; } -static gboolean +static gboolean gc_iface_satellite_get_satellite (GcIfaceSatellite *gc, int *timestamp, int *satellite_used, diff --git a/geoclue/gc-iface-satellite.h b/geoclue/gc-iface-satellite.h index 81a4324..e7d84b6 100644 --- a/geoclue/gc-iface-satellite.h +++ b/geoclue/gc-iface-satellite.h @@ -2,7 +2,7 @@ * Geoclue * gc-iface-satellite.c - GInterface for org.freedesktop.Geoclue.Satellite * - * Author: Sagnho Park , Youngae Kang , + * Author: Sagnho Park , Youngae Kang , * Yunhan Kim , Genie Kim * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * diff --git a/geoclue/gc-iface-velocity.c b/geoclue/gc-iface-velocity.c old mode 100644 new mode 100755 index a2ceee8..a0cac71 --- a/geoclue/gc-iface-velocity.c +++ b/geoclue/gc-iface-velocity.c @@ -35,7 +35,7 @@ enum { static guint signals[LAST_SIGNAL] = {0}; -static gboolean +static gboolean gc_iface_velocity_get_velocity (GcIfaceVelocity *velocity, int *fields, int *timestamp, @@ -55,7 +55,7 @@ gc_iface_velocity_base_init (gpointer klass) return; } initialized = TRUE; - + signals[VELOCITY_CHANGED] = g_signal_new ("velocity-changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, @@ -75,7 +75,7 @@ GType gc_iface_velocity_get_type (void) { static GType type = 0; - + if (!type) { const GTypeInfo info = { sizeof (GcIfaceVelocityClass), @@ -90,7 +90,7 @@ gc_iface_velocity_get_type (void) return type; } -static gboolean +static gboolean gc_iface_velocity_get_velocity (GcIfaceVelocity *gc, int *fields, int *timestamp, @@ -99,7 +99,7 @@ gc_iface_velocity_get_velocity (GcIfaceVelocity *gc, double *climb, GError **error) { - return GC_IFACE_VELOCITY_GET_CLASS (gc)->get_velocity + return GC_IFACE_VELOCITY_GET_CLASS (gc)->get_velocity (gc, (GeoclueVelocityFields *) fields, timestamp, speed, direction, climb, error); } diff --git a/geoclue/gc-iface-velocity.h b/geoclue/gc-iface-velocity.h old mode 100644 new mode 100755 diff --git a/geoclue/gc-provider.c b/geoclue/gc-provider.c index 0c2b2df..8330953 100644 --- a/geoclue/gc-provider.c +++ b/geoclue/gc-provider.c @@ -26,15 +26,15 @@ /** * SECTION:gc-provider * @short_description: Abstract class to derive Geoclue providers from. - * - * #GcProvider is an abstract class that all Geoclue providers should + * + * #GcProvider is an abstract class that all Geoclue providers should * derive from. It takes care of setting up the provider D-Bus service, - * and also implements #GcIfaceGeoclue interface (derived classes still + * and also implements #GcIfaceGeoclue interface (derived classes still * need to implement the functionality). - * - * Derived classes should define the #GcIfaceGeoclue methods in their + * + * Derived classes should define the #GcIfaceGeoclue methods in their * class_init() and call gc_provider_set_details() in init() - * + * */ #include @@ -52,7 +52,7 @@ typedef struct { char *name; char *description; - + GHashTable *connections; } GcProviderPrivate; @@ -79,9 +79,9 @@ static void dispose (GObject *object) { GcProviderPrivate *priv = GET_PRIVATE (object); - + g_hash_table_destroy (priv->connections); - + ((GObjectClass *) gc_provider_parent_class)->dispose (object); } @@ -92,9 +92,9 @@ gc_provider_class_init (GcProviderClass *klass) o_class->finalize = finalize; o_class->dispose = dispose; - + klass->shutdown = NULL; - + g_type_class_add_private (klass, sizeof (GcProviderPrivate)); } @@ -103,14 +103,14 @@ gc_provider_init (GcProvider *provider) { GError *error = NULL; GcProviderPrivate *priv = GET_PRIVATE (provider); - + provider->connection = dbus_g_bus_get (GEOCLUE_DBUS_BUS, &error); if (provider->connection == NULL) { g_warning ("%s was unable to create a connection to D-Bus: %s", G_OBJECT_TYPE_NAME (provider), error->message); g_error_free (error); } - + priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); } @@ -122,7 +122,7 @@ gc_provider_shutdown (GcProvider *provider) } -static gboolean +static gboolean get_provider_info (GcIfaceGeoclue *geoclue, gchar **name, gchar **description, @@ -130,14 +130,14 @@ get_provider_info (GcIfaceGeoclue *geoclue, { GcProvider *provider = GC_PROVIDER (geoclue); GcProviderPrivate *priv = GET_PRIVATE (provider); - + if (name) { *name = g_strdup (priv->name); } if (description) { *description = g_strdup (priv->description); } - + return TRUE; } @@ -169,25 +169,25 @@ set_options (GcIfaceGeoclue *geoclue, klass = GC_PROVIDER_GET_CLASS (geoclue); if (klass->set_options) { return klass->set_options (geoclue, options, error); - } + } /* It is not an error to not have a SetOptions implementation */ return TRUE; } -static gboolean +static gboolean gc_provider_remove_client (GcProvider *provider, const char *client) -{ +{ int *pcount; GcProviderPrivate *priv = GET_PRIVATE (provider); - - pcount = g_hash_table_lookup (priv->connections, client); + + pcount = g_hash_table_lookup (priv->connections, client); if (!pcount) { g_debug("Client[%s] is already removed", client); return FALSE; - } + } (*pcount)--; - g_debug("Client[%s] has reference count[%d]", client, *pcount); + g_debug("Client[%s] has reference count[%d]", client, *pcount); if (*pcount == 0) { g_debug("Reference count is zero, Now remove client[%s] in hash table", client); g_hash_table_remove (priv->connections, client); @@ -199,24 +199,24 @@ gc_provider_remove_client (GcProvider *provider, const char *client) return TRUE; } -static gboolean +static gboolean gc_provider_remove_client_by_force(GcProvider *provider, const char *client) -{ +{ int *pcount; - GcProviderPrivate *priv = GET_PRIVATE (provider); - + GcProviderPrivate *priv = GET_PRIVATE (provider); + pcount = g_hash_table_lookup (priv->connections, client); if(!pcount){ g_debug("Client(%s) is already removed", client); return FALSE; } - + (*pcount)--; - g_debug("Client(%s) has reference count[%d]. Anway, we will remove it by force!", client, *pcount); + g_debug("Client(%s) has reference count[%d]. Anway, we will remove it by force!", client, *pcount); g_hash_table_remove (priv->connections, client); if (g_hash_table_size (priv->connections) == 0) { g_debug("Hash table size is zero, Now we shutdown provider[%s]", priv->name); - gc_provider_shutdown (provider); + gc_provider_shutdown (provider); } return TRUE; } @@ -229,7 +229,7 @@ add_reference (GcIfaceGeoclue *geoclue, GcProviderPrivate *priv = GET_PRIVATE (geoclue); char *sender; int *pcount; - + /* Update the hash of open connections */ sender = dbus_g_method_get_sender (context); pcount = g_hash_table_lookup (priv->connections, sender); @@ -238,24 +238,24 @@ add_reference (GcIfaceGeoclue *geoclue, g_hash_table_insert (priv->connections, sender, pcount); } (*pcount)++; - + dbus_g_method_return (context); } -static void +static void remove_reference (GcIfaceGeoclue *geoclue, DBusGMethodInvocation *context) { GcProvider *provider = GC_PROVIDER (geoclue); char *sender; - + sender = dbus_g_method_get_sender (context); if (!gc_provider_remove_client (provider, sender)) { g_warning ("Unreffed by client that has not been referenced"); } g_free (sender); - + dbus_g_method_return (context); } @@ -294,8 +294,8 @@ gc_provider_geoclue_init (GcIfaceGeoclueClass *iface) * @description: The description of the provider * * Requests ownership of the @service name, and if that succeeds registers - * @provider at @path. @name should be the name of the provider (e.g. - * "Hostip"), @description should be a short description of the provider + * @provider at @path. @name should be the name of the provider (e.g. + * "Hostip"), @description should be a short description of the provider * (e.g. "Web service based Position & Address provider (http://hostip.info)"). */ void @@ -322,23 +322,23 @@ gc_provider_set_details (GcProvider *provider, if (!org_freedesktop_DBus_request_name (driver, service, 0, &request_ret, &error)) { - g_warning ("%s was unable to register service %s: %s", - G_OBJECT_TYPE_NAME (provider), service, + g_warning ("%s was unable to register service %s: %s", + G_OBJECT_TYPE_NAME (provider), service, error->message); g_error_free (error); return; } - + dbus_g_proxy_add_signal (driver, "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_connect_signal (driver, "NameOwnerChanged", G_CALLBACK (name_owner_changed), provider, NULL); - - dbus_g_connection_register_g_object (provider->connection, + + dbus_g_connection_register_g_object (provider->connection, path, G_OBJECT (provider)); - + priv->name = g_strdup (name); priv->description = g_strdup (description); } diff --git a/geoclue/gc-provider.h b/geoclue/gc-provider.h old mode 100644 new mode 100755 index 84bb1ce..e7484b0 --- a/geoclue/gc-provider.h +++ b/geoclue/gc-provider.h @@ -43,15 +43,15 @@ G_BEGIN_DECLS typedef struct _GcProvider { GObject parent_class; - + DBusGConnection *connection; } GcProvider; typedef struct _GcProviderClass { GObjectClass parent_class; - + void (*shutdown) (GcProvider *provider); - + /* Implements the GcIfaceGeoclue interface */ gboolean (*get_status) (GcIfaceGeoclue *geoclue, GeoclueStatus *status, diff --git a/geoclue/gc-web-service.c b/geoclue/gc-web-service.c index 430bd63..eee8f1f 100644 --- a/geoclue/gc-web-service.c +++ b/geoclue/gc-web-service.c @@ -3,7 +3,7 @@ * gc-web-service.c - A web service helper object for geoclue providers * * Author: Jussi Kukkonen - * + * * Copyright 2007 Jussi Kukkonen (from old geoclue_web_service.c) * Copyright 2007, 2008 by Garmin Ltd. or its subsidiaries * @@ -28,50 +28,50 @@ * SECTION:gc-web-service * @short_description: Web service helper object for Geoclue providers. * - * #GcWebService is a web service abstraction for Geoclue provider - * implementations. It handles basic http stuff and xml parsing - * (although the raw data is available through + * #GcWebService is a web service abstraction for Geoclue provider + * implementations. It handles basic http stuff and xml parsing + * (although the raw data is available through * gc_web_service_get_response() as well). - * - * At the moment xml parsing functions only exist for double and + * + * At the moment xml parsing functions only exist for double and * char-array data types. Adding new functions is trivial, though. * * * . . . - * + * * #GcWebService *web_service; * web_service = g_object_new (GC_TYPE_WEB_SERVICE, NULL); * gc_web_service_set_base_url (web_service, "http://example.org"); - * - * / * Add namespaces if needed * / + * + * / * Add namespaces if needed * / * gc_web_service_add_namespace (web_service, * "ns_name", "http://example.org/ns"); - * + * * . . . - * + * * / * Fetch document "http://api.example.org?key1=val1&key2=val2" * / - * if (!gc_web_service_query (web_service, + * if (!gc_web_service_query (web_service, * "key1", "val1" * "key2", val2" * (char *)0)) { * / * error * / * return; * } - * + * * / * Use XPath expressions to parse the xml in fetched document * / * gchar *str; * if (gc_web_service_get_string (web_service, * &str, "//path/to/element")) { * g_debug("got string: %s", str); * } - * + * * gdouble number; * if (gc_web_service_get_double (web_service, * &number, "//path/to/another/element")) { * g_debug("got double: %f", number); * } - * - * . . . + * + * . . . * * g_object_unref (G_OBJECT (web_service)); * @@ -101,8 +101,8 @@ gc_web_service_register_ns (gpointer data, gpointer user_data) { GcWebService *self = (GcWebService *)user_data; XmlNamespace *ns = (XmlNamespace *)data; - - xmlXPathRegisterNs (self->xpath_ctx, + + xmlXPathRegisterNs (self->xpath_ctx, (xmlChar*)ns->name, (xmlChar*)ns->uri); } @@ -111,7 +111,7 @@ static void gc_web_service_free_ns (gpointer data, gpointer user_data) { XmlNamespace *ns = (XmlNamespace *)data; - + g_free (ns->name); g_free (ns->uri); g_free (ns); @@ -132,7 +132,7 @@ gc_web_service_reset (GcWebService *self) g_free (self->response); self->response = NULL; self->response_length = 0; - + if (self->xpath_ctx) { if (self->xpath_ctx->doc) { xmlFreeDoc (self->xpath_ctx->doc); @@ -142,19 +142,19 @@ gc_web_service_reset (GcWebService *self) } } -/* Parse data (self->response), build xpath context and register +/* Parse data (self->response), build xpath context and register * namespaces. Nothing will be done if xpath context exists already. */ static gboolean gc_web_service_build_xpath_context (GcWebService *self) { xmlDocPtr doc; xmlChar *tmp; - + /* don't rebuild if there's no need */ if (self->xpath_ctx) { return TRUE; } - + /* make sure response is NULL-terminated */ tmp = xmlStrndup(self->response, self->response_length); doc = xmlParseDoc (tmp); @@ -164,7 +164,7 @@ gc_web_service_build_xpath_context (GcWebService *self) return FALSE; } xmlFree (tmp); - + self->xpath_ctx = xmlXPathNewContext(doc); if (!self->xpath_ctx) { /* TODO: error handling */ @@ -182,39 +182,39 @@ gc_web_service_fetch (GcWebService *self, gchar *url, GError **error) gint len; xmlChar buf[1024]; xmlBuffer *output; - + g_assert (url); - + gc_web_service_reset (self); - + xmlNanoHTTPInit(); ctxt = xmlNanoHTTPMethod (url, "GET", NULL, NULL, NULL, 0); if (!ctxt) { - *error = g_error_new (GEOCLUE_ERROR, + *error = g_error_new (GEOCLUE_ERROR, GEOCLUE_ERROR_NOT_AVAILABLE, g_strdup_printf ("xmlNanoHTTPMethod did not get a response from %s\n", url)); return FALSE; } - + output = xmlBufferCreate (); while ((len = xmlNanoHTTPRead (ctxt, buf, sizeof(buf))) > 0) { if (xmlBufferAdd (output, buf, len) != 0) { xmlNanoHTTPClose(ctxt); xmlBufferFree (output); - - *error = g_error_new (GEOCLUE_ERROR, + + *error = g_error_new (GEOCLUE_ERROR, GEOCLUE_ERROR_FAILED, g_strdup_printf ("libxml error (xmlBufferAdd failed)")); - + return FALSE; } } xmlNanoHTTPClose(ctxt); - + self->response_length = xmlBufferLength (output); self->response = g_memdup (xmlBufferContent (output), self->response_length); xmlBufferFree (output); - + return TRUE; } @@ -222,17 +222,17 @@ static xmlXPathObject* gc_web_service_get_xpath_object (GcWebService *self, gchar* xpath) { xmlXPathObject *obj = NULL; - + g_return_val_if_fail (xpath, FALSE); - + /* parse the doc if not parsed yet and register namespaces */ if (!gc_web_service_build_xpath_context (self)) { return FALSE; } g_assert (self->xpath_ctx); - + obj = xmlXPathEvalExpression ((xmlChar*)xpath, self->xpath_ctx); - if (obj && + if (obj && (!obj->nodesetval || xmlXPathNodeSetIsEmpty (obj->nodesetval))) { xmlXPathFreeObject (obj); obj = NULL; @@ -255,14 +255,14 @@ static void gc_web_service_finalize (GObject *obj) { GcWebService *self = (GcWebService *) obj; - + gc_web_service_reset (self); - + g_free (self->base_url); - + g_list_foreach (self->namespaces, (GFunc)gc_web_service_free_ns, NULL); g_list_free (self->namespaces); - + ((GObjectClass *) gc_web_service_parent_class)->finalize (obj); } @@ -277,29 +277,29 @@ gc_web_service_class_init (GcWebServiceClass *klass) * gc_web_service_set_base_url: * @self: The #GcWebService object * @url: base url - * - * Sets base url for the web service. Must be called before calls to + * + * Sets base url for the web service. Must be called before calls to * gc_web_service_get_* -methods. */ void gc_web_service_set_base_url (GcWebService *self, gchar *url) { g_assert (url); - + gc_web_service_reset (self); - + g_free (self->base_url); self->base_url = g_strdup (url); } - + /** * gc_web_service_add_namespace: * @self: The #GcWebService object * @namespace: Namespace name - * @uri: Namespace uri - * - * Adds an xml namespace that will be used in all following calls to - * gc_web_service_get_*-functions. + * @uri: Namespace uri + * + * Adds an xml namespace that will be used in all following calls to + * gc_web_service_get_*-functions. * * Return value: %TRUE on success. */ @@ -307,9 +307,9 @@ gboolean gc_web_service_add_namespace (GcWebService *self, gchar *namespace, gchar *uri) { XmlNamespace *ns; - + g_return_val_if_fail (self->base_url, FALSE); - + ns = g_new0 (XmlNamespace,1); ns->name = g_strdup (namespace); ns->uri = g_strdup (uri); @@ -321,10 +321,10 @@ gc_web_service_add_namespace (GcWebService *self, gchar *namespace, gchar *uri) * gc_web_service_query: * @self: A #GcWebService object * @Varargs: NULL-terminated list of key-value gchar* pairs - * - * Fetches data from the web. The url is constructed using the - * optional arguments as GET parameters (see example in the - * Description-section). Data should be read using + * + * Fetches data from the web. The url is constructed using the + * optional arguments as GET parameters (see example in the + * Description-section). Data should be read using * gc_web_service_get_* -functions. * * Return value: %TRUE on success. @@ -335,11 +335,11 @@ gc_web_service_query (GcWebService *self, GError **error, ...) va_list list; gchar *key, *value, *esc_value, *tmp, *url; gboolean first_pair = TRUE; - + g_return_val_if_fail (self->base_url, FALSE); - + url = g_strdup (self->base_url); - + /* read the arguments one key-value pair at a time, add the pairs to url as "?key1=value1&key2=value2&..." */ va_start (list, error); @@ -347,7 +347,7 @@ gc_web_service_query (GcWebService *self, GError **error, ...) while (key) { value = va_arg (list, char*); esc_value = (gchar *)xmlURIEscapeStr ((xmlChar *)value, NULL); - + if (first_pair) { tmp = g_strdup_printf ("%s?%s=%s", url, key, esc_value); first_pair = FALSE; @@ -360,13 +360,13 @@ gc_web_service_query (GcWebService *self, GError **error, ...) key = va_arg (list, char*); } va_end (list); - + if (!gc_web_service_fetch (self, url, error)) { g_free (url); return FALSE; } g_free (url); - + return TRUE; } @@ -374,10 +374,10 @@ gc_web_service_query (GcWebService *self, GError **error, ...) * gc_web_service_get_double: * @self: A #GcWebService object * @value: Pointer to returned value - * @xpath: XPath expression to find the value - * - * Extracts a @value from the data that was fetched in the last call - * to gc_web_service_query() using XPath expression @xpath. Returned + * @xpath: XPath expression to find the value + * + * Extracts a @value from the data that was fetched in the last call + * to gc_web_service_query() using XPath expression @xpath. Returned * value is the first match. * * Return value: %TRUE if a value was found. @@ -386,7 +386,7 @@ gboolean gc_web_service_get_double (GcWebService *self, gdouble *value, gchar *xpath) { xmlXPathObject *obj; - + obj = gc_web_service_get_xpath_object (self, xpath); if (!obj) { return FALSE; @@ -400,10 +400,10 @@ gc_web_service_get_double (GcWebService *self, gdouble *value, gchar *xpath) * gc_web_service_get_string: * @self: The #GcWebService object * @value: pointer to newly allocated string - * @xpath: XPath expression used to find the value - * - * Extracts a @value from the data that was fetched in the last call - * to gc_web_service_query() using XPath expression @xpath (returned + * @xpath: XPath expression used to find the value + * + * Extracts a @value from the data that was fetched in the last call + * to gc_web_service_query() using XPath expression @xpath (returned * value is the first match). * * Return value: %TRUE if a value was found. @@ -412,7 +412,7 @@ gboolean gc_web_service_get_string (GcWebService *self, gchar **value, gchar* xpath) { xmlXPathObject *obj; - + obj = gc_web_service_get_xpath_object (self, xpath); if (!obj) { return FALSE; @@ -427,8 +427,8 @@ gc_web_service_get_string (GcWebService *self, gchar **value, gchar* xpath) * @self: The #GcWebService object * @response: returned guchar array * @response_length: length of the returned array - * - * Returns the raw data fetched with the last call to + * + * Returns the raw data fetched with the last call to * gc_web_service_query(). Data may be unterminated. * * Return value: %TRUE on success. diff --git a/geoclue/gc-web-service.h b/geoclue/gc-web-service.h old mode 100644 new mode 100755 index b5d21ca..c281b2f --- a/geoclue/gc-web-service.h +++ b/geoclue/gc-web-service.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS typedef struct _GcWebService { GObject parent; - + /* private */ gchar *base_url; guchar *response; diff --git a/geoclue/geoclue-accuracy.c b/geoclue/geoclue-accuracy.c old mode 100644 new mode 100755 index d996fd6..0259ceb --- a/geoclue/geoclue-accuracy.c +++ b/geoclue/geoclue-accuracy.c @@ -1,7 +1,7 @@ /* * Geoclue * geoclue-accuracy.c - Code for manipulating the GeoclueAccuracy structure - * + * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries * @@ -25,11 +25,11 @@ /** * SECTION:geoclue-accuracy * @short_description: Methods for manipulating #GeoclueAccuracy structure - * - * A #GeoclueAccuracy holds accuracy information: a + * + * A #GeoclueAccuracy holds accuracy information: a * #GeoclueAccuracyLevel and metric values for horizontal and vertical * accuracy. The last two will only be defined if #GeoclueAccuracyLevel is - * %GEOCLUE_ACCURACY_LEVEL_DETAILED. These values should be set and queried + * %GEOCLUE_ACCURACY_LEVEL_DETAILED. These values should be set and queried * using provided functions. **/ @@ -43,10 +43,10 @@ * @horizontal_accuracy: Horizontal accuracy in meters * @vertical_accuracy: Vertical accuracy in meters * - * Creates a new #GeoclueAccuracy with given values. Use 0 for + * Creates a new #GeoclueAccuracy with given values. Use 0 for * horizontal_accuracy and vertical_accuracy if @level is not * %GEOCLUE_ACCURACY_LEVEL_DETAILED. - * + * * Return value: New #GeoclueAccuracy. */ GeoclueAccuracy * @@ -66,7 +66,7 @@ geoclue_accuracy_new (GeoclueAccuracyLevel level, 1, horizontal_accuracy, 2, vertical_accuracy, G_MAXUINT); - + return (GeoclueAccuracy *) g_value_get_boxed (&accuracy_struct); } @@ -82,7 +82,7 @@ geoclue_accuracy_free (GeoclueAccuracy *accuracy) if (!accuracy) { return; } - + g_boxed_free (GEOCLUE_ACCURACY_TYPE, accuracy); } @@ -92,8 +92,8 @@ geoclue_accuracy_free (GeoclueAccuracy *accuracy) * @level: Pointer to returned #GeoclueAccuracyLevel or %NULL * @horizontal_accuracy: Pointer to returned horizontal accuracy in meters or %NULL * @vertical_accuracy: Pointer to returned vertical accuracy in meters or %NULL - * - * @horizontal_accuracy and @vertical_accuracy will only be defined + * + * @horizontal_accuracy and @vertical_accuracy will only be defined * if @level is %GEOCLUE_ACCURACY_LEVEL_DETAILED. */ void @@ -103,7 +103,7 @@ geoclue_accuracy_get_details (GeoclueAccuracy *accuracy, double *vertical_accuracy) { GValueArray *vals; - + vals = accuracy; if (level != NULL) { *level = g_value_get_int (g_value_array_get_nth (vals, 0)); @@ -123,7 +123,7 @@ geoclue_accuracy_get_details (GeoclueAccuracy *accuracy, * @horizontal_accuracy: Horizontal accuracy in meters * @vertical_accuracy: Vertical accuracy in meters * - * Replaces @accuracy values with given ones. + * Replaces @accuracy values with given ones. */ void geoclue_accuracy_set_details (GeoclueAccuracy *accuracy, @@ -134,7 +134,7 @@ geoclue_accuracy_set_details (GeoclueAccuracy *accuracy, GValueArray *vals = accuracy; g_value_set_int (g_value_array_get_nth (vals, 0), level); - g_value_set_double (g_value_array_get_nth (vals, 1), + g_value_set_double (g_value_array_get_nth (vals, 1), horizontal_accuracy); g_value_set_double (g_value_array_get_nth (vals, 2), vertical_accuracy); @@ -153,7 +153,7 @@ geoclue_accuracy_copy (GeoclueAccuracy *accuracy) { GeoclueAccuracyLevel level; double hor, ver; - + geoclue_accuracy_get_details (accuracy, &level, &hor, &ver); return geoclue_accuracy_new (level, hor, ver); } @@ -172,10 +172,10 @@ geoclue_accuracy_compare (GeoclueAccuracy *accuracy1, GeoclueAccuracy *accuracy2 { GeoclueAccuracyLevel level1, level2; double hor1, hor2; - + geoclue_accuracy_get_details (accuracy1, &level1, &hor1, NULL); geoclue_accuracy_get_details (accuracy2, &level2, &hor2, NULL); - + if (level1 == GEOCLUE_ACCURACY_LEVEL_DETAILED && level2 == GEOCLUE_ACCURACY_LEVEL_DETAILED) { if (hor1 > hor2) { @@ -186,5 +186,5 @@ geoclue_accuracy_compare (GeoclueAccuracy *accuracy1, GeoclueAccuracy *accuracy2 return 0; } return level1 -level2; - + } diff --git a/geoclue/geoclue-accuracy.h b/geoclue/geoclue-accuracy.h old mode 100644 new mode 100755 diff --git a/geoclue/geoclue-address-details.c b/geoclue/geoclue-address-details.c old mode 100644 new mode 100755 index d58a459..c104eb2 --- a/geoclue/geoclue-address-details.c +++ b/geoclue/geoclue-address-details.c @@ -1,7 +1,7 @@ /* * Geoclue * geoclue-address-details.c - Helper functions for GeoclueAddress - * + * * Author: Jussi Kukkonen * Copyright 2008 by Garmin Ltd. or its subsidiaries * @@ -286,11 +286,11 @@ char *countries[][2] = { /** * geoclue_address_details_new: - * + * * Creates a new #GHashTable suitable for Geoclue Address details. * Both keys and values inserted to this #GHashTable will be freed * on g_hash_table_destroy(). - * + * * Return value: New #GHashTable */ GHashTable * @@ -306,7 +306,7 @@ geoclue_address_details_new () * @address: #GHashTable to insert value in * @key: the key to use, one of GEOCLUE_ADDRESS_KEY_* * @value: value to insert into address - * + * * Adds a address field into @address. Will take copies * of the strings. */ @@ -327,21 +327,21 @@ copy_address_key_and_value (char *key, char *value, GHashTable *target) /** * geoclue_address_details_copy: * @source: #GHashTable to copy - * + * * Deep-copies a #GHashTable. - * + * * Return value: New, deep copied #GHashTable */ GHashTable * geoclue_address_details_copy (GHashTable *source) { GHashTable *target; - + g_assert (source != NULL); - + target = geoclue_address_details_new (); - g_hash_table_foreach (source, - (GHFunc)copy_address_key_and_value, + g_hash_table_foreach (source, + (GHFunc)copy_address_key_and_value, target); return target; } @@ -350,10 +350,10 @@ geoclue_address_details_copy (GHashTable *source) /** * geoclue_address_details_set_country_from_code: * @address: #GHashTable with address data - * - * Uses the "ISO 3166-1 alpha-2" list to figure out the country name matching + * + * Uses the "ISO 3166-1 alpha-2" list to figure out the country name matching * the country code in @details, and adds the country name to details. - * + * * Using this function in providers is useful even when the data source includes * country name: this way names are standardized. */ @@ -391,9 +391,9 @@ geoclue_address_details_set_country_from_code (GHashTable *address) /** * geoclue_address_details_get_accuracy_level: * @address: A #GHashTable with address hash values - * + * * Returns a #GeoclueAccuracy that best describes the accuracy of @address - * + * * Return value: #GeoclueAccuracy */ GeoclueAccuracyLevel diff --git a/geoclue/geoclue-address-details.h b/geoclue/geoclue-address-details.h old mode 100644 new mode 100755 index 3c0dd71..f00a897 --- a/geoclue/geoclue-address-details.h +++ b/geoclue/geoclue-address-details.h @@ -1,6 +1,6 @@ /* * Geoclue - * geoclue-address-details.h - + * geoclue-address-details.h - * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries diff --git a/geoclue/geoclue-address.c b/geoclue/geoclue-address.c old mode 100644 new mode 100755 index fe13c42..62d63e7 --- a/geoclue/geoclue-address.c +++ b/geoclue/geoclue-address.c @@ -26,18 +26,18 @@ * SECTION:geoclue-address * @short_description: Geoclue address client API * - * #GeoclueAddress contains Address-related methods and signals. - * It is part of the Geoclue public C client API which uses D-Bus + * #GeoclueAddress contains Address-related methods and signals. + * It is part of the Geoclue public C client API which uses D-Bus * to communicate with the actual provider. - * - * After a #GeoclueAddress is created with geoclue_address_new() or - * geoclue_master_client_create_address(), the - * geoclue_address_get_address() and geoclue_address_get_address_async() methods - * and the address-changed signal can be used to obtain the current address. - * - * Address #GHashTable keys are defined in - * geoclue-types.h. See also - * convenience functions in + * + * After a #GeoclueAddress is created with geoclue_address_new() or + * geoclue_master_client_create_address(), the + * geoclue_address_get_address() and geoclue_address_get_address_async() methods + * and the address-changed signal can be used to obtain the current address. + * + * Address #GHashTable keys are defined in + * geoclue-types.h. See also + * convenience functions in * geoclue-address-details.h. */ @@ -80,7 +80,7 @@ address_changed (DBusGProxy *proxy, GeoclueAccuracy *accuracy, GeoclueAddress *address) { - g_signal_emit (address, signals[ADDRESS_CHANGED], 0, + g_signal_emit (address, signals[ADDRESS_CHANGED], 0, timestamp, details, accuracy); } @@ -95,9 +95,9 @@ constructor (GType type, object = G_OBJECT_CLASS (geoclue_address_parent_class)->constructor (type, n_props, props); provider = GEOCLUE_PROVIDER (object); - + dbus_g_proxy_add_signal (provider->proxy, "AddressChanged", - G_TYPE_INT, + G_TYPE_INT, DBUS_TYPE_G_STRING_STRING_HASHTABLE, GEOCLUE_ACCURACY_TYPE, G_TYPE_INVALID); @@ -118,29 +118,29 @@ geoclue_address_class_init (GeoclueAddressClass *klass) o_class->constructor = constructor; g_type_class_add_private (klass, sizeof (GeoclueAddressPrivate)); - + /** * GeoclueAddress::address-changed: * @address: the #GeoclueAddress object emitting the signal * @timestamp: Time of address measurement (Unix timestamp) * @details: Address details as #GHashTable. * @accuracy: Accuracy of measurement as #GeoclueAccuracy - * - * The address-changed signal is emitted each time the address changes. - * See geoclue-types.h for the possible + * + * The address-changed signal is emitted each time the address changes. + * See geoclue-types.h for the possible * GEOCLUE_ADDRESS_KEY_* keys used in @details. - * + * * Note that not all providers support signals. */ signals[ADDRESS_CHANGED] = g_signal_new ("address-changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GeoclueAddressClass, address_changed), + G_STRUCT_OFFSET (GeoclueAddressClass, address_changed), NULL, NULL, geoclue_marshal_VOID__INT_BOXED_BOXED, G_TYPE_NONE, 3, - G_TYPE_INT, + G_TYPE_INT, G_TYPE_POINTER, G_TYPE_POINTER); } @@ -156,7 +156,7 @@ geoclue_address_init (GeoclueAddress *address) * @path: D-Bus path name * * Creates a #GeoclueAddress with given D-Bus service name and path. - * + * * Return value: Pointer to a new #GeoclueAddress */ GeoclueAddress * @@ -177,17 +177,17 @@ geoclue_address_new (const char *service, * @details: Pointer to returned #GHashTable with address details or %NULL * @accuracy: Pointer to returned #GeoclueAccuracy or NULL * @error: Pointer to returned #Gerror or %NULL - * - * Obtains the current address. @timestamp will contain the time of + * + * Obtains the current address. @timestamp will contain the time of * the actual address measurement. @accuracy is the estimated of the - * accuracy of the current address information (see #GeoclueAccuracy - * for more details). @details is a hashtable with the address data, - * see geoclue-types.h for the + * accuracy of the current address information (see #GeoclueAccuracy + * for more details). @details is a hashtable with the address data, + * see geoclue-types.h for the * hashtable keys. - * - * If the caller is not interested in some values, the pointers can be + * + * If the caller is not interested in some values, the pointers can be * left %NULL. - * + * * Return value: %TRUE if there is no @error */ gboolean @@ -216,7 +216,7 @@ typedef struct _GeoclueAddressAsyncData { } GeoclueAddressAsyncData; static void -get_address_async_callback (DBusGProxy *proxy, +get_address_async_callback (DBusGProxy *proxy, int timestamp, GHashTable *details, GeoclueAccuracy *accuracy, @@ -240,7 +240,7 @@ get_address_async_callback (DBusGProxy *proxy, * @accuracy: Accuracy of measurement as #GeoclueAccuracy * @error: Error as #Gerror (may be %NULL) * @userdata: User data pointer set in geoclue_position_get_position_async() - * + * * Callback function for geoclue_address_get_address_async(). */ @@ -249,23 +249,23 @@ get_address_async_callback (DBusGProxy *proxy, * @address: A #GeoclueAddress object * @callback: A #GeoclueAddressCallback function that should be called when return values are available * @userdata: pointer for user specified data - * + * * Function returns (essentially) immediately and calls @callback when current address * is available or when D-Bus timeouts. */ -void +void geoclue_address_get_address_async (GeoclueAddress *address, GeoclueAddressCallback callback, gpointer userdata) { GeoclueProvider *provider = GEOCLUE_PROVIDER (address); GeoclueAddressAsyncData *data; - + data = g_new (GeoclueAddressAsyncData, 1); data->address = address; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_Address_get_address_async (provider->proxy, (org_freedesktop_Geoclue_Address_get_address_reply) get_address_async_callback, diff --git a/geoclue/geoclue-address.h b/geoclue/geoclue-address.h old mode 100644 new mode 100755 index c31d367..447c23a --- a/geoclue/geoclue-address.h +++ b/geoclue/geoclue-address.h @@ -1,6 +1,6 @@ /* * Geoclue - * geoclue-address.h - + * geoclue-address.h - * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries diff --git a/geoclue/geoclue-error.c b/geoclue/geoclue-error.c old mode 100644 new mode 100755 index 54df6ed..4334ec2 --- a/geoclue/geoclue-error.c +++ b/geoclue/geoclue-error.c @@ -24,7 +24,7 @@ #include -GQuark +GQuark geoclue_error_quark (void) { static GQuark quark = 0; diff --git a/geoclue/geoclue-error.h b/geoclue/geoclue-error.h old mode 100644 new mode 100755 diff --git a/geoclue/geoclue-geocode.c b/geoclue/geoclue-geocode.c old mode 100644 new mode 100755 index 38e52a3..645a9d5 --- a/geoclue/geoclue-geocode.c +++ b/geoclue/geoclue-geocode.c @@ -28,19 +28,19 @@ * SECTION:geoclue-geocode * @short_description: Geoclue geocode client API * - * #GeoclueGeocode contains geocoding methods. - * It is part of the Geoclue public C client API which uses D-Bus + * #GeoclueGeocode contains geocoding methods. + * It is part of the Geoclue public C client API which uses D-Bus * to communicate with the actual provider. - * - * After a #GeoclueGeocode is created with geoclue_geocode_new(), the + * + * After a #GeoclueGeocode is created with geoclue_geocode_new(), the * geoclue_geocode_address_to_position(), * geoclue_geocode_freeform_address_to_position() methods and their * asynchronous counterparts can be used to obtain the position (coordinates) * of the given address. - * - * Address #GHashTable keys are defined in - * geoclue-types.h. See also - * convenience functions in + * + * Address #GHashTable keys are defined in + * geoclue-types.h. See also + * convenience functions in * geoclue-address-details.h. */ @@ -91,7 +91,7 @@ geoclue_geocode_init (GeoclueGeocode *geocode) * @path: D-Bus path name * * Creates a #GeoclueGeocode with given D-Bus service name and path. - * + * * Return value: Pointer to a new #GeoclueGeocode */ GeoclueGeocode * @@ -114,16 +114,16 @@ geoclue_geocode_new (const char *service, * @altitude: Pointer to returned altitude in meters or %NULL * @accuracy: Pointer to returned #GeoclueAccuracy or %NULL * @error: Pointer to returned #Gerror or %NULL - * - * Geocodes given address to coordinates (@latitude, @longitude, @altitude). - * see geoclue-types.h for the - * hashtable keys usable in @details. @accuracy is a rough estimate of + * + * Geocodes given address to coordinates (@latitude, @longitude, @altitude). + * see geoclue-types.h for the + * hashtable keys usable in @details. @accuracy is a rough estimate of * the accuracy of the returned position. - * - * If the caller is not interested in some values, the pointers can be + * + * If the caller is not interested in some values, the pointers can be * left %NULL. - * - * Return value: A #GeocluePositionFields bitfield representing the + * + * Return value: A #GeocluePositionFields bitfield representing the * validity of the returned coordinates. */ GeocluePositionFields @@ -139,7 +139,7 @@ geoclue_geocode_address_to_position (GeoclueGeocode *geocode, int fields; double la, lo, al; GeoclueAccuracy *acc; - + if (!org_freedesktop_Geoclue_Geocode_address_to_position (provider->proxy, details, &fields, &la, &lo, &al, @@ -173,7 +173,7 @@ typedef struct _GeoclueGeocodeAsyncData { } GeoclueGeocodeAsyncData; static void -address_to_position_callback (DBusGProxy *proxy, +address_to_position_callback (DBusGProxy *proxy, GeocluePositionFields fields, double latitude, double longitude, @@ -203,7 +203,7 @@ address_to_position_callback (DBusGProxy *proxy, * @accuracy: Accuracy of measurement as #GeoclueAccuracy * @error: Error as #Gerror or %NULL * @userdata: User data pointer - * + * * Callback function for the asynchronous methods. */ @@ -213,15 +213,15 @@ address_to_position_callback (DBusGProxy *proxy, * @details: A #GHashTable with address data * @callback: A #GeoclueAddressCallback function that should be called when return values are available * @userdata: pointer for user specified data - * - * Function returns (essentially) immediately and calls @callback when the geocoded + * + * Function returns (essentially) immediately and calls @callback when the geocoded * position data is available or when D-Bus timeouts. - * - * see geoclue-types.h for the + * + * see geoclue-types.h for the * hashtable keys usable in @details. - * + * */ -void +void geoclue_geocode_address_to_position_async (GeoclueGeocode *geocode, GHashTable *details, GeoclueGeocodeCallback callback, @@ -229,12 +229,12 @@ geoclue_geocode_address_to_position_async (GeoclueGeocode *geocode, { GeoclueProvider *provider = GEOCLUE_PROVIDER (geocode); GeoclueGeocodeAsyncData *data; - + data = g_new (GeoclueGeocodeAsyncData, 1); data->geocode = geocode; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_Geocode_address_to_position_async (provider->proxy, details, @@ -309,7 +309,7 @@ geoclue_geocode_freeform_address_to_position (GeoclueGeocode *geocode, * @callback: A #GeoclueAddressCallback function that should be called when return values are available * @userdata: pointer for user specified data * - * Function returns (essentially) immediately and calls @callback when the geocoded + * Function returns (essentially) immediately and calls @callback when the geocoded * position data is available or when D-Bus timeouts. */ void diff --git a/geoclue/geoclue-geocode.h b/geoclue/geoclue-geocode.h old mode 100644 new mode 100755 index 0523ed5..59aa15a --- a/geoclue/geoclue-geocode.h +++ b/geoclue/geoclue-geocode.h @@ -1,6 +1,6 @@ /* * Geoclue - * geoclue-geocode.h - + * geoclue-geocode.h - * * Authors: Iain Holmes * Jussi Kukkonen @@ -53,7 +53,7 @@ GType geoclue_geocode_get_type (void); GeoclueGeocode *geoclue_geocode_new (const char *service, const char *path); -GeocluePositionFields +GeocluePositionFields geoclue_geocode_address_to_position (GeoclueGeocode *geocode, GHashTable *details, double *latitude, diff --git a/geoclue/geoclue-master-client.c b/geoclue/geoclue-master-client.c index 248bc32..57b2d97 100644 --- a/geoclue/geoclue-master-client.c +++ b/geoclue/geoclue-master-client.c @@ -26,13 +26,13 @@ * SECTION:geoclue-master-client * @short_description: Geoclue MasterClient API * - * #GeoclueMasterClient is part of the Geoclue public C client API. It uses + * #GeoclueMasterClient is part of the Geoclue public C client API. It uses * D-Bus to communicate with the actual Master service. - * - * #GeoclueMasterClient is used to control the client specific behaviour + * + * #GeoclueMasterClient is used to control the client specific behaviour * of Geoclue Master. Chapter "Master provider: simple example in C" contains a * more complete example, but here are the main parts: - * + * * * * GeoclueMaster *master; @@ -40,10 +40,10 @@ * GeoclueAddress *address; * * ... - * + * * master = geoclue_master_get_default (); * client = geoclue_master_create_client (master, NULL, NULL); - * + * * if (!geoclue_master_client_set_requirements (client, * GEOCLUE_ACCURACY_LEVEL_NONE, * 0, FALSE, @@ -51,13 +51,13 @@ * &error)) { * / * handle error * / * } - * + * * address = geoclue_master_client_create_address (client, error); * if (!address) { * / * handle error * / * } - * - * / * Now we can use address just like we'd use a normal address provider, + * + * / * Now we can use address just like we'd use a normal address provider, * but GeoclueMasterClient makes sure that underneath the provider * that best matches our requirements is used * / * @@ -152,9 +152,9 @@ get_property (GObject *object, static void address_provider_changed (DBusGProxy *proxy, char *name, - char *description, - char *service, - char *path, + char *description, + char *service, + char *path, GeoclueMasterClient *client) { g_signal_emit (client, signals[ADDRESS_PROVIDER_CHANGED], 0, @@ -164,12 +164,12 @@ address_provider_changed (DBusGProxy *proxy, static void position_provider_changed (DBusGProxy *proxy, char *name, - char *description, - char *service, - char *path, + char *description, + char *service, + char *path, GeoclueMasterClient *client) { - g_signal_emit (client, signals[POSITION_PROVIDER_CHANGED], 0, + g_signal_emit (client, signals[POSITION_PROVIDER_CHANGED], 0, name, description, service, path); } @@ -228,7 +228,7 @@ constructor (GType type, dbus_g_proxy_connect_signal (priv->proxy, "AddressProviderChanged", G_CALLBACK (address_provider_changed), object, NULL); - + dbus_g_proxy_add_signal (priv->proxy, "PositionProviderChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); @@ -251,7 +251,7 @@ geoclue_master_client_class_init (GeoclueMasterClientClass *klass) g_type_class_add_private (klass, sizeof (GeoclueMasterClientPrivate)); - g_object_class_install_property + g_object_class_install_property (o_class, PROP_PATH, g_param_spec_string ("object-path", "Object path", @@ -262,7 +262,7 @@ geoclue_master_client_class_init (GeoclueMasterClientClass *klass) G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME)); - + /** * GeoclueMasterClient::address-provider-changed: * @client: the #GeoclueMasterClient object emitting the signal @@ -270,20 +270,20 @@ geoclue_master_client_class_init (GeoclueMasterClientClass *klass) * @description: a short description of the new provider or %NULL if there is no provider * @service: D-Bus service name of the new provider or %NULL if there is no provider * @path: D-Bus object path name of the new provider or %NULL if there is no provider - * + * * The address-provider-changed signal is emitted each time the used address provider * changes. **/ - signals[ADDRESS_PROVIDER_CHANGED] = + signals[ADDRESS_PROVIDER_CHANGED] = g_signal_new ("address-provider-changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GeoclueMasterClientClass, address_provider_changed), + G_STRUCT_OFFSET (GeoclueMasterClientClass, address_provider_changed), NULL, NULL, geoclue_marshal_VOID__STRING_STRING_STRING_STRING, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); - + /** * GeoclueMasterClient::position-provider-changed: * @client: the #GeoclueMasterClient object emitting the signal @@ -291,15 +291,15 @@ geoclue_master_client_class_init (GeoclueMasterClientClass *klass) * @description: a short description of the new provider or %NULL if there is no provider * @service: D-Bus service name of the new provider or %NULL if there is no provider * @path: D-Bus object path name of the new provider or %NULL if there is no provider - * + * * The position-provider-changed signal is emitted each time the used position provider * changes. **/ - signals[POSITION_PROVIDER_CHANGED] = + signals[POSITION_PROVIDER_CHANGED] = g_signal_new ("position-provider-changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GeoclueMasterClientClass, position_provider_changed), + G_STRUCT_OFFSET (GeoclueMasterClientClass, position_provider_changed), NULL, NULL, geoclue_marshal_VOID__STRING_STRING_STRING_STRING, G_TYPE_NONE, 4, @@ -353,7 +353,7 @@ geoclue_master_client_set_requirements (GeoclueMasterClient *client, GeoclueMasterClientPrivate *priv; priv = GET_PRIVATE (client); - if (!org_freedesktop_Geoclue_MasterClient_set_requirements + if (!org_freedesktop_Geoclue_MasterClient_set_requirements (priv->proxy, min_accuracy, min_time, require_updates, allowed_resources, error)) { return FALSE; } @@ -362,7 +362,7 @@ geoclue_master_client_set_requirements (GeoclueMasterClient *client, } static void -set_requirements_callback (DBusGProxy *proxy, +set_requirements_callback (DBusGProxy *proxy, GError *error, GeoclueMasterClientAsyncData *data) { @@ -377,7 +377,7 @@ set_requirements_callback (DBusGProxy *proxy, * @client: A #GeoclueMasterClient object * @error: Error as #Gerror (may be %NULL) * @userdata: User data pointer set in geoclue_master_client_set_requirements_async() - * + * * Callback function for geoclue_master_client_set_requirements_async(). */ @@ -389,11 +389,11 @@ set_requirements_callback (DBusGProxy *proxy, * @require_updates: Whether the updates (signals) are required. Only applies to interfaces with signals * @allowed_resources: The resources that are allowed to be used as a #GeoclueResourceFlags * @callback: #GeoclueSetRequirementsCallback function to call when requirements have been set - * @userdata: User data pointer - * + * @userdata: User data pointer + * * Asynchronous version of geoclue_master_client_set_requirements(). */ -void +void geoclue_master_client_set_requirements_async (GeoclueMasterClient *client, GeoclueAccuracyLevel min_accuracy, int min_time, @@ -404,12 +404,12 @@ geoclue_master_client_set_requirements_async (GeoclueMasterClient *cli { GeoclueMasterClientPrivate *priv = GET_PRIVATE (client); GeoclueMasterClientAsyncData *data; - + data = g_new (GeoclueMasterClientAsyncData, 1); data->client = client; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_MasterClient_set_requirements_async (priv->proxy, min_accuracy, @@ -425,38 +425,38 @@ geoclue_master_client_set_requirements_async (GeoclueMasterClient *cli * @client: A #GeoclueMasterClient * @error: A pointer to returned #GError or %NULL. * - * Starts the GeoclueMasterClient address provider and returns + * Starts the GeoclueMasterClient address provider and returns * a #GeoclueAddress that uses the same D-Bus object as the #GeoclueMasterClient. * * Return value: New #GeoclueAddress or %NULL on error */ GeoclueAddress * -geoclue_master_client_create_address (GeoclueMasterClient *client, +geoclue_master_client_create_address (GeoclueMasterClient *client, GError **error) { GeoclueMasterClientPrivate *priv; - + priv = GET_PRIVATE (client); - + if (!org_freedesktop_Geoclue_MasterClient_address_start (priv->proxy, error)) { return NULL; } - + return geoclue_address_new (GEOCLUE_MASTER_DBUS_SERVICE, priv->object_path); } static void -address_start_async_callback (DBusGProxy *proxy, +address_start_async_callback (DBusGProxy *proxy, GError *error, GeoclueMasterClientAsyncData *data) { GeoclueMasterClientPrivate *priv = GET_PRIVATE (data->client); GeoclueAddress *address = NULL; - + if (!error) { address = geoclue_address_new (GEOCLUE_MASTER_DBUS_SERVICE, priv->object_path); } - + (*(CreateAddressCallback)data->callback) (data->client, address, error, @@ -470,7 +470,7 @@ address_start_async_callback (DBusGProxy *proxy, * @address: returned #GeoclueAddress * @error: Error as #Gerror (may be %NULL) * @userdata: User data pointer set in geoclue_master_client_create_address_async() - * + * * Callback function for geoclue_master_client_create_address_async(). */ @@ -479,23 +479,23 @@ address_start_async_callback (DBusGProxy *proxy, * @client: A #GeoclueMasterClient object * @callback: A #CreateAddressCallback function that should be called when return values are available * @userdata: pointer for user specified data - * + * * Function returns (essentially) immediately and calls @callback when it has started the address provider * and a #GeoclueAddress is available. */ -void +void geoclue_master_client_create_address_async (GeoclueMasterClient *client, CreateAddressCallback callback, gpointer userdata) { GeoclueMasterClientPrivate *priv = GET_PRIVATE (client); GeoclueMasterClientAsyncData *data; - + data = g_new (GeoclueMasterClientAsyncData, 1); data->client = client; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_MasterClient_address_start_async (priv->proxy, (org_freedesktop_Geoclue_MasterClient_address_start_reply)address_start_async_callback, @@ -508,7 +508,7 @@ geoclue_master_client_create_address_async (GeoclueMasterClient *client, * @client: A #GeoclueMasterClient * @error: A pointer to returned #GError or %NULL. * - * Starts the GeoclueMasterClient position provider and returns + * Starts the GeoclueMasterClient position provider and returns * a #GeocluePosition that uses the same D-Bus object as the #GeoclueMasterClient. * * Return value: New #GeocluePosition or %NULL on error @@ -518,9 +518,9 @@ geoclue_master_client_create_position (GeoclueMasterClient *client, GError **error) { GeoclueMasterClientPrivate *priv; - + priv = GET_PRIVATE (client); - + if (!org_freedesktop_Geoclue_MasterClient_position_start (priv->proxy, error)) { return NULL; } @@ -529,17 +529,17 @@ geoclue_master_client_create_position (GeoclueMasterClient *client, static void -position_start_async_callback (DBusGProxy *proxy, +position_start_async_callback (DBusGProxy *proxy, GError *error, GeoclueMasterClientAsyncData *data) { GeoclueMasterClientPrivate *priv = GET_PRIVATE (data->client); GeocluePosition *position = NULL; - + if (!error) { position = geoclue_position_new (GEOCLUE_MASTER_DBUS_SERVICE, priv->object_path); } - + (*(CreatePositionCallback)data->callback) (data->client, position, error, @@ -553,7 +553,7 @@ position_start_async_callback (DBusGProxy *proxy, * @position: returned #GeocluePosition * @error: Error as #Gerror (may be %NULL) * @userdata: User data pointer set in geoclue_master_client_create_position_async() - * + * * Callback function for geoclue_master_client_create_position_async(). */ @@ -562,23 +562,23 @@ position_start_async_callback (DBusGProxy *proxy, * @client: A #GeoclueMasterClient object * @callback: A #CreatePositionCallback function that should be called when return values are available * @userdata: pointer for user specified data - * + * * Function returns (essentially) immediately and calls @callback when it has started the position provider * and a #GeocluePosition is available. */ -void +void geoclue_master_client_create_position_async (GeoclueMasterClient *client, CreatePositionCallback callback, gpointer userdata) { GeoclueMasterClientPrivate *priv = GET_PRIVATE (client); GeoclueMasterClientAsyncData *data; - + data = g_new (GeoclueMasterClientAsyncData, 1); data->client = client; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_MasterClient_position_start_async (priv->proxy, (org_freedesktop_Geoclue_MasterClient_position_start_reply)position_start_async_callback, @@ -594,9 +594,9 @@ geoclue_master_client_create_position_async (GeoclueMasterClient *client, * @service: Pointer to returned D-Bus service name or %NULL * @path: Pointer to returned D-Bus object path or %NULL * @error: Pointer to returned #GError or %NULL - * + * * Gets name and other information for the currently used address provider. - * + * * Return value: %TRUE on success */ gboolean geoclue_master_client_get_address_provider (GeoclueMasterClient *client, @@ -607,26 +607,26 @@ gboolean geoclue_master_client_get_address_provider (GeoclueMasterClient *clien GError **error) { GeoclueMasterClientPrivate *priv; - + priv = GET_PRIVATE (client); - if (!org_freedesktop_Geoclue_MasterClient_get_address_provider + if (!org_freedesktop_Geoclue_MasterClient_get_address_provider (priv->proxy, name, description, service, path, error)) { return FALSE; } - + return TRUE; } static void -get_provider_callback (DBusGProxy *proxy, - char * name, - char * description, - char * service, - char * path, - GError *error, +get_provider_callback (DBusGProxy *proxy, + char * name, + char * description, + char * service, + char * path, + GError *error, GeoclueMasterClientAsyncData *data) { - + (*(GeoclueGetProviderCallback)data->callback) (data->client, name, description, @@ -642,22 +642,22 @@ get_provider_callback (DBusGProxy *proxy, * @client: A #GeoclueMasterClient * @callback: A #GeoclueGetProviderCallback function that will be called when return values are available * @userdata: pointer for user specified data - * + * * Gets name and other information for the currently used address provider asynchronously. */ -void +void geoclue_master_client_get_address_provider_async (GeoclueMasterClient *client, GeoclueGetProviderCallback callback, gpointer userdata) { GeoclueMasterClientPrivate *priv = GET_PRIVATE (client); GeoclueMasterClientAsyncData *data; - + data = g_new (GeoclueMasterClientAsyncData, 1); data->client = client; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_MasterClient_get_address_provider_async (priv->proxy, (org_freedesktop_Geoclue_MasterClient_get_address_provider_reply)get_provider_callback, @@ -673,9 +673,9 @@ geoclue_master_client_get_address_provider_async (GeoclueMasterClient *client, * @service: Pointer to returned D-Bus service name or %NULL * @path: Pointer to returned D-Bus object path or %NULL * @error: Pointer to returned #GError or %NULL - * + * * Gets name and other information for the currently used position provider. - * + * * Return value: %TRUE on success */ gboolean geoclue_master_client_get_position_provider (GeoclueMasterClient *client, @@ -686,13 +686,13 @@ gboolean geoclue_master_client_get_position_provider (GeoclueMasterClient *clie GError **error) { GeoclueMasterClientPrivate *priv; - + priv = GET_PRIVATE (client); - if (!org_freedesktop_Geoclue_MasterClient_get_position_provider + if (!org_freedesktop_Geoclue_MasterClient_get_position_provider (priv->proxy, name, description, service, path, error)) { return FALSE; } - + return TRUE; } @@ -701,22 +701,22 @@ gboolean geoclue_master_client_get_position_provider (GeoclueMasterClient *clie * @client: A #GeoclueMasterClient * @callback: A #GeoclueGetProviderCallback function that will be called when return values are available * @userdata: pointer for user specified data - * + * * Gets name and other information for the currently used position provider asynchronously. */ -void +void geoclue_master_client_get_position_provider_async (GeoclueMasterClient *client, GeoclueGetProviderCallback callback, gpointer userdata) { GeoclueMasterClientPrivate *priv = GET_PRIVATE (client); GeoclueMasterClientAsyncData *data; - + data = g_new (GeoclueMasterClientAsyncData, 1); data->client = client; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_MasterClient_get_position_provider_async (priv->proxy, (org_freedesktop_Geoclue_MasterClient_get_position_provider_reply)get_provider_callback, diff --git a/geoclue/geoclue-master-client.h b/geoclue/geoclue-master-client.h old mode 100644 new mode 100755 diff --git a/geoclue/geoclue-master.c b/geoclue/geoclue-master.c old mode 100644 new mode 100755 index d052540..efdb623 --- a/geoclue/geoclue-master.c +++ b/geoclue/geoclue-master.c @@ -26,13 +26,13 @@ * SECTION:geoclue-master * @short_description: Geoclue Master API * @see_also: #GeoclueMasterClient - * - * #GeoclueMaster is part of the Geoclue public C client API. It uses + * + * #GeoclueMaster is part of the Geoclue public C client API. It uses * D-Bus to communicate with the actual Master service. - * + * * #GeoclueMaster is a singleton service, so it should not be created * explicitly: instead one should use geoclue_master_get_default() to - * get a reference to it. It can be used to + * get a reference to it. It can be used to * create a #GeoclueMasterClient object. * */ @@ -121,7 +121,7 @@ geoclue_master_get_default (void) if (G_UNLIKELY (master == NULL)) { master = g_object_new (GEOCLUE_TYPE_MASTER, NULL); - g_object_add_weak_pointer (G_OBJECT (master), + g_object_add_weak_pointer (G_OBJECT (master), (gpointer) &master); return master; } @@ -140,7 +140,7 @@ geoclue_master_get_default (void) * * Return Value: A new #GeoclueMasterClient or %NULL on error. */ - + GeoclueMasterClient * geoclue_master_create_client (GeoclueMaster *master, char **object_path, @@ -154,65 +154,65 @@ geoclue_master_create_client (GeoclueMaster *master, priv = GET_PRIVATE (master); - if (!org_freedesktop_Geoclue_Master_create (priv->proxy, + if (!org_freedesktop_Geoclue_Master_create (priv->proxy, &path, error)){ return NULL; } - + client = g_object_new (GEOCLUE_TYPE_MASTER_CLIENT, "object-path", path, NULL); - + if (object_path) { *object_path = path; } else { g_free (path); } - + return client; } static void -create_client_callback (DBusGProxy *proxy, - char *path, - GError *error, +create_client_callback (DBusGProxy *proxy, + char *path, + GError *error, GeoclueMasterAsyncData *data) { GeoclueMasterClient *client; - + client = NULL; - + if (!error) { client = g_object_new (GEOCLUE_TYPE_MASTER_CLIENT, "object-path", path, NULL); } - + (*(GeoclueCreateClientCallback)data->callback) (data->master, client, path, error, data->userdata); - + g_free (data); } -void +void geoclue_master_create_client_async (GeoclueMaster *master, GeoclueCreateClientCallback callback, gpointer userdata) { GeoclueMasterPrivate *priv; GeoclueMasterAsyncData *data; - + g_return_if_fail (GEOCLUE_IS_MASTER (master)); - + priv = GET_PRIVATE (master); data = g_new (GeoclueMasterAsyncData, 1); data->master = master; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_Master_create_async (priv->proxy, (org_freedesktop_Geoclue_Master_create_reply)create_client_callback, diff --git a/geoclue/geoclue-master.h b/geoclue/geoclue-master.h old mode 100644 new mode 100755 diff --git a/geoclue/geoclue-nmea.c b/geoclue/geoclue-nmea.c index 4f18075..a63f696 100644 --- a/geoclue/geoclue-nmea.c +++ b/geoclue/geoclue-nmea.c @@ -2,7 +2,7 @@ * Geoclue * geoclue-nmea.c - Client API for accessing GcIfaceNmea * - * Author: Tae-Hwan Kim , Youngae Kang , + * Author: Tae-Hwan Kim , Youngae Kang , * Yunhan Kim , Genie Kim * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * @@ -27,13 +27,13 @@ * SECTION:geoclue-nmea * @short_description: Geoclue nmea client API * - * #GeoclueNmea contains nmea-related methods and signals. - * It is part of the Geoclue public C client API which uses D-Bus + * #GeoclueNmea contains nmea-related methods and signals. + * It is part of the Geoclue public C client API which uses D-Bus * to communicate with the actual provider. - * - * After a #GeoclueNmea is created with geoclue_nmea_new() or - * using geoclye_master_client_create_nmea(), the - * geoclue_nmea_get_nmea() and geoclue_nmea_get_nmea_async() + * + * After a #GeoclueNmea is created with geoclue_nmea_new() or + * using geoclye_master_client_create_nmea(), the + * geoclue_nmea_get_nmea() and geoclue_nmea_get_nmea_async() * method and the nmea-changed signal can be used to obtain the current nmea. */ @@ -94,7 +94,7 @@ constructor (GType type, provider = GEOCLUE_PROVIDER (object); dbus_g_proxy_add_signal (provider->proxy, "NmeaChanged", - G_TYPE_INT, + G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_connect_signal (provider->proxy, "NmeaChanged", @@ -114,7 +114,7 @@ geoclue_nmea_class_init (GeoclueNmeaClass *klass) o_class->constructor = constructor; g_type_class_add_private (klass, sizeof (GeoclueNmeaPrivate)); - + signals[NMEA_CHANGED] = g_signal_new ("nmea-changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | @@ -138,7 +138,7 @@ geoclue_nmea_init (GeoclueNmea *nmea) * @path: D-Bus path name * * Creates a #GeoclueNmea with given D-Bus service name and path. - * + * * Return value: Pointer to a new #GeoclueNmea */ GeoclueNmea * @@ -159,13 +159,13 @@ geoclue_nmea_get_nmea (GeoclueNmea *nmea, GError **error) { GeoclueProvider *provider = GEOCLUE_PROVIDER (nmea); - + if (!org_freedesktop_Geoclue_Nmea_get_nmea (provider->proxy, timestamp, nmea_data, error)) { return FALSE; - } + } return TRUE; } @@ -191,19 +191,19 @@ get_nmea_async_callback (DBusGProxy *proxy, g_free (data); } -void +void geoclue_nmea_get_nmea_async (GeoclueNmea *nmea, GeoclueNmeaCallback callback, gpointer userdata) { GeoclueProvider *provider = GEOCLUE_PROVIDER (nmea); GeoclueNmeaAsyncData *data; - + data = g_new (GeoclueNmeaAsyncData, 1); data->nmea = nmea; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_Nmea_get_nmea_async ( provider->proxy, (org_freedesktop_Geoclue_Nmea_get_nmea_reply)get_nmea_async_callback, diff --git a/geoclue/geoclue-nmea.h b/geoclue/geoclue-nmea.h index 72307a5..aabd1da 100644 --- a/geoclue/geoclue-nmea.h +++ b/geoclue/geoclue-nmea.h @@ -1,8 +1,8 @@ /* * Geoclue - * geoclue-nmea.h - + * geoclue-nmea.h - * - * Author: Tae-Hwan Kim , Youngae Kang , + * Author: Tae-Hwan Kim , Youngae Kang , * Yunhan Kim , Genie Kim * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * diff --git a/geoclue/geoclue-position.c b/geoclue/geoclue-position.c old mode 100644 new mode 100755 index ea4d53f..2366286 --- a/geoclue/geoclue-position.c +++ b/geoclue/geoclue-position.c @@ -26,13 +26,13 @@ * SECTION:geoclue-position * @short_description: Geoclue position client API * - * #GeocluePosition contains position-related methods and signals. - * It is part of the Geoclue public C client API which uses D-Bus + * #GeocluePosition contains position-related methods and signals. + * It is part of the Geoclue public C client API which uses D-Bus * to communicate with the actual provider. - * - * After a #GeocluePosition is created with geoclue_position_new() or - * using geoclye_master_client_create_position(), the - * geoclue_position_get_position() and geoclue_position_get_position_async() + * + * After a #GeocluePosition is created with geoclue_position_new() or + * using geoclye_master_client_create_position(), the + * geoclue_position_get_position() and geoclue_position_get_position_async() * method and the position-changed signal can be used to obtain the current position. */ @@ -96,7 +96,7 @@ constructor (GType type, dbus_g_proxy_add_signal (provider->proxy, "PositionChanged", G_TYPE_INT, G_TYPE_INT, G_TYPE_DOUBLE, - G_TYPE_DOUBLE, G_TYPE_DOUBLE, + G_TYPE_DOUBLE, G_TYPE_DOUBLE, GEOCLUE_ACCURACY_TYPE, G_TYPE_INVALID); dbus_g_proxy_connect_signal (provider->proxy, "PositionChanged", @@ -116,7 +116,7 @@ geoclue_position_class_init (GeocluePositionClass *klass) o_class->constructor = constructor; g_type_class_add_private (klass, sizeof (GeocluePositionPrivate)); - + /** * GeocluePosition::position-changed: * @position: the #GeocluePosition object emitting the signal @@ -126,7 +126,7 @@ geoclue_position_class_init (GeocluePositionClass *klass) * @longitude: Longitude in degrees * @altitude: Altitude in meters * @accuracy: Accuracy of measurement as #GeoclueAccuracy - * + * * The position-changed signal is emitted each time the position changes. Clients should note * that not all providers support signals. */ @@ -134,7 +134,7 @@ geoclue_position_class_init (GeocluePositionClass *klass) G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GeocluePositionClass, position_changed), + G_STRUCT_OFFSET (GeocluePositionClass, position_changed), NULL, NULL, geoclue_marshal_VOID__INT_INT_DOUBLE_DOUBLE_DOUBLE_BOXED, G_TYPE_NONE, 6, @@ -154,7 +154,7 @@ geoclue_position_init (GeocluePosition *position) * @path: D-Bus path name * * Creates a #GeocluePosition with given D-Bus service name and path. - * + * * Return value: Pointer to a new #GeocluePosition */ GeocluePosition * @@ -177,15 +177,15 @@ geoclue_position_new (const char *service, * @altitude: Pointer to returned altitude in meters or %NULL * @accuracy: Pointer to returned #GeoclueAccuracy or %NULL * @error: Pointer to returned #Gerror or %NULL - * - * Obtains the current position. @timestamp will contain the time of + * + * Obtains the current position. @timestamp will contain the time of * the actual position measurement. @accuracy is a rough estimate of the * accuracy of the current position. - * - * If the caller is not interested in some values, the pointers can be + * + * If the caller is not interested in some values, the pointers can be * left %NULL. - * - * Return value: A #GeocluePositionFields bitfield representing the + * + * Return value: A #GeocluePositionFields bitfield representing the * validity of the position values. */ GeocluePositionFields @@ -239,7 +239,7 @@ typedef struct _GeocluePositionAsyncData { } GeocluePositionAsyncData; static void -get_position_async_callback (DBusGProxy *proxy, +get_position_async_callback (DBusGProxy *proxy, GeocluePositionFields fields, int timestamp, double latitude, @@ -272,7 +272,7 @@ get_position_async_callback (DBusGProxy *proxy, * @accuracy: Accuracy of measurement as #GeoclueAccuracy * @error: Error as #Gerror or %NULL * @userdata: User data pointer set in geoclue_position_get_position_async() - * + * * Callback function for geoclue_position_get_position_async(). */ @@ -281,23 +281,23 @@ get_position_async_callback (DBusGProxy *proxy, * @position: A #GeocluePosition object * @callback: A #GeocluePositionCallback function that should be called when return values are available * @userdata: pointer for user specified data - * + * * Function returns (essentially) immediately and calls @callback when current position * is available or when D-Bus timeouts. */ -void +void geoclue_position_get_position_async (GeocluePosition *position, GeocluePositionCallback callback, gpointer userdata) { GeoclueProvider *provider = GEOCLUE_PROVIDER (position); GeocluePositionAsyncData *data; - + data = g_new (GeocluePositionAsyncData, 1); data->position = position; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_Position_get_position_async (provider->proxy, (org_freedesktop_Geoclue_Position_get_position_reply)get_position_async_callback, diff --git a/geoclue/geoclue-position.h b/geoclue/geoclue-position.h old mode 100644 new mode 100755 index 3d95672..da89a86 --- a/geoclue/geoclue-position.h +++ b/geoclue/geoclue-position.h @@ -1,6 +1,6 @@ /* * Geoclue - * geoclue-position.h - + * geoclue-position.h - * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries diff --git a/geoclue/geoclue-provider.c b/geoclue/geoclue-provider.c index 4f1d70a..4480e2f 100644 --- a/geoclue/geoclue-provider.c +++ b/geoclue/geoclue-provider.c @@ -40,8 +40,8 @@ * GeocluePosition *pos; * char *name; * GError *error; - * - * pos = geoclue_position_new ("org.freedesktop.Geoclue.Providers.Example", + * + * pos = geoclue_position_new ("org.freedesktop.Geoclue.Providers.Example", * "/org/freedesktop/Geoclue/Providers/Example"); * * if (geoclue_provider_get_provider_info (GEOCLUE_PROVIDER (pos), @@ -50,7 +50,7 @@ * } * * - * + * * #GeoclueProvider can be used to obtain generic * information about the provider and to set provider * options. @@ -67,7 +67,7 @@ typedef struct _GeoclueProviderAsyncData { typedef struct _GeoclueProviderPrivate { DBusGProxy *geoclue_proxy; - + char *service; char *path; char *interface; @@ -122,11 +122,11 @@ static void finalize (GObject *object) { GeoclueProviderPrivate *priv = GET_PRIVATE (object); - + g_free (priv->service); g_free (priv->path); g_free (priv->interface); - + G_OBJECT_CLASS (geoclue_provider_parent_class)->finalize (object); } @@ -135,7 +135,7 @@ dispose (GObject *object) { GeoclueProvider *provider = GEOCLUE_PROVIDER (object); GeoclueProviderPrivate *priv = GET_PRIVATE (object); - + org_freedesktop_Geoclue_remove_reference_async (priv->geoclue_proxy, remove_reference_callback, NULL); @@ -143,12 +143,12 @@ dispose (GObject *object) g_object_unref (priv->geoclue_proxy); priv->geoclue_proxy = NULL; } - + if (provider->proxy) { g_object_unref (provider->proxy); provider->proxy = NULL; } - + G_OBJECT_CLASS (geoclue_provider_parent_class)->dispose (object); } @@ -162,12 +162,12 @@ constructor (GType type, GeoclueProviderPrivate *priv; DBusGConnection *connection; GError *error = NULL; - + object = G_OBJECT_CLASS (geoclue_provider_parent_class)->constructor (type, n_props, props); provider = GEOCLUE_PROVIDER (object); priv = GET_PRIVATE (provider); - + // There is a crash due to DBUS_BUS_SESSION //connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); @@ -178,18 +178,18 @@ constructor (GType type, g_error_free (error); provider->proxy = NULL; priv->geoclue_proxy = NULL; - + return object; } - + /* proxy for the requested interface */ - provider->proxy = dbus_g_proxy_new_for_name (connection, - priv->service, priv->path, + provider->proxy = dbus_g_proxy_new_for_name (connection, + priv->service, priv->path, priv->interface); - + /* proxy for org.freedesktop.Geoclue */ - priv->geoclue_proxy = dbus_g_proxy_new_for_name (connection, - priv->service, priv->path, + priv->geoclue_proxy = dbus_g_proxy_new_for_name (connection, + priv->service, priv->path, GEOCLUE_INTERFACE_NAME); org_freedesktop_Geoclue_add_reference_async (priv->geoclue_proxy, add_reference_callback, @@ -199,10 +199,10 @@ constructor (GType type, dbus_g_proxy_connect_signal (priv->geoclue_proxy, "StatusChanged", G_CALLBACK (status_changed), object, NULL); - + return object; } - + static void set_property (GObject *object, guint prop_id, @@ -210,20 +210,20 @@ set_property (GObject *object, GParamSpec *pspec) { GeoclueProviderPrivate *priv = GET_PRIVATE (object); - + switch (prop_id) { case PROP_SERVICE: priv->service = g_value_dup_string (value); break; - + case PROP_PATH: priv->path = g_value_dup_string (value); break; - + case PROP_INTERFACE: priv->interface = g_value_dup_string (value); break; - + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -246,15 +246,15 @@ static void geoclue_provider_class_init (GeoclueProviderClass *klass) { GObjectClass *o_class = (GObjectClass *) klass; - + o_class->finalize = finalize; o_class->dispose = dispose; o_class->constructor = constructor; o_class->set_property = set_property; o_class->get_property = get_property; - + g_type_class_add_private (klass, sizeof (GeoclueProviderPrivate)); - + g_object_class_install_property (o_class, PROP_SERVICE, g_param_spec_string ("service", "Service", @@ -282,7 +282,7 @@ geoclue_provider_class_init (GeoclueProviderClass *klass) G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_STATIC_NAME)); - + /** * GeoclueProvider::status-changed: * @provider: the provider object emitting the signal @@ -295,7 +295,7 @@ geoclue_provider_class_init (GeoclueProviderClass *klass) G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GeoclueProviderClass, status_changed), + G_STRUCT_OFFSET (GeoclueProviderClass, status_changed), NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); @@ -306,7 +306,7 @@ static void geoclue_provider_init (GeoclueProvider *provider) { GeoclueProviderPrivate *priv = GET_PRIVATE (provider); - + provider->proxy = NULL; priv->geoclue_proxy = NULL; } @@ -316,9 +316,9 @@ geoclue_provider_init (GeoclueProvider *provider) * @provider: A #GeoclueProvider object * @status: Pointer for returned status as #GeoclueStatus * @error: Pointer for returned #GError or %NULL - * + * * Obtains the current status of the provider. - * + * * Return value: %TRUE on success */ gboolean @@ -328,12 +328,12 @@ geoclue_provider_get_status (GeoclueProvider *provider, { GeoclueProviderPrivate *priv = GET_PRIVATE (provider); int i; - + if (status == NULL) { return TRUE; } - - if (!org_freedesktop_Geoclue_get_status (priv->geoclue_proxy, + + if (!org_freedesktop_Geoclue_get_status (priv->geoclue_proxy, &i, error)) { return FALSE; } @@ -342,9 +342,9 @@ geoclue_provider_get_status (GeoclueProvider *provider, } static void -get_status_async_callback (DBusGProxy *proxy, - GeoclueStatus status, - GError *error, +get_status_async_callback (DBusGProxy *proxy, + GeoclueStatus status, + GError *error, GeoclueProviderAsyncData *data) { (*(GeoclueProviderStatusCallback)data->callback) (data->provider, @@ -352,7 +352,7 @@ get_status_async_callback (DBusGProxy *proxy, error, data->userdata); g_free (data); - + } /** @@ -361,7 +361,7 @@ get_status_async_callback (DBusGProxy *proxy, * @status: A #GeoclueStatus * @error: Error as #GError or %NULL * @userdata: User data pointer set in geoclue_provider_get_status_async() - * + * * Callback function for geoclue_provider_get_status_async(). */ @@ -370,24 +370,24 @@ get_status_async_callback (DBusGProxy *proxy, * @provider: A #GeoclueProvider object * @callback: A #GeoclueProviderStatusCallback function that will be called when return values are available * @userdata: pointer for user specified data - * - * Asynchronous version of geoclue_provider_get_status(). Function returns - * (essentially) immediately and calls @callback when status is available or + * + * Asynchronous version of geoclue_provider_get_status(). Function returns + * (essentially) immediately and calls @callback when status is available or * when there is an error. */ -void +void geoclue_provider_get_status_async (GeoclueProvider *provider, GeoclueProviderStatusCallback callback, gpointer userdata) { GeoclueProviderPrivate *priv = GET_PRIVATE (provider); GeoclueProviderAsyncData *data; - + data = g_new (GeoclueProviderAsyncData, 1); data->provider = provider; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_get_status_async (priv->geoclue_proxy, (org_freedesktop_Geoclue_get_status_reply)get_status_async_callback, @@ -411,18 +411,18 @@ geoclue_provider_set_options (GeoclueProvider *provider, GError **error) { GeoclueProviderPrivate *priv = GET_PRIVATE (provider); - + if (options == NULL) { return TRUE; } - - return org_freedesktop_Geoclue_set_options (priv->geoclue_proxy, + + return org_freedesktop_Geoclue_set_options (priv->geoclue_proxy, options, error); } static void -set_options_async_callback (DBusGProxy *proxy, - GError *error, +set_options_async_callback (DBusGProxy *proxy, + GError *error, GeoclueProviderAsyncData *data) { (*(GeoclueProviderOptionsCallback)data->callback) (data->provider, @@ -436,7 +436,7 @@ set_options_async_callback (DBusGProxy *proxy, * @provider: A #GeoclueProvider object * @error: Error as #GError or %NULL * @userdata: User data pointer set in geoclue_provider_set_options_async() - * + * * Callback function for geoclue_provider_set_options_async(). */ @@ -446,12 +446,12 @@ set_options_async_callback (DBusGProxy *proxy, * @options: A #GHashTable of options * @callback: A #GeoclueProviderOptionsCallback function that will be called when options are set * @userdata: pointer for user specified data - * - * Asynchronous version of geoclue_provider_set_options(). Function returns - * (essentially) immediately and calls @callback when options have been set or + * + * Asynchronous version of geoclue_provider_set_options(). Function returns + * (essentially) immediately and calls @callback when options have been set or * when there is an error. */ -void +void geoclue_provider_set_options_async (GeoclueProvider *provider, GHashTable *options, GeoclueProviderOptionsCallback callback, @@ -459,12 +459,12 @@ geoclue_provider_set_options_async (GeoclueProvider *provider, { GeoclueProviderPrivate *priv = GET_PRIVATE (provider); GeoclueProviderAsyncData *data; - + data = g_new (GeoclueProviderAsyncData, 1); data->provider = provider; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_set_options_async (priv->geoclue_proxy, options, @@ -478,9 +478,9 @@ geoclue_provider_set_options_async (GeoclueProvider *provider, * @name: Pointer for returned provider name or %NULL * @description: Pointer for returned provider description or %NULL * @error: Pointer for returned #GError or %NULL - * + * * Obtains name and a short description of the provider. - * + * * Return value: %TRUE on success */ gboolean @@ -490,17 +490,17 @@ geoclue_provider_get_provider_info (GeoclueProvider *provider, GError **error) { GeoclueProviderPrivate *priv = GET_PRIVATE (provider); - + return org_freedesktop_Geoclue_get_provider_info (priv->geoclue_proxy, name, description, error); } static void -get_provider_info_async_callback (DBusGProxy *proxy, +get_provider_info_async_callback (DBusGProxy *proxy, char *name, char *description, - GError *error, + GError *error, GeoclueProviderAsyncData *data) { (*(GeoclueProviderInfoCallback)data->callback) (data->provider, @@ -518,7 +518,7 @@ get_provider_info_async_callback (DBusGProxy *proxy, * @description: one-line description of the provider * @error: Error as #GError or %NULL * @userdata: User data pointer set in geoclue_provider_get_provider_info_async() - * + * * Callback function for geoclue_provider_get_provider_info_async(). */ @@ -527,24 +527,24 @@ get_provider_info_async_callback (DBusGProxy *proxy, * @provider: A #GeoclueProvider object * @callback: A #GeoclueProviderInfoCallback function that will be called when info is available * @userdata: pointer for user specified data - * - * Asynchronous version of geoclue_provider_get_provider_info(). Function returns - * (essentially) immediately and calls @callback when info is available or + * + * Asynchronous version of geoclue_provider_get_provider_info(). Function returns + * (essentially) immediately and calls @callback when info is available or * when there is an error. */ -void +void geoclue_provider_get_provider_info_async (GeoclueProvider *provider, GeoclueProviderInfoCallback callback, gpointer userdata) { GeoclueProviderPrivate *priv = GET_PRIVATE (provider); GeoclueProviderAsyncData *data; - + data = g_new (GeoclueProviderAsyncData, 1); data->provider = provider; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_get_provider_info_async (priv->geoclue_proxy, (org_freedesktop_Geoclue_get_provider_info_reply)get_provider_info_async_callback, diff --git a/geoclue/geoclue-provider.h b/geoclue/geoclue-provider.h old mode 100644 new mode 100755 index 811f099..65b7906 --- a/geoclue/geoclue-provider.h +++ b/geoclue/geoclue-provider.h @@ -1,4 +1,4 @@ -/* +/* * Geoclue * geoclue-provider.h - Client object for accessing Geoclue Providers * @@ -40,13 +40,13 @@ G_BEGIN_DECLS typedef struct _GeoclueProvider { GObject object; - + DBusGProxy *proxy; } GeoclueProvider; typedef struct _GeoclueProviderClass { GObjectClass object_class; - + void (*status_changed) (GeoclueProvider *provider, GeoclueStatus status); } GeoclueProviderClass; diff --git a/geoclue/geoclue-reverse-geocode.c b/geoclue/geoclue-reverse-geocode.c old mode 100644 new mode 100755 index 8ce6bf9..345859a --- a/geoclue/geoclue-reverse-geocode.c +++ b/geoclue/geoclue-reverse-geocode.c @@ -26,14 +26,14 @@ * SECTION:geoclue-reverse-geocode * @short_description: Geoclue reverse geocode client API * - * #GeoclueReverseGeocode contains reverse geocoding methods. - * It is part of the Geoclue public C client API which uses D-Bus + * #GeoclueReverseGeocode contains reverse geocoding methods. + * It is part of the Geoclue public C client API which uses D-Bus * to communicate with the actual provider. - * - * After a #GeoclueReverseGeocode is created with - * geoclue_reverse_geocode_new(), the - * geoclue_reverse_geocode_position_to_address() and - * geoclue_reverse_geocode_position_to_address_async() method can be used to + * + * After a #GeoclueReverseGeocode is created with + * geoclue_reverse_geocode_new(), the + * geoclue_reverse_geocode_position_to_address() and + * geoclue_reverse_geocode_position_to_address_async() method can be used to * obtain the address of a known position. */ @@ -84,7 +84,7 @@ geoclue_reverse_geocode_init (GeoclueReverseGeocode *geocode) * @path: D-Bus path name * * Creates a #GeoclueReverseGeocode with given D-Bus service name and path. - * + * * Return value: Pointer to a new #GeoclueReverseGeocode */ GeoclueReverseGeocode * @@ -105,17 +105,17 @@ geoclue_reverse_geocode_new (const char *service, * @longitude: longitude in degrees * @position_accuracy: Accuracy of the given latitude and longitude * @details: Pointer to returned #GHashTable with address details or %NULL - * @address_accuracy: Pointer to accuracy of the returned address or %NULL + * @address_accuracy: Pointer to accuracy of the returned address or %NULL * @error: Pointer to returned #Gerror or %NULL - * + * * Obtains an address for the position defined by @latitude and @longitude. - * @details is a #GHashTable with the returned address data, see + * @details is a #GHashTable with the returned address data, see * geoclue-types.h for the hashtable keys. - * - * If the caller is not interested in some values, the pointers can be + * + * If the caller is not interested in some values, the pointers can be * left %NULL. If accuracy of the position is not known, an accuracy with * GeoclueAccuracyLevel GEOCLUE_ACCURACY_DETAILED should be used. - * + * * Return value: %TRUE if there is no @error */ gboolean @@ -128,9 +128,9 @@ geoclue_reverse_geocode_position_to_address (GeoclueReverseGeocode *geocode, GError **error) { GeoclueProvider *provider = GEOCLUE_PROVIDER (geocode); - - return org_freedesktop_Geoclue_ReverseGeocode_position_to_address - (provider->proxy, latitude, longitude, position_accuracy, + + return org_freedesktop_Geoclue_ReverseGeocode_position_to_address + (provider->proxy, latitude, longitude, position_accuracy, details, address_accuracy, error); } @@ -142,7 +142,7 @@ typedef struct _GeoclueRevGeocodeAsyncData { } GeoclueRevGeocodeAsyncData; static void -position_to_address_callback (DBusGProxy *proxy, +position_to_address_callback (DBusGProxy *proxy, GHashTable *details, GeoclueAccuracy *accuracy, GError *error, @@ -163,10 +163,10 @@ position_to_address_callback (DBusGProxy *proxy, * @accuracy: Accuracy of measurement as #GeoclueAccuracy * @error: Error as #Gerror (may be %NULL) * @userdata: User data pointer set in geoclue_reverse_geocode_position_to_address_async() - * + * * Callback function for geoclue_reverse_geocode_position_to_address_async(). - * - * see geoclue-types.h for the + * + * see geoclue-types.h for the * hashtable keys used in @details. */ @@ -178,11 +178,11 @@ position_to_address_callback (DBusGProxy *proxy, * @accuracy: Accuracy of the given position as #GeoclueAccuracy * @callback: A #GeoclueAddressCallback function that should be called when return values are available * @userdata: pointer for user specified data - * - * Function returns (essentially) immediately and calls @callback when the reverse-geocoded + * + * Function returns (essentially) immediately and calls @callback when the reverse-geocoded * address data is available or when D-Bus timeouts. */ -void +void geoclue_reverse_geocode_position_to_address_async (GeoclueReverseGeocode *revgeocode, double latitude, double longitude, @@ -192,12 +192,12 @@ geoclue_reverse_geocode_position_to_address_async (GeoclueReverseGeocode { GeoclueProvider *provider = GEOCLUE_PROVIDER (revgeocode); GeoclueRevGeocodeAsyncData *data; - + data = g_new (GeoclueRevGeocodeAsyncData, 1); data->revgeocode = revgeocode; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_ReverseGeocode_position_to_address_async (provider->proxy, latitude, diff --git a/geoclue/geoclue-reverse-geocode.h b/geoclue/geoclue-reverse-geocode.h old mode 100644 new mode 100755 index 2c898e7..cee34ec --- a/geoclue/geoclue-reverse-geocode.h +++ b/geoclue/geoclue-reverse-geocode.h @@ -1,6 +1,6 @@ /* * Geoclue - * geoclue-reverse-geocode.h - + * geoclue-reverse-geocode.h - * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries @@ -50,7 +50,7 @@ GType geoclue_reverse_geocode_get_type (void); GeoclueReverseGeocode *geoclue_reverse_geocode_new (const char *service, const char *path); -gboolean +gboolean geoclue_reverse_geocode_position_to_address (GeoclueReverseGeocode *revgeocode, double latitude, double longitude, diff --git a/geoclue/geoclue-satellite-info.h b/geoclue/geoclue-satellite-info.h index f0a6a0c..99818a3 100644 --- a/geoclue/geoclue-satellite-info.h +++ b/geoclue/geoclue-satellite-info.h @@ -2,7 +2,7 @@ * Geoclue * gc-iface-satellite.c - GInterface for org.freedesktop.Geoclue.Satellite * - * Author: Sagnho Park , Youngae Kang , + * Author: Sagnho Park , Youngae Kang , * Yunhan Kim , Genie Kim * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * diff --git a/geoclue/geoclue-satellite.c b/geoclue/geoclue-satellite.c index a412026..de38d0d 100644 --- a/geoclue/geoclue-satellite.c +++ b/geoclue/geoclue-satellite.c @@ -2,7 +2,7 @@ * Geoclue * geoclue-satellite.c - Client API for accessing GcIfaceSatellite * - * Author: Sagnho Park , Youngae Kang , + * Author: Sagnho Park , Youngae Kang , * Yunhan Kim , Genie Kim * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * @@ -103,7 +103,7 @@ geoclue_satellite_class_init (GeoclueSatelliteClass *klass) o_class->constructor = constructor; g_type_class_add_private (klass, sizeof (GeoclueSatellitePrivate)); - + signals[SATELLITE_CHANGED] = g_signal_new ("satellite-changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | @@ -180,19 +180,19 @@ get_satellite_async_callback (DBusGProxy *proxy, g_free (data); } -void +void geoclue_satellite_get_satellite_async (GeoclueSatellite *satellite, GeoclueSatelliteCallback callback, gpointer userdata) { GeoclueProvider *provider = GEOCLUE_PROVIDER (satellite); GeoclueSatelliteAsyncData *data; - + data = g_new (GeoclueSatelliteAsyncData, 1); data->satellite = satellite; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_Satellite_get_satellite_async (provider->proxy, (org_freedesktop_Geoclue_Satellite_get_satellite_reply)get_satellite_async_callback, data); diff --git a/geoclue/geoclue-satellite.h b/geoclue/geoclue-satellite.h index 28e8555..eb381cb 100644 --- a/geoclue/geoclue-satellite.h +++ b/geoclue/geoclue-satellite.h @@ -1,8 +1,8 @@ /* * Geoclue - * geoclue-satellite.h - + * geoclue-satellite.h - * - * Author: Sagnho Park , Youngae Kang , + * Author: Sagnho Park , Youngae Kang , * Yunhan Kim , Genie Kim * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * diff --git a/geoclue/geoclue-types.c b/geoclue/geoclue-types.c index 6ba6b3d..ef14292 100644 --- a/geoclue/geoclue-types.c +++ b/geoclue/geoclue-types.c @@ -1,6 +1,6 @@ /* * Geoclue - * geoclue-types.c - + * geoclue-types.c - * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries @@ -39,7 +39,7 @@ geoclue_types_init (void) G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_INVALID); - + dbus_g_object_register_marshaller (geoclue_marshal_VOID__INT_INT_DOUBLE_DOUBLE_DOUBLE_BOXED, G_TYPE_NONE, G_TYPE_INT, @@ -49,14 +49,14 @@ geoclue_types_init (void) G_TYPE_DOUBLE, G_TYPE_BOXED, G_TYPE_INVALID); - + dbus_g_object_register_marshaller (geoclue_marshal_VOID__INT_BOXED_BOXED, G_TYPE_NONE, G_TYPE_INT, G_TYPE_BOXED, G_TYPE_BOXED, G_TYPE_INVALID); - + dbus_g_object_register_marshaller (geoclue_marshal_VOID__STRING_STRING_STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, diff --git a/geoclue/geoclue-types.h b/geoclue/geoclue-types.h index 9ecbc40..6d4f892 100644 --- a/geoclue/geoclue-types.h +++ b/geoclue/geoclue-types.h @@ -29,13 +29,13 @@ /** * SECTION:geoclue-types - * @short_description: Type definitions and defines useful for Geoclue clients + * @short_description: Type definitions and defines useful for Geoclue clients **/ /** * GeoclueStatus - * + * * defines the provider status **/ typedef enum { @@ -48,7 +48,7 @@ typedef enum { /** * GeoclueAccuracyLevel: * - * Enum values used to define the approximate accuracy of + * Enum values used to define the approximate accuracy of * Position or Address information. **/ typedef enum { @@ -64,15 +64,15 @@ typedef enum { /** * GeocluePositionFields: * - * #GeocluePositionFields is a bitfield that defines the validity of + * #GeocluePositionFields is a bitfield that defines the validity of * Position values. - * + * * Example: * * * GeocluePositionFields fields; * fields = geoclue_position_get_position (. . .); - * + * * if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && * fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { * g_print("latitude and longitude are valid"); @@ -90,7 +90,7 @@ typedef enum { /** * GeoclueVelocityFields: * - * GeoclueVelocityFields is a bitfield that defines the validity of + * GeoclueVelocityFields is a bitfield that defines the validity of * Velocity values. **/ typedef enum { @@ -102,55 +102,55 @@ typedef enum { /** * GEOCLUE_ADDRESS_KEY_COUNTRYCODE: - * - * A key for address hashtables. The hash value should be a ISO 3166 two - * letter country code. - * - * The used hash keys match the elements of XEP-0080 (XMPP protocol - * extension for user location), see + * + * A key for address hashtables. The hash value should be a ISO 3166 two + * letter country code. + * + * The used hash keys match the elements of XEP-0080 (XMPP protocol + * extension for user location), see * * http://www.xmpp.org/extensions/xep-0080.html */ #define GEOCLUE_ADDRESS_KEY_COUNTRYCODE "countrycode" /** * GEOCLUE_ADDRESS_KEY_COUNTRY: - * - * A key for address hashtables. The hash value should be a name of a country. + * + * A key for address hashtables. The hash value should be a name of a country. */ #define GEOCLUE_ADDRESS_KEY_COUNTRY "country" /** * GEOCLUE_ADDRESS_KEY_REGION: - * - * A key for address hashtables. The hash value should be a name of an + * + * A key for address hashtables. The hash value should be a name of an * administrative region of a nation, e.g. province or - * US state. + * US state. */ -#define GEOCLUE_ADDRESS_KEY_REGION "region" +#define GEOCLUE_ADDRESS_KEY_REGION "region" /** * GEOCLUE_ADDRESS_KEY_LOCALITY: - * - * A key for address hashtables. The hash value should be a name of a town - * or city. + * + * A key for address hashtables. The hash value should be a name of a town + * or city. */ #define GEOCLUE_ADDRESS_KEY_LOCALITY "locality" /** * GEOCLUE_ADDRESS_KEY_AREA: - * - * A key for address hashtables. The hash value should be a name of an - * area, such as neighborhood or campus. + * + * A key for address hashtables. The hash value should be a name of an + * area, such as neighborhood or campus. */ #define GEOCLUE_ADDRESS_KEY_AREA "area" /** * GEOCLUE_ADDRESS_KEY_POSTALCODE: - * - * A key for address hashtables. The hash value should be a code used for + * + * A key for address hashtables. The hash value should be a code used for * postal delivery. */ #define GEOCLUE_ADDRESS_KEY_POSTALCODE "postalcode" /** * GEOCLUE_ADDRESS_KEY_STREET: - * - * A key for address hashtables. The hash value should be a partial or full street + * + * A key for address hashtables. The hash value should be a partial or full street * address. */ #define GEOCLUE_ADDRESS_KEY_STREET "street" @@ -158,15 +158,15 @@ typedef enum { /** * GeoclueResourceFlags: * - * bitfield that represents a set of physical resources. - * + * bitfield that represents a set of physical resources. + * **/ typedef enum _GeoclueResourceFlags { GEOCLUE_RESOURCE_NONE = 0, GEOCLUE_RESOURCE_NETWORK = 1 << 0, GEOCLUE_RESOURCE_CELL = 1 << 1, GEOCLUE_RESOURCE_GPS = 1 << 2, - + GEOCLUE_RESOURCE_ALL = (1 << 10) - 1 } GeoclueResourceFlags; @@ -174,8 +174,8 @@ typedef enum _GeoclueResourceFlags { /** * GeoclueNetworkStatus: * - * Enumeration for current network status. - * + * Enumeration for current network status. + * **/ typedef enum { GEOCLUE_CONNECTIVITY_UNKNOWN, diff --git a/geoclue/geoclue-velocity.c b/geoclue/geoclue-velocity.c old mode 100644 new mode 100755 index 521d4ab..06abefd --- a/geoclue/geoclue-velocity.c +++ b/geoclue/geoclue-velocity.c @@ -26,12 +26,12 @@ * SECTION:geoclue-velocity * @short_description: Geoclue velocity client API * - * #GeoclueVelocity contains velocity-related methods and signals. - * It is part of the Geoclue public C client API which uses D-Bus + * #GeoclueVelocity contains velocity-related methods and signals. + * It is part of the Geoclue public C client API which uses D-Bus * to communicate with the actual provider. - * - * After a #GeoclueVelocity is created with - * geoclue_velocity_new(), the + * + * After a #GeoclueVelocity is created with + * geoclue_velocity_new(), the * geoclue_velocity_get_velocity() method and the VelocityChanged-signal * can be used to obtain the current velocity. */ @@ -89,7 +89,7 @@ constructor (GType type, GObject *object; GeoclueProvider *provider; - object = G_OBJECT_CLASS (geoclue_velocity_parent_class)->constructor + object = G_OBJECT_CLASS (geoclue_velocity_parent_class)->constructor (type, n_props, props); provider = GEOCLUE_PROVIDER (object); @@ -113,7 +113,7 @@ geoclue_velocity_class_init (GeoclueVelocityClass *klass) o_class->constructor = constructor; g_type_class_add_private (klass, sizeof (GeoclueVelocityPrivate)); - + /** * GeoclueVelocity::velocity-changed: * @velocity: the #GeoclueVelocity object emitting the signal @@ -122,9 +122,9 @@ geoclue_velocity_class_init (GeoclueVelocityClass *klass) * @speed: horizontal speed * @direction: horizontal direction (bearing) * @climb: vertical speed - * - * The geoclue-changed signal is emitted each time the velocity changes. - * + * + * The geoclue-changed signal is emitted each time the velocity changes. + * * Note that not all providers support signals. */ signals[VELOCITY_CHANGED] = g_signal_new ("velocity-changed", @@ -132,7 +132,7 @@ geoclue_velocity_class_init (GeoclueVelocityClass *klass) G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, G_STRUCT_OFFSET (GeoclueVelocityClass, velocity_changed), - NULL, NULL, + NULL, NULL, geoclue_marshal_VOID__INT_INT_DOUBLE_DOUBLE_DOUBLE, G_TYPE_NONE, 5, G_TYPE_INT, G_TYPE_INT, @@ -146,7 +146,7 @@ geoclue_velocity_class_init (GeoclueVelocityClass *klass) * @path: D-Bus path name * * Creates a #GeoclueVelocity with given D-Bus service name and path. - * + * * Return value: Pointer to a new #GeoclueVelocity */ static void @@ -174,13 +174,13 @@ geoclue_velocity_new (const char *service, * @climb: Pointer to returned vertical speed or %NULL * @error: Pointer to returned #GError or %NULL * - * Obtains the current velocity. @timestamp will contain the time of + * Obtains the current velocity. @timestamp will contain the time of * the actual velocity measurement. - * - * If the caller is not interested in some values, the pointers can be + * + * If the caller is not interested in some values, the pointers can be * left %NULL. - * - * Return value: A #GeoclueVelocityFields bitfield representing the + * + * Return value: A #GeoclueVelocityFields bitfield representing the * validity of the velocity values. */ GeoclueVelocityFields @@ -228,7 +228,7 @@ typedef struct _GeoclueVelocityAsyncData { } GeoclueVelocityAsyncData; static void -get_velocity_async_callback (DBusGProxy *proxy, +get_velocity_async_callback (DBusGProxy *proxy, GeoclueVelocityFields fields, int timestamp, double speed, @@ -258,7 +258,7 @@ get_velocity_async_callback (DBusGProxy *proxy, * @climb: Vertical speed * @error: Error as #GError (may be %NULL) * @userdata: User data pointer set in geoclue_velocity_get_velocity_async() - * + * * Callback function for geoclue_velocity_get_velocity_async(). */ @@ -267,23 +267,23 @@ get_velocity_async_callback (DBusGProxy *proxy, * @velocity: A #GeoclueVelocity object * @callback: A #GeoclueVelocityCallback function that should be called when return values are available * @userdata: pointer for user specified data - * + * * Function returns (essentially) immediately and calls @callback when current velocity * is available or when D-Bus timeouts. */ -void +void geoclue_velocity_get_velocity_async (GeoclueVelocity *velocity, GeoclueVelocityCallback callback, gpointer userdata) { GeoclueProvider *provider = GEOCLUE_PROVIDER (velocity); GeoclueVelocityAsyncData *data; - + data = g_new (GeoclueVelocityAsyncData, 1); data->velocity = velocity; data->callback = G_CALLBACK (callback); data->userdata = userdata; - + org_freedesktop_Geoclue_Velocity_get_velocity_async (provider->proxy, (org_freedesktop_Geoclue_Velocity_get_velocity_reply)get_velocity_async_callback, diff --git a/geoclue/geoclue-velocity.h b/geoclue/geoclue-velocity.h old mode 100644 new mode 100755 index fa6361b..2d33e08 --- a/geoclue/geoclue-velocity.h +++ b/geoclue/geoclue-velocity.h @@ -1,6 +1,6 @@ /* * Geoclue - * geoclue-velocity.h - + * geoclue-velocity.h - * * Author: Iain Holmes * Copyright 2007 by Garmin Ltd. or its subsidiaries diff --git a/interfaces/gc-iface-address-full.xml b/interfaces/gc-iface-address-full.xml old mode 100644 new mode 100755 index a3ed6fe..2357d84 --- a/interfaces/gc-iface-address-full.xml +++ b/interfaces/gc-iface-address-full.xml @@ -4,7 +4,7 @@ - + diff --git a/interfaces/gc-iface-geoclue-full.xml b/interfaces/gc-iface-geoclue-full.xml index 7543955..f290e8b 100644 --- a/interfaces/gc-iface-geoclue-full.xml +++ b/interfaces/gc-iface-geoclue-full.xml @@ -1,14 +1,14 @@ - + - Geoclue interface contains methods + Geoclue interface contains methods and signals common to all providers (and all providers must implement at least this interface). - + @@ -21,7 +21,7 @@ - + @@ -41,18 +41,18 @@ - + - Increase the reference count on the provider. - Provider may shutdown if reference count reaches zero, so + Increase the reference count on the provider. + Provider may shutdown if reference count reaches zero, so using AddReference()/RemoveReference is important for clients needing server persistence -- basically any client that uses SetOptions() or connects to signals. - + Decrease the reference count on the provider diff --git a/interfaces/gc-iface-geocode-full.xml b/interfaces/gc-iface-geocode-full.xml old mode 100644 new mode 100755 index 42e5683..5bec1c5 --- a/interfaces/gc-iface-geocode-full.xml +++ b/interfaces/gc-iface-geocode-full.xml @@ -1,7 +1,7 @@ - + diff --git a/interfaces/gc-iface-master-client-full.xml b/interfaces/gc-iface-master-client-full.xml old mode 100644 new mode 100755 index 050a707..647b4fd --- a/interfaces/gc-iface-master-client-full.xml +++ b/interfaces/gc-iface-master-client-full.xml @@ -8,10 +8,10 @@ - + - + @@ -24,7 +24,7 @@ - + diff --git a/interfaces/gc-iface-master-full.xml b/interfaces/gc-iface-master-full.xml old mode 100644 new mode 100755 index 172e5ec..4cfec4e --- a/interfaces/gc-iface-master-full.xml +++ b/interfaces/gc-iface-master-full.xml @@ -1,7 +1,7 @@ - + diff --git a/interfaces/gc-iface-nmea-full.xml b/interfaces/gc-iface-nmea-full.xml index 32a9bfa..2ef91aa 100644 --- a/interfaces/gc-iface-nmea-full.xml +++ b/interfaces/gc-iface-nmea-full.xml @@ -1,13 +1,13 @@ - + - Nmea interface contains a method + Nmea interface contains a method and a signal for querying current coordinates. - + diff --git a/interfaces/gc-iface-position-full.xml b/interfaces/gc-iface-position-full.xml old mode 100644 new mode 100755 index 5c079eb..7646605 --- a/interfaces/gc-iface-position-full.xml +++ b/interfaces/gc-iface-position-full.xml @@ -1,13 +1,13 @@ - + - Position interface contains a method + Position interface contains a method and a signal for querying current coordinates. - + diff --git a/interfaces/gc-iface-reverse-geocode-full.xml b/interfaces/gc-iface-reverse-geocode-full.xml old mode 100644 new mode 100755 index 9c4d40a..0247081 --- a/interfaces/gc-iface-reverse-geocode-full.xml +++ b/interfaces/gc-iface-reverse-geocode-full.xml @@ -1,12 +1,12 @@ - + - - + + - + diff --git a/interfaces/gc-iface-velocity-full.xml b/interfaces/gc-iface-velocity-full.xml old mode 100644 new mode 100755 diff --git a/packaging/geoclue.spec b/packaging/geoclue.spec old mode 100755 new mode 100644 index 28c350d..c60c673 --- a/packaging/geoclue.spec +++ b/packaging/geoclue.spec @@ -10,13 +10,12 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(gconf-2.0) -BuildRequires: pkgconfig(libgps) BuildRequires: pkgconfig(libxslt) %description -Geographic information framework GeoClue provides applications access to various geographical information - sources using a D-Bus API or a C library. +Geographic information framework GeoClue provides applications access to various geographical information + sources using a D-Bus API or a C library. . This package contains the master server for GeoClue. @@ -44,18 +43,6 @@ libgeoclue is a convenience wrapper for the GeoClue service, and the recommended way to use GeoClue in the C language. -%package -n geoclue-gpsd -Summary: Position server for GeoClue (GPS) -Group: TO_BE/FILLED -Requires: %{name} = %{version}-%{release} - -%description -n geoclue-gpsd -GeoClue provides applications access to various geographical information -sources using a D-Bus API or a C library. -. -This package provides a positioning backend for GeoClue. The -location information comes from a GPS receiver through gpsd - %package -n geoclue-nominatim Summary: Geocode server for GeoClue (OpenStreetMap) Group: TO_BE/FILLED @@ -105,11 +92,6 @@ rm -rf %{buildroot}/usr/bin/geoclue-test-gui #/usr/lib/libgeoclue.*a /usr/lib/libgeoclue.so -%files -n geoclue-gpsd -/usr/libexec/geoclue-gpsd -/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Gpsd.service -/usr/share/geoclue-providers/geoclue-gpsd.provider - %files -n geoclue-nominatim /usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Nominatim.service /usr/share/geoclue-providers/geoclue-nominatim.provider diff --git a/providers/example/geoclue-example.c b/providers/example/geoclue-example.c index 49d4ae3..8e71b52 100644 --- a/providers/example/geoclue-example.c +++ b/providers/example/geoclue-example.c @@ -79,7 +79,7 @@ static void shutdown (GcProvider *provider) { GeoclueExample *example = GEOCLUE_EXAMPLE (provider); - + g_main_loop_quit (example->loop); } @@ -135,9 +135,9 @@ emit_position_signal (gpointer data) accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0.0, 0.0); - - gc_iface_position_emit_position_changed - (GC_IFACE_POSITION (example), + + gc_iface_position_emit_position_changed + (GC_IFACE_POSITION (example), GEOCLUE_POSITION_FIELDS_NONE, time (NULL), 0.0, 0.0, 0.0, accuracy); diff --git a/providers/example/geoclue-example.provider b/providers/example/geoclue-example.provider old mode 100644 new mode 100755 diff --git a/providers/example/org.freedesktop.Geoclue.Providers.Example.service.in b/providers/example/org.freedesktop.Geoclue.Providers.Example.service.in old mode 100644 new mode 100755 diff --git a/providers/geonames/Makefile.am b/providers/geonames/Makefile.am index 57ae281..cf9a683 100644 --- a/providers/geonames/Makefile.am +++ b/providers/geonames/Makefile.am @@ -15,7 +15,7 @@ geoclue_geonames_CFLAGS = \ geoclue_geonames_LDADD = \ $(GEOCLUE_LIBS) \ - $(top_builddir)/geoclue/libgeoclue.la + $(top_builddir)/geoclue/libgeoclue.la providersdir = $(datadir)/geoclue-providers providers_DATA = geoclue-geonames.provider diff --git a/providers/geonames/geoclue-geonames.c b/providers/geonames/geoclue-geonames.c old mode 100644 new mode 100755 index c9c0e87..db8b28d --- a/providers/geonames/geoclue-geonames.c +++ b/providers/geonames/geoclue-geonames.c @@ -2,9 +2,9 @@ * Geoclue * geoclue-geonames.c - A geonames.org-based "Geocode" and * "Reverse geocode" provider - * + * * Copyright 2007 by Garmin Ltd. or its subsidiaries - * + * * Author: Jussi Kukkonen * * This library is free software; you can redistribute it and/or @@ -25,11 +25,11 @@ */ /* - * The used web service APIs are documented at + * The used web service APIs are documented at * http://www.geonames.org/export/ - * + * * Geonames currently does not support street level geocoding. There - * is a street level reverse geocoder in beta, but it's US only. + * is a street level reverse geocoder in beta, but it's US only. * http://www.geonames.org/export/reverse-geocoding.html */ @@ -74,7 +74,7 @@ #define ADDRESS_COUNTRY "//geonames/geoname/countryName" #define ADDRESS_COUNTRYCODE "//geonames/geoname/countryCode" - + static void geoclue_geonames_init (GeoclueGeonames *obj); static void geoclue_geonames_geocode_init (GcIfaceGeocodeClass *iface); static void geoclue_geonames_reverse_geocode_init (GcIfaceReverseGeocodeClass *iface); @@ -93,7 +93,7 @@ geoclue_geonames_get_status (GcIfaceGeoclue *iface, GeoclueStatus *status, GError **error) { - /* Assumption that we are available so long as the + /* Assumption that we are available so long as the providers requirements are met: ie network is up */ *status = GEOCLUE_STATUS_AVAILABLE; @@ -104,7 +104,7 @@ static void shutdown (GcProvider *provider) { GeoclueGeonames *obj = GEOCLUE_GEONAMES (provider); - + g_main_loop_quit (obj->loop); } @@ -123,13 +123,13 @@ geoclue_geonames_address_to_position (GcIfaceGeocode *iface, { GeoclueGeonames *obj = GEOCLUE_GEONAMES (iface); gchar *countrycode, *locality, *postalcode; - + countrycode = g_hash_table_lookup (address, GEOCLUE_ADDRESS_KEY_COUNTRYCODE); locality = g_hash_table_lookup (address, GEOCLUE_ADDRESS_KEY_LOCALITY); postalcode = g_hash_table_lookup (address, GEOCLUE_ADDRESS_KEY_POSTALCODE); - + *fields = GEOCLUE_POSITION_FIELDS_NONE; - + if (countrycode && postalcode) { if (!gc_web_service_query (obj->postalcode_geocoder, error, "postalcode", postalcode, @@ -139,12 +139,12 @@ geoclue_geonames_address_to_position (GcIfaceGeocode *iface, (char *)0)) { return FALSE; } - if (gc_web_service_get_double (obj->postalcode_geocoder, + if (gc_web_service_get_double (obj->postalcode_geocoder, latitude, POSTALCODE_LAT) && - gc_web_service_get_double (obj->postalcode_geocoder, + gc_web_service_get_double (obj->postalcode_geocoder, longitude, POSTALCODE_LON)) { - *fields |= GEOCLUE_POSITION_FIELDS_LATITUDE; - *fields |= GEOCLUE_POSITION_FIELDS_LONGITUDE; + *fields |= GEOCLUE_POSITION_FIELDS_LATITUDE; + *fields |= GEOCLUE_POSITION_FIELDS_LONGITUDE; *accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_POSTALCODE, 0, 0); } @@ -157,12 +157,12 @@ geoclue_geonames_address_to_position (GcIfaceGeocode *iface, (char *)0)) { return FALSE; } - if (gc_web_service_get_double (obj->place_geocoder, + if (gc_web_service_get_double (obj->place_geocoder, latitude, GEONAME_LAT) && - gc_web_service_get_double (obj->place_geocoder, + gc_web_service_get_double (obj->place_geocoder, longitude, GEONAME_LON)) { - *fields |= GEOCLUE_POSITION_FIELDS_LATITUDE; - *fields |= GEOCLUE_POSITION_FIELDS_LONGITUDE; + *fields |= GEOCLUE_POSITION_FIELDS_LATITUDE; + *fields |= GEOCLUE_POSITION_FIELDS_LONGITUDE; *accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_LOCALITY, 0, 0); } @@ -249,7 +249,7 @@ geoclue_geonames_position_to_address (GcIfaceReverseGeocode *iface, gchar *country = NULL; gchar *countrycode = NULL; GeoclueAccuracyLevel in_acc = GEOCLUE_ACCURACY_LEVEL_DETAILED; - + if (!address) { return TRUE; } @@ -270,14 +270,14 @@ geoclue_geonames_position_to_address (GcIfaceReverseGeocode *iface, (char *)0)) { return FALSE; } - + if (position_accuracy) { geoclue_accuracy_get_details (position_accuracy, &in_acc, NULL, NULL); } - + *address = g_hash_table_new (g_str_hash, g_str_equal); - - if (in_acc >= GEOCLUE_ACCURACY_LEVEL_COUNTRY && + + if (in_acc >= GEOCLUE_ACCURACY_LEVEL_COUNTRY && gc_web_service_get_string (obj->rev_place_geocoder, &countrycode, GEONAME_COUNTRYCODE)) { geoclue_address_details_insert (*address, @@ -287,7 +287,7 @@ geoclue_geonames_position_to_address (GcIfaceReverseGeocode *iface, geoclue_address_details_set_country_from_code (*address); } if (!g_hash_table_lookup (*address, GEOCLUE_ADDRESS_KEY_COUNTRY) && - in_acc >= GEOCLUE_ACCURACY_LEVEL_COUNTRY && + in_acc >= GEOCLUE_ACCURACY_LEVEL_COUNTRY && gc_web_service_get_string (obj->rev_place_geocoder, &country, GEONAME_COUNTRY)) { geoclue_address_details_insert (*address, @@ -295,7 +295,7 @@ geoclue_geonames_position_to_address (GcIfaceReverseGeocode *iface, country); g_free (country); } - if (in_acc >= GEOCLUE_ACCURACY_LEVEL_REGION && + if (in_acc >= GEOCLUE_ACCURACY_LEVEL_REGION && gc_web_service_get_string (obj->rev_place_geocoder, ®ion, GEONAME_ADMIN1)) { geoclue_address_details_insert (*address, @@ -303,7 +303,7 @@ geoclue_geonames_position_to_address (GcIfaceReverseGeocode *iface, region); g_free (region); } - if (in_acc >= GEOCLUE_ACCURACY_LEVEL_LOCALITY && + if (in_acc >= GEOCLUE_ACCURACY_LEVEL_LOCALITY && gc_web_service_get_string (obj->rev_place_geocoder, &locality, GEONAME_NAME)) { geoclue_address_details_insert (*address, @@ -311,8 +311,8 @@ geoclue_geonames_position_to_address (GcIfaceReverseGeocode *iface, locality); g_free (locality); } - - if (address_accuracy) { + + if (address_accuracy) { GeoclueAccuracyLevel level = geoclue_address_details_get_accuracy_level (*address); *address_accuracy = geoclue_accuracy_new (level, 0.0, 0.0); } @@ -349,7 +349,7 @@ geoclue_geonames_dispose (GObject *obj) g_object_unref (self->rev_street_geocoder); self->rev_street_geocoder = NULL; } - + ((GObjectClass *) geoclue_geonames_parent_class)->dispose (obj); } @@ -360,7 +360,7 @@ geoclue_geonames_class_init (GeoclueGeonamesClass *klass) { GcProviderClass *p_class = (GcProviderClass *)klass; GObjectClass *o_class = (GObjectClass *)klass; - + p_class->shutdown = shutdown; p_class->get_status = geoclue_geonames_get_status; @@ -371,25 +371,25 @@ geoclue_geonames_class_init (GeoclueGeonamesClass *klass) static void geoclue_geonames_init (GeoclueGeonames *obj) { - gc_provider_set_details (GC_PROVIDER (obj), + gc_provider_set_details (GC_PROVIDER (obj), GEOCLUE_GEONAMES_DBUS_SERVICE, GEOCLUE_GEONAMES_DBUS_PATH, "Geonames", "Geonames provider"); - + obj->place_geocoder = g_object_new (GC_TYPE_WEB_SERVICE, NULL); - gc_web_service_set_base_url (obj->place_geocoder, + gc_web_service_set_base_url (obj->place_geocoder, GEOCODE_PLACE_URL); - + obj->postalcode_geocoder = g_object_new (GC_TYPE_WEB_SERVICE, NULL); - gc_web_service_set_base_url (obj->postalcode_geocoder, + gc_web_service_set_base_url (obj->postalcode_geocoder, GEOCODE_POSTALCODE_URL); - + obj->rev_place_geocoder = g_object_new (GC_TYPE_WEB_SERVICE, NULL); - gc_web_service_set_base_url (obj->rev_place_geocoder, + gc_web_service_set_base_url (obj->rev_place_geocoder, REV_GEOCODE_PLACE_URL); - + obj->rev_street_geocoder = g_object_new (GC_TYPE_WEB_SERVICE, NULL); - gc_web_service_set_base_url (obj->rev_street_geocoder, + gc_web_service_set_base_url (obj->rev_street_geocoder, REV_GEOCODE_STREET_URL); } @@ -408,19 +408,19 @@ geoclue_geonames_reverse_geocode_init (GcIfaceReverseGeocodeClass *iface) iface->position_to_address = geoclue_geonames_position_to_address; } -int +int main() { GeoclueGeonames *obj; - + g_type_init(); obj = g_object_new (GEOCLUE_TYPE_GEONAMES, NULL); obj->loop = g_main_loop_new (NULL, TRUE); - + g_main_loop_run (obj->loop); - + g_main_loop_unref (obj->loop); g_object_unref (obj); - + return 0; } diff --git a/providers/geonames/geoclue-geonames.h b/providers/geonames/geoclue-geonames.h old mode 100644 new mode 100755 index 02bc0df..3468337 --- a/providers/geonames/geoclue-geonames.h +++ b/providers/geonames/geoclue-geonames.h @@ -40,10 +40,10 @@ G_BEGIN_DECLS typedef struct _GeoclueGeonames { GcProvider parent; GMainLoop *loop; - + GcWebService *place_geocoder; GcWebService *postalcode_geocoder; - + GcWebService *rev_street_geocoder; GcWebService *rev_place_geocoder; } GeoclueGeonames; diff --git a/providers/geonames/geoclue-geonames.provider b/providers/geonames/geoclue-geonames.provider old mode 100644 new mode 100755 diff --git a/providers/geonames/org.freedesktop.Geoclue.Providers.Geonames.service.in b/providers/geonames/org.freedesktop.Geoclue.Providers.Geonames.service.in old mode 100644 new mode 100755 diff --git a/providers/gpsd/Makefile.am b/providers/gpsd/Makefile.am old mode 100755 new mode 100644 diff --git a/providers/gpsd/geoclue-gpsd.c b/providers/gpsd/geoclue-gpsd.c old mode 100755 new mode 100644 index 1c6d111..f5ab9ea --- a/providers/gpsd/geoclue-gpsd.c +++ b/providers/gpsd/geoclue-gpsd.c @@ -45,9 +45,6 @@ #include "setting.h" -#define LAST_POS_PRECESION 10000 -#define POSITION_LENGTH 16 - typedef struct gps_data_t gps_data; typedef struct gps_fix_t gps_fix; @@ -64,7 +61,9 @@ typedef struct { int timestamp; double latitude; double longitude; - double accuracy; + double altitude; + double hor_accuracy; + double ver_accuracy; } GeoclueGpsdsLastPosition; typedef struct { @@ -90,48 +89,40 @@ typedef struct { GcProviderClass parent_class; } GeoclueGpsdClass; -static void geoclue_gpsd_position_init (GcIfacePositionClass *iface); -static void geoclue_gpsd_velocity_init (GcIfaceVelocityClass *iface); +static void geoclue_gpsd_position_init(GcIfacePositionClass * iface); +static void geoclue_gpsd_velocity_init(GcIfaceVelocityClass * iface); #define GEOCLUE_TYPE_GPSD (geoclue_gpsd_get_type ()) #define GEOCLUE_GPSD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEOCLUE_TYPE_GPSD, GeoclueGpsd)) -G_DEFINE_TYPE_WITH_CODE (GeoclueGpsd, geoclue_gpsd, GC_TYPE_PROVIDER, - G_IMPLEMENT_INTERFACE (GC_TYPE_IFACE_POSITION, - geoclue_gpsd_position_init) - G_IMPLEMENT_INTERFACE (GC_TYPE_IFACE_VELOCITY, - geoclue_gpsd_velocity_init)) - -static void geoclue_gpsd_stop_gpsd (GeoclueGpsd *self); -static gboolean geoclue_gpsd_start_gpsd (GeoclueGpsd *self); +G_DEFINE_TYPE_WITH_CODE(GeoclueGpsd, geoclue_gpsd, GC_TYPE_PROVIDER, + G_IMPLEMENT_INTERFACE(GC_TYPE_IFACE_POSITION, geoclue_gpsd_position_init) + G_IMPLEMENT_INTERFACE(GC_TYPE_IFACE_VELOCITY, geoclue_gpsd_velocity_init)) +static void geoclue_gpsd_stop_gpsd(GeoclueGpsd * self); +static gboolean geoclue_gpsd_start_gpsd(GeoclueGpsd * self); /* defining global GeoclueGpsd because gpsd does not support "user_data" * pointers in callbacks */ GeoclueGpsd *gpsd; /* Geoclue interface */ -static gboolean -get_status (GcIfaceGeoclue *gc, - GeoclueStatus *status, - GError **error) +static gboolean get_status(GcIfaceGeoclue * gc, GeoclueStatus * status, GError ** error) { - GeoclueGpsd *gpsd = GEOCLUE_GPSD (gc); + GeoclueGpsd *gpsd = GEOCLUE_GPSD(gc); *status = gpsd->last_status; return TRUE; } -static void -shutdown (GcProvider *provider) +static void shutdown(GcProvider * provider) { - GeoclueGpsd *gpsd = GEOCLUE_GPSD (provider); + GeoclueGpsd *gpsd = GEOCLUE_GPSD(provider); - g_main_loop_quit (gpsd->loop); + g_main_loop_quit(gpsd->loop); } -static void -geoclue_gpsd_set_status (GeoclueGpsd *self, GeoclueStatus status) +static void geoclue_gpsd_set_status(GeoclueGpsd * self, GeoclueStatus status) { if (status != self->last_status) { self->last_status = status; @@ -142,32 +133,25 @@ geoclue_gpsd_set_status (GeoclueGpsd *self, GeoclueStatus status) self->last_velo_fields = GEOCLUE_VELOCITY_FIELDS_NONE; } g_debug("status changed [%d]", status); - gc_iface_geoclue_emit_status_changed (GC_IFACE_GEOCLUE (self), - status); + gc_iface_geoclue_emit_status_changed(GC_IFACE_GEOCLUE(self), status); } } -static gboolean -set_options (GcIfaceGeoclue *gc, - GHashTable *options, - GError **error) +static gboolean set_options(GcIfaceGeoclue * gc, GHashTable * options, GError ** error) { - GeoclueGpsd *gpsd = GEOCLUE_GPSD (gc); + GeoclueGpsd *gpsd = GEOCLUE_GPSD(gc); char *port, *host; gboolean changed = FALSE; - host = g_hash_table_lookup (options, - "org.freedesktop.Geoclue.GPSHost"); - port = g_hash_table_lookup (options, - "org.freedesktop.Geoclue.GPSPort"); + host = g_hash_table_lookup(options, "org.freedesktop.Geoclue.GPSHost"); + port = g_hash_table_lookup(options, "org.freedesktop.Geoclue.GPSPort"); if (port == NULL) { port = DEFAULT_GPSD_PORT; } /* new values? */ - if (g_strcmp0 (host, gpsd->host) != 0 || - g_strcmp0 (port, gpsd->port) != 0) { + if (g_strcmp0(host, gpsd->host) != 0 || g_strcmp0(port, gpsd->port) != 0) { changed = TRUE; } @@ -176,47 +160,44 @@ set_options (GcIfaceGeoclue *gc, } /* update private values with new ones, restart gpsd */ - g_free (gpsd->port); + g_free(gpsd->port); gpsd->port = NULL; - g_free (gpsd->host); + g_free(gpsd->host); gpsd->host = NULL; - geoclue_gpsd_stop_gpsd (gpsd); + geoclue_gpsd_stop_gpsd(gpsd); if (host == NULL) { return TRUE; } - gpsd->port = g_strdup (port); - gpsd->host = g_strdup (host); - if (!geoclue_gpsd_start_gpsd (gpsd)) { - geoclue_gpsd_set_status (gpsd, GEOCLUE_STATUS_ERROR); - g_set_error (error, GEOCLUE_ERROR, - GEOCLUE_ERROR_FAILED, "Gpsd not found"); + gpsd->port = g_strdup(port); + gpsd->host = g_strdup(host); + if (!geoclue_gpsd_start_gpsd(gpsd)) { + geoclue_gpsd_set_status(gpsd, GEOCLUE_STATUS_ERROR); + g_set_error(error, GEOCLUE_ERROR, GEOCLUE_ERROR_FAILED, "Gpsd not found"); return FALSE; } return TRUE; } -static void -finalize (GObject *object) +static void finalize(GObject * object) { - GeoclueGpsd *gpsd = GEOCLUE_GPSD (object); + GeoclueGpsd *gpsd = GEOCLUE_GPSD(object); - geoclue_gpsd_stop_gpsd (gpsd); - g_free (gpsd->last_fix); - geoclue_accuracy_free (gpsd->last_accuracy); + geoclue_gpsd_stop_gpsd(gpsd); + g_free(gpsd->last_fix); + geoclue_accuracy_free(gpsd->last_accuracy); - g_free (gpsd->port); + g_free(gpsd->port); if (gpsd->host) { - g_free (gpsd->host); + g_free(gpsd->host); } - ((GObjectClass *) geoclue_gpsd_parent_class)->finalize (object); + ((GObjectClass *) geoclue_gpsd_parent_class)->finalize(object); } -static void -geoclue_gpsd_class_init (GeoclueGpsdClass *klass) +static void geoclue_gpsd_class_init(GeoclueGpsdClass * klass) { GObjectClass *o_class = (GObjectClass *) klass; GcProviderClass *p_class = (GcProviderClass *) klass; @@ -228,75 +209,20 @@ geoclue_gpsd_class_init (GeoclueGpsdClass *klass) p_class->shutdown = shutdown; } - -static gboolean -equal_or_nan (double a, double b) +static gboolean equal_or_nan(double a, double b) { - if (isnan (a) && isnan (b)) { + if (isnan(a) && isnan(b)) { return TRUE; } return a == b; } -static void -geoclue_gpsd_position_i2a(char *position, int lat, int lon) -{ - g_debug("geoclue_xps_position_i2a Lat : %d, Long : %d", lat, lon); - char latitude[POSITION_LENGTH/2 + 1] = { 0, }; - char longitude[POSITION_LENGTH/2 + 1] = { 0, }; - - if (lat < 0) { - snprintf(latitude, POSITION_LENGTH/2 + 1, "S%07d", abs(lat)); - } else { - snprintf(latitude, POSITION_LENGTH/2 + 1, "N%07d", lat); - } - - if (lon < 0) { - snprintf(longitude, POSITION_LENGTH/2 + 1, "W%07d", abs(lon)); - } else { - snprintf(longitude, POSITION_LENGTH/2 + 1, "E%07d", lon); - } - - strncpy(position, latitude, POSITION_LENGTH/2); - strncat(position, longitude, POSITION_LENGTH/2); - g_debug("i_to_a position : %s", position); -} - -static void -geoclue_gpsd_position_a2i(char *position, int *lat, int *lon) -{ - g_debug("geoclue_xps_position_a2i position : %s", position); - char *d_lat, *d_lon; - - char latitude[POSITION_LENGTH/2]; - char longitude[POSITION_LENGTH/2]; - memcpy(latitude, position + 1, POSITION_LENGTH/2 - 1); - memcpy(longitude, position + POSITION_LENGTH/2 + 1, POSITION_LENGTH/2 - 1); - latitude[POSITION_LENGTH/2 - 1] = '\0'; - longitude[POSITION_LENGTH/2 - 1] = '\0'; - d_lat = position; - d_lon = position + POSITION_LENGTH/2; - - *lat = atoi(latitude); - *lon = atoi(longitude); - - if (*d_lat == 'S') { - *lat = *lat * -1; - } - if (*d_lon == 'W') { - *lon = *lon * -1; - } - g_debug("a_to_i Lat : %d, Long : %d", *lat, *lon); -} - -double -deg2rad(double deg) +double deg2rad(double deg) { return (deg * M_PI / 180); } -static int -geoclue_gpsd_distance_to_last_position(GeoclueGpsd * gpsd, const gps_fix * last_fix) +static int geoclue_gpsd_distance_to_last_position(GeoclueGpsd * gpsd, const gps_fix * last_fix) { double delta_lat, delta_long; double dist; @@ -319,164 +245,152 @@ geoclue_gpsd_distance_to_last_position(GeoclueGpsd * gpsd, const gps_fix * last_ } } -static void -geoclue_gpsd_get_last_position(GeoclueGpsd * gpsd) +static void geoclue_gpsd_get_last_position(GeoclueGpsd * gpsd) { - int lat, lon, acc; - char position[POSITION_LENGTH + 1] = { 0, }; - - snprintf(position, POSITION_LENGTH + 1, "%s", setting_get_string(LAST_POSITION)); - geoclue_gpsd_position_a2i(position, &lat, &lon); - acc = setting_get_int(LAST_ACCURACY); - - gpsd->last_position.timestamp = setting_get_int(LAST_TIMESTAMP); - gpsd->last_position.latitude = lat * (1.0 / LAST_POS_PRECESION); - gpsd->last_position.longitude = lon * (1.0 / LAST_POS_PRECESION); - gpsd->last_position.accuracy = acc * (1.0 / LAST_POS_PRECESION); - g_debug("get Last Latitude = %f Longitude = %f Accuracy = %f", - gpsd->last_position.latitude, gpsd->last_position.longitude, - gpsd->last_position.accuracy); + setting_get_int(LAST_GPS_TIMESTAMP, &gpsd->last_position.timestamp); + setting_get_double(LAST_GPS_LATITUDE, &gpsd->last_position.latitude); + setting_get_double(LAST_GPS_LATITUDE, &gpsd->last_position.longitude); + setting_get_double(LAST_GPS_LONGITUDE, &gpsd->last_position.altitude); + setting_get_double(LAST_GPS_HOR_ACCURACY, &gpsd->last_position.hor_accuracy); + setting_get_double(LAST_GPS_VER_ACCURACY, &gpsd->last_position.ver_accuracy); + g_debug + ("get Last Latitude = %f Longitude = %f Altitude = %f H_Accuracy = %f V_Accuracy = %f", + gpsd->last_position.latitude, gpsd->last_position.longitude, + gpsd->last_position.altitude, gpsd->last_position.hor_accuracy, gpsd->last_position.ver_accuracy); } -static void -geoclue_gpsd_set_last_position(GeoclueGpsd * gpsd) +static void geoclue_gpsd_set_last_position(GeoclueGpsd * gpsd) { - int lat, lon, acc; - char position[POSITION_LENGTH + 1] = { 0, }; - - lat = gpsd->last_position.latitude * LAST_POS_PRECESION; - lon = gpsd->last_position.longitude * LAST_POS_PRECESION; - acc = gpsd->last_position.accuracy * LAST_POS_PRECESION; - g_debug("set GPSD Last Latitude = %d Longitude = %d Accuracy = %d", lat, lon, acc); - geoclue_gpsd_position_i2a(position, lat, lon); - - setting_set_int(LAST_TIMESTAMP, gpsd->last_position.timestamp); - setting_set_string(LAST_POSITION, position); - setting_set_int(LAST_ACCURACY, acc); + g_debug + ("set GPSD Last Latitude = %d Longitude = %d Altitude = %d H_Accuracy = %d V_Accuracy = %f", + gpsd->last_position.latitude, gpsd->last_position.longitude, + gpsd->last_position.altitude, gpsd->last_position.hor_accuracy, gpsd->last_position.ver_accuracy); + setting_set_int(LAST_GPS_TIMESTAMP, gpsd->last_position.timestamp); + setting_set_double(LAST_GPS_LATITUDE, gpsd->last_position.latitude); + setting_set_double(LAST_GPS_LONGITUDE, gpsd->last_position.longitude); + setting_set_double(LAST_GPS_ALTITUDE, gpsd->last_position.altitude); + setting_set_double(LAST_GPS_HOR_ACCURACY, gpsd->last_position.hor_accuracy); + setting_set_double(LAST_GPS_VER_ACCURACY, gpsd->last_position.ver_accuracy); + + setting_set_int(LAST_WPS_TIMESTAMP, gpsd->last_position.timestamp); + setting_set_double(LAST_WPS_LATITUDE, gpsd->last_position.latitude); + setting_set_double(LAST_WPS_LONGITUDE, gpsd->last_position.longitude); + setting_set_double(LAST_WPS_ALTITUDE, gpsd->last_position.altitude); + setting_set_double(LAST_WPS_HOR_ACCURACY, gpsd->last_position.hor_accuracy); } -static void -geoclue_gpsd_update_last_position(GeoclueGpsd * gpsd, const const gps_fix * last_fix, - int accuracy) +static void geoclue_gpsd_update_last_position(GeoclueGpsd * gpsd, const const gps_fix * last_fix) { - g_debug("geoclue_xps_update_last_position"); + g_debug("geoclue_gpsd_update_last_position"); gpsd->last_position.timestamp = last_fix->time + 0.5; gpsd->last_position.latitude = last_fix->latitude; gpsd->last_position.longitude = last_fix->longitude; - gpsd->last_position.accuracy = accuracy; + gpsd->last_position.altitude = last_fix->altitude; + gpsd->last_position.hor_accuracy = sqrt(pow(last_fix->epx, 2) + pow(last_fix->epy, 2)); + gpsd->last_position.ver_accuracy = last_fix->epv; + geoclue_gpsd_set_last_position(gpsd); } -static void -geoclue_gpsd_update_position (GeoclueGpsd *gpsd) +static void geoclue_gpsd_update_position(GeoclueGpsd * gpsd) { - if(gpsd->last_status != GEOCLUE_STATUS_AVAILABLE) + if (gpsd->last_status != GEOCLUE_STATUS_AVAILABLE) return; gps_fix *fix = &gpsd->gpsdata->fix; gps_fix *last_fix = gpsd->last_fix; - if (isnan(fix->time)==0){ + if (isnan(fix->time) == 0) { last_fix->time = fix->time; - } - if (equal_or_nan (fix->latitude, last_fix->latitude) && - equal_or_nan (fix->longitude, last_fix->longitude) && - equal_or_nan (fix->altitude, last_fix->altitude)) { + } + if (equal_or_nan(fix->latitude, last_fix->latitude) && equal_or_nan(fix->longitude, last_fix->longitude) + && equal_or_nan(fix->altitude, last_fix->altitude)) { return; } /* save values */ - if (fix->mode >= MODE_2D && isnan(fix->latitude)==0) { + if (fix->mode >= MODE_2D && isnan(fix->latitude) == 0) { last_fix->latitude = fix->latitude; } - if (fix->mode >= MODE_2D && isnan(fix->longitude)==0) { + if (fix->mode >= MODE_2D && isnan(fix->longitude) == 0) { last_fix->longitude = fix->longitude; } - if (fix->mode == MODE_3D && isnan(fix->altitude)==0){ + if (fix->mode == MODE_3D && isnan(fix->altitude) == 0) { last_fix->altitude = fix->altitude; } - if (isnan(fix->epx)==0){ + if (isnan(fix->epx) == 0) { last_fix->epx = fix->epx; } - if (isnan(fix->epy)==0){ + if (isnan(fix->epy) == 0) { last_fix->epy = fix->epy; } - if (isnan(fix->epv)==0){ + if (isnan(fix->epv) == 0) { last_fix->epv = fix->epv; } - geoclue_accuracy_set_details (gpsd->last_accuracy, - GEOCLUE_ACCURACY_LEVEL_DETAILED, - sqrt(pow(last_fix->epx, 2)+pow(last_fix->epy, 2)), fix->epv); + geoclue_accuracy_set_details(gpsd->last_accuracy, + GEOCLUE_ACCURACY_LEVEL_DETAILED, + sqrt(pow(last_fix->epx, 2) + pow(last_fix->epy, 2)), fix->epv); gpsd->last_pos_fields = GEOCLUE_POSITION_FIELDS_NONE; - gpsd->last_pos_fields |= (isnan (fix->latitude)) ? - 0 : GEOCLUE_POSITION_FIELDS_LATITUDE; - gpsd->last_pos_fields |= (isnan (fix->longitude)) ? - 0 : GEOCLUE_POSITION_FIELDS_LONGITUDE; - gpsd->last_pos_fields |= (isnan (fix->altitude)) ? - 0 : GEOCLUE_POSITION_FIELDS_ALTITUDE; + gpsd->last_pos_fields |= (isnan(fix->latitude)) ? 0 : GEOCLUE_POSITION_FIELDS_LATITUDE; + gpsd->last_pos_fields |= (isnan(fix->longitude)) ? 0 : GEOCLUE_POSITION_FIELDS_LONGITUDE; + gpsd->last_pos_fields |= (isnan(fix->altitude)) ? 0 : GEOCLUE_POSITION_FIELDS_ALTITUDE; if (geoclue_gpsd_distance_to_last_position(gpsd, last_fix) == 0) { - geoclue_gpsd_update_last_position(gpsd, last_fix, - (int)floor(sqrt(pow(last_fix->epx, 2) + pow(last_fix->epy, 2)))); + geoclue_gpsd_update_last_position(gpsd, last_fix); } else { g_debug("Last position is not updated"); } - g_debug("Update position: %lf, %lf, %lf, fields:0x%x, Accuracy level: %d, vert:%lf hori:%lf", - last_fix->latitude, last_fix->longitude, last_fix->altitude, gpsd->last_pos_fields, - GEOCLUE_ACCURACY_LEVEL_DETAILED, sqrt(pow(last_fix->epx, 2)+pow(last_fix->epy, 2)), fix->epv); - gc_iface_position_emit_position_changed - (GC_IFACE_POSITION (gpsd), gpsd->last_pos_fields, - (int)(last_fix->time+0.5), - last_fix->latitude, last_fix->longitude, last_fix->altitude, - gpsd->last_accuracy); + g_debug + ("Update position: %lf, %lf, %lf, fields:0x%x, Accuracy level: %d, hori:%lf vert:%lf", + last_fix->latitude, last_fix->longitude, last_fix->altitude, + gpsd->last_pos_fields, GEOCLUE_ACCURACY_LEVEL_DETAILED, + sqrt(pow(last_fix->epx, 2) + pow(last_fix->epy, 2)), fix->epv); + gc_iface_position_emit_position_changed(GC_IFACE_POSITION(gpsd), + gpsd->last_pos_fields, + (int)(last_fix->time + 0.5), + last_fix->latitude, + last_fix->longitude, last_fix->altitude, gpsd->last_accuracy); } -static void -geoclue_gpsd_update_velocity (GeoclueGpsd *gpsd) +static void geoclue_gpsd_update_velocity(GeoclueGpsd * gpsd) { - if(gpsd->last_status != GEOCLUE_STATUS_AVAILABLE) + if (gpsd->last_status != GEOCLUE_STATUS_AVAILABLE) return; gps_fix *fix = &gpsd->gpsdata->fix; gps_fix *last_fix = gpsd->last_fix; - if (isnan(fix->time)==0){ + if (isnan(fix->time) == 0) { last_fix->time = fix->time; - } - if (equal_or_nan (fix->track, last_fix->track) && - equal_or_nan (fix->speed, last_fix->speed) && - equal_or_nan (fix->climb, last_fix->climb)) { + } + if (equal_or_nan(fix->track, last_fix->track) && equal_or_nan(fix->speed, last_fix->speed) + && equal_or_nan(fix->climb, last_fix->climb)) { return; } - if (fix->mode >= MODE_2D && isnan(fix->track)==0){ + if (fix->mode >= MODE_2D && isnan(fix->track) == 0) { last_fix->track = fix->track; } - if (fix->mode >= MODE_2D && isnan(fix->speed)==0){ + if (fix->mode >= MODE_2D && isnan(fix->speed) == 0) { last_fix->speed = fix->speed; } - if (fix->mode >= MODE_3D && isnan(fix->climb)==0){ + if (fix->mode >= MODE_3D && isnan(fix->climb) == 0) { last_fix->climb = fix->climb; } g_debug("Update velocity: %lf, %lf, %lf", last_fix->track, last_fix->speed, last_fix->climb); gpsd->last_velo_fields = GEOCLUE_VELOCITY_FIELDS_NONE; - gpsd->last_velo_fields |= (isnan (last_fix->track)) ? - 0 : GEOCLUE_VELOCITY_FIELDS_DIRECTION; - gpsd->last_velo_fields |= (isnan (last_fix->speed)) ? - 0 : GEOCLUE_VELOCITY_FIELDS_SPEED; - gpsd->last_velo_fields |= (isnan (last_fix->climb)) ? - 0 : GEOCLUE_VELOCITY_FIELDS_CLIMB; + gpsd->last_velo_fields |= (isnan(last_fix->track)) ? 0 : GEOCLUE_VELOCITY_FIELDS_DIRECTION; + gpsd->last_velo_fields |= (isnan(last_fix->speed)) ? 0 : GEOCLUE_VELOCITY_FIELDS_SPEED; + gpsd->last_velo_fields |= (isnan(last_fix->climb)) ? 0 : GEOCLUE_VELOCITY_FIELDS_CLIMB; gc_iface_velocity_emit_velocity_changed - (GC_IFACE_VELOCITY (gpsd), gpsd->last_velo_fields, - (int)(last_fix->time+0.5), - last_fix->speed, last_fix->track, last_fix->climb); + (GC_IFACE_VELOCITY(gpsd), gpsd->last_velo_fields, + (int)(last_fix->time + 0.5), last_fix->speed, last_fix->track, last_fix->climb); } -static void -geoclue_gpsd_update_status (GeoclueGpsd *gpsd) +static void geoclue_gpsd_update_status(GeoclueGpsd * gpsd) { GeoclueStatus status; @@ -495,50 +409,46 @@ geoclue_gpsd_update_status (GeoclueGpsd *gpsd) return; } - geoclue_gpsd_set_status (gpsd, status); + geoclue_gpsd_set_status(gpsd, status); } -static void -gpsd_raw_hook (gps_data *gpsdata, char *message, size_t len) +static void gpsd_raw_hook(gps_data * gpsdata, char *message, size_t len) { - if(gpsdata == NULL) + if (gpsdata == NULL) return; - geoclue_gpsd_update_status (gpsd); - geoclue_gpsd_update_position (gpsd); - geoclue_gpsd_update_velocity (gpsd); + geoclue_gpsd_update_status(gpsd); + geoclue_gpsd_update_position(gpsd); + geoclue_gpsd_update_velocity(gpsd); } -static void -geoclue_gpsd_stop_gpsd (GeoclueGpsd *self) +static void geoclue_gpsd_stop_gpsd(GeoclueGpsd * self) { if (self->gpsdata) { - gps_close (self->gpsdata); + gps_close(self->gpsdata); self->gpsdata = NULL; } } -static gboolean -geoclue_gpsd_start_gpsd (GeoclueGpsd *self) +static gboolean geoclue_gpsd_start_gpsd(GeoclueGpsd * self) { - self->gpsdata = gps_open (self->host, self->port); + self->gpsdata = gps_open(self->host, self->port); if (self->gpsdata) { gps_stream(self->gpsdata, WATCH_ENABLE | WATCH_NEWSTYLE, NULL); - gps_set_raw_hook (self->gpsdata, gpsd_raw_hook); + gps_set_raw_hook(self->gpsdata, gpsd_raw_hook); return TRUE; } else { - g_warning ("gps_open() failed, is gpsd running (host=%s,port=%s)?", self->host, self->port); + g_warning("gps_open() failed, is gpsd running (host=%s,port=%s)?", self->host, self->port); return FALSE; } } -gboolean -gpsd_poll(gpointer data) +gboolean gpsd_poll(gpointer data) { - GeoclueGpsd *self = (GeoclueGpsd*)data; + GeoclueGpsd *self = (GeoclueGpsd *) data; if (self->gpsdata) { if (gps_poll(self->gpsdata) < 0) { - geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ERROR); + geoclue_gpsd_set_status(self, GEOCLUE_STATUS_ERROR); geoclue_gpsd_stop_gpsd(self); return FALSE; } @@ -546,72 +456,60 @@ gpsd_poll(gpointer data) return TRUE; } -static void -geoclue_gpsd_init (GeoclueGpsd *self) +static void geoclue_gpsd_init(GeoclueGpsd * self) { self->gpsdata = NULL; - self->last_fix = g_new0 (gps_fix, 1); + self->last_fix = g_new0(gps_fix, 1); self->last_pos_fields = GEOCLUE_POSITION_FIELDS_NONE; self->last_velo_fields = GEOCLUE_VELOCITY_FIELDS_NONE; - self->last_accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0, 0); + self->last_accuracy = geoclue_accuracy_new(GEOCLUE_ACCURACY_LEVEL_NONE, 0, 0); - gc_provider_set_details (GC_PROVIDER (self), - "org.freedesktop.Geoclue.Providers.Gpsd", - "/org/freedesktop/Geoclue/Providers/Gpsd", - "Gpsd", "Gpsd provider"); + gc_provider_set_details(GC_PROVIDER(self), + "org.freedesktop.Geoclue.Providers.Gpsd", + "/org/freedesktop/Geoclue/Providers/Gpsd", "Gpsd", "Gpsd provider"); - self->port = g_strdup (DEFAULT_GPSD_PORT); - self->host = g_strdup ("localhost"); + self->port = g_strdup(DEFAULT_GPSD_PORT); + self->host = g_strdup("localhost"); - geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ACQUIRING); - if (!geoclue_gpsd_start_gpsd (self)) { - geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ERROR); + geoclue_gpsd_set_status(self, GEOCLUE_STATUS_ACQUIRING); + if (!geoclue_gpsd_start_gpsd(self)) { + geoclue_gpsd_set_status(self, GEOCLUE_STATUS_ERROR); } geoclue_gpsd_get_last_position(self); } static gboolean -get_position (GcIfacePosition *gc, - GeocluePositionFields *fields, - int *timestamp, - double *latitude, - double *longitude, - double *altitude, - GeoclueAccuracy **accuracy, - GError **error) +get_position(GcIfacePosition * gc, + GeocluePositionFields * fields, + int *timestamp, + double *latitude, double *longitude, double *altitude, GeoclueAccuracy ** accuracy, GError ** error) { - GeoclueGpsd *gpsd = GEOCLUE_GPSD (gc); + GeoclueGpsd *gpsd = GEOCLUE_GPSD(gc); - *timestamp = (int)(gpsd->last_fix->time+0.5); + *timestamp = (int)(gpsd->last_fix->time + 0.5); *latitude = gpsd->last_fix->latitude; *longitude = gpsd->last_fix->longitude; *altitude = gpsd->last_fix->altitude; *fields = gpsd->last_pos_fields; - *accuracy = geoclue_accuracy_copy (gpsd->last_accuracy); + *accuracy = geoclue_accuracy_copy(gpsd->last_accuracy); return TRUE; } -static void -geoclue_gpsd_position_init (GcIfacePositionClass *iface) +static void geoclue_gpsd_position_init(GcIfacePositionClass * iface) { iface->get_position = get_position; } static gboolean -get_velocity (GcIfaceVelocity *gc, - GeoclueVelocityFields *fields, - int *timestamp, - double *speed, - double *direction, - double *climb, - GError **error) +get_velocity(GcIfaceVelocity * gc, + GeoclueVelocityFields * fields, int *timestamp, double *speed, double *direction, double *climb, GError ** error) { - GeoclueGpsd *gpsd = GEOCLUE_GPSD (gc); + GeoclueGpsd *gpsd = GEOCLUE_GPSD(gc); - *timestamp = (int)(gpsd->last_fix->time+0.5); + *timestamp = (int)(gpsd->last_fix->time + 0.5); *speed = gpsd->last_fix->speed; *direction = gpsd->last_fix->track; *climb = gpsd->last_fix->climb; @@ -620,27 +518,24 @@ get_velocity (GcIfaceVelocity *gc, return TRUE; } -static void -geoclue_gpsd_velocity_init (GcIfaceVelocityClass *iface) +static void geoclue_gpsd_velocity_init(GcIfaceVelocityClass * iface) { iface->get_velocity = get_velocity; } -int -main (int argc, - char **argv) +int main(int argc, char **argv) { - g_type_init (); + g_type_init(); - gpsd = g_object_new (GEOCLUE_TYPE_GPSD, NULL); + gpsd = g_object_new(GEOCLUE_TYPE_GPSD, NULL); - gpsd->loop = g_main_loop_new (NULL, TRUE); - g_timeout_add(500, gpsd_poll, (gpointer)gpsd); + gpsd->loop = g_main_loop_new(NULL, TRUE); + g_timeout_add(500, gpsd_poll, (gpointer) gpsd); - g_main_loop_run (gpsd->loop); + g_main_loop_run(gpsd->loop); - g_main_loop_unref (gpsd->loop); - g_object_unref (gpsd); + g_main_loop_unref(gpsd->loop); + g_object_unref(gpsd); return 0; } diff --git a/providers/gpsd/geoclue-gpsd.provider b/providers/gpsd/geoclue-gpsd.provider old mode 100755 new mode 100644 diff --git a/providers/gpsd/org.freedesktop.Geoclue.Providers.Gpsd.service.in b/providers/gpsd/org.freedesktop.Geoclue.Providers.Gpsd.service.in old mode 100755 new mode 100644 diff --git a/providers/gpsd/setting.c b/providers/gpsd/setting.c old mode 100755 new mode 100644 index 2049a6b..e7a1dc0 --- a/providers/gpsd/setting.c +++ b/providers/gpsd/setting.c @@ -29,48 +29,72 @@ #include #include "setting.h" -int setting_get_int(const char* path) +int setting_get_int(const char *path, int *val) { - if(!path) - return -1; + if (!path) { + return FALSE; + } - int val = -1; - if (vconf_get_int(path, &val)) { + int ret; + + if (vconf_get_int(path, val) == -1) { g_warning("vconf_get_int: failed [%s]", path); - val = -1; + ret = FALSE; } else { - g_debug("vconf_get_int: [%s]:[%d]", path, val); + g_debug("vconf_get_int: [%s]:[%d]", path, *val); + ret = TRUE; } - return val; + return ret; } -int setting_set_int(const char* path, int val) +int setting_set_int(const char *path, int val) { if (!path) { - return -1; + return FALSE; } int ret = vconf_set_int(path, val); if (ret == 0) { g_debug("vconf_set_int: [%s]:[%d]", path, val); + ret = TRUE; } else { - g_warning("vconf_set_int failed, [%s]\n", path); + g_warning("vconf_set_int failed, [%s]", path); + ret = FALSE; } return ret; } -char* setting_get_string(const char* path) +int setting_get_double(const char *path, double *val) { - return vconf_get_str(path); + if (!path) { + return FALSE; + } + + int ret; + + if (vconf_get_dbl(path, val) == -1) { + g_warning("vconf_get_dbl failed [%s]", path); + ret = FALSE; + } else { + g_debug("vconf_get_dbl: [%s]:[%f]", path, *val); + ret = TRUE; + } + return ret; } -int setting_set_string(const char* path, const char* val) +int setting_set_double(const char *path, double val) { - int ret = vconf_set_str(path, val); + if (!path) { + return FALSE; + } + + int ret = vconf_set_dbl(path, val); if (ret == 0) { - g_debug("vconf_set_str: [%s]:[%s]", path, val); + g_debug("vconf_set_dbl: [%s]:[%f]", path, val); + ret = TRUE; } else { - g_warning("vconf_set_str failed, [%s]\n", path); + g_warning("vconf_set_dbl failed, [%s]", path); + ret = FALSE; } return ret; } diff --git a/providers/gpsd/setting.h b/providers/gpsd/setting.h old mode 100755 new mode 100644 index ca1fe7d..3c5eb5a --- a/providers/gpsd/setting.h +++ b/providers/gpsd/setting.h @@ -28,16 +28,27 @@ #ifndef __SETTING_H__ #define __SETTING_H__ -// Sync VCONFKEY_GPS_STATE -#define VCONF_LOCATION_PATH "db/location" +#define VCONF_LOCATION_PATH "db/location" -#define LOCATION_POSITION_PATH VCONF_LOCATION_PATH"/position" -#define LAST_TIMESTAMP LOCATION_POSITION_PATH"/Timestamp" -#define LAST_POSITION LOCATION_POSITION_PATH"/LastPosition" -#define LAST_ACCURACY LOCATION_POSITION_PATH"/LastAccuracy" +#define LAST_POSITION_PATH VCONF_LOCATION_PATH"/lastposition" +#define METHOD_GPS LAST_POSITION_PATH"/gps" +#define METHOD_WPS LAST_POSITION_PATH"/wps" -int setting_get_int(const char* path); -int setting_set_int(const char* path, int val); -char* setting_get_string(const char* path); -int setting_set_string(const char* path, const char* val); +#define LAST_GPS_TIMESTAMP METHOD_GPS"/Timestamp" +#define LAST_GPS_LATITUDE METHOD_GPS"/Latitude" +#define LAST_GPS_LONGITUDE METHOD_GPS"/Longitude" +#define LAST_GPS_ALTITUDE METHOD_GPS"/Altitude" +#define LAST_GPS_HOR_ACCURACY METHOD_GPS"/HorAccuracy" +#define LAST_GPS_VER_ACCURACY METHOD_GPS"/VerAccuracy" + +#define LAST_WPS_TIMESTAMP METHOD_WPS"/Timestamp" +#define LAST_WPS_LATITUDE METHOD_WPS"/Latitude" +#define LAST_WPS_LONGITUDE METHOD_WPS"/Longitude" +#define LAST_WPS_ALTITUDE METHOD_WPS"/Altitude" +#define LAST_WPS_HOR_ACCURACY METHOD_WPS"/HorAccuracy" + +int setting_get_int(const char *path, int *val); +int setting_set_int(const char *path, int val); +int setting_get_double(const char *path, double *val); +int setting_set_double(const char *path, double val); #endif diff --git a/providers/gsmloc/Makefile.am b/providers/gsmloc/Makefile.am index 8a2486f..1b1e314 100644 --- a/providers/gsmloc/Makefile.am +++ b/providers/gsmloc/Makefile.am @@ -26,7 +26,7 @@ geoclue_gsmloc_CFLAGS = \ geoclue_gsmloc_LDADD = \ $(GEOCLUE_LIBS) \ - $(top_builddir)/geoclue/libgeoclue.la + $(top_builddir)/geoclue/libgeoclue.la providersdir = $(datadir)/geoclue-providers providers_DATA = geoclue-gsmloc.provider diff --git a/providers/gsmloc/geoclue-gsmloc-ofono.c b/providers/gsmloc/geoclue-gsmloc-ofono.c old mode 100644 new mode 100755 index 27e77d9..898e387 --- a/providers/gsmloc/geoclue-gsmloc-ofono.c +++ b/providers/gsmloc/geoclue-gsmloc-ofono.c @@ -1,7 +1,7 @@ /* * Geoclue * geoclue-gsmloc-ofono.c - oFono abstraction for gsmloc provider - * + * * Author: Jussi Kukkonen * Copyright 2008 by Garmin Ltd. or its subsidiaries * 2010 Intel Corporation @@ -22,7 +22,7 @@ * Boston, MA 02111-1307, USA. * */ - + #include #include @@ -423,11 +423,11 @@ modem_free (Modem *modem) } -static void +static void emit_network_data_changed (GeoclueGsmlocOfono *ofono) { GeoclueGsmlocOfonoPrivate *priv = GET_PRIVATE (ofono); - const char *mcc, *mnc, *lac, *cid; + const char *mcc, *mnc, *lac, *cid; GList *modems, *netops; mcc = mnc = lac = cid = NULL; @@ -639,7 +639,7 @@ geoclue_gsmloc_ofono_init (GeoclueGsmlocOfono *ofono) return; } - priv->ofono_manager = + priv->ofono_manager = dbus_g_proxy_new_for_name (system_bus, "org.ofono", "/", diff --git a/providers/gsmloc/geoclue-gsmloc-ofono.h b/providers/gsmloc/geoclue-gsmloc-ofono.h old mode 100644 new mode 100755 diff --git a/providers/gsmloc/geoclue-gsmloc.c b/providers/gsmloc/geoclue-gsmloc.c index 222d42c..4d65b97 100644 --- a/providers/gsmloc/geoclue-gsmloc.c +++ b/providers/gsmloc/geoclue-gsmloc.c @@ -1,7 +1,7 @@ /* * Geoclue * geoclue-gsmloc.c - A GSM cell based Position provider - * + * * Author: Jussi Kukkonen * Copyright 2008 by Garmin Ltd. or its subsidiaries * 2010 Intel Corporation @@ -23,18 +23,18 @@ * */ - /** - * Gsmloc provider is a position and address provider that uses GSM cell + /** + * Gsmloc provider is a position and address provider that uses GSM cell * location and the webservice http://www.opencellid.org/ (a similar service * used to live at gsmloc.org, hence the name). The web service does not - * provide any address data: that is done with a + * provide any address data: that is done with a * "mobile country code -> ISO country code" lookup table: as a result address * will only ever have country code and country fields. - * + * * Gsmloc requires the telephony stack oFono to work -- more IMSI data - * sources could be added fairly easily. + * sources could be added fairly easily. **/ - + #include #include @@ -122,7 +122,7 @@ geoclue_gsmloc_get_status (GcIfaceGeoclue *iface, } else if (!gsmloc->mcc || !gsmloc->mnc || !gsmloc->lac || !gsmloc->cid) { *status = GEOCLUE_STATUS_UNAVAILABLE; - } else { + } else { *status = GEOCLUE_STATUS_AVAILABLE; } return TRUE; @@ -152,11 +152,11 @@ geoclue_gsmloc_query_opencellid (GeoclueGsmloc *gsmloc) "cellid", gsmloc->cid, (char *)0)) { - if (gc_web_service_get_double (gsmloc->web_service, + if (gc_web_service_get_double (gsmloc->web_service, &lat, OPENCELLID_LAT)) { fields |= GEOCLUE_POSITION_FIELDS_LATITUDE; } - if (gc_web_service_get_double (gsmloc->web_service, + if (gc_web_service_get_double (gsmloc->web_service, &lon, OPENCELLID_LON)) { fields |= GEOCLUE_POSITION_FIELDS_LONGITUDE; } @@ -164,10 +164,10 @@ geoclue_gsmloc_query_opencellid (GeoclueGsmloc *gsmloc) if (fields != GEOCLUE_POSITION_FIELDS_NONE) { char *retval_cid; /* if cellid is not present, location is for the local area code. - * the accuracy might be an overstatement -- I have no idea how + * the accuracy might be an overstatement -- I have no idea how * big LACs typically are */ level = GEOCLUE_ACCURACY_LEVEL_LOCALITY; - if (gc_web_service_get_string (gsmloc->web_service, + if (gc_web_service_get_string (gsmloc->web_service, &retval_cid, OPENCELLID_CID)) { if (retval_cid && strlen (retval_cid) != 0) { level = GEOCLUE_ACCURACY_LEVEL_POSTALCODE; @@ -243,13 +243,13 @@ geoclue_gsmloc_update_address (GeoclueGsmloc *gsmloc) time (NULL), gsmloc->address, acc); - + } geoclue_accuracy_free (acc); } static void geoclue_gsmloc_set_cell (GeoclueGsmloc *gsmloc, - const char *mcc, const char *mnc, + const char *mcc, const char *mnc, const char *lac, const char *cid) { g_free (gsmloc->mcc); @@ -268,7 +268,7 @@ geoclue_gsmloc_set_cell (GeoclueGsmloc *gsmloc, static void network_data_changed_cb (gpointer connection_manager, - const char *mcc, const char *mnc, + const char *mcc, const char *mnc, const char *lac, const char *cid, GeoclueGsmloc *gsmloc) { @@ -284,7 +284,7 @@ network_data_changed_cb (gpointer connection_manager, /* Position interface implementation */ -static gboolean +static gboolean geoclue_gsmloc_get_position (GcIfacePosition *iface, GeocluePositionFields *fields, int *timestamp, @@ -392,7 +392,7 @@ geoclue_gsmloc_init (GeoclueGsmloc *gsmloc) { gsmloc->address = geoclue_address_details_new (); - gc_provider_set_details (GC_PROVIDER (gsmloc), + gc_provider_set_details (GC_PROVIDER (gsmloc), GEOCLUE_DBUS_SERVICE_GSMLOC, GEOCLUE_DBUS_PATH_GSMLOC, "Gsmloc", "GSM cell based position provider"); @@ -422,7 +422,7 @@ geoclue_gsmloc_address_init (GcIfaceAddressClass *iface) iface->get_address = geoclue_gsmloc_get_address; } -int +int main() { g_type_init(); diff --git a/providers/gsmloc/geoclue-gsmloc.provider b/providers/gsmloc/geoclue-gsmloc.provider old mode 100644 new mode 100755 diff --git a/providers/gsmloc/mcc.h b/providers/gsmloc/mcc.h old mode 100644 new mode 100755 index 8472b6e..f860cf2 --- a/providers/gsmloc/mcc.h +++ b/providers/gsmloc/mcc.h @@ -1,4 +1,4 @@ -/* Mobile country code list from +/* Mobile country code list from * "LIST OF MOBILE COUNTRY OR GEOGRAPHICAL AREA CODES" * (http://www.itu.int/publ/T-SP-E.212A-2007) * combined with ISO 3166-1 alpha-2 list for two letter country codes diff --git a/providers/gsmloc/ofono-manager.xml b/providers/gsmloc/ofono-manager.xml old mode 100644 new mode 100755 diff --git a/providers/gsmloc/ofono-marshal.list b/providers/gsmloc/ofono-marshal.list old mode 100644 new mode 100755 diff --git a/providers/gsmloc/ofono-modem.xml b/providers/gsmloc/ofono-modem.xml old mode 100644 new mode 100755 diff --git a/providers/gsmloc/ofono-network-operator.xml b/providers/gsmloc/ofono-network-operator.xml old mode 100644 new mode 100755 diff --git a/providers/gsmloc/ofono-network-registration.xml b/providers/gsmloc/ofono-network-registration.xml old mode 100644 new mode 100755 diff --git a/providers/gsmloc/org.freedesktop.Geoclue.Providers.Gsmloc.service.in b/providers/gsmloc/org.freedesktop.Geoclue.Providers.Gsmloc.service.in old mode 100644 new mode 100755 diff --git a/providers/gypsy/geoclue-gypsy.c b/providers/gypsy/geoclue-gypsy.c index 7d43450..4ebae94 100644 --- a/providers/gypsy/geoclue-gypsy.c +++ b/providers/gypsy/geoclue-gypsy.c @@ -38,7 +38,7 @@ typedef struct { GcProvider parent; char *device_name; - + GypsyControl *control; GypsyDevice *device; GypsyPosition *position; @@ -122,14 +122,14 @@ static GeocluePositionFields gypsy_position_to_geoclue (GypsyPositionFields fields) { GeocluePositionFields gc_fields = GEOCLUE_POSITION_FIELDS_NONE; - + gc_fields |= (fields & GYPSY_POSITION_FIELDS_LATITUDE) ? GEOCLUE_POSITION_FIELDS_LATITUDE : 0; gc_fields |= (fields & GYPSY_POSITION_FIELDS_LONGITUDE) ? GEOCLUE_POSITION_FIELDS_LONGITUDE : 0; gc_fields |= (fields & GYPSY_POSITION_FIELDS_ALTITUDE) ? GEOCLUE_POSITION_FIELDS_ALTITUDE : 0; - + return gc_fields; } - + static GeoclueVelocityFields gypsy_course_to_geoclue (GypsyCourseFields fields) { @@ -187,9 +187,9 @@ position_changed (GypsyPosition *position, g_print ("Emitting signal\n"); fields = gypsy_position_to_geoclue (gypsy->position_fields); - gc_iface_position_emit_position_changed + gc_iface_position_emit_position_changed (GC_IFACE_POSITION (gypsy), fields, - timestamp, gypsy->latitude, gypsy->longitude, + timestamp, gypsy->latitude, gypsy->longitude, gypsy->altitude, gypsy->accuracy); } } @@ -237,12 +237,12 @@ course_changed (GypsyCourse *course, GeoclueVelocityFields fields; fields = gypsy_course_to_geoclue (gypsy->course_fields); - gc_iface_velocity_emit_velocity_changed + gc_iface_velocity_emit_velocity_changed (GC_IFACE_VELOCITY (gypsy), fields, timestamp, gypsy->speed, gypsy->direction, gypsy->climb); } } - + static void accuracy_changed (GypsyAccuracy *accuracy, GypsyAccuracyFields fields, @@ -256,7 +256,7 @@ accuracy_changed (GypsyAccuracy *accuracy, double horiz, vert; geoclue_accuracy_get_details (gypsy->accuracy, &level, &horiz, &vert); - if (fields & (GYPSY_ACCURACY_FIELDS_HORIZONTAL | + if (fields & (GYPSY_ACCURACY_FIELDS_HORIZONTAL | GYPSY_ACCURACY_FIELDS_VERTICAL)){ if (level != GEOCLUE_ACCURACY_LEVEL_DETAILED || horiz != hdop || vert != vdop) { @@ -280,11 +280,11 @@ accuracy_changed (GypsyAccuracy *accuracy, if (changed) { GeocluePositionFields fields; - + fields = gypsy_position_to_geoclue (gypsy->position_fields); - gc_iface_position_emit_position_changed + gc_iface_position_emit_position_changed (GC_IFACE_POSITION (gypsy), fields, - gypsy->timestamp, gypsy->latitude, gypsy->longitude, + gypsy->timestamp, gypsy->latitude, gypsy->longitude, gypsy->altitude, gypsy->accuracy); } } @@ -294,7 +294,7 @@ connection_changed (GypsyDevice *device, gboolean connected, GeoclueGypsy *gypsy) { - if (connected == FALSE && + if (connected == FALSE && gypsy->status != GEOCLUE_STATUS_UNAVAILABLE) { gypsy->status = GEOCLUE_STATUS_UNAVAILABLE; gc_iface_geoclue_emit_status_changed (GC_IFACE_GEOCLUE (gypsy), @@ -381,7 +381,7 @@ set_options (GcIfaceGeoclue *gc, const char *device_name; char *path; - device_name = g_hash_table_lookup (options, + device_name = g_hash_table_lookup (options, "org.freedesktop.Geoclue.GPSDevice"); if (g_strcmp0 (gypsy->device_name, device_name) == 0) { @@ -413,7 +413,7 @@ set_options (GcIfaceGeoclue *gc, G_CALLBACK (connection_changed), gypsy); g_signal_connect (gypsy->device, "fix-status-changed", G_CALLBACK (fix_status_changed), gypsy); - + gypsy->position = gypsy_position_new (path); g_signal_connect (gypsy->position, "position-changed", G_CALLBACK (position_changed), gypsy); @@ -423,7 +423,7 @@ set_options (GcIfaceGeoclue *gc, gypsy->acc = gypsy_accuracy_new (path); g_signal_connect (gypsy->acc, "accuracy-changed", G_CALLBACK (accuracy_changed), gypsy); - + g_debug ("starting device"); gypsy_device_start (gypsy->device, error); if (*error != NULL) { @@ -434,7 +434,7 @@ set_options (GcIfaceGeoclue *gc, } get_initial_status (gypsy); g_free (path); - + return TRUE; } @@ -442,7 +442,7 @@ static void shutdown (GcProvider *provider) { GeoclueGypsy *gypsy = GEOCLUE_GYPSY (provider); - + g_main_loop_quit (gypsy->loop); } @@ -524,7 +524,7 @@ get_position (GcIfacePosition *gc, GeoclueGypsy *gypsy = GEOCLUE_GYPSY (gc); GeoclueAccuracyLevel level; double horizontal, vertical; - + *timestamp = gypsy->timestamp; *fields = GEOCLUE_POSITION_FIELDS_NONE; @@ -544,7 +544,7 @@ get_position (GcIfacePosition *gc, geoclue_accuracy_get_details (gypsy->accuracy, &level, &horizontal, &vertical); *accuracy = geoclue_accuracy_new (level, horizontal, vertical); - + return TRUE; } diff --git a/providers/gypsy/geoclue-gypsy.provider b/providers/gypsy/geoclue-gypsy.provider old mode 100644 new mode 100755 diff --git a/providers/gypsy/org.freedesktop.Geoclue.Providers.Gypsy.service.in b/providers/gypsy/org.freedesktop.Geoclue.Providers.Gypsy.service.in old mode 100644 new mode 100755 diff --git a/providers/hostip/Makefile.am b/providers/hostip/Makefile.am index ea841fd..e4220a8 100644 --- a/providers/hostip/Makefile.am +++ b/providers/hostip/Makefile.am @@ -15,7 +15,7 @@ geoclue_hostip_CFLAGS = \ geoclue_hostip_LDADD = \ $(GEOCLUE_LIBS) \ - $(top_builddir)/geoclue/libgeoclue.la + $(top_builddir)/geoclue/libgeoclue.la providersdir = $(datadir)/geoclue-providers providers_DATA = geoclue-hostip.provider diff --git a/providers/hostip/geoclue-hostip.c b/providers/hostip/geoclue-hostip.c old mode 100644 new mode 100755 index acafeea..1988abf --- a/providers/hostip/geoclue-hostip.c +++ b/providers/hostip/geoclue-hostip.c @@ -1,7 +1,7 @@ /* * Geoclue * geoclue-hostip.c - A hostip.info-based Address/Position provider - * + * * Author: Jussi Kukkonen * Copyright 2007, 2008 by Garmin Ltd. or its subsidiaries * @@ -80,7 +80,7 @@ shutdown (GcProvider *provider) /* Position interface implementation */ -static gboolean +static gboolean geoclue_hostip_get_position (GcIfacePosition *iface, GeocluePositionFields *fields, int *timestamp, @@ -92,14 +92,14 @@ geoclue_hostip_get_position (GcIfacePosition *iface, { GeoclueHostip *obj = (GEOCLUE_HOSTIP (iface)); gchar *coord_str = NULL; - + *fields = GEOCLUE_POSITION_FIELDS_NONE; - + if (!gc_web_service_query (obj->web_service, error, (char *)0)) { return FALSE; } - - if (gc_web_service_get_string (obj->web_service, + + if (gc_web_service_get_string (obj->web_service, &coord_str, HOSTIP_LATLON_XPATH)) { if (sscanf (coord_str, "%lf,%lf", longitude , latitude) == 2) { *fields |= GEOCLUE_POSITION_FIELDS_LONGITUDE; @@ -107,12 +107,12 @@ geoclue_hostip_get_position (GcIfacePosition *iface, } g_free (coord_str); } - + time ((time_t *)timestamp); - + if (*fields == GEOCLUE_POSITION_FIELDS_NONE) { *accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, - 0, 0); + 0, 0); } else { *accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_LOCALITY, 0, 0); @@ -122,7 +122,7 @@ geoclue_hostip_get_position (GcIfacePosition *iface, /* Address interface implementation */ -static gboolean +static gboolean geoclue_hostip_get_address (GcIfaceAddress *iface, int *timestamp, GHashTable **address, @@ -133,14 +133,14 @@ geoclue_hostip_get_address (GcIfaceAddress *iface, gchar *locality = NULL; gchar *country = NULL; gchar *country_code = NULL; - + if (!gc_web_service_query (obj->web_service, error, (char *)0)) { return FALSE; } - + if (address) { *address = geoclue_address_details_new (); - if (gc_web_service_get_string (obj->web_service, + if (gc_web_service_get_string (obj->web_service, &locality, HOSTIP_LOCALITY_XPATH)) { /* hostip "sctructured data" for the win... */ if (g_ascii_strcasecmp (locality, "(Unknown city)") == 0 || @@ -154,8 +154,8 @@ geoclue_hostip_get_address (GcIfaceAddress *iface, locality); } } - - if (gc_web_service_get_string (obj->web_service, + + if (gc_web_service_get_string (obj->web_service, &country_code, HOSTIP_COUNTRYCODE_XPATH)) { if (g_ascii_strcasecmp (country_code, "XX") == 0) { g_free (country_code); @@ -169,7 +169,7 @@ geoclue_hostip_get_address (GcIfaceAddress *iface, } if (!g_hash_table_lookup (*address, GEOCLUE_ADDRESS_KEY_COUNTRY) && - gc_web_service_get_string (obj->web_service, + gc_web_service_get_string (obj->web_service, &country, HOSTIP_COUNTRY_XPATH)) { if (g_ascii_strcasecmp (country, "(Unknown Country?)") == 0) { g_free (country); @@ -209,9 +209,9 @@ static void geoclue_hostip_finalize (GObject *obj) { GeoclueHostip *self = (GeoclueHostip *) obj; - + g_object_unref (self->web_service); - + ((GObjectClass *) geoclue_hostip_parent_class)->finalize (obj); } @@ -223,21 +223,21 @@ geoclue_hostip_class_init (GeoclueHostipClass *klass) { GcProviderClass *p_class = (GcProviderClass *)klass; GObjectClass *o_class = (GObjectClass *)klass; - + p_class->shutdown = shutdown; p_class->get_status = geoclue_hostip_get_status; - + o_class->finalize = geoclue_hostip_finalize; } static void geoclue_hostip_init (GeoclueHostip *obj) { - gc_provider_set_details (GC_PROVIDER (obj), + gc_provider_set_details (GC_PROVIDER (obj), GEOCLUE_DBUS_SERVICE_HOSTIP, GEOCLUE_DBUS_PATH_HOSTIP, "Hostip", "Hostip provider"); - + obj->web_service = g_object_new (GC_TYPE_WEB_SERVICE, NULL); gc_web_service_set_base_url (obj->web_service, HOSTIP_URL); gc_web_service_add_namespace (obj->web_service, @@ -256,18 +256,18 @@ geoclue_hostip_address_init (GcIfaceAddressClass *iface) iface->get_address = geoclue_hostip_get_address; } -int +int main() { g_type_init(); - + GeoclueHostip *o = g_object_new (GEOCLUE_TYPE_HOSTIP, NULL); o->loop = g_main_loop_new (NULL, TRUE); - + g_main_loop_run (o->loop); - + g_main_loop_unref (o->loop); g_object_unref (o); - + return 0; } diff --git a/providers/hostip/geoclue-hostip.h b/providers/hostip/geoclue-hostip.h old mode 100644 new mode 100755 diff --git a/providers/hostip/geoclue-hostip.provider b/providers/hostip/geoclue-hostip.provider old mode 100644 new mode 100755 diff --git a/providers/hostip/org.freedesktop.Geoclue.Providers.Hostip.service.in b/providers/hostip/org.freedesktop.Geoclue.Providers.Hostip.service.in old mode 100644 new mode 100755 diff --git a/providers/localnet/Makefile.am b/providers/localnet/Makefile.am index 6f5a85f..f810ec3 100644 --- a/providers/localnet/Makefile.am +++ b/providers/localnet/Makefile.am @@ -10,7 +10,7 @@ BUILT_SOURCES = \ $(nodist_geoclue_localnet_SOURCES) geoclue_localnet_SOURCES = \ - geoclue-localnet.c + geoclue-localnet.c geoclue_localnet_CFLAGS = \ -I$(top_srcdir) \ diff --git a/providers/localnet/geoclue-localnet.c b/providers/localnet/geoclue-localnet.c index 80501cb..57379ed 100644 --- a/providers/localnet/geoclue-localnet.c +++ b/providers/localnet/geoclue-localnet.c @@ -1,27 +1,27 @@ /** - * + * * Expects to find a keyfile in user config dir - * (~/.config/geoclue-localnet-gateways). - * + * (~/.config/geoclue-localnet-gateways). + * * The keyfile should contain entries like this: - * + * * [00:1D:7E:55:8D:80] * country=Finland * street=Solnantie 24 * locality=Helsinki * - * Only address interface is supported so far. - * - * Any application that can obtain a reliable address can submit it + * Only address interface is supported so far. + * + * Any application that can obtain a reliable address can submit it * to localnet provider through the D-Bus API -- it will then be provided * whenever connected to the same router: * org.freedesktop.Geoclue.Localnet.SetAddress * org.freedesktop.Geoclue.Localnet.SetAddressFields * - * SetAddress allows setting the current address as a GeoclueAddress, - * while SetAddressFields is a convenience version with separate + * SetAddress allows setting the current address as a GeoclueAddress, + * while SetAddressFields is a convenience version with separate * address fields. Shell example using SetAddressFields: - * + * dbus-send --print-reply --type=method_call \ --dest=org.freedesktop.Geoclue.Providers.Localnet \ /org/freedesktop/Geoclue/Providers/Localnet \ @@ -33,9 +33,9 @@ string: \ string: \ string:"Solnantie 24" - - * This would make the provider save the specified address with current - * router mac address. It will provide the address to clients whenever + + * This would make the provider save the specified address with current + * router mac address. It will provide the address to clients whenever * the computer is connected to the same router again. * * This library is free software; you can redistribute it and/or @@ -53,7 +53,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - */ + */ #include @@ -80,9 +80,9 @@ typedef struct { typedef struct { GcProvider parent; - + GMainLoop *loop; - + char *keyfile_name; GSList *gateways; } GeoclueLocalnet; @@ -118,7 +118,7 @@ static void shutdown (GcProvider *provider) { GeoclueLocalnet *localnet; - + localnet = GEOCLUE_LOCALNET (provider); g_main_loop_quit (localnet->loop); } @@ -127,17 +127,17 @@ static void free_gateway_list (GSList *gateways) { GSList *l; - + l = gateways; while (l) { Gateway *gw; - + gw = l->data; g_free (gw->mac); g_hash_table_destroy (gw->address); geoclue_accuracy_free (gw->accuracy); g_free (gw); - + l = l->next; } g_slist_free (gateways); @@ -147,12 +147,12 @@ static void finalize (GObject *object) { GeoclueLocalnet *localnet; - + localnet = GEOCLUE_LOCALNET (object); - + g_free (localnet->keyfile_name); free_gateway_list (localnet->gateways); - + G_OBJECT_CLASS (geoclue_localnet_parent_class)->finalize (object); } @@ -161,24 +161,24 @@ geoclue_localnet_class_init (GeoclueLocalnetClass *klass) { GcProviderClass *p_class = (GcProviderClass *) klass; GObjectClass *o_class = (GObjectClass *) klass; - + o_class->finalize = finalize; - + p_class->get_status = get_status; p_class->shutdown = shutdown; - + dbus_g_object_type_install_info (geoclue_localnet_get_type (), &dbus_glib_geoclue_localnet_object_info); } /* Parse /proc/net/route to get default gateway address and then parse - * /proc/net/arp to find matching mac address. + * /proc/net/arp to find matching mac address. * * There are some problems with this. First, it's IPv4 only. * Second, there must be a way to do this with ioctl, but that seemed really - * complicated... even /usr/sbin/arp parses /proc/net/arp - * + * complicated... even /usr/sbin/arp parses /proc/net/arp + * * returns: * 1 : on success * 0 : no success, no errors @@ -207,8 +207,8 @@ get_mac_address (char **mac) while (*entry && strlen (*entry) > 0) { char dest[9]; char gateway[9]; - if (sscanf (*entry, - "%*s %8[0-9A-Fa-f] %8[0-9A-Fa-f] %*s", + if (sscanf (*entry, + "%*s %8[0-9A-Fa-f] %8[0-9A-Fa-f] %*s", dest, gateway) != 2) { g_warning ("Failed to parse /proc/net/route entry '%s'", *entry); } else if (strcmp (dest, "00000000") == 0) { @@ -217,7 +217,7 @@ get_mac_address (char **mac) } entry++; } - g_strfreev (lines); + g_strfreev (lines); if (!route_gateway) { g_warning ("Failed to find default route in /proc/net/route"); @@ -229,7 +229,7 @@ get_mac_address (char **mac) g_error_free (error); return -1; } - + lines = g_strsplit (content, "\n", 0); g_free (content); entry = lines+1; @@ -237,9 +237,9 @@ get_mac_address (char **mac) char hwa[100]; char *arp_gateway; int ip[4]; - - if (sscanf(*entry, - "%d.%d.%d.%d 0x%*x 0x%*x %100s %*s %*s\n", + + if (sscanf(*entry, + "%d.%d.%d.%d 0x%*x 0x%*x %100s %*s %*s\n", &ip[0], &ip[1], &ip[2], &ip[3], hwa) != 5) { g_warning ("Failed to parse /proc/net/arp entry '%s'", *entry); } else { @@ -250,7 +250,7 @@ get_mac_address (char **mac) break; } g_free (arp_gateway); - + } entry++; } @@ -261,13 +261,13 @@ get_mac_address (char **mac) } static void -geoclue_localnet_load_gateways_from_keyfile (GeoclueLocalnet *localnet, +geoclue_localnet_load_gateways_from_keyfile (GeoclueLocalnet *localnet, GKeyFile *keyfile) { char **groups; char **g; GError *error = NULL; - + groups = g_key_file_get_groups (keyfile, NULL); g = groups; while (*g) { @@ -275,36 +275,36 @@ geoclue_localnet_load_gateways_from_keyfile (GeoclueLocalnet *localnet, char **keys; char **k; Gateway *gateway = g_new0 (Gateway, 1); - + gateway->mac = g_ascii_strdown (*g, -1); gateway->address = geoclue_address_details_new (); - + /* read all keys in the group as address fields */ keys = g_key_file_get_keys (keyfile, *g, NULL, &error); if (error) { - g_warning ("Could not load keys for group [%s] from %s: %s", + g_warning ("Could not load keys for group [%s] from %s: %s", *g, localnet->keyfile_name, error->message); g_error_free (error); error = NULL; } - + k = keys; while (*k) { char *value; - + value = g_key_file_get_string (keyfile, *g, *k, NULL); - g_hash_table_insert (gateway->address, + g_hash_table_insert (gateway->address, *k, value); k++; } g_free (keys); - + level = geoclue_address_details_get_accuracy_level (gateway->address); gateway->accuracy = geoclue_accuracy_new (level, 0, 0); - + localnet->gateways = g_slist_prepend (localnet->gateways, gateway); - + g++; } g_strfreev (groups); @@ -314,19 +314,19 @@ static Gateway * geoclue_localnet_find_gateway (GeoclueLocalnet *localnet, char *mac) { GSList *l; - + l = localnet->gateways; /* eww, should be using a hashtable or something here */ while (l) { Gateway *gw = l->data; - + if (strcmp (gw->mac, mac) == 0) { return gw; } - + l = l->next; } - + return NULL; } @@ -336,31 +336,31 @@ geoclue_localnet_init (GeoclueLocalnet *localnet) const char *dir; GKeyFile *keyfile; GError *error = NULL; - + gc_provider_set_details (GC_PROVIDER (localnet), "org.freedesktop.Geoclue.Providers.Localnet", "/org/freedesktop/Geoclue/Providers/Localnet", "Localnet", "provides Address based on current gateway mac address and a local address file (which can be updated through D-Bus)"); - - + + localnet->gateways = NULL; - + /* load known addresses from keyfile */ dir = g_get_user_config_dir (); g_mkdir_with_parents (dir, 0755); localnet->keyfile_name = g_build_filename (dir, KEYFILE_NAME, NULL); - + keyfile = g_key_file_new (); - if (!g_key_file_load_from_file (keyfile, localnet->keyfile_name, + if (!g_key_file_load_from_file (keyfile, localnet->keyfile_name, G_KEY_FILE_NONE, &error)) { - g_warning ("Could not load keyfile %s: %s", + g_warning ("Could not load keyfile %s: %s", localnet->keyfile_name, error->message); g_error_free (error); } geoclue_localnet_load_gateways_from_keyfile (localnet, keyfile); g_key_file_free (keyfile); - - + + } typedef struct { @@ -369,7 +369,7 @@ typedef struct { } localnet_keyfile_group; static void -add_address_detail_to_keyfile (char *key, char *value, +add_address_detail_to_keyfile (char *key, char *value, localnet_keyfile_group *group) { g_key_file_set_string (group->keyfile, group->group_name, @@ -386,15 +386,15 @@ geoclue_localnet_set_address (GeoclueLocalnet *localnet, GError *int_err = NULL; localnet_keyfile_group *keyfile_group; Gateway *gw; - + if (!details) { /* TODO set error */ return FALSE; } - - if (get_mac_address (&mac) < 0) + + if (get_mac_address (&mac) < 0) return FALSE; - + if (!mac) { g_warning ("Couldn't get current gateway mac address"); /* TODO set error */ @@ -402,23 +402,23 @@ geoclue_localnet_set_address (GeoclueLocalnet *localnet, } /* reload keyfile just in case it's changed */ keyfile = g_key_file_new (); - if (!g_key_file_load_from_file (keyfile, localnet->keyfile_name, + if (!g_key_file_load_from_file (keyfile, localnet->keyfile_name, G_KEY_FILE_NONE, &int_err)) { - g_warning ("Could not load keyfile %s: %s", + g_warning ("Could not load keyfile %s: %s", localnet->keyfile_name, int_err->message); g_error_free (int_err); int_err = NULL; } - + /* remove old group (if exists) and add new to GKeyFile */ g_key_file_remove_group (keyfile, mac, NULL); - + keyfile_group = g_new0 (localnet_keyfile_group, 1); keyfile_group->keyfile = keyfile; keyfile_group->group_name = mac; g_hash_table_foreach (details, (GHFunc) add_address_detail_to_keyfile, keyfile_group); g_free (keyfile_group); - + /* save keyfile*/ str = g_key_file_to_data (keyfile, NULL, &int_err); if (int_err) { @@ -429,7 +429,7 @@ geoclue_localnet_set_address (GeoclueLocalnet *localnet, /* TODO set error */ return FALSE; } - + g_file_set_contents (localnet->keyfile_name, str, -1, &int_err); g_free (str); if (int_err) { @@ -440,16 +440,16 @@ geoclue_localnet_set_address (GeoclueLocalnet *localnet, /* TODO set error */ return FALSE; } - + /* re-parse keyfile */ free_gateway_list (localnet->gateways); localnet->gateways = NULL; geoclue_localnet_load_gateways_from_keyfile (localnet, keyfile); g_key_file_free (keyfile); - + gw = geoclue_localnet_find_gateway (localnet, mac); g_free (mac); - + if (gw) { gc_iface_address_emit_address_changed (GC_IFACE_ADDRESS (localnet), time (NULL), gw->address, gw->accuracy); @@ -472,11 +472,11 @@ geoclue_localnet_set_address_fields (GeoclueLocalnet *localnet, { GHashTable *address; gboolean ret; - + address = geoclue_address_details_new (); if (country_code && (strlen (country_code) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_COUNTRYCODE), + g_strdup (GEOCLUE_ADDRESS_KEY_COUNTRYCODE), g_strdup (country_code)); if (!country) { geoclue_address_details_set_country_from_code (address); @@ -484,35 +484,35 @@ geoclue_localnet_set_address_fields (GeoclueLocalnet *localnet, } if (country && (strlen (country) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_COUNTRY), + g_strdup (GEOCLUE_ADDRESS_KEY_COUNTRY), g_strdup (country)); } if (region && (strlen (region) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_REGION), + g_strdup (GEOCLUE_ADDRESS_KEY_REGION), g_strdup (region)); } if (locality && (strlen (locality) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_LOCALITY), + g_strdup (GEOCLUE_ADDRESS_KEY_LOCALITY), g_strdup (locality)); } if (area && (strlen (area) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_AREA), + g_strdup (GEOCLUE_ADDRESS_KEY_AREA), g_strdup (area)); } if (postalcode && (strlen (postalcode) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_POSTALCODE), + g_strdup (GEOCLUE_ADDRESS_KEY_POSTALCODE), g_strdup (postalcode)); } if (street && (strlen (street) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_STREET), + g_strdup (GEOCLUE_ADDRESS_KEY_STREET), g_strdup (street)); } - + ret = geoclue_localnet_set_address (localnet, address, error); @@ -531,10 +531,10 @@ get_address (GcIfaceAddress *gc, int i, ret_val; char *mac = NULL; Gateway *gw; - + localnet = GEOCLUE_LOCALNET (gc); - /* we may be trying to read /proc/net/arp right after network connection. + /* we may be trying to read /proc/net/arp right after network connection. * It's sometimes not up yet, try a couple of times */ for (i = 0; i < 5; i++) { ret_val = get_mac_address (&mac); @@ -544,19 +544,19 @@ get_address (GcIfaceAddress *gc, break; usleep (200); } - + if (!mac) { g_warning ("Couldn't get current gateway mac address"); if (error) { - g_set_error (error, GEOCLUE_ERROR, + g_set_error (error, GEOCLUE_ERROR, GEOCLUE_ERROR_NOT_AVAILABLE, "Could not get current gateway mac address"); } return FALSE; } - + gw = geoclue_localnet_find_gateway (localnet, mac); g_free (mac); - + if (timestamp) { *timestamp = time(NULL); } @@ -588,16 +588,16 @@ main (int argc, char **argv) { GeoclueLocalnet *localnet; - + g_type_init (); - + localnet = g_object_new (GEOCLUE_TYPE_LOCALNET, NULL); localnet->loop = g_main_loop_new (NULL, TRUE); - + g_main_loop_run (localnet->loop); - + g_main_loop_unref (localnet->loop); g_object_unref (localnet); - + return 0; } diff --git a/providers/localnet/geoclue-localnet.provider b/providers/localnet/geoclue-localnet.provider old mode 100644 new mode 100755 diff --git a/providers/localnet/geoclue-localnet.xml b/providers/localnet/geoclue-localnet.xml old mode 100644 new mode 100755 diff --git a/providers/localnet/org.freedesktop.Geoclue.Providers.Localnet.service.in b/providers/localnet/org.freedesktop.Geoclue.Providers.Localnet.service.in old mode 100644 new mode 100755 diff --git a/providers/manual/Makefile.am b/providers/manual/Makefile.am index 86ead81..b7ff8ac 100644 --- a/providers/manual/Makefile.am +++ b/providers/manual/Makefile.am @@ -10,7 +10,7 @@ BUILT_SOURCES = \ $(nodist_geoclue_manual_SOURCES) geoclue_manual_SOURCES = \ - geoclue-manual.c + geoclue-manual.c geoclue_manual_CFLAGS = \ -I$(top_srcdir) \ diff --git a/providers/manual/geoclue-manual.c b/providers/manual/geoclue-manual.c index 3640c4b..b0a7922 100644 --- a/providers/manual/geoclue-manual.c +++ b/providers/manual/geoclue-manual.c @@ -23,17 +23,17 @@ */ /** Geoclue manual provider - * - * This is an address provider which gets its address data from user - * input. No UI is included, any application may query the address from + * + * This is an address provider which gets its address data from user + * input. No UI is included, any application may query the address from * the user and submit it to manual provider through the D-Bus API: * org.freedesktop.Geoclue.Manual.SetAddress * org.freedesktop.Geoclue.Manual.SetAddressFields - * - * SetAddress allows setting the current address as a GeoclueAddress, - * while SetAddressFields is a convenience version with separate + * + * SetAddress allows setting the current address as a GeoclueAddress, + * while SetAddressFields is a convenience version with separate * address fields. Shell example using SetAddressFields: - * + * * dbus-send --print-reply --type=method_call \ * --dest=org.freedesktop.Geoclue.Providers.Manual \ * /org/freedesktop/Geoclue/Providers/Manual \ @@ -46,10 +46,10 @@ * string: \ * string: \ * string:"Solnantie 24" - * - * This would make the provider emit a AddressChanged signal with - * accuracy level GEOCLUE_ACCURACY_STREET. Unless new SetAddress* calls - * are made, provider will emit another signal in two hours (7200 sec), + * + * This would make the provider emit a AddressChanged signal with + * accuracy level GEOCLUE_ACCURACY_STREET. Unless new SetAddress* calls + * are made, provider will emit another signal in two hours (7200 sec), * with empty address and GEOCLUE_ACCURACY_NONE. **/ @@ -63,11 +63,11 @@ typedef struct { GcProvider parent; - + GMainLoop *loop; - + guint event_id; - + int timestamp; GHashTable *address; GeoclueAccuracy *accuracy; @@ -138,19 +138,19 @@ static void shutdown (GcProvider *provider) { GeoclueManual *manual; - + manual = GEOCLUE_MANUAL (provider); g_main_loop_quit (manual->loop); } -gboolean +gboolean validity_ended (GeoclueManual *manual) { manual->event_id = 0; g_hash_table_remove_all (manual->address); geoclue_accuracy_set_details (manual->accuracy, GEOCLUE_ACCURACY_LEVEL_NONE, 0, 0); - + gc_iface_address_emit_address_changed (GC_IFACE_ADDRESS (manual), manual->timestamp, manual->address, @@ -167,24 +167,24 @@ geoclue_manual_set_address_common (GeoclueManual *manual, if (manual->event_id > 0) { g_source_remove (manual->event_id); } - + manual->timestamp = time (NULL); - + g_hash_table_destroy (manual->address); manual->address = address; - + geoclue_accuracy_set_details (manual->accuracy, get_accuracy_for_address (address), 0, 0); - + gc_iface_address_emit_address_changed (GC_IFACE_ADDRESS (manual), manual->timestamp, manual->address, manual->accuracy); - + if (valid_for > 0) { - manual->event_id = g_timeout_add (valid_for * 1000, - (GSourceFunc)validity_ended, + manual->event_id = g_timeout_add (valid_for * 1000, + (GSourceFunc)validity_ended, manual); } } @@ -214,44 +214,44 @@ geoclue_manual_set_address_fields (GeoclueManual *manual, GError **error) { GHashTable *address; - + address = geoclue_address_details_new (); if (country_code && (strlen (country_code) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_COUNTRYCODE), + g_strdup (GEOCLUE_ADDRESS_KEY_COUNTRYCODE), g_strdup (country_code)); } if (country && (strlen (country) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_COUNTRY), + g_strdup (GEOCLUE_ADDRESS_KEY_COUNTRY), g_strdup (country)); } if (region && (strlen (region) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_REGION), + g_strdup (GEOCLUE_ADDRESS_KEY_REGION), g_strdup (region)); } if (locality && (strlen (locality) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_LOCALITY), + g_strdup (GEOCLUE_ADDRESS_KEY_LOCALITY), g_strdup (locality)); } if (area && (strlen (area) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_AREA), + g_strdup (GEOCLUE_ADDRESS_KEY_AREA), g_strdup (area)); } if (postalcode && (strlen (postalcode) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_POSTALCODE), + g_strdup (GEOCLUE_ADDRESS_KEY_POSTALCODE), g_strdup (postalcode)); } if (street && (strlen (street) > 0)) { g_hash_table_insert (address, - g_strdup (GEOCLUE_ADDRESS_KEY_STREET), + g_strdup (GEOCLUE_ADDRESS_KEY_STREET), g_strdup (street)); } - + geoclue_manual_set_address_common (manual, valid_for, address); @@ -263,12 +263,12 @@ static void finalize (GObject *object) { GeoclueManual *manual; - + manual = GEOCLUE_MANUAL (object); - + g_hash_table_destroy (manual->address); geoclue_accuracy_free (manual->accuracy); - + ((GObjectClass *) geoclue_manual_parent_class)->finalize (object); } @@ -277,12 +277,12 @@ geoclue_manual_class_init (GeoclueManualClass *klass) { GObjectClass *o_class = (GObjectClass *) klass; GcProviderClass *p_class = (GcProviderClass *) klass; - + o_class->finalize = finalize; - + p_class->get_status = get_status; p_class->shutdown = shutdown; - + dbus_g_object_type_install_info (geoclue_manual_get_type (), &dbus_glib_geoclue_manual_object_info); } @@ -294,9 +294,9 @@ geoclue_manual_init (GeoclueManual *manual) "org.freedesktop.Geoclue.Providers.Manual", "/org/freedesktop/Geoclue/Providers/Manual", "Manual", "Manual provider"); - + manual->address = geoclue_address_details_new (); - manual->accuracy = + manual->accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0, 0); } @@ -308,8 +308,8 @@ get_address (GcIfaceAddress *gc, GError **error) { GeoclueManual *manual = GEOCLUE_MANUAL (gc); - - + + if (timestamp) { *timestamp = manual->timestamp; } @@ -319,7 +319,7 @@ get_address (GcIfaceAddress *gc, if (accuracy) { *accuracy = geoclue_accuracy_copy (manual->accuracy); } - + return TRUE; } @@ -334,16 +334,16 @@ main (int argc, char **argv) { GeoclueManual *manual; - + g_type_init (); - + manual = g_object_new (GEOCLUE_TYPE_MANUAL, NULL); manual->loop = g_main_loop_new (NULL, TRUE); - + g_main_loop_run (manual->loop); - + g_main_loop_unref (manual->loop); g_object_unref (manual); - + return 0; } diff --git a/providers/manual/geoclue-manual.provider b/providers/manual/geoclue-manual.provider old mode 100644 new mode 100755 diff --git a/providers/manual/geoclue-manual.xml b/providers/manual/geoclue-manual.xml old mode 100644 new mode 100755 diff --git a/providers/manual/org.freedesktop.Geoclue.Providers.Manual.service.in b/providers/manual/org.freedesktop.Geoclue.Providers.Manual.service.in old mode 100644 new mode 100755 diff --git a/providers/nominatim/Makefile.am b/providers/nominatim/Makefile.am index 7ffdc7e..9fac2da 100644 --- a/providers/nominatim/Makefile.am +++ b/providers/nominatim/Makefile.am @@ -15,7 +15,7 @@ geoclue_nominatim_CFLAGS = \ geoclue_nominatim_LDADD = \ $(GEOCLUE_LIBS) \ - $(top_builddir)/geoclue/libgeoclue.la + $(top_builddir)/geoclue/libgeoclue.la providersdir = $(datadir)/geoclue-providers providers_DATA = geoclue-nominatim.provider diff --git a/providers/nominatim/geoclue-nominatim.c b/providers/nominatim/geoclue-nominatim.c old mode 100644 new mode 100755 index 0ff8824..4a06226 --- a/providers/nominatim/geoclue-nominatim.c +++ b/providers/nominatim/geoclue-nominatim.c @@ -2,16 +2,16 @@ * Geoclue * geoclue-nominatim.c - A nominatim.openstreetmap.org-based "Geocode" and * "Reverse geocode" provider - * + * * Copyright 2010 by Intel Corporation - * + * * Author: Jussi Kukkonen */ /* - * The used web service APIs are documented at + * The used web service APIs are documented at * http://wiki.openstreetmap.org/wiki/Nominatim - * + * */ #include @@ -55,7 +55,7 @@ #define NOMINATIM_LATLON_COUNTY "//searchresults/place[1]/county" #define NOMINATIM_LATLON_COUNTRY "//searchresults/place[1]/country" #define NOMINATIM_LATLON_COUNTRYCODE "//searchresults/place[1]/countrycode" - + static void geoclue_nominatim_init (GeoclueNominatim *obj); static void geoclue_nominatim_geocode_init (GcIfaceGeocodeClass *iface); static void geoclue_nominatim_reverse_geocode_init (GcIfaceReverseGeocodeClass *iface); @@ -74,7 +74,7 @@ geoclue_nominatim_get_status (GcIfaceGeoclue *iface, GeoclueStatus *status, GError **error) { - /* Assumption that we are available so long as the + /* Assumption that we are available so long as the providers requirements are met: ie network is up */ *status = GEOCLUE_STATUS_AVAILABLE; @@ -85,7 +85,7 @@ static void shutdown (GcProvider *provider) { GeoclueNominatim *obj = GEOCLUE_NOMINATIM (provider); - + g_main_loop_quit (obj->loop); } @@ -177,18 +177,18 @@ geoclue_nominatim_address_to_position (GcIfaceGeocode *iface, g_string_free (str, TRUE); *fields = GEOCLUE_POSITION_FIELDS_NONE; - if (latitude && gc_web_service_get_double (obj->geocoder, + if (latitude && gc_web_service_get_double (obj->geocoder, latitude, NOMINATIM_LAT)) { *fields |= GEOCLUE_POSITION_FIELDS_LATITUDE; } - if (longitude && gc_web_service_get_double (obj->geocoder, + if (longitude && gc_web_service_get_double (obj->geocoder, longitude, NOMINATIM_LON)) { - *fields |= GEOCLUE_POSITION_FIELDS_LONGITUDE; + *fields |= GEOCLUE_POSITION_FIELDS_LONGITUDE; } if (accuracy) { - *accuracy = get_geocode_accuracy (obj->geocoder); + *accuracy = get_geocode_accuracy (obj->geocoder); } return TRUE; @@ -279,7 +279,7 @@ geoclue_nominatim_position_to_address (GcIfaceReverseGeocode *iface, *address = geoclue_address_details_new (); - if (in_acc >= GEOCLUE_ACCURACY_LEVEL_COUNTRY && + if (in_acc >= GEOCLUE_ACCURACY_LEVEL_COUNTRY && gc_web_service_get_string (obj->rev_geocoder, &countrycode, NOMINATIM_COUNTRYCODE)) { geoclue_address_details_insert (*address, @@ -289,7 +289,7 @@ geoclue_nominatim_position_to_address (GcIfaceReverseGeocode *iface, geoclue_address_details_set_country_from_code (*address); } if (!g_hash_table_lookup (*address, GEOCLUE_ADDRESS_KEY_COUNTRY) && - in_acc >= GEOCLUE_ACCURACY_LEVEL_COUNTRY && + in_acc >= GEOCLUE_ACCURACY_LEVEL_COUNTRY && gc_web_service_get_string (obj->rev_geocoder, &country, NOMINATIM_COUNTRY)) { geoclue_address_details_insert (*address, @@ -297,7 +297,7 @@ geoclue_nominatim_position_to_address (GcIfaceReverseGeocode *iface, country); g_free (country); } - if (in_acc >= GEOCLUE_ACCURACY_LEVEL_REGION && + if (in_acc >= GEOCLUE_ACCURACY_LEVEL_REGION && gc_web_service_get_string (obj->rev_geocoder, ®ion, NOMINATIM_COUNTY)) { geoclue_address_details_insert (*address, @@ -305,7 +305,7 @@ geoclue_nominatim_position_to_address (GcIfaceReverseGeocode *iface, region); g_free (region); } - if (in_acc >= GEOCLUE_ACCURACY_LEVEL_LOCALITY && + if (in_acc >= GEOCLUE_ACCURACY_LEVEL_LOCALITY && gc_web_service_get_string (obj->rev_geocoder, &locality, NOMINATIM_CITY)) { geoclue_address_details_insert (*address, @@ -313,7 +313,7 @@ geoclue_nominatim_position_to_address (GcIfaceReverseGeocode *iface, locality); g_free (locality); } - if (in_acc >= GEOCLUE_ACCURACY_LEVEL_POSTALCODE && + if (in_acc >= GEOCLUE_ACCURACY_LEVEL_POSTALCODE && gc_web_service_get_string (obj->rev_geocoder, &area, NOMINATIM_VILLAGE)) { geoclue_address_details_insert (*address, @@ -321,7 +321,7 @@ geoclue_nominatim_position_to_address (GcIfaceReverseGeocode *iface, area); g_free (area); } - if (in_acc >= GEOCLUE_ACCURACY_LEVEL_POSTALCODE && + if (in_acc >= GEOCLUE_ACCURACY_LEVEL_POSTALCODE && gc_web_service_get_string (obj->rev_geocoder, &postcode, NOMINATIM_POSTCODE)) { geoclue_address_details_insert (*address, @@ -329,7 +329,7 @@ geoclue_nominatim_position_to_address (GcIfaceReverseGeocode *iface, postcode); g_free (postcode); } - if (in_acc >= GEOCLUE_ACCURACY_LEVEL_STREET && + if (in_acc >= GEOCLUE_ACCURACY_LEVEL_STREET && gc_web_service_get_string (obj->rev_geocoder, &street, NOMINATIM_ROAD)) { char *nr; @@ -350,7 +350,7 @@ geoclue_nominatim_position_to_address (GcIfaceReverseGeocode *iface, g_free (street); } - if (address_accuracy) { + if (address_accuracy) { GeoclueAccuracyLevel level = geoclue_address_details_get_accuracy_level (*address); *address_accuracy = geoclue_accuracy_new (level, 0.0, 0.0); } @@ -388,7 +388,7 @@ geoclue_nominatim_class_init (GeoclueNominatimClass *klass) { GcProviderClass *p_class = (GcProviderClass *)klass; GObjectClass *o_class = (GObjectClass *)klass; - + p_class->shutdown = shutdown; p_class->get_status = geoclue_nominatim_get_status; @@ -399,14 +399,14 @@ geoclue_nominatim_class_init (GeoclueNominatimClass *klass) static void geoclue_nominatim_init (GeoclueNominatim *obj) { - gc_provider_set_details (GC_PROVIDER (obj), + gc_provider_set_details (GC_PROVIDER (obj), GEOCLUE_NOMINATIM_DBUS_SERVICE, GEOCLUE_NOMINATIM_DBUS_PATH, "Nominatim", "Nominatim (OpenStreetMap geocoder) provider"); obj->geocoder = g_object_new (GC_TYPE_WEB_SERVICE, NULL); gc_web_service_set_base_url (obj->geocoder, GEOCODE_URL); - + obj->rev_geocoder = g_object_new (GC_TYPE_WEB_SERVICE, NULL); gc_web_service_set_base_url (obj->rev_geocoder, REV_GEOCODE_URL); } @@ -424,19 +424,19 @@ geoclue_nominatim_reverse_geocode_init (GcIfaceReverseGeocodeClass *iface) iface->position_to_address = geoclue_nominatim_position_to_address; } -int +int main() { GeoclueNominatim *obj; - + g_type_init(); obj = g_object_new (GEOCLUE_TYPE_NOMINATIM, NULL); obj->loop = g_main_loop_new (NULL, TRUE); - + g_main_loop_run (obj->loop); - + g_main_loop_unref (obj->loop); g_object_unref (obj); - + return 0; } diff --git a/providers/nominatim/geoclue-nominatim.h b/providers/nominatim/geoclue-nominatim.h old mode 100644 new mode 100755 index a5d8d77..4900b0e --- a/providers/nominatim/geoclue-nominatim.h +++ b/providers/nominatim/geoclue-nominatim.h @@ -24,7 +24,7 @@ G_BEGIN_DECLS typedef struct _GeoclueNominatim { GcProvider parent; GMainLoop *loop; - + GcWebService *geocoder; GcWebService *rev_geocoder; } GeoclueNominatim; diff --git a/providers/nominatim/geoclue-nominatim.provider b/providers/nominatim/geoclue-nominatim.provider old mode 100644 new mode 100755 diff --git a/providers/nominatim/org.freedesktop.Geoclue.Providers.Nominatim.service.in b/providers/nominatim/org.freedesktop.Geoclue.Providers.Nominatim.service.in old mode 100644 new mode 100755 diff --git a/providers/plazes/Makefile.am b/providers/plazes/Makefile.am index de9323e..1cfa1cb 100644 --- a/providers/plazes/Makefile.am +++ b/providers/plazes/Makefile.am @@ -11,7 +11,7 @@ geoclue_plazes_CFLAGS = \ geoclue_plazes_LDADD = \ $(GEOCLUE_LIBS) \ - $(top_builddir)/geoclue/libgeoclue.la + $(top_builddir)/geoclue/libgeoclue.la providersdir = $(datadir)/geoclue-providers providers_DATA = geoclue-plazes.provider diff --git a/providers/plazes/geoclue-plazes.c b/providers/plazes/geoclue-plazes.c index ee88560..d12b4a1 100644 --- a/providers/plazes/geoclue-plazes.c +++ b/providers/plazes/geoclue-plazes.c @@ -1,7 +1,7 @@ /* * Geoclue * geoclue-plazes.c - A plazes.com-based Address/Position provider - * + * * Author: Jussi Kukkonen * Copyright 2008 by Garmin Ltd. or its subsidiaries * @@ -98,14 +98,14 @@ geoclue_plazes_set_status (GeocluePlazes *self, GeoclueStatus status) gc_iface_geoclue_emit_status_changed (GC_IFACE_GEOCLUE (self), status); } } - + /* Parse /proc/net/route to get default gateway address and then parse - * /proc/net/arp to find matching mac address. + * /proc/net/arp to find matching mac address. * * There are some problems with this. First, it's IPv4 only. * Second, there must be a way to do this with ioctl, but that seemed really - * complicated... even /usr/sbin/arp parses /proc/net/arp - * + * complicated... even /usr/sbin/arp parses /proc/net/arp + * * returns: * 1 : on success * 0 : no success, no errors @@ -134,8 +134,8 @@ get_mac_address (char **mac) while (*entry && strlen (*entry) > 0) { char dest[9]; char gateway[9]; - if (sscanf (*entry, - "%*s %8[0-9A-Fa-f] %8[0-9A-Fa-f] %*s", + if (sscanf (*entry, + "%*s %8[0-9A-Fa-f] %8[0-9A-Fa-f] %*s", dest, gateway) != 2) { g_warning ("Failed to parse /proc/net/route entry '%s'", *entry); } else if (strcmp (dest, "00000000") == 0) { @@ -144,7 +144,7 @@ get_mac_address (char **mac) } entry++; } - g_strfreev (lines); + g_strfreev (lines); if (!route_gateway) { g_warning ("Failed to find default route in /proc/net/route"); @@ -156,7 +156,7 @@ get_mac_address (char **mac) g_error_free (error); return -1; } - + lines = g_strsplit (content, "\n", 0); g_free (content); entry = lines+1; @@ -164,9 +164,9 @@ get_mac_address (char **mac) char hwa[100]; char *arp_gateway; int ip[4]; - - if (sscanf(*entry, - "%d.%d.%d.%d 0x%*x 0x%*x %100s %*s %*s\n", + + if (sscanf(*entry, + "%d.%d.%d.%d 0x%*x 0x%*x %100s %*s %*s\n", &ip[0], &ip[1], &ip[2], &ip[3], hwa) != 5) { g_warning ("Failed to parse /proc/net/arp entry '%s'", *entry); } else { @@ -177,7 +177,7 @@ get_mac_address (char **mac) break; } g_free (arp_gateway); - + } entry++; } @@ -190,7 +190,7 @@ get_mac_address (char **mac) /* Position interface implementation */ -static gboolean +static gboolean geoclue_plazes_get_position (GcIfacePosition *iface, GeocluePositionFields *fields, int *timestamp, @@ -203,15 +203,15 @@ geoclue_plazes_get_position (GcIfacePosition *iface, GeocluePlazes *plazes; int i, ret_val; char *mac = NULL; - + plazes = (GEOCLUE_PLAZES (iface)); - + *fields = GEOCLUE_POSITION_FIELDS_NONE; if (timestamp) { *timestamp = time (NULL); } - /* we may be trying to read /proc/net/arp right after network connection. + /* we may be trying to read /proc/net/arp right after network connection. * It's sometimes not up yet, try a couple of times */ for (i = 0; i < 5; i++) { ret_val = get_mac_address (&mac); @@ -223,55 +223,55 @@ geoclue_plazes_get_position (GcIfacePosition *iface, } if (mac == NULL) { - g_set_error (error, GEOCLUE_ERROR, - GEOCLUE_ERROR_NOT_AVAILABLE, + g_set_error (error, GEOCLUE_ERROR, + GEOCLUE_ERROR_NOT_AVAILABLE, "Router mac address query failed"); geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_ERROR); return FALSE; } - + geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_ACQUIRING); if (!gc_web_service_query (plazes->web_service, error, - PLAZES_KEY_MAC, mac, + PLAZES_KEY_MAC, mac, (char *)0)) { g_free (mac); // did not get a reply; we can try again later geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_AVAILABLE); - g_set_error (error, GEOCLUE_ERROR, - GEOCLUE_ERROR_NOT_AVAILABLE, + g_set_error (error, GEOCLUE_ERROR, + GEOCLUE_ERROR_NOT_AVAILABLE, "Did not get reply from server"); return FALSE; } - - if (latitude && gc_web_service_get_double (plazes->web_service, + + if (latitude && gc_web_service_get_double (plazes->web_service, latitude, PLAZES_LAT_XPATH)) { *fields |= GEOCLUE_POSITION_FIELDS_LATITUDE; } - if (longitude && gc_web_service_get_double (plazes->web_service, + if (longitude && gc_web_service_get_double (plazes->web_service, longitude, PLAZES_LON_XPATH)) { *fields |= GEOCLUE_POSITION_FIELDS_LONGITUDE; } - + if (accuracy) { - /* Educated guess. Plazes are typically hand pointed on - * a map, or geocoded from address, so should be fairly + /* Educated guess. Plazes are typically hand pointed on + * a map, or geocoded from address, so should be fairly * accurate */ *accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_STREET, 0, 0); } - + if (!(*fields & GEOCLUE_POSITION_FIELDS_LATITUDE && *fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)) { // we got a reply, but could not exploit it. It would probably be the // same next time. geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_ERROR); - g_set_error (error, GEOCLUE_ERROR, - GEOCLUE_ERROR_NOT_AVAILABLE, + g_set_error (error, GEOCLUE_ERROR, + GEOCLUE_ERROR_NOT_AVAILABLE, "Could not understand reply from server"); return FALSE; } - + geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_AVAILABLE); return TRUE; @@ -279,25 +279,25 @@ geoclue_plazes_get_position (GcIfacePosition *iface, /* Address interface implementation */ -static gboolean +static gboolean geoclue_plazes_get_address (GcIfaceAddress *iface, int *timestamp, GHashTable **address, GeoclueAccuracy **accuracy, GError **error) { - + GeocluePlazes *plazes = GEOCLUE_PLAZES (iface); int i, ret_val; char *mac = NULL; GeoclueAccuracyLevel level = GEOCLUE_ACCURACY_LEVEL_NONE; - + if (timestamp) { *timestamp = time (NULL); } - /* we may be trying to read /proc/net/arp right after network connection. + /* we may be trying to read /proc/net/arp right after network connection. * It's sometimes not up yet, try a couple of times */ for (i = 0; i < 5; i++) { ret_val = get_mac_address (&mac); @@ -309,32 +309,32 @@ geoclue_plazes_get_address (GcIfaceAddress *iface, } if (mac == NULL) { - g_set_error (error, GEOCLUE_ERROR, - GEOCLUE_ERROR_NOT_AVAILABLE, + g_set_error (error, GEOCLUE_ERROR, + GEOCLUE_ERROR_NOT_AVAILABLE, "Router mac address query failed"); geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_ERROR); return FALSE; } - + geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_ACQUIRING); if (!gc_web_service_query (plazes->web_service, error, - PLAZES_KEY_MAC, mac, + PLAZES_KEY_MAC, mac, (char *)0)) { g_free (mac); geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_AVAILABLE); - g_set_error (error, GEOCLUE_ERROR, - GEOCLUE_ERROR_NOT_AVAILABLE, + g_set_error (error, GEOCLUE_ERROR, + GEOCLUE_ERROR_NOT_AVAILABLE, "Did not get reply from server"); return FALSE; } - + if (address) { char *str; - + *address = geoclue_address_details_new (); - - if (gc_web_service_get_string (plazes->web_service, + + if (gc_web_service_get_string (plazes->web_service, &str, "//plaze/country")) { geoclue_address_details_insert (*address, GEOCLUE_ADDRESS_KEY_COUNTRY, @@ -342,7 +342,7 @@ geoclue_plazes_get_address (GcIfaceAddress *iface, g_free (str); level = GEOCLUE_ACCURACY_LEVEL_COUNTRY; } - if (gc_web_service_get_string (plazes->web_service, + if (gc_web_service_get_string (plazes->web_service, &str, "//plaze/country_code")) { geoclue_address_details_insert (*address, GEOCLUE_ADDRESS_KEY_COUNTRYCODE, @@ -350,7 +350,7 @@ geoclue_plazes_get_address (GcIfaceAddress *iface, g_free (str); level = GEOCLUE_ACCURACY_LEVEL_COUNTRY; } - if (gc_web_service_get_string (plazes->web_service, + if (gc_web_service_get_string (plazes->web_service, &str, "//plaze/city")) { geoclue_address_details_insert (*address, GEOCLUE_ADDRESS_KEY_LOCALITY, @@ -358,7 +358,7 @@ geoclue_plazes_get_address (GcIfaceAddress *iface, g_free (str); level = GEOCLUE_ACCURACY_LEVEL_LOCALITY; } - if (gc_web_service_get_string (plazes->web_service, + if (gc_web_service_get_string (plazes->web_service, &str, "//plaze/zip_code")) { geoclue_address_details_insert (*address, GEOCLUE_ADDRESS_KEY_POSTALCODE, @@ -366,7 +366,7 @@ geoclue_plazes_get_address (GcIfaceAddress *iface, g_free (str); level = GEOCLUE_ACCURACY_LEVEL_POSTALCODE; } - if (gc_web_service_get_string (plazes->web_service, + if (gc_web_service_get_string (plazes->web_service, &str, "//plaze/address")) { geoclue_address_details_insert (*address, GEOCLUE_ADDRESS_KEY_STREET, @@ -380,8 +380,8 @@ geoclue_plazes_get_address (GcIfaceAddress *iface, // we got a reply, but could not exploit it. It would probably be the // same next time. geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_ERROR); - g_set_error (error, GEOCLUE_ERROR, - GEOCLUE_ERROR_NOT_AVAILABLE, + g_set_error (error, GEOCLUE_ERROR, + GEOCLUE_ERROR_NOT_AVAILABLE, "Could not understand reply from server"); return FALSE; } @@ -389,7 +389,7 @@ geoclue_plazes_get_address (GcIfaceAddress *iface, if (accuracy) { *accuracy = geoclue_accuracy_new (level, 0, 0); } - + return TRUE; } @@ -397,9 +397,9 @@ static void geoclue_plazes_finalize (GObject *obj) { GeocluePlazes *plazes = GEOCLUE_PLAZES (obj); - + g_object_unref (plazes->web_service); - + ((GObjectClass *) geoclue_plazes_parent_class)->finalize (obj); } @@ -411,21 +411,21 @@ geoclue_plazes_class_init (GeocluePlazesClass *klass) { GcProviderClass *p_class = (GcProviderClass *)klass; GObjectClass *o_class = (GObjectClass *)klass; - + p_class->shutdown = shutdown; p_class->get_status = geoclue_plazes_get_status; - + o_class->finalize = geoclue_plazes_finalize; } static void geoclue_plazes_init (GeocluePlazes *plazes) { - gc_provider_set_details (GC_PROVIDER (plazes), + gc_provider_set_details (GC_PROVIDER (plazes), GEOCLUE_DBUS_SERVICE_PLAZES, GEOCLUE_DBUS_PATH_PLAZES, "Plazes", "Plazes.com based provider, uses gateway mac address to locate"); - + plazes->web_service = g_object_new (GC_TYPE_WEB_SERVICE, NULL); gc_web_service_set_base_url (plazes->web_service, PLAZES_URL); geoclue_plazes_set_status (plazes, GEOCLUE_STATUS_AVAILABLE); @@ -443,18 +443,18 @@ geoclue_plazes_address_init (GcIfaceAddressClass *iface) iface->get_address = geoclue_plazes_get_address; } -int +int main() { g_type_init(); - + GeocluePlazes *o = g_object_new (GEOCLUE_TYPE_PLAZES, NULL); o->loop = g_main_loop_new (NULL, TRUE); - + g_main_loop_run (o->loop); - + g_main_loop_unref (o->loop); g_object_unref (o); - + return 0; } diff --git a/providers/plazes/geoclue-plazes.provider b/providers/plazes/geoclue-plazes.provider old mode 100644 new mode 100755 diff --git a/providers/plazes/org.freedesktop.Geoclue.Providers.Plazes.service.in b/providers/plazes/org.freedesktop.Geoclue.Providers.Plazes.service.in old mode 100644 new mode 100755 diff --git a/providers/skyhook/Makefile.am b/providers/skyhook/Makefile.am index 6353d1b..a7d3f1c 100644 --- a/providers/skyhook/Makefile.am +++ b/providers/skyhook/Makefile.am @@ -13,7 +13,7 @@ geoclue_skyhook_CFLAGS = \ geoclue_skyhook_LDADD = \ $(GEOCLUE_LIBS) \ $(SKYHOOK_LIBS) \ - $(top_builddir)/geoclue/libgeoclue.la + $(top_builddir)/geoclue/libgeoclue.la providersdir = $(datadir)/geoclue-providers providers_DATA = geoclue-skyhook.provider diff --git a/providers/skyhook/geoclue-skyhook.c b/providers/skyhook/geoclue-skyhook.c index 71fa2a9..3a37a82 100644 --- a/providers/skyhook/geoclue-skyhook.c +++ b/providers/skyhook/geoclue-skyhook.c @@ -1,7 +1,7 @@ /* * Geoclue * geoclue-skyhook.c - A skyhook.com-based Address/Position provider - * + * * Author: Bastien Nocera * Copyright 2009 Bastien Nocera */ @@ -77,23 +77,23 @@ _shutdown (GcProvider *provider) static char * get_mac_address (void) { - /* this is an ugly hack, but it seems there is no easy - * ioctl-based way to get the mac address of the router. This - * implementation expects the system to have netstat, grep and awk + /* this is an ugly hack, but it seems there is no easy + * ioctl-based way to get the mac address of the router. This + * implementation expects the system to have netstat, grep and awk * */ - + FILE *in; char mac[MAC_LEN]; int i; - - /*for some reason netstat or /proc/net/arp isn't always ready + + /*for some reason netstat or /proc/net/arp isn't always ready * when a connection is already up... Try a couple of times */ for (i=0; i<10; i++) { if (!(in = popen ("ROUTER_IP=`netstat -rn | grep '^0.0.0.0 ' | awk '{ print $2 }'` && grep \"^$ROUTER_IP \" /proc/net/arp | awk '{print $4}'", "r"))) { g_warning ("popen failed"); return NULL; } - + if (!(fgets (mac, MAC_LEN, in))) { if (errno != ENOENT && errno != EAGAIN) { g_debug ("error %d", errno); @@ -180,7 +180,7 @@ parse_response (const char *body, gdouble *latitude, gdouble *longitude) /* Position interface implementation */ -static gboolean +static gboolean geoclue_skyhook_get_position (GcIfacePosition *iface, GeocluePositionFields *fields, int *timestamp, @@ -193,16 +193,16 @@ geoclue_skyhook_get_position (GcIfacePosition *iface, GeoclueSkyhook *skyhook; char *query; SoupMessage *msg; - + skyhook = (GEOCLUE_SKYHOOK (iface)); - + *fields = GEOCLUE_POSITION_FIELDS_NONE; if (timestamp) *timestamp = time (NULL); - + query = create_post_query (); if (query == NULL) { - g_set_error (error, GEOCLUE_ERROR, + g_set_error (error, GEOCLUE_ERROR, GEOCLUE_ERROR_NOT_AVAILABLE, "Router mac address query failed"); /* TODO: set status == error ? */ @@ -251,8 +251,8 @@ geoclue_skyhook_get_position (GcIfacePosition *iface, *accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0, 0); } else { - /* Educated guess. Skyhook are typically hand pointed on - * a map, or geocoded from address, so should be fairly + /* Educated guess. Skyhook are typically hand pointed on + * a map, or geocoded from address, so should be fairly * accurate */ *accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_STREET, 0, 0); @@ -266,9 +266,9 @@ static void geoclue_skyhook_finalize (GObject *obj) { GeoclueSkyhook *skyhook = GEOCLUE_SKYHOOK (obj); - + g_object_unref (skyhook->session); - + ((GObjectClass *) geoclue_skyhook_parent_class)->finalize (obj); } @@ -280,17 +280,17 @@ geoclue_skyhook_class_init (GeoclueSkyhookClass *klass) { GcProviderClass *p_class = (GcProviderClass *)klass; GObjectClass *o_class = (GObjectClass *)klass; - + p_class->shutdown = _shutdown; p_class->get_status = geoclue_skyhook_get_status; - + o_class->finalize = geoclue_skyhook_finalize; } static void geoclue_skyhook_init (GeoclueSkyhook *skyhook) { - gc_provider_set_details (GC_PROVIDER (skyhook), + gc_provider_set_details (GC_PROVIDER (skyhook), GEOCLUE_DBUS_SERVICE_SKYHOOK, GEOCLUE_DBUS_PATH_SKYHOOK, "Skyhook", "Skyhook.com based provider, uses gateway mac address to locate"); @@ -303,7 +303,7 @@ geoclue_skyhook_position_init (GcIfacePositionClass *iface) iface->get_position = geoclue_skyhook_get_position; } -int +int main() { g_type_init(); @@ -313,9 +313,9 @@ main() o->loop = g_main_loop_new (NULL, TRUE); g_main_loop_run (o->loop); - + g_main_loop_unref (o->loop); g_object_unref (o); - + return 0; } diff --git a/providers/skyhook/org.freedesktop.Geoclue.Providers.Skyhook.service.in b/providers/skyhook/org.freedesktop.Geoclue.Providers.Skyhook.service.in old mode 100644 new mode 100755 diff --git a/providers/yahoo/Makefile.am b/providers/yahoo/Makefile.am index 781d2f3..720d1cf 100644 --- a/providers/yahoo/Makefile.am +++ b/providers/yahoo/Makefile.am @@ -11,7 +11,7 @@ geoclue_yahoo_CFLAGS = \ geoclue_yahoo_LDADD = \ $(GEOCLUE_LIBS) \ - $(top_builddir)/geoclue/libgeoclue.la + $(top_builddir)/geoclue/libgeoclue.la providersdir = $(datadir)/geoclue-providers providers_DATA = geoclue-yahoo.provider diff --git a/providers/yahoo/geoclue-yahoo.c b/providers/yahoo/geoclue-yahoo.c old mode 100644 new mode 100755 index f36612b..92211e5 --- a/providers/yahoo/geoclue-yahoo.c +++ b/providers/yahoo/geoclue-yahoo.c @@ -2,9 +2,9 @@ * Geoclue * geoclue-yahoo.c - A "local.yahooapis.com"-based Geocode-provider which * converts from street address to position. - * + * * Copyright 2008 by Garmin Ltd. or its subsidiaries - * + * * Author: Jussi Kukkonen * * This library is free software; you can redistribute it and/or @@ -41,7 +41,7 @@ typedef struct _GeoclueYahoo { GcProvider parent; GMainLoop *loop; - + GcWebService *web_service; } GeoclueYahoo; @@ -49,7 +49,7 @@ typedef struct _GeoclueYahooClass { GcProviderClass parent_class; } GeoclueYahooClass; - + static void geoclue_yahoo_init (GeoclueYahoo *obj); static void geoclue_yahoo_geocode_init (GcIfaceGeocodeClass *iface); @@ -65,10 +65,10 @@ geoclue_yahoo_get_status (GcIfaceGeoclue *iface, GeoclueStatus *status, GError **error) { - /* Assumption that we are available so long as the + /* Assumption that we are available so long as the providers requirements are met: ie network is up */ *status = GEOCLUE_STATUS_AVAILABLE; - + return TRUE; } @@ -76,7 +76,7 @@ static void shutdown (GcProvider *provider) { GeoclueYahoo *yahoo = GEOCLUE_YAHOO (provider); - + g_main_loop_quit (yahoo->loop); } @@ -85,7 +85,7 @@ static char * get_address_value (GHashTable *address, char *key) { char *value; - + value = g_strdup (g_hash_table_lookup (address, key)); if (!value) { value = g_strdup (""); @@ -134,17 +134,17 @@ geoclue_yahoo_address_to_position (GcIfaceGeocode *iface, { GeoclueYahoo *yahoo; char *street, *postalcode, *locality, *region; - + yahoo = GEOCLUE_YAHOO (iface); - + *fields = GEOCLUE_POSITION_FIELDS_NONE; - + /* weird: the results are all over the globe, but country is not an input parameter... */ street = get_address_value (address, GEOCLUE_ADDRESS_KEY_STREET); postalcode = get_address_value (address, GEOCLUE_ADDRESS_KEY_POSTALCODE); locality = get_address_value (address, GEOCLUE_ADDRESS_KEY_LOCALITY); region = get_address_value (address, GEOCLUE_ADDRESS_KEY_REGION); - + if (!gc_web_service_query (yahoo->web_service, error, "appid", YAHOO_GEOCLUE_APP_ID, "street", street, @@ -154,30 +154,30 @@ geoclue_yahoo_address_to_position (GcIfaceGeocode *iface, (char *)0)) { return FALSE; } - + if (latitude) { if (gc_web_service_get_double (yahoo->web_service, latitude, "//yahoo:Latitude")) { - *fields |= GEOCLUE_POSITION_FIELDS_LATITUDE; + *fields |= GEOCLUE_POSITION_FIELDS_LATITUDE; } } if (longitude) { if (gc_web_service_get_double (yahoo->web_service, longitude, "//yahoo:Longitude")) { - *fields |= GEOCLUE_POSITION_FIELDS_LONGITUDE; + *fields |= GEOCLUE_POSITION_FIELDS_LONGITUDE; } } - + if (accuracy) { *accuracy = geoclue_accuracy_new (get_query_accuracy_level (yahoo), 0, 0); } - + g_free (street); g_free (postalcode); g_free (locality); g_free (region); - + return TRUE; } @@ -229,12 +229,12 @@ static void geoclue_yahoo_dispose (GObject *obj) { GeoclueYahoo *yahoo = (GeoclueYahoo *) obj; - + if (yahoo->web_service) { g_object_unref (yahoo->web_service); yahoo->web_service = NULL; } - + ((GObjectClass *) geoclue_yahoo_parent_class)->dispose (obj); } @@ -245,21 +245,21 @@ geoclue_yahoo_class_init (GeoclueYahooClass *klass) { GcProviderClass *p_class = (GcProviderClass *)klass; GObjectClass *o_class = (GObjectClass *)klass; - + p_class->shutdown = shutdown; p_class->get_status = geoclue_yahoo_get_status; - + o_class->dispose = geoclue_yahoo_dispose; } static void geoclue_yahoo_init (GeoclueYahoo *yahoo) { - gc_provider_set_details (GC_PROVIDER (yahoo), + gc_provider_set_details (GC_PROVIDER (yahoo), "org.freedesktop.Geoclue.Providers.Yahoo", "/org/freedesktop/Geoclue/Providers/Yahoo", "Yahoo", "Geocode provider that uses the Yahoo! Maps web services API"); - + yahoo->web_service = g_object_new (GC_TYPE_WEB_SERVICE, NULL); gc_web_service_set_base_url (yahoo->web_service, YAHOO_BASE_URL); gc_web_service_add_namespace (yahoo->web_service, "yahoo", "urn:yahoo:maps"); @@ -274,19 +274,19 @@ geoclue_yahoo_geocode_init (GcIfaceGeocodeClass *iface) geoclue_yahoo_freeform_address_to_position; } -int +int main() { GeoclueYahoo *yahoo; - + g_type_init(); yahoo = g_object_new (GEOCLUE_TYPE_YAHOO, NULL); yahoo->loop = g_main_loop_new (NULL, TRUE); - + g_main_loop_run (yahoo->loop); - + g_main_loop_unref (yahoo->loop); g_object_unref (yahoo); - + return 0; } diff --git a/providers/yahoo/geoclue-yahoo.provider b/providers/yahoo/geoclue-yahoo.provider old mode 100644 new mode 100755 diff --git a/providers/yahoo/org.freedesktop.Geoclue.Providers.Yahoo.service.in b/providers/yahoo/org.freedesktop.Geoclue.Providers.Yahoo.service.in old mode 100644 new mode 100755 diff --git a/src/client.c b/src/client.c index d4650e8..a40c983 100644 --- a/src/client.c +++ b/src/client.c @@ -25,10 +25,10 @@ */ /** TODO - * - * might want to write a testing-provider with a gui for + * + * might want to write a testing-provider with a gui for * choosing what to emit... - * + * **/ @@ -67,28 +67,28 @@ typedef struct _GcMasterClientPrivate { int min_time; gboolean require_updates; GeoclueResourceFlags allowed_resources; - + gboolean position_started; GcMasterProvider *position_provider; GList *position_providers; gboolean position_provider_choice_in_progress; - + gboolean address_started; GcMasterProvider *address_provider; GList *address_providers; gboolean address_provider_choice_in_progress; - + } GcMasterClientPrivate; #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GC_TYPE_MASTER_CLIENT, GcMasterClientPrivate)) -static gboolean gc_iface_master_client_set_requirements (GcMasterClient *client, - GeoclueAccuracyLevel min_accuracy, - int min_time, - gboolean require_updates, - GeoclueResourceFlags allowed_resources, +static gboolean gc_iface_master_client_set_requirements (GcMasterClient *client, + GeoclueAccuracyLevel min_accuracy, + int min_time, + gboolean require_updates, + GeoclueResourceFlags allowed_resources, GError **error); static gboolean gc_iface_master_client_position_start (GcMasterClient *client, GError **error); static gboolean gc_iface_master_client_address_start (GcMasterClient *client, GError **error); @@ -126,9 +126,9 @@ static gboolean status_change_requires_provider_change (GList *provid GeoclueStatus status); static void gc_master_client_emit_position_changed (GcMasterClient *client); static void gc_master_client_emit_address_changed (GcMasterClient *client); -static gboolean gc_master_client_choose_position_provider (GcMasterClient *client, +static gboolean gc_master_client_choose_position_provider (GcMasterClient *client, GList *providers); -static gboolean gc_master_client_choose_address_provider (GcMasterClient *client, +static gboolean gc_master_client_choose_address_provider (GcMasterClient *client, GList *providers); @@ -138,29 +138,29 @@ status_changed (GcMasterProvider *provider, GcMasterClient *client) { GcMasterClientPrivate *priv = GET_PRIVATE (client); - + g_debug ("client: provider %s status changed: %d", gc_master_provider_get_name (provider), status); - + /* change providers if needed (and if we're not choosing provider already) */ - + if (!priv->position_provider_choice_in_progress && status_change_requires_provider_change (priv->position_providers, priv->position_provider, provider, status) && - gc_master_client_choose_position_provider (client, + gc_master_client_choose_position_provider (client, priv->position_providers)) { - + /* we have a new position provider, force-emit position_changed */ gc_master_client_emit_position_changed (client); } - + if (!priv->address_provider_choice_in_progress && status_change_requires_provider_change (priv->address_providers, priv->address_provider, provider, status) && - gc_master_client_choose_address_provider (client, + gc_master_client_choose_address_provider (client, priv->address_providers)) { - + /* we have a new address provider, force-emit address_changed */ gc_master_client_emit_address_changed (client); } @@ -174,40 +174,40 @@ accuracy_changed (GcMasterProvider *provider, { GcMasterClientPrivate *priv = GET_PRIVATE (client); GcInterfaceAccuracy *accuracy_data; - + accuracy_data = g_new0 (GcInterfaceAccuracy, 1); - g_debug ("client: %s accuracy changed (%d)", + g_debug ("client: %s accuracy changed (%d)", gc_master_provider_get_name (provider), level); - + accuracy_data->interface = interface; accuracy_data->accuracy_level = priv->min_accuracy; switch (interface) { case GC_IFACE_POSITION: - priv->position_providers = - g_list_sort_with_data (priv->position_providers, + priv->position_providers = + g_list_sort_with_data (priv->position_providers, (GCompareDataFunc)gc_master_provider_compare, accuracy_data); if (priv->position_provider_choice_in_progress) { g_debug (" ...but provider choice in progress"); - } else if (gc_master_client_choose_position_provider (client, + } else if (gc_master_client_choose_position_provider (client, priv->position_providers)) { gc_master_client_emit_position_changed (client); } break; - + case GC_IFACE_ADDRESS: - priv->address_providers = - g_list_sort_with_data (priv->address_providers, + priv->address_providers = + g_list_sort_with_data (priv->address_providers, (GCompareDataFunc)gc_master_provider_compare, accuracy_data); if (priv->address_provider_choice_in_progress) { g_debug (" ...but provider choice in progress"); - } else if (gc_master_client_choose_address_provider (client, + } else if (gc_master_client_choose_address_provider (client, priv->address_providers)) { gc_master_client_emit_address_changed (client); } break; - + default: g_assert_not_reached (); } @@ -255,18 +255,18 @@ status_change_requires_provider_change (GList *provider_list, { if (!provider_list) { return FALSE; - + } else if (current_provider == NULL) { return (status == GEOCLUE_STATUS_AVAILABLE); - + } else if (current_provider == changed_provider) { return (status != GEOCLUE_STATUS_AVAILABLE); - + }else if (status != GEOCLUE_STATUS_AVAILABLE) { return FALSE; - + } - + while (provider_list) { GcMasterProvider *p = provider_list->data; if (p == current_provider) { @@ -287,7 +287,7 @@ gc_master_client_connect_common_signals (GcMasterClient *client, GList *provider { GcMasterClientPrivate *priv = GET_PRIVATE (client); GList *l; - + /* connect to common signals if the provider is not already connected */ l = providers; while (l) { @@ -313,11 +313,11 @@ gc_master_client_unsubscribe_providers (GcMasterClient *client, GList *provider_ { while (provider_list) { GcMasterProvider *provider = provider_list->data; - + gc_master_provider_unsubscribe (provider, client, iface); provider_list = provider_list->next; } - + } /* get_best_provider will return the best provider with status == GEOCLUE_STATUS_AVAILABLE. @@ -329,15 +329,15 @@ gc_master_client_get_best_provider (GcMasterClient *client, { GList *l = *provider_list; /* TODO: should maybe choose a acquiring provider if better ones are are not available */ - + g_debug ("client: choosing best provider"); - + while (l) { GcMasterProvider *provider = l->data; - + g_debug (" ...trying provider %s", gc_master_provider_get_name (provider)); if (gc_master_provider_subscribe (provider, client, iface)) { - /* provider was started, so accuracy may have changed + /* provider was started, so accuracy may have changed (which re-sorts provider lists), restart provider selection */ /* TODO re-think this: restarting provider selection leads to potentially never-ending looping */ @@ -348,7 +348,7 @@ gc_master_client_get_best_provider (GcMasterClient *client, continue; } /* provider did not need to be started */ - + /* TODO: currently returning even providers that are worse than priv->min_accuracy, * if nothing else is available */ if (gc_master_provider_get_status (provider) == GEOCLUE_STATUS_AVAILABLE) { @@ -358,7 +358,7 @@ gc_master_client_get_best_provider (GcMasterClient *client, } l = l->next; } - + /* no provider found */ gc_master_client_unsubscribe_providers (client, *provider_list, iface); return NULL; @@ -373,8 +373,8 @@ gc_master_client_emit_position_changed (GcMasterClient *client) double latitude, longitude, altitude; GeoclueAccuracy *accuracy = NULL; GError *error = NULL; - - + + if (priv->position_provider == NULL) { accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0.0, 0.0); gc_iface_position_emit_position_changed @@ -386,7 +386,7 @@ gc_master_client_emit_position_changed (GcMasterClient *client) geoclue_accuracy_free (accuracy); return; } - + fields = gc_master_provider_get_position (priv->position_provider, ×tamp, @@ -395,7 +395,7 @@ gc_master_client_emit_position_changed (GcMasterClient *client) &error); if (error) { /*TODO what now?*/ - g_warning ("client: failed to get position from %s: %s", + g_warning ("client: failed to get position from %s: %s", gc_master_provider_get_name (priv->position_provider), error->message); g_error_free (error); @@ -409,7 +409,7 @@ gc_master_client_emit_position_changed (GcMasterClient *client) accuracy); } -static void +static void gc_master_client_emit_address_changed (GcMasterClient *client) { GcMasterClientPrivate *priv = GET_PRIVATE (client); @@ -417,7 +417,7 @@ gc_master_client_emit_address_changed (GcMasterClient *client) GHashTable *details = NULL; GeoclueAccuracy *accuracy = NULL; GError *error = NULL; - + if (priv->address_provider == NULL) { accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0.0, 0.0); details = g_hash_table_new (g_str_hash, g_str_equal); @@ -437,7 +437,7 @@ gc_master_client_emit_address_changed (GcMasterClient *client) &accuracy, &error)) { /*TODO what now?*/ - g_warning ("client: failed to get address from %s: %s", + g_warning ("client: failed to get address from %s: %s", gc_master_provider_get_name (priv->address_provider), error->message); g_error_free (error); @@ -452,40 +452,40 @@ gc_master_client_emit_address_changed (GcMasterClient *client) /* return true if a _new_ provider was chosen */ static gboolean -gc_master_client_choose_position_provider (GcMasterClient *client, +gc_master_client_choose_position_provider (GcMasterClient *client, GList *providers) { GcMasterClientPrivate *priv = GET_PRIVATE (client); GcMasterProvider *new_p; - + /* choose and start provider */ priv->position_provider_choice_in_progress = TRUE; - new_p = gc_master_client_get_best_provider (client, - &priv->position_providers, + new_p = gc_master_client_get_best_provider (client, + &priv->position_providers, GC_IFACE_POSITION); priv->position_provider_choice_in_progress = FALSE; - + if (priv->position_provider && new_p == priv->position_provider) { return FALSE; } - + if (priv->signals[POSITION_CHANGED] > 0) { - g_signal_handler_disconnect (priv->position_provider, + g_signal_handler_disconnect (priv->position_provider, priv->signals[POSITION_CHANGED]); priv->signals[POSITION_CHANGED] = 0; } - + priv->position_provider = new_p; - + if (priv->position_provider == NULL) { g_debug ("client: position provider changed (to NULL)"); - g_signal_emit (client, signals[POSITION_PROVIDER_CHANGED], 0, + g_signal_emit (client, signals[POSITION_PROVIDER_CHANGED], 0, NULL, NULL, NULL, NULL); return TRUE; } - + g_debug ("client: position provider changed (to %s)", gc_master_provider_get_name (priv->position_provider)); - g_signal_emit (client, signals[POSITION_PROVIDER_CHANGED], 0, + g_signal_emit (client, signals[POSITION_PROVIDER_CHANGED], 0, gc_master_provider_get_name (priv->position_provider), gc_master_provider_get_description (priv->position_provider), gc_master_provider_get_service (priv->position_provider), @@ -500,47 +500,47 @@ gc_master_client_choose_position_provider (GcMasterClient *client, /* return true if a _new_ provider was chosen */ static gboolean -gc_master_client_choose_address_provider (GcMasterClient *client, +gc_master_client_choose_address_provider (GcMasterClient *client, GList *providers) { GcMasterClientPrivate *priv = GET_PRIVATE (client); GcMasterProvider *new_p; - - + + /* choose and start provider */ priv->address_provider_choice_in_progress = TRUE; - new_p = gc_master_client_get_best_provider (client, - &priv->address_providers, + new_p = gc_master_client_get_best_provider (client, + &priv->address_providers, GC_IFACE_ADDRESS); priv->address_provider_choice_in_progress = FALSE; - + if (priv->address_provider != NULL && new_p == priv->address_provider) { /* keep using the same provider */ return FALSE; } - + if (priv->address_provider && priv->signals[ADDRESS_CHANGED] > 0) { - g_signal_handler_disconnect (priv->address_provider, + g_signal_handler_disconnect (priv->address_provider, priv->signals[ADDRESS_CHANGED]); priv->signals[ADDRESS_CHANGED] = 0; } - + priv->address_provider = new_p; - + if (priv->address_provider == NULL) { g_debug ("client: address provider changed (to NULL)"); - g_signal_emit (client, signals[ADDRESS_PROVIDER_CHANGED], 0, + g_signal_emit (client, signals[ADDRESS_PROVIDER_CHANGED], 0, NULL, NULL, NULL, NULL); return TRUE; } - + g_debug ("client: address provider changed (to %s)", gc_master_provider_get_name (priv->address_provider)); - g_signal_emit (client, signals[ADDRESS_PROVIDER_CHANGED], 0, + g_signal_emit (client, signals[ADDRESS_PROVIDER_CHANGED], 0, gc_master_provider_get_name (priv->address_provider), gc_master_provider_get_description (priv->address_provider), gc_master_provider_get_service (priv->address_provider), gc_master_provider_get_path (priv->address_provider)); - priv->signals[ADDRESS_CHANGED] = + priv->signals[ADDRESS_CHANGED] = g_signal_connect (G_OBJECT (priv->address_provider), "address-changed", G_CALLBACK (address_changed), @@ -549,42 +549,42 @@ gc_master_client_choose_address_provider (GcMasterClient *client, } static void -gc_master_provider_set_position_providers (GcMasterClient *client, +gc_master_provider_set_position_providers (GcMasterClient *client, GList *providers) { GcMasterClientPrivate *priv = GET_PRIVATE (client); GcInterfaceAccuracy *accuracy_data; - + accuracy_data = g_new0(GcInterfaceAccuracy, 1); accuracy_data->interface = GC_IFACE_POSITION; accuracy_data->accuracy_level = priv->min_accuracy; - + gc_master_client_connect_common_signals (client, providers); - priv->position_providers = + priv->position_providers = g_list_sort_with_data (providers, (GCompareDataFunc)gc_master_provider_compare, accuracy_data); - + g_free (accuracy_data); } static void -gc_master_provider_set_address_providers (GcMasterClient *client, +gc_master_provider_set_address_providers (GcMasterClient *client, GList *providers) { GcMasterClientPrivate *priv = GET_PRIVATE (client); GcInterfaceAccuracy *accuracy_data; - + accuracy_data = g_new0(GcInterfaceAccuracy, 1); accuracy_data->interface = GC_IFACE_ADDRESS; accuracy_data->accuracy_level = priv->min_accuracy; - + gc_master_client_connect_common_signals (client, providers); - priv->address_providers = + priv->address_providers = g_list_sort_with_data (providers, (GCompareDataFunc)gc_master_provider_compare, accuracy_data); - + g_free (accuracy_data); } @@ -593,21 +593,21 @@ gc_master_client_init_position_providers (GcMasterClient *client) { GcMasterClientPrivate *priv = GET_PRIVATE (client); GList *providers; - + if (!priv->position_started) { return; } - + /* TODO: free priv->position_providers */ - + providers = gc_master_get_providers (GC_IFACE_POSITION, priv->min_accuracy, priv->require_updates, priv->allowed_resources, NULL); - g_debug ("client: %d position providers matching requirements found, now choosing current provider", + g_debug ("client: %d position providers matching requirements found, now choosing current provider", g_list_length (providers)); - + gc_master_provider_set_position_providers (client, providers); gc_master_client_choose_position_provider (client, priv->position_providers); } @@ -616,21 +616,21 @@ gc_master_client_init_address_providers (GcMasterClient *client) { GList *providers; GcMasterClientPrivate *priv = GET_PRIVATE (client); - + if (!priv->address_started) { return; } - + /* TODO: free priv->address_providers */ - + providers = gc_master_get_providers (GC_IFACE_ADDRESS, priv->min_accuracy, priv->require_updates, priv->allowed_resources, NULL); - g_debug ("client: %d address providers matching requirements found, now choosing current provider", + g_debug ("client: %d address providers matching requirements found, now choosing current provider", g_list_length (providers)); - + gc_master_provider_set_address_providers (client, providers); gc_master_client_choose_address_provider (client, priv->address_providers); } @@ -644,25 +644,25 @@ gc_iface_master_client_set_requirements (GcMasterClient *client, GError **error) { GcMasterClientPrivate *priv = GET_PRIVATE (client); - + priv->min_accuracy = min_accuracy; priv->min_time = min_time; priv->require_updates = require_updates; priv->allowed_resources = allowed_resources; - + gc_master_client_init_position_providers (client); gc_master_client_init_address_providers (client); - + return TRUE; } -static gboolean -gc_iface_master_client_position_start (GcMasterClient *client, +static gboolean +gc_iface_master_client_position_start (GcMasterClient *client, GError **error) { GcMasterClientPrivate *priv = GET_PRIVATE (client); - + if (priv->position_providers) { if (error) { *error = g_error_new (GEOCLUE_ERROR, @@ -671,20 +671,20 @@ gc_iface_master_client_position_start (GcMasterClient *client, } return FALSE; } - + priv->position_started = TRUE; - - gc_master_client_init_position_providers (client); - + + gc_master_client_init_position_providers (client); + return TRUE; } -static gboolean +static gboolean gc_iface_master_client_address_start (GcMasterClient *client, GError **error) { GcMasterClientPrivate *priv = GET_PRIVATE (client); - + if (priv->address_providers) { if (error) { *error = g_error_new (GEOCLUE_ERROR, @@ -693,7 +693,7 @@ gc_iface_master_client_address_start (GcMasterClient *client, } return FALSE; } - + priv->address_started = TRUE; gc_master_client_init_address_providers (client); return TRUE; @@ -735,9 +735,9 @@ get_master_provider_details (GcMasterProvider *provider, } } } - -static gboolean + +static gboolean gc_iface_master_client_get_address_provider (GcMasterClient *client, char **name, char **description, @@ -746,13 +746,13 @@ gc_iface_master_client_get_address_provider (GcMasterClient *client, GError **error) { GcMasterClientPrivate *priv = GET_PRIVATE (client); - + get_master_provider_details (priv->address_provider, name, description, service, path); return TRUE; } -static gboolean +static gboolean gc_iface_master_client_get_position_provider (GcMasterClient *client, char **name, char **description, @@ -761,7 +761,7 @@ gc_iface_master_client_get_position_provider (GcMasterClient *client, GError **error) { GcMasterClientPrivate *priv = GET_PRIVATE (client); - + get_master_provider_details (priv->position_provider, name, description, service, path); return TRUE; @@ -772,7 +772,7 @@ finalize (GObject *object) { GcMasterClient *client = GC_MASTER_CLIENT (object); GcMasterClientPrivate *priv = GET_PRIVATE (object); - + /* do not free contents of the lists, Master takes care of them */ if (priv->position_providers) { gc_master_client_unsubscribe_providers (client, priv->position_providers, GC_IFACE_ALL); @@ -784,7 +784,7 @@ finalize (GObject *object) g_list_free (priv->address_providers); priv->address_providers = NULL; } - + ((GObjectClass *) gc_master_client_parent_class)->finalize (object); } @@ -792,12 +792,12 @@ static void gc_master_client_class_init (GcMasterClientClass *klass) { GObjectClass *o_class = (GObjectClass *) klass; - + o_class->finalize = finalize; - + g_type_class_add_private (klass, sizeof (GcMasterClientPrivate)); - - signals[ADDRESS_PROVIDER_CHANGED] = + + signals[ADDRESS_PROVIDER_CHANGED] = g_signal_new ("address-provider-changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, @@ -805,7 +805,7 @@ gc_master_client_class_init (GcMasterClientClass *klass) geoclue_marshal_VOID__STRING_STRING_STRING_STRING, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); - signals[POSITION_PROVIDER_CHANGED] = + signals[POSITION_PROVIDER_CHANGED] = g_signal_new ("position-provider-changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, @@ -813,10 +813,10 @@ gc_master_client_class_init (GcMasterClientClass *klass) geoclue_marshal_VOID__STRING_STRING_STRING_STRING, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); - + dbus_g_object_type_install_info (gc_master_client_get_type (), &dbus_glib_gc_iface_master_client_object_info); - + } @@ -824,14 +824,14 @@ static void gc_master_client_init (GcMasterClient *client) { GcMasterClientPrivate *priv = GET_PRIVATE (client); - + priv->position_provider_choice_in_progress = FALSE; priv->address_provider_choice_in_progress = FALSE; - + priv->position_started = FALSE; priv->position_provider = NULL; priv->position_providers = NULL; - + priv->address_started = FALSE; priv->address_provider = NULL; priv->address_providers = NULL; @@ -849,7 +849,7 @@ get_position (GcIfacePosition *iface, { GcMasterClient *client = GC_MASTER_CLIENT (iface); GcMasterClientPrivate *priv = GET_PRIVATE (client); - + if (priv->position_provider == NULL) { if (error) { *error = g_error_new (GEOCLUE_ERROR, @@ -858,7 +858,7 @@ get_position (GcIfacePosition *iface, } return FALSE; } - + *fields = gc_master_provider_get_position (priv->position_provider, timestamp, @@ -868,7 +868,7 @@ get_position (GcIfacePosition *iface, return (!*error); } -static gboolean +static gboolean get_address (GcIfaceAddress *iface, int *timestamp, GHashTable **address, @@ -877,7 +877,7 @@ get_address (GcIfaceAddress *iface, { GcMasterClient *client = GC_MASTER_CLIENT (iface); GcMasterClientPrivate *priv = GET_PRIVATE (client); - + if (priv->address_provider == NULL) { if (error) { *error = g_error_new (GEOCLUE_ERROR, @@ -886,7 +886,7 @@ get_address (GcIfaceAddress *iface, } return FALSE; } - + return gc_master_provider_get_address (priv->address_provider, timestamp, @@ -911,12 +911,12 @@ set_options (GcIfaceGeoclue *geoclue, GError **error) { /* not meaningful, options come from master */ - + /* It is not an error to not have a SetOptions implementation */ return TRUE; } -static gboolean +static gboolean get_provider_info (GcIfaceGeoclue *geoclue, gchar **name, gchar **description, diff --git a/src/client.h b/src/client.h old mode 100644 new mode 100755 diff --git a/src/connectivity-conic.c b/src/connectivity-conic.c old mode 100644 new mode 100755 index c60cac8..14bc152 --- a/src/connectivity-conic.c +++ b/src/connectivity-conic.c @@ -43,7 +43,7 @@ static int get_status (GeoclueConnectivity *iface) { GeoclueConic *conic = GEOCLUE_CONIC (iface); - + return conic->status; } @@ -52,7 +52,7 @@ static void finalize (GObject *object) { /* free everything */ - + ((GObjectClass *) geoclue_conic_parent_class)->finalize (object); } @@ -60,7 +60,7 @@ static void dispose (GObject *object) { GeoclueConic *self = GEOCLUE_CONIC (object); - + g_object_unref (self->conic); ((GObjectClass *) geoclue_conic_parent_class)->dispose (object); } @@ -69,13 +69,13 @@ static void geoclue_conic_class_init (GeoclueConicClass *klass) { GObjectClass *o_class = (GObjectClass *) klass; - + o_class->finalize = finalize; o_class->dispose = dispose; } -static GeoclueNetworkStatus +static GeoclueNetworkStatus conicstatus_to_geocluenetworkstatus (ConIcConnectionStatus status) { switch (status) { @@ -99,7 +99,7 @@ geoclue_conic_state_changed (ConIcConnection *connection, GeoclueConic *self = GEOCLUE_CONIC (userdata); ConIcConnectionStatus status = con_ic_connection_event_get_status (event); GeoclueNetworkStatus gc_status; - + g_debug ("conic change"); gc_status = conicstatus_to_geocluenetworkstatus (status); if (gc_status != self->status) { @@ -113,9 +113,9 @@ static void geoclue_conic_init (GeoclueConic *self) { DBusConnection *system_bus = NULL; - + self->status = GEOCLUE_CONNECTIVITY_UNKNOWN; - + /* Need to run dbus_connection_setup_with_g_main(), * otherwise conic signals will not fire... */ system_bus = dbus_bus_get (DBUS_BUS_SYSTEM, NULL); @@ -124,22 +124,22 @@ geoclue_conic_init (GeoclueConic *self) return; } dbus_connection_setup_with_g_main (system_bus, NULL); - + self->conic = con_ic_connection_new(); if (self->conic == NULL) { g_warning ("Creating new ConicConnection failed"); return; } - - g_signal_connect (G_OBJECT (self->conic), - "connection-event", - G_CALLBACK (geoclue_conic_state_changed), + + g_signal_connect (G_OBJECT (self->conic), + "connection-event", + G_CALLBACK (geoclue_conic_state_changed), self); - - /* this should result in a connection-event signal with current + + /* this should result in a connection-event signal with current * connection status. Weird API.*/ - g_object_set (G_OBJECT (self->conic), - "automatic-connection-events", + g_object_set (G_OBJECT (self->conic), + "automatic-connection-events", TRUE, NULL); } diff --git a/src/connectivity-conic.h b/src/connectivity-conic.h old mode 100644 new mode 100755 index 7a3c862..f7733cd --- a/src/connectivity-conic.h +++ b/src/connectivity-conic.h @@ -36,7 +36,7 @@ G_BEGIN_DECLS typedef struct { GObject parent; - + /* private */ GeoclueNetworkStatus status; ConIcConnection *conic; diff --git a/src/connectivity-networkmanager.c b/src/connectivity-networkmanager.c index 95f1c37..93771bc 100644 --- a/src/connectivity-networkmanager.c +++ b/src/connectivity-networkmanager.c @@ -48,7 +48,7 @@ static int get_status (GeoclueConnectivity *iface) { GeoclueNetworkManager *nm = GEOCLUE_NETWORKMANAGER (iface); - + return nm->status; } @@ -110,7 +110,7 @@ static void finalize (GObject *object) { /* free everything */ - + ((GObjectClass *) geoclue_networkmanager_parent_class)->finalize (object); } @@ -118,7 +118,7 @@ static void dispose (GObject *object) { GeoclueNetworkManager *self = GEOCLUE_NETWORKMANAGER (object); - + dbus_g_connection_unref (self->connection); g_free (self->cache_ap_mac); self->cache_ap_mac = NULL; @@ -131,12 +131,12 @@ static void geoclue_networkmanager_class_init (GeoclueNetworkManagerClass *klass) { GObjectClass *o_class = (GObjectClass *) klass; - + o_class->finalize = finalize; o_class->dispose = dispose; } -static GeoclueNetworkStatus +static GeoclueNetworkStatus nmstate_to_geocluenetworkstatus (NMState status) { switch (status) { @@ -156,15 +156,15 @@ nmstate_to_geocluenetworkstatus (NMState status) } static void -geoclue_networkmanager_state_changed (DBusGProxy *proxy, - NMState status, +geoclue_networkmanager_state_changed (DBusGProxy *proxy, + NMState status, gpointer userdata) { GeoclueNetworkManager *self = GEOCLUE_NETWORKMANAGER (userdata); GeoclueNetworkStatus gc_status; - + gc_status = nmstate_to_geocluenetworkstatus (status); - + if (gc_status != self->status) { cache_ap_mac (self); self->status = gc_status; @@ -182,9 +182,9 @@ geoclue_networkmanager_init (GeoclueNetworkManager *self) GError *error = NULL; DBusGProxy *proxy; NMState state; - + self->status = GEOCLUE_CONNECTIVITY_UNKNOWN; - + self->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); if (self->connection == NULL) { g_warning ("%s was unable to create a connection to D-Bus: %s", @@ -192,19 +192,19 @@ geoclue_networkmanager_init (GeoclueNetworkManager *self) g_error_free (error); return; } - - proxy = dbus_g_proxy_new_for_name (self->connection, + + proxy = dbus_g_proxy_new_for_name (self->connection, NM_DBUS_SERVICE, - NM_DBUS_PATH, + NM_DBUS_PATH, NM_DBUS_INTERFACE); - dbus_g_proxy_add_signal (proxy, NM_DBUS_SIGNAL_STATE_CHANGE, + dbus_g_proxy_add_signal (proxy, NM_DBUS_SIGNAL_STATE_CHANGE, G_TYPE_UINT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (proxy, NM_DBUS_SIGNAL_STATE_CHANGE, - G_CALLBACK (geoclue_networkmanager_state_changed), + dbus_g_proxy_connect_signal (proxy, NM_DBUS_SIGNAL_STATE_CHANGE, + G_CALLBACK (geoclue_networkmanager_state_changed), self, NULL); - - if (dbus_g_proxy_call (proxy, "state", &error, - G_TYPE_INVALID, + + if (dbus_g_proxy_call (proxy, "state", &error, + G_TYPE_INVALID, G_TYPE_UINT, &state, G_TYPE_INVALID)){ self->status = nmstate_to_geocluenetworkstatus (state); } else { diff --git a/src/connectivity-networkmanager.h b/src/connectivity-networkmanager.h index 23e587d..762822a 100644 --- a/src/connectivity-networkmanager.h +++ b/src/connectivity-networkmanager.h @@ -37,7 +37,7 @@ G_BEGIN_DECLS typedef struct { GObject parent; - + /* private */ GeoclueNetworkStatus status; DBusGConnection *connection; diff --git a/src/connectivity.c b/src/connectivity.c index 713bae9..97ba408 100644 --- a/src/connectivity.c +++ b/src/connectivity.c @@ -35,16 +35,16 @@ static void geoclue_connectivity_base_init (gpointer klass) { static gboolean initialized = FALSE; - + if (initialized) { return; } - + initialized = TRUE; signals[STATUS_CHANGED] = g_signal_new ("status-changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GeoclueConnectivityInterface, + G_STRUCT_OFFSET (GeoclueConnectivityInterface, status_changed), NULL, NULL, g_cclosure_marshal_VOID__INT, @@ -55,19 +55,19 @@ GType geoclue_connectivity_get_type (void) { static GType type = 0; - + if (!type) { const GTypeInfo info = { sizeof (GeoclueConnectivityInterface), geoclue_connectivity_base_init, NULL, }; - + type = g_type_register_static (G_TYPE_INTERFACE, - "GeoclueConnectivity", + "GeoclueConnectivity", &info, 0); } - + return type; } diff --git a/src/connectivity.h b/src/connectivity.h index c9e9315..7a835e0 100644 --- a/src/connectivity.h +++ b/src/connectivity.h @@ -1,6 +1,6 @@ /* * Geoclue - * geoclue-connectivity.h + * geoclue-connectivity.h * * Author: Jussi Kukkonen * Copyright 2007 by Garmin Ltd. or its subsidiaries @@ -41,11 +41,11 @@ typedef struct _GeoclueConnectivityInterface GeoclueConnectivityInterface; struct _GeoclueConnectivityInterface { GTypeInterface parent; - + /* signals */ void (* status_changed) (GeoclueConnectivity *self, GeoclueNetworkStatus status); - + /* vtable */ int (*get_status) (GeoclueConnectivity *self); char * (*get_ap_mac) (GeoclueConnectivity *self); diff --git a/src/main.c b/src/main.c index 0f436af..79b94c6 100644 --- a/src/main.c +++ b/src/main.c @@ -111,7 +111,7 @@ load_options (void) value = NULL; g_print (" %s = %s\n", key, value); - g_hash_table_insert (ht, g_path_get_basename (key), + g_hash_table_insert (ht, g_path_get_basename (key), g_strdup (value)); gconf_entry_free (entry); } @@ -165,8 +165,8 @@ main (int argc, options = load_options (); master = g_object_new (GC_TYPE_MASTER, NULL); - dbus_g_connection_register_g_object (conn, - "/org/freedesktop/Geoclue/Master", + dbus_g_connection_register_g_object (conn, + "/org/freedesktop/Geoclue/Master", G_OBJECT (master)); g_main_loop_run (mainloop); diff --git a/src/main.h b/src/main.h old mode 100644 new mode 100755 diff --git a/src/master-provider.c b/src/master-provider.c index cffc8d8..4701a89 100644 --- a/src/master-provider.c +++ b/src/master-provider.c @@ -3,7 +3,7 @@ * master-provider.c - Provider object for master and master client * * Author: Jussi Kukkonen - * + * * Copyright 2007-2008 by Garmin Ltd. or its subsidiaries * 2008 OpenedHand Ltd * @@ -25,22 +25,22 @@ */ /** - * Provider object for GcMaster. Takes care of cacheing + * Provider object for GcMaster. Takes care of cacheing * queried data. - * + * * Should probably start/stop the actual providers as needed * in the future - * - * Cache could also be used to save "stale" data for situations when - * current data is not available (MasterClient api would have to + * + * Cache could also be used to save "stale" data for situations when + * current data is not available (MasterClient api would have to * have a "allowOldData" setting) - * - * TODO: + * + * TODO: * figure out what to do if get_* returns GEOCLUE_ERROR_NOT_AVAILABLE. * Should try again, but when? - * + * * implement velocity - * + * * implement other (non-updating) ifaces **/ @@ -78,30 +78,30 @@ typedef struct _GcAddressCache { typedef struct _GcMasterProviderPrivate { char *name; char *description; - + char *service; char *path; GcInterfaceFlags interfaces; - + GList *position_clients; /* list of clients currently using this provider */ GList *address_clients; - + GeoclueAccuracyLevel expected_accuracy; - + GeoclueResourceFlags required_resources; GeoclueProvideFlags provides; - + GeoclueStatus master_status; /* net_status and status affect this */ GeoclueNetworkStatus net_status; - + GeoclueStatus status; /* cached status from actual provider */ - + GeocluePosition *position; GcPositionCache position_cache; - + GeoclueAddress *address; GcAddressCache address_cache; - + } GcMasterProviderPrivate; enum { @@ -147,7 +147,7 @@ static GeoclueProvider* gc_master_provider_get_provider (GcMasterProvider *master_provider) { GcMasterProviderPrivate *priv = GET_PRIVATE (master_provider); - + if (priv->address) { return GEOCLUE_PROVIDER (priv->address); } @@ -163,7 +163,7 @@ gc_master_provider_is_running (GcMasterProvider *master_provider) return (gc_master_provider_get_provider (master_provider) != NULL); } -static void +static void gc_master_provider_handle_new_position_accuracy (GcMasterProvider *provider, GeoclueAccuracy *accuracy) { @@ -171,7 +171,7 @@ gc_master_provider_handle_new_position_accuracy (GcMasterProvider *provider, GeoclueAccuracyLevel old_level; GeoclueAccuracyLevel new_level = GEOCLUE_ACCURACY_LEVEL_NONE; double new_hor_acc, new_vert_acc; - + geoclue_accuracy_get_details (priv->position_cache.accuracy, &old_level, NULL, NULL); if (accuracy) { @@ -180,14 +180,14 @@ gc_master_provider_handle_new_position_accuracy (GcMasterProvider *provider, } geoclue_accuracy_set_details (priv->position_cache.accuracy, new_level, new_hor_acc, new_vert_acc); - + if (old_level != new_level) { g_signal_emit (provider, signals[ACCURACY_CHANGED], 0, GC_IFACE_POSITION, new_level); } } -static void +static void gc_master_provider_handle_new_address_accuracy (GcMasterProvider *provider, GeoclueAccuracy *accuracy) { @@ -195,7 +195,7 @@ gc_master_provider_handle_new_address_accuracy (GcMasterProvider *provider, GeoclueAccuracyLevel old_level; GeoclueAccuracyLevel new_level = GEOCLUE_ACCURACY_LEVEL_NONE; double new_hor_acc, new_vert_acc; - + geoclue_accuracy_get_details (priv->address_cache.accuracy, &old_level, NULL, NULL); if (accuracy) { @@ -204,7 +204,7 @@ gc_master_provider_handle_new_address_accuracy (GcMasterProvider *provider, } geoclue_accuracy_set_details (priv->address_cache.accuracy, new_level, new_hor_acc, new_vert_acc); - + if (old_level != new_level) { g_signal_emit (provider, signals[ACCURACY_CHANGED], 0, GC_IFACE_ADDRESS, new_level); @@ -222,23 +222,23 @@ gc_master_provider_set_position (GcMasterProvider *provider, GError *error) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - + priv->position_cache.timestamp = timestamp; priv->position_cache.fields = fields; priv->position_cache.latitude = latitude; priv->position_cache.longitude = longitude; priv->position_cache.altitude = altitude; - + copy_error (&priv->position_cache.error, error); - - /* emit accuracy-changed if needed, so masterclient can re-choose providers + + /* emit accuracy-changed if needed, so masterclient can re-choose providers * before we emit position-changed */ gc_master_provider_handle_new_position_accuracy (provider, accuracy); - + if (!error) { - g_signal_emit (provider, signals[POSITION_CHANGED], 0, - fields, timestamp, - latitude, longitude, altitude, + g_signal_emit (provider, signals[POSITION_CHANGED], 0, + fields, timestamp, + latitude, longitude, altitude, priv->position_cache.accuracy); } } @@ -251,9 +251,9 @@ gc_master_provider_set_address (GcMasterProvider *provider, GError *error) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - + priv->address_cache.timestamp = timestamp; - + g_hash_table_destroy (priv->address_cache.details); if (details) { priv->address_cache.details = geoclue_address_details_copy (details); @@ -261,15 +261,15 @@ gc_master_provider_set_address (GcMasterProvider *provider, priv->address_cache.details = geoclue_address_details_new (); } copy_error (&priv->address_cache.error, error); - - /* emit accuracy-changed if needed, so masterclient can re-choose providers + + /* emit accuracy-changed if needed, so masterclient can re-choose providers * before we emit position-changed */ gc_master_provider_handle_new_address_accuracy (provider, accuracy); - + if (!error) { - g_signal_emit (provider, signals[ADDRESS_CHANGED], 0, - priv->address_cache.timestamp, - priv->address_cache.details, + g_signal_emit (provider, signals[ADDRESS_CHANGED], 0, + priv->address_cache.timestamp, + priv->address_cache.details, priv->address_cache.accuracy); } } @@ -281,7 +281,7 @@ parse_resource_strings (char **flags) { GeoclueResourceFlags resources = GEOCLUE_RESOURCE_NONE; int i; - + for (i = 0; flags[i]; i++) { if (strcmp (flags[i], "RequiresNetwork") == 0) { resources |= GEOCLUE_RESOURCE_NETWORK; @@ -291,7 +291,7 @@ parse_resource_strings (char **flags) resources |= GEOCLUE_RESOURCE_GPS; } } - + return resources; } @@ -300,7 +300,7 @@ parse_provide_strings (char **flags) { GeoclueProvideFlags provides = GEOCLUE_PROVIDE_NONE; int i; - + for (i = 0; flags[i]; i++) { if (strcmp (flags[i], "ProvidesUpdates") == 0) { provides |= GEOCLUE_PROVIDE_UPDATES; @@ -308,7 +308,7 @@ parse_provide_strings (char **flags) provides |= GEOCLUE_PROVIDE_CACHEABLE_ON_CONNECTION; } } - + return provides; } @@ -317,7 +317,7 @@ parse_interface_strings (char **strs) { GcInterfaceFlags ifaces = GC_IFACE_GEOCLUE; int i; - + for (i = 0; strs[i]; i++) { if (strcmp (strs[i], GEOCLUE_POSITION_INTERFACE_NAME) == 0) { ifaces |= GC_IFACE_POSITION; @@ -348,7 +348,7 @@ parse_accuracy_string (char *str) level = GEOCLUE_ACCURACY_LEVEL_DETAILED; } else { g_warning ("'%s' is not a recognised accuracy level value", str); - } + } return level; } @@ -356,14 +356,14 @@ static void gc_master_provider_handle_error (GcMasterProvider *provider, GError *error) { GcMasterProviderPrivate *priv; - + g_assert (error); - + priv = GET_PRIVATE (provider); g_debug ("%s handling error %d", priv->name, error->code); - + /* web service providers that are unavailable */ - if (priv->provides & GEOCLUE_PROVIDE_CACHEABLE_ON_CONNECTION && + if (priv->provides & GEOCLUE_PROVIDE_CACHEABLE_ON_CONNECTION && error->code == GEOCLUE_ERROR_NOT_AVAILABLE) { priv->master_status = GEOCLUE_STATUS_UNAVAILABLE; /* TODO set timer to re-check availability */ @@ -376,9 +376,9 @@ static void gc_master_provider_handle_status_change (GcMasterProvider *provider) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - + GeoclueStatus new_master_status; - + /* calculate new master status */ if (priv->required_resources & GEOCLUE_RESOURCE_NETWORK || priv->provides & GEOCLUE_PROVIDE_CACHEABLE_ON_CONNECTION) { @@ -401,47 +401,47 @@ gc_master_provider_handle_status_change (GcMasterProvider *provider) default: g_assert_not_reached (); } - + } else { new_master_status = priv->status; } - + if (new_master_status != priv->master_status) { priv->master_status = new_master_status; - + g_signal_emit (provider, signals[STATUS_CHANGED], 0, new_master_status); } } -static void +static void gc_master_provider_update_cache (GcMasterProvider *master_provider) { GcMasterProviderPrivate *priv; - + priv = GET_PRIVATE (master_provider); - + if ((!(priv->provides & GEOCLUE_PROVIDE_UPDATES)) || (!gc_master_provider_get_provider (master_provider))) { /* non-cacheable provider or provider not running */ return; } - + g_debug ("%s: Updating cache ", priv->name); priv->master_status = GEOCLUE_STATUS_ACQUIRING; g_signal_emit (master_provider, signals[STATUS_CHANGED], 0, priv->master_status); - + if (priv->position) { int timestamp; double lat, lon, alt; GeocluePositionFields fields; GeoclueAccuracy *accuracy = NULL; GError *error = NULL; - + fields = geoclue_position_get_position (priv->position, ×tamp, &lat, &lon, &alt, - &accuracy, + &accuracy, &error); if (error){ g_warning ("Error updating position cache: %s", error->message); @@ -452,13 +452,13 @@ gc_master_provider_update_cache (GcMasterProvider *master_provider) lat, lon, alt, accuracy, error); } - + if (priv->address) { int timestamp; GHashTable *details = NULL; GeoclueAccuracy *accuracy = NULL; GError *error = NULL; - + if (!geoclue_address_get_address (priv->address, ×tamp, &details, @@ -473,7 +473,7 @@ gc_master_provider_update_cache (GcMasterProvider *master_provider) accuracy, error); } - + gc_master_provider_handle_status_change (master_provider); } @@ -485,7 +485,7 @@ provider_status_changed (GeoclueProvider *provider, GcMasterProvider *master_provider) { GcMasterProviderPrivate *priv = GET_PRIVATE (master_provider); - + priv->status = status; gc_master_provider_handle_status_change (master_provider); } @@ -500,7 +500,7 @@ position_changed (GeocluePosition *position, GeoclueAccuracy *accuracy, GcMasterProvider *provider) { - /* is there a situation when we'd need to check against cache + /* is there a situation when we'd need to check against cache * if data has really changed? probably not */ gc_master_provider_set_position (provider, fields, timestamp, @@ -515,7 +515,7 @@ address_changed (GeoclueAddress *address, GeoclueAccuracy *accuracy, GcMasterProvider *provider) { - /* is there a situation when we'd need to check against cache + /* is there a situation when we'd need to check against cache * if data has really changed? probably not */ gc_master_provider_set_address (provider, timestamp, @@ -529,7 +529,7 @@ static void finalize (GObject *object) { GcMasterProviderPrivate *priv = GET_PRIVATE (object); - + geoclue_accuracy_free (priv->position_cache.accuracy); geoclue_accuracy_free (priv->address_cache.accuracy); if (priv->position_cache.error) { @@ -538,15 +538,15 @@ finalize (GObject *object) if (priv->address_cache.error) { g_error_free (priv->address_cache.error); } - + g_free (priv->name); g_free (priv->description); g_free (priv->service); g_free (priv->path); - + g_free (priv->position_clients); g_free (priv->address_clients); - + G_OBJECT_CLASS (gc_master_provider_parent_class)->finalize (object); } @@ -554,12 +554,12 @@ static void dispose (GObject *object) { GcMasterProviderPrivate *priv = GET_PRIVATE (object); - + if (priv->position) { g_object_unref (priv->position); priv->position = NULL; } - + if (priv->address) { g_object_unref (priv->address); priv->address = NULL; @@ -568,7 +568,7 @@ dispose (GObject *object) g_hash_table_destroy (priv->address_cache.details); priv->address_cache.details = NULL; } - + G_OBJECT_CLASS (gc_master_provider_parent_class)->dispose (object); } @@ -576,17 +576,17 @@ static void gc_master_provider_class_init (GcMasterProviderClass *klass) { GObjectClass *o_class = (GObjectClass *) klass; - + o_class->finalize = finalize; o_class->dispose = dispose; - + g_type_class_add_private (klass, sizeof (GcMasterProviderPrivate)); - + signals[STATUS_CHANGED] = g_signal_new ("status-changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GcMasterProviderClass, status_changed), + G_STRUCT_OFFSET (GcMasterProviderClass, status_changed), NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, @@ -595,7 +595,7 @@ gc_master_provider_class_init (GcMasterProviderClass *klass) G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GcMasterProviderClass, accuracy_changed), + G_STRUCT_OFFSET (GcMasterProviderClass, accuracy_changed), NULL, NULL, geoclue_marshal_VOID__INT_INT, G_TYPE_NONE, 2, @@ -604,7 +604,7 @@ gc_master_provider_class_init (GcMasterProviderClass *klass) G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GcMasterProviderClass, position_changed), + G_STRUCT_OFFSET (GcMasterProviderClass, position_changed), NULL, NULL, geoclue_marshal_VOID__INT_INT_DOUBLE_DOUBLE_DOUBLE_BOXED, G_TYPE_NONE, 6, @@ -615,11 +615,11 @@ gc_master_provider_class_init (GcMasterProviderClass *klass) G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GcMasterProviderClass, address_changed), + G_STRUCT_OFFSET (GcMasterProviderClass, address_changed), NULL, NULL, geoclue_marshal_VOID__INT_BOXED_BOXED, G_TYPE_NONE, 3, - G_TYPE_INT, + G_TYPE_INT, G_TYPE_POINTER, G_TYPE_POINTER); } @@ -628,19 +628,19 @@ static void gc_master_provider_init (GcMasterProvider *provider) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - + priv->position_clients = NULL; priv->address_clients = NULL; - + priv->master_status = GEOCLUE_STATUS_UNAVAILABLE; - + priv->position = NULL; - priv->position_cache.accuracy = + priv->position_cache.accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0 ,0); priv->position_cache.error = NULL; - + priv->address = NULL; - priv->address_cache.accuracy = + priv->address_cache.accuracy = geoclue_accuracy_new (GEOCLUE_ACCURACY_LEVEL_NONE, 0 ,0); priv->address_cache.details = geoclue_address_details_new (); priv->address_cache.error = NULL; @@ -655,15 +655,15 @@ gc_master_provider_dump_position (GcMasterProvider *provider) int time; double lat, lon, alt; GError *error = NULL; - + priv = GET_PRIVATE (provider); - - + + g_print (" Position Information:\n"); g_print (" ---------------------\n"); - + fields = gc_master_provider_get_position (provider, - &time, + &time, &lat, &lon, &alt, NULL, &error); if (error) { @@ -678,7 +678,7 @@ gc_master_provider_dump_position (GcMasterProvider *provider) fields & GEOCLUE_POSITION_FIELDS_LONGITUDE ? "" : "(not set)"); g_print (" Altitude: %.2f %s\n", alt, fields & GEOCLUE_POSITION_FIELDS_ALTITUDE ? "" : "(not set)"); - + } static void @@ -693,11 +693,11 @@ gc_master_provider_dump_address (GcMasterProvider *provider) int time; GHashTable *details; GError *error = NULL; - + g_print (" Address Information:\n"); g_print (" --------------------\n"); if (!gc_master_provider_get_address (provider, - &time, + &time, &details, NULL, &error)) { g_print (" Error: %s", error->message); @@ -706,14 +706,14 @@ gc_master_provider_dump_address (GcMasterProvider *provider) } g_print (" Timestamp: %d\n", time); g_hash_table_foreach (details, (GHFunc)dump_address_key_and_value, NULL); - + } static void gc_master_provider_dump_required_resources (GcMasterProvider *provider) { GcMasterProviderPrivate *priv; - + priv = GET_PRIVATE (provider); g_print (" Requires\n"); if (priv->required_resources & GEOCLUE_RESOURCE_GPS) { @@ -729,7 +729,7 @@ static void gc_master_provider_dump_provides (GcMasterProvider *provider) { GcMasterProviderPrivate *priv; - + priv = GET_PRIVATE (provider); g_print (" Provides\n"); if (priv->provides & GEOCLUE_PROVIDE_UPDATES) { @@ -744,20 +744,20 @@ static void gc_master_provider_dump_provider_details (GcMasterProvider *provider) { GcMasterProviderPrivate *priv; - + priv = GET_PRIVATE (provider); g_print ("\n Name - %s\n", priv->name); g_print (" Description - %s\n", priv->description); g_print (" Service - %s\n", priv->service); g_print (" Path - %s\n", priv->path); g_print (" Accuracy level - %d\n", priv->expected_accuracy); - g_print (" Provider is currently %srunning, status %d\n", + g_print (" Provider is currently %srunning, status %d\n", gc_master_provider_get_provider (master_provider) ? "" : "not ", priv->master_status); gc_master_provider_dump_required_resources (provider); gc_master_provider_dump_provides (provider); - - + + if (priv->interfaces & GC_IFACE_POSITION) { g_print (" Interface - Position\n"); gc_master_provider_dump_position (provider); @@ -775,9 +775,9 @@ gc_master_provider_initialize_geoclue (GcMasterProvider *master_provider) GcMasterProviderPrivate *priv = GET_PRIVATE (master_provider); GeoclueProvider *geoclue; GError *error = NULL; - + geoclue = gc_master_provider_get_provider (master_provider); - + if (!geoclue_provider_set_options (geoclue, geoclue_get_main_options (), &error)) { @@ -785,20 +785,20 @@ gc_master_provider_initialize_geoclue (GcMasterProvider *master_provider) g_error_free (error); return FALSE; } - + /* priv->name has been read from .provider-file earlier... * could ask the provider anyway, just to be consistent */ - if (!geoclue_provider_get_provider_info (geoclue, NULL, + if (!geoclue_provider_get_provider_info (geoclue, NULL, &priv->description, &error)) { g_warning ("Error getting provider info: %s\n", error->message); g_error_free (error); return FALSE; } - + g_signal_connect (G_OBJECT (geoclue), "status-changed", G_CALLBACK (provider_status_changed), master_provider); - - + + if (!geoclue_provider_get_status (geoclue, &priv->status, &error)) { g_warning ("Error getting provider status: %s\n", error->message); g_error_free (error); @@ -811,35 +811,35 @@ static gboolean gc_master_provider_initialize_interfaces (GcMasterProvider *provider) { GcMasterProviderPrivate *priv; - + priv = GET_PRIVATE (provider); - + if (priv->interfaces <= GC_IFACE_GEOCLUE) { g_warning ("No interfaces defined for %s", priv->name); return FALSE; } - + if (priv->interfaces & GC_IFACE_POSITION) { g_assert (priv->position == NULL); - - priv->position = geoclue_position_new (priv->service, + + priv->position = geoclue_position_new (priv->service, priv->path); g_signal_connect (G_OBJECT (priv->position), "position-changed", G_CALLBACK (position_changed), provider); } if (priv->interfaces & GC_IFACE_ADDRESS) { g_assert (priv->address == NULL); - - priv->address = geoclue_address_new (priv->service, + + priv->address = geoclue_address_new (priv->service, priv->path); g_signal_connect (G_OBJECT (priv->address), "address-changed", G_CALLBACK (address_changed), provider); } - + if (!gc_master_provider_initialize_geoclue (provider)) { return FALSE; } - + return TRUE; } @@ -848,13 +848,13 @@ static gboolean gc_master_provider_initialize (GcMasterProvider *provider) { GcMasterProviderPrivate *priv; - + priv = GET_PRIVATE (provider); - + if (!gc_master_provider_initialize_interfaces (provider)) { return FALSE; } - + gc_master_provider_update_cache (provider); #if DEBUG_INFO gc_master_provider_dump_provider_details (provider); @@ -866,7 +866,7 @@ static void gc_master_provider_deinitialize (GcMasterProvider *provider) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - + if (priv->position) { g_object_unref (priv->position); priv->position = NULL; @@ -879,14 +879,14 @@ gc_master_provider_deinitialize (GcMasterProvider *provider) } static void -network_status_changed (gpointer *connectivity, - GeoclueNetworkStatus status, +network_status_changed (gpointer *connectivity, + GeoclueNetworkStatus status, GcMasterProvider *provider) { GcMasterProviderPrivate *priv; - + priv = GET_PRIVATE (provider); - + priv->net_status = status; /* update connection-cacheable providers */ if (status == GEOCLUE_CONNECTIVITY_ONLINE && @@ -914,7 +914,7 @@ update_cache_and_deinit (GcMasterProvider *provider) /* public methods (for GcMaster and GcMasterClient) */ -/* Loads provider details from 'filename' */ +/* Loads provider details from 'filename' */ GcMasterProvider * gc_master_provider_new (const char *filename, GeoclueConnectivity *connectivity) @@ -924,11 +924,11 @@ gc_master_provider_new (const char *filename, GKeyFile *keyfile; GError *error = NULL; gboolean ret; - char *accuracy_str; + char *accuracy_str; char **flags, **interfaces; - + keyfile = g_key_file_new (); - ret = g_key_file_load_from_file (keyfile, filename, + ret = g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, &error); if (ret == FALSE) { g_warning ("Error loading %s: %s", filename, error->message); @@ -936,31 +936,31 @@ gc_master_provider_new (const char *filename, g_key_file_free (keyfile); return NULL; } - + provider = g_object_new (GC_TYPE_MASTER_PROVIDER, NULL); priv = GET_PRIVATE (provider); - + priv->name = g_key_file_get_value (keyfile, "Geoclue Provider", "Name", NULL); priv->service = g_key_file_get_value (keyfile, "Geoclue Provider", "Service", NULL); priv->path = g_key_file_get_value (keyfile, "Geoclue Provider", "Path", NULL); - + accuracy_str = g_key_file_get_value (keyfile, "Geoclue Provider", "Accuracy", NULL); priv->expected_accuracy = parse_accuracy_string (accuracy_str); if (accuracy_str){ g_free (accuracy_str); } - + /* set cached accuracies to a default value */ geoclue_accuracy_set_details (priv->position_cache.accuracy, priv->expected_accuracy, 0.0, 0.0); geoclue_accuracy_set_details (priv->address_cache.accuracy, priv->expected_accuracy, 0.0, 0.0); - + flags = g_key_file_get_string_list (keyfile, "Geoclue Provider", "Requires", NULL, NULL); if (flags != NULL) { @@ -969,7 +969,7 @@ gc_master_provider_new (const char *filename, } else { priv->required_resources = GEOCLUE_RESOURCE_NONE; } - + flags = g_key_file_get_string_list (keyfile, "Geoclue Provider", "Provides", NULL, NULL); if (flags != NULL) { @@ -979,30 +979,30 @@ gc_master_provider_new (const char *filename, priv->provides = GEOCLUE_PROVIDE_NONE; } - if (!connectivity && + if (!connectivity && (priv->required_resources & GEOCLUE_RESOURCE_NETWORK)) { priv->provides &= ~GEOCLUE_PROVIDE_CACHEABLE_ON_CONNECTION; priv->net_status = GEOCLUE_CONNECTIVITY_ONLINE; priv->status = GEOCLUE_STATUS_AVAILABLE; gc_master_provider_handle_status_change (provider); } - - if (connectivity && + + if (connectivity && (priv->provides & GEOCLUE_PROVIDE_CACHEABLE_ON_CONNECTION)) { - - /* we have network status events: mark network provider + + /* we have network status events: mark network provider * with update flag, set the callback and set use_cache */ priv->provides |= GEOCLUE_PROVIDE_UPDATES; - - g_signal_connect (connectivity, + + g_signal_connect (connectivity, "status-changed", - G_CALLBACK (network_status_changed), + G_CALLBACK (network_status_changed), provider); priv->net_status = geoclue_connectivity_get_status (connectivity); } - + priv->interfaces = GC_IFACE_GEOCLUE; - interfaces = g_key_file_get_string_list (keyfile, + interfaces = g_key_file_get_string_list (keyfile, "Geoclue Provider", "Interfaces", NULL, NULL); @@ -1010,7 +1010,7 @@ gc_master_provider_new (const char *filename, priv->interfaces = parse_interface_strings (interfaces); g_strfreev (interfaces); } - + if (priv->provides & GEOCLUE_PROVIDE_CACHEABLE_ON_CONNECTION && priv->net_status == GEOCLUE_CONNECTIVITY_ONLINE) { /* do this as idle so we can return without waiting for http queries */ @@ -1019,26 +1019,26 @@ gc_master_provider_new (const char *filename, return provider; } -/* client calls this when it wants to use the provider. - Returns true if provider was actually started, and - client should assume accuracy has changed. +/* client calls this when it wants to use the provider. + Returns true if provider was actually started, and + client should assume accuracy has changed. Returns false if provider was not started (it was either already running or starting the provider failed). */ -gboolean -gc_master_provider_subscribe (GcMasterProvider *provider, +gboolean +gc_master_provider_subscribe (GcMasterProvider *provider, gpointer client, GcInterfaceFlags interface) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); gboolean started = FALSE; - + /* decide wether to run initialize or not */ if (!gc_master_provider_is_running (provider)) { if (!(priv->provides & GEOCLUE_PROVIDE_CACHEABLE_ON_CONNECTION)) { started = gc_master_provider_initialize (provider); } } - + /* add subscription */ if (interface & GC_IFACE_POSITION) { if (!g_list_find (priv->position_clients, client)) { @@ -1050,7 +1050,7 @@ gc_master_provider_subscribe (GcMasterProvider *provider, priv->address_clients = g_list_prepend (priv->address_clients, client); } } - + return started; } @@ -1061,20 +1061,20 @@ gc_master_provider_unsubscribe (GcMasterProvider *provider, GcInterfaceFlags interface) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - + if (interface & GC_IFACE_POSITION) { priv->position_clients = g_list_remove (priv->position_clients, client); } if (interface & GC_IFACE_ADDRESS) { priv->address_clients = g_list_remove (priv->address_clients, client); } - + if (!priv->position_clients && !priv->address_clients) { /* no one is using this provider, shutdown... */ /* not clearing cached accuracies on purpose */ g_debug ("%s without clients", priv->name); - + /* gc_master_provider_deinitialize (provider); */ } } @@ -1090,10 +1090,10 @@ gc_master_provider_get_position (GcMasterProvider *provider, GError **error) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - - g_assert (priv->position || + + g_assert (priv->position || priv->provides & GEOCLUE_PROVIDE_CACHEABLE_ON_CONNECTION); - + if (priv->provides & GEOCLUE_PROVIDE_UPDATES) { if (timestamp != NULL) { *timestamp = priv->position_cache.timestamp; @@ -1118,15 +1118,15 @@ gc_master_provider_get_position (GcMasterProvider *provider, } else { return geoclue_position_get_position (priv->position, timestamp, - latitude, - longitude, + latitude, + longitude, altitude, - accuracy, + accuracy, error); } } -gboolean +gboolean gc_master_provider_get_address (GcMasterProvider *provider, int *timestamp, GHashTable **details, @@ -1135,7 +1135,7 @@ gc_master_provider_get_address (GcMasterProvider *provider, { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); if (priv->provides & GEOCLUE_PROVIDE_UPDATES) { - + if (timestamp != NULL) { *timestamp = priv->address_cache.timestamp; } @@ -1154,8 +1154,8 @@ gc_master_provider_get_address (GcMasterProvider *provider, g_assert (priv->address); return geoclue_address_get_address (priv->address, timestamp, - details, - accuracy, + details, + accuracy, error); } } @@ -1170,19 +1170,19 @@ gc_master_provider_is_good (GcMasterProvider *provider, GcMasterProviderPrivate *priv; GcInterfaceFlags supported_ifaces; GeoclueProvideFlags required_flags = GEOCLUE_PROVIDE_NONE; - + priv = GET_PRIVATE (provider); - + if (need_update) { required_flags |= GEOCLUE_PROVIDE_UPDATES; } - + supported_ifaces = priv->interfaces; - + /* provider must provide all that is required and * cannot require a resource that is not allowed */ /* TODO: really, we need to change some of those terms... */ - + return (((supported_ifaces & iface_type) == iface_type) && ((priv->provides & required_flags) == required_flags) && (priv->expected_accuracy >= min_accuracy) && @@ -1194,9 +1194,9 @@ gc_master_provider_update_options (GcMasterProvider *provider) { GeoclueProvider *geoclue; GError *error = NULL; - + geoclue = gc_master_provider_get_provider (provider); - + if (!geoclue_provider_set_options (geoclue, geoclue_get_main_options (), &error)) { @@ -1205,20 +1205,20 @@ gc_master_provider_update_options (GcMasterProvider *provider) } } -GeoclueStatus +GeoclueStatus gc_master_provider_get_status (GcMasterProvider *provider) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - + return priv->master_status; } -GeoclueAccuracyLevel +GeoclueAccuracyLevel gc_master_provider_get_accuracy (GcMasterProvider *provider, GcInterfaceFlags iface) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); GeoclueAccuracyLevel acc_level; - + switch (iface) { case GC_IFACE_POSITION: geoclue_accuracy_get_details (priv->position_cache.accuracy, @@ -1235,49 +1235,49 @@ gc_master_provider_get_accuracy (GcMasterProvider *provider, GcInterfaceFlags if } /*returns a reference, but is not meant for editing...*/ -char * +char * gc_master_provider_get_name (GcMasterProvider *provider) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - + return priv->name; } -char * +char * gc_master_provider_get_description (GcMasterProvider *provider) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - + return priv->description; } -char * +char * gc_master_provider_get_service (GcMasterProvider *provider) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - + return priv->service; } -char * +char * gc_master_provider_get_path (GcMasterProvider *provider) { GcMasterProviderPrivate *priv = GET_PRIVATE (provider); - + return priv->path; } /* GCompareDataFunc for sorting providers by accuracy and required resources */ int -gc_master_provider_compare (GcMasterProvider *a, +gc_master_provider_compare (GcMasterProvider *a, GcMasterProvider *b, GcInterfaceAccuracy *iface_min_accuracy) { int diff; GeoclueAccuracy *acc_a, *acc_b; GeoclueAccuracyLevel level_a, level_b, min_level; - - + + GcMasterProviderPrivate *priv_a = GET_PRIVATE (a); GcMasterProviderPrivate *priv_b = GET_PRIVATE (b); - + /* get the current accuracylevels */ switch (iface_min_accuracy->interface) { case GC_IFACE_POSITION: @@ -1292,12 +1292,12 @@ gc_master_provider_compare (GcMasterProvider *a, g_warning("iface: %d", iface_min_accuracy->interface); g_assert_not_reached (); } - + geoclue_accuracy_get_details (acc_a, &level_a, NULL, NULL); geoclue_accuracy_get_details (acc_b, &level_b, NULL, NULL); min_level = iface_min_accuracy->accuracy_level; - + /* sort by resource requirements and accuracy, but only if both * providers meet the minimum accuracy requirement */ if ((level_b >= min_level) && @@ -1308,7 +1308,7 @@ gc_master_provider_compare (GcMasterProvider *a, } return level_b - level_a; } - + /* one or both do not meet req's, sort by accuracy */ return level_b - level_a; } diff --git a/src/master-provider.h b/src/master-provider.h old mode 100644 new mode 100755 index 18e19d5..309ba0d --- a/src/master-provider.h +++ b/src/master-provider.h @@ -38,15 +38,15 @@ G_BEGIN_DECLS #define GC_IS_MASTER_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GC_TYPE_MASTER_PROVIDER)) typedef enum { - GC_IFACE_NONE = 0, - GC_IFACE_GEOCLUE = 1 << 0, + GC_IFACE_NONE = 0, + GC_IFACE_GEOCLUE = 1 << 0, GC_IFACE_POSITION = 1 << 1, GC_IFACE_ADDRESS = 1 << 2, GC_IFACE_VELOCITY = 1 << 3, GC_IFACE_GEOCODE = 1 << 4, GC_IFACE_REVERSE_GEOCODE = 1 << 5, - - GC_IFACE_ALL = (1 << 6) - 1 + + GC_IFACE_ALL = (1 << 6) - 1 } GcInterfaceFlags; @@ -56,7 +56,7 @@ typedef struct _GcMasterProvider { typedef struct _GcMasterProviderClass { GObjectClass parent_class; - + void (* status_changed) (GcMasterProvider *master_provider, GeoclueStatus status); void (* accuracy_changed) (GcMasterProvider *master_provider, @@ -80,7 +80,7 @@ GType gc_master_provider_get_type (void); GcMasterProvider *gc_master_provider_new (const char *filename, GeoclueConnectivity *connectivity); -gboolean gc_master_provider_subscribe (GcMasterProvider *provider, +gboolean gc_master_provider_subscribe (GcMasterProvider *provider, gpointer client, GcInterfaceFlags interface); void gc_master_provider_unsubscribe (GcMasterProvider *provider, @@ -93,7 +93,7 @@ typedef struct _GcInterfaceAccuracy { GeoclueAccuracyLevel accuracy_level; } GcInterfaceAccuracy; -gint gc_master_provider_compare (GcMasterProvider *a, +gint gc_master_provider_compare (GcMasterProvider *a, GcMasterProvider *b, GcInterfaceAccuracy *iface_min_accuracy); diff --git a/src/master.c b/src/master.c index 030b4cf..d4186ba 100644 --- a/src/master.c +++ b/src/master.c @@ -71,7 +71,7 @@ gc_iface_master_create (GcMaster *master, client = g_object_new (GC_TYPE_MASTER_CLIENT, NULL); dbus_g_connection_register_g_object (master->connection, path, G_OBJECT (client)); - + if (object_path) { *object_path = path; } @@ -88,7 +88,7 @@ gc_master_class_init (GcMasterClass *klass) G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (GcMasterClass, options_changed), + G_STRUCT_OFFSET (GcMasterClass, options_changed), NULL, NULL, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, @@ -101,15 +101,15 @@ gc_master_add_new_provider (GcMaster *master, const char *filename) { GcMasterProvider *provider; - - provider = gc_master_provider_new (filename, + + provider = gc_master_provider_new (filename, master->connectivity); - + if (!provider) { g_warning ("Loading from %s failed", filename); return; } - + providers = g_list_prepend (providers, provider); } @@ -148,11 +148,11 @@ gc_master_load_providers (GcMaster *master) continue; } - fullname = g_build_filename (GEOCLUE_PROVIDERS_DIR, + fullname = g_build_filename (GEOCLUE_PROVIDERS_DIR, filename, NULL); gc_master_add_new_provider (master, fullname); g_free (fullname); - + filename = g_dir_read_name (dir); } @@ -163,15 +163,15 @@ static void gc_master_init (GcMaster *master) { GError *error = NULL; - - + + master->connection = dbus_g_bus_get (GEOCLUE_DBUS_BUS, &error); if (master->connection == NULL) { - g_warning ("Could not get %s: %s", GEOCLUE_DBUS_BUS, + g_warning ("Could not get %s: %s", GEOCLUE_DBUS_BUS, error->message); g_error_free (error); } - + master->connectivity = NULL; #ifdef HAVE_NETWORK_MANAGER master->connectivity = GEOCLUE_CONNECTIVITY (g_object_new (GEOCLUE_TYPE_NETWORKMANAGER, NULL)); @@ -180,7 +180,7 @@ gc_master_init (GcMaster *master) master->connectivity = GEOCLUE_CONNECTIVITY (g_object_new (GEOCLUE_TYPE_CONIC, NULL)); #endif #endif - + gc_master_load_providers (master); } @@ -193,22 +193,22 @@ gc_master_get_providers (GcInterfaceFlags iface_type, GError **error) { GList *l, *p = NULL; - + if (providers == NULL) { return NULL; } - + for (l = providers; l; l = l->next) { GcMasterProvider *provider = l->data; - + if (gc_master_provider_is_good (provider, - iface_type, - min_accuracy, - can_update, + iface_type, + min_accuracy, + can_update, allowed)) { p = g_list_prepend (p, provider); } } - + return p; } diff --git a/src/master.h b/src/master.h old mode 100644 new mode 100755 index f84264f..549411b --- a/src/master.h +++ b/src/master.h @@ -38,7 +38,7 @@ typedef struct { GObject parent; - + GMainLoop *loop; DBusGConnection *connection; GeoclueConnectivity *connectivity; @@ -58,4 +58,4 @@ GList *gc_master_get_providers (GcInterfaceFlags iface_type, GError **error); #endif - + diff --git a/src/org.freedesktop.Geoclue.Master.service.in b/src/org.freedesktop.Geoclue.Master.service.in old mode 100644 new mode 100755 diff --git a/test/geoclue-test-gui.c b/test/geoclue-test-gui.c index 3d33d40..929eebf 100644 --- a/test/geoclue-test-gui.c +++ b/test/geoclue-test-gui.c @@ -3,7 +3,7 @@ * client-test-gui.c - Geoclue Test GUI * * Authors: Jussi Kukkonen - * + * * Copyright 2008 OpenedHand Ltd * 2008 Intel Corporation * @@ -66,19 +66,19 @@ enum { typedef struct { GObject parent; - + GtkWidget *window; GtkTextBuffer *buffer; - + GeoclueMasterClient *client; char *master_client_path; GeoclueAccuracyLevel master_accuracy; GeoclueResourceFlags master_resources; - + GtkListStore *position_store; GList *position_providers; /* PositionProviders, first one is master */ - - GtkListStore *address_store; + + GtkListStore *address_store; GList *address_providers; /* AddressProviders, first one is master */ } GeoclueTestGui; @@ -92,7 +92,7 @@ G_DEFINE_TYPE (GeoclueTestGui, geoclue_test_gui, G_TYPE_OBJECT) static void geoclue_test_gui_dispose (GObject *object) { - + G_OBJECT_CLASS (geoclue_test_gui_parent_class)->dispose (object); } @@ -101,7 +101,7 @@ static void geoclue_test_gui_class_init (GeoclueTestGuiClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - + object_class->dispose = geoclue_test_gui_dispose; } @@ -114,16 +114,16 @@ geoclue_test_gui_master_log_message (GeoclueTestGui *gui, char *message) time_t rawtime; struct tm *timeinfo; char time_buffer [20]; - + time (&rawtime); timeinfo = localtime (&rawtime); - + strftime (time_buffer, 19, "%X", timeinfo); line = g_strdup_printf ("%s: %s\n", time_buffer, message); - + gtk_text_buffer_get_end_iter (gui->buffer, &iter); gtk_text_buffer_insert (gui->buffer, &iter, line, -1); - + g_free (line); } @@ -132,10 +132,10 @@ get_matching_tree_iter (GtkTreeModel *model, GeoclueProvider *provider, GtkTreeI { GeoclueProvider *p = NULL; gboolean valid; - + g_assert (model); g_assert (provider); - + valid = gtk_tree_model_get_iter_first (model, iter); while (valid) { gtk_tree_model_get (model, iter, @@ -144,10 +144,10 @@ get_matching_tree_iter (GtkTreeModel *model, GeoclueProvider *provider, GtkTreeI if (p == provider) { return TRUE; } - + valid = gtk_tree_model_iter_next (model, iter); } - + return FALSE; } @@ -155,9 +155,9 @@ static void update_address (GeoclueTestGui *gui, GeoclueAddress *address, GHashTable *details) { GtkTreeIter iter; - + g_assert (details); - + if (get_matching_tree_iter (GTK_TREE_MODEL (gui->address_store), GEOCLUE_PROVIDER (address), &iter)) { @@ -175,11 +175,11 @@ update_address (GeoclueTestGui *gui, GeoclueAddress *address, GHashTable *detail static void -update_position (GeoclueTestGui *gui, GeocluePosition *position, +update_position (GeoclueTestGui *gui, GeocluePosition *position, double lat, double lon, double alt) { GtkTreeIter iter; - + if (get_matching_tree_iter (GTK_TREE_MODEL (gui->position_store), GEOCLUE_PROVIDER (position), &iter)) { @@ -229,11 +229,11 @@ address_callback (GeoclueAddress *address, g_error_free (error); details = geoclue_address_details_new (); } - + update_address (GEOCLUE_TEST_GUI (userdata), address, details); } -static void +static void info_callback (GeoclueProvider *provider, char *name, char *description, @@ -242,13 +242,13 @@ info_callback (GeoclueProvider *provider, { GtkTreeIter iter; GeoclueTestGui *gui = GEOCLUE_TEST_GUI (userdata); - + if (error) { g_warning ("Error getting provider info: %s\n", error->message); g_error_free (error); return; } - + if (get_matching_tree_iter (GTK_TREE_MODEL (gui->address_store), provider, &iter)) { @@ -259,7 +259,7 @@ info_callback (GeoclueProvider *provider, -1); } } - + if (get_matching_tree_iter (GTK_TREE_MODEL (gui->position_store), provider, &iter)) { @@ -272,14 +272,14 @@ info_callback (GeoclueProvider *provider, } } -static void +static void add_to_address_store (GeoclueTestGui *gui, GeoclueAddress *address, gboolean is_master) { GtkTreeIter iter; - + g_assert (gui->address_store); g_assert (address); - + if (is_master) { /* master is already on the first line */ gtk_tree_model_get_iter_first (GTK_TREE_MODEL (gui->address_store), &iter); @@ -290,15 +290,15 @@ add_to_address_store (GeoclueTestGui *gui, GeoclueAddress *address, gboolean is_ COL_ADDRESS_PROVIDER, address, COL_ADDRESS_IS_MASTER, is_master, -1); - + g_signal_connect (G_OBJECT (address), "address-changed", G_CALLBACK (address_changed), gui); - - geoclue_provider_get_provider_info_async (GEOCLUE_PROVIDER (address), + + geoclue_provider_get_provider_info_async (GEOCLUE_PROVIDER (address), info_callback, gui); geoclue_address_get_address_async (address, address_callback, gui); - + } static gboolean @@ -309,26 +309,26 @@ get_next_provider (GDir *dir, char **name, char **service, char **path, char **i GKeyFile *keyfile; gboolean ret; GError *error; - + filename = g_dir_read_name (dir); if (!filename) { return FALSE; } - - fullname = g_build_filename (GEOCLUE_PROVIDERS_DIR, + + fullname = g_build_filename (GEOCLUE_PROVIDERS_DIR, filename, NULL); keyfile = g_key_file_new (); - ret = g_key_file_load_from_file (keyfile, fullname, + ret = g_key_file_load_from_file (keyfile, fullname, G_KEY_FILE_NONE, &error); g_free (fullname); - + if (!ret) { g_warning ("Error loading %s: %s", filename, error->message); g_error_free (error); } else { *name = g_key_file_get_value (keyfile, "Geoclue Provider", "Name", NULL); - + *service = g_key_file_get_value (keyfile, "Geoclue Provider", "Service", NULL); *path = g_key_file_get_value (keyfile, "Geoclue Provider", @@ -336,12 +336,12 @@ get_next_provider (GDir *dir, char **name, char **service, char **path, char **i *ifaces = g_key_file_get_value (keyfile, "Geoclue Provider", "Interfaces", NULL); } - + g_key_file_free (keyfile); return TRUE; } -static void +static void position_callback (GeocluePosition *position, GeocluePositionFields fields, int timestamp, @@ -358,14 +358,14 @@ position_callback (GeocluePosition *position, update_position (GEOCLUE_TEST_GUI (userdata), position, lat, lon, alt); } -static void +static void add_to_position_store (GeoclueTestGui *gui, GeocluePosition *position, gboolean is_master) { GtkTreeIter iter; - + g_assert (gui->position_store); g_assert (position); - + if (is_master) { /* master is already on the first line */ gtk_tree_model_get_iter_first (GTK_TREE_MODEL (gui->position_store), &iter); @@ -376,11 +376,11 @@ add_to_position_store (GeoclueTestGui *gui, GeocluePosition *position, gboolean COL_POSITION_PROVIDER, position, COL_POSITION_IS_MASTER, is_master, -1); - + g_signal_connect (G_OBJECT (position), "position-changed", G_CALLBACK (position_changed), gui); - - geoclue_provider_get_provider_info_async (GEOCLUE_PROVIDER (position), + + geoclue_provider_get_provider_info_async (GEOCLUE_PROVIDER (position), info_callback, gui); geoclue_position_get_position_async (position, position_callback, gui); @@ -392,69 +392,69 @@ get_address_tree_view (GeoclueTestGui *gui) { GtkTreeView *view; GtkCellRenderer *renderer; - + view = GTK_TREE_VIEW (gtk_tree_view_new ()); - + renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - "Provider", + gtk_tree_view_insert_column_with_attributes (view, -1, + "Provider", renderer, "text", COL_ADDRESS_PROVIDER_NAME, NULL); - + renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - GEOCLUE_ADDRESS_KEY_COUNTRY, + gtk_tree_view_insert_column_with_attributes (view, -1, + GEOCLUE_ADDRESS_KEY_COUNTRY, renderer, - "text", + "text", COL_ADDRESS_COUNTRY, NULL); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - GEOCLUE_ADDRESS_KEY_COUNTRYCODE, + gtk_tree_view_insert_column_with_attributes (view, -1, + GEOCLUE_ADDRESS_KEY_COUNTRYCODE, renderer, - "text", + "text", COL_ADDRESS_COUNTRYCODE, NULL); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - GEOCLUE_ADDRESS_KEY_REGION, + gtk_tree_view_insert_column_with_attributes (view, -1, + GEOCLUE_ADDRESS_KEY_REGION, renderer, - "text", + "text", COL_ADDRESS_REGION, NULL); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - GEOCLUE_ADDRESS_KEY_LOCALITY, + gtk_tree_view_insert_column_with_attributes (view, -1, + GEOCLUE_ADDRESS_KEY_LOCALITY, renderer, - "text", + "text", COL_ADDRESS_LOCALITY, NULL); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - GEOCLUE_ADDRESS_KEY_AREA, + gtk_tree_view_insert_column_with_attributes (view, -1, + GEOCLUE_ADDRESS_KEY_AREA, renderer, - "text", + "text", COL_ADDRESS_AREA, NULL); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - GEOCLUE_ADDRESS_KEY_POSTALCODE, + gtk_tree_view_insert_column_with_attributes (view, -1, + GEOCLUE_ADDRESS_KEY_POSTALCODE, renderer, - "text", + "text", COL_ADDRESS_POSTALCODE, NULL); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - GEOCLUE_ADDRESS_KEY_STREET, + gtk_tree_view_insert_column_with_attributes (view, -1, + GEOCLUE_ADDRESS_KEY_STREET, renderer, - "text", + "text", COL_ADDRESS_STREET, NULL); - - gui->address_store = gtk_list_store_new (NUM_ADDRESS_COLS, - G_TYPE_POINTER, + + gui->address_store = gtk_list_store_new (NUM_ADDRESS_COLS, + G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, @@ -464,9 +464,9 @@ get_address_tree_view (GeoclueTestGui *gui) G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); - + gtk_tree_view_set_model (view, GTK_TREE_MODEL(gui->address_store)); - + return GTK_WIDGET (view); } @@ -476,63 +476,63 @@ get_position_tree_view (GeoclueTestGui *gui) { GtkTreeView *view; GtkCellRenderer *renderer; - + view = GTK_TREE_VIEW (gtk_tree_view_new ()); - + renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - "Provider", + gtk_tree_view_insert_column_with_attributes (view, -1, + "Provider", renderer, "text", COL_POSITION_PROVIDER_NAME, NULL); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - "latitude", + gtk_tree_view_insert_column_with_attributes (view, -1, + "latitude", renderer, - "text", + "text", COL_POSITION_LAT, NULL); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - "longitude", + gtk_tree_view_insert_column_with_attributes (view, -1, + "longitude", renderer, - "text", + "text", COL_POSITION_LON, NULL); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, -1, - "altitude", + gtk_tree_view_insert_column_with_attributes (view, -1, + "altitude", renderer, - "text", + "text", COL_POSITION_ALT, NULL); - - gui->position_store = gtk_list_store_new (NUM_POSITION_COLS, - G_TYPE_POINTER, + + gui->position_store = gtk_list_store_new (NUM_POSITION_COLS, + G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_DOUBLE); - + gtk_tree_view_set_model (view, GTK_TREE_MODEL(gui->position_store)); - + return GTK_WIDGET (view); } static void master_position_provider_changed (GeoclueMasterClient *client, char *name, - char *description, + char *description, char *service, char *path, GeoclueTestGui *gui) { GtkTreeIter iter; char *msg; - - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (gui->position_store), + + if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (gui->position_store), &iter)) { gtk_list_store_set (gui->position_store, &iter, COL_POSITION_PROVIDER_NAME, g_strdup_printf ("Master (%s)", name), @@ -546,15 +546,15 @@ master_position_provider_changed (GeoclueMasterClient *client, static void master_address_provider_changed (GeoclueMasterClient *client, char *name, - char *description, + char *description, char *service, char *path, GeoclueTestGui *gui) { GtkTreeIter iter; char *msg; - - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (gui->address_store), + + if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (gui->address_store), &iter)) { gtk_list_store_set (gui->address_store, &iter, COL_ADDRESS_PROVIDER_NAME, g_strdup_printf ("Master (%s)", name), @@ -579,7 +579,7 @@ set_requirements_callback (GeoclueMasterClient *client, static void update_master_requirements (GeoclueTestGui *gui) { - geoclue_master_client_set_requirements_async (gui->client, + geoclue_master_client_set_requirements_async (gui->client, gui->master_accuracy, 0, FALSE, @@ -588,14 +588,14 @@ update_master_requirements (GeoclueTestGui *gui) NULL); } -static void +static void create_address_callback (GeoclueMasterClient *client, GeoclueAddress *address, GError *error, gpointer userdata) { GeoclueTestGui *gui = GEOCLUE_TEST_GUI (userdata); - + if (error) { g_printerr ("Master Client: Failed to create address: %s", error->message); g_error_free (error); @@ -604,14 +604,14 @@ create_address_callback (GeoclueMasterClient *client, add_to_address_store (gui, address, TRUE); } -static void +static void create_position_callback (GeoclueMasterClient *client, GeocluePosition *position, GError *error, gpointer userdata) { GeoclueTestGui *gui = GEOCLUE_TEST_GUI (userdata); - + if (error) { g_printerr ("Master Client: Failed to create position: %s", error->message); g_error_free (error); @@ -632,40 +632,40 @@ create_client_callback (GeoclueMaster *master, char *name, *path, *service, *ifaces; GtkTreeIter iter; GeoclueTestGui *gui = GEOCLUE_TEST_GUI (userdata); - + if (error) { g_printerr ("Failed to create master client: %s", error->message); g_error_free (error); return; } - + gui->client = client; - + g_signal_connect (G_OBJECT (gui->client), "position-provider-changed", G_CALLBACK (master_position_provider_changed), gui); g_signal_connect (G_OBJECT (gui->client), "address-provider-changed", G_CALLBACK (master_address_provider_changed), gui); update_master_requirements (gui); - + /* add master providers to the lists */ gtk_list_store_append (gui->position_store, &iter); - geoclue_master_client_create_position_async (gui->client, + geoclue_master_client_create_position_async (gui->client, create_position_callback, gui); gtk_list_store_append (gui->address_store, &iter); - geoclue_master_client_create_address_async (gui->client, + geoclue_master_client_create_address_async (gui->client, create_address_callback, gui); - + /* add individual providers based on files in GEOCLUE_PROVIDERS_DIR */ dir = g_dir_open (GEOCLUE_PROVIDERS_DIR, 0, &error); if (!dir) { - g_warning ("Error opening %s: %s\n", + g_warning ("Error opening %s: %s\n", GEOCLUE_PROVIDERS_DIR, error->message); g_error_free (error); return; } - + name = service = path = ifaces = NULL; while (get_next_provider (dir, &name, &service, &path, &ifaces)) { if (ifaces && strstr (ifaces, "org.freedesktop.Geoclue.Position")) { @@ -679,7 +679,7 @@ create_client_callback (GeoclueMaster *master, g_free (service); g_free (ifaces); } - + g_dir_close (dir); g_object_unref (master); } @@ -688,9 +688,9 @@ static void geoclue_test_gui_load_providers (GeoclueTestGui *gui) { GeoclueMaster *master; - + master = geoclue_master_get_default (); - geoclue_master_create_client_async (master, + geoclue_master_create_client_async (master, create_client_callback, gui); } @@ -699,13 +699,13 @@ static void accuracy_combo_changed (GtkComboBox *combo, GeoclueTestGui *gui) { GtkTreeIter iter; - + if (gtk_combo_box_get_active_iter (combo, &iter)) { GtkTreeModel *model; - + model = gtk_combo_box_get_model (combo); - gtk_tree_model_get (model, &iter, 0, &gui->master_accuracy, -1); - + gtk_tree_model_get (model, &iter, 0, &gui->master_accuracy, -1); + update_master_requirements (gui); } } @@ -750,49 +750,49 @@ get_accuracy_combo (GeoclueTestGui *gui) GtkWidget *combo; GtkTreeIter iter; GtkCellRenderer *renderer; - + store = gtk_list_store_new (2, G_TYPE_UINT, G_TYPE_STRING); - + gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - 0, GEOCLUE_ACCURACY_LEVEL_COUNTRY, + gtk_list_store_set (store, &iter, + 0, GEOCLUE_ACCURACY_LEVEL_COUNTRY, 1, "Country", -1); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - 0, GEOCLUE_ACCURACY_LEVEL_REGION, + gtk_list_store_set (store, &iter, + 0, GEOCLUE_ACCURACY_LEVEL_REGION, 1, "Region", -1); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - 0, GEOCLUE_ACCURACY_LEVEL_LOCALITY, + gtk_list_store_set (store, &iter, + 0, GEOCLUE_ACCURACY_LEVEL_LOCALITY, 1, "Locality", -1); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - 0, GEOCLUE_ACCURACY_LEVEL_POSTALCODE, + gtk_list_store_set (store, &iter, + 0, GEOCLUE_ACCURACY_LEVEL_POSTALCODE, 1, "Postalcode", -1); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - 0, GEOCLUE_ACCURACY_LEVEL_STREET, + gtk_list_store_set (store, &iter, + 0, GEOCLUE_ACCURACY_LEVEL_STREET, 1, "Street", -1); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - 0, GEOCLUE_ACCURACY_LEVEL_DETAILED, + gtk_list_store_set (store, &iter, + 0, GEOCLUE_ACCURACY_LEVEL_DETAILED, 1, "Detailed", -1); - + combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "text", 1, NULL); - + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); gui->master_accuracy = GEOCLUE_ACCURACY_LEVEL_COUNTRY; - + return combo; } @@ -810,88 +810,88 @@ geoclue_test_gui_init (GeoclueTestGui *gui) GtkWidget *combo, *check; GtkWidget *scrolled_win; GtkWidget *view; - + gui->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (G_OBJECT (gui->window), "destroy", G_CALLBACK (gtk_main_quit), NULL); - + view = gtk_text_view_new (); gtk_widget_set_size_request (GTK_WIDGET (view), 500, 200); g_object_set (G_OBJECT (view), "editable", FALSE, NULL); gui->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); - - + + box = gtk_vbox_new (FALSE, 8); gtk_container_add (GTK_CONTAINER (gui->window), box); - + frame = gtk_frame_new ("Master settings"); gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 4); - - + + hbox = gtk_hbox_new (FALSE, 24); gtk_container_add (GTK_CONTAINER (frame), hbox); - + vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 8); label = gtk_label_new ("Required accuracy level:"); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - - combo = get_accuracy_combo (gui); + + combo = get_accuracy_combo (gui); g_signal_connect (combo, "changed", G_CALLBACK (accuracy_combo_changed), gui); gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); - + vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); label = gtk_label_new ("Allow resources:"); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - + check = gtk_check_button_new_with_label ("Network"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE); gui->master_resources |= GEOCLUE_RESOURCE_NETWORK; g_signal_connect (check, "toggled", G_CALLBACK (network_check_toggled), gui); gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0); - + check = gtk_check_button_new_with_label ("GPS"); g_signal_connect (check, "toggled", G_CALLBACK (gps_check_toggled), gui); gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0); - + check = gtk_check_button_new_with_label ("Cell"); g_signal_connect (check, "toggled", G_CALLBACK (cell_check_toggled), gui); gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0); - + notebook = gtk_notebook_new (); gtk_box_pack_start (GTK_BOX (box), notebook, FALSE, FALSE, 0); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), TRUE); gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), TRUE); - + address_view = get_address_tree_view (gui); label = gtk_label_new ("Address"); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), address_view, label); - + position_view = get_position_tree_view (gui); label = gtk_label_new ("Position"); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), position_view, label); - - + + hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0); label = gtk_label_new ("Master log"); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - + scrolled_win = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win), + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_container_add (GTK_CONTAINER (box), scrolled_win); gtk_container_add (GTK_CONTAINER (scrolled_win), view); - + geoclue_test_gui_load_providers (gui); - + geoclue_test_gui_master_log_message (gui, "Started Geoclue test UI"); - + gtk_widget_show_all (gui->window); } @@ -899,13 +899,13 @@ geoclue_test_gui_init (GeoclueTestGui *gui) int main (int argc, char **argv) { GeoclueTestGui *gui; - + gtk_init (&argc, &argv); - + gui = g_object_new (GEOCLUE_TYPE_TEST_GUI, NULL); gtk_main (); - + g_object_unref (gui); - + return 0; } -- 2.7.4