From ca6c40ef054a57bf3ea2dd923b78668f71a8436d Mon Sep 17 00:00:00 2001 From: Ankit Date: Thu, 19 Mar 2015 18:48:52 +0530 Subject: [PATCH] Switch to GClueLocation class This patch switches the code from use of GeocodeLocation to GClueLocation. This is needed for the new API which will be added to GClueLocation. https://bugs.freedesktop.org/show_bug.cgi?id=89395 --- src/gclue-3g.c | 10 +++++----- src/gclue-cdma.c | 10 +++++----- src/gclue-config.h | 2 +- src/gclue-location-source.c | 22 ++++++++++++---------- src/gclue-location-source.h | 6 +++--- src/gclue-locator.c | 21 ++++++++++++--------- src/gclue-locator.h | 2 +- src/gclue-modem-gps.c | 6 +++--- src/gclue-mozilla.c | 18 +++++++++--------- src/gclue-mozilla.h | 6 +++--- src/gclue-service-client.c | 10 +++++----- src/gclue-service-location.c | 22 ++++++++++++---------- src/gclue-service-location.h | 4 ++-- src/gclue-web-source.c | 13 +++++++------ src/gclue-web-source.h | 4 ++-- src/gclue-wifi.c | 8 ++++---- 16 files changed, 86 insertions(+), 78 deletions(-) diff --git a/src/gclue-3g.c b/src/gclue-3g.c index ec182af..f83a5f8 100644 --- a/src/gclue-3g.c +++ b/src/gclue-3g.c @@ -25,7 +25,7 @@ #include #include "gclue-3g.h" #include "gclue-modem-manager.h" -#include "geocode-glib/geocode-location.h" +#include "gclue-location.h" #include "gclue-mozilla.h" /** @@ -56,12 +56,12 @@ gclue_3g_create_query (GClueWebSource *web, GError **error); static SoupMessage * gclue_3g_create_submit_query (GClueWebSource *web, - GeocodeLocation *location, + GClueLocation *location, GError **error); static GClueAccuracyLevel gclue_3g_get_available_accuracy_level (GClueWebSource *web, gboolean available); -static GeocodeLocation * +static GClueLocation * gclue_3g_parse_response (GClueWebSource *web, const char *xml, GError **error); @@ -100,7 +100,7 @@ on_is_3g_available_notify (GObject *gobject, source); } -static GeocodeLocation * +static GClueLocation * gclue_3g_parse_response (GClueWebSource *web, const char *content, GError **error) @@ -216,7 +216,7 @@ gclue_3g_create_query (GClueWebSource *web, static SoupMessage * gclue_3g_create_submit_query (GClueWebSource *web, - GeocodeLocation *location, + GClueLocation *location, GError **error) { GClue3GPrivate *priv = GCLUE_3G (web)->priv; diff --git a/src/gclue-cdma.c b/src/gclue-cdma.c index c1caada..70b9581 100644 --- a/src/gclue-cdma.c +++ b/src/gclue-cdma.c @@ -24,7 +24,7 @@ #include #include "gclue-cdma.h" #include "gclue-modem-manager.h" -#include "geocode-glib/geocode-location.h" +#include "gclue-location.h" /** * SECTION:gclue-cdma @@ -193,11 +193,11 @@ on_fix_cdma (GClueModem *modem, gdouble longitude, gpointer user_data) { - GeocodeLocation *location; + GClueLocation *location; - location = geocode_location_new (latitude, - longitude, - 1000); /* Assume 1 km accuracy */ + location = gclue_location_new (latitude, + longitude, + 1000); /* Assume 1 km accuracy */ gclue_location_source_set_location (GCLUE_LOCATION_SOURCE (user_data), location); diff --git a/src/gclue-config.h b/src/gclue-config.h index a1831f7..93e12c5 100644 --- a/src/gclue-config.h +++ b/src/gclue-config.h @@ -24,7 +24,7 @@ #define GCLUE_CONFIG_H #include -#include "geocode-glib/geocode-location.h" +#include "gclue-location.h" #include "gclue-client-info.h" #include "gclue-config.h" diff --git a/src/gclue-location-source.c b/src/gclue-location-source.c index ce2a1c0..079c45d 100644 --- a/src/gclue-location-source.c +++ b/src/gclue-location-source.c @@ -39,7 +39,7 @@ G_DEFINE_ABSTRACT_TYPE (GClueLocationSource, gclue_location_source, G_TYPE_OBJEC struct _GClueLocationSourcePrivate { - GeocodeLocation *location; + GClueLocation *location; guint active_counter; @@ -95,7 +95,7 @@ gclue_location_source_set_property (GObject *object, switch (prop_id) { case PROP_LOCATION: { - GeocodeLocation *location = g_value_get_object (value); + GClueLocation *location = g_value_get_object (value); gclue_location_source_set_location (source, location); break; @@ -138,7 +138,7 @@ gclue_location_source_class_init (GClueLocationSourceClass *klass) gParamSpecs[PROP_LOCATION] = g_param_spec_object ("location", "Location", "Location", - GEOCODE_TYPE_LOCATION, + GCLUE_TYPE_LOCATION, G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_LOCATION, @@ -246,7 +246,7 @@ gclue_location_source_stop (GClueLocationSource *source) * * Returns: (transfer none): The location, or NULL if unknown. **/ -GeocodeLocation * +GClueLocation * gclue_location_source_get_location (GClueLocationSource *source) { g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), NULL); @@ -263,18 +263,20 @@ gclue_location_source_get_location (GClueLocationSource *source) **/ void gclue_location_source_set_location (GClueLocationSource *source, - GeocodeLocation *location) + GClueLocation *location) { GClueLocationSourcePrivate *priv = source->priv; + GeocodeLocation *gloc; if (priv->location == NULL) - priv->location = g_object_new (GEOCODE_TYPE_LOCATION, NULL); + priv->location = g_object_new (GCLUE_TYPE_LOCATION, NULL); + gloc = GEOCODE_LOCATION (location); g_object_set (priv->location, - "latitude", geocode_location_get_latitude (location), - "longitude", geocode_location_get_longitude (location), - "accuracy", geocode_location_get_accuracy (location), - "description", geocode_location_get_description (location), + "latitude", geocode_location_get_latitude (gloc), + "longitude", geocode_location_get_longitude (gloc), + "accuracy", geocode_location_get_accuracy (gloc), + "description", geocode_location_get_description (gloc), NULL); g_object_notify (G_OBJECT (source), "location"); diff --git a/src/gclue-location-source.h b/src/gclue-location-source.h index 5c5c3d0..059b290 100644 --- a/src/gclue-location-source.h +++ b/src/gclue-location-source.h @@ -25,7 +25,7 @@ #include #include #include "public-api/gclue-enum-types.h" -#include "geocode-glib/geocode-location.h" +#include "gclue-location.h" G_BEGIN_DECLS @@ -61,11 +61,11 @@ GType gclue_location_source_get_type (void) G_GNUC_CONST; void gclue_location_source_start (GClueLocationSource *source); void gclue_location_source_stop (GClueLocationSource *source); -GeocodeLocation * gclue_location_source_get_location +GClueLocation *gclue_location_source_get_location (GClueLocationSource *source); void gclue_location_source_set_location (GClueLocationSource *source, - GeocodeLocation *location); + GClueLocation *location); gboolean gclue_location_source_get_active (GClueLocationSource *source); GClueAccuracyLevel diff --git a/src/gclue-locator.c b/src/gclue-locator.c index 42ce395..c93ccf1 100644 --- a/src/gclue-locator.c +++ b/src/gclue-locator.c @@ -70,21 +70,24 @@ enum static GParamSpec *gParamSpecs[LAST_PROP]; static void -set_location (GClueLocator *locator, - GeocodeLocation *location) +set_location (GClueLocator *locator, + GClueLocation *location) { - GeocodeLocation *cur_location; + GClueLocation *cur_location; + GeocodeLocation *gloc, *cur_gloc; cur_location = gclue_location_source_get_location (GCLUE_LOCATION_SOURCE (locator)); + gloc = GEOCODE_LOCATION (location); + cur_gloc = GEOCODE_LOCATION (cur_location); g_debug ("New location available"); if (cur_location != NULL && - geocode_location_get_distance_from (location, cur_location) < - geocode_location_get_accuracy (location) && - geocode_location_get_accuracy (location) > - geocode_location_get_accuracy (cur_location)) { + geocode_location_get_distance_from (gloc, cur_gloc) < + geocode_location_get_accuracy (gloc) && + geocode_location_get_accuracy (gloc) > + geocode_location_get_accuracy (cur_gloc)) { /* We only take the new location if either the previous one * lies outside its accuracy circle or its more or as * accurate as previous one. @@ -129,7 +132,7 @@ on_location_changed (GObject *gobject, { GClueLocator *locator = GCLUE_LOCATOR (user_data); GClueLocationSource *source = GCLUE_LOCATION_SOURCE (gobject); - GeocodeLocation *location; + GClueLocation *location; location = gclue_location_source_get_location (source); set_location (locator, location); @@ -146,7 +149,7 @@ static void start_source (GClueLocator *locator, GClueLocationSource *src) { - GeocodeLocation *location; + GClueLocation *location; g_signal_connect (G_OBJECT (src), "notify::location", diff --git a/src/gclue-locator.h b/src/gclue-locator.h index 10350e0..97e52e0 100644 --- a/src/gclue-locator.h +++ b/src/gclue-locator.h @@ -24,7 +24,7 @@ #define GCLUE_LOCATOR_H #include -#include "geocode-glib/geocode-location.h" +#include "gclue-location.h" #include "public-api/gclue-enum-types.h" #include "gclue-location-source.h" diff --git a/src/gclue-modem-gps.c b/src/gclue-modem-gps.c index 7f1338f..ed5a2b7 100644 --- a/src/gclue-modem-gps.c +++ b/src/gclue-modem-gps.c @@ -24,7 +24,7 @@ #include #include "gclue-modem-gps.h" #include "gclue-modem-manager.h" -#include "geocode-glib/geocode-location.h" +#include "gclue-location.h" /** * SECTION:gclue-modem-gps @@ -268,7 +268,7 @@ on_fix_gps (GClueModem *modem, gpointer user_data) { GClueModemGPS *source = GCLUE_MODEM_GPS (user_data); - GeocodeLocation *location; + GClueLocation *location; gdouble latitude, longitude, accuracy, altitude; gdouble hdop; /* Horizontal Dilution Of Precision */ char **parts; @@ -295,7 +295,7 @@ on_fix_gps (GClueModem *modem, hdop = g_ascii_strtod (parts[8], NULL); accuracy = get_accuracy_from_hdop (hdop); - location = geocode_location_new (latitude, longitude, accuracy); + location = gclue_location_new (latitude, longitude, accuracy); if (altitude != GEOCODE_LOCATION_ALTITUDE_UNKNOWN) g_object_set (location, "altitude", altitude, NULL); gclue_location_source_set_location (GCLUE_LOCATION_SOURCE (source), diff --git a/src/gclue-mozilla.c b/src/gclue-mozilla.c index 80afeba..3d0d31d 100644 --- a/src/gclue-mozilla.c +++ b/src/gclue-mozilla.c @@ -216,14 +216,14 @@ parse_server_error (JsonObject *object, GError **error) return TRUE; } -GeocodeLocation * +GClueLocation * gclue_mozilla_parse_response (const char *json, GError **error) { JsonParser *parser; JsonNode *node; JsonObject *object, *loc_object; - GeocodeLocation *location; + GClueLocation *location; gdouble latitude, longitude, accuracy; parser = json_parser_new (); @@ -243,7 +243,7 @@ gclue_mozilla_parse_response (const char *json, accuracy = json_object_get_double_member (object, "accuracy"); - location = geocode_location_new (latitude, longitude, accuracy); + location = gclue_location_new (latitude, longitude, accuracy); g_object_unref (parser); @@ -265,7 +265,7 @@ get_submit_config (const char **nick) } SoupMessage * -gclue_mozilla_create_submit_query (GeocodeLocation *location, +gclue_mozilla_create_submit_query (GClueLocation *location, GList *bss_list, /* As in Access Points */ GClue3GTower *tower, GError **error) @@ -293,27 +293,27 @@ gclue_mozilla_create_submit_query (GeocodeLocation *location, json_builder_begin_object (builder); - lat = geocode_location_get_latitude (location); + lat = geocode_location_get_latitude (GEOCODE_LOCATION (location)); json_builder_set_member_name (builder, "lat"); json_builder_add_double_value (builder, lat); - lon = geocode_location_get_longitude (location); + lon = geocode_location_get_longitude (GEOCODE_LOCATION (location)); json_builder_set_member_name (builder, "lon"); json_builder_add_double_value (builder, lon); - accuracy = geocode_location_get_accuracy (location); + accuracy = geocode_location_get_accuracy (GEOCODE_LOCATION (location)); if (accuracy != GEOCODE_LOCATION_ACCURACY_UNKNOWN) { json_builder_set_member_name (builder, "accuracy"); json_builder_add_double_value (builder, accuracy); } - altitude = geocode_location_get_altitude (location); + altitude = geocode_location_get_altitude (GEOCODE_LOCATION (location)); if (altitude != GEOCODE_LOCATION_ALTITUDE_UNKNOWN) { json_builder_set_member_name (builder, "altitude"); json_builder_add_double_value (builder, altitude); } - tv.tv_sec = geocode_location_get_timestamp (location); + tv.tv_sec = geocode_location_get_timestamp (GEOCODE_LOCATION (location)); tv.tv_usec = 0; timestamp = g_time_val_to_iso8601 (&tv); json_builder_set_member_name (builder, "time"); diff --git a/src/gclue-mozilla.h b/src/gclue-mozilla.h index cc3f74d..88e8502 100644 --- a/src/gclue-mozilla.h +++ b/src/gclue-mozilla.h @@ -25,7 +25,7 @@ #include #include #include "wpa_supplicant-interface.h" -#include "geocode-glib/geocode-location.h" +#include "gclue-location.h" #include "gclue-3g-tower.h" G_BEGIN_DECLS @@ -34,11 +34,11 @@ SoupMessage * gclue_mozilla_create_query (GList *bss_list, /* As in Access Points */ GClue3GTower *tower, GError **error); -GeocodeLocation * +GClueLocation * gclue_mozilla_parse_response (const char *json, GError **error); SoupMessage * -gclue_mozilla_create_submit_query (GeocodeLocation *location, +gclue_mozilla_create_submit_query (GClueLocation *location, GList *bss_list, /* As in Access Points */ GClue3GTower *tower, GError **error); diff --git a/src/gclue-service-client.c b/src/gclue-service-client.c index e6dffad..6e9867d 100644 --- a/src/gclue-service-client.c +++ b/src/gclue-service-client.c @@ -114,10 +114,10 @@ emit_location_updated (GClueServiceClient *client, static gboolean below_threshold (GClueServiceClient *client, - GeocodeLocation *location) + GClueLocation *location) { GClueServiceClientPrivate *priv = client->priv; - GeocodeLocation *cur_location; + GClueLocation *cur_location; gdouble distance; gdouble threshold_km; @@ -127,8 +127,8 @@ below_threshold (GClueServiceClient *client, g_object_get (priv->location, "location", &cur_location, NULL); - distance = geocode_location_get_distance_from (cur_location, - location); + distance = geocode_location_get_distance_from + (GEOCODE_LOCATION (cur_location), GEOCODE_LOCATION (location)); g_object_unref (cur_location); threshold_km = priv->threshold / 1000.0; @@ -146,7 +146,7 @@ on_locator_location_changed (GObject *gobject, GClueServiceClient *client = GCLUE_SERVICE_CLIENT (user_data); GClueServiceClientPrivate *priv = client->priv; GClueLocationSource *locator = GCLUE_LOCATION_SOURCE (gobject); - GeocodeLocation *location_info; + GClueLocation *location_info; char *path = NULL; const char *prev_path; GError *error = NULL; diff --git a/src/gclue-service-location.c b/src/gclue-service-location.c index 6bdbb41..ba29da9 100644 --- a/src/gclue-service-location.c +++ b/src/gclue-service-location.c @@ -89,10 +89,10 @@ gclue_service_location_get_property (GObject *object, case PROP_LOCATION: { - GeocodeLocation *loc; + GClueLocation *loc; gdouble altitude; - loc = geocode_location_new_with_description + loc = gclue_location_new_with_description (gclue_dbus_location_get_latitude (location), gclue_dbus_location_get_longitude (location), gclue_dbus_location_get_accuracy (location), @@ -134,19 +134,21 @@ gclue_service_location_set_property (GObject *object, case PROP_LOCATION: { - GeocodeLocation *loc; + GClueLocation *loc; gdouble altitude; + GeocodeLocation *g_loc; loc = g_value_get_object (value); + g_loc = GEOCODE_LOCATION (loc); gclue_dbus_location_set_latitude - (location, geocode_location_get_latitude (loc)); + (location, geocode_location_get_latitude (g_loc)); gclue_dbus_location_set_longitude - (location, geocode_location_get_longitude (loc)); + (location, geocode_location_get_longitude (g_loc)); gclue_dbus_location_set_accuracy - (location, geocode_location_get_accuracy (loc)); + (location, geocode_location_get_accuracy (g_loc)); gclue_dbus_location_set_description - (location, geocode_location_get_description (loc)); - altitude = geocode_location_get_altitude (loc); + (location, geocode_location_get_description (g_loc)); + altitude = geocode_location_get_altitude (g_loc); if (altitude != GEOCODE_LOCATION_ALTITUDE_UNKNOWN) gclue_dbus_location_set_altitude (location, altitude); break; @@ -320,7 +322,7 @@ gclue_service_location_class_init (GClueServiceLocationClass *klass) gParamSpecs[PROP_LOCATION] = g_param_spec_object ("location", "Location", "Location", - GEOCODE_TYPE_LOCATION, + GCLUE_TYPE_LOCATION, G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_LOCATION, @@ -359,7 +361,7 @@ GClueServiceLocation * gclue_service_location_new (GClueClientInfo *info, const char *path, GDBusConnection *connection, - GeocodeLocation *location, + GClueLocation *location, GError **error) { return g_initable_new (GCLUE_TYPE_SERVICE_LOCATION, diff --git a/src/gclue-service-location.h b/src/gclue-service-location.h index 482b88c..eeb1f7d 100644 --- a/src/gclue-service-location.h +++ b/src/gclue-service-location.h @@ -24,7 +24,7 @@ #define GCLUE_SERVICE_LOCATION_H #include -#include "geocode-glib/geocode-location.h" +#include "gclue-location.h" #include "gclue-client-info.h" #include "geoclue-interface.h" @@ -60,7 +60,7 @@ GType gclue_service_location_get_type (void) G_GNUC_CONST; GClueServiceLocation * gclue_service_location_new (GClueClientInfo *info, const char *path, GDBusConnection *connection, - GeocodeLocation *location, + GClueLocation *location, GError **error); const char * gclue_service_location_get_path (GClueServiceLocation *location); diff --git a/src/gclue-web-source.c b/src/gclue-web-source.c index 131d683..054b9cf 100644 --- a/src/gclue-web-source.c +++ b/src/gclue-web-source.c @@ -26,7 +26,7 @@ #include #include "gclue-web-source.h" #include "gclue-error.h" -#include "geocode-glib/geocode-location.h" +#include "gclue-location.h" /** * SECTION:gclue-web-source @@ -62,7 +62,7 @@ query_callback (SoupSession *session, GError *error = NULL; char *contents; char *str; - GeocodeLocation *location; + GClueLocation *location; SoupURI *uri; if (query->status_code == SOUP_STATUS_CANCELLED) @@ -293,19 +293,20 @@ on_submit_source_location_notify (GObject *source_object, GClueLocationSource *source = GCLUE_LOCATION_SOURCE (source_object); GClueWebSource *web = GCLUE_WEB_SOURCE (user_data); GNetworkMonitor *monitor; - GeocodeLocation *location; + GClueLocation *location; SoupMessage *query; GError *error = NULL; location = gclue_location_source_get_location (source); if (location == NULL || - geocode_location_get_accuracy (location) > + geocode_location_get_accuracy (GEOCODE_LOCATION (location)) > SUBMISSION_ACCURACY_THRESHOLD || - geocode_location_get_timestamp (location) < + geocode_location_get_timestamp (GEOCODE_LOCATION (location)) < web->priv->last_submitted + SUBMISSION_TIME_THRESHOLD) return; - web->priv->last_submitted = geocode_location_get_timestamp (location); + web->priv->last_submitted = geocode_location_get_timestamp + (GEOCODE_LOCATION (location)); monitor = g_network_monitor_get_default (); if (!g_network_monitor_get_network_available (monitor)) diff --git a/src/gclue-web-source.h b/src/gclue-web-source.h index 07ec0b1..9dd0349 100644 --- a/src/gclue-web-source.h +++ b/src/gclue-web-source.h @@ -65,9 +65,9 @@ struct _GClueWebSourceClass { SoupMessage * (*create_query) (GClueWebSource *source, GError **error); SoupMessage * (*create_submit_query) (GClueWebSource *source, - GeocodeLocation *location, + GClueLocation *location, GError **error); - GeocodeLocation * (*parse_response) (GClueWebSource *source, + GClueLocation * (*parse_response) (GClueWebSource *source, const char *response, GError **error); GClueAccuracyLevel (*get_available_accuracy_level) diff --git a/src/gclue-wifi.c b/src/gclue-wifi.c index e94ef04..6626781 100644 --- a/src/gclue-wifi.c +++ b/src/gclue-wifi.c @@ -67,9 +67,9 @@ gclue_wifi_create_query (GClueWebSource *source, GError **error); static SoupMessage * gclue_wifi_create_submit_query (GClueWebSource *source, - GeocodeLocation *location, + GClueLocation *location, GError **error); -static GeocodeLocation * +static GClueLocation * gclue_wifi_parse_response (GClueWebSource *source, const char *json, GError **error); @@ -680,7 +680,7 @@ gclue_wifi_create_query (GClueWebSource *source, return gclue_mozilla_create_query (bss_list, NULL, error); } -static GeocodeLocation * +static GClueLocation * gclue_wifi_parse_response (GClueWebSource *source, const char *json, GError **error) @@ -690,7 +690,7 @@ gclue_wifi_parse_response (GClueWebSource *source, static SoupMessage * gclue_wifi_create_submit_query (GClueWebSource *source, - GeocodeLocation *location, + GClueLocation *location, GError **error) { GList *bss_list; /* As in Access Points */ -- 2.1.0