Commit 9c8f3614 authored by Zeeshan Ali's avatar Zeeshan Ali

locator: Add 'accuracy-level' property

Currently locator doesn't actually makes use of it cause it only has one
source right now but later we use it to decide which sources to
initialize and which not to.
parent 196eee66
......@@ -24,6 +24,7 @@
#include "gclue-locator.h"
#include "gclue-ipclient.h"
#include "gclue-enum-types.h"
/* This class will be responsible for doing the actual geolocating. */
......@@ -38,12 +39,15 @@ struct _GClueLocatorPrivate
GCancellable *cancellable;
gulong network_changed_id;
GClueAccuracyLevel accuracy_level;
};
enum
{
PROP_0,
PROP_LOCATION,
PROP_ACCURACY_LEVEL,
LAST_PROP
};
......@@ -79,6 +83,10 @@ gclue_locator_get_property (GObject *object,
g_value_set_object (value, locator->priv->location);
break;
case PROP_ACCURACY_LEVEL:
g_value_set_enum (value, locator->priv->accuracy_level);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
......@@ -90,7 +98,16 @@ gclue_locator_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
GClueLocator *locator = GCLUE_LOCATOR (object);
switch (prop_id) {
case PROP_ACCURACY_LEVEL:
locator->priv->accuracy_level = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
......@@ -112,6 +129,16 @@ gclue_locator_class_init (GClueLocatorClass *klass)
g_object_class_install_property (object_class,
PROP_LOCATION,
gParamSpecs[PROP_LOCATION]);
gParamSpecs[PROP_ACCURACY_LEVEL] = g_param_spec_enum ("accuracy-level",
"AccuracyLevel",
"Accuracy level",
GCLUE_TYPE_ACCURACY_LEVEL,
GCLUE_ACCURACY_LEVEL_CITY,
G_PARAM_READWRITE);
g_object_class_install_property (object_class,
PROP_ACCURACY_LEVEL,
gParamSpecs[PROP_ACCURACY_LEVEL]);
}
static void
......@@ -302,3 +329,22 @@ GeocodeLocation * gclue_locator_get_location (GClueLocator *locator)
return locator->priv->location;
}
GClueAccuracyLevel
gclue_locator_get_accuracy_level (GClueLocator *locator)
{
g_return_val_if_fail (GCLUE_IS_LOCATOR (locator),
GCLUE_ACCURACY_LEVEL_COUNTRY);
return locator->priv->accuracy_level;
}
void
gclue_locator_set_accuracy_level (GClueLocator *locator,
GClueAccuracyLevel level)
{
g_return_if_fail (GCLUE_IS_LOCATOR (locator));
locator->priv->accuracy_level = level;
g_object_notify (G_OBJECT (locator), "accuracy-level");
}
......@@ -25,6 +25,7 @@
#include <gio/gio.h>
#include "geocode-location.h"
#include "gclue-enum-types.h"
G_BEGIN_DECLS
......@@ -71,6 +72,11 @@ gboolean gclue_locator_stop_finish (GClueLocator *locator,
GAsyncResult *res,
GError **error);
GeocodeLocation * gclue_locator_get_location (GClueLocator *locator);
GClueAccuracyLevel gclue_locator_get_accuracy_level
(GClueLocator *locator);
void gclue_locator_set_accuracy_level
(GClueLocator *locator,
GClueAccuracyLevel level);
G_END_DECLS
......
......@@ -25,6 +25,9 @@
#include "gclue-service-client.h"
#include "gclue-service-location.h"
#include "gclue-locator.h"
#include "gclue-enum-types.h"
#define DEFAULT_ACCURACY_LEVEL GCLUE_ACCURACY_LEVEL_CITY
static void
gclue_service_client_client_iface_init (GClueClientIface *iface);
......@@ -239,6 +242,7 @@ on_authorize_app_ready (GObject *source_object,
GError *error = NULL;
GVariant *results = NULL;
gboolean authorized = FALSE;
GClueAccuracyLevel accuracy_level;
results = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
res,
......@@ -257,6 +261,9 @@ on_authorize_app_ready (GObject *source_object,
goto error_out;
}
accuracy_level = gclue_client_get_requested_accuracy_level
(GCLUE_CLIENT (data->client));
gclue_locator_set_accuracy_level (priv->locator, accuracy_level);
priv->location_change_id =
g_signal_connect (priv->locator,
"notify::location",
......@@ -642,6 +649,8 @@ gclue_service_client_init (GClueServiceClient *client)
GClueServiceClientPrivate);
client->priv->locator = gclue_locator_new ();
gclue_client_set_requested_accuracy_level (GCLUE_CLIENT (client),
DEFAULT_ACCURACY_LEVEL);
}
GClueServiceClient *
......
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