diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/anydata/mm-plugin-anydata.c | 60 | ||||
-rw-r--r-- | plugins/cinterion/mm-plugin-cinterion.c | 61 | ||||
-rw-r--r-- | plugins/generic/mm-plugin-generic.c | 80 | ||||
-rw-r--r-- | plugins/gobi/mm-plugin-gobi.c | 63 | ||||
-rw-r--r-- | plugins/iridium/mm-plugin-iridium.c | 65 | ||||
-rw-r--r-- | plugins/linktop/mm-plugin-linktop.c | 64 | ||||
-rw-r--r-- | plugins/motorola/mm-plugin-motorola.c | 63 | ||||
-rw-r--r-- | plugins/nokia/mm-plugin-nokia.c | 73 | ||||
-rw-r--r-- | plugins/novatel/mm-plugin-novatel.c | 58 | ||||
-rw-r--r-- | plugins/option/mm-plugin-hso.c | 57 | ||||
-rw-r--r-- | plugins/option/mm-plugin-option.c | 63 | ||||
-rw-r--r-- | plugins/simtech/mm-plugin-simtech.c | 61 | ||||
-rw-r--r-- | plugins/wavecom/mm-plugin-wavecom.c | 62 |
14 files changed, 335 insertions, 497 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 04678693..5c571671 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -37,9 +37,9 @@ udevrules_DATA = pkglib_LTLIBRARIES = \ libmm-plugin-generic.la \ + libmm-plugin-nokia.la \ libmm-plugin-cinterion.la \ libmm-plugin-iridium.la \ - libmm-plugin-nokia.la \ libmm-plugin-gobi.la \ libmm-plugin-motorola.la \ libmm-plugin-novatel.la \ diff --git a/plugins/anydata/mm-plugin-anydata.c b/plugins/anydata/mm-plugin-anydata.c index 4a8cec4d..9d7304e7 100644 --- a/plugins/anydata/mm-plugin-anydata.c +++ b/plugins/anydata/mm-plugin-anydata.c @@ -32,46 +32,33 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_anydata_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; - const gchar *name, *subsys; - guint16 vendor = 0, product = 0; - - 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_anydata_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_probe_get_port_type (probe), - MM_AT_PORT_FLAG_NONE, - error)) { - if (modem) - g_object_unref (modem); - return NULL; - } - - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + mm_port_probe_get_port_type (probe), + MM_AT_PORT_FLAG_NONE, + error); } /*****************************************************************************/ @@ -102,5 +89,6 @@ mm_plugin_anydata_class_init (MMPluginAnydataClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/cinterion/mm-plugin-cinterion.c b/plugins/cinterion/mm-plugin-cinterion.c index e712d692..8ecdac3e 100644 --- a/plugins/cinterion/mm-plugin-cinterion.c +++ b/plugins/cinterion/mm-plugin-cinterion.c @@ -17,7 +17,7 @@ * Boston, MA 02111-1307, USA. * * Copyright (C) 2011 Ammonit Measurement GmbH - * Copyright (C) 2011 Google Inc. + * Copyright (C) 2011 - 2012 Google Inc. * Author: Aleksander Morgado <aleksander@lanedo.com> */ @@ -36,14 +36,27 @@ int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_cinterion_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; - const gchar *name, *subsys, *driver; - guint16 vendor = 0, product = 0; /* The Cinterion plugin cannot do anything with non-AT ports */ if (!mm_port_probe_is_at (probe)) { @@ -51,38 +64,15 @@ grab_port (MMPluginBase *base, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, "Ignoring non-AT port"); - return NULL; - } - - subsys = mm_port_probe_get_port_subsys (probe); - name = mm_port_probe_get_port_name (probe); - driver = mm_port_probe_get_port_driver (probe); - - /* Try to get Product IDs from udev. Note that it is not an error - * if we can't get them in our case, as we also support serial - * modems. */ - mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product); - - /* If this is the first port being grabbed, create a new modem object */ - if (!existing) - modem = MM_BASE_MODEM (mm_broadband_modem_cinterion_new (mm_port_probe_get_port_physdev (probe), - driver, - 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 FALSE; } - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + MM_PORT_TYPE_AT, /* we only allow AT ports here */ + MM_AT_PORT_FLAG_NONE, + error); } /*****************************************************************************/ @@ -114,5 +104,6 @@ mm_plugin_cinterion_class_init (MMPluginCinterionClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/generic/mm-plugin-generic.c b/plugins/generic/mm-plugin-generic.c index 02430838..844e7856 100644 --- a/plugins/generic/mm-plugin-generic.c +++ b/plugins/generic/mm-plugin-generic.c @@ -40,19 +40,27 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - GUdevDevice *port; - MMBaseModem *modem = NULL; - const gchar *name, *subsys, *devfile, *driver; - guint16 vendor = 0, product = 0; - - subsys = mm_port_probe_get_port_subsys (probe); - name = mm_port_probe_get_port_name (probe); - /* The generic plugin cannot do anything with non-AT and non-QCDM ports */ if (!mm_port_probe_is_at (probe) && !mm_port_probe_is_qcdm (probe)) { @@ -60,54 +68,15 @@ grab_port (MMPluginBase *base, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, "Ignoring non-AT/non-QCDM ports"); - return NULL; - } - - driver = mm_port_probe_get_port_driver (probe); - port = mm_port_probe_get_port (probe); - - /* Check device file of the port, we expect one */ - devfile = g_udev_device_get_device_file (port); - if (!devfile) { - if (!driver || !g_str_equal (driver, "bluetooth")) { - g_set_error (error, - MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Could not get port's sysfs file."); - return NULL; - } - - mm_warn ("%s: (%s/%s) WARNING: missing udev 'device' file", - mm_plugin_get_name (MM_PLUGIN (base)), - subsys, - name); - } - - /* Vendor and Product IDs are really optional, we'll just warn if they - * cannot get loaded */ - if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) - mm_warn ("Could not get modem vendor/product ID"); - - /* If this is the first port being grabbed, create a new modem object */ - if (!existing) - modem = MM_BASE_MODEM (mm_broadband_modem_new (mm_port_probe_get_port_physdev (probe), - driver, - mm_plugin_get_name (MM_PLUGIN (base)), - vendor, - product)); - - if (!mm_base_modem_grab_port (existing ? existing : modem, - subsys, - name, - mm_port_probe_get_port_type (probe), - MM_AT_PORT_FLAG_NONE, - error)) { - if (modem) - g_object_unref (modem); - return NULL; + return FALSE; } - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + mm_port_probe_get_port_type (probe), + MM_AT_PORT_FLAG_NONE, + error); } /*****************************************************************************/ @@ -136,5 +105,6 @@ mm_plugin_generic_class_init (MMPluginGenericClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/gobi/mm-plugin-gobi.c b/plugins/gobi/mm-plugin-gobi.c index 690b5210..cb47d58d 100644 --- a/plugins/gobi/mm-plugin-gobi.c +++ b/plugins/gobi/mm-plugin-gobi.c @@ -30,56 +30,42 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_gobi_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; - const gchar *name, *subsys, *driver; - guint16 vendor = 0, product = 0; - /* The Gobi plugin only handles AT and QCDM ports (for now) */ if (!mm_port_probe_is_at (probe) && !mm_port_probe_is_qcdm (probe)) { g_set_error_literal (error, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, "Ignoring non-AT/non-QCDM port"); - return NULL; - } - - subsys = mm_port_probe_get_port_subsys (probe); - name = mm_port_probe_get_port_name (probe); - driver = mm_port_probe_get_port_driver (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_gobi_new (mm_port_probe_get_port_physdev (probe), - driver, - mm_plugin_get_name (MM_PLUGIN (base)), - vendor, - product)); - - if (!mm_base_modem_grab_port (existing ? existing : modem, - subsys, - name, - mm_port_probe_get_port_type (probe), - MM_AT_PORT_FLAG_NONE, - error)) { - if (modem) - g_object_unref (modem); - return NULL; + return FALSE; } - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + mm_port_probe_get_port_type (probe), + MM_AT_PORT_FLAG_NONE, + error); } /*****************************************************************************/ @@ -110,5 +96,6 @@ mm_plugin_gobi_class_init (MMPluginGobiClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/iridium/mm-plugin-iridium.c b/plugins/iridium/mm-plugin-iridium.c index 1bfaf522..eb881876 100644 --- a/plugins/iridium/mm-plugin-iridium.c +++ b/plugins/iridium/mm-plugin-iridium.c @@ -16,11 +16,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * -<<<<<<< HEAD - * Copyright (C) 2011 Ammonit Measurement GmbH -======= * Copyright (C) 2011 - 2012 Ammonit Measurement GmbH ->>>>>>> 4ce461e... iridium: start porting the Iridium plugin to the '06-api' codebase * Author: Aleksander Morgado <aleksander@lanedo.com> */ @@ -40,54 +36,42 @@ int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_iridium_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; - const gchar *name, *subsys, *driver; - guint16 vendor = 0, product = 0; - /* The Iridium 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; - } - - subsys = mm_port_probe_get_port_subsys (probe); - name = mm_port_probe_get_port_name (probe); - driver = mm_port_probe_get_port_driver (probe); - - /* Try to get Product IDs from udev. Note that it is not an error - * if we can't get them in our case, as we also support serial - * modems. */ - mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product); - - /* If this is the first port being grabbed, create a new modem object */ - if (!existing) - modem = MM_BASE_MODEM (mm_broadband_modem_iridium_new ( - mm_port_probe_get_port_physdev (probe), - driver, - 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 FALSE; } - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + MM_PORT_TYPE_AT, /* we only allow AT ports here */ + MM_AT_PORT_FLAG_NONE, + error); } /*****************************************************************************/ @@ -123,5 +107,6 @@ mm_plugin_iridium_class_init (MMPluginIridiumClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/linktop/mm-plugin-linktop.c b/plugins/linktop/mm-plugin-linktop.c index 69a8e881..e05a2697 100644 --- a/plugins/linktop/mm-plugin-linktop.c +++ b/plugins/linktop/mm-plugin-linktop.c @@ -30,15 +30,29 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_linktop_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; GUdevDevice *port; - const gchar *name, *subsys, *devfile; - guint16 vendor = 0, product = 0; + const gchar *devfile; /* The Linktop plugin cannot do anything with non-AT ports */ if (!mm_port_probe_is_at (probe)) { @@ -46,7 +60,7 @@ grab_port (MMPluginBase *base, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, "Ignoring non-AT port"); - return NULL; + return FALSE; } port = mm_port_probe_get_port (probe); /* transfer none */ @@ -55,40 +69,15 @@ grab_port (MMPluginBase *base, 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 FALSE; } - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + MM_PORT_TYPE_AT, /* we only allow AT ports here */ + MM_AT_PORT_FLAG_NONE, + error); } /*****************************************************************************/ @@ -118,5 +107,6 @@ mm_plugin_linktop_class_init (MMPluginLinktopClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/motorola/mm-plugin-motorola.c b/plugins/motorola/mm-plugin-motorola.c index ed26430f..f6db862a 100644 --- a/plugins/motorola/mm-plugin-motorola.c +++ b/plugins/motorola/mm-plugin-motorola.c @@ -32,56 +32,42 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_motorola_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; - const gchar *name, *subsys; - guint16 vendor = 0, product = 0; - /* The Motorola 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; - } - - 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_motorola_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 FALSE; } - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + MM_PORT_TYPE_AT, /* we only allow AT ports here */ + MM_AT_PORT_FLAG_NONE, + error); } /*****************************************************************************/ @@ -115,5 +101,6 @@ mm_plugin_motorola_class_init (MMPluginMotorolaClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/nokia/mm-plugin-nokia.c b/plugins/nokia/mm-plugin-nokia.c index 7aa102b0..56b649bd 100644 --- a/plugins/nokia/mm-plugin-nokia.c +++ b/plugins/nokia/mm-plugin-nokia.c @@ -12,7 +12,7 @@ * * Copyright (C) 2008 - 2009 Novell, Inc. * Copyright (C) 2009 - 2011 Red Hat, Inc. - * Copyright (C) 2011 Google, Inc. + * Copyright (C) 2011 - 2012 Google, Inc. */ #include <string.h> @@ -42,38 +42,40 @@ static const MMPortProbeAtCommand custom_init[] = { /*****************************************************************************/ static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_nokia_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; GUdevDevice *port; - const gchar *name, *subsys, *driver; - guint16 vendor = 0, product = 0; MMAtPortFlag pflags = MM_AT_PORT_FLAG_NONE; - /* The Nokia plugin cannot do anything with non-AT ports */ + /* The Nokia plugin cannot do anything with non-AT */ 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; + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_UNSUPPORTED, + "Ignoring non-AT port"); + return FALSE; } port = mm_port_probe_get_port (probe); /* transfer none */ - subsys = mm_port_probe_get_port_subsys (probe); - name = mm_port_probe_get_port_name (probe); - driver = mm_port_probe_get_port_driver (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; - } /* Look for port type hints */ if (g_udev_device_get_property_as_boolean (port, "ID_MM_NOKIA_PORT_TYPE_MODEM")) @@ -81,26 +83,12 @@ grab_port (MMPluginBase *base, else if (g_udev_device_get_property_as_boolean (port, "ID_MM_NOKIA_PORT_TYPE_AUX")) pflags = MM_AT_PORT_FLAG_SECONDARY; - /* If this is the first port being grabbed, create a new modem object */ - if (!existing) - modem = MM_BASE_MODEM (mm_broadband_modem_nokia_new (mm_port_probe_get_port_physdev (probe), - driver, - 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 */ - pflags, - error)) { - if (modem) - g_object_unref (modem); - return NULL; - } - - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + mm_port_probe_get_port_type (probe), + pflags, + error); } /*****************************************************************************/ @@ -131,5 +119,6 @@ mm_plugin_nokia_class_init (MMPluginNokiaClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/novatel/mm-plugin-novatel.c b/plugins/novatel/mm-plugin-novatel.c index de3fcbf2..a4a0c5ab 100644 --- a/plugins/novatel/mm-plugin-novatel.c +++ b/plugins/novatel/mm-plugin-novatel.c @@ -34,49 +34,40 @@ int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_novatel_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; - const gchar *name, *subsys, *driver; - guint16 vendor = 0, product = 0; - /* The Novatel plugin uses AT and net ports */ if (!mm_port_probe_is_at (probe) && !g_str_equal (mm_port_probe_get_port_subsys (probe), "net")) { g_set_error (error, 0, 0, "Ignoring non-AT/net port"); - return NULL; - } - - subsys = mm_port_probe_get_port_subsys (probe); - name = mm_port_probe_get_port_name (probe); - driver = mm_port_probe_get_port_driver (probe); - - /* Try to get Product IDs from udev. */ - mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product); - - /* If this is the first port being grabbed, create a new modem object */ - if (!existing) - modem = MM_BASE_MODEM (mm_broadband_modem_novatel_new (mm_port_probe_get_port_physdev (probe), - driver, - mm_plugin_get_name (MM_PLUGIN (base)), - vendor, - product)); - - if (!mm_base_modem_grab_port (existing ? existing : modem, - subsys, - name, - mm_port_probe_get_port_type (probe), - MM_AT_PORT_FLAG_NONE, - error)) { - if (modem) - g_object_unref (modem); - return NULL; + return FALSE; } - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + mm_port_probe_get_port_type (probe), + MM_AT_PORT_FLAG_NONE, + error); } /*****************************************************************************/ @@ -107,5 +98,6 @@ mm_plugin_novatel_class_init (MMPluginNovatelClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/option/mm-plugin-hso.c b/plugins/option/mm-plugin-hso.c index bc04265d..2aa98fdd 100644 --- a/plugins/option/mm-plugin-hso.c +++ b/plugins/option/mm-plugin-hso.c @@ -33,15 +33,29 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_hso_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; GUdevDevice *port; const gchar *name, *subsys, *sysfs_path; - guint16 vendor = 0, product = 0; MMAtPortFlag pflags = MM_AT_PORT_FLAG_NONE; gchar *devfile; MMPortType port_type; @@ -50,14 +64,6 @@ grab_port (MMPluginBase *base, 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; - } - /* Build proper devfile path * TODO: Why do we need to do this? If this is useful, a comment should be * added explaining why; if it's not useful, let's get rid of it. */ @@ -79,7 +85,7 @@ grab_port (MMPluginBase *base, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Could not get port's sysfs file."); - return NULL; + return FALSE; } } g_free (devfile); @@ -110,26 +116,12 @@ grab_port (MMPluginBase *base, g_free (hsotype_path); } - /* If this is the first port being grabbed, create a new modem object */ - if (!existing) - modem = MM_BASE_MODEM (mm_broadband_modem_hso_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, - port_type, - pflags, - error)) { - if (modem) - g_object_unref (modem); - return NULL; - } - - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + subsys, + name, + port_type, + pflags, + error); } /*****************************************************************************/ @@ -160,5 +152,6 @@ mm_plugin_hso_class_init (MMPluginHsoClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/option/mm-plugin-option.c b/plugins/option/mm-plugin-option.c index 24aed6c0..771cb7b3 100644 --- a/plugins/option/mm-plugin-option.c +++ b/plugins/option/mm-plugin-option.c @@ -32,16 +32,29 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_option_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; - GUdevDevice *port; - const gchar *name, *subsys, *driver; - guint16 vendor = 0, product = 0; MMAtPortFlag pflags = MM_AT_PORT_FLAG_NONE; + GUdevDevice *port; gint usbif; /* The Option plugin cannot do anything with non-AT ports */ @@ -50,21 +63,10 @@ grab_port (MMPluginBase *base, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, "Ignoring non-AT port"); - return NULL; + return FALSE; } port = mm_port_probe_get_port (probe); /* transfer none */ - subsys = mm_port_probe_get_port_subsys (probe); - name = mm_port_probe_get_port_name (probe); - driver = mm_port_probe_get_port_driver (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; - } /* Genuine Option NV devices are always supposed to use USB interface 0 as * the modem/data port, per mail with Option engineers. Only this port @@ -74,26 +76,12 @@ grab_port (MMPluginBase *base, if (usbif == 0) pflags = MM_AT_PORT_FLAG_PRIMARY | MM_AT_PORT_FLAG_PPP; - /* If this is the first port being grabbed, create a new modem object */ - if (!existing) - modem = MM_BASE_MODEM (mm_broadband_modem_option_new (mm_port_probe_get_port_physdev (probe), - driver, - 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 */ - pflags, - error)) { - if (modem) - g_object_unref (modem); - return NULL; - } - - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + MM_PORT_TYPE_AT, /* we only allow AT ports here */ + pflags, + error); } /*****************************************************************************/ @@ -129,5 +117,6 @@ mm_plugin_option_class_init (MMPluginOptionClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/simtech/mm-plugin-simtech.c b/plugins/simtech/mm-plugin-simtech.c index 963da478..7f3bc21a 100644 --- a/plugins/simtech/mm-plugin-simtech.c +++ b/plugins/simtech/mm-plugin-simtech.c @@ -27,20 +27,32 @@ G_DEFINE_TYPE (MMPluginSimtech, mm_plugin_simtech, MM_TYPE_PLUGIN_BASE) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; - /*****************************************************************************/ static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_simtech_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; GUdevDevice *port; MMPortType ptype; - const gchar *name, *subsys; - guint16 vendor = 0, product = 0; MMAtPortFlag pflags = MM_AT_PORT_FLAG_NONE; /* The Simtech plugin cannot do anything with non-AT non-QCDM ports */ @@ -50,20 +62,10 @@ grab_port (MMPluginBase *base, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, "Ignoring non-AT non-QCDM port"); - return NULL; + return FALSE; } port = mm_port_probe_get_port (probe); /* transfer none */ - 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; - } /* Look for port type hints; just probing can't distinguish which port should * be the data/primary port on these devices. We have to tag them based on @@ -84,26 +86,12 @@ grab_port (MMPluginBase *base, else ptype = mm_port_probe_get_port_type (probe); - /* If this is the first port being grabbed, create a new modem object */ - if (!existing) - modem = MM_BASE_MODEM (mm_broadband_modem_simtech_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, - ptype, - pflags, - error)) { - if (modem) - g_object_unref (modem); - return NULL; - } - - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + ptype, + pflags, + error); } /*****************************************************************************/ @@ -135,5 +123,6 @@ mm_plugin_simtech_class_init (MMPluginSimtechClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } diff --git a/plugins/wavecom/mm-plugin-wavecom.c b/plugins/wavecom/mm-plugin-wavecom.c index d83f96ee..a3e71b26 100644 --- a/plugins/wavecom/mm-plugin-wavecom.c +++ b/plugins/wavecom/mm-plugin-wavecom.c @@ -38,55 +38,42 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * +create_modem (MMPluginBase *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_wavecom_new (sysfs_path, + driver, + mm_plugin_get_name (MM_PLUGIN (plugin)), + vendor, + product)); +} + +static gboolean grab_port (MMPluginBase *base, - MMBaseModem *existing, + MMBaseModem *modem, MMPortProbe *probe, GError **error) { - MMBaseModem *modem = NULL; - const gchar *name, *subsys; - guint16 vendor = 0, product = 0; - /* The Wavecom 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; - } - - 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_wavecom_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 FALSE; } - return existing ? existing : modem; + return mm_base_modem_grab_port (modem, + mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe), + MM_PORT_TYPE_AT, /* we only allow AT ports here */ + MM_AT_PORT_FLAG_NONE, + error); } /*****************************************************************************/ @@ -116,5 +103,6 @@ mm_plugin_wavecom_class_init (MMPluginWavecomClass *klass) { MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + pb_class->create_modem = create_modem; pb_class->grab_port = grab_port; } |