core: new MMBroadbandModem object, inherits from MMBaseModem
New object to implement broadband modem specific behaviour.
This commit is contained in:
@@ -116,6 +116,8 @@ modem_manager_SOURCES = \
|
|||||||
mm-base-modem.c \
|
mm-base-modem.c \
|
||||||
mm-iface-modem.h \
|
mm-iface-modem.h \
|
||||||
mm-iface-modem.c \
|
mm-iface-modem.c \
|
||||||
|
mm-broadband-modem.h \
|
||||||
|
mm-broadband-modem.c \
|
||||||
mm-modem.c \
|
mm-modem.c \
|
||||||
mm-modem.h \
|
mm-modem.h \
|
||||||
mm-serial-parsers.c \
|
mm-serial-parsers.c \
|
||||||
|
173
src/mm-broadband-modem.c
Normal file
173
src/mm-broadband-modem.c
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
/* -*- 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 - 2009 Novell, Inc.
|
||||||
|
* Copyright (C) 2009 - 2011 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2011 Google, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <ModemManager.h>
|
||||||
|
|
||||||
|
#include <mm-errors-types.h>
|
||||||
|
#include <mm-enums-types.h>
|
||||||
|
|
||||||
|
#include "mm-broadband-modem.h"
|
||||||
|
#include "mm-errors.h"
|
||||||
|
#include "mm-log.h"
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (MMBroadbandModem, mm_broadband_modem, MM_TYPE_BASE_MODEM);
|
||||||
|
|
||||||
|
struct _MMBroadbandModemPrivate {
|
||||||
|
gpointer dummy;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
enable (MMBaseModem *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GSimpleAsyncResult *res;
|
||||||
|
|
||||||
|
res = g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
enable);
|
||||||
|
|
||||||
|
g_simple_async_result_set_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res), TRUE);
|
||||||
|
g_simple_async_result_complete_in_idle (G_SIMPLE_ASYNC_RESULT (res));
|
||||||
|
g_object_unref (res);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
enable_finish (MMBaseModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
disable (MMBaseModem *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GSimpleAsyncResult *res;
|
||||||
|
|
||||||
|
res = g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
disable);
|
||||||
|
|
||||||
|
g_simple_async_result_set_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res), TRUE);
|
||||||
|
g_simple_async_result_complete_in_idle (G_SIMPLE_ASYNC_RESULT (res));
|
||||||
|
g_object_unref (res);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
disable_finish (MMBaseModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void
|
||||||
|
initialize (MMBaseModem *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GSimpleAsyncResult *res;
|
||||||
|
|
||||||
|
res = g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
initialize);
|
||||||
|
|
||||||
|
g_simple_async_result_set_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res), TRUE);
|
||||||
|
g_simple_async_result_complete_in_idle (G_SIMPLE_ASYNC_RESULT (res));
|
||||||
|
g_object_unref (res);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
initialize_finish (MMBaseModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
MMBroadbandModem *
|
||||||
|
mm_broadband_modem_new (const gchar *device,
|
||||||
|
const gchar *driver,
|
||||||
|
const gchar *plugin,
|
||||||
|
guint16 vendor_id,
|
||||||
|
guint16 product_id)
|
||||||
|
{
|
||||||
|
return g_object_new (MM_TYPE_BROADBAND_MODEM,
|
||||||
|
MM_BASE_MODEM_DEVICE, device,
|
||||||
|
MM_BASE_MODEM_DRIVER, driver,
|
||||||
|
MM_BASE_MODEM_PLUGIN, plugin,
|
||||||
|
MM_BASE_MODEM_VENDOR_ID, vendor_id,
|
||||||
|
MM_BASE_MODEM_PRODUCT_ID, product_id,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_broadband_modem_init (MMBroadbandModem *self)
|
||||||
|
{
|
||||||
|
/* Initialize private data */
|
||||||
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
|
||||||
|
MM_TYPE_BROADBAND_MODEM,
|
||||||
|
MMBroadbandModemPrivate);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_broadband_modem_class_init (MMBroadbandModemClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
MMBaseModemClass *base_modem_class = MM_BASE_MODEM_CLASS (klass);
|
||||||
|
|
||||||
|
g_type_class_add_private (object_class, sizeof (MMBroadbandModemPrivate));
|
||||||
|
|
||||||
|
base_modem_class->initialize = initialize;
|
||||||
|
base_modem_class->initialize_finish = initialize_finish;
|
||||||
|
base_modem_class->enable = enable;
|
||||||
|
base_modem_class->enable_finish = enable_finish;
|
||||||
|
base_modem_class->disable = disable;
|
||||||
|
base_modem_class->disable_finish = disable_finish;
|
||||||
|
}
|
55
src/mm-broadband-modem.h
Normal file
55
src/mm-broadband-modem.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/* -*- 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 - 2009 Novell, Inc.
|
||||||
|
* Copyright (C) 2009 - 2011 Red Hat, Inc.
|
||||||
|
* Copyright (C) 2011 Google, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MM_BROADBAND_MODEM_H
|
||||||
|
#define MM_BROADBAND_MODEM_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "mm-base-modem.h"
|
||||||
|
|
||||||
|
#define MM_TYPE_BROADBAND_MODEM (mm_broadband_modem_get_type ())
|
||||||
|
#define MM_BROADBAND_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM, MMBroadbandModem))
|
||||||
|
#define MM_BROADBAND_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM, MMBroadbandModemClass))
|
||||||
|
#define MM_IS_BROADBAND_MODEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM))
|
||||||
|
#define MM_IS_BROADBAND_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM))
|
||||||
|
#define MM_BROADBAND_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM, MMBroadbandModemClass))
|
||||||
|
|
||||||
|
typedef struct _MMBroadbandModem MMBroadbandModem;
|
||||||
|
typedef struct _MMBroadbandModemClass MMBroadbandModemClass;
|
||||||
|
typedef struct _MMBroadbandModemPrivate MMBroadbandModemPrivate;
|
||||||
|
|
||||||
|
struct _MMBroadbandModem {
|
||||||
|
MMBaseModem parent;
|
||||||
|
MMBroadbandModemPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MMBroadbandModemClass {
|
||||||
|
MMBaseModemClass parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType mm_broadband_modem_get_type (void);
|
||||||
|
|
||||||
|
MMBroadbandModem *mm_broadband_modem_new (const gchar *device,
|
||||||
|
const gchar *driver,
|
||||||
|
const gchar *plugin,
|
||||||
|
guint16 vendor_id,
|
||||||
|
guint16 product_id);
|
||||||
|
|
||||||
|
#endif /* MM_BROADBAND_MODEM_H */
|
||||||
|
|
Reference in New Issue
Block a user