diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-19 09:33:56 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-08-06 20:07:25 +0200 |
commit | fa6ea4258a5db51f4fd9d93e8a8649d5c20f9211 (patch) | |
tree | a542a1354b98f2cadc24f82aa81bc610c57cc3be | |
parent | e8aa5d0f722c1c8b72a62307124b05b8f6e73c7b (diff) |
icera: new `MMBroadbandBearerIcera'
-rw-r--r-- | plugins/Makefile.am | 4 | ||||
-rw-r--r-- | plugins/icera/mm-broadband-bearer-icera.c | 84 | ||||
-rw-r--r-- | plugins/icera/mm-broadband-bearer-icera.h | 60 | ||||
-rw-r--r-- | plugins/icera/mm-iface-icera.c | 57 | ||||
-rw-r--r-- | plugins/icera/mm-iface-icera.h | 8 |
5 files changed, 212 insertions, 1 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 1de58fc7..0efc6d82 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -26,7 +26,9 @@ udevrules_DATA = noinst_LTLIBRARIES = libmm-utils-icera.la libmm_utils_icera_la_SOURCES = \ icera/mm-iface-icera.h \ - icera/mm-iface-icera.c + icera/mm-iface-icera.c \ + icera/mm-broadband-bearer-icera.h \ + icera/mm-broadband-bearer-icera.c libmm_utils_icera_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) libmm_utils_icera_la_LIBADD = $(GUDEV_LDFLAGS) diff --git a/plugins/icera/mm-broadband-bearer-icera.c b/plugins/icera/mm-broadband-bearer-icera.c new file mode 100644 index 00000000..2e366c3f --- /dev/null +++ b/plugins/icera/mm-broadband-bearer-icera.c @@ -0,0 +1,84 @@ +/* -*- 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. + * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org> + */ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <ctype.h> + +#include <ModemManager.h> +#include <libmm-common.h> + +#include "mm-broadband-bearer-icera.h" +#include "mm-base-modem-at.h" +#include "mm-log.h" +#include "mm-modem-helpers.h" +#include "mm-utils.h" + +G_DEFINE_TYPE (MMBroadbandBearerIcera, mm_broadband_bearer_icera, MM_TYPE_BROADBAND_BEARER); + +/*****************************************************************************/ + +MMBearer * +mm_broadband_bearer_icera_new_finish (GAsyncResult *res, + GError **error) +{ + GObject *source; + GObject *bearer; + + source = g_async_result_get_source_object (res); + bearer = g_async_initable_new_finish (G_ASYNC_INITABLE (source), res, error); + g_object_unref (source); + + if (!bearer) + return NULL; + + /* Only export valid bearers */ + mm_bearer_export (MM_BEARER (bearer)); + + return MM_BEARER (bearer); +} + +void +mm_broadband_bearer_icera_new (MMBroadbandModem *modem, + MMBearerProperties *config, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_async_initable_new_async ( + MM_TYPE_BROADBAND_BEARER_ICERA, + G_PRIORITY_DEFAULT, + cancellable, + callback, + user_data, + MM_BEARER_MODEM, modem, + MM_BEARER_CONFIG, config, + NULL); +} + +static void +mm_broadband_bearer_icera_init (MMBroadbandBearerIcera *self) +{ +} + +static void +mm_broadband_bearer_icera_class_init (MMBroadbandBearerIceraClass *klass) +{ +} diff --git a/plugins/icera/mm-broadband-bearer-icera.h b/plugins/icera/mm-broadband-bearer-icera.h new file mode 100644 index 00000000..4fd1f496 --- /dev/null +++ b/plugins/icera/mm-broadband-bearer-icera.h @@ -0,0 +1,60 @@ +/* -*- 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: + * + * Author: Nathan Williams <njw@google.com> + * + * Copyright (C) 2012 Google, Inc. + * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org> + */ + +#ifndef MM_BROADBAND_BEARER_ICERA_H +#define MM_BROADBAND_BEARER_ICERA_H + +#include <glib.h> +#include <glib-object.h> + +#include <libmm-common.h> + +#include "mm-broadband-bearer.h" + +#define MM_TYPE_BROADBAND_BEARER_ICERA (mm_broadband_bearer_icera_get_type ()) +#define MM_BROADBAND_BEARER_ICERA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_BEARER_ICERA, MMBroadbandBearerIcera)) +#define MM_BROADBAND_BEARER_ICERA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_BEARER_ICERA, MMBroadbandBearerIceraClass)) +#define MM_IS_BROADBAND_BEARER_ICERA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_BEARER_ICERA)) +#define MM_IS_BROADBAND_BEARER_ICERA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_BEARER_ICERA)) +#define MM_BROADBAND_BEARER_ICERA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_BEARER_ICERA, MMBroadbandBearerIceraClass)) + +typedef struct _MMBroadbandBearerIcera MMBroadbandBearerIcera; +typedef struct _MMBroadbandBearerIceraClass MMBroadbandBearerIceraClass; +typedef struct _MMBroadbandBearerIceraPrivate MMBroadbandBearerIceraPrivate; + +struct _MMBroadbandBearerIcera { + MMBroadbandBearer parent; + MMBroadbandBearerIceraPrivate *priv; +}; + +struct _MMBroadbandBearerIceraClass { + MMBroadbandBearerClass parent; +}; + +GType mm_broadband_bearer_icera_get_type (void); + +/* Default bearer creation implementation */ +void mm_broadband_bearer_icera_new (MMBroadbandModem *modem, + MMBearerProperties *config, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMBearer *mm_broadband_bearer_icera_new_finish (GAsyncResult *res, + GError **error); + +#endif /* MM_BROADBAND_BEARER_ICERA_H */ diff --git a/plugins/icera/mm-iface-icera.c b/plugins/icera/mm-iface-icera.c index 851dbc01..9f2d4a72 100644 --- a/plugins/icera/mm-iface-icera.c +++ b/plugins/icera/mm-iface-icera.c @@ -26,6 +26,7 @@ #include "mm-log.h" #include "mm-modem-helpers.h" #include "mm-iface-icera.h" +#include "mm-broadband-bearer-icera.h" #include "mm-base-modem-at.h" /*****************************************************************************/ @@ -492,6 +493,62 @@ mm_iface_icera_modem_3gpp_enable_unsolicited_events (MMIfaceModem3gpp *self, } /*****************************************************************************/ +/* Create bearer (Modem interface) */ + +MMBearer * +mm_iface_icera_modem_create_bearer_finish (MMIfaceModem *self, + GAsyncResult *res, + GError **error) +{ + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) + return NULL; + + return MM_BEARER (g_object_ref ( + g_simple_async_result_get_op_res_gpointer ( + G_SIMPLE_ASYNC_RESULT (res)))); +} + +static void +broadband_bearer_icera_new_ready (GObject *source, + GAsyncResult *res, + GSimpleAsyncResult *simple) +{ + MMBearer *bearer = NULL; + GError *error = NULL; + + bearer = mm_broadband_bearer_icera_new_finish (res, &error); + if (!bearer) + g_simple_async_result_take_error (simple, error); + else + g_simple_async_result_set_op_res_gpointer (simple, + bearer, + (GDestroyNotify)g_object_unref); + g_simple_async_result_complete (simple); + g_object_unref (simple); +} + +void +mm_iface_icera_modem_create_bearer (MMIfaceModem *self, + MMBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + + /* Set a new ref to the bearer object as result */ + result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + mm_iface_icera_modem_create_bearer); + + mm_broadband_bearer_icera_new (MM_BROADBAND_MODEM (self), + properties, + NULL, /* cancellable */ + (GAsyncReadyCallback)broadband_bearer_icera_new_ready, + result); +} + +/*****************************************************************************/ static void iface_icera_init (gpointer g_iface) diff --git a/plugins/icera/mm-iface-icera.h b/plugins/icera/mm-iface-icera.h index ba3337ed..529f2844 100644 --- a/plugins/icera/mm-iface-icera.h +++ b/plugins/icera/mm-iface-icera.h @@ -67,6 +67,14 @@ gboolean mm_iface_icera_modem_load_access_technologies_finish (MMIfaceModem *sel guint *mask, GError **error); +void mm_iface_icera_modem_create_bearer (MMIfaceModem *self, + MMBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data); +MMBearer *mm_iface_icera_modem_create_bearer_finish (MMIfaceModem *self, + GAsyncResult *res, + GError **error); + /*****************************************************************************/ /* Modem 3GPP interface specific implementations */ |