aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Makefile.am12
-rw-r--r--plugins/mm-modem-huawei.c230
-rw-r--r--plugins/mm-modem-huawei.h32
-rw-r--r--plugins/mm-plugin-huawei.c371
-rw-r--r--plugins/mm-plugin-huawei.h32
-rw-r--r--src/mm-generic-gsm.c43
-rw-r--r--src/mm-generic-gsm.h6
7 files changed, 514 insertions, 212 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 49457c34..3b2bca37 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -66,16 +66,20 @@ libmm_plugin_gobi_la_LDFLAGS = \
# Huawei
libmm_plugin_huawei_la_SOURCES = \
- mm-modem-huawei.c \
- mm-modem-huawei.h \
mm-plugin-huawei.c \
- mm-plugin-huawei.h
+ mm-plugin-huawei.h \
+ mm-modem-huawei.c \
+ mm-modem-huawei.h
libmm_plugin_huawei_la_CPPFLAGS = \
$(MM_CFLAGS) \
+ $(GUDEV_CFLAGS) \
-I$(top_srcdir)/src
-libmm_plugin_huawei_la_LDFLAGS = -module -avoid-version
+libmm_plugin_huawei_la_LDFLAGS = \
+ $(GUDEV_LDFLAGS) \
+ -module \
+ -avoid-version
# HSO
diff --git a/plugins/mm-modem-huawei.c b/plugins/mm-modem-huawei.c
index 2e6b5151..5ddfae18 100644
--- a/plugins/mm-modem-huawei.c
+++ b/plugins/mm-modem-huawei.c
@@ -1,12 +1,31 @@
/* -*- 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 Red Hat, Inc.
+ */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+
+#define G_UDEV_API_IS_SUBJECT_TO_CHANGE
+#include <gudev/gudev.h>
+
#include "mm-modem-huawei.h"
#include "mm-modem-gsm-network.h"
#include "mm-errors.h"
#include "mm-callback-info.h"
+#include "mm-serial-port.h"
#include "mm-serial-parsers.h"
static gpointer mm_modem_huawei_parent_class = NULL;
@@ -14,8 +33,6 @@ static gpointer mm_modem_huawei_parent_class = NULL;
#define MM_MODEM_HUAWEI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_MODEM_HUAWEI, MMModemHuaweiPrivate))
typedef struct {
- MMSerial *monitor_device;
-
/* Cached state */
guint signal_quality;
MMModemGsmNetworkMode mode;
@@ -23,20 +40,18 @@ typedef struct {
} MMModemHuaweiPrivate;
MMModem *
-mm_modem_huawei_new (const char *data_device,
- const char *monitor_device,
- const char *driver)
+mm_modem_huawei_new (const char *device,
+ const char *driver,
+ const char *plugin)
{
- g_return_val_if_fail (data_device != NULL, NULL);
- g_return_val_if_fail (monitor_device != NULL, NULL);
+ g_return_val_if_fail (device != NULL, NULL);
g_return_val_if_fail (driver != NULL, NULL);
+ g_return_val_if_fail (plugin != NULL, NULL);
return MM_MODEM (g_object_new (MM_TYPE_MODEM_HUAWEI,
- MM_SERIAL_DEVICE, monitor_device,
- MM_MODEM_DEVICE, data_device,
- MM_SERIAL_CARRIER_DETECT, FALSE,
+ MM_MODEM_MASTER_DEVICE, device,
MM_MODEM_DRIVER, driver,
- MM_MODEM_TYPE, MM_MODEM_TYPE_GSM,
+ MM_MODEM_PLUGIN, plugin,
NULL));
}
@@ -80,24 +95,26 @@ parse_syscfg (MMModemHuawei *self,
}
static void
-set_network_mode_done (MMSerial *serial,
+set_network_mode_done (MMSerialPort *port,
GString *response,
GError *error,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
+ MMModemHuawei *self = MM_MODEM_HUAWEI (info->modem);
+ MMModemHuaweiPrivate *priv = MM_MODEM_HUAWEI_GET_PRIVATE (self);
if (error)
info->error = g_error_copy (error);
else
/* Success, cache the value */
- MM_MODEM_HUAWEI_GET_PRIVATE (serial)->mode = GPOINTER_TO_UINT (mm_callback_info_get_data (info, "mode"));
+ priv->mode = GPOINTER_TO_UINT (mm_callback_info_get_data (info, "mode"));
mm_callback_info_schedule (info);
}
static void
-set_network_mode_get_done (MMSerial *serial,
+set_network_mode_get_done (MMSerialPort *port,
GString *response,
GError *error,
gpointer user_data)
@@ -111,7 +128,7 @@ set_network_mode_get_done (MMSerial *serial,
int a, b, u1, u2;
guint32 band;
- if (parse_syscfg (MM_MODEM_HUAWEI (serial), response->str, &a, &b, &band, &u1, &u2)) {
+ if (parse_syscfg (MM_MODEM_HUAWEI (info->modem), response->str, &a, &b, &band, &u1, &u2)) {
char *command;
switch (GPOINTER_TO_UINT (mm_callback_info_get_data (info, "mode"))) {
@@ -142,7 +159,7 @@ set_network_mode_get_done (MMSerial *serial,
}
command = g_strdup_printf ("AT^SYSCFG=%d,%d,%X,%d,%d", a, b, band, u1, u2);
- mm_serial_queue_command (serial, command, 3, set_network_mode_done, info);
+ mm_serial_port_queue_command (port, command, 3, set_network_mode_done, info);
g_free (command);
}
}
@@ -155,6 +172,7 @@ set_network_mode (MMModemGsmNetwork *modem,
gpointer user_data)
{
MMCallbackInfo *info;
+ MMSerialPort *primary;
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
@@ -174,9 +192,10 @@ set_network_mode (MMModemGsmNetwork *modem,
case MM_MODEM_GSM_NETWORK_MODE_3G_ONLY:
/* Allowed values */
mm_callback_info_set_data (info, "mode", GUINT_TO_POINTER (mode), NULL);
- mm_serial_queue_command (MM_SERIAL (modem), "AT^SYSCFG?", 3, set_network_mode_get_done, info);
+ primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_SERIAL_PORT_TYPE_PRIMARY);
+ g_assert (primary);
+ mm_serial_port_queue_command (primary, "AT^SYSCFG?", 3, set_network_mode_get_done, info);
return;
- break;
default:
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL, "Invalid mode.");
break;
@@ -186,19 +205,21 @@ set_network_mode (MMModemGsmNetwork *modem,
}
static void
-get_network_mode_done (MMSerial *serial,
+get_network_mode_done (MMSerialPort *port,
GString *response,
GError *error,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
+ MMModemHuawei *self = MM_MODEM_HUAWEI (info->modem);
+ MMModemHuaweiPrivate *priv = MM_MODEM_HUAWEI_GET_PRIVATE (self);
int mode_a, mode_b, u1, u2;
guint32 band;
if (error)
info->error = g_error_copy (error);
- else if (parse_syscfg (MM_MODEM_HUAWEI (serial), response->str, &mode_a, &mode_b, &band, &u1, &u2))
- mm_callback_info_set_result (info, GUINT_TO_POINTER (MM_MODEM_HUAWEI_GET_PRIVATE (serial)->mode), NULL);
+ else if (parse_syscfg (self, response->str, &mode_a, &mode_b, &band, &u1, &u2))
+ mm_callback_info_set_result (info, GUINT_TO_POINTER (priv->mode), NULL);
mm_callback_info_schedule (info);
}
@@ -220,36 +241,42 @@ get_network_mode (MMModemGsmNetwork *modem,
} else {
/* Get it from modem */
MMCallbackInfo *info;
+ MMSerialPort *primary;
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
- mm_serial_queue_command (MM_SERIAL (modem), "AT^SYSCFG?", 3, get_network_mode_done, info);
+ primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_SERIAL_PORT_TYPE_PRIMARY);
+ g_assert (primary);
+ mm_serial_port_queue_command (primary, "AT^SYSCFG?", 3, get_network_mode_done, info);
}
}
static void
-set_band_done (MMSerial *serial,
+set_band_done (MMSerialPort *port,
GString *response,
GError *error,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
+ MMModemHuawei *self = MM_MODEM_HUAWEI (info->modem);
+ MMModemHuaweiPrivate *priv = MM_MODEM_HUAWEI_GET_PRIVATE (self);
if (error)
info->error = g_error_copy (error);
else
/* Success, cache the value */
- MM_MODEM_HUAWEI_GET_PRIVATE (serial)->band = GPOINTER_TO_UINT (mm_callback_info_get_data (info, "band"));
+ priv->band = GPOINTER_TO_UINT (mm_callback_info_get_data (info, "band"));
mm_callback_info_schedule (info);
}
static void
-set_band_get_done (MMSerial *serial,
+set_band_get_done (MMSerialPort *port,
GString *response,
GError *error,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
+ MMModemHuawei *self = MM_MODEM_HUAWEI (info->modem);
if (error) {
info->error = g_error_copy (error);
@@ -258,7 +285,7 @@ set_band_get_done (MMSerial *serial,
int a, b, u1, u2;
guint32 band;
- if (parse_syscfg (MM_MODEM_HUAWEI (serial), response->str, &a, &b, &band, &u1, &u2)) {
+ if (parse_syscfg (self, response->str, &a, &b, &band, &u1, &u2)) {
char *command;
switch (GPOINTER_TO_UINT (mm_callback_info_get_data (info, "band"))) {
@@ -278,7 +305,7 @@ set_band_get_done (MMSerial *serial,
}
command = g_strdup_printf ("AT^SYSCFG=%d,%d,%X,%d,%d", a, b, band, u1, u2);
- mm_serial_queue_command (serial, command, 3, set_band_done, info);
+ mm_serial_port_queue_command (port, command, 3, set_band_done, info);
g_free (command);
}
}
@@ -291,6 +318,7 @@ set_band (MMModemGsmNetwork *modem,
gpointer user_data)
{
MMCallbackInfo *info;
+ MMSerialPort *primary;
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
@@ -301,29 +329,34 @@ set_band (MMModemGsmNetwork *modem,
case MM_MODEM_GSM_NETWORK_BAND_U2100:
case MM_MODEM_GSM_NETWORK_BAND_PCS:
mm_callback_info_set_data (info, "band", GUINT_TO_POINTER (band), NULL);
- mm_serial_queue_command (MM_SERIAL (modem), "AT^SYSCFG?", 3, set_band_get_done, info);
- break;
+ primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_SERIAL_PORT_TYPE_PRIMARY);
+ g_assert (primary);
+ mm_serial_port_queue_command (primary, "AT^SYSCFG?", 3, set_band_get_done, info);
+ return;
default:
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL, "Invalid band.");
- mm_callback_info_schedule (info);
break;
}
+
+ mm_callback_info_schedule (info);
}
static void
-get_band_done (MMSerial *serial,
+get_band_done (MMSerialPort *port,
GString *response,
GError *error,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
+ MMModemHuawei *self = MM_MODEM_HUAWEI (info->modem);
+ MMModemHuaweiPrivate *priv = MM_MODEM_HUAWEI_GET_PRIVATE (self);
int mode_a, mode_b, u1, u2;
guint32 band;
if (error)
info->error = g_error_copy (error);
- else if (parse_syscfg (MM_MODEM_HUAWEI (serial), response->str, &mode_a, &mode_b, &band, &u1, &u2))
- mm_callback_info_set_result (info, GUINT_TO_POINTER (MM_MODEM_HUAWEI_GET_PRIVATE (serial)->band), NULL);
+ else if (parse_syscfg (self, response->str, &mode_a, &mode_b, &band, &u1, &u2))
+ mm_callback_info_set_result (info, GUINT_TO_POINTER (priv->band), NULL);
mm_callback_info_schedule (info);
}
@@ -334,6 +367,7 @@ get_band (MMModemGsmNetwork *modem,
gpointer user_data)
{
MMModemHuaweiPrivate *priv = MM_MODEM_HUAWEI_GET_PRIVATE (modem);
+ MMSerialPort *primary;
if (priv->band != MM_MODEM_GSM_NETWORK_BAND_ANY) {
/* have cached mode (from an unsolicited message). Use that */
@@ -347,7 +381,9 @@ get_band (MMModemGsmNetwork *modem,
MMCallbackInfo *info;
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
- mm_serial_queue_command (MM_SERIAL (modem), "AT^SYSCFG?", 3, get_band_done, info);
+ primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_SERIAL_PORT_TYPE_PRIMARY);
+ g_assert (primary);
+ mm_serial_port_queue_command (primary, "AT^SYSCFG?", 3, get_band_done, info);
}
}
@@ -377,10 +413,12 @@ get_signal_quality (MMModemGsmNetwork *modem,
/* Unsolicited message handlers */
static void
-handle_signal_quality_change (MMSerial *serial,
+handle_signal_quality_change (MMSerialPort *port,
GMatchInfo *match_info,
gpointer user_data)
{
+ MMModemHuawei *self = MM_MODEM_HUAWEI (user_data);
+ MMModemHuaweiPrivate *priv = MM_MODEM_HUAWEI_GET_PRIVATE (self);
char *str;
int quality;
@@ -396,16 +434,17 @@ handle_signal_quality_change (MMSerial *serial,
quality = quality * 100 / 31;
g_debug ("Signal quality: %d", quality);
- MM_MODEM_HUAWEI_GET_PRIVATE (serial)->signal_quality = (guint32) quality;
- mm_modem_gsm_network_signal_quality (MM_MODEM_GSM_NETWORK (serial), (guint32) quality);
+ priv->signal_quality = (guint32) quality;
+ mm_modem_gsm_network_signal_quality (MM_MODEM_GSM_NETWORK (self), (guint32) quality);
}
static void
-handle_mode_change (MMSerial *serial,
+handle_mode_change (MMSerialPort *port,
GMatchInfo *match_info,
gpointer user_data)
{
- MMModemHuaweiPrivate *priv = MM_MODEM_HUAWEI_GET_PRIVATE (serial);
+ MMModemHuawei *self = MM_MODEM_HUAWEI (user_data);
+ MMModemHuaweiPrivate *priv = MM_MODEM_HUAWEI_GET_PRIVATE (self);
char *str;
int a;
int b;
@@ -436,11 +475,11 @@ handle_mode_change (MMSerial *serial,
}
g_debug ("Mode: %d", priv->mode);
- mm_modem_gsm_network_mode (MM_MODEM_GSM_NETWORK (serial), priv->mode);
+ mm_modem_gsm_network_mode (MM_MODEM_GSM_NETWORK (self), priv->mode);
}
static void
-handle_status_change (MMSerial *serial,
+handle_status_change (MMSerialPort *port,
GMatchInfo *match_info,
gpointer user_data)
{
@@ -457,6 +496,91 @@ handle_status_change (MMSerial *serial,
/*****************************************************************************/
+static gboolean
+grab_port (MMModem *modem,
+ const char *subsys,
+ const char *name,
+ GError **error)
+{
+ MMGenericGsm *gsm = MM_GENERIC_GSM (modem);
+ MMSerialPortType ptype = MM_SERIAL_PORT_TYPE_IGNORED;
+ const char *sys[] = { "tty", NULL };
+ GUdevClient *client;
+ GUdevDevice *device = NULL;
+ MMSerialPort *port = NULL;
+ int usbif;
+
+ client = g_udev_client_new (sys);
+ if (!client) {
+ g_set_error (error, 0, 0, "Could not get udev client.");
+ return FALSE;
+ }
+
+ device = g_udev_client_query_by_subsystem_and_name (client, subsys, name);
+ if (!device) {
+ g_set_error (error, 0, 0, "Could not get udev device.");
+ goto out;
+ }
+
+ usbif = g_udev_device_get_property_as_int (device, "ID_USB_INTERFACE_NUM");
+ if (usbif < 0) {
+ g_set_error (error, 0, 0, "Could not get USB device interface number.");
+ goto out;
+ }
+
+ if (usbif == 0) {
+ if (!mm_generic_gsm_get_port (gsm, MM_SERIAL_PORT_TYPE_PRIMARY))
+ ptype = MM_SERIAL_PORT_TYPE_PRIMARY;
+ } else if (usbif == 1) {
+ if (!mm_generic_gsm_get_port (gsm, MM_SERIAL_PORT_TYPE_SECONDARY))
+ ptype = MM_SERIAL_PORT_TYPE_SECONDARY;
+ }
+
+ port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
+ if (!port)
+ goto out;
+
+ if (ptype == MM_SERIAL_PORT_TYPE_PRIMARY) {
+ g_object_set (G_OBJECT (port), MM_SERIAL_PORT_CARRIER_DETECT, FALSE, NULL);
+ } else if (ptype == MM_SERIAL_PORT_TYPE_SECONDARY) {
+ GRegex *regex;
+
+ g_object_set (G_OBJECT (port), MM_SERIAL_PORT_CARRIER_DETECT, FALSE, NULL);
+
+ mm_generic_gsm_set_unsolicited_registration (MM_GENERIC_GSM (modem), TRUE);
+
+ regex = g_regex_new ("\\r\\n\\^RSSI:(\\d+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
+ mm_serial_port_add_unsolicited_msg_handler (port, regex, handle_signal_quality_change, modem, NULL);
+ g_regex_unref (regex);
+
+ regex = g_regex_new ("\\r\\n\\^MODE:(\\d),(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
+ mm_serial_port_add_unsolicited_msg_handler (port, regex, handle_mode_change, modem, NULL);
+ g_regex_unref (regex);
+
+ regex = g_regex_new ("\\r\\n\\^DSFLOWRPT:(.+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
+ mm_serial_port_add_unsolicited_msg_handler (port, regex, handle_status_change, modem, NULL);
+ g_regex_unref (regex);
+
+ regex = g_regex_new ("\\r\\n\\^BOOT:.+\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
+ mm_serial_port_add_unsolicited_msg_handler (port, regex, NULL, modem, NULL);
+ g_regex_unref (regex);
+ }
+
+out:
+ if (device)
+ g_object_unref (device);
+ g_object_unref (client);
+ return !!port;
+}
+
+/*****************************************************************************/
+
+static void
+modem_init (MMModem *modem_class)
+{
+ modem_class->grab_port = grab_port;
+}
+
static void
modem_gsm_network_init (MMModemGsmNetwork *class)
{
@@ -470,25 +594,6 @@ modem_gsm_network_init (MMModemGsmNetwork *class)
static void
mm_modem_huawei_init (MMModemHuawei *self)
{
- GRegex *regex;
-
- mm_generic_gsm_set_unsolicited_registration (MM_GENERIC_GSM (self), TRUE);
-
- regex = g_regex_new ("\\r\\n\\^RSSI:(\\d+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
- mm_serial_add_unsolicited_msg_handler (MM_SERIAL (self), regex, handle_signal_quality_change, NULL, NULL);
- g_regex_unref (regex);
-
- regex = g_regex_new ("\\r\\n\\^MODE:(\\d),(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
- mm_serial_add_unsolicited_msg_handler (MM_SERIAL (self), regex, handle_mode_change, NULL, NULL);
- g_regex_unref (regex);
-
- regex = g_regex_new ("\\r\\n\\^DSFLOWRPT:(.+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
- mm_serial_add_unsolicited_msg_handler (MM_SERIAL (self), regex, handle_status_change, NULL, NULL);
- g_regex_unref (regex);
-
- regex = g_regex_new ("\\r\\n\\^BOOT:.+\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
- mm_serial_add_unsolicited_msg_handler (MM_SERIAL (self), regex, NULL, NULL, NULL);
- g_regex_unref (regex);
}
static void
@@ -518,11 +623,16 @@ mm_modem_huawei_get_type (void)
(GInstanceInitFunc) mm_modem_huawei_init,
};
+ static const GInterfaceInfo modem_iface_info = {
+ (GInterfaceInitFunc) modem_init
+ };
+
static const GInterfaceInfo modem_gsm_network_info = {
(GInterfaceInitFunc) modem_gsm_network_init
};
modem_huawei_type = g_type_register_static (MM_TYPE_GENERIC_GSM, "MMModemHuawei", &modem_huawei_type_info, 0);
+ g_type_add_interface_static (modem_huawei_type, MM_TYPE_MODEM, &modem_iface_info);
g_type_add_interface_static (modem_huawei_type, MM_TYPE_MODEM_GSM_NETWORK, &modem_gsm_network_info);
}
diff --git a/plugins/mm-modem-huawei.h b/plugins/mm-modem-huawei.h
index f5154690..16ac99a8 100644
--- a/plugins/mm-modem-huawei.h
+++ b/plugins/mm-modem-huawei.h
@@ -1,16 +1,30 @@
/* -*- 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 Red Hat, Inc.
+ */
#ifndef MM_MODEM_HUAWEI_H
#define MM_MODEM_HUAWEI_H
#include "mm-generic-gsm.h"
-#define MM_TYPE_MODEM_HUAWEI (mm_modem_huawei_get_type ())
-#define MM_MODEM_HUAWEI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_HUAWEI, MMModemHuawei))
-#define MM_MODEM_HUAWEI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_HUAWEI, MMModemHuaweiClass))
-#define MM_IS_MODEM_HUAWEI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_HUAWEI))
-#define MM_IS_MODEM_HUAWEI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_MODEM_HUAWEI))
-#define MM_MODEM_HUAWEI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_HUAWEI, MMModemHuaweiClass))
+#define MM_TYPE_MODEM_HUAWEI (mm_modem_huawei_get_type ())
+#define MM_MODEM_HUAWEI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_HUAWEI, MMModemHuawei))
+#define MM_MODEM_HUAWEI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_HUAWEI, MMModemHuaweiClass))
+#define MM_IS_MODEM_HUAWEI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_HUAWEI))
+#define MM_IS_MODEM_HUAWEI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_MODEM_HUAWEI))
+#define MM_MODEM_HUAWEI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_HUAWEI, MMModemHuaweiClass))
typedef struct {
MMGenericGsm parent;
@@ -22,8 +36,8 @@ typedef struct {
GType mm_modem_huawei_get_type (void);
-MMModem *mm_modem_huawei_new (const char *data_device,
- const char *monitor_device,
- const char *driver);
+MMModem *mm_modem_huawei_new (const char *device,
+ const char *driver,
+ const char *plugin);
#endif /* MM_MODEM_HUAWEI_H */
diff --git a/plugins/mm-plugin-huawei.c b/plugins/mm-plugin-huawei.c
index 206fa7b5..46b10534 100644
--- a/plugins/mm-plugin-huawei.c
+++ b/plugins/mm-plugin-huawei.c
@@ -1,18 +1,44 @@
/* -*- 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 Red Hat, Inc.
+ */
#include <string.h>
#include <gmodule.h>
+
+#define G_UDEV_API_IS_SUBJECT_TO_CHANGE
+#include <gudev/gudev.h>
+
#include "mm-plugin-huawei.h"
+#include "mm-generic-gsm.h"
#include "mm-modem-huawei.h"
static void plugin_init (MMPlugin *plugin_class);
-G_DEFINE_TYPE_EXTENDED (MMPluginHuawei, mm_plugin_huawei, G_TYPE_OBJECT,
+G_DEFINE_TYPE_EXTENDED (MMPluginHuawei, mm_plugin_huawei, MM_TYPE_PLUGIN_BASE,
0, G_IMPLEMENT_INTERFACE (MM_TYPE_PLUGIN, plugin_init))
int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
+#define MM_PLUGIN_HUAWEI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_PLUGIN_HUAWEI, MMPluginHuaweiPrivate))
+
+typedef struct {
+ GUdevClient *client;
+} MMPluginHuaweiPrivate;
+
+
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
@@ -21,107 +47,180 @@ mm_plugin_create (void)
/*****************************************************************************/
-static const char *
-get_name (MMPlugin *plugin)
+/* From hostap, Copyright (c) 2002-2005, Jouni Malinen <jkmaline@cc.hut.fi> */
+
+static int hex2num (char c)
{
- return "Huawei";
+ if (c >= '0' && c <= '9')
+ return c - '0';
+ if (c >= 'a' && c <= 'f')
+ return c - 'a' + 10;
+ if (c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+ return -1;
}
-static char **
-list_supported_udis (MMPlugin *plugin, LibHalContext *hal_ctx)
+static int hex2byte (const char *hex)
{
- char **supported = NULL;
- char **devices;
- int num_devices;
- int i;
+ int a, b;
+ a = hex2num(*hex++);
+ if (a < 0)
+ return -1;
+ b = hex2num(*hex++);
+ if (b < 0)
+ return -1;
+ return (a << 4) | b;
+}
- devices = libhal_find_device_by_capability (hal_ctx, "modem", &num_devices, NULL);
- if (devices) {
- GPtrArray *array;
+/* End from hostap */
- array = g_ptr_array_new ();
+static gboolean
+get_ids (GUdevDevice *device, guint32 *vendor, guint32 *product)
+{
+ const char *vid, *pid;
- for (i = 0; i < num_devices; i++) {
- char *udi = devices[i];
+ g_return_val_if_fail (device != NULL, FALSE);
- if (mm_plugin_supports_udi (plugin, hal_ctx, udi))
- g_ptr_array_add (array, g_strdup (udi));
- }
+ vid = g_udev_device_get_property (device, "ID_VENDOR_ID");
+ if (!vid || (strlen (vid) != 4))
+ return FALSE;
- if (array->len > 0) {
- g_ptr_array_add (array, NULL);
- supported = (char **) g_ptr_array_free (array, FALSE);
- } else
- g_ptr_array_free (array, TRUE);
+ if (vendor) {
+ *vendor = (guint32) (hex2byte (vid + 2) & 0xFF);
+ *vendor |= (guint32) ((hex2byte (vid) & 0xFF) << 8);
}
- g_strfreev (devices);
+ pid = g_udev_device_get_property (device, "ID_MODEL_ID");
+ if (!pid || (strlen (pid) != 4))
+ return FALSE;
- return supported;
+ if (product) {
+ *product = (guint32) (hex2byte (pid + 2) & 0xFF);
+ *product |= (guint32) ((hex2byte (pid) & 0xFF) << 8);
+ }
+
+ return TRUE;
}
-static int
-get_product (LibHalContext *hal_ctx, const char *udi)
+static char *
+get_driver_name (GUdevDevice *device)
{
- char *parent_udi;
- int product = 0;
-
- parent_udi = libhal_device_get_property_string (hal_ctx, udi, "info.parent", NULL);
- if (parent_udi) {
- product = libhal_device_get_property_int (hal_ctx, parent_udi, "usb.product_id", NULL);
- libhal_free_string (parent_udi);
+ GUdevDevice *parent = NULL;
+ const char *driver;
+ char *ret;
+
+ driver = g_udev_device_get_driver (device);
+ if (!driver) {
+ parent = g_udev_device_get_parent (device);
+ if (parent)
+ driver = g_udev_device_get_driver (parent);
}
- return product;
+ if (driver)
+ ret = g_strdup (driver);
+ if (parent)
+ g_object_unref (parent);
+
+ return ret;
}
-static gboolean
-supports_udi (MMPlugin *plugin, LibHalContext *hal_ctx, const char *udi)
+static GUdevDevice *
+find_physical_device (GUdevDevice *child)
{
- char **capabilities;
- char **iter;
- gboolean supported = FALSE;
+ GUdevDevice *iter, *old = NULL;
+ const char *bus, *type;
- capabilities = libhal_device_get_property_strlist (hal_ctx, udi, "modem.command_sets", NULL);
- for (iter = capabilities; iter && *iter && !supported; iter++) {
- if (!strcmp (*iter, "GSM-07.07")) {
- char *parent_udi;
+ g_return_val_if_fail (child != NULL, NULL);
- parent_udi = libhal_device_get_property_string (hal_ctx, udi, "info.parent", NULL);
- if (parent_udi) {
- int vendor;
- int product;
+ bus = g_udev_device_get_property (child, "ID_BUS");
+ if (!bus)
+ return NULL;
- vendor = libhal_device_get_property_int (hal_ctx, parent_udi, "usb.vendor_id", NULL);
- product = get_product (hal_ctx, udi);
+ if (strcmp (bus, "usb"))
+ return NULL;
- if (vendor == 0x12d1 && (product == 0x1001 || product == 0x1003 || product == 0x1004))
- supported = TRUE;
+ /* Walk the parents to find the 'usb_device' for this device. */
+ iter = g_object_ref (child);
+ while (iter) {
+ type = g_udev_device_get_devtype (iter);
+ if (type && !strcmp (type, "usb_device"))
+ return iter;
- libhal_free_string (parent_udi);
- }
- }
+ old = iter;
+ iter = g_udev_device_get_parent (old);
+ g_object_unref (old);
}
- g_strfreev (capabilities);
+ g_object_unref (child);
- return supported;
+ return NULL;
}
-static char *
-get_driver_name (LibHalContext *ctx, const char *udi)
+#define PROP_GSM "ID_MM_MODEM_GSM"
+
+static GUdevDevice *
+get_device (GUdevClient *client,
+ const char *subsys,
+ const char *name,
+ GUdevDevice **physdev)
{
- char *parent_udi;
- char *driver = NULL;
+ GUdevDevice *device;
+ const char *tmp;
+
+ /* Can't do anything with non-serial ports */
+ if (strcmp (subsys, "tty"))
+ return NULL;
+
+ device = g_udev_client_query_by_subsystem_and_name (client, subsys, name);
+ if (!device)
+ return NULL;
+
+ tmp = g_udev_device_get_property (device, "ID_BUS");
+ if (!tmp || strcmp (tmp, "usb"))
+ goto error;
+
+ if (!g_udev_device_get_property_as_boolean (device, PROP_GSM))
+ goto error;
+
+ *physdev = find_physical_device (device);
+ if (*physdev)
+ return device;
+
+error:
+ g_object_unref (device);
+ return NULL;
+}
- parent_udi = libhal_device_get_property_string (ctx, udi, "info.parent", NULL);
- if (parent_udi) {
- driver = libhal_device_get_property_string (ctx, parent_udi, "info.linux.driver", NULL);
- libhal_free_string (parent_udi);
- }
+static guint32
+supports_port (MMPlugin *plugin,
+ const char *subsys,
+ const char *name)
+{
+ MMPluginHuaweiPrivate *priv = MM_PLUGIN_HUAWEI_GET_PRIVATE (plugin);
+ GUdevDevice *device, *physdev = NULL;
+ guint32 level = 0;
+ guint32 vendor = 0, product = 0;
+
+ device = get_device (priv->client, subsys, name, &physdev);
+ if (!device)
+ goto out;
+ g_object_unref (physdev);
+
+ if (!get_ids (device, &vendor, &product))
+ goto out;
+
+ if (vendor != 0x12d1)
+ goto out;
+
+ if (product == 0x1001 || product == 0x1003 || product == 0x1004)
+ level = 10;
- return driver;
+out:
+ if (device)
+ g_object_unref (device);
+ return level;
}
+#if 0
static char *
find_second_port (LibHalContext *ctx, const char *parent)
{
@@ -142,66 +241,94 @@ find_second_port (LibHalContext *ctx, const char *parent)
return second_port;
}
+#endif
-static char *
-get_monitor_device (LibHalContext *ctx, const char *udi)
+static MMModem *
+grab_port (MMPlugin *plugin,
+ const char *subsys,
+ const char *name,
+ GError **error)
{
- char *parent;
- char *grand_parent;
- char **uncles;
- char *monitor_device = NULL;
- int num_uncles = 0;
- int i;
+ MMPluginHuawei *self = MM_PLUGIN_HUAWEI (plugin);
+ MMPluginHuaweiPrivate *priv = MM_PLUGIN_HUAWEI_GET_PRIVATE (plugin);
+ GUdevDevice *device = NULL, *physdev = NULL;
+ const char *devfile, *sysfs_path;
+ char *driver = NULL;
+ MMModem *modem = NULL;
+ guint32 product = 0;
- parent = libhal_device_get_property_string (ctx, udi, "info.parent", NULL);
- grand_parent = libhal_device_get_property_string (ctx, parent, "info.parent", NULL);
+ g_return_val_if_fail (subsys != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
- /* Find "uncles" */
- uncles = libhal_manager_find_device_string_match (ctx, "info.parent", grand_parent, &num_uncles, NULL);
- for (i = 0; i < num_uncles && monitor_device == NULL; i++) {
- const char *uncle = uncles[i];
+ device = get_device (priv->client, subsys, name, &physdev);
+ if (!device)
+ goto out;
- /* Ignore "dad" */
- if (strcmp (uncle, parent))
- monitor_device = find_second_port (ctx, uncle);
+ devfile = g_udev_device_get_device_file (device);
+ if (!devfile) {
+ g_set_error (error, 0, 0, "Could not get port's sysfs file.");
+ goto out;
}
- libhal_free_string_array (uncles);
- libhal_free_string (parent);
- libhal_free_string (grand_parent);
-
- return monitor_device;
-}
+ driver = get_driver_name (device);
+ if (!driver) {
+ g_set_error (error, 0, 0, "Could not get port's driver name.");
+ goto out;
+ }
-static MMModem *
-create_modem (MMPlugin *plugin, LibHalContext *hal_ctx, const char *udi)
-{
- char *data_device;
- char *monitor_device;
- char *driver;
- MMModem *modem;
+ sysfs_path = g_udev_device_get_sysfs_path (physdev);
+ if (!devfile) {
+ g_set_error (error, 0, 0, "Could not get port's physical device sysfs path.");
+ goto out;
+ }
- data_device = libhal_device_get_property_string (hal_ctx, udi, "serial.device", NULL);
- g_return_val_if_fail (data_device != NULL, NULL);
+ if (!get_ids (device, NULL, &product)) {
+ g_set_error (error, 0, 0, "Could not get modem product ID.");
+ goto out;
+ }
- driver = get_driver_name (hal_ctx, udi);
- g_return_val_if_fail (driver != NULL, NULL);
+ modem = mm_plugin_base_find_modem (MM_PLUGIN_BASE (self), sysfs_path);
+ if (!modem) {
+ if (product == 0x1001) {
+ /* This modem is handled by generic GSM driver */
+ modem = mm_generic_gsm_new (sysfs_path,
+ driver,
+ mm_plugin_get_name (plugin));
+ } else {
+ modem = mm_modem_huawei_new (sysfs_path,
+ driver,
+ mm_plugin_get_name (plugin));
+ }
- if (get_product (hal_ctx, udi) == 0x1001) {
- /* This modem is handled by generic GSM device */
- modem = mm_generic_gsm_new (data_device, driver);
+ if (modem) {
+ if (!mm_modem_grab_port (modem, subsys, name, error)) {
+g_message ("%s: couldn't grab port", __func__);
+ g_object_unref (modem);
+ modem = NULL;
+ goto out;
+ }
+ mm_plugin_base_add_modem (MM_PLUGIN_BASE (self), modem);
+ }
} else {
- monitor_device = get_monitor_device (hal_ctx, udi);
- modem = mm_modem_huawei_new (data_device, monitor_device, driver);
- libhal_free_string (monitor_device);
+ if (!mm_modem_grab_port (modem, subsys, name, error))
+ modem = NULL;
}
- libhal_free_string (data_device);
- libhal_free_string (driver);
-
+out:
+ g_free (driver);
+ g_object_unref (device);
+ g_object_unref (physdev);
+g_message ("%s: port %s / %s modem %p", __func__, subsys, name, modem);
return modem;
}
+static const char *
+get_name (MMPlugin *plugin)
+{
+ return "Huawei";
+}
+
+
/*****************************************************************************/
static void
@@ -209,17 +336,33 @@ plugin_init (MMPlugin *plugin_class)
{
/* interface implementation */
plugin_class->get_name = get_name;
- plugin_class->list_supported_udis = list_supported_udis;
- plugin_class->supports_udi = supports_udi;
- plugin_class->create_modem = create_modem;
+ plugin_class->supports_port = supports_port;
+ plugin_class->grab_port = grab_port;
}
static void
mm_plugin_huawei_init (MMPluginHuawei *self)
{
+ MMPluginHuaweiPrivate *priv = MM_PLUGIN_HUAWEI_GET_PRIVATE (self);
+ const char *subsys[2] = { "tty", NULL };
+
+ priv->client = g_udev_client_new (subsys);
+}
+
+static void
+dispose (GObject *object)
+{
+ MMPluginHuaweiPrivate *priv = MM_PLUGIN_HUAWEI_GET_PRIVATE (object);
+
+ g_object_unref (priv->client);
}
static void
mm_plugin_huawei_class_init (MMPluginHuaweiClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof (MMPluginHuaweiPrivate));
+
+ object_class->dispose = dispose;
}
diff --git a/plugins/mm-plugin-huawei.h b/plugins/mm-plugin-huawei.h
index e37a3a7a..de9294c4 100644
--- a/plugins/mm-plugin-huawei.h
+++ b/plugins/mm-plugin-huawei.h
@@ -1,24 +1,38 @@
/* -*- 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 Red Hat, Inc.
+ */
#ifndef MM_PLUGIN_HUAWEI_H
#define MM_PLUGIN_HUAWEI_H
#include "mm-plugin.h"
-#include "mm-generic-gsm.h"
+#include "mm-plugin-base.h"
-#define MM_TYPE_PLUGIN_HUAWEI (mm_plugin_huawei_get_type ())
-#define MM_PLUGIN_HUAWEI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_HUAWEI, MMPluginHuawei))
-#define MM_PLUGIN_HUAWEI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_HUAWEI, MMPluginHuaweiClass))
-#define MM_IS_PLUGIN_HUAWEI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_HUAWEI))
-#define MM_IS_PLUGIN_HUAWEI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_HUAWEI))
-#define MM_PLUGIN_HUAWEI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_HUAWEI, MMPluginHuaweiClass))
+#define MM_TYPE_PLUGIN_HUAWEI (mm_plugin_huawei_get_type ())
+#define MM_PLUGIN_HUAWEI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_HUAWEI, MMPluginHuawei))
+#define MM_PLUGIN_HUAWEI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_HUAWEI, MMPluginHuaweiClass))
+#define MM_IS_PLUGIN_HUAWEI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_HUAWEI))
+#define MM_IS_PLUGIN_HUAWEI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_HUAWEI))
+#define MM_PLUGIN_HUAWEI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_HUAWEI, MMPluginHuaweiClass))
typedef struct {
- GObject parent;
+ MMPluginBase parent;
} MMPluginHuawei;
typedef struct {
- GObjectClass parent;
+ MMPluginBaseClass parent;
} MMPluginHuaweiClass;
GType mm_plugin_huawei_get_type (void);
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index 0a5ee92b..842ae22b 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -207,25 +207,19 @@ owns_port (MMModem *modem, const char *subsys, const char *name)
return !!mm_serial_get_port (MM_SERIAL (self), name);
}
-static gboolean
-grab_port (MMModem *modem,
- const char *subsys,
- const char *name,
- GError **error)
+MMSerialPort *
+mm_generic_gsm_grab_port (MMGenericGsm *self,
+ const char *subsys,
+ const char *name,
+ MMSerialPortType ptype,
+ GError **error)
{
- MMGenericGsm *self = MM_GENERIC_GSM (modem);
MMGenericGsmPrivate *priv = MM_GENERIC_GSM_GET_PRIVATE (self);
- MMSerialPortType ptype = MM_SERIAL_PORT_TYPE_IGNORED;
- MMSerialPort *port;
+ MMSerialPort *port = NULL;
GRegex *regex;
if (strcmp (subsys, "tty"))
- return FALSE;
-
- if (!priv->primary)
- ptype = MM_SERIAL_PORT_TYPE_PRIMARY;
- else if (!priv->secondary)
- ptype = MM_SERIAL_PORT_TYPE_SECONDARY;
+ return NULL;
port = mm_serial_add_port (MM_SERIAL (self), name, ptype);
mm_serial_port_set_response_parser (port,
@@ -237,7 +231,6 @@ grab_port (MMModem *modem,
mm_serial_port_add_unsolicited_msg_handler (port, regex, reg_state_changed, self, NULL);
g_regex_unref (regex);
-
if (ptype == MM_SERIAL_PORT_TYPE_PRIMARY) {
priv->primary = port;
g_object_notify (G_OBJECT (self), MM_MODEM_DATA_DEVICE);
@@ -245,7 +238,25 @@ grab_port (MMModem *modem,
} else if (ptype == MM_SERIAL_PORT_TYPE_SECONDARY)
priv->secondary = port;
- return TRUE;
+ return port;
+}
+
+static gboolean
+grab_port (MMModem *modem,
+ const char *subsys,
+ const char *name,
+ GError **error)
+{
+ MMGenericGsm *self = MM_GENERIC_GSM (modem);
+ MMGenericGsmPrivate *priv = MM_GENERIC_GSM_GET_PRIVATE (self);
+ MMSerialPortType ptype = MM_SERIAL_PORT_TYPE_IGNORED;
+
+ if (!priv->primary)
+ ptype = MM_SERIAL_PORT_TYPE_PRIMARY;
+ else if (!priv->secondary)
+ ptype = MM_SERIAL_PORT_TYPE_SECONDARY;
+
+ return !!mm_generic_gsm_grab_port (self, subsys, name, ptype, error);
}
static void
diff --git a/src/mm-generic-gsm.h b/src/mm-generic-gsm.h
index 4178ef1d..9efabe13 100644
--- a/src/mm-generic-gsm.h
+++ b/src/mm-generic-gsm.h
@@ -61,4 +61,10 @@ void mm_generic_gsm_check_pin (MMGenericGsm *modem,
MMSerialPort *mm_generic_gsm_get_port (MMGenericGsm *modem,
MMSerialPortType ptype);
+MMSerialPort *mm_generic_gsm_grab_port (MMGenericGsm *modem,
+ const char *subsys,
+ const char *name,
+ MMSerialPortType ptype,
+ GError **error);
+
#endif /* MM_GENERIC_GSM_H */