aboutsummaryrefslogtreecommitdiff
path: root/libmm-common
diff options
context:
space:
mode:
Diffstat (limited to 'libmm-common')
-rw-r--r--libmm-common/Makefile.am8
-rw-r--r--libmm-common/libmm-common.h2
-rw-r--r--libmm-common/mm-common-location-3gpp.h68
-rw-r--r--libmm-common/mm-location-3gpp.c (renamed from libmm-common/mm-common-location-3gpp.c)96
-rw-r--r--libmm-common/mm-location-3gpp.h68
5 files changed, 130 insertions, 112 deletions
diff --git a/libmm-common/Makefile.am b/libmm-common/Makefile.am
index 56db3257..b9699726 100644
--- a/libmm-common/Makefile.am
+++ b/libmm-common/Makefile.am
@@ -154,7 +154,7 @@ mm-simple-connect-properties.c: mm-errors-types.h
mm-bearer-properties.c: mm-errors-types.h
mm-sms-properties.c: mm-errors-types.h
mm-bearer-ip-config.c: mm-errors-types.h
-mm-common-location-3gpp.c: mm-errors-types.h
+mm-location-3gpp.c: mm-errors-types.h
mm-errors-quarks.c: mm-errors-types.h
mm-unlock-retries.c: mm-enums-types.h
@@ -168,7 +168,7 @@ include_HEADERS = \
mm-bearer-properties.h \
mm-sms-properties.h \
mm-bearer-ip-config.h \
- mm-common-location-3gpp.h \
+ mm-location-3gpp.h \
mm-unlock-retries.h \
mm-gdbus-manager.h \
mm-gdbus-modem.h \
@@ -194,8 +194,8 @@ libmm_common_la_SOURCES = \
mm-sms-properties.c \
mm-bearer-ip-config.h \
mm-bearer-ip-config.c \
- mm-common-location-3gpp.h \
- mm-common-location-3gpp.c \
+ mm-location-3gpp.h \
+ mm-location-3gpp.c \
mm-unlock-retries.h \
mm-unlock-retries.c \
libmm-common.h
diff --git a/libmm-common/libmm-common.h b/libmm-common/libmm-common.h
index 04c1bfd7..743ad6ec 100644
--- a/libmm-common/libmm-common.h
+++ b/libmm-common/libmm-common.h
@@ -31,7 +31,7 @@
#include "mm-sms-properties.h"
#include "mm-bearer-properties.h"
#include "mm-bearer-ip-config.h"
-#include "mm-common-location-3gpp.h"
+#include "mm-location-3gpp.h"
#include "mm-unlock-retries.h"
#include "mm-gdbus-manager.h"
#include "mm-gdbus-modem.h"
diff --git a/libmm-common/mm-common-location-3gpp.h b/libmm-common/mm-common-location-3gpp.h
deleted file mode 100644
index 1f5c4633..00000000
--- a/libmm-common/mm-common-location-3gpp.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- 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 Google, Inc.
- */
-
-#ifndef MM_COMMON_LOCATION_3GPP_H
-#define MM_COMMON_LOCATION_3GPP_H
-
-#include <ModemManager.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define MM_TYPE_COMMON_LOCATION_3GPP (mm_common_location_3gpp_get_type ())
-#define MM_COMMON_LOCATION_3GPP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_COMMON_LOCATION_3GPP, MMCommonLocation3gpp))
-#define MM_COMMON_LOCATION_3GPP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_COMMON_LOCATION_3GPP, MMCommonLocation3gppClass))
-#define MM_IS_COMMON_LOCATION_3GPP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_COMMON_LOCATION_3GPP))
-#define MM_IS_COMMON_LOCATION_3GPP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_COMMON_LOCATION_3GPP))
-#define MM_COMMON_LOCATION_3GPP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_COMMON_LOCATION_3GPP, MMCommonLocation3gppClass))
-
-typedef struct _MMCommonLocation3gpp MMCommonLocation3gpp;
-typedef struct _MMCommonLocation3gppClass MMCommonLocation3gppClass;
-typedef struct _MMCommonLocation3gppPrivate MMCommonLocation3gppPrivate;
-
-struct _MMCommonLocation3gpp {
- GObject parent;
- MMCommonLocation3gppPrivate *priv;
-};
-
-struct _MMCommonLocation3gppClass {
- GObjectClass parent;
-};
-
-GType mm_common_location_3gpp_get_type (void);
-
-MMCommonLocation3gpp *mm_common_location_3gpp_new (void);
-MMCommonLocation3gpp *mm_common_location_3gpp_new_from_string_variant (GVariant *string,
- GError **error);
-
-gboolean mm_common_location_3gpp_set_mobile_country_code (MMCommonLocation3gpp *self,
- guint mobile_country_code);
-gboolean mm_common_location_3gpp_set_mobile_network_code (MMCommonLocation3gpp *self,
- guint mobile_network_code);
-gboolean mm_common_location_3gpp_set_location_area_code (MMCommonLocation3gpp *self,
- gulong location_area_code);
-gboolean mm_common_location_3gpp_set_cell_id (MMCommonLocation3gpp *self,
- gulong cell_id);
-
-guint mm_common_location_3gpp_get_mobile_country_code (MMCommonLocation3gpp *self);
-guint mm_common_location_3gpp_get_mobile_network_code (MMCommonLocation3gpp *self);
-gulong mm_common_location_3gpp_get_location_area_code (MMCommonLocation3gpp *self);
-gulong mm_common_location_3gpp_get_cell_id (MMCommonLocation3gpp *self);
-
-GVariant *mm_common_location_3gpp_get_string_variant (MMCommonLocation3gpp *self);
-
-G_END_DECLS
-
-#endif /* MM_COMMON_LOCATION_3GPP_H */
diff --git a/libmm-common/mm-common-location-3gpp.c b/libmm-common/mm-location-3gpp.c
index 395015b3..8ac599f4 100644
--- a/libmm-common/mm-common-location-3gpp.c
+++ b/libmm-common/mm-location-3gpp.c
@@ -19,11 +19,11 @@
#include "mm-errors-types.h"
#include "mm-common-helpers.h"
-#include "mm-common-location-3gpp.h"
+#include "mm-location-3gpp.h"
-G_DEFINE_TYPE (MMCommonLocation3gpp, mm_common_location_3gpp, G_TYPE_OBJECT);
+G_DEFINE_TYPE (MMLocation3gpp, mm_location_3gpp, G_TYPE_OBJECT);
-struct _MMCommonLocation3gppPrivate {
+struct _MMLocation3gppPrivate {
guint mobile_country_code;
guint mobile_network_code;
gulong location_area_code;
@@ -33,42 +33,43 @@ struct _MMCommonLocation3gppPrivate {
/*****************************************************************************/
guint
-mm_common_location_3gpp_get_mobile_country_code (MMCommonLocation3gpp *self)
+mm_location_3gpp_get_mobile_country_code (MMLocation3gpp *self)
{
+ g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), 0);
+
return self->priv->mobile_country_code;
}
guint
-mm_common_location_3gpp_get_mobile_network_code (MMCommonLocation3gpp *self)
+mm_location_3gpp_get_mobile_network_code (MMLocation3gpp *self)
{
+ g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), 0);
+
return self->priv->mobile_network_code;
}
gulong
-mm_common_location_3gpp_get_location_area_code (MMCommonLocation3gpp *self)
+mm_location_3gpp_get_location_area_code (MMLocation3gpp *self)
{
+ g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), 0);
+
return self->priv->location_area_code;
}
gulong
-mm_common_location_3gpp_get_cell_id (MMCommonLocation3gpp *self)
+mm_location_3gpp_get_cell_id (MMLocation3gpp *self)
{
+ g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), 0);
+
return self->priv->cell_id;
}
-/* void */
-/* mm_common_location_3gpp_clear (MMCommonLocation3gpp *self) */
-/* { */
-/* self->priv->mobile_country_code = 0; */
-/* self->priv->mobile_network_code = 0; */
-/* self->priv->location_area_code = 0; */
-/* self->priv->cell_id = 0; */
-/* } */
-
gboolean
-mm_common_location_3gpp_set_mobile_country_code (MMCommonLocation3gpp *self,
- guint mobile_country_code)
+mm_location_3gpp_set_mobile_country_code (MMLocation3gpp *self,
+ guint mobile_country_code)
{
+ g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), FALSE);
+
/* If no change in the location info, don't do anything */
if (self->priv->mobile_country_code == mobile_country_code)
return FALSE;
@@ -78,9 +79,11 @@ mm_common_location_3gpp_set_mobile_country_code (MMCommonLocation3gpp *self,
}
gboolean
-mm_common_location_3gpp_set_mobile_network_code (MMCommonLocation3gpp *self,
- guint mobile_network_code)
+mm_location_3gpp_set_mobile_network_code (MMLocation3gpp *self,
+ guint mobile_network_code)
{
+ g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), FALSE);
+
/* If no change in the location info, don't do anything */
if (self->priv->mobile_network_code == mobile_network_code)
return FALSE;
@@ -90,9 +93,11 @@ mm_common_location_3gpp_set_mobile_network_code (MMCommonLocation3gpp *self,
}
gboolean
-mm_common_location_3gpp_set_location_area_code (MMCommonLocation3gpp *self,
- gulong location_area_code)
+mm_location_3gpp_set_location_area_code (MMLocation3gpp *self,
+ gulong location_area_code)
{
+ g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), FALSE);
+
/* If no change in the location info, don't do anything */
if (self->priv->location_area_code == location_area_code)
return FALSE;
@@ -103,9 +108,11 @@ mm_common_location_3gpp_set_location_area_code (MMCommonLocation3gpp *self,
gboolean
-mm_common_location_3gpp_set_cell_id (MMCommonLocation3gpp *self,
- gulong cell_id)
+mm_location_3gpp_set_cell_id (MMLocation3gpp *self,
+ gulong cell_id)
{
+ g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), FALSE);
+
/* If no change in the location info, don't do anything */
if (self->priv->cell_id == cell_id)
return FALSE;
@@ -117,10 +124,12 @@ mm_common_location_3gpp_set_cell_id (MMCommonLocation3gpp *self,
/*****************************************************************************/
GVariant *
-mm_common_location_3gpp_get_string_variant (MMCommonLocation3gpp *self)
+mm_location_3gpp_get_string_variant (MMLocation3gpp *self)
{
GVariant *variant = NULL;
+ g_return_val_if_fail (MM_IS_LOCATION_3GPP (self), NULL);
+
if (self->priv->mobile_country_code &&
self->priv->mobile_network_code &&
self->priv->location_area_code &&
@@ -198,13 +207,22 @@ validate_numeric_string_content (const gchar *display,
return TRUE;
}
-MMCommonLocation3gpp *
-mm_common_location_3gpp_new_from_string_variant (GVariant *string,
- GError **error)
+MMLocation3gpp *
+mm_location_3gpp_new_from_string_variant (GVariant *string,
+ GError **error)
{
- MMCommonLocation3gpp *self = NULL;
+ MMLocation3gpp *self = NULL;
gchar **split;
+ if (!g_variant_is_of_type (string, G_VARIANT_TYPE_STRING)) {
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_INVALID_ARGS,
+ "Cannot create 3GPP location from string: "
+ "invalid variant type received");
+ return NULL;
+ }
+
split = g_strsplit (g_variant_get_string (string, NULL), ",", -1);
if (!split) {
g_set_error (error,
@@ -225,7 +243,7 @@ mm_common_location_3gpp_new_from_string_variant (GVariant *string,
validate_string_length ("Cell ID", split[3], 8, error) &&
validate_numeric_string_content ("Cell ID", split[3], TRUE, error)) {
/* Create new location object */
- self = mm_common_location_3gpp_new ();
+ self = mm_location_3gpp_new ();
self->priv->mobile_country_code = strtol (split[0], NULL, 10);
self->priv->mobile_network_code = strtol (split[1], NULL, 10);
self->priv->location_area_code = strtol (split[2], NULL, 16);
@@ -238,25 +256,25 @@ mm_common_location_3gpp_new_from_string_variant (GVariant *string,
/*****************************************************************************/
-MMCommonLocation3gpp *
-mm_common_location_3gpp_new (void)
+MMLocation3gpp *
+mm_location_3gpp_new (void)
{
- return (MM_COMMON_LOCATION_3GPP (
- g_object_new (MM_TYPE_COMMON_LOCATION_3GPP, NULL)));
+ return (MM_LOCATION_3GPP (
+ g_object_new (MM_TYPE_LOCATION_3GPP, NULL)));
}
static void
-mm_common_location_3gpp_init (MMCommonLocation3gpp *self)
+mm_location_3gpp_init (MMLocation3gpp *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
- MM_TYPE_COMMON_LOCATION_3GPP,
- MMCommonLocation3gppPrivate);
+ MM_TYPE_LOCATION_3GPP,
+ MMLocation3gppPrivate);
}
static void
-mm_common_location_3gpp_class_init (MMCommonLocation3gppClass *klass)
+mm_location_3gpp_class_init (MMLocation3gppClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (object_class, sizeof (MMCommonLocation3gppPrivate));
+ g_type_class_add_private (object_class, sizeof (MMLocation3gppPrivate));
}
diff --git a/libmm-common/mm-location-3gpp.h b/libmm-common/mm-location-3gpp.h
new file mode 100644
index 00000000..41469c85
--- /dev/null
+++ b/libmm-common/mm-location-3gpp.h
@@ -0,0 +1,68 @@
+/* -*- 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 Google, Inc.
+ */
+
+#ifndef MM_LOCATION_3GPP_H
+#define MM_LOCATION_3GPP_H
+
+#include <ModemManager.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define MM_TYPE_LOCATION_3GPP (mm_location_3gpp_get_type ())
+#define MM_LOCATION_3GPP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_LOCATION_3GPP, MMLocation3gpp))
+#define MM_LOCATION_3GPP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_LOCATION_3GPP, MMLocation3gppClass))
+#define MM_IS_LOCATION_3GPP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_LOCATION_3GPP))
+#define MM_IS_LOCATION_3GPP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_LOCATION_3GPP))
+#define MM_LOCATION_3GPP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_LOCATION_3GPP, MMLocation3gppClass))
+
+typedef struct _MMLocation3gpp MMLocation3gpp;
+typedef struct _MMLocation3gppClass MMLocation3gppClass;
+typedef struct _MMLocation3gppPrivate MMLocation3gppPrivate;
+
+struct _MMLocation3gpp {
+ GObject parent;
+ MMLocation3gppPrivate *priv;
+};
+
+struct _MMLocation3gppClass {
+ GObjectClass parent;
+};
+
+GType mm_location_3gpp_get_type (void);
+
+MMLocation3gpp *mm_location_3gpp_new (void);
+MMLocation3gpp *mm_location_3gpp_new_from_string_variant (GVariant *string,
+ GError **error);
+
+gboolean mm_location_3gpp_set_mobile_country_code (MMLocation3gpp *self,
+ guint mobile_country_code);
+gboolean mm_location_3gpp_set_mobile_network_code (MMLocation3gpp *self,
+ guint mobile_network_code);
+gboolean mm_location_3gpp_set_location_area_code (MMLocation3gpp *self,
+ gulong location_area_code);
+gboolean mm_location_3gpp_set_cell_id (MMLocation3gpp *self,
+ gulong cell_id);
+
+guint mm_location_3gpp_get_mobile_country_code (MMLocation3gpp *self);
+guint mm_location_3gpp_get_mobile_network_code (MMLocation3gpp *self);
+gulong mm_location_3gpp_get_location_area_code (MMLocation3gpp *self);
+gulong mm_location_3gpp_get_cell_id (MMLocation3gpp *self);
+
+GVariant *mm_location_3gpp_get_string_variant (MMLocation3gpp *self);
+
+G_END_DECLS
+
+#endif /* MM_LOCATION_3GPP_H */