libmm-common: `MMSimpleConnectProperties' won't be considered internal any more

Renamed `MMCommonConnectProperties' to `MMSimpleConnectProperties', and removed
the `MMModemSimpleConnectProperties' provided in libmm-glib. We'll just use the
original one from libmm-common always.
This commit is contained in:
Aleksander Morgado
2012-03-01 12:31:17 +01:00
parent d306bb082f
commit 1385eb394f
12 changed files with 230 additions and 396 deletions

View File

@@ -316,11 +316,11 @@ get_modem_ready (GObject *source,
/* Request to connect the modem? */
if (connect_str) {
GError *error = NULL;
MMModemSimpleConnectProperties *properties;
MMSimpleConnectProperties *properties;
g_debug ("Asynchronously connecting the modem...");
properties = mm_modem_simple_connect_properties_new_from_string (connect_str, &error);
properties = mm_simple_connect_properties_new_from_string (connect_str, &error);
if (!properties) {
g_printerr ("Error parsing connect string: '%s'\n", error->message);
exit (EXIT_FAILURE);

View File

@@ -150,7 +150,7 @@ $(mm_gdbus_bearer_generated): $(top_srcdir)/introspection/org.freedesktop.ModemM
# Additional dependency rules
mm-common-helpers.c: mm-errors-types.h mm-enums-types.h
mm-common-simple-properties.c: mm-errors-types.h mm-enums-types.h
mm-common-connect-properties.c: mm-errors-types.h
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
@@ -164,7 +164,7 @@ include_HEADERS = \
mm-enums-types.h \
mm-common-helpers.h \
mm-common-simple-properties.h \
mm-common-connect-properties.h \
mm-simple-connect-properties.h \
mm-bearer-properties.h \
mm-sms-properties.h \
mm-bearer-ip-config.h \
@@ -186,8 +186,8 @@ libmm_common_la_SOURCES = \
mm-common-helpers.c \
mm-common-simple-properties.h \
mm-common-simple-properties.c \
mm-common-connect-properties.h \
mm-common-connect-properties.c \
mm-simple-connect-properties.h \
mm-simple-connect-properties.c \
mm-bearer-properties.h \
mm-bearer-properties.c \
mm-sms-properties.h \

View File

@@ -27,7 +27,7 @@
#include "mm-enums-types.h"
#include "mm-common-helpers.h"
#include "mm-common-simple-properties.h"
#include "mm-common-connect-properties.h"
#include "mm-simple-connect-properties.h"
#include "mm-sms-properties.h"
#include "mm-bearer-properties.h"
#include "mm-bearer-ip-config.h"

View File

@@ -1,121 +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) 2011 Aleksander Morgado <aleksander@gnu.org>
*/
#ifndef MM_COMMON_CONNECT_PROPERTIES_H
#define MM_COMMON_CONNECT_PROPERTIES_H
#include <ModemManager.h>
#include <glib-object.h>
#include "mm-bearer-properties.h"
G_BEGIN_DECLS
#define MM_TYPE_COMMON_CONNECT_PROPERTIES (mm_common_connect_properties_get_type ())
#define MM_COMMON_CONNECT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_COMMON_CONNECT_PROPERTIES, MMCommonConnectProperties))
#define MM_COMMON_CONNECT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_COMMON_CONNECT_PROPERTIES, MMCommonConnectPropertiesClass))
#define MM_IS_COMMON_CONNECT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_COMMON_CONNECT_PROPERTIES))
#define MM_IS_COMMON_CONNECT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_COMMON_CONNECT_PROPERTIES))
#define MM_COMMON_CONNECT_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_COMMON_CONNECT_PROPERTIES, MMCommonConnectPropertiesClass))
typedef struct _MMCommonConnectProperties MMCommonConnectProperties;
typedef struct _MMCommonConnectPropertiesClass MMCommonConnectPropertiesClass;
typedef struct _MMCommonConnectPropertiesPrivate MMCommonConnectPropertiesPrivate;
struct _MMCommonConnectProperties {
GObject parent;
MMCommonConnectPropertiesPrivate *priv;
};
struct _MMCommonConnectPropertiesClass {
GObjectClass parent;
};
GType mm_common_connect_properties_get_type (void);
MMCommonConnectProperties *mm_common_connect_properties_new (void);
MMCommonConnectProperties *mm_common_connect_properties_new_from_string (
const gchar *str,
GError **error);
MMCommonConnectProperties *mm_common_connect_properties_new_from_dictionary (
GVariant *dictionary,
GError **error);
void mm_common_connect_properties_set_pin (
MMCommonConnectProperties *properties,
const gchar *pin);
void mm_common_connect_properties_set_operator_id (
MMCommonConnectProperties *properties,
const gchar *operator_id);
void mm_common_connect_properties_set_bands (
MMCommonConnectProperties *properties,
const MMModemBand *bands,
guint n_bands);
void mm_common_connect_properties_set_allowed_modes (
MMCommonConnectProperties *properties,
MMModemMode allowed,
MMModemMode preferred);
void mm_common_connect_properties_set_apn (
MMCommonConnectProperties *properties,
const gchar *apn);
void mm_common_connect_properties_set_user (
MMCommonConnectProperties *properties,
const gchar *user);
void mm_common_connect_properties_set_password (
MMCommonConnectProperties *properties,
const gchar *password);
void mm_common_connect_properties_set_ip_type (
MMCommonConnectProperties *properties,
const gchar *ip_type);
void mm_common_connect_properties_set_allow_roaming (
MMCommonConnectProperties *properties,
gboolean allow_roaming);
void mm_common_connect_properties_set_number (
MMCommonConnectProperties *properties,
const gchar *number);
const gchar *mm_common_connect_properties_get_pin (
MMCommonConnectProperties *properties);
const gchar *mm_common_connect_properties_get_operator_id (
MMCommonConnectProperties *properties);
void mm_common_connect_properties_get_bands (
MMCommonConnectProperties *properties,
const MMModemBand **bands,
guint *n_bands);
void mm_common_connect_properties_get_allowed_modes (
MMCommonConnectProperties *properties,
MMModemMode *allowed,
MMModemMode *preferred);
const gchar *mm_common_connect_properties_get_apn (
MMCommonConnectProperties *properties);
const gchar *mm_common_connect_properties_get_user (
MMCommonConnectProperties *properties);
const gchar *mm_common_connect_properties_get_password (
MMCommonConnectProperties *properties);
const gchar *mm_common_connect_properties_get_ip_type (
MMCommonConnectProperties *properties);
gboolean mm_common_connect_properties_get_allow_roaming (
MMCommonConnectProperties *properties);
const gchar *mm_common_connect_properties_get_number (
MMCommonConnectProperties *properties);
MMBearerProperties *mm_common_connect_properties_get_bearer_properties (
MMCommonConnectProperties *properties);
GVariant *mm_common_connect_properties_get_dictionary (MMCommonConnectProperties *self);
G_END_DECLS
#endif /* MM_COMMON_CONNECT_PROPERTIES_H */

View File

@@ -17,9 +17,9 @@
#include "mm-errors-types.h"
#include "mm-common-helpers.h"
#include "mm-common-connect-properties.h"
#include "mm-simple-connect-properties.h"
G_DEFINE_TYPE (MMCommonConnectProperties, mm_common_connect_properties, G_TYPE_OBJECT);
G_DEFINE_TYPE (MMSimpleConnectProperties, mm_simple_connect_properties, G_TYPE_OBJECT);
#define PROPERTY_PIN "pin"
#define PROPERTY_OPERATOR_ID "operator-id"
@@ -27,7 +27,7 @@ G_DEFINE_TYPE (MMCommonConnectProperties, mm_common_connect_properties, G_TYPE_O
#define PROPERTY_ALLOWED_MODES "allowed-modes"
#define PROPERTY_PREFERRED_MODE "preferred-mode"
struct _MMCommonConnectPropertiesPrivate {
struct _MMSimpleConnectPropertiesPrivate {
/* PIN */
gchar *pin;
/* Operator ID */
@@ -46,26 +46,32 @@ struct _MMCommonConnectPropertiesPrivate {
/*****************************************************************************/
void
mm_common_connect_properties_set_pin (MMCommonConnectProperties *self,
mm_simple_connect_properties_set_pin (MMSimpleConnectProperties *self,
const gchar *pin)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
g_free (self->priv->pin);
self->priv->pin = g_strdup (pin);
}
void
mm_common_connect_properties_set_operator_id (MMCommonConnectProperties *self,
mm_simple_connect_properties_set_operator_id (MMSimpleConnectProperties *self,
const gchar *operator_id)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
g_free (self->priv->operator_id);
self->priv->operator_id = g_strdup (operator_id);
}
void
mm_common_connect_properties_set_bands (MMCommonConnectProperties *self,
mm_simple_connect_properties_set_bands (MMSimpleConnectProperties *self,
const MMModemBand *bands,
guint n_bands)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
g_free (self->priv->bands);
self->priv->n_bands = n_bands;
self->priv->bands = g_new (MMModemBand, self->priv->n_bands);
@@ -75,59 +81,73 @@ mm_common_connect_properties_set_bands (MMCommonConnectProperties *self,
}
void
mm_common_connect_properties_set_allowed_modes (MMCommonConnectProperties *self,
mm_simple_connect_properties_set_allowed_modes (MMSimpleConnectProperties *self,
MMModemMode allowed,
MMModemMode preferred)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
self->priv->allowed_modes = allowed;
self->priv->preferred_mode = preferred;
self->priv->allowed_modes_set = TRUE;
}
void
mm_common_connect_properties_set_apn (MMCommonConnectProperties *self,
mm_simple_connect_properties_set_apn (MMSimpleConnectProperties *self,
const gchar *apn)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
mm_bearer_properties_set_apn (self->priv->bearer_properties,
apn);
}
void
mm_common_connect_properties_set_user (MMCommonConnectProperties *self,
mm_simple_connect_properties_set_user (MMSimpleConnectProperties *self,
const gchar *user)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
mm_bearer_properties_set_user (self->priv->bearer_properties,
user);
}
void
mm_common_connect_properties_set_password (MMCommonConnectProperties *self,
mm_simple_connect_properties_set_password (MMSimpleConnectProperties *self,
const gchar *password)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
mm_bearer_properties_set_password (self->priv->bearer_properties,
password);
}
void
mm_common_connect_properties_set_ip_type (MMCommonConnectProperties *self,
mm_simple_connect_properties_set_ip_type (MMSimpleConnectProperties *self,
const gchar *ip_type)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
mm_bearer_properties_set_ip_type (self->priv->bearer_properties,
ip_type);
}
void
mm_common_connect_properties_set_allow_roaming (MMCommonConnectProperties *self,
mm_simple_connect_properties_set_allow_roaming (MMSimpleConnectProperties *self,
gboolean allow_roaming)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
mm_bearer_properties_set_allow_roaming (self->priv->bearer_properties,
allow_roaming);
}
void
mm_common_connect_properties_set_number (MMCommonConnectProperties *self,
mm_simple_connect_properties_set_number (MMSimpleConnectProperties *self,
const gchar *number)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
mm_bearer_properties_set_number (self->priv->bearer_properties,
number);
}
@@ -135,81 +155,107 @@ mm_common_connect_properties_set_number (MMCommonConnectProperties *self,
/*****************************************************************************/
MMBearerProperties *
mm_common_connect_properties_get_bearer_properties (MMCommonConnectProperties *self)
mm_simple_connect_properties_get_bearer_properties (MMSimpleConnectProperties *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL);
return g_object_ref (self->priv->bearer_properties);
}
const gchar *
mm_common_connect_properties_get_pin (MMCommonConnectProperties *self)
mm_simple_connect_properties_get_pin (MMSimpleConnectProperties *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL);
return self->priv->pin;
}
const gchar *
mm_common_connect_properties_get_operator_id (MMCommonConnectProperties *self)
mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL);
return self->priv->operator_id;
}
void
mm_common_connect_properties_get_bands (MMCommonConnectProperties *self,
mm_simple_connect_properties_get_bands (MMSimpleConnectProperties *self,
const MMModemBand **bands,
guint *n_bands)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
g_return_if_fail (bands != NULL);
g_return_if_fail (n_bands != NULL);
*bands = self->priv->bands;
*n_bands = self->priv->n_bands;
}
void
mm_common_connect_properties_get_allowed_modes (MMCommonConnectProperties *self,
mm_simple_connect_properties_get_allowed_modes (MMSimpleConnectProperties *self,
MMModemMode *allowed,
MMModemMode *preferred)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
g_return_if_fail (allowed != NULL);
g_return_if_fail (preferred != NULL);
*allowed = self->priv->allowed_modes;
*preferred = self->priv->preferred_mode;
}
const gchar *
mm_common_connect_properties_get_apn (MMCommonConnectProperties *self)
mm_simple_connect_properties_get_apn (MMSimpleConnectProperties *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL);
return mm_bearer_properties_get_apn (self->priv->bearer_properties);
}
const gchar *
mm_common_connect_properties_get_user (MMCommonConnectProperties *self)
mm_simple_connect_properties_get_user (MMSimpleConnectProperties *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL);
return mm_bearer_properties_get_user (self->priv->bearer_properties);
}
const gchar *
mm_common_connect_properties_get_password (MMCommonConnectProperties *self)
mm_simple_connect_properties_get_password (MMSimpleConnectProperties *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL);
return mm_bearer_properties_get_password (self->priv->bearer_properties);
}
const gchar *
mm_common_connect_properties_get_ip_type (MMCommonConnectProperties *self)
mm_simple_connect_properties_get_ip_type (MMSimpleConnectProperties *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL);
return mm_bearer_properties_get_ip_type (self->priv->bearer_properties);
}
gboolean
mm_common_connect_properties_get_allow_roaming (MMCommonConnectProperties *self)
mm_simple_connect_properties_get_allow_roaming (MMSimpleConnectProperties *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), FALSE);
return mm_bearer_properties_get_allow_roaming (self->priv->bearer_properties);
}
const gchar *
mm_common_connect_properties_get_number (MMCommonConnectProperties *self)
mm_simple_connect_properties_get_number (MMSimpleConnectProperties *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL);
return mm_bearer_properties_get_number (self->priv->bearer_properties);
}
/*****************************************************************************/
GVariant *
mm_common_connect_properties_get_dictionary (MMCommonConnectProperties *self)
mm_simple_connect_properties_get_dictionary (MMSimpleConnectProperties *self)
{
GVariantBuilder builder;
GVariantIter iter;
@@ -221,6 +267,8 @@ mm_common_connect_properties_get_dictionary (MMCommonConnectProperties *self)
if (!self)
return NULL;
g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
if (self->priv->pin)
@@ -272,7 +320,7 @@ mm_common_connect_properties_get_dictionary (MMCommonConnectProperties *self)
/*****************************************************************************/
typedef struct {
MMCommonConnectProperties *properties;
MMSimpleConnectProperties *properties;
GError *error;
gchar *allowed_modes_str;
gchar *preferred_mode_str;
@@ -290,16 +338,16 @@ key_value_foreach (const gchar *key,
return TRUE;
if (g_str_equal (key, PROPERTY_PIN))
mm_common_connect_properties_set_pin (ctx->properties, value);
mm_simple_connect_properties_set_pin (ctx->properties, value);
else if (g_str_equal (key, PROPERTY_OPERATOR_ID))
mm_common_connect_properties_set_operator_id (ctx->properties, value);
mm_simple_connect_properties_set_operator_id (ctx->properties, value);
else if (g_str_equal (key, PROPERTY_BANDS)) {
MMModemBand *bands = NULL;
guint n_bands = 0;
mm_common_get_bands_from_string (value, &bands, &n_bands, &ctx->error);
if (!ctx->error) {
mm_common_connect_properties_set_bands (ctx->properties, bands, n_bands);
mm_simple_connect_properties_set_bands (ctx->properties, bands, n_bands);
g_free (bands);
}
} else if (g_str_equal (key, PROPERTY_ALLOWED_MODES)) {
@@ -316,8 +364,8 @@ key_value_foreach (const gchar *key,
return !ctx->error;
}
MMCommonConnectProperties *
mm_common_connect_properties_new_from_string (const gchar *str,
MMSimpleConnectProperties *
mm_simple_connect_properties_new_from_string (const gchar *str,
GError **error)
{
ParseKeyValueContext ctx;
@@ -325,7 +373,7 @@ mm_common_connect_properties_new_from_string (const gchar *str,
ctx.error = NULL;
ctx.allowed_modes_str = NULL;
ctx.preferred_mode_str = NULL;
ctx.properties = mm_common_connect_properties_new ();
ctx.properties = mm_simple_connect_properties_new ();
mm_common_parse_key_value_string (str,
&ctx.error,
@@ -358,7 +406,7 @@ mm_common_connect_properties_new_from_string (const gchar *str,
g_object_unref (ctx.properties);
ctx.properties = NULL;
} else {
mm_common_connect_properties_set_allowed_modes (
mm_simple_connect_properties_set_allowed_modes (
ctx.properties,
allowed_modes,
preferred_mode);
@@ -373,22 +421,32 @@ mm_common_connect_properties_new_from_string (const gchar *str,
/*****************************************************************************/
MMCommonConnectProperties *
mm_common_connect_properties_new_from_dictionary (GVariant *dictionary,
MMSimpleConnectProperties *
mm_simple_connect_properties_new_from_dictionary (GVariant *dictionary,
GError **error)
{
GError *inner_error = NULL;
GVariantIter iter;
gchar *key;
GVariant *value;
MMCommonConnectProperties *properties;
MMSimpleConnectProperties *properties;
GVariant *allowed_modes_variant = NULL;
GVariant *preferred_mode_variant = NULL;
properties = mm_common_connect_properties_new ();
properties = mm_simple_connect_properties_new ();
if (!dictionary)
return properties;
if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) {
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_INVALID_ARGS,
"Cannot create Simple Connect properties from dictionary: "
"invalid variant type received");
g_object_unref (properties);
return NULL;
}
g_variant_iter_init (&iter, dictionary);
while (!inner_error &&
g_variant_iter_next (&iter, "{sv}", &key, &value)) {
@@ -398,18 +456,18 @@ mm_common_connect_properties_new_from_dictionary (GVariant *dictionary,
key, value,
NULL)) {
if (g_str_equal (key, PROPERTY_PIN))
mm_common_connect_properties_set_pin (
mm_simple_connect_properties_set_pin (
properties,
g_variant_get_string (value, NULL));
else if (g_str_equal (key, PROPERTY_OPERATOR_ID))
mm_common_connect_properties_set_operator_id (
mm_simple_connect_properties_set_operator_id (
properties,
g_variant_get_string (value, NULL));
else if (g_str_equal (key, PROPERTY_BANDS)) {
GArray *array;
array = mm_common_bands_variant_to_garray (value);
mm_common_connect_properties_set_bands (
mm_simple_connect_properties_set_bands (
properties,
(MMModemBand *)array->data,
array->len);
@@ -439,7 +497,7 @@ mm_common_connect_properties_new_from_dictionary (GVariant *dictionary,
}
/* If we got allowed modes variant, check if we got preferred mode */
else if (allowed_modes_variant) {
mm_common_connect_properties_set_allowed_modes (
mm_simple_connect_properties_set_allowed_modes (
properties,
g_variant_get_uint32 (allowed_modes_variant),
(preferred_mode_variant ?
@@ -448,7 +506,7 @@ mm_common_connect_properties_new_from_dictionary (GVariant *dictionary,
}
/* If we only got preferred mode, assume allowed is ANY */
else if (preferred_mode_variant) {
mm_common_connect_properties_set_allowed_modes (
mm_simple_connect_properties_set_allowed_modes (
properties,
MM_MODEM_MODE_ANY,
g_variant_get_uint32 (preferred_mode_variant));
@@ -465,19 +523,19 @@ mm_common_connect_properties_new_from_dictionary (GVariant *dictionary,
/*****************************************************************************/
MMCommonConnectProperties *
mm_common_connect_properties_new (void)
MMSimpleConnectProperties *
mm_simple_connect_properties_new (void)
{
return (MM_COMMON_CONNECT_PROPERTIES (
g_object_new (MM_TYPE_COMMON_CONNECT_PROPERTIES, NULL)));
return (MM_SIMPLE_CONNECT_PROPERTIES (
g_object_new (MM_TYPE_SIMPLE_CONNECT_PROPERTIES, NULL)));
}
static void
mm_common_connect_properties_init (MMCommonConnectProperties *self)
mm_simple_connect_properties_init (MMSimpleConnectProperties *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
MM_TYPE_COMMON_CONNECT_PROPERTIES,
MMCommonConnectPropertiesPrivate);
MM_TYPE_SIMPLE_CONNECT_PROPERTIES,
MMSimpleConnectPropertiesPrivate);
/* Some defaults */
self->priv->bearer_properties = mm_bearer_properties_new ();
@@ -491,22 +549,22 @@ mm_common_connect_properties_init (MMCommonConnectProperties *self)
static void
finalize (GObject *object)
{
MMCommonConnectProperties *self = MM_COMMON_CONNECT_PROPERTIES (object);
MMSimpleConnectProperties *self = MM_SIMPLE_CONNECT_PROPERTIES (object);
g_free (self->priv->pin);
g_free (self->priv->operator_id);
g_free (self->priv->bands);
g_object_unref (self->priv->bearer_properties);
G_OBJECT_CLASS (mm_common_connect_properties_parent_class)->finalize (object);
G_OBJECT_CLASS (mm_simple_connect_properties_parent_class)->finalize (object);
}
static void
mm_common_connect_properties_class_init (MMCommonConnectPropertiesClass *klass)
mm_simple_connect_properties_class_init (MMSimpleConnectPropertiesClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (object_class, sizeof (MMCommonConnectPropertiesPrivate));
g_type_class_add_private (object_class, sizeof (MMSimpleConnectPropertiesPrivate));
object_class->finalize = finalize;
}

View File

@@ -0,0 +1,98 @@
/* -*- 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) 2011 Aleksander Morgado <aleksander@gnu.org>
*/
#ifndef MM_SIMPLE_CONNECT_PROPERTIES_H
#define MM_SIMPLE_CONNECT_PROPERTIES_H
#include <ModemManager.h>
#include <glib-object.h>
#include "mm-bearer-properties.h"
G_BEGIN_DECLS
#define MM_TYPE_SIMPLE_CONNECT_PROPERTIES (mm_simple_connect_properties_get_type ())
#define MM_SIMPLE_CONNECT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SIMPLE_CONNECT_PROPERTIES, MMSimpleConnectProperties))
#define MM_SIMPLE_CONNECT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SIMPLE_CONNECT_PROPERTIES, MMSimpleConnectPropertiesClass))
#define MM_IS_SIMPLE_CONNECT_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SIMPLE_CONNECT_PROPERTIES))
#define MM_IS_SIMPLE_CONNECT_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_SIMPLE_CONNECT_PROPERTIES))
#define MM_SIMPLE_CONNECT_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SIMPLE_CONNECT_PROPERTIES, MMSimpleConnectPropertiesClass))
typedef struct _MMSimpleConnectProperties MMSimpleConnectProperties;
typedef struct _MMSimpleConnectPropertiesClass MMSimpleConnectPropertiesClass;
typedef struct _MMSimpleConnectPropertiesPrivate MMSimpleConnectPropertiesPrivate;
struct _MMSimpleConnectProperties {
GObject parent;
MMSimpleConnectPropertiesPrivate *priv;
};
struct _MMSimpleConnectPropertiesClass {
GObjectClass parent;
};
GType mm_simple_connect_properties_get_type (void);
MMSimpleConnectProperties *mm_simple_connect_properties_new (void);
MMSimpleConnectProperties *mm_simple_connect_properties_new_from_string (const gchar *str,
GError **error);
MMSimpleConnectProperties *mm_simple_connect_properties_new_from_dictionary (GVariant *dictionary,
GError **error);
void mm_simple_connect_properties_set_pin (MMSimpleConnectProperties *properties,
const gchar *pin);
void mm_simple_connect_properties_set_operator_id (MMSimpleConnectProperties *properties,
const gchar *operator_id);
void mm_simple_connect_properties_set_bands (MMSimpleConnectProperties *properties,
const MMModemBand *bands,
guint n_bands);
void mm_simple_connect_properties_set_allowed_modes (MMSimpleConnectProperties *properties,
MMModemMode allowed,
MMModemMode preferred);
void mm_simple_connect_properties_set_apn (MMSimpleConnectProperties *properties,
const gchar *apn);
void mm_simple_connect_properties_set_user (MMSimpleConnectProperties *properties,
const gchar *user);
void mm_simple_connect_properties_set_password (MMSimpleConnectProperties *properties,
const gchar *password);
void mm_simple_connect_properties_set_ip_type (MMSimpleConnectProperties *properties,
const gchar *ip_type);
void mm_simple_connect_properties_set_allow_roaming (MMSimpleConnectProperties *properties,
gboolean allow_roaming);
void mm_simple_connect_properties_set_number (MMSimpleConnectProperties *properties,
const gchar *number);
const gchar *mm_simple_connect_properties_get_pin (MMSimpleConnectProperties *properties);
const gchar *mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *properties);
void mm_simple_connect_properties_get_bands (MMSimpleConnectProperties *properties,
const MMModemBand **bands,
guint *n_bands);
void mm_simple_connect_properties_get_allowed_modes (MMSimpleConnectProperties *properties,
MMModemMode *allowed,
MMModemMode *preferred);
const gchar *mm_simple_connect_properties_get_apn (MMSimpleConnectProperties *properties);
const gchar *mm_simple_connect_properties_get_user (MMSimpleConnectProperties *properties);
const gchar *mm_simple_connect_properties_get_password (MMSimpleConnectProperties *properties);
const gchar *mm_simple_connect_properties_get_ip_type (MMSimpleConnectProperties *properties);
gboolean mm_simple_connect_properties_get_allow_roaming (MMSimpleConnectProperties *properties);
const gchar *mm_simple_connect_properties_get_number (MMSimpleConnectProperties *properties);
MMBearerProperties *mm_simple_connect_properties_get_bearer_properties (MMSimpleConnectProperties *properties);
GVariant *mm_simple_connect_properties_get_dictionary (MMSimpleConnectProperties *self);
G_END_DECLS
#endif /* MM_SIMPLE_CONNECT_PROPERTIES_H */

View File

@@ -24,8 +24,6 @@ libmm_glib_la_SOURCES = \
mm-modem-3gpp-ussd.c \
mm-modem-cdma.h \
mm-modem-cdma.c \
mm-modem-simple-connect-properties.h \
mm-modem-simple-connect-properties.c \
mm-modem-simple-status-properties.h \
mm-modem-simple-status-properties.c \
mm-modem-simple.h \
@@ -54,7 +52,6 @@ include_HEADERS = \
mm-object.h \
mm-modem.h \
mm-modem-3gpp.h \
mm-modem-simple-connect-properties.h \
mm-modem-simple-status-properties.h \
mm-modem-simple.h \
mm-sim.h \

View File

@@ -1,123 +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) 2011 Aleksander Morgado <aleksander@gnu.org>
*/
#include "mm-modem-simple-connect-properties.h"
void
mm_modem_simple_connect_properties_set_pin (MMModemSimpleConnectProperties *self,
const gchar *pin)
{
g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self));
mm_common_connect_properties_set_pin (self, pin);
}
void
mm_modem_simple_connect_properties_set_operator_id (MMModemSimpleConnectProperties *self,
const gchar *operator_id)
{
g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self));
mm_common_connect_properties_set_operator_id (self, operator_id);
}
void
mm_modem_simple_connect_properties_set_bands (MMModemSimpleConnectProperties *self,
const MMModemBand *bands,
guint n_bands)
{
g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self));
mm_common_connect_properties_set_bands (self, bands, n_bands);
}
void
mm_modem_simple_connect_properties_set_allowed_modes (MMModemSimpleConnectProperties *self,
MMModemMode allowed,
MMModemMode preferred)
{
g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self));
mm_common_connect_properties_set_allowed_modes (self, allowed, preferred);
}
void
mm_modem_simple_connect_properties_set_apn (MMModemSimpleConnectProperties *self,
const gchar *apn)
{
g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self));
mm_common_connect_properties_set_apn (self, apn);
}
void
mm_modem_simple_connect_properties_set_user (MMModemSimpleConnectProperties *self,
const gchar *user)
{
g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self));
mm_common_connect_properties_set_user (self, user);
}
void
mm_modem_simple_connect_properties_set_password (MMModemSimpleConnectProperties *self,
const gchar *password)
{
g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self));
mm_common_connect_properties_set_password (self, password);
}
void
mm_modem_simple_connect_properties_set_ip_type (MMModemSimpleConnectProperties *self,
const gchar *ip_type)
{
g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self));
mm_common_connect_properties_set_ip_type (self, ip_type);
}
void
mm_modem_simple_connect_properties_set_allow_roaming (MMModemSimpleConnectProperties *self,
gboolean allow_roaming)
{
g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self));
mm_common_connect_properties_set_allow_roaming (self, allow_roaming);
}
void
mm_modem_simple_connect_properties_set_number (MMModemSimpleConnectProperties *self,
const gchar *number)
{
g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self));
mm_common_connect_properties_set_number (self, number);
}
/*****************************************************************************/
MMModemSimpleConnectProperties *
mm_modem_simple_connect_properties_new_from_string (const gchar *str,
GError **error)
{
return mm_common_connect_properties_new_from_string (str, error);
}
MMModemSimpleConnectProperties *
mm_modem_simple_connect_properties_new (void)
{
return mm_common_connect_properties_new ();
}

View File

@@ -1,71 +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) 2011 Aleksander Morgado <aleksander@gnu.org>
*/
#ifndef MM_MODEM_SIMPLE_CONNECT_PROPERTIES_H
#define MM_MODEM_SIMPLE_CONNECT_PROPERTIES_H
#include <ModemManager.h>
#include <glib-object.h>
#include <libmm-common.h>
G_BEGIN_DECLS
typedef MMCommonConnectProperties MMModemSimpleConnectProperties;
#define MM_TYPE_MODEM_SIMPLE_CONNECT_PROPERTIES(o) MM_TYPE_COMMON_CONNECT_PROPERTIES (o)
#define MM_MODEM_SIMPLE_CONNECT_PROPERTIES(o) MM_COMMON_CONNECT_PROPERTIES(o)
#define MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES(o) MM_IS_COMMON_CONNECT_PROPERTIES(o)
MMModemSimpleConnectProperties *mm_modem_simple_connect_properties_new (void);
MMModemSimpleConnectProperties *mm_modem_simple_connect_properties_new_from_string (
const gchar *str,
GError **error);
void mm_modem_simple_connect_properties_set_pin (
MMModemSimpleConnectProperties *properties,
const gchar *pin);
void mm_modem_simple_connect_properties_set_operator_id (
MMModemSimpleConnectProperties *properties,
const gchar *operator_id);
void mm_modem_simple_connect_properties_set_bands (
MMModemSimpleConnectProperties *properties,
const MMModemBand *bands,
guint n_bands);
void mm_modem_simple_connect_properties_set_allowed_modes (
MMModemSimpleConnectProperties *properties,
MMModemMode allowed,
MMModemMode preferred);
void mm_modem_simple_connect_properties_set_apn (
MMModemSimpleConnectProperties *properties,
const gchar *apn);
void mm_modem_simple_connect_properties_set_user (
MMModemSimpleConnectProperties *properties,
const gchar *user);
void mm_modem_simple_connect_properties_set_password (
MMModemSimpleConnectProperties *properties,
const gchar *password);
void mm_modem_simple_connect_properties_set_ip_type (
MMModemSimpleConnectProperties *properties,
const gchar *ip_type);
void mm_modem_simple_connect_properties_set_allow_roaming (
MMModemSimpleConnectProperties *properties,
gboolean allow_roaming);
void mm_modem_simple_connect_properties_set_number (
MMModemSimpleConnectProperties *properties,
const gchar *number);
G_END_DECLS
#endif /* MM_MODEM_SIMPLE_CONNECT_PROPERTIES_H */

View File

@@ -140,7 +140,7 @@ simple_connect_ready (MMModemSimple *self,
void
mm_modem_simple_connect (MMModemSimple *self,
MMModemSimpleConnectProperties *properties,
MMSimpleConnectProperties *properties,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -158,8 +158,7 @@ mm_modem_simple_connect (MMModemSimple *self,
if (cancellable)
ctx->cancellable = g_object_ref (cancellable);
variant = mm_common_connect_properties_get_dictionary (
MM_COMMON_CONNECT_PROPERTIES (properties));
variant = mm_simple_connect_properties_get_dictionary (properties);
mm_gdbus_modem_simple_call_connect (
self,
variant,
@@ -172,7 +171,7 @@ mm_modem_simple_connect (MMModemSimple *self,
MMBearer *
mm_modem_simple_connect_sync (MMModemSimple *self,
MMModemSimpleConnectProperties *properties,
MMSimpleConnectProperties *properties,
GCancellable *cancellable,
GError **error)
{
@@ -182,8 +181,7 @@ mm_modem_simple_connect_sync (MMModemSimple *self,
g_return_val_if_fail (MM_GDBUS_IS_MODEM_SIMPLE (self), NULL);
variant = mm_common_connect_properties_get_dictionary (
MM_COMMON_CONNECT_PROPERTIES (properties));
variant = mm_simple_connect_properties_get_dictionary (properties);
mm_gdbus_modem_simple_call_connect_sync (self,
variant,
&bearer_path,

View File

@@ -27,7 +27,6 @@
#include <mm-gdbus-modem.h>
#include "mm-bearer.h"
#include "mm-modem-simple-connect-properties.h"
#include "mm-modem-simple-status-properties.h"
G_BEGIN_DECLS
@@ -41,7 +40,7 @@ const gchar *mm_modem_simple_get_path (MMModemSimple *self);
gchar *mm_modem_simple_dup_path (MMModemSimple *self);
void mm_modem_simple_connect (MMModemSimple *self,
MMModemSimpleConnectProperties *properties,
MMSimpleConnectProperties *properties,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@@ -49,7 +48,7 @@ MMBearer *mm_modem_simple_connect_finish (MMModemSimple *self,
GAsyncResult *res,
GError **error);
MMBearer *mm_modem_simple_connect_sync (MMModemSimple *self,
MMModemSimpleConnectProperties *properties,
MMSimpleConnectProperties *properties,
GCancellable *cancellable,
GError **error);

View File

@@ -187,7 +187,7 @@ typedef struct {
/* Expected input properties */
GVariant *dictionary;
MMCommonConnectProperties *properties;
MMSimpleConnectProperties *properties;
/* Results to set */
MMBearer *bearer;
@@ -375,7 +375,7 @@ unlock_check_ready (MMIfaceModem *self,
/* During simple connect we are only allowed to use SIM PIN */
if (lock != MM_MODEM_LOCK_SIM_PIN ||
!mm_common_connect_properties_get_pin (ctx->properties)) {
!mm_simple_connect_properties_get_pin (ctx->properties)) {
g_dbus_method_invocation_return_error (
ctx->invocation,
MM_CORE_ERROR,
@@ -402,7 +402,7 @@ unlock_check_ready (MMIfaceModem *self,
}
mm_sim_send_pin (sim,
mm_common_connect_properties_get_pin (ctx->properties),
mm_simple_connect_properties_get_pin (ctx->properties),
(GAsyncReadyCallback)send_pin_ready,
ctx);
g_object_unref (sim);
@@ -440,7 +440,7 @@ connection_step (ConnectionContext *ctx)
mm_info ("Simple connect state (%d/%d): Allowed mode",
ctx->step, CONNECTION_STEP_LAST);
mm_common_connect_properties_get_allowed_modes (ctx->properties,
mm_simple_connect_properties_get_allowed_modes (ctx->properties,
&allowed_modes,
&preferred_mode);
mm_iface_modem_set_allowed_modes (MM_IFACE_MODEM (ctx->self),
@@ -460,7 +460,7 @@ connection_step (ConnectionContext *ctx)
mm_info ("Simple connect state (%d/%d): Bands",
ctx->step, CONNECTION_STEP_LAST);
mm_common_connect_properties_get_bands (ctx->properties,
mm_simple_connect_properties_get_bands (ctx->properties,
&bands,
&n_bands);
@@ -485,7 +485,7 @@ connection_step (ConnectionContext *ctx)
/* 3GPP or CDMA registration */
register_in_3gpp_or_cdma_network (
ctx->self,
mm_common_connect_properties_get_operator_id (ctx->properties),
mm_simple_connect_properties_get_operator_id (ctx->properties),
(GAsyncReadyCallback)register_in_3gpp_or_cdma_network_ready,
ctx);
return;
@@ -507,8 +507,7 @@ connection_step (ConnectionContext *ctx)
MM_IFACE_MODEM_BEARER_LIST, &list,
NULL);
bearer_properties = (mm_common_connect_properties_get_bearer_properties (
ctx->properties));
bearer_properties = mm_simple_connect_properties_get_bearer_properties (ctx->properties);
/* Check if the bearer we want to create is already in the list */
ctx->bearer = mm_bearer_list_find (list, bearer_properties);
@@ -575,7 +574,7 @@ connect_auth_ready (MMBaseModem *self,
return;
}
ctx->properties = mm_common_connect_properties_new_from_dictionary (ctx->dictionary, &error);
ctx->properties = mm_simple_connect_properties_new_from_dictionary (ctx->dictionary, &error);
if (!ctx->properties) {
g_dbus_method_invocation_take_error (ctx->invocation, error);
connection_context_free (ctx);