Blame src/gclue-location-source.c

Packit Service b2c451
/* vim: set et ts=8 sw=8: */
Packit Service b2c451
/*
Packit Service b2c451
 * Copyright 2014 Red Hat, Inc.
Packit Service b2c451
 *
Packit Service b2c451
 * Geoclue is free software; you can redistribute it and/or modify it under
Packit Service b2c451
 * the terms of the GNU General Public License as published by the Free
Packit Service b2c451
 * Software Foundation; either version 2 of the License, or (at your option)
Packit Service b2c451
 * any later version.
Packit Service b2c451
 *
Packit Service b2c451
 * Geoclue is distributed in the hope that it will be useful, but WITHOUT ANY
Packit Service b2c451
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
Packit Service b2c451
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
Packit Service b2c451
 * details.
Packit Service b2c451
 *
Packit Service b2c451
 * You should have received a copy of the GNU General Public License along
Packit Service b2c451
 * with Geoclue; if not, write to the Free Software Foundation, Inc.,
Packit Service b2c451
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
Packit Service b2c451
 *
Packit Service b2c451
 * Authors: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
Packit Service b2c451
 */
Packit Service b2c451
Packit Service b2c451
#include <glib.h>
Packit Service b2c451
#include "gclue-location-source.h"
Packit Service b2c451
#include "gclue-compass.h"
Packit Service b2c451
Packit Service b2c451
/**
Packit Service b2c451
 * SECTION:gclue-location-source
Packit Service b2c451
 * @short_description: GeoIP client
Packit Service b2c451
 * @include: gclue-glib/gclue-location-source.h
Packit Service b2c451
 *
Packit Service b2c451
 * The interface all geolocation sources must implement.
Packit Service b2c451
 **/
Packit Service b2c451
Packit Service b2c451
static gboolean
Packit Service b2c451
start_source (GClueLocationSource *source);
Packit Service b2c451
static gboolean
Packit Service b2c451
stop_source (GClueLocationSource *source);
Packit Service b2c451
Packit Service b2c451
struct _GClueLocationSourcePrivate
Packit Service b2c451
{
Packit Service b2c451
        GClueLocation *location;
Packit Service b2c451
Packit Service b2c451
        guint active_counter;
Packit Service b2c451
        GClueMinUINT *time_threshold;
Packit Service b2c451
Packit Service b2c451
        GClueAccuracyLevel avail_accuracy_level;
Packit Service b2c451
Packit Service b2c451
        gboolean compute_movement;
Packit Service b2c451
        gboolean scramble_location;
Packit Service b2c451
Packit Service b2c451
        GClueCompass *compass;
Packit Service b2c451
Packit Service b2c451
        guint heading_changed_id;
Packit Service b2c451
};
Packit Service b2c451
Packit Service b2c451
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GClueLocationSource,
Packit Service b2c451
                                  gclue_location_source,
Packit Service b2c451
                                  G_TYPE_OBJECT,
Packit Service b2c451
                                  G_ADD_PRIVATE (GClueLocationSource))
Packit Service b2c451
Packit Service b2c451
enum
Packit Service b2c451
{
Packit Service b2c451
        PROP_0,
Packit Service b2c451
        PROP_LOCATION,
Packit Service b2c451
        PROP_ACTIVE,
Packit Service b2c451
        PROP_TIME_THRESHOLD,
Packit Service b2c451
        PROP_AVAILABLE_ACCURACY_LEVEL,
Packit Service b2c451
        PROP_COMPUTE_MOVEMENT,
Packit Service b2c451
        PROP_SCRAMBLE_LOCATION,
Packit Service b2c451
        LAST_PROP
Packit Service b2c451
};
Packit Service b2c451
Packit Service b2c451
static GParamSpec *gParamSpecs[LAST_PROP];
Packit Service b2c451
Packit Service b2c451
static gboolean
Packit Service b2c451
set_heading_from_compass (GClueLocationSource *source,
Packit Service b2c451
                          GClueLocation       *location)
Packit Service b2c451
{
Packit Service b2c451
        GClueLocationSourcePrivate *priv = source->priv;
Packit Service b2c451
        gdouble heading, curr_heading;
Packit Service b2c451
Packit Service b2c451
        if (priv->compass == NULL)
Packit Service b2c451
                return FALSE;
Packit Service b2c451
Packit Service b2c451
        heading = gclue_compass_get_heading (priv->compass);
Packit Service b2c451
        curr_heading = gclue_location_get_heading (location);
Packit Service b2c451
Packit Service b2c451
        if (heading == GCLUE_LOCATION_HEADING_UNKNOWN  ||
Packit Service b2c451
            heading == curr_heading)
Packit Service b2c451
                return FALSE;
Packit Service b2c451
Packit Service b2c451
        g_debug ("%s got new heading %f", G_OBJECT_TYPE_NAME (source), heading);
Packit Service b2c451
        /* We trust heading from compass more than any other source so we always
Packit Service b2c451
         * override existing heading
Packit Service b2c451
         */
Packit Service b2c451
        gclue_location_set_heading (location, heading);
Packit Service b2c451
Packit Service b2c451
        return TRUE;
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
static void
Packit Service b2c451
on_compass_heading_changed (GObject    *gobject,
Packit Service b2c451
                            GParamSpec *pspec,
Packit Service b2c451
                            gpointer    user_data)
Packit Service b2c451
{
Packit Service b2c451
        GClueLocationSource* source = GCLUE_LOCATION_SOURCE (user_data);
Packit Service b2c451
Packit Service b2c451
        if (source->priv->location == NULL)
Packit Service b2c451
                return;
Packit Service b2c451
Packit Service b2c451
        if (set_heading_from_compass (source, source->priv->location))
Packit Service b2c451
                g_object_notify (G_OBJECT (source), "location");
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
static void
Packit Service b2c451
gclue_location_source_get_property (GObject    *object,
Packit Service b2c451
                                    guint       prop_id,
Packit Service b2c451
                                    GValue     *value,
Packit Service b2c451
                                    GParamSpec *pspec)
Packit Service b2c451
{
Packit Service b2c451
        GClueLocationSource *source = GCLUE_LOCATION_SOURCE (object);
Packit Service b2c451
Packit Service b2c451
        switch (prop_id) {
Packit Service b2c451
        case PROP_LOCATION:
Packit Service b2c451
                g_value_set_object (value, source->priv->location);
Packit Service b2c451
                break;
Packit Service b2c451
Packit Service b2c451
        case PROP_ACTIVE:
Packit Service b2c451
                g_value_set_boolean (value,
Packit Service b2c451
                                     gclue_location_source_get_active (source));
Packit Service b2c451
                break;
Packit Service b2c451
Packit Service b2c451
        case PROP_TIME_THRESHOLD:
Packit Service b2c451
                g_value_set_object (value, source->priv->time_threshold);
Packit Service b2c451
                break;
Packit Service b2c451
Packit Service b2c451
        case PROP_AVAILABLE_ACCURACY_LEVEL:
Packit Service b2c451
                g_value_set_enum (value, source->priv->avail_accuracy_level);
Packit Service b2c451
                break;
Packit Service b2c451
Packit Service b2c451
        case PROP_COMPUTE_MOVEMENT:
Packit Service b2c451
                g_value_set_boolean (value, source->priv->compute_movement);
Packit Service b2c451
                break;
Packit Service b2c451
Packit Service b2c451
        case PROP_SCRAMBLE_LOCATION:
Packit Service b2c451
                g_value_set_boolean (value, source->priv->scramble_location);
Packit Service b2c451
                break;
Packit Service b2c451
Packit Service b2c451
        default:
Packit Service b2c451
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Packit Service b2c451
        }
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
static void
Packit Service b2c451
gclue_location_source_set_property (GObject      *object,
Packit Service b2c451
                                    guint         prop_id,
Packit Service b2c451
                                    const GValue *value,
Packit Service b2c451
                                    GParamSpec   *pspec)
Packit Service b2c451
{
Packit Service b2c451
        GClueLocationSource *source = GCLUE_LOCATION_SOURCE (object);
Packit Service b2c451
Packit Service b2c451
        switch (prop_id) {
Packit Service b2c451
        case PROP_LOCATION:
Packit Service b2c451
        {
Packit Service b2c451
                GClueLocation *location = g_value_get_object (value);
Packit Service b2c451
Packit Service b2c451
                gclue_location_source_set_location (source, location);
Packit Service b2c451
                break;
Packit Service b2c451
        }
Packit Service b2c451
Packit Service b2c451
        case PROP_AVAILABLE_ACCURACY_LEVEL:
Packit Service b2c451
                source->priv->avail_accuracy_level = g_value_get_enum (value);
Packit Service b2c451
                break;
Packit Service b2c451
Packit Service b2c451
        case PROP_COMPUTE_MOVEMENT:
Packit Service b2c451
                source->priv->compute_movement = g_value_get_boolean (value);
Packit Service b2c451
                break;
Packit Service b2c451
Packit Service b2c451
        case PROP_SCRAMBLE_LOCATION:
Packit Service b2c451
                source->priv->scramble_location = g_value_get_boolean (value);
Packit Service b2c451
                break;
Packit Service b2c451
Packit Service b2c451
        default:
Packit Service b2c451
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Packit Service b2c451
        }
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
static void
Packit Service b2c451
gclue_location_source_finalize (GObject *object)
Packit Service b2c451
{
Packit Service b2c451
        GClueLocationSourcePrivate *priv = GCLUE_LOCATION_SOURCE (object)->priv;
Packit Service b2c451
Packit Service b2c451
        gclue_location_source_stop (GCLUE_LOCATION_SOURCE (object));
Packit Service b2c451
        g_clear_object (&priv->location);
Packit Service b2c451
Packit Service b2c451
        G_OBJECT_CLASS (gclue_location_source_parent_class)->finalize (object);
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
static void
Packit Service b2c451
gclue_location_source_class_init (GClueLocationSourceClass *klass)
Packit Service b2c451
{
Packit Service b2c451
        GObjectClass *object_class;
Packit Service b2c451
Packit Service b2c451
        klass->start = start_source;
Packit Service b2c451
        klass->stop = stop_source;
Packit Service b2c451
Packit Service b2c451
        object_class = G_OBJECT_CLASS (klass);
Packit Service b2c451
        object_class->get_property = gclue_location_source_get_property;
Packit Service b2c451
        object_class->set_property = gclue_location_source_set_property;
Packit Service b2c451
        object_class->finalize = gclue_location_source_finalize;
Packit Service b2c451
Packit Service b2c451
        gParamSpecs[PROP_LOCATION] = g_param_spec_object ("location",
Packit Service b2c451
                                                          "Location",
Packit Service b2c451
                                                          "Location",
Packit Service b2c451
                                                          GCLUE_TYPE_LOCATION,
Packit Service b2c451
                                                          G_PARAM_READWRITE);
Packit Service b2c451
        g_object_class_install_property (object_class,
Packit Service b2c451
                                         PROP_LOCATION,
Packit Service b2c451
                                         gParamSpecs[PROP_LOCATION]);
Packit Service b2c451
Packit Service b2c451
        gParamSpecs[PROP_ACTIVE] = g_param_spec_boolean ("active",
Packit Service b2c451
                                                         "Active",
Packit Service b2c451
                                                         "Active",
Packit Service b2c451
                                                         FALSE,
Packit Service b2c451
                                                         G_PARAM_READABLE);
Packit Service b2c451
        g_object_class_install_property (object_class,
Packit Service b2c451
                                         PROP_ACTIVE,
Packit Service b2c451
                                         gParamSpecs[PROP_ACTIVE]);
Packit Service b2c451
Packit Service b2c451
        gParamSpecs[PROP_TIME_THRESHOLD] =
Packit Service b2c451
                g_param_spec_object ("time-threshold",
Packit Service b2c451
                                     "TimeThreshold",
Packit Service b2c451
                                     "TimeThreshold",
Packit Service b2c451
                                     GCLUE_TYPE_MIN_UINT,
Packit Service b2c451
                                     G_PARAM_READABLE);
Packit Service b2c451
        g_object_class_install_property (object_class,
Packit Service b2c451
                                         PROP_TIME_THRESHOLD,
Packit Service b2c451
                                         gParamSpecs[PROP_TIME_THRESHOLD]);
Packit Service b2c451
Packit Service b2c451
        gParamSpecs[PROP_AVAILABLE_ACCURACY_LEVEL] =
Packit Service b2c451
                g_param_spec_enum ("available-accuracy-level",
Packit Service b2c451
                                   "AvailableAccuracyLevel",
Packit Service b2c451
                                   "Available accuracy level",
Packit Service b2c451
                                   GCLUE_TYPE_ACCURACY_LEVEL,
Packit Service b2c451
                                   0,
Packit Service b2c451
                                   G_PARAM_READWRITE);
Packit Service b2c451
        g_object_class_install_property (object_class,
Packit Service b2c451
                                         PROP_AVAILABLE_ACCURACY_LEVEL,
Packit Service b2c451
                                         gParamSpecs[PROP_AVAILABLE_ACCURACY_LEVEL]);
Packit Service b2c451
Packit Service b2c451
        gParamSpecs[PROP_COMPUTE_MOVEMENT] =
Packit Service b2c451
                g_param_spec_boolean ("compute-movement",
Packit Service b2c451
                                      "ComputeMovement",
Packit Service b2c451
                                      "Whether or not, speed and heading should "
Packit Service b2c451
                                      "be automatically computed (or fetched "
Packit Service b2c451
                                      "from hardware) and set on new locations.",
Packit Service b2c451
                                      TRUE,
Packit Service b2c451
                                      G_PARAM_READWRITE);
Packit Service b2c451
        g_object_class_install_property (object_class,
Packit Service b2c451
                                         PROP_COMPUTE_MOVEMENT,
Packit Service b2c451
                                         gParamSpecs[PROP_COMPUTE_MOVEMENT]);
Packit Service b2c451
Packit Service b2c451
        gParamSpecs[PROP_SCRAMBLE_LOCATION] =
Packit Service b2c451
                g_param_spec_boolean ("scramble-location",
Packit Service b2c451
                                      "ScrambleLocation",
Packit Service b2c451
                                      "Enable location scrambling",
Packit Service b2c451
                                      FALSE,
Packit Service b2c451
                                      G_PARAM_READWRITE |
Packit Service b2c451
                                      G_PARAM_CONSTRUCT_ONLY);
Packit Service b2c451
        g_object_class_install_property (object_class,
Packit Service b2c451
                                         PROP_SCRAMBLE_LOCATION,
Packit Service b2c451
                                         gParamSpecs[PROP_SCRAMBLE_LOCATION]);
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
static void
Packit Service b2c451
gclue_location_source_init (GClueLocationSource *source)
Packit Service b2c451
{
Packit Service b2c451
        source->priv =
Packit Service b2c451
                G_TYPE_INSTANCE_GET_PRIVATE (source,
Packit Service b2c451
                                             GCLUE_TYPE_LOCATION_SOURCE,
Packit Service b2c451
                                             GClueLocationSourcePrivate);
Packit Service b2c451
        source->priv->compute_movement = TRUE;
Packit Service b2c451
        source->priv->time_threshold = gclue_min_uint_new ();
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
static gboolean
Packit Service b2c451
start_source (GClueLocationSource *source)
Packit Service b2c451
{
Packit Service b2c451
        source->priv->active_counter++;
Packit Service b2c451
        if (source->priv->active_counter > 1) {
Packit Service b2c451
                g_debug ("%s already active, not starting.",
Packit Service b2c451
                         G_OBJECT_TYPE_NAME (source));
Packit Service b2c451
                return FALSE;
Packit Service b2c451
        }
Packit Service b2c451
Packit Service b2c451
        if (source->priv->compute_movement) {
Packit Service b2c451
                source->priv->compass = gclue_compass_get_singleton ();
Packit Service b2c451
                source->priv->heading_changed_id = g_signal_connect
Packit Service b2c451
                        (G_OBJECT (source->priv->compass),
Packit Service b2c451
                         "notify::heading",
Packit Service b2c451
                         G_CALLBACK (on_compass_heading_changed),
Packit Service b2c451
                         source);
Packit Service b2c451
        }
Packit Service b2c451
Packit Service b2c451
        g_object_notify (G_OBJECT (source), "active");
Packit Service b2c451
        g_debug ("%s now active", G_OBJECT_TYPE_NAME (source));
Packit Service b2c451
        return TRUE;
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
static gboolean
Packit Service b2c451
stop_source (GClueLocationSource *source)
Packit Service b2c451
{
Packit Service b2c451
        if (source->priv->active_counter == 0) {
Packit Service b2c451
                g_debug ("%s already inactive, not stopping.",
Packit Service b2c451
                         G_OBJECT_TYPE_NAME (source));
Packit Service b2c451
                return FALSE;
Packit Service b2c451
        }
Packit Service b2c451
Packit Service b2c451
        source->priv->active_counter--;
Packit Service b2c451
        if (source->priv->active_counter > 0) {
Packit Service b2c451
                g_debug ("%s still in use, not stopping.",
Packit Service b2c451
                         G_OBJECT_TYPE_NAME (source));
Packit Service b2c451
                return FALSE;
Packit Service b2c451
        }
Packit Service b2c451
Packit Service b2c451
        if (source->priv->compass) {
Packit Service b2c451
                g_signal_handler_disconnect (source->priv->compass,
Packit Service b2c451
                                             source->priv->heading_changed_id);
Packit Service b2c451
                g_clear_object (&source->priv->compass);
Packit Service b2c451
        }
Packit Service b2c451
Packit Service b2c451
        g_object_notify (G_OBJECT (source), "active");
Packit Service b2c451
        g_debug ("%s now inactive", G_OBJECT_TYPE_NAME (source));
Packit Service b2c451
Packit Service b2c451
        return TRUE;
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
/**
Packit Service b2c451
 * gclue_location_source_start:
Packit Service b2c451
 * @source: a #GClueLocationSource
Packit Service b2c451
 *
Packit Service b2c451
 * Start searching for location and keep an eye on location changes.
Packit Service b2c451
 **/
Packit Service b2c451
void
Packit Service b2c451
gclue_location_source_start (GClueLocationSource *source)
Packit Service b2c451
{
Packit Service b2c451
        g_return_if_fail (GCLUE_IS_LOCATION_SOURCE (source));
Packit Service b2c451
Packit Service b2c451
        GCLUE_LOCATION_SOURCE_GET_CLASS (source)->start (source);
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
/**
Packit Service b2c451
 * gclue_location_source_stop:
Packit Service b2c451
 * @source: a #GClueLocationSource
Packit Service b2c451
 *
Packit Service b2c451
 * Stop searching for location and no need to keep an eye on location changes
Packit Service b2c451
 * anymore.
Packit Service b2c451
 **/
Packit Service b2c451
void
Packit Service b2c451
gclue_location_source_stop (GClueLocationSource *source)
Packit Service b2c451
{
Packit Service b2c451
        g_return_if_fail (GCLUE_IS_LOCATION_SOURCE (source));
Packit Service b2c451
Packit Service b2c451
        GCLUE_LOCATION_SOURCE_GET_CLASS (source)->stop (source);
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
/**
Packit Service b2c451
 * gclue_location_source_get_location:
Packit Service b2c451
 * @source: a #GClueLocationSource
Packit Service b2c451
 *
Packit Service b2c451
 * Returns: (transfer none): The location, or NULL if unknown.
Packit Service b2c451
 **/
Packit Service b2c451
GClueLocation *
Packit Service b2c451
gclue_location_source_get_location (GClueLocationSource *source)
Packit Service b2c451
{
Packit Service b2c451
        g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), NULL);
Packit Service b2c451
Packit Service b2c451
        return source->priv->location;
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
/* 1 km in latitude is always .00899928005759539236 degrees */
Packit Service b2c451
#define LATITUDE_IN_KM .00899928005759539236
Packit Service b2c451
Packit Service b2c451
/**
Packit Service b2c451
 * gclue_location_source_set_location:
Packit Service b2c451
 * @source: a #GClueLocationSource
Packit Service b2c451
 *
Packit Service b2c451
 * Set the current location to @location. Its meant to be only used by
Packit Service b2c451
 * subclasses.
Packit Service b2c451
 **/
Packit Service b2c451
void
Packit Service b2c451
gclue_location_source_set_location (GClueLocationSource *source,
Packit Service b2c451
                                    GClueLocation       *location)
Packit Service b2c451
{
Packit Service b2c451
        GClueLocationSourcePrivate *priv = source->priv;
Packit Service b2c451
        GClueLocation *cur_location;
Packit Service b2c451
        gdouble speed, heading;
Packit Service b2c451
Packit Service b2c451
        cur_location = priv->location;
Packit Service b2c451
        priv->location = gclue_location_duplicate (location);
Packit Service b2c451
Packit Service b2c451
        if (priv->scramble_location) {
Packit Service b2c451
                gdouble latitude, distance, accuracy;
Packit Service b2c451
Packit Service b2c451
                latitude = gclue_location_get_latitude (priv->location);
Packit Service b2c451
                accuracy = gclue_location_get_accuracy (priv->location);
Packit Service b2c451
Packit Service b2c451
                /* Randomization is needed to stop apps from calculationg the
Packit Service b2c451
                 * actual location.
Packit Service b2c451
                 */
Packit Service b2c451
                distance = (gdouble) g_random_int_range (1, 3);
Packit Service b2c451
Packit Service b2c451
                if (g_random_boolean ())
Packit Service b2c451
                        latitude += distance * LATITUDE_IN_KM;
Packit Service b2c451
                else
Packit Service b2c451
                        latitude -= distance * LATITUDE_IN_KM;
Packit Service b2c451
                accuracy += 3000;
Packit Service b2c451
Packit Service b2c451
                g_object_set (G_OBJECT (priv->location),
Packit Service b2c451
                              "latitude", latitude,
Packit Service b2c451
                              "accuracy", accuracy,
Packit Service b2c451
                              NULL);
Packit Service b2c451
                g_debug ("location scrambled");
Packit Service b2c451
        }
Packit Service b2c451
Packit Service b2c451
        speed = gclue_location_get_speed (location);
Packit Service b2c451
        if (speed == GCLUE_LOCATION_SPEED_UNKNOWN) {
Packit Service b2c451
                if (cur_location != NULL && priv->compute_movement) {
Packit Service b2c451
                        guint64 cur_timestamp, timestamp;
Packit Service b2c451
Packit Service b2c451
                        timestamp = gclue_location_get_timestamp (location);
Packit Service b2c451
                        cur_timestamp = gclue_location_get_timestamp
Packit Service b2c451
                                        (cur_location);
Packit Service b2c451
Packit Service b2c451
                        if (timestamp != cur_timestamp)
Packit Service b2c451
                                gclue_location_set_speed_from_prev_location
Packit Service b2c451
                                        (priv->location, cur_location);
Packit Service b2c451
                }
Packit Service b2c451
        } else {
Packit Service b2c451
                gclue_location_set_speed (priv->location, speed);
Packit Service b2c451
        }
Packit Service b2c451
Packit Service b2c451
        set_heading_from_compass (source, location);
Packit Service b2c451
        heading = gclue_location_get_heading (location);
Packit Service b2c451
        if (heading == GCLUE_LOCATION_HEADING_UNKNOWN) {
Packit Service b2c451
                if (cur_location != NULL && priv->compute_movement)
Packit Service b2c451
                        gclue_location_set_heading_from_prev_location
Packit Service b2c451
                                (priv->location, cur_location);
Packit Service b2c451
        } else {
Packit Service b2c451
                gclue_location_set_heading (priv->location, heading);
Packit Service b2c451
        }
Packit Service b2c451
Packit Service b2c451
        g_object_notify (G_OBJECT (source), "location");
Packit Service b2c451
        g_clear_object (&cur_location);
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
/**
Packit Service b2c451
 * gclue_location_source_get_active:
Packit Service b2c451
 * @source: a #GClueLocationSource
Packit Service b2c451
 *
Packit Service b2c451
 * Returns: TRUE if source is active, FALSE otherwise.
Packit Service b2c451
 **/
Packit Service b2c451
gboolean
Packit Service b2c451
gclue_location_source_get_active (GClueLocationSource *source)
Packit Service b2c451
{
Packit Service b2c451
        g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), FALSE);
Packit Service b2c451
Packit Service b2c451
        return (source->priv->active_counter > 0);
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
/**
Packit Service b2c451
 * gclue_location_source_get_available_accuracy_level:
Packit Service b2c451
 * @source: a #GClueLocationSource
Packit Service b2c451
 *
Packit Service b2c451
 * Returns: The currently available accuracy level.
Packit Service b2c451
 **/
Packit Service b2c451
GClueAccuracyLevel
Packit Service b2c451
gclue_location_source_get_available_accuracy_level (GClueLocationSource *source)
Packit Service b2c451
{
Packit Service b2c451
        g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), 0);
Packit Service b2c451
Packit Service b2c451
        return source->priv->avail_accuracy_level;
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
/**
Packit Service b2c451
 * gclue_location_source_get_compute_movement
Packit Service b2c451
 * @source: a #GClueLocationSource
Packit Service b2c451
 *
Packit Service b2c451
 * Returns: %TRUE if speed and heading will be automatically computed (or
Packit Service b2c451
 * fetched from hardware) and set on new locations, %FALSE otherwise.
Packit Service b2c451
 **/
Packit Service b2c451
gboolean
Packit Service b2c451
gclue_location_source_get_compute_movement (GClueLocationSource *source)
Packit Service b2c451
{
Packit Service b2c451
        g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), FALSE);
Packit Service b2c451
Packit Service b2c451
        return source->priv->compute_movement;
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
/**
Packit Service b2c451
 * gclue_location_source_set_compute_movement
Packit Service b2c451
 * @source: a #GClueLocationSource
Packit Service b2c451
 * @compute: a #gboolean
Packit Service b2c451
 *
Packit Service b2c451
 * Use this to specify whether or not you want @source to automatically compute
Packit Service b2c451
 * (or fetch from hardware) and set speed and heading on new locations.
Packit Service b2c451
 **/
Packit Service b2c451
void
Packit Service b2c451
gclue_location_source_set_compute_movement (GClueLocationSource *source,
Packit Service b2c451
                                            gboolean             compute)
Packit Service b2c451
{
Packit Service b2c451
        g_return_if_fail (GCLUE_IS_LOCATION_SOURCE (source));
Packit Service b2c451
Packit Service b2c451
        source->priv->compute_movement = compute;
Packit Service b2c451
}
Packit Service b2c451
Packit Service b2c451
/**
Packit Service b2c451
 * gclue_location_source_get_time_threshold
Packit Service b2c451
 * @source: a #GClueLocationSource
Packit Service b2c451
 *
Packit Service b2c451
 * Returns: (transfer none): The current time-threshold object, or NULL if
Packit Service b2c451
 * @source is not a valid #GClueLocationSource instance.
Packit Service b2c451
 **/
Packit Service b2c451
GClueMinUINT *
Packit Service b2c451
gclue_location_source_get_time_threshold (GClueLocationSource *source)
Packit Service b2c451
{
Packit Service b2c451
        g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), NULL);
Packit Service b2c451
Packit Service b2c451
        return source->priv->time_threshold;
Packit Service b2c451
}