aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Makefile.am21
-rw-r--r--plugins/linktop/mm-broadband-modem-linktop.c238
-rw-r--r--plugins/linktop/mm-broadband-modem-linktop.h49
-rw-r--r--plugins/linktop/mm-plugin-linktop.c122
-rw-r--r--plugins/linktop/mm-plugin-linktop.h (renamed from plugins/mm-plugin-linktop.h)3
-rw-r--r--plugins/mm-modem-linktop.c193
-rw-r--r--plugins/mm-modem-linktop.h45
-rw-r--r--plugins/mm-plugin-linktop.c169
8 files changed, 422 insertions, 418 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 9c82135d..dab86033 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -41,7 +41,8 @@ pkglib_LTLIBRARIES = \
libmm-plugin-novatel.la \
libmm-plugin-option.la \
libmm-plugin-hso.la \
- libmm-plugin-anydata.la
+ libmm-plugin-anydata.la \
+ libmm-plugin-linktop.la
#pkglib_LTLIBRARIES = \
# libmm-plugin-generic.la \
@@ -201,6 +202,15 @@ libmm_plugin_anydata_la_SOURCES = \
libmm_plugin_anydata_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
libmm_plugin_anydata_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
+# Linktop CDMA
+libmm_plugin_linktop_la_SOURCES = \
+ linktop/mm-plugin-linktop.c \
+ linktop/mm-plugin-linktop.h \
+ linktop/mm-broadband-modem-linktop.h \
+ linktop/mm-broadband-modem-linktop.c
+libmm_plugin_linktop_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
+libmm_plugin_linktop_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
+
## SimTech
#libmm_plugin_simtech_la_SOURCES = \
# mm-plugin-simtech.c \
@@ -219,15 +229,6 @@ libmm_plugin_anydata_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
#libmm_plugin_x22x_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
#libmm_plugin_x22x_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
#
-## Linktop
-#libmm_plugin_linktop_la_SOURCES = \
-# mm-plugin-linktop.c \
-# mm-plugin-linktop.h \
-# mm-modem-linktop.c \
-# mm-modem-linktop.h
-#libmm_plugin_linktop_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
-#libmm_plugin_linktop_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
-#
## Samsung modem
#libmm_plugin_samsung_la_SOURCES = \
# mm-plugin-samsung.c \
diff --git a/plugins/linktop/mm-broadband-modem-linktop.c b/plugins/linktop/mm-broadband-modem-linktop.c
new file mode 100644
index 00000000..2c6aef57
--- /dev/null
+++ b/plugins/linktop/mm-broadband-modem-linktop.c
@@ -0,0 +1,238 @@
+/* -*- 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 - 2012 Red Hat, Inc.
+ * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org>
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+
+#include <libmm-common.h>
+
+#include "ModemManager.h"
+#include "mm-serial-parsers.h"
+#include "mm-log.h"
+#include "mm-modem-helpers.h"
+#include "mm-iface-modem.h"
+#include "mm-base-modem-at.h"
+#include "mm-broadband-modem-linktop.h"
+
+#define LINKTOP_MODE_ANY 1
+#define LINKTOP_MODE_2G 5
+#define LINKTOP_MODE_3G 6
+
+static void iface_modem_init (MMIfaceModem *iface);
+
+G_DEFINE_TYPE_EXTENDED (MMBroadbandModemLinktop, mm_broadband_modem_linktop, MM_TYPE_BROADBAND_MODEM, 0,
+ G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init));
+
+/*****************************************************************************/
+/* Load initial allowed/preferred modes (Modem interface) */
+
+static gboolean
+load_allowed_modes_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ MMModemMode *allowed,
+ MMModemMode *preferred,
+ GError **error)
+{
+ const gchar *response;
+ const gchar *str;
+ guint aux;
+
+ response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
+ if (!response)
+ return FALSE;
+
+ str = mm_strip_tag (response, "CFUN:");
+ if (!mm_get_uint_from_str (str, &aux)) {
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't parse CFUN? response: '%s'",
+ response);
+ return FALSE;
+ }
+
+ switch (aux) {
+ case LINKTOP_MODE_2G:
+ *allowed = MM_MODEM_MODE_2G;
+ *preferred = MM_MODEM_MODE_NONE;
+ break;
+
+ case LINKTOP_MODE_3G:
+ *allowed = MM_MODEM_MODE_3G;
+ *preferred = MM_MODEM_MODE_NONE;
+ break;
+
+ case LINKTOP_MODE_ANY:
+ *allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
+ *preferred = MM_MODEM_MODE_NONE;
+ break;
+
+ default:
+ *allowed = MM_MODEM_MODE_ANY;
+ *preferred = MM_MODEM_MODE_NONE;
+ break;
+ }
+
+ return TRUE;
+}
+
+static void
+load_allowed_modes (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ mm_base_modem_at_command (MM_BASE_MODEM (self),
+ "+CFUN?",
+ 3,
+ FALSE,
+ callback,
+ user_data);
+}
+
+/*****************************************************************************/
+/* Set allowed modes (Modem interface) */
+
+static gboolean
+set_allowed_modes_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
+}
+
+static void
+allowed_mode_update_ready (MMBroadbandModemLinktop *self,
+ GAsyncResult *res,
+ GSimpleAsyncResult *operation_result)
+{
+ GError *error = NULL;
+
+ mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
+ if (error)
+ /* Let the error be critical. */
+ g_simple_async_result_take_error (operation_result, error);
+ else
+ g_simple_async_result_set_op_res_gboolean (operation_result, TRUE);
+ g_simple_async_result_complete (operation_result);
+ g_object_unref (operation_result);
+}
+
+static void
+set_allowed_modes (MMIfaceModem *self,
+ MMModemMode allowed,
+ MMModemMode preferred,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+ gchar *command;
+ gint linktop_mode = -1;
+
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ set_allowed_modes);
+
+ /* There is no explicit config for CS connections, we just assume we may
+ * have them as part of 2G when no GPRS is available */
+ if (allowed & MM_MODEM_MODE_CS) {
+ allowed |= MM_MODEM_MODE_2G;
+ allowed &= ~MM_MODEM_MODE_CS;
+ }
+
+ if (allowed == MM_MODEM_MODE_2G)
+ linktop_mode = LINKTOP_MODE_2G;
+ else if (allowed == MM_MODEM_MODE_3G)
+ linktop_mode = LINKTOP_MODE_3G;
+ else if ((allowed == (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G)) &&
+ (preferred == MM_MODEM_MODE_NONE)) {
+ linktop_mode = LINKTOP_MODE_ANY;
+ }
+
+ if (linktop_mode < 0) {
+ gchar *allowed_str;
+ gchar *preferred_str;
+
+ allowed_str = mm_modem_mode_build_string_from_mask (allowed);
+ preferred_str = mm_modem_mode_build_string_from_mask (preferred);
+ g_simple_async_result_set_error (result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Requested mode (allowed: '%s', preferred: '%s') not "
+ "supported by the modem.",
+ allowed_str,
+ preferred_str);
+ g_free (allowed_str);
+ g_free (preferred_str);
+
+ g_simple_async_result_complete_in_idle (result);
+ g_object_unref (result);
+ return;
+ }
+
+ command = g_strdup_printf ("AT+CFUN=%d", linktop_mode);
+ mm_base_modem_at_command (
+ MM_BASE_MODEM (self),
+ command,
+ 3,
+ FALSE,
+ (GAsyncReadyCallback)allowed_mode_update_ready,
+ result);
+ g_free (command);
+}
+
+/*****************************************************************************/
+
+MMBroadbandModemLinktop *
+mm_broadband_modem_linktop_new (const gchar *device,
+ const gchar *driver,
+ const gchar *plugin,
+ guint16 vendor_id,
+ guint16 product_id)
+{
+ return g_object_new (MM_TYPE_BROADBAND_MODEM_LINKTOP,
+ 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_linktop_init (MMBroadbandModemLinktop *self)
+{
+}
+
+static void
+iface_modem_init (MMIfaceModem *iface)
+{
+ iface->load_allowed_modes = load_allowed_modes;
+ iface->load_allowed_modes_finish = load_allowed_modes_finish;
+ iface->set_allowed_modes = set_allowed_modes;
+ iface->set_allowed_modes_finish = set_allowed_modes_finish;
+}
+
+static void
+mm_broadband_modem_linktop_class_init (MMBroadbandModemLinktopClass *klass)
+{
+}
diff --git a/plugins/linktop/mm-broadband-modem-linktop.h b/plugins/linktop/mm-broadband-modem-linktop.h
new file mode 100644
index 00000000..dbc8a10d
--- /dev/null
+++ b/plugins/linktop/mm-broadband-modem-linktop.h
@@ -0,0 +1,49 @@
+/* -*- 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 - 2012 Red Hat, Inc.
+ * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org>
+ */
+
+#ifndef MM_BROADBAND_MODEM_LINKTOP_H
+#define MM_BROADBAND_MODEM_LINKTOP_H
+
+#include "mm-broadband-modem.h"
+
+#define MM_TYPE_BROADBAND_MODEM_LINKTOP (mm_broadband_modem_linktop_get_type ())
+#define MM_BROADBAND_MODEM_LINKTOP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_LINKTOP, MMBroadbandModemLinktop))
+#define MM_BROADBAND_MODEM_LINKTOP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_LINKTOP, MMBroadbandModemLinktopClass))
+#define MM_IS_BROADBAND_MODEM_LINKTOP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_LINKTOP))
+#define MM_IS_BROADBAND_MODEM_LINKTOP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_LINKTOP))
+#define MM_BROADBAND_MODEM_LINKTOP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_LINKTOP, MMBroadbandModemLinktopClass))
+
+typedef struct _MMBroadbandModemLinktop MMBroadbandModemLinktop;
+typedef struct _MMBroadbandModemLinktopClass MMBroadbandModemLinktopClass;
+
+struct _MMBroadbandModemLinktop {
+ MMBroadbandModem parent;
+};
+
+struct _MMBroadbandModemLinktopClass{
+ MMBroadbandModemClass parent;
+};
+
+GType mm_broadband_modem_linktop_get_type (void);
+
+MMBroadbandModemLinktop *mm_broadband_modem_linktop_new (const gchar *device,
+ const gchar *driver,
+ const gchar *plugin,
+ guint16 vendor_id,
+ guint16 product_id);
+
+#endif /* MM_BROADBAND_MODEM_LINKTOP_H */
diff --git a/plugins/linktop/mm-plugin-linktop.c b/plugins/linktop/mm-plugin-linktop.c
new file mode 100644
index 00000000..69a8e881
--- /dev/null
+++ b/plugins/linktop/mm-plugin-linktop.c
@@ -0,0 +1,122 @@
+/* -*- 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 - 2012 Red Hat, Inc.
+ * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org>
+ */
+
+#include <string.h>
+#include <gmodule.h>
+#include <libmm-common.h>
+
+#include "mm-plugin-linktop.h"
+#include "mm-broadband-modem-linktop.h"
+
+G_DEFINE_TYPE (MMPluginLinktop, mm_plugin_linktop, MM_TYPE_PLUGIN_BASE)
+
+int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
+int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
+
+/*****************************************************************************/
+
+static MMBaseModem *
+grab_port (MMPluginBase *base,
+ MMBaseModem *existing,
+ MMPortProbe *probe,
+ GError **error)
+{
+ MMBaseModem *modem = NULL;
+ GUdevDevice *port;
+ const gchar *name, *subsys, *devfile;
+ guint16 vendor = 0, product = 0;
+
+ /* The Linktop plugin cannot do anything with non-AT ports */
+ if (!mm_port_probe_is_at (probe)) {
+ g_set_error_literal (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_UNSUPPORTED,
+ "Ignoring non-AT port");
+ return NULL;
+ }
+
+ port = mm_port_probe_get_port (probe); /* transfer none */
+
+ /* TODO: Why do we check for device file? */
+ devfile = g_udev_device_get_device_file (port);
+ if (!devfile) {
+ g_set_error (error, 0, 0, "Could not get port's sysfs file.");
+ return NULL;
+ }
+
+ subsys = mm_port_probe_get_port_subsys (probe);
+ name = mm_port_probe_get_port_name (probe);
+
+ if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
+ g_set_error_literal (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Could not get modem product ID");
+ return NULL;
+ }
+
+ /* If this is the first port being grabbed, create a new modem object */
+ if (!existing)
+ modem = MM_BASE_MODEM (mm_broadband_modem_linktop_new (mm_port_probe_get_port_physdev (probe),
+ mm_port_probe_get_port_driver (probe),
+ mm_plugin_get_name (MM_PLUGIN (base)),
+ vendor,
+ product));
+
+ if (!mm_base_modem_grab_port (existing ? existing : modem,
+ subsys,
+ name,
+ MM_PORT_TYPE_AT, /* we only allow AT ports here */
+ MM_AT_PORT_FLAG_NONE,
+ error)) {
+ if (modem)
+ g_object_unref (modem);
+ return NULL;
+ }
+
+ return existing ? existing : modem;
+}
+
+/*****************************************************************************/
+
+G_MODULE_EXPORT MMPlugin *
+mm_plugin_create (void)
+{
+ static const gchar *subsystems[] = { "tty", NULL };
+ static const guint16 vendor_ids[] = { 0x230d, 0 };
+
+ return MM_PLUGIN (
+ g_object_new (MM_TYPE_PLUGIN_LINKTOP,
+ MM_PLUGIN_BASE_NAME, "Linktop",
+ MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems,
+ MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids,
+ MM_PLUGIN_BASE_ALLOWED_AT, TRUE,
+ NULL));
+}
+
+static void
+mm_plugin_linktop_init (MMPluginLinktop *self)
+{
+}
+
+static void
+mm_plugin_linktop_class_init (MMPluginLinktopClass *klass)
+{
+ MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
+
+ pb_class->grab_port = grab_port;
+}
diff --git a/plugins/mm-plugin-linktop.h b/plugins/linktop/mm-plugin-linktop.h
index b9047256..e4b68c41 100644
--- a/plugins/mm-plugin-linktop.h
+++ b/plugins/linktop/mm-plugin-linktop.h
@@ -11,7 +11,8 @@
* GNU General Public License for more details:
*
* Copyright (C) 2008 - 2009 Novell, Inc.
- * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2009 - 2012 Red Hat, Inc.
+ * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org>
*/
#ifndef MM_PLUGIN_LINKTOP_H
diff --git a/plugins/mm-modem-linktop.c b/plugins/mm-modem-linktop.c
deleted file mode 100644
index a263dd0a..00000000
--- a/plugins/mm-modem-linktop.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/* -*- 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>
-#include <unistd.h>
-#include "mm-modem-linktop.h"
-#include "mm-serial-parsers.h"
-#include "mm-errors.h"
-
-#define LINKTOP_NETWORK_MODE_ANY 1
-#define LINKTOP_NETWORK_MODE_2G 5
-#define LINKTOP_NETWORK_MODE_3G 6
-
-G_DEFINE_TYPE (MMModemLinktop, mm_modem_linktop, MM_TYPE_GENERIC_GSM)
-
-
-MMModem *
-mm_modem_linktop_new (const char *device,
- const char *driver,
- const char *plugin,
- guint32 vendor,
- guint32 product)
-{
- 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_LINKTOP,
- MM_MODEM_MASTER_DEVICE, device,
- MM_MODEM_DRIVER, driver,
- MM_MODEM_PLUGIN, plugin,
- MM_MODEM_HW_VID, vendor,
- MM_MODEM_HW_PID, product,
- NULL));
-}
-
-static void
-port_grabbed (MMGenericGsm *gsm,
- MMPort *port,
- MMAtPortFlags pflags,
- gpointer user_data)
-{
- if (MM_IS_AT_SERIAL_PORT (port)) {
- mm_at_serial_port_set_response_parser (MM_AT_SERIAL_PORT (port),
- mm_serial_parser_v1_e1_parse,
- mm_serial_parser_v1_e1_new (),
- mm_serial_parser_v1_e1_destroy);
- }
-}
-
-static int
-linktop_parse_allowed_mode (MMModemGsmAllowedMode network_mode)
-{
- switch (network_mode) {
- case MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY:
- return LINKTOP_NETWORK_MODE_2G;
- case MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY:
- return LINKTOP_NETWORK_MODE_3G;
- default:
- return LINKTOP_NETWORK_MODE_ANY;
- }
-}
-
-static void
-linktop_set_allowed_mode_done (MMAtSerialPort *port,
- GString *response,
- GError *error,
- gpointer user_data)
-{
- MMCallbackInfo *info = (MMCallbackInfo *) user_data;
-
- /* If the modem has already been removed, return without
- * scheduling callback */
- if (mm_callback_info_check_modem_removed (info))
- return;
-
- if (error)
- info->error = g_error_copy (error);
-
- mm_callback_info_schedule (info);
-}
-
-static void
-set_allowed_mode (MMGenericGsm *gsm,
- MMModemGsmAllowedMode mode,
- MMModemFn callback,
- gpointer user_data)
-{
- MMCallbackInfo *info;
- char *command;
- MMAtSerialPort *port;
-
- info = mm_callback_info_new (MM_MODEM (gsm), callback, user_data);
-
- port = mm_generic_gsm_get_best_at_port (gsm, &info->error);
- if (!port) {
- mm_callback_info_schedule (info);
- return;
- }
-
- command = g_strdup_printf ("+CFUN=%d", linktop_parse_allowed_mode (mode));
- mm_at_serial_port_queue_command (port, command, 3, linktop_set_allowed_mode_done, info);
- g_free (command);
-}
-
-static void
-get_allowed_mode_done (MMAtSerialPort *port,
- GString *response,
- GError *error,
- gpointer user_data)
-{
- MMCallbackInfo *info = (MMCallbackInfo *) user_data;
- gboolean parsed = FALSE;
-
- /* If the modem has already been removed, return without
- * scheduling callback */
- if (mm_callback_info_check_modem_removed (info))
- return;
-
- if (error)
- info->error = g_error_copy (error);
- else if (!g_str_has_prefix (response->str, "CFUN: ")) {
- MMModemGsmAllowedMode mode = MM_MODEM_GSM_ALLOWED_MODE_ANY;
- int a;
-
- a = atoi (response->str + 6);
- if (a == LINKTOP_NETWORK_MODE_2G)
- mode = MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY;
- else if (a == LINKTOP_NETWORK_MODE_3G)
- mode = MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY;
-
- mm_callback_info_set_result (info, GUINT_TO_POINTER (mode), NULL);
- parsed = TRUE;
- }
-
- if (!error && !parsed)
- info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
- "Could not parse allowed mode results");
-
- mm_callback_info_schedule (info);
-}
-
-static void
-get_allowed_mode (MMGenericGsm *gsm,
- MMModemUIntFn callback,
- gpointer user_data)
-{
- MMCallbackInfo *info;
- MMAtSerialPort *port;
-
- info = mm_callback_info_uint_new (MM_MODEM (gsm), callback, user_data);
-
- port = mm_generic_gsm_get_best_at_port (gsm, &info->error);
- if (!port) {
- mm_callback_info_schedule (info);
- return;
- }
-
- mm_at_serial_port_queue_command (port, "+CFUN?", 3, get_allowed_mode_done, info);
-}
-
-/*****************************************************************************/
-
-static void
-mm_modem_linktop_init (MMModemLinktop *self)
-{
-}
-
-static void
-mm_modem_linktop_class_init (MMModemLinktopClass *klass)
-{
- MMGenericGsmClass *gsm_class = MM_GENERIC_GSM_CLASS (klass);
-
- gsm_class->port_grabbed = port_grabbed;
- gsm_class->get_allowed_mode = get_allowed_mode;
- gsm_class->set_allowed_mode = set_allowed_mode;
-}
-
diff --git a/plugins/mm-modem-linktop.h b/plugins/mm-modem-linktop.h
deleted file mode 100644
index 4b7153ec..00000000
--- a/plugins/mm-modem-linktop.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- 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_LINKTOP_H
-#define MM_MODEM_LINKTOP_H
-
-#include "mm-generic-gsm.h"
-
-#define MM_TYPE_MODEM_LINKTOP (mm_modem_linktop_get_type ())
-#define MM_MODEM_LINKTOP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_LINKTOP, MMModemLinktop))
-#define MM_MODEM_LINKTOP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_LINKTOP, MMModemLinktopClass))
-#define MM_IS_MODEM_LINKTOP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_LINKTOP))
-#define MM_IS_MODEM_LINKTOP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_MODEM_LINKTOP))
-#define MM_MODEM_LINKTOP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_LINKTOP, MMModemLinktopClass))
-
-typedef struct {
- MMGenericGsm parent;
-} MMModemLinktop;
-
-typedef struct {
- MMGenericGsmClass parent;
-} MMModemLinktopClass;
-
-GType mm_modem_linktop_get_type (void);
-
-MMModem *mm_modem_linktop_new (const char *data,
- const char *driver,
- const char *plugin,
- guint32 vendor,
- guint32 product);
-
-#endif /* MM_MODEM_LINKTOP_H */
diff --git a/plugins/mm-plugin-linktop.c b/plugins/mm-plugin-linktop.c
deleted file mode 100644
index 874e355a..00000000
--- a/plugins/mm-plugin-linktop.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/* -*- 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>
-#include "mm-plugin-linktop.h"
-#include "mm-modem-linktop.h"
-
-G_DEFINE_TYPE (MMPluginLinktop, mm_plugin_linktop, MM_TYPE_PLUGIN_BASE)
-
-int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
-int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
-
-G_MODULE_EXPORT MMPlugin *
-mm_plugin_create (void)
-{
- return MM_PLUGIN (g_object_new (MM_TYPE_PLUGIN_LINKTOP,
- MM_PLUGIN_BASE_NAME, "Linktop",
- NULL));
-}
-
-/*****************************************************************************/
-
-static guint32
-get_level_for_capabilities (guint32 capabilities)
-{
- if (capabilities & MM_PLUGIN_BASE_PORT_CAP_GSM)
- return 10;
- return 0;
-}
-
-static void
-probe_result (MMPluginBase *base,
- MMPluginBaseSupportsTask *task,
- guint32 capabilities,
- gpointer user_data)
-{
- mm_plugin_base_supports_task_complete (task, get_level_for_capabilities (capabilities));
-}
-
-static MMPluginSupportsResult
-supports_port (MMPluginBase *base,
- MMModem *existing,
- MMPluginBaseSupportsTask *task)
-{
- GUdevDevice *port;
- const char *subsys, *name;
- guint16 vendor = 0;
-
- /* Can't do anything with non-serial ports */
- port = mm_plugin_base_supports_task_get_port (task);
- if (strcmp (g_udev_device_get_subsystem (port), "tty"))
- return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
-
- subsys = g_udev_device_get_subsystem (port);
- name = g_udev_device_get_name (port);
-
- if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, NULL))
- return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
-
- if (vendor != 0x230d)
- return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
-
- /* Check if a previous probing was already launched in this port */
- if (mm_plugin_base_supports_task_propagate_cached (task)) {
- guint32 level;
-
- /* A previous probing was already done, use its results */
- level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
- if (level) {
- mm_plugin_base_supports_task_complete (task, level);
- return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
- }
- return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
- }
-
- /* Otherwise kick off a probe */
- if (mm_plugin_base_probe_port (base, task, 100000, NULL))
- return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
-
- return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
-}
-
-static MMModem *
-grab_port (MMPluginBase *base,
- MMModem *existing,
- MMPluginBaseSupportsTask *task,
- GError **error)
-{
- GUdevDevice *port = NULL;
- MMModem *modem = NULL;
- const char *name, *subsys, *devfile, *sysfs_path;
- guint32 caps;
- guint16 vendor = 0, product = 0;
- MMPortType ptype;
-
- port = mm_plugin_base_supports_task_get_port (task);
- g_assert (port);
-
- devfile = g_udev_device_get_device_file (port);
- if (!devfile) {
- g_set_error (error, 0, 0, "Could not get port's sysfs file.");
- return NULL;
- }
-
- subsys = g_udev_device_get_subsystem (port);
- name = g_udev_device_get_name (port);
-
- if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
- g_set_error (error, 0, 0, "Could not get modem product ID.");
- return NULL;
- }
-
- caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
- ptype = mm_plugin_base_probed_capabilities_to_port_type (caps);
- sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
- if (!existing) {
- if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
- modem = mm_modem_linktop_new (sysfs_path,
- mm_plugin_base_supports_task_get_driver (task),
- mm_plugin_get_name (MM_PLUGIN (base)),
- vendor,
- product);
- }
-
- if (modem) {
- if (!mm_modem_grab_port (modem, subsys, name, ptype, MM_AT_PORT_FLAG_NONE, NULL, error)) {
- g_object_unref (modem);
- return NULL;
- }
- }
- } else if (get_level_for_capabilities (caps)) {
- modem = existing;
- if (!mm_modem_grab_port (modem, subsys, name, ptype, MM_AT_PORT_FLAG_NONE, NULL, error))
- return NULL;
- }
-
- return modem;
-}
-
-/*****************************************************************************/
-
-static void
-mm_plugin_linktop_init (MMPluginLinktop *self)
-{
- g_signal_connect (self, "probe-result", G_CALLBACK (probe_result), NULL);
-}
-
-static void
-mm_plugin_linktop_class_init (MMPluginLinktopClass *klass)
-{
- MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
-
- pb_class->supports_port = supports_port;
- pb_class->grab_port = grab_port;
-}