mbm: new `MMBroadbandBearerMbm' object
This commit is contained in:
@@ -119,7 +119,9 @@ libmm_plugin_mbm_la_SOURCES = \
|
|||||||
mbm/mm-plugin-mbm.c \
|
mbm/mm-plugin-mbm.c \
|
||||||
mbm/mm-plugin-mbm.h \
|
mbm/mm-plugin-mbm.h \
|
||||||
mbm/mm-broadband-modem-mbm.c \
|
mbm/mm-broadband-modem-mbm.c \
|
||||||
mbm/mm-broadband-modem-mbm.h
|
mbm/mm-broadband-modem-mbm.h \
|
||||||
|
mbm/mm-broadband-bearer-mbm.c \
|
||||||
|
mbm/mm-broadband-bearer-mbm.h
|
||||||
libmm_plugin_mbm_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
|
libmm_plugin_mbm_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
|
||||||
libmm_plugin_mbm_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
|
libmm_plugin_mbm_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
|
||||||
udevrules_DATA += mbm/77-mm-ericsson-mbm.rules
|
udevrules_DATA += mbm/77-mm-ericsson-mbm.rules
|
||||||
|
93
plugins/mbm/mm-broadband-bearer-mbm.c
Normal file
93
plugins/mbm/mm-broadband-bearer-mbm.c
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/* -*- 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) 2008 - 2010 Ericsson AB
|
||||||
|
* Copyright (C) 2009 - 2012 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2012 Lanedo GmbH
|
||||||
|
*
|
||||||
|
* Author: Per Hallsmark <per.hallsmark@ericsson.com>
|
||||||
|
* Bjorn Runaker <bjorn.runaker@ericsson.com>
|
||||||
|
* Torgny Johansson <torgny.johansson@ericsson.com>
|
||||||
|
* Jonas Sjöquist <jonas.sjoquist@ericsson.com>
|
||||||
|
* Dan Williams <dcbw@redhat.com>
|
||||||
|
* Aleksander Morgado <aleksander@lanedo.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#include <ModemManager.h>
|
||||||
|
#include <libmm-common.h>
|
||||||
|
|
||||||
|
#include "mm-base-modem-at.h"
|
||||||
|
#include "mm-broadband-bearer-mbm.h"
|
||||||
|
#include "mm-log.h"
|
||||||
|
#include "mm-modem-helpers.h"
|
||||||
|
#include "mm-utils.h"
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (MMBroadbandBearerMbm, mm_broadband_bearer_mbm, MM_TYPE_BROADBAND_BEARER);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
MMBearer *
|
||||||
|
mm_broadband_bearer_mbm_new_finish (GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GObject *bearer;
|
||||||
|
GObject *source;
|
||||||
|
|
||||||
|
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_mbm_new (MMBroadbandModemMbm *modem,
|
||||||
|
MMBearerProperties *config,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_async_initable_new_async (
|
||||||
|
MM_TYPE_BROADBAND_BEARER_MBM,
|
||||||
|
G_PRIORITY_DEFAULT,
|
||||||
|
cancellable,
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
MM_BEARER_MODEM, modem,
|
||||||
|
MM_BEARER_CONFIG, config,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_broadband_bearer_mbm_init (MMBroadbandBearerMbm *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_broadband_bearer_mbm_class_init (MMBroadbandBearerMbmClass *klass)
|
||||||
|
{
|
||||||
|
}
|
66
plugins/mbm/mm-broadband-bearer-mbm.h
Normal file
66
plugins/mbm/mm-broadband-bearer-mbm.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/* -*- 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) 2008 - 2010 Ericsson AB
|
||||||
|
* Copyright (C) 2009 - 2012 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2012 Lanedo GmbH
|
||||||
|
*
|
||||||
|
* Author: Per Hallsmark <per.hallsmark@ericsson.com>
|
||||||
|
* Bjorn Runaker <bjorn.runaker@ericsson.com>
|
||||||
|
* Torgny Johansson <torgny.johansson@ericsson.com>
|
||||||
|
* Jonas Sjöquist <jonas.sjoquist@ericsson.com>
|
||||||
|
* Dan Williams <dcbw@redhat.com>
|
||||||
|
* Aleksander Morgado <aleksander@lanedo.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MM_BROADBAND_BEARER_MBM_H
|
||||||
|
#define MM_BROADBAND_BEARER_MBM_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include <libmm-common.h>
|
||||||
|
|
||||||
|
#include "mm-broadband-bearer.h"
|
||||||
|
#include "mm-broadband-modem-mbm.h"
|
||||||
|
|
||||||
|
#define MM_TYPE_BROADBAND_BEARER_MBM (mm_broadband_bearer_mbm_get_type ())
|
||||||
|
#define MM_BROADBAND_BEARER_MBM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_BEARER_MBM, MMBroadbandBearerMbm))
|
||||||
|
#define MM_BROADBAND_BEARER_MBM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_BEARER_MBM, MMBroadbandBearerMbmClass))
|
||||||
|
#define MM_IS_BROADBAND_BEARER_MBM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_BEARER_MBM))
|
||||||
|
#define MM_IS_BROADBAND_BEARER_MBM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_BEARER_MBM))
|
||||||
|
#define MM_BROADBAND_BEARER_MBM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_BEARER_MBM, MMBroadbandBearerMbmClass))
|
||||||
|
|
||||||
|
typedef struct _MMBroadbandBearerMbm MMBroadbandBearerMbm;
|
||||||
|
typedef struct _MMBroadbandBearerMbmClass MMBroadbandBearerMbmClass;
|
||||||
|
typedef struct _MMBroadbandBearerMbmPrivate MMBroadbandBearerMbmPrivate;
|
||||||
|
|
||||||
|
struct _MMBroadbandBearerMbm {
|
||||||
|
MMBroadbandBearer parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MMBroadbandBearerMbmClass {
|
||||||
|
MMBroadbandBearerClass parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType mm_broadband_bearer_mbm_get_type (void);
|
||||||
|
|
||||||
|
/* Default 3GPP bearer creation implementation */
|
||||||
|
void mm_broadband_bearer_mbm_new (MMBroadbandModemMbm *modem,
|
||||||
|
MMBearerProperties *config,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
MMBearer *mm_broadband_bearer_mbm_new_finish (GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
#endif /* MM_BROADBAND_BEARER_MBM_H */
|
@@ -35,6 +35,7 @@
|
|||||||
#include "mm-errors-types.h"
|
#include "mm-errors-types.h"
|
||||||
#include "mm-modem-helpers.h"
|
#include "mm-modem-helpers.h"
|
||||||
#include "mm-broadband-modem-mbm.h"
|
#include "mm-broadband-modem-mbm.h"
|
||||||
|
#include "mm-broadband-bearer-mbm.h"
|
||||||
#include "mm-base-modem-at.h"
|
#include "mm-base-modem-at.h"
|
||||||
#include "mm-iface-modem.h"
|
#include "mm-iface-modem.h"
|
||||||
#include "mm-iface-modem-3gpp.h"
|
#include "mm-iface-modem-3gpp.h"
|
||||||
@@ -66,6 +67,62 @@ struct _MMBroadbandModemMbmPrivate {
|
|||||||
GRegex *erinfo_regex;
|
GRegex *erinfo_regex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Create Bearer (Modem interface) */
|
||||||
|
|
||||||
|
static MMBearer *
|
||||||
|
modem_create_bearer_finish (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
MMBearer *bearer;
|
||||||
|
|
||||||
|
bearer = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
|
||||||
|
mm_dbg ("New MBM bearer created at DBus path '%s'", mm_bearer_get_path (bearer));
|
||||||
|
|
||||||
|
return g_object_ref (bearer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
broadband_bearer_mbm_new_ready (GObject *source,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GSimpleAsyncResult *simple)
|
||||||
|
{
|
||||||
|
MMBearer *bearer = NULL;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
bearer = mm_broadband_bearer_mbm_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
modem_create_bearer (MMIfaceModem *self,
|
||||||
|
MMBearerProperties *properties,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GSimpleAsyncResult *result;
|
||||||
|
|
||||||
|
result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
modem_create_bearer);
|
||||||
|
|
||||||
|
mm_dbg ("Creating MBM bearer...");
|
||||||
|
mm_broadband_bearer_mbm_new (MM_BROADBAND_MODEM_MBM (self),
|
||||||
|
properties,
|
||||||
|
NULL, /* cancellable */
|
||||||
|
(GAsyncReadyCallback)broadband_bearer_mbm_new_ready,
|
||||||
|
result);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* After SIM unlock (Modem interface) */
|
/* After SIM unlock (Modem interface) */
|
||||||
|
|
||||||
@@ -960,6 +1017,8 @@ finalize (GObject *object)
|
|||||||
static void
|
static void
|
||||||
iface_modem_init (MMIfaceModem *iface)
|
iface_modem_init (MMIfaceModem *iface)
|
||||||
{
|
{
|
||||||
|
iface->create_bearer = modem_create_bearer;
|
||||||
|
iface->create_bearer_finish = modem_create_bearer_finish;
|
||||||
iface->modem_after_sim_unlock = modem_after_sim_unlock;
|
iface->modem_after_sim_unlock = modem_after_sim_unlock;
|
||||||
iface->modem_after_sim_unlock_finish = modem_after_sim_unlock_finish;
|
iface->modem_after_sim_unlock_finish = modem_after_sim_unlock_finish;
|
||||||
iface->load_allowed_modes = load_allowed_modes;
|
iface->load_allowed_modes = load_allowed_modes;
|
||||||
|
Reference in New Issue
Block a user