bearer-cdma: new bearer to handle connections in CDMA networks

This commit is contained in:
Aleksander Morgado
2012-01-08 19:16:50 +01:00
parent 531c1fa660
commit 06ea25c0d4
3 changed files with 257 additions and 0 deletions

View File

@@ -132,6 +132,8 @@ modem_manager_SOURCES = \
mm-bearer.c \ mm-bearer.c \
mm-bearer-3gpp.h \ mm-bearer-3gpp.h \
mm-bearer-3gpp.c \ mm-bearer-3gpp.c \
mm-bearer-cdma.h \
mm-bearer-cdma.c \
mm-bearer-list.h \ mm-bearer-list.h \
mm-bearer-list.c \ mm-bearer-list.c \
mm-base-modem-at.h \ mm-base-modem-at.h \

194
src/mm-bearer-cdma.c Normal file
View File

@@ -0,0 +1,194 @@
/* -*- 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) 2012 Google, Inc.
*/
#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-bearer-cdma.h"
#include "mm-base-modem-at.h"
#include "mm-utils.h"
#include "mm-log.h"
#include "mm-modem-helpers.h"
G_DEFINE_TYPE (MMBearerCdma, mm_bearer_cdma, MM_TYPE_BEARER);
enum {
PROP_0,
PROP_RM_PROTOCOL,
PROP_LAST
};
static GParamSpec *properties[PROP_LAST];
struct _MMBearerCdmaPrivate {
/* Protocol of the Rm interface */
MMModemCdmaRmProtocol rm_protocol;
};
/*****************************************************************************/
MMModemCdmaRmProtocol
mm_bearer_cdma_get_rm_protocol (MMBearerCdma *self)
{
return self->priv->rm_protocol;
}
/*****************************************************************************/
/* CONNECT */
static gboolean
connect_finish (MMBearer *self,
GAsyncResult *res,
GError **error)
{
return FALSE;
}
static void
connect (MMBearer *self,
const gchar *number,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
}
/*****************************************************************************/
/* DISCONNECT */
static gboolean
disconnect_finish (MMBearer *self,
GAsyncResult *res,
GError **error)
{
return FALSE;
}
static void
disconnect (MMBearer *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
}
/*****************************************************************************/
MMBearer *
mm_bearer_cdma_new (MMBaseModem *modem,
MMCommonBearerProperties *properties,
GError **error)
{
static guint id = 0;
MMBearerCdma *bearer;
gchar *path;
/* Create the object */
bearer = g_object_new (MM_TYPE_BEARER_CDMA,
MM_BEARER_CDMA_RM_PROTOCOL, mm_common_bearer_properties_get_rm_protocol (properties),
MM_BEARER_ALLOW_ROAMING, mm_common_bearer_properties_get_allow_roaming (properties),
NULL);
/* Set modem and path ONLY after having checked input properties, so that
* we don't export invalid bearers. */
path = g_strdup_printf (MM_DBUS_BEARER_CDMA_PREFIX "/%d", id++);
g_object_set (bearer,
MM_BEARER_PATH, path,
MM_BEARER_MODEM, modem,
NULL);
g_free (path);
return MM_BEARER (bearer);
}
static void
set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MMBearerCdma *self = MM_BEARER_CDMA (object);
switch (prop_id) {
case PROP_RM_PROTOCOL:
self->priv->rm_protocol = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MMBearerCdma *self = MM_BEARER_CDMA (object);
switch (prop_id) {
case PROP_RM_PROTOCOL:
g_value_set_enum (value, self->priv->rm_protocol);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
mm_bearer_cdma_init (MMBearerCdma *self)
{
/* Initialize private data */
self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
MM_TYPE_BEARER_CDMA,
MMBearerCdmaPrivate);
self->priv->rm_protocol = MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN;
}
static void
mm_bearer_cdma_class_init (MMBearerCdmaClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
MMBearerClass *bearer_class = MM_BEARER_CLASS (klass);
g_type_class_add_private (object_class, sizeof (MMBearerCdmaPrivate));
/* Virtual methods */
object_class->get_property = get_property;
object_class->set_property = set_property;
bearer_class->connect = connect;
bearer_class->connect_finish = connect_finish;
bearer_class->disconnect = disconnect;
bearer_class->disconnect_finish = disconnect_finish;
properties[PROP_RM_PROTOCOL] =
g_param_spec_enum (MM_BEARER_CDMA_RM_PROTOCOL,
"Rm Protocol",
"Protocol to use in the Rm interface",
MM_TYPE_MODEM_CDMA_RM_PROTOCOL,
MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_RM_PROTOCOL, properties[PROP_RM_PROTOCOL]);
}

61
src/mm-bearer-cdma.h Normal file
View File

@@ -0,0 +1,61 @@
/* -*- 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: Aleksander Morgado <aleksander@lanedo.com>
*
* Copyright (C) 2012 Google, Inc.
*/
#ifndef MM_BEARER_CDMA_H
#define MM_BEARER_CDMA_H
#include <glib.h>
#include <glib-object.h>
#include "mm-bearer.h"
#include "mm-base-modem.h"
#define MM_TYPE_BEARER_CDMA (mm_bearer_cdma_get_type ())
#define MM_BEARER_CDMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BEARER_CDMA, MMBearerCdma))
#define MM_BEARER_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BEARER_CDMA, MMBearerCdmaClass))
#define MM_IS_BEARER_CDMA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BEARER_CDMA))
#define MM_IS_BEARER_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BEARER_CDMA))
#define MM_BEARER_CDMA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BEARER_CDMA, MMBearerCdmaClass))
#define MM_BEARER_CDMA_RM_PROTOCOL "bearer-cdma-rm-protocol"
/* Prefix for all CDMA bearer object paths */
#define MM_DBUS_BEARER_CDMA_PREFIX MM_DBUS_BEARER_PREFIX "/CDMA"
typedef struct _MMBearerCdma MMBearerCdma;
typedef struct _MMBearerCdmaClass MMBearerCdmaClass;
typedef struct _MMBearerCdmaPrivate MMBearerCdmaPrivate;
struct _MMBearerCdma {
MMBearer parent;
MMBearerCdmaPrivate *priv;
};
struct _MMBearerCdmaClass {
MMBearerClass parent;
};
GType mm_bearer_cdma_get_type (void);
/* Default CDMA bearer creation implementation */
MMBearer *mm_bearer_cdma_new (MMBaseModem *modem,
MMCommonBearerProperties *properties,
GError **error);
guint mm_bearer_cdma_get_rm_protocol (MMBearerCdma *self);
#endif /* MM_BEARER_CDMA_H */