Commit fa72e03f authored by Ankit's avatar Ankit Committed by Zeeshan Ali

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
parent 3a03cd32
......@@ -25,7 +25,7 @@
#include <string.h>
#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;
......
......@@ -24,7 +24,7 @@
#include <string.h>
#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);
......
......@@ -24,7 +24,7 @@
#define GCLUE_CONFIG_H
#include <gio/gio.h>
#include "geocode-glib/geocode-location.h"
#include "gclue-location.h"
#include "gclue-client-info.h"
#include "gclue-config.h"
......
......@@ -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");
......
......@@ -25,7 +25,7 @@
#include <glib.h>
#include <gio/gio.h>
#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
......
......@@ -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",
......
......@@ -24,7 +24,7 @@
#define GCLUE_LOCATOR_H
#include <gio/gio.h>
#include "geocode-glib/geocode-location.h"
#include "gclue-location.h"
#include "public-api/gclue-enum-types.h"
#include "gclue-location-source.h"
......
......@@ -24,7 +24,7 @@
#include <string.h>
#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),
......
......@@ -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");
......
......@@ -25,7 +25,7 @@
#include <glib.h>
#include <libsoup/soup.h>
#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);
......
......@@ -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;
......
......@@ -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,
......
......@@ -24,7 +24,7 @@
#define GCLUE_SERVICE_LOCATION_H
#include <glib-object.h>
#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);
......
......@@ -26,7 +26,7 @@
#include <string.h>
#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))
......
......@@ -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)
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment