libmm-glib: new header file for common stuff in location reporting
This commit is contained in:
@@ -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
|
||||
|
@@ -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 \
|
||||
|
@@ -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>
|
||||
|
48
libmm-glib/mm-location-common.h
Normal file
48
libmm-glib/mm-location-common.h
Normal file
@@ -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 */
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user