diff options
Diffstat (limited to '.pc')
24 files changed, 3043 insertions, 0 deletions
diff --git a/.pc/applied-patches b/.pc/applied-patches index 43feb46..8a7eadc 100755 --- a/.pc/applied-patches +++ b/.pc/applied-patches @@ -1,2 +1,6 @@ tizen.patch geoclue_0.12.0-20slp2.patch +geoclue_0.12.0-21slp2.patch +geoclue_0.12.0-22slp2.patch +geoclue_0.12.0-24slp2.patch +geoclue_0.12.0-25slp2.patch diff --git a/.pc/geoclue_0.12.0-21slp2.patch/.timestamp b/.pc/geoclue_0.12.0-21slp2.patch/.timestamp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pc/geoclue_0.12.0-21slp2.patch/.timestamp diff --git a/.pc/geoclue_0.12.0-21slp2.patch/providers/gpsd/geoclue-gpsd.c b/.pc/geoclue_0.12.0-21slp2.patch/providers/gpsd/geoclue-gpsd.c new file mode 100644 index 0000000..1c6d111 --- /dev/null +++ b/.pc/geoclue_0.12.0-21slp2.patch/providers/gpsd/geoclue-gpsd.c @@ -0,0 +1,646 @@ +/* + * Geoclue + * geoclue-gpsd.c - Geoclue Position backend for gpsd + * + * Authors: Jussi Kukkonen <jku@o-hand.com> + * Copyright 2007 by Garmin Ltd. or its subsidiaries + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +/* TODO: + * + * call to gps_set_callback blocks for a long time if + * BT device is not present. + * + **/ + +#include <config.h> + +#include <glib.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <gps.h> + +#include <geoclue/geoclue-error.h> +#include <geoclue/gc-provider.h> +#include <geoclue/gc-iface-position.h> +#include <geoclue/gc-iface-velocity.h> + +#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; + +/* only listing used tags */ +typedef enum { + NMEA_NONE, + NMEA_GSA, + NMEA_GGA, + NMEA_GSV, + NMEA_RMC +} NmeaTag; + +typedef struct { + int timestamp; + double latitude; + double longitude; + double accuracy; +} GeoclueGpsdsLastPosition; + +typedef struct { + GcProvider parent; + + char *host; + char *port; + + gps_data *gpsdata; + + gps_fix *last_fix; + + GeoclueStatus last_status; + GeocluePositionFields last_pos_fields; + GeoclueAccuracy *last_accuracy; + GeoclueVelocityFields last_velo_fields; + GeoclueGpsdsLastPosition last_position; + + GMainLoop *loop; +} GeoclueGpsd; + +typedef struct { + GcProviderClass parent_class; +} GeoclueGpsdClass; + +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); + + +/* 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) +{ + GeoclueGpsd *gpsd = GEOCLUE_GPSD (gc); + + *status = gpsd->last_status; + return TRUE; +} + +static void +shutdown (GcProvider *provider) +{ + GeoclueGpsd *gpsd = GEOCLUE_GPSD (provider); + + g_main_loop_quit (gpsd->loop); +} + +static void +geoclue_gpsd_set_status (GeoclueGpsd *self, GeoclueStatus status) +{ + if (status != self->last_status) { + self->last_status = status; + + /* make position and velocity invalid if no fix */ + if (status != GEOCLUE_STATUS_AVAILABLE) { + self->last_pos_fields = GEOCLUE_POSITION_FIELDS_NONE; + 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); + } +} + +static gboolean +set_options (GcIfaceGeoclue *gc, + GHashTable *options, + GError **error) +{ + 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"); + + if (port == NULL) { + port = DEFAULT_GPSD_PORT; + } + + /* new values? */ + if (g_strcmp0 (host, gpsd->host) != 0 || + g_strcmp0 (port, gpsd->port) != 0) { + changed = TRUE; + } + + if (!changed) { + return TRUE; + } + + /* update private values with new ones, restart gpsd */ + g_free (gpsd->port); + gpsd->port = NULL; + g_free (gpsd->host); + gpsd->host = NULL; + + 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"); + return FALSE; + } + return TRUE; +} + +static void +finalize (GObject *object) +{ + GeoclueGpsd *gpsd = GEOCLUE_GPSD (object); + + geoclue_gpsd_stop_gpsd (gpsd); + g_free (gpsd->last_fix); + geoclue_accuracy_free (gpsd->last_accuracy); + + g_free (gpsd->port); + if (gpsd->host) { + g_free (gpsd->host); + } + + ((GObjectClass *) geoclue_gpsd_parent_class)->finalize (object); +} + +static void +geoclue_gpsd_class_init (GeoclueGpsdClass *klass) +{ + GObjectClass *o_class = (GObjectClass *) klass; + GcProviderClass *p_class = (GcProviderClass *) klass; + + o_class->finalize = finalize; + + p_class->get_status = get_status; + p_class->set_options = set_options; + p_class->shutdown = shutdown; +} + + +static gboolean +equal_or_nan (double a, double 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) +{ + return (deg * M_PI / 180); +} + +static int +geoclue_gpsd_distance_to_last_position(GeoclueGpsd * gpsd, const gps_fix * last_fix) +{ + double delta_lat, delta_long; + double dist; + + delta_lat = last_fix->latitude - gpsd->last_position.latitude; + delta_long = last_fix->longitude - gpsd->last_position.longitude; + + g_debug("GPS pos Latitude = %f Longitude = %f", last_fix->latitude, last_fix->longitude); + + dist = sin(deg2rad(delta_lat) / 2) * sin(deg2rad(delta_lat) / 2) + + cos(deg2rad(last_fix->latitude)) * cos(deg2rad(gpsd->last_position.latitude)) + * sin(deg2rad(delta_long) / 2) * sin(deg2rad(delta_long) / 2); + dist = 2 * atan2(sqrt(dist), sqrt(1 - dist)); + dist = 6371 * dist; // unit: 'km' + + if (dist > 0.3) { + return 0; + } else { + return -1; + } +} + +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); +} + +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); +} + +static void +geoclue_gpsd_update_last_position(GeoclueGpsd * gpsd, const const gps_fix * last_fix, + int accuracy) +{ + g_debug("geoclue_xps_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; + geoclue_gpsd_set_last_position(gpsd); +} + +static void +geoclue_gpsd_update_position (GeoclueGpsd *gpsd) +{ + 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){ + 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)) { + return; + } + /* save values */ + if (fix->mode >= MODE_2D && isnan(fix->latitude)==0) { + last_fix->latitude = fix->latitude; + } + if (fix->mode >= MODE_2D && isnan(fix->longitude)==0) { + last_fix->longitude = fix->longitude; + } + if (fix->mode == MODE_3D && isnan(fix->altitude)==0){ + last_fix->altitude = fix->altitude; + } + + if (isnan(fix->epx)==0){ + last_fix->epx = fix->epx; + } + if (isnan(fix->epy)==0){ + last_fix->epy = fix->epy; + } + 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); + 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; + + 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)))); + } 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); + +} + +static void +geoclue_gpsd_update_velocity (GeoclueGpsd *gpsd) +{ + 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){ + 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)) { + return; + } + if (fix->mode >= MODE_2D && isnan(fix->track)==0){ + last_fix->track = fix->track; + } + if (fix->mode >= MODE_2D && isnan(fix->speed)==0){ + last_fix->speed = fix->speed; + } + 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; + + 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); +} + +static void +geoclue_gpsd_update_status (GeoclueGpsd *gpsd) +{ + GeoclueStatus status; + + /* gpsdata->online is supposedly always up-to-date */ + if (gpsd->gpsdata->online <= 0) { + status = GEOCLUE_STATUS_UNAVAILABLE; + } else if (gpsd->gpsdata->set & STATUS_SET) { + gpsd->gpsdata->set &= ~(STATUS_SET); + if (gpsd->gpsdata->status > 0) { + status = GEOCLUE_STATUS_AVAILABLE; + } else { + status = GEOCLUE_STATUS_ACQUIRING; + } + } else { + status = GEOCLUE_STATUS_AVAILABLE; + return; + } + + geoclue_gpsd_set_status (gpsd, status); +} + +static void +gpsd_raw_hook (gps_data *gpsdata, char *message, size_t len) +{ + if(gpsdata == NULL) + return; + + geoclue_gpsd_update_status (gpsd); + geoclue_gpsd_update_position (gpsd); + geoclue_gpsd_update_velocity (gpsd); +} + +static void +geoclue_gpsd_stop_gpsd (GeoclueGpsd *self) +{ + if (self->gpsdata) { + gps_close (self->gpsdata); + self->gpsdata = NULL; + } +} + +static gboolean +geoclue_gpsd_start_gpsd (GeoclueGpsd *self) +{ + 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); + return TRUE; + } else { + g_warning ("gps_open() failed, is gpsd running (host=%s,port=%s)?", self->host, self->port); + return FALSE; + } +} + +gboolean +gpsd_poll(gpointer data) +{ + GeoclueGpsd *self = (GeoclueGpsd*)data; + if (self->gpsdata) { + if (gps_poll(self->gpsdata) < 0) { + geoclue_gpsd_set_status (self, GEOCLUE_STATUS_ERROR); + geoclue_gpsd_stop_gpsd(self); + return FALSE; + } + } + return TRUE; +} + +static void +geoclue_gpsd_init (GeoclueGpsd *self) +{ + self->gpsdata = NULL; + 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); + + 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) +{ + GeoclueGpsd *gpsd = GEOCLUE_GPSD (gc); + + *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); + + return TRUE; +} + +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) +{ + GeoclueGpsd *gpsd = GEOCLUE_GPSD (gc); + + *timestamp = (int)(gpsd->last_fix->time+0.5); + *speed = gpsd->last_fix->speed; + *direction = gpsd->last_fix->track; + *climb = gpsd->last_fix->climb; + *fields = gpsd->last_velo_fields; + + return TRUE; +} + +static void +geoclue_gpsd_velocity_init (GcIfaceVelocityClass *iface) +{ + iface->get_velocity = get_velocity; +} + +int +main (int argc, + char **argv) +{ + g_type_init (); + + gpsd = g_object_new (GEOCLUE_TYPE_GPSD, NULL); + + 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_unref (gpsd->loop); + g_object_unref (gpsd); + + return 0; +} diff --git a/.pc/geoclue_0.12.0-21slp2.patch/providers/gpsd/setting.h b/.pc/geoclue_0.12.0-21slp2.patch/providers/gpsd/setting.h new file mode 100644 index 0000000..ca1fe7d --- /dev/null +++ b/.pc/geoclue_0.12.0-21slp2.patch/providers/gpsd/setting.h @@ -0,0 +1,43 @@ +/* + * Geoclue Providers + * + * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>, + * Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com> + * + * PROPRIETARY/CONFIDENTIAL + * + * This software is the confidential and proprietary information of + * SAMSUNG ELECTRONICS ("Confidential Information"). + * + * You agree and acknowledge that this software is owned by Samsung and you + * shall not disclose such Confidential Information and shall use it only + * in accordance with the terms of the license agreement you entered into with + * SAMSUNG ELECTRONICS. + * + * SAMSUNG make no representations or warranties about the suitability + * of the software, either express or implied, including but not limited to + * the implied warranties of merchantability, fitness for a particular purpose, + * or non-infringement. + * + * SAMSUNG shall not be liable for any damages suffered by licensee arising + * out of or related to this software. + */ + +#ifndef __SETTING_H__ +#define __SETTING_H__ + +// Sync VCONFKEY_GPS_STATE +#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" + +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); +#endif diff --git a/.pc/geoclue_0.12.0-22slp2.patch/.timestamp b/.pc/geoclue_0.12.0-22slp2.patch/.timestamp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pc/geoclue_0.12.0-22slp2.patch/.timestamp diff --git a/.pc/geoclue_0.12.0-22slp2.patch/configure.ac b/.pc/geoclue_0.12.0-22slp2.patch/configure.ac new file mode 100644 index 0000000..e692553 --- /dev/null +++ b/.pc/geoclue_0.12.0-22slp2.patch/configure.ac @@ -0,0 +1,197 @@ +AC_PREREQ(2.59) +AC_INIT(geoclue, 0.12.0, http://geoclue.freedesktop.org) + +AC_CONFIG_SRCDIR(geoclue/gc-iface-geoclue.c) +AM_CONFIG_HEADER(config.h) +AM_INIT_AUTOMAKE([1.9 foreign]) +GEOCLUE_VERSION=0.12.0 + +AC_PROG_CC +AC_ISC_POSIX + +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET +AC_PROG_GCC_TRADITIONAL +AM_PROG_LIBTOOL + +#GTK_DOC_CHECK(1.0) +AC_CHECK_PROGS(XSLT, xsltproc) + +AC_ARG_ENABLE(system-bus, + [AC_HELP_STRING([--enable-system-bus], + [Use the system bus instead of session bus])], + enable_system_bus="$enableval", + enable_system_bus=no) + +AM_CONDITIONAL(USE_SYSTEM_BUS, test x$enable_system_bus = xyes) +if test x$enable_system_bus = xyes; then + AC_DEFINE(GEOCLUE_DBUS_BUS, DBUS_BUS_SYSTEM, Use the system bus) +else + AC_DEFINE(GEOCLUE_DBUS_BUS, DBUS_BUS_SESSION, Use the session bus) +fi + +PKG_CHECK_MODULES(GEOCLUE, [ + glib-2.0 + gobject-2.0 + dbus-glib-1 >= 0.60 + libxml-2.0 +]) +AC_SUBST(GEOCLUE_LIBS) +AC_SUBST(GEOCLUE_CFLAGS) + +PKG_CHECK_MODULES(MASTER, [ + gconf-2.0 +]) +AC_SUBST(MASTER_LIBS) +AC_SUBST(MASTER_CFLAGS) + +AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool) +AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal) + +DBUS_SERVICES_DIR="${datadir}/dbus-1/services" +AC_SUBST(DBUS_SERVICES_DIR) +AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Where services dir for D-Bus is]) + +CFLAGS="$CFLAGS -g -Wall -Werror -Wno-format" + +# ----------------------------------------------------------- +# gtk+ +# ----------------------------------------------------------- +AC_ARG_ENABLE(gtk, + AS_HELP_STRING([--enable-gtk=@<:@no/yes/auto@:>@], + [build with gtk support]), , + enable_gtk=no) + +if test "x$enable_gtk" != "xno"; then + PKG_CHECK_MODULES(GTK, + [ + gtk+-2.0 + ], have_gtk="yes", have_gtk="no") + + if test "x$have_gtk" = "xyes"; then + AC_DEFINE(HAVE_GTK, 1, [Define if you have gtk+]) + fi +else + have_gtk=no +fi + +if test "x$enable_gtk" = "xyes" -a "x$have_gtk" != "xyes"; then + AC_MSG_ERROR(["Couldn't find gtk dependencies."]) +fi + +AM_CONDITIONAL(HAVE_GTK, test "x$have_gtk" = "xyes") +AC_SUBST(GTK_LIBS) +AC_SUBST(GTK_CFLAGS) + +# ----------------------------------------------------------- +# connectivity +# ----------------------------------------------------------- + +CONNECTIVITY="None" + +AC_ARG_ENABLE(conic, + AS_HELP_STRING([--enable-conic=@<:@no/yes/auto@:>@], + [build with conic support]), , + enable_conic=auto) + +if test "x$enable_conic" != "xno"; then + PKG_CHECK_MODULES(CONIC, + [ + conic + ], have_conic="yes", have_conic="no") + + if test "x$have_conic" = "xyes"; then + CONNECTIVITY="Maemo LibConIC" + CONNECTIVITY_LIBS=${CONIC_LIBS} + CONNECTIVITY_CFLAGS=${CONIC_CFLAGS} + AC_DEFINE(HAVE_CONIC, 1, [define if libconic is installed]) + fi +else + have_conic=no +fi + +if test "x$enable_conic" = "xyes" -a "x$have_conic" != "xyes"; then + AC_MSG_ERROR(["Couldn't find conic dependencies."]) +fi + +AC_ARG_ENABLE(networkmanager, + AS_HELP_STRING([--enable-networkmanager=@<:@no/yes/auto@:>@], + [build with NetworkManager support]), , + enable_networkmanager=auto) + +if test "x$enable_networkmanager" != "xno"; then + PKG_CHECK_MODULES(NETWORK_MANAGER, + [ + NetworkManager libnm_glib + ], have_networkmanager="yes", have_networkmanager="no") + + if test "x$have_networkmanager" = "xyes"; then + CONNECTIVITY="Network Manager" + CONNECTIVITY_LIBS=${NETWORK_MANAGER_LIBS} + CONNECTIVITY_CFLAGS=${NETWORK_MANAGER_CFLAGS} + AC_DEFINE(HAVE_NETWORK_MANAGER, 1, [define if Network Manager is installed]) + fi +else + have_networkmanager=no +fi + +if test "x$enable_networkmanager" = "xyes" -a "x$have_networkmanager" != "xyes"; then + AC_MSG_ERROR(["Couldn't find Network Manager dependencies."]) +fi + +AC_SUBST(CONNECTIVITY_LIBS) +AC_SUBST(CONNECTIVITY_CFLAGS) + +PROVIDER_SUBDIRS="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) + +AC_CONFIG_FILES([ +geoclue.pc +Makefile +interfaces/Makefile +geoclue/Makefile +providers/Makefile +providers/gpsd/Makefile +providers/nominatim/Makefile +src/Makefile +]) +#docs/Makefile +#docs/reference/Makefile +#docs/tools/Makefile + +AC_OUTPUT + +echo "" +echo "Geoclue ${VERSION} has been configured as follows: " +echo "---------------------------------------------------" +echo "Source code location: ${srcdir}" +echo "Compiler: ${CC}" +echo "Network connectivity: ${CONNECTIVITY}" +echo "Providers: ${PROVIDER_SUBDIRS}" +echo "Excluded providers: ${NO_BUILD_PROVIDERS}" +echo "" diff --git a/.pc/geoclue_0.12.0-24slp2.patch/.timestamp b/.pc/geoclue_0.12.0-24slp2.patch/.timestamp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/.timestamp diff --git a/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-position.c b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-position.c new file mode 100755 index 0000000..a246bbe --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-position.c @@ -0,0 +1,123 @@ +/* + * Geoclue + * gc-iface-position.c - GInterface for org.freedesktop.Geoclue.Position + * + * Author: Iain Holmes <iain@openedhand.com> + * Copyright 2007 by Garmin Ltd. or its subsidiaries + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include <glib.h> + +#include <dbus/dbus-glib.h> +#include <geoclue/gc-iface-position.h> +#include <geoclue/geoclue-marshal.h> +#include <geoclue/geoclue-accuracy.h> + +enum { + POSITION_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = {0}; + +static gboolean +gc_iface_position_get_position (GcIfacePosition *position, + int *fields, + int *timestamp, + double *latitude, + double *longitude, + double *altitude, + GeoclueAccuracy **accuracy, + GError **error); + +#include "gc-iface-position-glue.h" + +static void +gc_iface_position_base_init (gpointer klass) +{ + static gboolean initialized = FALSE; + + if (initialized) { + return; + } + initialized = TRUE; + + signals[POSITION_CHANGED] = g_signal_new ("position-changed", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST, 0, + NULL, NULL, + geoclue_marshal_VOID__INT_INT_DOUBLE_DOUBLE_DOUBLE_BOXED, + G_TYPE_NONE, 6, + G_TYPE_INT, + G_TYPE_INT, + G_TYPE_DOUBLE, + 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); +} + +GType +gc_iface_position_get_type (void) +{ + static GType type = 0; + + if (!type) { + const GTypeInfo info = { + sizeof (GcIfacePositionClass), + gc_iface_position_base_init, + NULL, + }; + + type = g_type_register_static (G_TYPE_INTERFACE, + "GcIfacePosition", &info, 0); + } + + return type; +} + +static gboolean +gc_iface_position_get_position (GcIfacePosition *gc, + int *fields, + int *timestamp, + double *latitude, + double *longitude, + double *altitude, + GeoclueAccuracy **accuracy, + GError **error) +{ + return GC_IFACE_POSITION_GET_CLASS (gc)->get_position + (gc, (GeocluePositionFields *) fields, timestamp, + latitude, longitude, altitude, accuracy, error); +} + +void +gc_iface_position_emit_position_changed (GcIfacePosition *gc, + GeocluePositionFields fields, + int timestamp, + double latitude, + double longitude, + double altitude, + GeoclueAccuracy *accuracy) +{ + g_signal_emit (gc, signals[POSITION_CHANGED], 0, fields, timestamp, + latitude, longitude, altitude, accuracy); +} diff --git a/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-position.h b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-position.h new file mode 100755 index 0000000..43b992d --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-position.h @@ -0,0 +1,78 @@ +/* + * Geoclue + * gc-iface-position.h - GInterface for org.freedesktop.Geoclue.Position + * + * Author: Iain Holmes <iain@openedhand.com> + * Copyright 2007 by Garmin Ltd. or its subsidiaries + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef _GC_IFACE_POSITION_H +#define _GC_IFACE_POSITION_H + +#include <geoclue/geoclue-types.h> +#include <geoclue/geoclue-accuracy.h> + +G_BEGIN_DECLS + +#define GC_TYPE_IFACE_POSITION (gc_iface_position_get_type ()) +#define GC_IFACE_POSITION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GC_TYPE_IFACE_POSITION, GcIfacePosition)) +#define GC_IFACE_POSITION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GC_TYPE_IFACE_POSITION, GcIfacePositionClass)) +#define GC_IS_IFACE_POSITION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GC_TYPE_IFACE_POSITION)) +#define GC_IS_IFACE_POSITION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GC_TYPE_IFACE_POSITION)) +#define GC_IFACE_POSITION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GC_TYPE_IFACE_POSITION, GcIfacePositionClass)) + +typedef struct _GcIfacePosition GcIfacePosition; /* Dummy typedef */ +typedef struct _GcIfacePositionClass GcIfacePositionClass; + +struct _GcIfacePositionClass { + GTypeInterface base_iface; + + /* signals */ + void (* position_changed) (GcIfacePosition *gc, + GeocluePositionFields fields, + int timestamp, + double latitude, + double longitude, + double altitude, + GeoclueAccuracy *accuracy); + + /* vtable */ + gboolean (* get_position) (GcIfacePosition *gc, + GeocluePositionFields *fields, + int *timestamp, + double *latitude, + double *longitude, + double *altitude, + GeoclueAccuracy **accuracy, + GError **error); +}; + +GType gc_iface_position_get_type (void); + +void gc_iface_position_emit_position_changed (GcIfacePosition *gc, + GeocluePositionFields fields, + int timestamp, + double latitude, + double longitude, + double altitude, + GeoclueAccuracy *accuracy); + +G_END_DECLS + +#endif diff --git a/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-satellite.c b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-satellite.c new file mode 100644 index 0000000..de0215d --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-satellite.c @@ -0,0 +1,123 @@ +/* + * Geoclue + * gc-iface-satellite.c - GInterface for org.freedesktop.Geoclue.Satellite + * + * Author: Sagnho Park <sangho.g.park@samsung.com>, Youngae Kang <youngae.kang@samsung.com>, + * Yunhan Kim <yhan.kim@samsung.com>, Genie Kim <daejins.kim@samsung.com> + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include <glib.h> + +#include <dbus/dbus-glib.h> +#include <geoclue/gc-iface-satellite.h> +#include <geoclue/geoclue-marshal.h> + +enum { + SATELLITE_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = {0}; + +static gboolean +gc_iface_satellite_get_satellite (GcIfaceSatellite *satellite, + int *timestamp, + int *satellite_used, + int *satellite_visible, + GArray **used_prn, + GPtrArray **sat_info, + GError **error); + +#include "gc-iface-satellite-glue.h" + +static void +gc_iface_satellite_base_init (gpointer klass) +{ + static gboolean initialized = FALSE; + + if (initialized) { + return; + } + initialized = TRUE; + + signals[SATELLITE_CHANGED] = g_signal_new ("satellite-changed", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST, 0, + NULL, NULL, + geoclue_marshal_VOID__INT_INT_INT_POINTER_POINTER, + G_TYPE_NONE, 5, + G_TYPE_INT, + G_TYPE_INT, + G_TYPE_INT, + DBUS_TYPE_G_INT_ARRAY, + GEOCLUE_SATELLITE_INFO_ARRAY); + dbus_g_object_type_install_info (gc_iface_satellite_get_type (), + &dbus_glib_gc_iface_satellite_object_info); +} + +GType +gc_iface_satellite_get_type (void) +{ + static GType type = 0; + + if (!type) { + const GTypeInfo info = { + sizeof (GcIfaceSatelliteClass), + gc_iface_satellite_base_init, + NULL, + }; + + type = g_type_register_static (G_TYPE_INTERFACE, + "GcIfaceSatellite", &info, 0); + } + + return type; +} + +static gboolean +gc_iface_satellite_get_satellite (GcIfaceSatellite *gc, + int *timestamp, + int *satellite_used, + int *satellite_visible, + GArray **used_prn, + GPtrArray **sat_info, + GError **error) +{ + return GC_IFACE_SATELLITE_GET_CLASS (gc)->get_satellite (gc, + timestamp, + satellite_used, + satellite_visible, + used_prn, + sat_info, + error); +} + +void +gc_iface_satellite_emit_satellite_changed (GcIfaceSatellite *gc, + int timestamp, + int satellite_used, + int satellite_visible, + GArray *used_prn, + GPtrArray *sat_info) +{ + g_signal_emit (gc, signals[SATELLITE_CHANGED], 0, + timestamp, satellite_used, satellite_visible, + used_prn, sat_info); +} diff --git a/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-satellite.h b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-satellite.h new file mode 100644 index 0000000..e7d84b6 --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-satellite.h @@ -0,0 +1,76 @@ +/* + * Geoclue + * gc-iface-satellite.c - GInterface for org.freedesktop.Geoclue.Satellite + * + * Author: Sagnho Park <sangho.g.park@samsung.com>, Youngae Kang <youngae.kang@samsung.com>, + * Yunhan Kim <yhan.kim@samsung.com>, Genie Kim <daejins.kim@samsung.com> + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef _GC_IFACE_SATELLITE_H +#define _GC_IFACE_SATELLITE_H + +#include <geoclue/geoclue-types.h> +#include <geoclue/geoclue-satellite-info.h> + +G_BEGIN_DECLS + +#define GC_TYPE_IFACE_SATELLITE (gc_iface_satellite_get_type ()) +#define GC_IFACE_SATELLITE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GC_TYPE_IFACE_SATELLITE, GcIfaceSatellite)) +#define GC_IFACE_SATELLITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GC_TYPE_IFACE_SATELLITE, GcIfaceSatelliteClass)) +#define GC_IS_IFACE_SATELLITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GC_TYPE_IFACE_SATELLITE)) +#define GC_IS_IFACE_SATELLITE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GC_TYPE_IFACE_SATELLITE)) +#define GC_IFACE_SATELLITE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GC_TYPE_IFACE_SATELLITE, GcIfaceSatelliteClass)) + +typedef struct _GcIfaceSatellite GcIfaceSatellite; /* Dummy typedef */ +typedef struct _GcIfaceSatelliteClass GcIfaceSatelliteClass; + +struct _GcIfaceSatelliteClass { + GTypeInterface base_iface; + + /* signals */ + void (* satellite_changed) (GcIfaceSatellite *gc, + int timestamp, + int satellite_used, + int satellite_visible, + GArray *used_prn, + GPtrArray *sat_info); + + /* vtable */ + gboolean (* get_satellite) (GcIfaceSatellite *gc, + int *timestamp, + int *satellite_used, + int *satellite_visible, + GArray **used_prn, + GPtrArray **sat_info, + GError **error); +}; + +GType gc_iface_satellite_get_type (void); + +void gc_iface_satellite_emit_satellite_changed (GcIfaceSatellite *gc, + int timestamp, + int satellite_used, + int satellite_visible, + GArray *used_prn, + GPtrArray *sat_info); + +G_END_DECLS + +#endif diff --git a/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-velocity.c b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-velocity.c new file mode 100755 index 0000000..a0cac71 --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-velocity.c @@ -0,0 +1,117 @@ +/* + * Geoclue + * gc-iface-velocity.c - GInterface for org.freedesktop.Geoclue.Velocity + * + * Author: Iain Holmes <iain@openedhand.com> + * Copyright 2007 by Garmin Ltd. or its subsidiaries + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include <glib.h> + +#include <dbus/dbus-glib.h> +#include <geoclue/gc-iface-velocity.h> +#include <geoclue/geoclue-marshal.h> + +enum { + VELOCITY_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = {0}; + +static gboolean +gc_iface_velocity_get_velocity (GcIfaceVelocity *velocity, + int *fields, + int *timestamp, + double *latitude, + double *longitude, + double *altitude, + GError **error); + +#include "gc-iface-velocity-glue.h" + +static void +gc_iface_velocity_base_init (gpointer klass) +{ + static gboolean initialized = FALSE; + + if (initialized) { + return; + } + initialized = TRUE; + + signals[VELOCITY_CHANGED] = g_signal_new ("velocity-changed", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST, 0, + NULL, NULL, + geoclue_marshal_VOID__INT_INT_DOUBLE_DOUBLE_DOUBLE, + G_TYPE_NONE, 5, + G_TYPE_INT, + G_TYPE_INT, + G_TYPE_DOUBLE, + G_TYPE_DOUBLE, + G_TYPE_DOUBLE); + dbus_g_object_type_install_info (gc_iface_velocity_get_type (), + &dbus_glib_gc_iface_velocity_object_info); +} + +GType +gc_iface_velocity_get_type (void) +{ + static GType type = 0; + + if (!type) { + const GTypeInfo info = { + sizeof (GcIfaceVelocityClass), + gc_iface_velocity_base_init, + NULL, + }; + + type = g_type_register_static (G_TYPE_INTERFACE, + "GcIfaceVelocity", &info, 0); + } + + return type; +} + +static gboolean +gc_iface_velocity_get_velocity (GcIfaceVelocity *gc, + int *fields, + int *timestamp, + double *speed, + double *direction, + double *climb, + GError **error) +{ + return GC_IFACE_VELOCITY_GET_CLASS (gc)->get_velocity + (gc, (GeoclueVelocityFields *) fields, timestamp, + speed, direction, climb, error); +} + +void +gc_iface_velocity_emit_velocity_changed (GcIfaceVelocity *gc, + GeoclueVelocityFields fields, + int timestamp, + double speed, + double direction, + double climb) +{ + g_signal_emit (gc, signals[VELOCITY_CHANGED], 0, fields, timestamp, + speed, direction, climb); +} diff --git a/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-velocity.h b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-velocity.h new file mode 100755 index 0000000..df2f678 --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/gc-iface-velocity.h @@ -0,0 +1,74 @@ +/* + * Geoclue + * gc-iface-velocity.h - GInterface for org.freedesktop.Geoclue.Velocity + * + * Author: Iain Holmes <iain@openedhand.com> + * Copyright 2007 by Garmin Ltd. or its subsidiaries + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef _GC_IFACE_VELOCITY_H +#define _GC_IFACE_VELOCITY_H + +#include <geoclue/geoclue-types.h> + +G_BEGIN_DECLS + +#define GC_TYPE_IFACE_VELOCITY (gc_iface_velocity_get_type ()) +#define GC_IFACE_VELOCITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GC_TYPE_IFACE_VELOCITY, GcIfaceVelocity)) +#define GC_IFACE_VELOCITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GC_TYPE_IFACE_VELOCITY, GcIfaceVelocityClass)) +#define GC_IS_IFACE_VELOCITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GC_TYPE_IFACE_VELOCITY)) +#define GC_IS_IFACE_VELOCITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GC_TYPE_IFACE_VELOCITY)) +#define GC_IFACE_VELOCITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GC_TYPE_IFACE_VELOCITY, GcIfaceVelocityClass)) + +typedef struct _GcIfaceVelocity GcIfaceVelocity; /* Dummy typedef */ +typedef struct _GcIfaceVelocityClass GcIfaceVelocityClass; + +struct _GcIfaceVelocityClass { + GTypeInterface base_iface; + + /* signals */ + void (* velocity_changed) (GcIfaceVelocity *gc, + GeoclueVelocityFields fields, + int timestamp, + double speed, + double direction, + double climb); + + /* vtable */ + gboolean (* get_velocity) (GcIfaceVelocity *gc, + GeoclueVelocityFields *fields, + int *timestamp, + double *speed, + double *direction, + double *climb, + GError **error); +}; + +GType gc_iface_velocity_get_type (void); + +void gc_iface_velocity_emit_velocity_changed (GcIfaceVelocity *gc, + GeoclueVelocityFields fields, + int timestamp, + double speed, + double direction, + double climb); + +G_END_DECLS + +#endif diff --git a/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-position.c b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-position.c new file mode 100755 index 0000000..2366286 --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-position.c @@ -0,0 +1,305 @@ +/* + * Geoclue + * geoclue-position.c - Client API for accessing GcIfacePosition + * + * Author: Iain Holmes <iain@openedhand.com> + * Copyright 2007 by Garmin Ltd. or its subsidiaries + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +/** + * 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 + * 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() + * method and the position-changed signal can be used to obtain the current position. + */ + +#include <geoclue/geoclue-position.h> +#include <geoclue/geoclue-marshal.h> + +#include "gc-iface-position-bindings.h" + +typedef struct _GeocluePositionPrivate { + int dummy; +} GeocluePositionPrivate; + +enum { + POSITION_CHANGED, + LAST_SIGNAL +}; + +static guint32 signals[LAST_SIGNAL] = {0, }; + +#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GEOCLUE_TYPE_POSITION, GeocluePositionPrivate)) + +G_DEFINE_TYPE (GeocluePosition, geoclue_position, GEOCLUE_TYPE_PROVIDER); + +static void +finalize (GObject *object) +{ + G_OBJECT_CLASS (geoclue_position_parent_class)->finalize (object); +} + +static void +dispose (GObject *object) +{ + G_OBJECT_CLASS (geoclue_position_parent_class)->dispose (object); +} + +static void +position_changed (DBusGProxy *proxy, + int fields, + int timestamp, + double latitude, + double longitude, + double altitude, + GeoclueAccuracy *accuracy, + GeocluePosition *position) +{ + g_signal_emit (position, signals[POSITION_CHANGED], 0, fields, + timestamp, latitude, longitude, altitude, accuracy); +} + +static GObject * +constructor (GType type, + guint n_props, + GObjectConstructParam *props) +{ + GObject *object; + GeoclueProvider *provider; + + object = G_OBJECT_CLASS (geoclue_position_parent_class)->constructor + (type, n_props, props); + provider = GEOCLUE_PROVIDER (object); + + dbus_g_proxy_add_signal (provider->proxy, "PositionChanged", + G_TYPE_INT, G_TYPE_INT, G_TYPE_DOUBLE, + G_TYPE_DOUBLE, G_TYPE_DOUBLE, + GEOCLUE_ACCURACY_TYPE, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (provider->proxy, "PositionChanged", + G_CALLBACK (position_changed), + object, NULL); + + return object; +} + +static void +geoclue_position_class_init (GeocluePositionClass *klass) +{ + GObjectClass *o_class = (GObjectClass *) klass; + + o_class->finalize = finalize; + o_class->dispose = dispose; + o_class->constructor = constructor; + + g_type_class_add_private (klass, sizeof (GeocluePositionPrivate)); + + /** + * GeocluePosition::position-changed: + * @position: the #GeocluePosition object emitting the signal + * @fields: A #GeocluePositionFields bitfield representing the validity of the position values + * @timestamp: Time of position measurement (Unix timestamp) + * @latitude: Latitude in degrees + * @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. + */ + signals[POSITION_CHANGED] = g_signal_new ("position-changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST | + G_SIGNAL_NO_RECURSE, + G_STRUCT_OFFSET (GeocluePositionClass, position_changed), + NULL, NULL, + geoclue_marshal_VOID__INT_INT_DOUBLE_DOUBLE_DOUBLE_BOXED, + G_TYPE_NONE, 6, + G_TYPE_INT, G_TYPE_INT, + G_TYPE_DOUBLE, G_TYPE_DOUBLE, + G_TYPE_DOUBLE, G_TYPE_POINTER); +} + +static void +geoclue_position_init (GeocluePosition *position) +{ +} + +/** + * geoclue_position_new: + * @service: D-Bus service name + * @path: D-Bus path name + * + * Creates a #GeocluePosition with given D-Bus service name and path. + * + * Return value: Pointer to a new #GeocluePosition + */ +GeocluePosition * +geoclue_position_new (const char *service, + const char *path) +{ + return g_object_new (GEOCLUE_TYPE_POSITION, + "service", service, + "path", path, + "interface", GEOCLUE_POSITION_INTERFACE_NAME, + NULL); +} + +/** + * geoclue_position_get_position: + * @position: A #GeocluePosition object + * @timestamp: Pointer to returned time of position measurement (Unix timestamp) or %NULL + * @latitude: Pointer to returned latitude in degrees or %NULL + * @longitude: Pointer to returned longitude in degrees or %NULL + * @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 + * 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 + * left %NULL. + * + * Return value: A #GeocluePositionFields bitfield representing the + * validity of the position values. + */ +GeocluePositionFields +geoclue_position_get_position (GeocluePosition *position, + int *timestamp, + double *latitude, + double *longitude, + double *altitude, + GeoclueAccuracy **accuracy, + GError **error) +{ + GeoclueProvider *provider = GEOCLUE_PROVIDER (position); + double la, lo, al; + int ts, fields; + GeoclueAccuracy *acc; + if (!org_freedesktop_Geoclue_Position_get_position (provider->proxy, + &fields, &ts, + &la, &lo, &al, + &acc, error)) { + return GEOCLUE_POSITION_FIELDS_NONE; + } + + if (timestamp != NULL) { + *timestamp = ts; + } + + if (latitude != NULL && (fields & GEOCLUE_POSITION_FIELDS_LATITUDE)) { + *latitude = la; + } + + if (longitude != NULL && (fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)) { + *longitude = lo; + } + + if (altitude != NULL && (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE)) { + *altitude = al; + } + + if (accuracy != NULL) { + *accuracy = acc; + } + + return fields; +} + + +typedef struct _GeocluePositionAsyncData { + GeocluePosition *position; + GCallback callback; + gpointer userdata; +} GeocluePositionAsyncData; + +static void +get_position_async_callback (DBusGProxy *proxy, + GeocluePositionFields fields, + int timestamp, + double latitude, + double longitude, + double altitude, + GeoclueAccuracy *accuracy, + GError *error, + GeocluePositionAsyncData *data) +{ + (*(GeocluePositionCallback)data->callback) (data->position, + fields, + timestamp, + latitude, + longitude, + altitude, + accuracy, + error, + data->userdata); + g_free (data); +} + +/** + * GeocluePositionCallback: + * @position: A #GeocluePosition object + * @fields: A #GeocluePositionFields bitfield representing the validity of the position values + * @timestamp: Time of position measurement (Unix timestamp) + * @latitude: Latitude in degrees + * @longitude: Longitude in degrees + * @altitude: Altitude in meters + * @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(). + */ + +/** + * geoclue_position_get_position_async: + * @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 +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, + data); +} diff --git a/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-position.h b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-position.h new file mode 100755 index 0000000..da89a86 --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-position.h @@ -0,0 +1,85 @@ +/* + * Geoclue + * geoclue-position.h - + * + * Author: Iain Holmes <iain@openedhand.com> + * Copyright 2007 by Garmin Ltd. or its subsidiaries + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef _GEOCLUE_POSITION_H +#define _GEOCLUE_POSITION_H + +#include <geoclue/geoclue-provider.h> +#include <geoclue/geoclue-types.h> +#include <geoclue/geoclue-accuracy.h> + +G_BEGIN_DECLS + +#define GEOCLUE_TYPE_POSITION (geoclue_position_get_type ()) +#define GEOCLUE_POSITION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEOCLUE_TYPE_POSITION, GeocluePosition)) +#define GEOCLUE_IS_POSITION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEOCLUE_TYPE_POSITION)) + +#define GEOCLUE_POSITION_INTERFACE_NAME "org.freedesktop.Geoclue.Position" + +typedef struct _GeocluePosition { + GeoclueProvider provider; +} GeocluePosition; + +typedef struct _GeocluePositionClass { + GeoclueProviderClass provider_class; + + void (* position_changed) (GeocluePosition *position, + GeocluePositionFields fields, + int timestamp, + double latitude, + double longitude, + double altitude, + GeoclueAccuracy *accuracy); +} GeocluePositionClass; + +GType geoclue_position_get_type (void); + +GeocluePosition *geoclue_position_new (const char *service, + const char *path); + +GeocluePositionFields geoclue_position_get_position (GeocluePosition *position, + int *timestamp, + double *latitude, + double *longitude, + double *altitude, + GeoclueAccuracy **accuracy, + GError **error); + +typedef void (*GeocluePositionCallback) (GeocluePosition *position, + GeocluePositionFields fields, + int timestamp, + double latitude, + double longitude, + double altitude, + GeoclueAccuracy *accuracy, + GError *error, + gpointer userdata); + +void geoclue_position_get_position_async (GeocluePosition *position, + GeocluePositionCallback callback, + gpointer userdata); + +G_END_DECLS + +#endif diff --git a/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-satellite.c b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-satellite.c new file mode 100644 index 0000000..de38d0d --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-satellite.c @@ -0,0 +1,199 @@ +/* + * Geoclue + * geoclue-satellite.c - Client API for accessing GcIfaceSatellite + * + * Author: Sagnho Park <sangho.g.park@samsung.com>, Youngae Kang <youngae.kang@samsung.com>, + * Yunhan Kim <yhan.kim@samsung.com>, Genie Kim <daejins.kim@samsung.com> + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include <geoclue/geoclue-satellite.h> +#include <geoclue/geoclue-marshal.h> + +#include "gc-iface-satellite-bindings.h" + +typedef struct _GeoclueSatellitePrivate { + int dummy; +} GeoclueSatellitePrivate; + +enum { + SATELLITE_CHANGED, + LAST_SIGNAL +}; + +static guint32 signals[LAST_SIGNAL] = {0, }; + +#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GEOCLUE_TYPE_SATELLITE, GeoclueSatellitePrivate)) + +G_DEFINE_TYPE (GeoclueSatellite, geoclue_satellite, GEOCLUE_TYPE_PROVIDER); + +static void +finalize (GObject *object) +{ + G_OBJECT_CLASS (geoclue_satellite_parent_class)->finalize (object); +} + +static void +dispose (GObject *object) +{ + G_OBJECT_CLASS (geoclue_satellite_parent_class)->dispose (object); +} + +static void +satellite_changed (DBusGProxy *proxy, + int timestamp, + int satellite_used, + int satellite_visible, + GArray *used_prn, + GPtrArray *sat_info, + GeoclueSatellite *satellite) +{ + g_signal_emit (satellite, signals[SATELLITE_CHANGED], 0, timestamp, satellite_used, satellite_visible, + used_prn,sat_info); +} + +static GObject * +constructor (GType type, + guint n_props, + GObjectConstructParam *props) +{ + GObject *object; + GeoclueProvider *provider; + + object = G_OBJECT_CLASS (geoclue_satellite_parent_class)->constructor (type, n_props, props); + provider = GEOCLUE_PROVIDER (object); + + dbus_g_proxy_add_signal (provider->proxy, "SatelliteChanged", + G_TYPE_INT, + G_TYPE_INT, + G_TYPE_INT, + DBUS_TYPE_G_INT_ARRAY, + GEOCLUE_SATELLITE_INFO_ARRAY, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal (provider->proxy, "SatelliteChanged", + G_CALLBACK (satellite_changed), + object, NULL); + + return object; +} + +static void +geoclue_satellite_class_init (GeoclueSatelliteClass *klass) +{ + GObjectClass *o_class = (GObjectClass *) klass; + + o_class->finalize = finalize; + o_class->dispose = dispose; + 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 | + G_SIGNAL_NO_RECURSE, + G_STRUCT_OFFSET (GeoclueSatelliteClass, satellite_changed), + NULL, NULL, + geoclue_marshal_VOID__INT_INT_INT_POINTER_POINTER, + G_TYPE_NONE, 5, + G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, + G_TYPE_POINTER, G_TYPE_POINTER); +} + +static void +geoclue_satellite_init (GeoclueSatellite *satellite) +{ +} + +GeoclueSatellite * +geoclue_satellite_new (const char *service, + const char *path) +{ + return g_object_new (GEOCLUE_TYPE_SATELLITE, + "service", service, + "path", path, + "interface", GEOCLUE_SATELLITE_INTERFACE_NAME, + NULL); +} + +gboolean +geoclue_satellite_get_satellite (GeoclueSatellite *satellite, + int *timestamp, + int *satellite_used, + int *satellite_visible, + GArray **used_prn, + GPtrArray **sat_info, + GError **error) +{ + GeoclueProvider *provider = GEOCLUE_PROVIDER (satellite); + if (!org_freedesktop_Geoclue_Satellite_get_satellite (provider->proxy, + timestamp, satellite_used, satellite_visible, + used_prn, sat_info, error)) { + return FALSE; + } + + return TRUE; +} + + +typedef struct _GeoclueSatelliteAsyncData { + GeoclueSatellite *satellite; + GCallback callback; + gpointer userdata; +} GeoclueSatelliteAsyncData; + +static void +get_satellite_async_callback (DBusGProxy *proxy, + int timestamp, + int satellite_used, + int satellite_visible, + GArray *used_prn, + GPtrArray *sat_info, + GError *error, + GeoclueSatelliteAsyncData *data) +{ + (*(GeoclueSatelliteCallback)data->callback) (data->satellite, + timestamp, + satellite_used, + satellite_visible, + used_prn, + sat_info, + error, + data->userdata); + + g_free (data); +} + +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/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-satellite.h b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-satellite.h new file mode 100644 index 0000000..eb381cb --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-satellite.h @@ -0,0 +1,84 @@ +/* + * Geoclue + * geoclue-satellite.h - + * + * Author: Sagnho Park <sangho.g.park@samsung.com>, Youngae Kang <youngae.kang@samsung.com>, + * Yunhan Kim <yhan.kim@samsung.com>, Genie Kim <daejins.kim@samsung.com> + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef _GEOCLUE_SATELLITE_H +#define _GEOCLUE_SATELLITE_H + +#include <geoclue/geoclue-provider.h> +#include <geoclue/geoclue-types.h> +#include <geoclue/geoclue-satellite-info.h> + +G_BEGIN_DECLS + +#define GEOCLUE_TYPE_SATELLITE (geoclue_satellite_get_type ()) +#define GEOCLUE_SATELLITE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEOCLUE_TYPE_SATELLITE, GeoclueSatellite)) +#define GEOCLUE_IS_SATELLITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEOCLUE_TYPE_SATELLITE)) + +#define GEOCLUE_SATELLITE_INTERFACE_NAME "org.freedesktop.Geoclue.Satellite" + +typedef struct _GeoclueSatellite { + GeoclueProvider provider; +} GeoclueSatellite; + +typedef struct _GeoclueSatelliteClass { + GeoclueProviderClass provider_class; + + void (* satellite_changed) (GeoclueSatellite *satellite, + int timestamp, + int satellite_used, + int satellite_visible, + GArray *used_prn, + GPtrArray *sat_info); +} GeoclueSatelliteClass; + +GType geoclue_satellite_get_type (void); + +GeoclueSatellite *geoclue_satellite_new (const char *service, + const char *path); + +gboolean geoclue_satellite_get_satellite (GeoclueSatellite *satellite, + int *timestamp, + int *satellite_used, + int *satellite_visible, + GArray **used_prn, + GPtrArray **sat_info, + GError **error); + +typedef void (*GeoclueSatelliteCallback) (GeoclueSatellite *satellite, + int timestamp, + int satellite_used, + int satellite_visible, + GArray *used_prn, + GPtrArray *sat_info, + GError *error, + gpointer userdata); + +void geoclue_satellite_get_satellite_async (GeoclueSatellite *satellite, + GeoclueSatelliteCallback callback, + gpointer userdata); + +G_END_DECLS + +#endif diff --git a/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-velocity.c b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-velocity.c new file mode 100755 index 0000000..06abefd --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-velocity.c @@ -0,0 +1,291 @@ +/* + * Geoclue + * geoclue-velocity.c - Client API for accessing GcIfaceVelocity + * + * Author: Iain Holmes <iain@openedhand.com> + * Copyright 2007 by Garmin Ltd. or its subsidiaries + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +/** + * 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 + * to communicate with the actual provider. + * + * 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. + */ + +#include <geoclue/geoclue-velocity.h> +#include <geoclue/geoclue-marshal.h> + +#include "gc-iface-velocity-bindings.h" + +typedef struct _GeoclueVelocityPrivate { + int dummy; +} GeoclueVelocityPrivate; + +enum { + VELOCITY_CHANGED, + LAST_SIGNAL +}; + +static guint32 signals[LAST_SIGNAL] = {0, }; + +#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVASTE ((o), GEOCLUE_TYPE_VELOCITY, GeoclueVelocityPrivate)) + +G_DEFINE_TYPE (GeoclueVelocity, geoclue_velocity, GEOCLUE_TYPE_PROVIDER); + +static void +finalize (GObject *object) +{ + G_OBJECT_CLASS (geoclue_velocity_parent_class)->finalize (object); +} + +static void +dispose (GObject *object) +{ + G_OBJECT_CLASS (geoclue_velocity_parent_class)->dispose (object); +} + +static void +velocity_changed (DBusGProxy *proxy, + int fields, + int timestamp, + double speed, + double direction, + double climb, + GeoclueVelocity *velocity) +{ + g_signal_emit (velocity, signals[VELOCITY_CHANGED], 0, fields, + timestamp, speed, direction, climb); +} + +static GObject * +constructor (GType type, + guint n_props, + GObjectConstructParam *props) +{ + GObject *object; + GeoclueProvider *provider; + + object = G_OBJECT_CLASS (geoclue_velocity_parent_class)->constructor + (type, n_props, props); + provider = GEOCLUE_PROVIDER (object); + + dbus_g_proxy_add_signal (provider->proxy, "VelocityChanged", + G_TYPE_INT, G_TYPE_INT, G_TYPE_DOUBLE, + G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (provider->proxy, "VelocityChanged", + G_CALLBACK (velocity_changed), + object, NULL); + + return object; +} + +static void +geoclue_velocity_class_init (GeoclueVelocityClass *klass) +{ + GObjectClass *o_class = (GObjectClass *) klass; + + o_class->finalize = finalize; + o_class->dispose = dispose; + o_class->constructor = constructor; + + g_type_class_add_private (klass, sizeof (GeoclueVelocityPrivate)); + + /** + * GeoclueVelocity::velocity-changed: + * @velocity: the #GeoclueVelocity object emitting the signal + * @fields: A #GeoclueVelocityFields bitfield representing the validity of the velocity values + * @timestamp: Time of velocity measurement (Unix timestamp) + * @speed: horizontal speed + * @direction: horizontal direction (bearing) + * @climb: vertical speed + * + * 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", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST | + G_SIGNAL_NO_RECURSE, + G_STRUCT_OFFSET (GeoclueVelocityClass, velocity_changed), + NULL, NULL, + geoclue_marshal_VOID__INT_INT_DOUBLE_DOUBLE_DOUBLE, + G_TYPE_NONE, 5, + G_TYPE_INT, G_TYPE_INT, + G_TYPE_DOUBLE, G_TYPE_DOUBLE, + G_TYPE_DOUBLE); +} + +/** + * geoclue_velocity_new: + * @service: D-Bus service name + * @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 +geoclue_velocity_init (GeoclueVelocity *velocity) +{ +} + +GeoclueVelocity * +geoclue_velocity_new (const char *service, + const char *path) +{ + return g_object_new (GEOCLUE_TYPE_VELOCITY, + "service", service, + "path", path, + "interface", GEOCLUE_VELOCITY_INTERFACE_NAME, + NULL); +} + +/** + * geoclue_velocity_get_velocity: + * @velocity: A #GeoclueVelocity object + * @timestamp: Pointer to returned time of velocity measurement (unix timestamp) or %NULL + * @speed: Pointer to returned horizontal speed or %NULL + * @direction: Pointer to returned horizontal direction (bearing) or %NULL + * @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 + * the actual velocity measurement. + * + * If the caller is not interested in some values, the pointers can be + * left %NULL. + * + * Return value: A #GeoclueVelocityFields bitfield representing the + * validity of the velocity values. + */ +GeoclueVelocityFields +geoclue_velocity_get_velocity (GeoclueVelocity *velocity, + int *timestamp, + double *speed, + double *direction, + double *climb, + GError **error) +{ + GeoclueProvider *provider = GEOCLUE_PROVIDER (velocity); + double sp, di, cl; + int ts, fields; + + if (!org_freedesktop_Geoclue_Velocity_get_velocity (provider->proxy, + &fields, &ts, + &sp, &di, &cl, + error)) { + return GEOCLUE_VELOCITY_FIELDS_NONE; + } + + if (timestamp != NULL) { + *timestamp = ts; + } + + if (speed != NULL && (fields & GEOCLUE_VELOCITY_FIELDS_SPEED)) { + *speed = sp; + } + + if (direction != NULL && (fields & GEOCLUE_VELOCITY_FIELDS_DIRECTION)) { + *direction = di; + } + + if (climb != NULL && (fields & GEOCLUE_VELOCITY_FIELDS_CLIMB)) { + *climb = cl; + } + + return fields; +} + +typedef struct _GeoclueVelocityAsyncData { + GeoclueVelocity *velocity; + GCallback callback; + gpointer userdata; +} GeoclueVelocityAsyncData; + +static void +get_velocity_async_callback (DBusGProxy *proxy, + GeoclueVelocityFields fields, + int timestamp, + double speed, + double direction, + double climb, + GError *error, + GeoclueVelocityAsyncData *data) +{ + (*(GeoclueVelocityCallback)data->callback) (data->velocity, + fields, + timestamp, + speed, + direction, + climb, + error, + data->userdata); + g_free (data); +} + +/** + * GeoclueVelocityCallback: + * @velocity: A #GeoclueVelocity object + * @fields: A #GeoclueVelocityFields bitfield representing the validity of the velocity values + * @timestamp: Time of velocity measurement (unix timestamp) + * @speed: Horizontal speed + * @direction: Horizontal direction (bearing) + * @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(). + */ + +/** + * geoclue_velocity_get_velocity_async: + * @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 +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, + data); +} diff --git a/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-velocity.h b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-velocity.h new file mode 100755 index 0000000..2d33e08 --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/geoclue/geoclue-velocity.h @@ -0,0 +1,82 @@ +/* + * Geoclue + * geoclue-velocity.h - + * + * Author: Iain Holmes <iain@openedhand.com> + * Copyright 2007 by Garmin Ltd. or its subsidiaries + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef _GEOCLUE_VELOCITY_H +#define _GEOCLUE_VELOCITY_H + +#include <geoclue/geoclue-provider.h> +#include <geoclue/geoclue-types.h> +#include <geoclue/geoclue-accuracy.h> + +G_BEGIN_DECLS + +#define GEOCLUE_TYPE_VELOCITY (geoclue_velocity_get_type ()) +#define GEOCLUE_VELOCITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEOCLUE_TYPE_VELOCITY, GeoclueVelocity)) +#define GEOCLUE_IS_VELOCITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEOCLUE_TYPE_VELOCITY)) + +#define GEOCLUE_VELOCITY_INTERFACE_NAME "org.freedesktop.Geoclue.Velocity" + +typedef struct _GeoclueVelocity { + GeoclueProvider provider; +} GeoclueVelocity; + +typedef struct _GeoclueVelocityClass { + GeoclueProviderClass provider_class; + + void (* velocity_changed) (GeoclueVelocity *velocity, + GeoclueVelocityFields fields, + int timestamp, + double speed, + double direction, + double climb); +} GeoclueVelocityClass; + +GType geoclue_velocity_get_type (void); + +GeoclueVelocity *geoclue_velocity_new (const char *service, + const char *path); + +GeoclueVelocityFields geoclue_velocity_get_velocity (GeoclueVelocity *velocity, + int *timestamp, + double *speed, + double *direction, + double *climb, + GError **error); + +typedef void (*GeoclueVelocityCallback) (GeoclueVelocity *velocity, + GeoclueVelocityFields fields, + int timestamp, + double speed, + double direction, + double climb, + GError *error, + gpointer userdata); + +void geoclue_velocity_get_velocity_async (GeoclueVelocity *velocity, + GeoclueVelocityCallback callback, + gpointer userdata); + +G_END_DECLS + +#endif diff --git a/.pc/geoclue_0.12.0-24slp2.patch/interfaces/gc-iface-position-full.xml b/.pc/geoclue_0.12.0-24slp2.patch/interfaces/gc-iface-position-full.xml new file mode 100755 index 0000000..7646605 --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/interfaces/gc-iface-position-full.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> + + <interface name="org.freedesktop.Geoclue.Position"> + <doc:doc> + <doc:para>Position interface contains a method + and a signal for querying current coordinates.</doc:para> + </doc:doc> + + <method name="GetPosition"> + <arg type="i" name="fields" direction="out" /> + <arg type="i" name="timestamp" direction="out" /> + + <arg type="d" name="latitude" direction="out" /> + <arg type="d" name="longitude" direction="out" /> + <arg type="d" name="altitude" direction="out" /> + + <arg name="accuracy" type="(idd)" direction="out" /> + </method> + + <signal name="PositionChanged"> + <arg type="i" name="fields" /> + <arg type="i" name="timestamp" /> + <arg type="d" name="latitude" /> + <arg type="d" name="longitude" /> + <arg type="d" name="altitude" /> + + <arg type="(idd)" name="accuracy" /> + </signal> + </interface> +</node> diff --git a/.pc/geoclue_0.12.0-24slp2.patch/interfaces/gc-iface-satellite-full.xml b/.pc/geoclue_0.12.0-24slp2.patch/interfaces/gc-iface-satellite-full.xml new file mode 100644 index 0000000..83e48a2 --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/interfaces/gc-iface-satellite-full.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/"> + <interface name="org.freedesktop.Geoclue.Satellite"> + <method name="GetSatellite"> + <arg type="i" name="timestamp" direction="out" /> + <arg type="i" name="satellite_used" direction="out" /> + <arg type="i" name="satellite_visible" direction="out" /> + <arg type="ai" name="used_prn" direction="out" /> + <arg type="a(iiii)" name="sat_info" direction="out" /> + </method> + + <signal name="SatelliteChanged"> + <arg type="i" name="timestamp" /> + <arg type="i" name="satellite_used" /> + <arg type="i" name="satellite_visible" /> + <arg type="ai" name="used_prn" /> + <arg type="a(iiii)" name="sat_info" /> + </signal> + </interface> +</node> diff --git a/.pc/geoclue_0.12.0-24slp2.patch/interfaces/gc-iface-velocity-full.xml b/.pc/geoclue_0.12.0-24slp2.patch/interfaces/gc-iface-velocity-full.xml new file mode 100755 index 0000000..de07243 --- /dev/null +++ b/.pc/geoclue_0.12.0-24slp2.patch/interfaces/gc-iface-velocity-full.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/"> + <interface name="org.freedesktop.Geoclue.Velocity"> + <method name="GetVelocity"> + <arg type="i" name="fields" direction="out" /> + <arg type="i" name="timestamp" direction="out" /> + <arg type="d" name="speed" direction="out" /> + <arg type="d" name="direction" direction="out" /> + <arg type="d" name="climb" direction="out" /> + </method> + + <signal name="VelocityChanged"> + <arg type="i" name="fields" /> + <arg type="i" name="timestamp" /> + <arg type="d" name="speed" /> + <arg type="d" name="direction" /> + <arg type="d" name="climb" /> + </signal> + </interface> +</node> diff --git a/.pc/geoclue_0.12.0-25slp2.patch/.timestamp b/.pc/geoclue_0.12.0-25slp2.patch/.timestamp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pc/geoclue_0.12.0-25slp2.patch/.timestamp diff --git a/.pc/geoclue_0.12.0-25slp2.patch/geoclue/gc-web-service.c b/.pc/geoclue_0.12.0-25slp2.patch/geoclue/gc-web-service.c new file mode 100644 index 0000000..eee8f1f --- /dev/null +++ b/.pc/geoclue_0.12.0-25slp2.patch/geoclue/gc-web-service.c @@ -0,0 +1,442 @@ +/* + * Geoclue + * gc-web-service.c - A web service helper object for geoclue providers + * + * Author: Jussi Kukkonen <jku@o-hand.com> + * + * Copyright 2007 Jussi Kukkonen (from old geoclue_web_service.c) + * Copyright 2007, 2008 by Garmin Ltd. or its subsidiaries + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +/** + * 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 + * gc_web_service_get_response() as well). + * + * At the moment xml parsing functions only exist for double and + * char-array data types. Adding new functions is trivial, though. + * <informalexample> + * <programlisting> + * . . . + * + * #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 * / + * 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, + * "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)); + * </programlisting> + * </informalexample> + */ + +#include <stdarg.h> +#include <glib-object.h> + +#include <libxml/nanohttp.h> +#include <libxml/xpathInternals.h> +#include <libxml/uri.h> /* for xmlURIEscapeStr */ + +#include "gc-web-service.h" +#include "geoclue-error.h" + +G_DEFINE_TYPE (GcWebService, gc_web_service, G_TYPE_OBJECT) + +typedef struct _XmlNamespace { + gchar *name; + gchar *uri; +}XmlNamespace; + +/* GFunc, use with g_list_foreach */ +static void +gc_web_service_register_ns (gpointer data, gpointer user_data) +{ + GcWebService *self = (GcWebService *)user_data; + XmlNamespace *ns = (XmlNamespace *)data; + + xmlXPathRegisterNs (self->xpath_ctx, + (xmlChar*)ns->name, (xmlChar*)ns->uri); +} + +/* GFunc, use with g_list_foreach */ +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); +} + + +/* Register namespaces listed in self->namespaces */ +static void +gc_web_service_register_namespaces (GcWebService *self) +{ + g_assert (self->xpath_ctx); + g_list_foreach (self->namespaces, (GFunc)gc_web_service_register_ns, self); +} + +static void +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); + } + xmlXPathFreeContext (self->xpath_ctx); + self->xpath_ctx = NULL; + } +} + +/* 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); + if (!doc) { + /* TODO: error handling */ + g_free (tmp); + return FALSE; + } + xmlFree (tmp); + + self->xpath_ctx = xmlXPathNewContext(doc); + if (!self->xpath_ctx) { + /* TODO: error handling */ + return FALSE; + } + gc_web_service_register_namespaces (self); + return TRUE; +} + +/* fetch data from url, save into self->response */ +static gboolean +gc_web_service_fetch (GcWebService *self, gchar *url, GError **error) +{ + void* ctxt = NULL; + 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, + 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, + 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; +} + +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 && + (!obj->nodesetval || xmlXPathNodeSetIsEmpty (obj->nodesetval))) { + xmlXPathFreeObject (obj); + obj = NULL; + } + return obj; +} + +static void +gc_web_service_init (GcWebService *self) +{ + self->response = NULL; + self->response_length = 0; + self->xpath_ctx = NULL; + self->namespaces = NULL; + self->base_url = NULL; +} + + +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); +} + +static void +gc_web_service_class_init (GcWebServiceClass *klass) +{ + GObjectClass *o_class = (GObjectClass *) klass; + o_class->finalize = gc_web_service_finalize; +} + +/** + * 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 + * 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. + * + * Return value: %TRUE on success. + */ +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); + self->namespaces = g_list_prepend (self->namespaces, ns); + return TRUE; +} + +/** + * 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 + * gc_web_service_get_* -functions. + * + * Return value: %TRUE on success. + */ +gboolean +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); + key = va_arg (list, char*); + 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; + } else { + tmp = g_strdup_printf ("%s&%s=%s", url, key, esc_value); + } + g_free (esc_value); + g_free (url); + url = tmp; + 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; +} + +/** + * 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 + * value is the first match. + * + * Return value: %TRUE if a value was found. + */ +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; + } + *value = xmlXPathCastNodeSetToNumber (obj->nodesetval); + xmlXPathFreeObject (obj); + return TRUE; +} + +/** + * 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 + * value is the first match). + * + * Return value: %TRUE if a value was found. + */ +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; + } + *value = (char*)xmlXPathCastNodeSetToString (obj->nodesetval); + xmlXPathFreeObject (obj); + return TRUE; +} + +/** + * gc_web_service_get_response: + * @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 + * gc_web_service_query(). Data may be unterminated. + * + * Return value: %TRUE on success. + */ +gboolean +gc_web_service_get_response (GcWebService *self, guchar **response, gint *response_length) +{ + *response = g_memdup (self->response, self->response_length); + *response_length = self->response_length; + return TRUE; +} |