summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-10-31 12:09:46 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-11-02 08:23:10 +0100
commit72068598e51a020a1f4c405c3d1650e4d2eef0a3 (patch)
tree91fe7b8630f04d6b89d3a5be187b529d1047699f
parent15f7a370d2c4adb118488287fd553c673e8142b4 (diff)
libmm-glib: new header file for common stuff in location reporting
-rw-r--r--docs/reference/libmm-glib/libmm-glib-sections.txt6
-rw-r--r--libmm-glib/Makefile.am2
-rw-r--r--libmm-glib/libmm-glib.h1
-rw-r--r--libmm-glib/mm-location-common.h48
-rw-r--r--libmm-glib/mm-location-gps-raw.c38
-rw-r--r--libmm-glib/mm-location-gps-raw.h27
6 files changed, 75 insertions, 47 deletions
diff --git a/docs/reference/libmm-glib/libmm-glib-sections.txt b/docs/reference/libmm-glib/libmm-glib-sections.txt
index f37e7a3d..1959ae4e 100644
--- a/docs/reference/libmm-glib/libmm-glib-sections.txt
+++ b/docs/reference/libmm-glib/libmm-glib-sections.txt
@@ -302,6 +302,9 @@ mm_modem_cdma_get_type
<FILE>mm-modem-location</FILE>
<TITLE>MMModemLocation</TITLE>
MMModemLocation
+MM_LOCATION_LONGITUDE_UNKNOWN
+MM_LOCATION_LATITUDE_UNKNOWN
+MM_LOCATION_ALTITUDE_UNKNOWN
<SUBSECTION Getters>
mm_modem_location_get_path
mm_modem_location_dup_path
@@ -392,9 +395,6 @@ mm_location_gps_nmea_get_type
<FILE>mm-location-gps-raw</FILE>
<TITLE>MMLocationGpsRaw</TITLE>
MMLocationGpsRaw
-MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN
-MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN
-MM_LOCATION_GPS_RAW_ALTITUDE_UNKNOWN
<SUBSECTION Getters>
mm_location_gps_raw_get_utc_time
mm_location_gps_raw_get_longitude
diff --git a/libmm-glib/Makefile.am b/libmm-glib/Makefile.am
index d2dd10b0..9d02835f 100644
--- a/libmm-glib/Makefile.am
+++ b/libmm-glib/Makefile.am
@@ -45,6 +45,7 @@ libmm_glib_la_SOURCES = \
mm-sms-properties.c \
mm-bearer-ip-config.h \
mm-bearer-ip-config.c \
+ mm-location-common.h \
mm-location-3gpp.h \
mm-location-3gpp.c \
mm-location-gps-raw.h \
@@ -93,6 +94,7 @@ include_HEADERS = \
mm-bearer-properties.h \
mm-sms-properties.h \
mm-bearer-ip-config.h \
+ mm-location-common.h \
mm-location-3gpp.h \
mm-location-gps-nmea.h \
mm-location-gps-raw.h \
diff --git a/libmm-glib/libmm-glib.h b/libmm-glib/libmm-glib.h
index 79ee3102..ab00fdd1 100644
--- a/libmm-glib/libmm-glib.h
+++ b/libmm-glib/libmm-glib.h
@@ -57,6 +57,7 @@
#include <mm-sms-properties.h>
#include <mm-bearer-properties.h>
#include <mm-bearer-ip-config.h>
+#include <mm-location-common.h>
#include <mm-location-3gpp.h>
#include <mm-location-gps-raw.h>
#include <mm-location-gps-nmea.h>
diff --git a/libmm-glib/mm-location-common.h b/libmm-glib/mm-location-common.h
new file mode 100644
index 00000000..6397dc6c
--- /dev/null
+++ b/libmm-glib/mm-location-common.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program 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.
+ *
+ * This program 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:
+ *
+ * Copyright (C) 2012 Lanedo GmbH <aleksander@lanedo.com>
+ */
+
+#ifndef MM_LOCATION_COMMON_H
+#define MM_LOCATION_COMMON_H
+
+#if !defined (__MODEM_MANAGER_H_INSIDE__)
+#error "Only <ModemManager.h> can be included directly."
+#endif
+
+/**
+ * MM_LOCATION_LONGITUDE_UNKNOWN:
+ *
+ * Identifier for an unknown longitude value.
+ *
+ * Proper longitude values fall in the [-180,180] range.
+ */
+#define MM_LOCATION_LONGITUDE_UNKNOWN G_MINDOUBLE
+
+/**
+ * MM_LOCATION_LATITUDE_UNKNOWN:
+ *
+ * Identifier for an unknown latitude value.
+ *
+ * Proper latitude values fall in the [-90,90] range.
+ */
+#define MM_LOCATION_LATITUDE_UNKNOWN G_MINDOUBLE
+
+/**
+ * MM_LOCATION_ALTITUDE_UNKNOWN:
+ *
+ * Identifier for an unknown altitude value.
+ */
+#define MM_LOCATION_ALTITUDE_UNKNOWN G_MINDOUBLE
+
+#endif /* MM_LOCATION_COMMON_H */
diff --git a/libmm-glib/mm-location-gps-raw.c b/libmm-glib/mm-location-gps-raw.c
index d6b93997..4418eff2 100644
--- a/libmm-glib/mm-location-gps-raw.c
+++ b/libmm-glib/mm-location-gps-raw.c
@@ -76,13 +76,13 @@ mm_location_gps_raw_get_utc_time (MMLocationGpsRaw *self)
*
* Gets the longitude, in the [-180,180] range.
*
- * Returns: the longitude, or %MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN if unknown.
+ * Returns: the longitude, or %MM_LOCATION_LONGITUDE_UNKNOWN if unknown.
*/
gdouble
mm_location_gps_raw_get_longitude (MMLocationGpsRaw *self)
{
g_return_val_if_fail (MM_IS_LOCATION_GPS_RAW (self),
- MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN);
+ MM_LOCATION_LONGITUDE_UNKNOWN);
return self->priv->longitude;
}
@@ -95,13 +95,13 @@ mm_location_gps_raw_get_longitude (MMLocationGpsRaw *self)
*
* Gets the latitude, in the [-90,90] range.
*
- * Returns: the latitude, or %MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN if unknown.
+ * Returns: the latitude, or %MM_LOCATION_LATITUDE_UNKNOWN if unknown.
*/
gdouble
mm_location_gps_raw_get_latitude (MMLocationGpsRaw *self)
{
g_return_val_if_fail (MM_IS_LOCATION_GPS_RAW (self),
- MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN);
+ MM_LOCATION_LATITUDE_UNKNOWN);
return self->priv->latitude;
}
@@ -114,13 +114,13 @@ mm_location_gps_raw_get_latitude (MMLocationGpsRaw *self)
*
* Gets the altitude, in the [-90,90] range.
*
- * Returns: the altitude, or %MM_LOCATION_GPS_RAW_ALTITUDE_UNKNOWN if unknown.
+ * Returns: the altitude, or %MM_LOCATION_ALTITUDE_UNKNOWN if unknown.
*/
gdouble
mm_location_gps_raw_get_altitude (MMLocationGpsRaw *self)
{
g_return_val_if_fail (MM_IS_LOCATION_GPS_RAW (self),
- MM_LOCATION_GPS_RAW_ALTITUDE_UNKNOWN);
+ MM_LOCATION_ALTITUDE_UNKNOWN);
return self->priv->altitude;
}
@@ -208,7 +208,7 @@ mm_location_gps_raw_add_trace (MMLocationGpsRaw *self,
self->priv->utc_time = g_match_info_fetch (match_info, 1);
/* Latitude */
- self->priv->latitude = MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN;
+ self->priv->latitude = MM_LOCATION_LATITUDE_UNKNOWN;
if (get_longitude_or_latitude_from_match_info (match_info, 2, &self->priv->latitude)) {
gchar *str;
@@ -220,7 +220,7 @@ mm_location_gps_raw_add_trace (MMLocationGpsRaw *self,
}
/* Longitude */
- self->priv->longitude = MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN;
+ self->priv->longitude = MM_LOCATION_LONGITUDE_UNKNOWN;
if (get_longitude_or_latitude_from_match_info (match_info, 4, &self->priv->longitude)) {
gchar *str;
@@ -232,7 +232,7 @@ mm_location_gps_raw_add_trace (MMLocationGpsRaw *self,
}
/* Altitude */
- self->priv->altitude = MM_LOCATION_GPS_RAW_ALTITUDE_UNKNOWN;
+ self->priv->altitude = MM_LOCATION_ALTITUDE_UNKNOWN;
mm_get_double_from_match_info (match_info, 9, &self->priv->altitude);
}
@@ -256,8 +256,8 @@ mm_location_gps_raw_get_dictionary (MMLocationGpsRaw *self)
/* If mandatory parameters are not found, return NULL */
if (!self->priv->utc_time ||
- self->priv->longitude == MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN ||
- self->priv->latitude == MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN)
+ self->priv->longitude == MM_LOCATION_LONGITUDE_UNKNOWN ||
+ self->priv->latitude == MM_LOCATION_LATITUDE_UNKNOWN)
return NULL;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
@@ -275,7 +275,7 @@ mm_location_gps_raw_get_dictionary (MMLocationGpsRaw *self)
g_variant_new_double (self->priv->latitude));
/* Altitude is optional */
- if (self->priv->altitude != MM_LOCATION_GPS_RAW_ALTITUDE_UNKNOWN)
+ if (self->priv->altitude != MM_LOCATION_ALTITUDE_UNKNOWN)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_ALTITUDE,
@@ -327,8 +327,8 @@ mm_location_gps_raw_new_from_dictionary (GVariant *dictionary,
/* If any of the mandatory parameters is missing, cleanup */
if (!self->priv->utc_time ||
- self->priv->longitude == MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN ||
- self->priv->latitude == MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN) {
+ self->priv->longitude == MM_LOCATION_LONGITUDE_UNKNOWN ||
+ self->priv->latitude == MM_LOCATION_LATITUDE_UNKNOWN) {
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_INVALID_ARGS,
@@ -336,8 +336,8 @@ mm_location_gps_raw_new_from_dictionary (GVariant *dictionary,
"mandatory parameters missing "
"(utc-time: %s, longitude: %s, latitude: %s)",
self->priv->utc_time ? "yes" : "missing",
- (self->priv->longitude != MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN) ? "yes" : "missing",
- (self->priv->latitude != MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN) ? "yes" : "missing");
+ (self->priv->longitude != MM_LOCATION_LONGITUDE_UNKNOWN) ? "yes" : "missing",
+ (self->priv->latitude != MM_LOCATION_LATITUDE_UNKNOWN) ? "yes" : "missing");
g_clear_object (&self);
}
@@ -361,9 +361,9 @@ mm_location_gps_raw_init (MMLocationGpsRaw *self)
MMLocationGpsRawPrivate);
self->priv->utc_time = NULL;
- self->priv->latitude = MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN;
- self->priv->longitude = MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN;
- self->priv->altitude = MM_LOCATION_GPS_RAW_ALTITUDE_UNKNOWN;
+ self->priv->latitude = MM_LOCATION_LATITUDE_UNKNOWN;
+ self->priv->longitude = MM_LOCATION_LONGITUDE_UNKNOWN;
+ self->priv->altitude = MM_LOCATION_ALTITUDE_UNKNOWN;
}
static void
diff --git a/libmm-glib/mm-location-gps-raw.h b/libmm-glib/mm-location-gps-raw.h
index 3ec0b29d..8ef3747d 100644
--- a/libmm-glib/mm-location-gps-raw.h
+++ b/libmm-glib/mm-location-gps-raw.h
@@ -23,6 +23,8 @@
#include <ModemManager.h>
#include <glib-object.h>
+#include "mm-location-common.h"
+
G_BEGIN_DECLS
#define MM_TYPE_LOCATION_GPS_RAW (mm_location_gps_raw_get_type ())
@@ -32,31 +34,6 @@ G_BEGIN_DECLS
#define MM_IS_LOCATION_GPS_RAW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_LOCATION_GPS_RAW))
#define MM_LOCATION_GPS_RAW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_LOCATION_GPS_RAW, MMLocationGpsRawClass))
-/**
- * MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN:
- *
- * Identifier for an unknown longitude value.
- *
- * Proper longitude values fall in the [-180,180] range.
- */
-#define MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN G_MINDOUBLE
-
-/**
- * MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN:
- *
- * Identifier for an unknown latitude value.
- *
- * Proper latitude values fall in the [-90,90] range.
- */
-#define MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN G_MINDOUBLE
-
-/**
- * MM_LOCATION_GPS_RAW_ALTITUDE_UNKNOWN:
- *
- * Identifier for an unknown altitude value.
- */
-#define MM_LOCATION_GPS_RAW_ALTITUDE_UNKNOWN G_MINDOUBLE
-
typedef struct _MMLocationGpsRaw MMLocationGpsRaw;
typedef struct _MMLocationGpsRawClass MMLocationGpsRawClass;
typedef struct _MMLocationGpsRawPrivate MMLocationGpsRawPrivate;