From 63754173e623857c8e45b3e59dcbbb12160d07a9 Mon Sep 17 00:00:00 2001 From: Ankit Date: Sun, 15 Mar 2015 22:38:57 +0530 Subject: [PATCH] Add GClueLocation class GClueLocation class is the subclass of GeocodeLocation. It is done for the new API, which will be added to GClueLocation. The code will be switched from GeoclueLocation to GClueLocation in the next patch. https://bugs.freedesktop.org/show_bug.cgi?id=89395 --- src/Makefile.am | 2 + src/gclue-location.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/gclue-location.h | 73 ++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100644 src/gclue-location.c create mode 100644 src/gclue-location.h diff --git a/src/Makefile.am b/src/Makefile.am index 485f989..b81c4f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -92,6 +92,8 @@ libgeoclue_la_SOURCES = \ gclue-wifi.c \ gclue-mozilla.h \ gclue-mozilla.c \ + gclue-location.h \ + gclue-location.c \ $(NULL) if BUILD_MODEM_SOURCE diff --git a/src/gclue-location.c b/src/gclue-location.c new file mode 100644 index 0000000..7f1ce2e --- /dev/null +++ b/src/gclue-location.c @@ -0,0 +1,123 @@ +/* vim: set et ts=8 sw=8: */ +/* gclue-location.c + * + * Copyright (C) 2015 Red Hat, Inc. + * Copyright (C) 2015 Ankit + * + * 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 + * + * Authors: Bastien Nocera + * Zeeshan Ali (Khattak) + * Ankit + */ + +#include "gclue-location.h" + +G_DEFINE_TYPE (GClueLocation, gclue_location, GEOCODE_TYPE_LOCATION); + +static void +gclue_location_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + default: + /* We don't have any other property... */ + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gclue_location_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + default: + /* We don't have any other property... */ + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gclue_location_finalize (GObject *glocation) +{ + G_OBJECT_CLASS (gclue_location_parent_class)->finalize (glocation); +} + +static void +gclue_location_class_init (GClueLocationClass *klass) +{ + GObjectClass *glocation_class = G_OBJECT_CLASS (klass); + + glocation_class->finalize = gclue_location_finalize; +} + +static void +gclue_location_init (GClueLocation *location) +{ + +} + +/** + * gclue_location_new: + * @latitude: a valid latitude + * @longitude: a valid longitude + * @accuracy: accuracy of location in meters + * + * Creates a new #GClueLocation object. + * + * Returns: a new #GClueLocation object. Use g_object_unref() when done. + **/ +GClueLocation * +gclue_location_new (gdouble latitude, + gdouble longitude, + gdouble accuracy) +{ + return g_object_new (GCLUE_TYPE_LOCATION, + "latitude", latitude, + "longitude", longitude, + "accuracy", accuracy, + NULL); +} + +/** + * gclue_location_new_with_description: + * @latitude: a valid latitude + * @longitude: a valid longitude + * @accuracy: accuracy of location in meters + * @description: a description for the location + * + * Creates a new #GClueLocation object. + * + * Returns: a new #GClueLocation object. Use g_object_unref() when done. + **/ +GClueLocation * +gclue_location_new_with_description (gdouble latitude, + gdouble longitude, + gdouble accuracy, + const char *description) +{ + return g_object_new (GCLUE_TYPE_LOCATION, + "latitude", latitude, + "longitude", longitude, + "accuracy", accuracy, + "description", description, + NULL); +} diff --git a/src/gclue-location.h b/src/gclue-location.h new file mode 100644 index 0000000..9f44c95 --- /dev/null +++ b/src/gclue-location.h @@ -0,0 +1,73 @@ +/* vim: set et ts=8 sw=8: */ +/* gclue-location.h + * + * Copyright (C) 2015 Red Hat, Inc. + * Copyright (C) 2015 Ankit + * + * 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 + * + * Authors: Bastien Nocera + * Zeeshan Ali (Khattak) + * Ankit + */ + +#ifndef GCLUE_LOCATION_H +#define GCLUE_LOCATION_H + +#include +#include "geocode-glib/geocode-location.h" + +G_BEGIN_DECLS + +#define GCLUE_TYPE_LOCATION (gclue_location_get_type ()) +#define GCLUE_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCLUE_TYPE_LOCATION, GClueLocation)) +#define GCLUE_IS_LOCATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCLUE_TYPE_LOCATION)) +#define GCLUE_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCLUE_TYPE_LOCATION, GClueLocationClass)) +#define GCLUE_IS_LOCATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCLUE_TYPE_LOCATION)) +#define GCLUE_LOCATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCLUE_TYPE_LOCATION, GClueLocationClass)) + +typedef struct _GClueLocation GClueLocation; +typedef struct _GClueLocationClass GClueLocationClass; + +struct _GClueLocation +{ + /* Parent instance structure */ + GeocodeLocation parent_instance; +}; + +struct _GClueLocationClass +{ + /* Parent class structure */ + GeocodeLocationClass parent_class; +}; + +/* used by GCLUE_TYPE_LOCATION */ +GType gclue_location_get_type (void); + +/* + * Method definitions. + */ + +GClueLocation *gclue_location_new (gdouble latitude, + gdouble longitude, + gdouble accuracy); + +GClueLocation *gclue_location_new_with_description + (gdouble latitude, + gdouble longitude, + gdouble accuracy, + const char *description); + +#endif /* GCLUE_LOCATION_H */ \ No newline at end of file -- 2.1.0