...
 
Commits (8)
......@@ -30,6 +30,7 @@
/* Commandline options */
static gint timeout = 30; /* seconds */
static GClueAccuracyLevel accuracy_level = GCLUE_ACCURACY_LEVEL_EXACT;
static gint time_threshold;
static GOptionEntry entries[] =
{
......@@ -40,6 +41,14 @@ static GOptionEntry entries[] =
&timeout,
N_("Exit after T seconds. Default: 30"),
"T" },
{ "time-threshold",
'i',
0,
G_OPTION_ARG_INT,
&time_threshold,
N_("Only report location update after T seconds. "
"Default: 0 (report new location without any delay)"),
"T" },
{ "accuracy-level",
'a',
0,
......@@ -146,6 +155,9 @@ on_simple_ready (GObject *source_object,
g_object_ref (client);
g_print ("Client object: %s\n",
g_dbus_proxy_get_object_path (G_DBUS_PROXY (client)));
if (time_threshold > 0) {
gclue_client_set_time_threshold (client, time_threshold);
}
print_location (simple);
......
......@@ -136,6 +136,8 @@ libgeoclue_internal_la_SOURCES = \
gclue-location-source.c \
gclue-locator.h \
gclue-locator.c \
gclue-min-uint.h \
gclue-min-uint.c \
gclue-service-manager.h \
gclue-service-manager.c \
gclue-service-client.h \
......
......@@ -43,6 +43,7 @@ struct _GClueLocationSourcePrivate
GClueLocation *location;
guint active_counter;
GClueMinUINT *time_threshold;
GClueAccuracyLevel avail_accuracy_level;
......@@ -58,6 +59,7 @@ enum
PROP_0,
PROP_LOCATION,
PROP_ACTIVE,
PROP_TIME_THRESHOLD,
PROP_AVAILABLE_ACCURACY_LEVEL,
PROP_COMPUTE_MOVEMENT,
LAST_PROP
......@@ -123,6 +125,10 @@ gclue_location_source_get_property (GObject *object,
gclue_location_source_get_active (source));
break;
case PROP_TIME_THRESHOLD:
g_value_set_object (value, source->priv->time_threshold);
break;
case PROP_AVAILABLE_ACCURACY_LEVEL:
g_value_set_enum (value, source->priv->avail_accuracy_level);
break;
......@@ -209,6 +215,16 @@ gclue_location_source_class_init (GClueLocationSourceClass *klass)
PROP_ACTIVE,
gParamSpecs[PROP_ACTIVE]);
gParamSpecs[PROP_TIME_THRESHOLD] =
g_param_spec_object ("time-threshold",
"TimeThreshold",
"TimeThreshold",
GCLUE_TYPE_MIN_UINT,
G_PARAM_READABLE);
g_object_class_install_property (object_class,
PROP_TIME_THRESHOLD,
gParamSpecs[PROP_TIME_THRESHOLD]);
gParamSpecs[PROP_AVAILABLE_ACCURACY_LEVEL] =
g_param_spec_enum ("available-accuracy-level",
"AvailableAccuracyLevel",
......@@ -241,6 +257,7 @@ gclue_location_source_init (GClueLocationSource *source)
GCLUE_TYPE_LOCATION_SOURCE,
GClueLocationSourcePrivate);
source->priv->compute_movement = TRUE;
source->priv->time_threshold = gclue_min_uint_new ();
}
static gboolean
......@@ -447,3 +464,18 @@ gclue_location_source_set_compute_movement (GClueLocationSource *source,
source->priv->compute_movement = compute;
}
/**
* gclue_location_source_get_time_threshold
* @source: a #GClueLocationSource
*
* Returns: (transfer none): The current time-threshold object, or NULL if
* @source is not a valid #GClueLocationSource instance.
**/
GClueMinUINT *
gclue_location_source_get_time_threshold (GClueLocationSource *source)
{
g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), NULL);
return source->priv->time_threshold;
}
......@@ -26,6 +26,7 @@
#include <gio/gio.h>
#include "gclue-enum-types.h"
#include "gclue-location.h"
#include "gclue-min-uint.h"
G_BEGIN_DECLS
......@@ -71,6 +72,9 @@ gboolean gclue_location_source_get_active
GClueAccuracyLevel
gclue_location_source_get_available_accuracy_level
(GClueLocationSource *source);
GClueMinUINT *gclue_location_source_get_time_threshold
(GClueLocationSource *source);
gboolean
gclue_location_source_get_compute_movement (GClueLocationSource *source);
void
......
......@@ -62,6 +62,8 @@ struct _GClueLocatorPrivate
GList *active_sources;
GClueAccuracyLevel accuracy_level;
guint time_threshold;
};
enum
......@@ -225,6 +227,36 @@ on_avail_accuracy_level_changed (GObject *gobject,
}
}
static void
reset_time_threshold (GClueLocator *locator,
GClueLocationSource *source,
guint value)
{
GClueMinUINT *threshold;
threshold = gclue_location_source_get_time_threshold (source);
gclue_min_uint_add_value (threshold, value, G_OBJECT (locator));
}
static void
on_time_threshold_changed (GObject *gobject,
GParamSpec *pspec,
gpointer user_data)
{
GClueMinUINT *threshold = GCLUE_MIN_UINT (gobject);
GClueLocator *locator = GCLUE_LOCATOR (user_data);
guint value = gclue_min_uint_get_value (threshold);
GList *node;
g_debug ("Locator: on_time_threshold_changed");
for (node = locator->priv->sources; node != NULL; node = node->next) {
reset_time_threshold (locator,
GCLUE_LOCATION_SOURCE (node->data),
value);
}
}
static void
gclue_locator_get_property (GObject *object,
guint prop_id,
......@@ -267,14 +299,23 @@ gclue_locator_finalize (GObject *gsource)
GClueLocator *locator = GCLUE_LOCATOR (gsource);
GClueLocatorPrivate *priv = locator->priv;
GList *node;
GClueMinUINT *threshold;
G_OBJECT_CLASS (gclue_locator_parent_class)->finalize (gsource);
for (node = locator->priv->sources; node != NULL; node = node->next)
threshold = gclue_location_source_get_time_threshold
(GCLUE_LOCATION_SOURCE (locator));
g_signal_handlers_disconnect_by_func
(G_OBJECT (threshold),
G_CALLBACK (on_time_threshold_changed),
locator);
for (node = locator->priv->sources; node != NULL; node = node->next) {
g_signal_handlers_disconnect_by_func
(G_OBJECT (node->data),
G_CALLBACK (on_avail_accuracy_level_changed),
locator);
}
for (node = locator->priv->active_sources; node != NULL; node = node->next) {
g_signal_handlers_disconnect_by_func
(G_OBJECT (node->data),
......@@ -294,6 +335,7 @@ gclue_locator_constructed (GObject *object)
GClueLocationSource *submit_source = NULL;
GClueConfig *gconfig = gclue_config_get_singleton ();
GList *node;
GClueMinUINT *threshold;
G_OBJECT_CLASS (gclue_locator_parent_class)->constructed (object);
......@@ -331,6 +373,13 @@ gclue_locator_constructed (GObject *object)
gclue_web_source_set_submit_source
(GCLUE_WEB_SOURCE (node->data), submit_source);
}
threshold = gclue_location_source_get_time_threshold
(GCLUE_LOCATION_SOURCE (locator));
g_signal_connect (G_OBJECT (threshold),
"notify::value",
G_CALLBACK (on_time_threshold_changed),
locator);
refresh_available_accuracy_level (locator);
}
......@@ -466,3 +515,45 @@ gclue_locator_get_accuracy_level (GClueLocator *locator)
return locator->priv->accuracy_level;
}
/**
* gclue_locator_get_time_threshold
* @locator: a #GClueLocator
*
* Returns: The current time-threshold in seconds.
**/
guint
gclue_locator_get_time_threshold (GClueLocator *locator)
{
GClueMinUINT *threshold;
g_return_val_if_fail (GCLUE_IS_LOCATOR (locator), 0);
threshold = gclue_location_source_get_time_threshold
(GCLUE_LOCATION_SOURCE (locator));
return gclue_min_uint_get_value (threshold);
}
/**
* gclue_locator_set_time_threshold
* @locator: a #GClueLocator
* @value: The new threshold value
*
* Sets the time-threshold to @value.
*
* Unlike other (real) location sources, Locator instances are unique for each
* client application. Which means we only need just one time-threshold value
* and hence the reason we have these getter and setters, instead of making use
* of the #GClueLocationSource:time-threshold property.
**/
void
gclue_locator_set_time_threshold (GClueLocator *locator,
guint value)
{
g_return_if_fail (GCLUE_IS_LOCATOR (locator));
reset_time_threshold (locator,
GCLUE_LOCATION_SOURCE (locator),
value);
}
......@@ -59,6 +59,9 @@ GType gclue_locator_get_type (void) G_GNUC_CONST;
GClueLocator * gclue_locator_new (GClueAccuracyLevel level);
GClueAccuracyLevel gclue_locator_get_accuracy_level (GClueLocator *locator);
guint gclue_locator_get_time_threshold (GClueLocator *locator);
void gclue_locator_set_time_threshold (GClueLocator *locator,
guint threshold);
G_END_DECLS
......
/* vim: set et ts=8 sw=8: */
/* gclue-min-uint.c
*
* Copyright (C) 2018 Collabora Ltd.
*
* Geoclue is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* Geoclue 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with Geoclue; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
*/
#include "gclue-min-uint.h"
/**
* SECTION:gclue-min-uint
* @short_description: Easy way to keep track of minimum of a bunch of values
* @include: gclue-glib/gclue-location-source.h
*
* This is a helper class that keeps a list of guint values and the minimum
* value from this list. It is used by location sources to use the minimum
* time-threshold (location update rate) from all the time-thresholds requested
* by different applications.
**/
G_DEFINE_TYPE (GClueMinUINT, gclue_min_uint, G_TYPE_OBJECT)
struct _GClueMinUINTPrivate
{
GHashTable *all_values;
gboolean notify_value;
};
enum
{
PROP_0,
PROP_VALUE,
LAST_PROP
};
static GParamSpec *gParamSpecs[LAST_PROP];
typedef struct
{
GClueMinUINT *muint;
GObject *owner;
} OwnerData;
static gboolean
on_owner_weak_ref_notify_defered (OwnerData *data)
{
gclue_min_uint_drop_value (data->muint, data->owner);
g_object_unref (data->muint);
g_slice_free (OwnerData, data);
return FALSE;
}
static void
on_owner_weak_ref_notify (gpointer data, GObject *object)
{
OwnerData *owner_data = g_slice_new (OwnerData);
owner_data->muint = GCLUE_MIN_UINT (data);
g_object_ref (owner_data->muint);
owner_data->owner = object;
// Let's ensure owner is really gone before we drop its value
g_idle_add ((GSourceFunc) on_owner_weak_ref_notify_defered, owner_data);
}
static void
gclue_min_uint_finalize (GObject *object)
{
g_clear_pointer (&GCLUE_MIN_UINT (object)->priv->all_values,
g_hash_table_unref);
/* Chain up to the parent class */
G_OBJECT_CLASS (gclue_min_uint_parent_class)->finalize (object);
}
static void
gclue_min_uint_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GClueMinUINT *muint = GCLUE_MIN_UINT (object);
switch (prop_id) {
case PROP_VALUE:
g_value_set_uint (value, gclue_min_uint_get_value (muint));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gclue_min_uint_class_init (GClueMinUINTClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gclue_min_uint_finalize;
object_class->get_property = gclue_min_uint_get_property;
g_type_class_add_private (object_class, sizeof (GClueMinUINTPrivate));
gParamSpecs[PROP_VALUE] = g_param_spec_uint ("value",
"Value",
"The mininum value",
0,
G_MAXINT,
0,
G_PARAM_READABLE);
g_object_class_install_property (object_class,
PROP_VALUE,
gParamSpecs[PROP_VALUE]);
}
static void
gclue_min_uint_init (GClueMinUINT *muint)
{
muint->priv = G_TYPE_INSTANCE_GET_PRIVATE (muint,
GCLUE_TYPE_MIN_UINT,
GClueMinUINTPrivate);
muint->priv->all_values = g_hash_table_new (g_direct_hash,
g_direct_equal);
muint->priv->notify_value = TRUE;
}
/**
* gclue_min_uint_new
*
* Returns: A new #GClueMinUINT instance.
**/
GClueMinUINT *
gclue_min_uint_new (void)
{
return g_object_new (GCLUE_TYPE_MIN_UINT, NULL);
}
/**
* gclue_min_uint_get_value
* @muint: a #GClueMinUINT
*
* Returns: The current mininum value from the list.
**/
guint
gclue_min_uint_get_value (GClueMinUINT *muint)
{
guint value;
GList *values, *l;
g_return_val_if_fail (GCLUE_IS_MIN_UINT(muint), 0);
if (g_hash_table_size (muint->priv->all_values) == 0)
return 0;
values = g_hash_table_get_values (muint->priv->all_values);
value = GPOINTER_TO_UINT (values->data);
for (l = values->next; l; l = l->next) {
guint i = GPOINTER_TO_UINT (l->data);
if (value > i) {
value = i;
}
}
return value;
}
/**
* gclue_min_uint_add_value
* @muint: a #GClueMinUINT
* @value: A value to add to the list
* @owner: the object adding this value
*
* If @owner has already added a value previously, this call will simply replace
* that. i-e Each object can only add one value at a time.
**/
void
gclue_min_uint_add_value (GClueMinUINT *muint,
guint value,
GObject *owner)
{
guint new_value;
g_return_if_fail (GCLUE_IS_MIN_UINT(muint));
g_hash_table_replace (muint->priv->all_values,
owner,
GUINT_TO_POINTER (value));
g_object_weak_ref (owner, on_owner_weak_ref_notify, muint);
new_value = gclue_min_uint_get_value (muint);
g_debug ("%s: Added %u for %s. New minimum value: %u",
G_OBJECT_TYPE_NAME (muint),
value,
G_OBJECT_TYPE_NAME (owner),
new_value);
g_object_notify_by_pspec (G_OBJECT (muint), gParamSpecs[PROP_VALUE]);
}
/**
* gclue_min_uint_drop_value
* @muint: a #GClueMinUINT
* @owner: the object that adadded a value previously
**/
void
gclue_min_uint_drop_value (GClueMinUINT *muint,
GObject *owner)
{
gpointer hash_value;
guint new_value;
g_return_if_fail (GCLUE_IS_MIN_UINT(muint));
if (!g_hash_table_lookup_extended (muint->priv->all_values,
owner,
NULL,
&hash_value)) {
return;
}
g_hash_table_remove (muint->priv->all_values, owner);
new_value = gclue_min_uint_get_value (muint);
g_debug ("%s: Dropped %u. New minimum value: %u",
G_OBJECT_TYPE_NAME (muint),
GPOINTER_TO_INT (hash_value),
new_value);
g_object_notify_by_pspec (G_OBJECT (muint), gParamSpecs[PROP_VALUE]);
}
/* vim: set et ts=8 sw=8: */
/* gclue-service-client.h
*
* Copyright (C) 2018 Collabora Ltd.
*
* Geoclue is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* Geoclue 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with Geoclue; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
*/
#ifndef GCLUE_MIN_UINT_H
#define GCLUE_MIN_UINT_H
#include <glib-object.h>
G_BEGIN_DECLS
#define GCLUE_TYPE_MIN_UINT (gclue_min_uint_get_type())
#define GCLUE_MIN_UINT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCLUE_TYPE_MIN_UINT, GClueMinUINT))
#define GCLUE_MIN_UINT_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCLUE_TYPE_MIN_UINT, GClueMinUINT const))
#define GCLUE_MIN_UINT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCLUE_TYPE_MIN_UINT, GClueMinUINTClass))
#define GCLUE_IS_MIN_UINT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCLUE_TYPE_MIN_UINT))
#define GCLUE_IS_MIN_UINT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCLUE_TYPE_MIN_UINT))
#define GCLUE_MIN_UINT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCLUE_TYPE_MIN_UINT, GClueMinUINTClass))
typedef struct _GClueMinUINT GClueMinUINT;
typedef struct _GClueMinUINTClass GClueMinUINTClass;
typedef struct _GClueMinUINTPrivate GClueMinUINTPrivate;
struct _GClueMinUINT
{
GObject parent;
/*< private >*/
GClueMinUINTPrivate *priv;
};
struct _GClueMinUINTClass
{
GObjectClass parent_class;
};
GType gclue_min_uint_get_type (void) G_GNUC_CONST;
GClueMinUINT * gclue_min_uint_new (void);
guint gclue_min_uint_get_value (GClueMinUINT *muint);
void gclue_min_uint_add_value (GClueMinUINT *muint,
guint value,
GObject *owner);
void gclue_min_uint_drop_value (GClueMinUINT *muint,
GObject *owner);
G_END_DECLS
#endif /* GCLUE_MIN_UINT_H */
......@@ -106,6 +106,18 @@ on_is_gps_available_notify (GObject *gobject,
source);
}
static void
on_time_threshold_changed (GObject *gobject,
GParamSpec *pspec,
gpointer user_data)
{
GClueModemGPS *source = GCLUE_MODEM_GPS (user_data);
guint threshold;
threshold = gclue_min_uint_get_value (GCLUE_MIN_UINT (gobject));
gclue_modem_set_time_threshold (source->priv->modem, threshold);
}
static void
gclue_modem_gps_finalize (GObject *ggps)
{
......@@ -140,6 +152,7 @@ static void
gclue_modem_gps_init (GClueModemGPS *source)
{
GClueModemGPSPrivate *priv;
GClueMinUINT *threshold;
source->priv = G_TYPE_INSTANCE_GET_PRIVATE ((source), GCLUE_TYPE_MODEM_GPS, GClueModemGPSPrivate);
priv = source->priv;
......@@ -152,6 +165,12 @@ gclue_modem_gps_init (GClueModemGPS *source)
"notify::is-gps-available",
G_CALLBACK (on_is_gps_available_notify),
source);
threshold = gclue_location_source_get_time_threshold
(GCLUE_LOCATION_SOURCE (source));
g_signal_connect (threshold,
"notify::value",
G_CALLBACK (on_time_threshold_changed),
source);
}
static void
......
......@@ -52,6 +52,8 @@ struct _GClueModemManagerPrivate {
GCancellable *cancellable;
MMModemLocationSource caps; /* Caps we set or are going to set */
guint time_threshold;
};
enum
......@@ -60,6 +62,7 @@ enum
PROP_IS_3G_AVAILABLE,
PROP_IS_CDMA_AVAILABLE,
PROP_IS_GPS_AVAILABLE,
PROP_TIME_THRESHOLD,
LAST_PROP
};
......@@ -80,6 +83,11 @@ static gboolean
gclue_modem_manager_get_is_cdma_available (GClueModem *modem);
static gboolean
gclue_modem_manager_get_is_gps_available (GClueModem *modem);
static guint
gclue_modem_manager_get_time_threshold (GClueModem *modem);
static void
gclue_modem_manager_set_time_threshold (GClueModem *modem,
guint time_threshold);
static void
gclue_modem_manager_enable_3g (GClueModem *modem,
GCancellable *cancellable,
......@@ -160,6 +168,30 @@ gclue_modem_manager_get_property (GObject *object,
gclue_modem_get_is_gps_available (modem));
break;
case PROP_TIME_THRESHOLD:
g_value_set_uint (value,
gclue_modem_get_time_threshold (modem));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gclue_modem_manager_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GClueModem *modem = GCLUE_MODEM (object);
switch (prop_id) {
case PROP_TIME_THRESHOLD:
gclue_modem_set_time_threshold (modem,
g_value_get_uint (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
......@@ -174,6 +206,7 @@ gclue_modem_manager_class_init (GClueModemManagerClass *klass)
GObjectClass *gmodem_class = G_OBJECT_CLASS (klass);
gmodem_class->get_property = gclue_modem_manager_get_property;
gmodem_class->set_property = gclue_modem_manager_set_property;
gmodem_class->finalize = gclue_modem_manager_finalize;
gmodem_class->constructed = gclue_modem_manager_constructed;
......@@ -197,6 +230,12 @@ gclue_modem_manager_class_init (GClueModemManagerClass *klass)
gParamSpecs[PROP_IS_GPS_AVAILABLE] =
g_object_class_find_property (gmodem_class,
"is-gps-available");
g_object_class_override_property (gmodem_class,
PROP_TIME_THRESHOLD,
"time-threshold");
gParamSpecs[PROP_TIME_THRESHOLD] =
g_object_class_find_property (gmodem_class,
"time-threshold");
signals[FIX_3G] = g_signal_lookup ("fix-3g", GCLUE_TYPE_MODEM);
signals[FIX_CDMA] = g_signal_lookup ("fix-cdma", GCLUE_TYPE_MODEM);
......@@ -209,6 +248,8 @@ gclue_modem_interface_init (GClueModemInterface *iface)
iface->get_is_3g_available = gclue_modem_manager_get_is_3g_available;
iface->get_is_cdma_available = gclue_modem_manager_get_is_cdma_available;
iface->get_is_gps_available = gclue_modem_manager_get_is_gps_available;
iface->get_time_threshold = gclue_modem_manager_get_time_threshold;
iface->set_time_threshold = gclue_modem_manager_set_time_threshold;
iface->enable_3g = gclue_modem_manager_enable_3g;
iface->enable_3g_finish = gclue_modem_manager_enable_3g_finish;
iface->enable_cdma = gclue_modem_manager_enable_cdma;
......@@ -279,7 +320,7 @@ on_get_3gpp_ready (GObject *source_object,
cell_id = mm_location_3gpp_get_cell_id (location_3gpp);
if (is_location_3gpp_same (manager, mcc, mnc, lac, cell_id)) {
g_debug ("New 3GPP location is same as last one");
//g_debug ("New 3GPP location is same as last one");
return;
}
g_clear_object (&priv->location_3gpp);
......@@ -368,13 +409,13 @@ on_get_gps_nmea_ready (GObject *source_object,
}
if (is_location_gga_same (manager, gga)) {
g_debug ("New GGA trace is same as last one: %s", gga);
//g_debug ("New GGA trace is same as last one: %s", gga);
return;
}
g_clear_object (&priv->location_nmea);
priv->location_nmea = location_nmea;
g_debug ("New GPGGA trace: %s", gga);
//g_debug ("New GPGGA trace: %s", gga);
g_signal_emit (manager, signals[FIX_GPS], 0, gga);
}
......@@ -600,11 +641,15 @@ on_mm_object_added (GDBusObjectManager *object_manager,
manager->priv->modem = mm_modem;
manager->priv->modem_location = mm_object_get_modem_location (mm_object);
mm_modem_location_set_gps_refresh_rate (manager->priv->modem_location,
0,
manager->priv->cancellable,
on_gps_refresh_rate_set,
user_data);
g_debug ("Setting GPS refresh rate to %u on Modem '%s'",
manager->priv->time_threshold,
mm_object_get_path (mm_object));
mm_modem_location_set_gps_refresh_rate
(manager->priv->modem_location,
manager->priv->time_threshold,
manager->priv->cancellable,
on_gps_refresh_rate_set,
NULL);
g_signal_connect (G_OBJECT (manager->priv->modem_location),
"notify::location",
......@@ -721,6 +766,7 @@ gclue_modem_manager_constructed (GObject *object)
priv->cancellable,
on_bus_get_ready,
object);
}
static void
......@@ -790,6 +836,41 @@ gclue_modem_manager_get_is_gps_available (GClueModem *modem)
MM_MODEM_LOCATION_SOURCE_GPS_NMEA);
}
static guint
gclue_modem_manager_get_time_threshold (GClueModem *modem)
{
g_return_val_if_fail (GCLUE_IS_MODEM_MANAGER (modem), 0);
return GCLUE_MODEM_MANAGER (modem)->priv->time_threshold;
}
static void
gclue_modem_manager_set_time_threshold (GClueModem *modem,
guint time_threshold)
{
GClueModemManager *manager;
g_return_if_fail (GCLUE_IS_MODEM_MANAGER (modem));
manager = GCLUE_MODEM_MANAGER (modem);
manager->priv->time_threshold = time_threshold;
if (manager->priv->modem_location != NULL) {
mm_modem_location_set_gps_refresh_rate
(manager->priv->modem_location,
time_threshold,
manager->priv->cancellable,
on_gps_refresh_rate_set,
NULL);
}
g_object_notify_by_pspec (G_OBJECT (manager),
gParamSpecs[PROP_TIME_THRESHOLD]);
g_debug ("%s: New time-threshold: %u",
G_OBJECT_TYPE_NAME (manager),
time_threshold);
}
static void
gclue_modem_manager_enable_3g (GClueModem *modem,
GCancellable *cancellable,
......
......@@ -63,6 +63,15 @@ gclue_modem_default_init (GClueModemInterface *iface)
G_PARAM_READABLE);
g_object_interface_install_property (iface, spec);
spec = g_param_spec_uint ("time-threshold",
"TimeThreshold",
"Time Threshold",
0,
G_MAXUINT,
0,
G_PARAM_READWRITE);
g_object_interface_install_property (iface, spec);
g_signal_new ("fix-3g",
GCLUE_TYPE_MODEM,
G_SIGNAL_RUN_LAST,
......@@ -125,6 +134,24 @@ gclue_modem_get_is_gps_available (GClueModem *modem)
return GCLUE_MODEM_GET_INTERFACE (modem)->get_is_gps_available (modem);
}
guint
gclue_modem_get_time_threshold (GClueModem *modem)
{
g_return_val_if_fail (GCLUE_IS_MODEM (modem), 0);
return GCLUE_MODEM_GET_INTERFACE (modem)->get_time_threshold (modem);
}
void
gclue_modem_set_time_threshold (GClueModem *modem,
guint threshold)
{
g_return_if_fail (GCLUE_IS_MODEM (modem));
return GCLUE_MODEM_GET_INTERFACE (modem)->set_time_threshold
(modem, threshold);
}
void
gclue_modem_enable_3g (GClueModem *modem,
GCancellable *cancellable,
......
......@@ -47,6 +47,9 @@ struct _GClueModemInterface {
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
guint (*get_time_threshold) (GClueModem *modem);
void (*set_time_threshold) (GClueModem *modem,
guint threshold);
gboolean (*enable_3g_finish) (GClueModem *modem,
GAsyncResult *result,
GError **error);
......@@ -82,6 +85,9 @@ void gclue_modem_enable_3g (GClueModem *modem,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
guint gclue_modem_get_time_threshold (GClueModem *modem);
void gclue_modem_set_time_threshold (GClueModem *modem,
guint threshold);
gboolean gclue_modem_enable_3g_finish (GClueModem *modem,
GAsyncResult *result,
GError **error);
......
......@@ -258,6 +258,7 @@ start_client (GClueServiceClient *client, GClueAccuracyLevel accuracy_level)
gclue_dbus_client_set_active (GCLUE_DBUS_CLIENT (client), TRUE);
priv->locator = gclue_locator_new (accuracy_level);
gclue_locator_set_time_threshold (priv->locator, 0);
g_signal_connect (priv->locator,
"notify::location",
G_CALLBACK (on_locator_location_changed),
......@@ -702,7 +703,11 @@ gclue_service_client_handle_set_property (GDBusConnection *connection,
} else if (ret && strcmp (property_name, "TimeThreshold") == 0) {
priv->time_threshold = gclue_dbus_client_get_time_threshold
(client);
g_debug ("New time threshold: %u", priv->time_threshold);
gclue_locator_set_time_threshold (priv->locator,
priv->time_threshold);
g_debug ("%s: New time-threshold: %u",
G_OBJECT_TYPE_NAME (client),
priv->time_threshold);
}
return ret;
......