diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-10 11:15:23 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-08-06 20:06:45 +0200 |
commit | e5e46f489e9d89bdecb4c4948b0d9627e33555cc (patch) | |
tree | 4b8e1b316787b0a7e1346a1bd6930c293639171f | |
parent | 7e9d3e4b685f0e92979af2f595be6cd336b5dbd6 (diff) |
core: merge `MMPluginBase' and `MMPlugin'
There's no real point in maintaining a separate `MMPlugin' interface, as all the
plugins will inherit from `MMPluginBase', so just merge them and simplify
everything.
33 files changed, 1352 insertions, 1584 deletions
@@ -91,10 +91,6 @@ example to update the signal quality value or check registration status. - MMModem (instead of MMBaseModem), MMModemBroadband, MMModemPots - MMBearer, MMBearerBroadband, MMBearerPots - ** MMPlugin: do we really need a separate interface for the plugin? Why not - just assume that all plugins need to provide objects subclassing - MMPluginBase? - ** Test cases for CIEV responses. ** When a modem gets initialized for the first time it goes into DISABLED, but diff --git a/docs/reference/api/ModemManager-overview.xml b/docs/reference/api/ModemManager-overview.xml index 55dbca49..dee7b5ae 100644 --- a/docs/reference/api/ModemManager-overview.xml +++ b/docs/reference/api/ModemManager-overview.xml @@ -99,8 +99,8 @@ launched as requested by the given plugin. </para> <para> - This filter is specified by the <type>MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS</type> - property in the <structname>MMPluginBase</structname> object provided + This filter is specified by the <type>MM_PLUGIN_ALLOWED_VENDOR_IDS</type> + property in the <structname>MMPlugin</structname> object provided by the plugin. </para> </listitem> @@ -118,8 +118,8 @@ expected to work only with a given specific product of a given vendor. </para> <para> - This filter is specified by the <type>MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS</type> - property in the <structname>MMPluginBase</structname> object provided + This filter is specified by the <type>MM_PLUGIN_ALLOWED_PRODUCT_IDS</type> + property in the <structname>MMPlugin</structname> object provided by the plugin. </para> </listitem> @@ -130,8 +130,8 @@ any port detected with a subsystem not listed by the plugin. </para> <para> - This filter is specified by the <type>MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS</type> - property in the <structname>MMPluginBase</structname> object provided + This filter is specified by the <type>MM_PLUGIN_ALLOWED_SUBSYSTEMS</type> + property in the <structname>MMPlugin</structname> object provided by the plugin. </para> </listitem> @@ -142,8 +142,8 @@ any port detected being managed by a driver not listed by the plugin. </para> <para> - This filter is specified by the <type>MM_PLUGIN_BASE_ALLOWED_DRIVERS</type> - property in the <structname>MMPluginBase</structname> object provided + This filter is specified by the <type>MM_PLUGIN_ALLOWED_DRIVERS</type> + property in the <structname>MMPlugin</structname> object provided by the plugin. </para> </listitem> @@ -154,8 +154,8 @@ any port detected which doesn't expose any of the given tags. </para> <para> - This filter is specified by the <type>MM_PLUGIN_BASE_ALLOWED_UDEV_TAGS</type> - property in the <structname>MMPluginBase</structname> object provided + This filter is specified by the <type>MM_PLUGIN_ALLOWED_UDEV_TAGS</type> + property in the <structname>MMPlugin</structname> object provided by the plugin. </para> </listitem> @@ -186,8 +186,8 @@ AT or not. </para> <para> - This configuration is specified by the <type>MM_PLUGIN_BASE_CUSTOM_INIT</type> - property in the <structname>MMPluginBase</structname> object provided + This configuration is specified by the <type>MM_PLUGIN_CUSTOM_INIT</type> + property in the <structname>MMPlugin</structname> object provided by the plugin. </para> </listitem> @@ -198,8 +198,8 @@ AT serial ports. </para> <para> - This configuration is specified by the <type>MM_PLUGIN_BASE_ALLOWED_AT</type> - property in the <structname>MMPluginBase</structname> object provided + This configuration is specified by the <type>MM_PLUGIN_ALLOWED_AT</type> + property in the <structname>MMPlugin</structname> object provided by the plugin. </para> </listitem> @@ -211,8 +211,8 @@ in ports of the same device will get cancelled. </para> <para> - This configuration is specified by the <type>MM_PLUGIN_BASE_ALLOWED_SINGLE_AT</type> - property in the <structname>MMPluginBase</structname> object provided + This configuration is specified by the <type>MM_PLUGIN_ALLOWED_SINGLE_AT</type> + property in the <structname>MMPlugin</structname> object provided by the plugin. </para> </listitem> @@ -223,8 +223,8 @@ QCDM serial ports. </para> <para> - This configuration is specified by the <type>MM_PLUGIN_BASE_ALLOWED_QCDM</type> - property in the <structname>MMPluginBase</structname> object provided + This configuration is specified by the <type>MM_PLUGIN_ALLOWED_QCDM</type> + property in the <structname>MMPlugin</structname> object provided by the plugin. </para> </listitem> @@ -250,8 +250,8 @@ it can handle this modem. </para> <para> - This filter is specified by the <type>MM_PLUGIN_BASE_ALLOWED_VENDOR_STRINGS</type> - property in the <structname>MMPluginBase</structname> object provided + This filter is specified by the <type>MM_PLUGIN_ALLOWED_VENDOR_STRINGS</type> + property in the <structname>MMPlugin</structname> object provided by the plugin. </para> </listitem> @@ -268,8 +268,8 @@ expected to work only with a given specific product of a given vendor. </para> <para> - This filter is specified by the <type>MM_PLUGIN_BASE_ALLOWED_PRODUCT_STRINGS</type> - property in the <structname>MMPluginBase</structname> object provided + This filter is specified by the <type>MM_PLUGIN_ALLOWED_PRODUCT_STRINGS</type> + property in the <structname>MMPlugin</structname> object provided by the plugin. </para> </listitem> @@ -304,15 +304,15 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_IRIDIUM, - MM_PLUGIN_BASE_NAME, "Example", + MM_PLUGIN_NAME, "Example", /* Next items are pre-probing filters */ - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids, - MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS, product_ids, + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_ALLOWED_PRODUCT_IDS, product_ids, /* Next items are probing sequence setup */ - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, + MM_PLUGIN_ALLOWED_AT, TRUE, /* No post-probing filters */ NULL)); @@ -332,17 +332,17 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_IRIDIUM, - MM_PLUGIN_BASE_NAME, "Example", + MM_PLUGIN_NAME, "Example", /* Next items are pre-probing filters */ - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, /* Next items are probing sequence setup */ - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, + MM_PLUGIN_ALLOWED_AT, TRUE, /* Next items are post-probing filters */ - MM_PLUGIN_BASE_VENDOR_STRINGS, vendor_strings, - MM_PLUGIN_BASE_PRODUCT_STRINGS, product_strings, + MM_PLUGIN_VENDOR_STRINGS, vendor_strings, + MM_PLUGIN_PRODUCT_STRINGS, product_strings, NULL)); } </programlisting> @@ -381,15 +381,15 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_NOKIA, - MM_PLUGIN_BASE_NAME, "Example", + MM_PLUGIN_NAME, "Example", /* Next items are pre-probing filters */ - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids, /* Next items are probing sequence setup */ - MM_PLUGIN_BASE_CUSTOM_INIT, custom_init, - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, + MM_PLUGIN_CUSTOM_INIT, custom_init, + MM_PLUGIN_ALLOWED_AT, TRUE, /* No post-probing filters */ NULL)); diff --git a/plugins/anydata/mm-plugin-anydata.c b/plugins/anydata/mm-plugin-anydata.c index 9d7304e7..b0c3a897 100644 --- a/plugins/anydata/mm-plugin-anydata.c +++ b/plugins/anydata/mm-plugin-anydata.c @@ -24,7 +24,7 @@ #include "mm-plugin-anydata.h" #include "mm-broadband-modem-anydata.h" -G_DEFINE_TYPE (MMPluginAnydata, mm_plugin_anydata, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginAnydata, mm_plugin_anydata, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; @@ -32,7 +32,7 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -42,13 +42,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_anydata_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -71,11 +71,11 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_ANYDATA, - MM_PLUGIN_BASE_NAME, "AnyDATA", - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids, - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, - MM_PLUGIN_BASE_ALLOWED_QCDM, TRUE, + MM_PLUGIN_NAME, "AnyDATA", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_ALLOWED_AT, TRUE, + MM_PLUGIN_ALLOWED_QCDM, TRUE, NULL)); } @@ -87,8 +87,8 @@ mm_plugin_anydata_init (MMPluginAnydata *self) static void mm_plugin_anydata_class_init (MMPluginAnydataClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/anydata/mm-plugin-anydata.h b/plugins/anydata/mm-plugin-anydata.h index fa84a41d..765c19a5 100644 --- a/plugins/anydata/mm-plugin-anydata.h +++ b/plugins/anydata/mm-plugin-anydata.h @@ -19,7 +19,7 @@ #ifndef MM_PLUGIN_ANYDATA_H #define MM_PLUGIN_ANYDATA_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_ANYDATA (mm_plugin_anydata_get_type ()) #define MM_PLUGIN_ANYDATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_ANYDATA, MMPluginAnydata)) @@ -29,11 +29,11 @@ #define MM_PLUGIN_ANYDATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_ANYDATA, MMPluginAnydataClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginAnydata; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginAnydataClass; GType mm_plugin_anydata_get_type (void); diff --git a/plugins/cinterion/mm-plugin-cinterion.c b/plugins/cinterion/mm-plugin-cinterion.c index 8ecdac3e..f596b690 100644 --- a/plugins/cinterion/mm-plugin-cinterion.c +++ b/plugins/cinterion/mm-plugin-cinterion.c @@ -30,13 +30,13 @@ #include "mm-broadband-modem-cinterion.h" #include "mm-log.h" -G_DEFINE_TYPE (MMPluginCinterion, mm_plugin_cinterion, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginCinterion, mm_plugin_cinterion, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -46,13 +46,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_cinterion_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -86,11 +86,11 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_CINTERION, - MM_PLUGIN_BASE_NAME, "Cinterion", - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_VENDOR_STRINGS, vendor_strings, - MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids, - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, + MM_PLUGIN_NAME, "Cinterion", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_VENDOR_STRINGS, vendor_strings, + MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_ALLOWED_AT, TRUE, NULL)); } @@ -102,8 +102,8 @@ mm_plugin_cinterion_init (MMPluginCinterion *self) static void mm_plugin_cinterion_class_init (MMPluginCinterionClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/cinterion/mm-plugin-cinterion.h b/plugins/cinterion/mm-plugin-cinterion.h index 13497653..a8a3b6bb 100644 --- a/plugins/cinterion/mm-plugin-cinterion.h +++ b/plugins/cinterion/mm-plugin-cinterion.h @@ -23,7 +23,7 @@ #ifndef MM_PLUGIN_CINTERION_H #define MM_PLUGIN_CINTERION_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_CINTERION (mm_plugin_cinterion_get_type ()) #define MM_PLUGIN_CINTERION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_CINTERION, MMPluginCinterion)) @@ -33,11 +33,11 @@ #define MM_PLUGIN_CINTERION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_CINTERION, MMPluginCinterionClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginCinterion; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginCinterionClass; GType mm_plugin_cinterion_get_type (void); diff --git a/plugins/generic/mm-plugin-generic.c b/plugins/generic/mm-plugin-generic.c index 844e7856..6c89d653 100644 --- a/plugins/generic/mm-plugin-generic.c +++ b/plugins/generic/mm-plugin-generic.c @@ -32,7 +32,7 @@ #include "mm-serial-parsers.h" #include "mm-log.h" -G_DEFINE_TYPE (MMPluginGeneric, mm_plugin_generic, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginGeneric, mm_plugin_generic, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; @@ -40,7 +40,7 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -50,13 +50,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -88,10 +88,10 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_GENERIC, - MM_PLUGIN_BASE_NAME, MM_PLUGIN_GENERIC_NAME, - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, - MM_PLUGIN_BASE_ALLOWED_QCDM, TRUE, + MM_PLUGIN_NAME, MM_PLUGIN_GENERIC_NAME, + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_AT, TRUE, + MM_PLUGIN_ALLOWED_QCDM, TRUE, NULL)); } @@ -103,8 +103,8 @@ mm_plugin_generic_init (MMPluginGeneric *self) static void mm_plugin_generic_class_init (MMPluginGenericClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/generic/mm-plugin-generic.h b/plugins/generic/mm-plugin-generic.h index 8d05689f..12f9dd9d 100644 --- a/plugins/generic/mm-plugin-generic.h +++ b/plugins/generic/mm-plugin-generic.h @@ -17,7 +17,6 @@ #define MM_PLUGIN_GENERIC_H #include "mm-plugin.h" -#include "mm-plugin-base.h" #define MM_TYPE_PLUGIN_GENERIC (mm_plugin_generic_get_type ()) #define MM_PLUGIN_GENERIC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_GENERIC, MMPluginGeneric)) @@ -27,11 +26,11 @@ #define MM_PLUGIN_GENERIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_GENERIC, MMPluginGenericClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginGeneric; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginGenericClass; GType mm_plugin_generic_get_type (void); diff --git a/plugins/gobi/mm-plugin-gobi.c b/plugins/gobi/mm-plugin-gobi.c index cb47d58d..8181e2af 100644 --- a/plugins/gobi/mm-plugin-gobi.c +++ b/plugins/gobi/mm-plugin-gobi.c @@ -22,7 +22,7 @@ #include "mm-plugin-gobi.h" #include "mm-broadband-modem-gobi.h" -G_DEFINE_TYPE (MMPluginGobi, mm_plugin_gobi, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginGobi, mm_plugin_gobi, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; @@ -30,7 +30,7 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -40,13 +40,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_gobi_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -78,11 +78,11 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_GOBI, - MM_PLUGIN_BASE_NAME, "Gobi", - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_DRIVERS, drivers, - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, - MM_PLUGIN_BASE_ALLOWED_QCDM, TRUE, + MM_PLUGIN_NAME, "Gobi", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_DRIVERS, drivers, + MM_PLUGIN_ALLOWED_AT, TRUE, + MM_PLUGIN_ALLOWED_QCDM, TRUE, NULL)); } @@ -94,8 +94,8 @@ mm_plugin_gobi_init (MMPluginGobi *self) static void mm_plugin_gobi_class_init (MMPluginGobiClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/gobi/mm-plugin-gobi.h b/plugins/gobi/mm-plugin-gobi.h index 6c63d9c5..c47b172c 100644 --- a/plugins/gobi/mm-plugin-gobi.h +++ b/plugins/gobi/mm-plugin-gobi.h @@ -17,7 +17,7 @@ #ifndef MM_PLUGIN_GOBI_H #define MM_PLUGIN_GOBI_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_GOBI (mm_plugin_gobi_get_type ()) #define MM_PLUGIN_GOBI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_GOBI, MMPluginGobi)) @@ -27,11 +27,11 @@ #define MM_PLUGIN_GOBI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_GOBI, MMPluginGobiClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginGobi; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginGobiClass; GType mm_plugin_gobi_get_type (void); @@ -39,4 +39,3 @@ GType mm_plugin_gobi_get_type (void); G_MODULE_EXPORT MMPlugin *mm_plugin_create (void); #endif /* MM_PLUGIN_GOBI_H */ - diff --git a/plugins/iridium/mm-plugin-iridium.c b/plugins/iridium/mm-plugin-iridium.c index eb881876..76664fc9 100644 --- a/plugins/iridium/mm-plugin-iridium.c +++ b/plugins/iridium/mm-plugin-iridium.c @@ -30,13 +30,13 @@ #include "mm-private-boxed-types.h" #include "mm-log.h" -G_DEFINE_TYPE (MMPluginIridium, mm_plugin_iridium, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginIridium, mm_plugin_iridium, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -46,13 +46,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_iridium_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -88,12 +88,12 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_IRIDIUM, - MM_PLUGIN_BASE_NAME, "Iridium", - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_VENDOR_STRINGS, vendor_strings, - MM_PLUGIN_BASE_ALLOWED_PRODUCT_STRINGS, product_strings, - MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids, - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, + MM_PLUGIN_NAME, "Iridium", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_VENDOR_STRINGS, vendor_strings, + MM_PLUGIN_ALLOWED_PRODUCT_STRINGS, product_strings, + MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_ALLOWED_AT, TRUE, NULL)); } @@ -105,8 +105,8 @@ mm_plugin_iridium_init (MMPluginIridium *self) static void mm_plugin_iridium_class_init (MMPluginIridiumClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/iridium/mm-plugin-iridium.h b/plugins/iridium/mm-plugin-iridium.h index 20706da7..b729ce98 100644 --- a/plugins/iridium/mm-plugin-iridium.h +++ b/plugins/iridium/mm-plugin-iridium.h @@ -23,7 +23,7 @@ #ifndef MM_PLUGIN_IRIDIUM_H #define MM_PLUGIN_IRIDIUM_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_IRIDIUM (mm_plugin_iridium_get_type ()) #define MM_PLUGIN_IRIDIUM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_IRIDIUM, MMPluginIridium)) @@ -33,11 +33,11 @@ #define MM_PLUGIN_IRIDIUM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_IRIDIUM, MMPluginIridiumClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginIridium; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginIridiumClass; GType mm_plugin_iridium_get_type (void); diff --git a/plugins/linktop/mm-plugin-linktop.c b/plugins/linktop/mm-plugin-linktop.c index e05a2697..de66c3af 100644 --- a/plugins/linktop/mm-plugin-linktop.c +++ b/plugins/linktop/mm-plugin-linktop.c @@ -22,7 +22,7 @@ #include "mm-plugin-linktop.h" #include "mm-broadband-modem-linktop.h" -G_DEFINE_TYPE (MMPluginLinktop, mm_plugin_linktop, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginLinktop, mm_plugin_linktop, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; @@ -30,7 +30,7 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -40,13 +40,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_linktop_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -90,10 +90,10 @@ mm_plugin_create (void) 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, + MM_PLUGIN_NAME, "Linktop", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_ALLOWED_AT, TRUE, NULL)); } @@ -105,8 +105,8 @@ mm_plugin_linktop_init (MMPluginLinktop *self) static void mm_plugin_linktop_class_init (MMPluginLinktopClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/linktop/mm-plugin-linktop.h b/plugins/linktop/mm-plugin-linktop.h index e4b68c41..6c8e5789 100644 --- a/plugins/linktop/mm-plugin-linktop.h +++ b/plugins/linktop/mm-plugin-linktop.h @@ -18,7 +18,7 @@ #ifndef MM_PLUGIN_LINKTOP_H #define MM_PLUGIN_LINKTOP_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_LINKTOP (mm_plugin_linktop_get_type ()) #define MM_PLUGIN_LINKTOP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_LINKTOP, MMPluginLinktop)) @@ -28,11 +28,11 @@ #define MM_PLUGIN_LINKTOP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_LINKTOP, MMPluginLinktopClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginLinktop; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginLinktopClass; GType mm_plugin_linktop_get_type (void); diff --git a/plugins/motorola/mm-plugin-motorola.c b/plugins/motorola/mm-plugin-motorola.c index f6db862a..fca75f92 100644 --- a/plugins/motorola/mm-plugin-motorola.c +++ b/plugins/motorola/mm-plugin-motorola.c @@ -24,7 +24,7 @@ #include "mm-plugin-motorola.h" #include "mm-broadband-modem-motorola.h" -G_DEFINE_TYPE (MMPluginMotorola, mm_plugin_motorola, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginMotorola, mm_plugin_motorola, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; @@ -32,7 +32,7 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -42,13 +42,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_motorola_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -84,10 +84,10 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_MOTOROLA, - MM_PLUGIN_BASE_NAME, "Motorola", - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS, product_ids, - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, + MM_PLUGIN_NAME, "Motorola", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_PRODUCT_IDS, product_ids, + MM_PLUGIN_ALLOWED_AT, TRUE, NULL)); } @@ -99,8 +99,8 @@ mm_plugin_motorola_init (MMPluginMotorola *self) static void mm_plugin_motorola_class_init (MMPluginMotorolaClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/motorola/mm-plugin-motorola.h b/plugins/motorola/mm-plugin-motorola.h index 432a0c4d..6812ba36 100644 --- a/plugins/motorola/mm-plugin-motorola.h +++ b/plugins/motorola/mm-plugin-motorola.h @@ -18,7 +18,7 @@ #ifndef MM_PLUGIN_MOTOROLA_H #define MM_PLUGIN_MOTOROLA_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_MOTOROLA (mm_plugin_motorola_get_type ()) #define MM_PLUGIN_MOTOROLA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_MOTOROLA, MMPluginMotorola)) @@ -28,11 +28,11 @@ #define MM_PLUGIN_MOTOROLA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_MOTOROLA, MMPluginMotorolaClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginMotorola; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginMotorolaClass; GType mm_plugin_motorola_get_type (void); diff --git a/plugins/nokia/mm-plugin-nokia.c b/plugins/nokia/mm-plugin-nokia.c index 56b649bd..e4ad853f 100644 --- a/plugins/nokia/mm-plugin-nokia.c +++ b/plugins/nokia/mm-plugin-nokia.c @@ -24,7 +24,7 @@ #include "mm-plugin-nokia.h" #include "mm-broadband-modem-nokia.h" -G_DEFINE_TYPE (MMPluginNokia, mm_plugin_nokia, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginNokia, mm_plugin_nokia, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; @@ -42,7 +42,7 @@ static const MMPortProbeAtCommand custom_init[] = { /*****************************************************************************/ static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -52,13 +52,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_nokia_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -101,11 +101,11 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_NOKIA, - MM_PLUGIN_BASE_NAME, "Nokia", - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids, - MM_PLUGIN_BASE_CUSTOM_INIT, custom_init, - MM_PLUGIN_BASE_ALLOWED_SINGLE_AT, TRUE, /* only 1 AT port expected! */ + MM_PLUGIN_NAME, "Nokia", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_CUSTOM_INIT, custom_init, + MM_PLUGIN_ALLOWED_SINGLE_AT, TRUE, /* only 1 AT port expected! */ NULL)); } @@ -117,8 +117,8 @@ mm_plugin_nokia_init (MMPluginNokia *self) static void mm_plugin_nokia_class_init (MMPluginNokiaClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/nokia/mm-plugin-nokia.h b/plugins/nokia/mm-plugin-nokia.h index fdc0f417..e2f3589b 100644 --- a/plugins/nokia/mm-plugin-nokia.h +++ b/plugins/nokia/mm-plugin-nokia.h @@ -17,7 +17,7 @@ #ifndef MM_PLUGIN_NOKIA_H #define MM_PLUGIN_NOKIA_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_NOKIA (mm_plugin_nokia_get_type ()) #define MM_PLUGIN_NOKIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_NOKIA, MMPluginNokia)) @@ -27,11 +27,11 @@ #define MM_PLUGIN_NOKIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_NOKIA, MMPluginNokiaClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginNokia; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginNokiaClass; GType mm_plugin_nokia_get_type (void); diff --git a/plugins/novatel/mm-plugin-novatel.c b/plugins/novatel/mm-plugin-novatel.c index a4a0c5ab..e8c05726 100644 --- a/plugins/novatel/mm-plugin-novatel.c +++ b/plugins/novatel/mm-plugin-novatel.c @@ -28,13 +28,13 @@ #include "mm-broadband-modem-novatel.h" #include "mm-log.h" -G_DEFINE_TYPE (MMPluginNovatel, mm_plugin_novatel, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginNovatel, mm_plugin_novatel, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -44,13 +44,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_novatel_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -81,10 +81,10 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_NOVATEL, - MM_PLUGIN_BASE_NAME, "Novatel", - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS, products, - MM_PLUGIN_BASE_ALLOWED_SINGLE_AT, TRUE, + MM_PLUGIN_NAME, "Novatel", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_PRODUCT_IDS, products, + MM_PLUGIN_ALLOWED_SINGLE_AT, TRUE, NULL)); } @@ -96,8 +96,8 @@ mm_plugin_novatel_init (MMPluginNovatel *self) static void mm_plugin_novatel_class_init (MMPluginNovatelClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/novatel/mm-plugin-novatel.h b/plugins/novatel/mm-plugin-novatel.h index bffbf3c8..50e10270 100644 --- a/plugins/novatel/mm-plugin-novatel.h +++ b/plugins/novatel/mm-plugin-novatel.h @@ -23,7 +23,7 @@ #ifndef MM_PLUGIN_NOVATEL_H #define MM_PLUGIN_NOVATEL_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_NOVATEL (mm_plugin_novatel_get_type ()) #define MM_PLUGIN_NOVATEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_NOVATEL, MMPluginNovatel)) @@ -33,11 +33,11 @@ #define MM_PLUGIN_NOVATEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_NOVATEL, MMPluginNovatelClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginNovatel; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginNovatelClass; GType mm_plugin_novatel_get_type (void); diff --git a/plugins/option/mm-plugin-hso.c b/plugins/option/mm-plugin-hso.c index 2aa98fdd..f80540a5 100644 --- a/plugins/option/mm-plugin-hso.c +++ b/plugins/option/mm-plugin-hso.c @@ -25,7 +25,7 @@ #include "mm-broadband-modem-hso.h" #include "mm-log.h" -G_DEFINE_TYPE (MMPluginHso, mm_plugin_hso, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginHso, mm_plugin_hso, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; @@ -33,7 +33,7 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -43,13 +43,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_hso_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -134,11 +134,11 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_HSO, - MM_PLUGIN_BASE_NAME, "Option High-Speed", - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_DRIVERS, drivers, - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, - MM_PLUGIN_BASE_ALLOWED_QCDM, TRUE, + MM_PLUGIN_NAME, "Option High-Speed", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_DRIVERS, drivers, + MM_PLUGIN_ALLOWED_AT, TRUE, + MM_PLUGIN_ALLOWED_QCDM, TRUE, NULL)); } @@ -150,8 +150,8 @@ mm_plugin_hso_init (MMPluginHso *self) static void mm_plugin_hso_class_init (MMPluginHsoClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/option/mm-plugin-hso.h b/plugins/option/mm-plugin-hso.h index 1c554a3f..5ef13439 100644 --- a/plugins/option/mm-plugin-hso.h +++ b/plugins/option/mm-plugin-hso.h @@ -18,7 +18,7 @@ #ifndef MM_PLUGIN_HSO_H #define MM_PLUGIN_HSO_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_HSO (mm_plugin_hso_get_type ()) #define MM_PLUGIN_HSO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_HSO, MMPluginHso)) @@ -28,11 +28,11 @@ #define MM_PLUGIN_HSO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_HSO, MMPluginHsoClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginHso; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginHsoClass; GType mm_plugin_hso_get_type (void); diff --git a/plugins/option/mm-plugin-option.c b/plugins/option/mm-plugin-option.c index 771cb7b3..5cff84fa 100644 --- a/plugins/option/mm-plugin-option.c +++ b/plugins/option/mm-plugin-option.c @@ -24,7 +24,7 @@ #include "mm-plugin-option.h" #include "mm-broadband-modem-option.h" -G_DEFINE_TYPE (MMPluginOption, mm_plugin_option, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginOption, mm_plugin_option, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; @@ -32,7 +32,7 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -42,13 +42,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_option_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -98,12 +98,12 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_OPTION, - MM_PLUGIN_BASE_NAME, "Option", - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_DRIVERS, drivers, - MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids, - MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS, product_ids, - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, + MM_PLUGIN_NAME, "Option", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_DRIVERS, drivers, + MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_ALLOWED_PRODUCT_IDS, product_ids, + MM_PLUGIN_ALLOWED_AT, TRUE, NULL)); } @@ -115,8 +115,8 @@ mm_plugin_option_init (MMPluginOption *self) static void mm_plugin_option_class_init (MMPluginOptionClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/option/mm-plugin-option.h b/plugins/option/mm-plugin-option.h index 5792c78d..275fc403 100644 --- a/plugins/option/mm-plugin-option.h +++ b/plugins/option/mm-plugin-option.h @@ -18,7 +18,7 @@ #ifndef MM_PLUGIN_OPTION_H #define MM_PLUGIN_OPTION_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_OPTION (mm_plugin_option_get_type ()) #define MM_PLUGIN_OPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_OPTION, MMPluginOption)) @@ -28,11 +28,11 @@ #define MM_PLUGIN_OPTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_OPTION, MMPluginOptionClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginOption; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginOptionClass; GType mm_plugin_option_get_type (void); diff --git a/plugins/simtech/mm-plugin-simtech.c b/plugins/simtech/mm-plugin-simtech.c index 7f3bc21a..5a07f1f3 100644 --- a/plugins/simtech/mm-plugin-simtech.c +++ b/plugins/simtech/mm-plugin-simtech.c @@ -22,7 +22,7 @@ #include "mm-plugin-simtech.h" #include "mm-broadband-modem-simtech.h" -G_DEFINE_TYPE (MMPluginSimtech, mm_plugin_simtech, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginSimtech, mm_plugin_simtech, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; @@ -30,7 +30,7 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -40,13 +40,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_simtech_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -105,11 +105,11 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_SIMTECH, - MM_PLUGIN_BASE_NAME, "SimTech", - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids, - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, - MM_PLUGIN_BASE_ALLOWED_QCDM, TRUE, + MM_PLUGIN_NAME, "SimTech", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_ALLOWED_AT, TRUE, + MM_PLUGIN_ALLOWED_QCDM, TRUE, NULL)); } @@ -121,8 +121,8 @@ mm_plugin_simtech_init (MMPluginSimtech *self) static void mm_plugin_simtech_class_init (MMPluginSimtechClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/simtech/mm-plugin-simtech.h b/plugins/simtech/mm-plugin-simtech.h index 603045e8..eab8630c 100644 --- a/plugins/simtech/mm-plugin-simtech.h +++ b/plugins/simtech/mm-plugin-simtech.h @@ -18,7 +18,7 @@ #ifndef MM_PLUGIN_SIMTECH_H #define MM_PLUGIN_SIMTECH_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_SIMTECH (mm_plugin_simtech_get_type ()) #define MM_PLUGIN_SIMTECH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_SIMTECH, MMPluginSimtech)) @@ -28,11 +28,11 @@ #define MM_PLUGIN_SIMTECH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_SIMTECH, MMPluginSimtechClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginSimtech; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginSimtechClass; GType mm_plugin_simtech_get_type (void); diff --git a/plugins/wavecom/mm-plugin-wavecom.c b/plugins/wavecom/mm-plugin-wavecom.c index a3e71b26..f55ccad1 100644 --- a/plugins/wavecom/mm-plugin-wavecom.c +++ b/plugins/wavecom/mm-plugin-wavecom.c @@ -30,7 +30,7 @@ #include "mm-plugin-wavecom.h" #include "mm-broadband-modem-wavecom.h" -G_DEFINE_TYPE (MMPluginWavecom, mm_plugin_wavecom, MM_TYPE_PLUGIN_BASE) +G_DEFINE_TYPE (MMPluginWavecom, mm_plugin_wavecom, MM_TYPE_PLUGIN) int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; @@ -38,7 +38,7 @@ int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; /*****************************************************************************/ static MMBaseModem * -create_modem (MMPluginBase *plugin, +create_modem (MMPlugin *self, const gchar *sysfs_path, const gchar *driver, guint16 vendor, @@ -48,13 +48,13 @@ create_modem (MMPluginBase *plugin, { return MM_BASE_MODEM (mm_broadband_modem_wavecom_new (sysfs_path, driver, - mm_plugin_get_name (MM_PLUGIN (plugin)), + mm_plugin_get_name (self), vendor, product)); } static gboolean -grab_port (MMPluginBase *base, +grab_port (MMPlugin *self, MMBaseModem *modem, MMPortProbe *probe, GError **error) @@ -86,10 +86,10 @@ mm_plugin_create (void) return MM_PLUGIN ( g_object_new (MM_TYPE_PLUGIN_WAVECOM, - MM_PLUGIN_BASE_NAME, "Wavecom", - MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, - MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids, - MM_PLUGIN_BASE_ALLOWED_AT, TRUE, + MM_PLUGIN_NAME, "Wavecom", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_ALLOWED_AT, TRUE, NULL)); } @@ -101,8 +101,8 @@ mm_plugin_wavecom_init (MMPluginWavecom *self) static void mm_plugin_wavecom_class_init (MMPluginWavecomClass *klass) { - MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); - pb_class->create_modem = create_modem; - pb_class->grab_port = grab_port; + plugin_class->create_modem = create_modem; + plugin_class->grab_port = grab_port; } diff --git a/plugins/wavecom/mm-plugin-wavecom.h b/plugins/wavecom/mm-plugin-wavecom.h index 9b355d5f..c1d76309 100644 --- a/plugins/wavecom/mm-plugin-wavecom.h +++ b/plugins/wavecom/mm-plugin-wavecom.h @@ -25,7 +25,7 @@ #ifndef MM_PLUGIN_WAVECOM_H #define MM_PLUGIN_WAVECOM_H -#include "mm-plugin-base.h" +#include "mm-plugin.h" #define MM_TYPE_PLUGIN_WAVECOM (mm_plugin_wavecom_get_type ()) #define MM_PLUGIN_WAVECOM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_WAVECOM, MMPluginWavecom)) @@ -35,11 +35,11 @@ #define MM_PLUGIN_WAVECOM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_WAVECOM, MMPluginWavecomClass)) typedef struct { - MMPluginBase parent; + MMPlugin parent; } MMPluginWavecom; typedef struct { - MMPluginBaseClass parent; + MMPluginClass parent; } MMPluginWavecomClass; GType mm_plugin_wavecom_get_type (void); diff --git a/src/Makefile.am b/src/Makefile.am index 34dde87c..a53cb83a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -197,9 +197,7 @@ ModemManager_SOURCES = \ mm-port-probe-cache.h \ mm-port-probe-cache.c \ mm-plugin.c \ - mm-plugin.h \ - mm-plugin-base.c \ - mm-plugin-base.h + mm-plugin.h # Additional dependency rules mm-bearer.c: mm-daemon-enums-types.h diff --git a/src/mm-plugin-base.c b/src/mm-plugin-base.c deleted file mode 100644 index 1452c4cb..00000000 --- a/src/mm-plugin-base.c +++ /dev/null @@ -1,1138 +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 - 2010 Red Hat, Inc. - */ - -#define _GNU_SOURCE /* for strcasestr */ - -#include <stdio.h> -#include <stdlib.h> -#include <sys/stat.h> -#include <unistd.h> -#include <string.h> - -#include <gudev/gudev.h> - -#include <ModemManager.h> -#include <mm-errors-types.h> - -#include "mm-plugin-base.h" -#include "mm-port-probe-cache.h" -#include "mm-at-serial-port.h" -#include "mm-qcdm-serial-port.h" -#include "mm-serial-parsers.h" -#include "mm-marshal.h" -#include "mm-utils.h" -#include "mm-private-boxed-types.h" -#include "libqcdm/src/commands.h" -#include "libqcdm/src/utils.h" -#include "libqcdm/src/errors.h" -#include "mm-log.h" - -static void plugin_init (MMPlugin *plugin_class); - -G_DEFINE_TYPE_EXTENDED (MMPluginBase, mm_plugin_base, G_TYPE_OBJECT, - 0, G_IMPLEMENT_INTERFACE (MM_TYPE_PLUGIN, plugin_init)) - -#define MM_PLUGIN_BASE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_PLUGIN_BASE, MMPluginBasePrivate)) - -/* Virtual port corresponding to the embeded modem */ -static gchar *virtual_port[] = {"smd0", NULL}; - -typedef struct { - gchar *name; - GUdevClient *client; - GHashTable *tasks; - - /* Plugin-specific setups */ - gchar **subsystems; - gchar **drivers; - guint16 *vendor_ids; - mm_uint16_pair *product_ids; - gchar **vendor_strings; - mm_str_pair *product_strings; - gchar **udev_tags; - gboolean at; - gboolean single_at; - gboolean qcdm; - MMPortProbeAtCommand *custom_init; - guint64 send_delay; -} MMPluginBasePrivate; - -enum { - PROP_0, - PROP_NAME, - PROP_ALLOWED_SUBSYSTEMS, - PROP_ALLOWED_DRIVERS, - PROP_ALLOWED_VENDOR_IDS, - PROP_ALLOWED_PRODUCT_IDS, - PROP_ALLOWED_VENDOR_STRINGS, - PROP_ALLOWED_PRODUCT_STRINGS, - PROP_ALLOWED_UDEV_TAGS, - PROP_ALLOWED_AT, - PROP_ALLOWED_SINGLE_AT, - PROP_ALLOWED_QCDM, - PROP_CUSTOM_INIT, - PROP_SEND_DELAY, - LAST_PROP -}; - -/*****************************************************************************/ - -static gboolean -get_device_ids (MMPluginBase *self, - const char *subsys, - const char *name, - guint16 *vendor, - guint16 *product) -{ - MMPluginBasePrivate *priv; - GUdevDevice *device = NULL, *parent = NULL; - const char *vid = NULL, *pid = NULL, *parent_subsys; - gboolean success = FALSE; - - g_return_val_if_fail (self != NULL, FALSE); - g_return_val_if_fail (MM_IS_PLUGIN_BASE (self), FALSE); - g_return_val_if_fail (subsys != NULL, FALSE); - g_return_val_if_fail (name != NULL, FALSE); - if (vendor) - g_return_val_if_fail (*vendor == 0, FALSE); - if (product) - g_return_val_if_fail (*product == 0, FALSE); - - priv = MM_PLUGIN_BASE_GET_PRIVATE (self); - - device = g_udev_client_query_by_subsystem_and_name (priv->client, subsys, name); - if (!device) - goto out; - - parent = g_udev_device_get_parent (device); - if (parent) { - parent_subsys = g_udev_device_get_subsystem (parent); - if (parent_subsys) { - if (!strcmp (parent_subsys, "bluetooth")) { - /* Bluetooth devices report the VID/PID of the BT adapter here, - * which isn't really what we want. Just return null IDs instead. - */ - success = TRUE; - goto out; - } else if (!strcmp (parent_subsys, "pcmcia")) { - /* For PCMCIA devices we need to grab the PCMCIA subsystem's - * manfid and cardid, since any IDs on the tty device itself - * may be from PCMCIA controller or something else. - */ - vid = g_udev_device_get_sysfs_attr (parent, "manf_id"); - pid = g_udev_device_get_sysfs_attr (parent, "card_id"); - if (!vid || !pid) - goto out; - } else if (!strcmp (parent_subsys, "platform")) { - /* Platform devices don't usually have a VID/PID */ - success = TRUE; - goto out; - } - } - } - - if (!vid) - vid = g_udev_device_get_property (device, "ID_VENDOR_ID"); - if (!vid) - goto out; - - if (strncmp (vid, "0x", 2) == 0) - vid += 2; - if (strlen (vid) != 4) - goto out; - - if (vendor) { - *vendor = (guint16) (utils_hex2byte (vid + 2) & 0xFF); - *vendor |= (guint16) ((utils_hex2byte (vid) & 0xFF) << 8); - } - - if (!pid) - pid = g_udev_device_get_property (device, "ID_MODEL_ID"); - if (!pid) { - *vendor = 0; - goto out; - } - - if (strncmp (pid, "0x", 2) == 0) - pid += 2; - if (strlen (pid) != 4) { - *vendor = 0; - goto out; - } - - if (product) { - *product = (guint16) (utils_hex2byte (pid + 2) & 0xFF); - *product |= (guint16) ((utils_hex2byte (pid) & 0xFF) << 8); - } - - success = TRUE; - -out: - if (device) - g_object_unref (device); - if (parent) - g_object_unref (parent); - return success; -} - -static char * -get_key (const char *subsys, const char *name) -{ - return g_strdup_printf ("%s%s", subsys, name); -} - -static const char * -get_name (MMPlugin *plugin) -{ - return MM_PLUGIN_BASE_GET_PRIVATE (plugin)->name; -} - -static gboolean -get_sort_last (const MMPlugin *plugin) -{ - MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (plugin); - - /* If we have any post-probing filter, we need to sort the plugin last */ - return (priv->vendor_strings || priv->product_strings); -} - -static char * -get_driver_name (GUdevDevice *device) -{ - GUdevDevice *parent = NULL; - const char *driver, *subsys; - char *ret = NULL; - - 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); - - /* Check for bluetooth; it's driver is a bunch of levels up so we - * just check for the subsystem of the parent being bluetooth. - */ - if (!driver && parent) { - subsys = g_udev_device_get_subsystem (parent); - if (subsys && !strcmp (subsys, "bluetooth")) - driver = "bluetooth"; - } - } - - if (driver) - ret = g_strdup (driver); - if (parent) - g_object_unref (parent); - - return ret; -} - -static gboolean -device_file_exists (const char *name) -{ - char *devfile; - struct stat s; - int result; - - devfile = g_strdup_printf ("/dev/%s", name); - result = stat (devfile, &s); - g_free (devfile); - - return (0 == result) ? TRUE : FALSE; -} - -static gboolean -is_virtual_port (const gchar *device_name) -{ - guint idx; - - /* Detect any modems accessible through the list of virtual ports */ - for (idx = 0; virtual_port[idx]; idx++) { - if (strcmp (device_name, virtual_port[idx])) - continue; - if (!device_file_exists (virtual_port[idx])) - continue; - - return TRUE; - } - - return FALSE; -} - -/* Returns TRUE if the support check request was filtered out */ -static gboolean -apply_pre_probing_filters (MMPluginBase *self, - GUdevDevice *port, - const gchar *subsys, - const gchar *name, - const gchar *driver, - gboolean *need_vendor_probing, - gboolean *need_product_probing) -{ - MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self); - guint16 vendor = 0; - guint16 product = 0; - gboolean product_filtered = FALSE; - gboolean vendor_filtered = FALSE; - guint i; - - *need_vendor_probing = FALSE; - *need_product_probing = FALSE; - - /* The plugin may specify that only some subsystems are supported. If that - * is the case, filter by subsystem */ - if (priv->subsystems) { - for (i = 0; priv->subsystems[i]; i++) { - if (g_str_equal (subsys, priv->subsystems[i])) - break; - } - - /* If we didn't match any subsystem: unsupported */ - if (!priv->subsystems[i]) - return TRUE; - } - - /* The plugin may specify that only some drivers are supported. If that - * is the case, filter by driver */ - if (priv->drivers) { - for (i = 0; priv->drivers[i]; i++) { - if (g_str_equal (driver, priv->drivers[i])) - break; - } - - /* If we didn't match any driver: unsupported */ - if (!priv->drivers[i]) - return TRUE; - } - - get_device_ids (self, subsys, name, &vendor, &product); - - /* The plugin may specify that only some vendor IDs are supported. If that - * is the case, filter by vendor ID. */ - if (priv->vendor_ids) { - /* If we didn't get any vendor: filtered */ - if (!vendor) - vendor_filtered = TRUE; - else { - for (i = 0; priv->vendor_ids[i]; i++) - if (vendor == priv->vendor_ids[i]) - break; - - /* If we didn't match any vendor: filtered */ - if (!priv->vendor_ids[i]) - vendor_filtered = TRUE; - } - } - - /* The plugin may specify that only some product IDs are supported. If - * that is the case, filter by vendor+product ID pair */ - if (priv->product_ids) { - /* If we didn't get any product: filtered */ - if (!product) - product_filtered = TRUE; - else { - for (i = 0; priv->product_ids[i].l; i++) - if (vendor == priv->product_ids[i].l && - product == priv->product_ids[i].r) - break; - - /* If we didn't match any product: filtered */ - if (!priv->product_ids[i].l) - product_filtered = TRUE; - } - } - - /* If we got filtered by vendor or product IDs and we do not have vendor - * or product strings to compare with: unsupported */ - if ((vendor_filtered || product_filtered) && - !priv->vendor_strings && - !priv->product_strings) - return TRUE; - - /* If we need to filter by vendor/product strings, need to probe for both. - * This covers the case where a RS232 modem is connected via a USB<->RS232 - * adaptor, and we get in udev the vendor ID of the adaptor */ - - if (priv->product_strings) { - *need_vendor_probing = TRUE; - *need_product_probing = TRUE; - } else if (priv->vendor_strings) - *need_vendor_probing = TRUE; - - /* The plugin may specify that only ports with some given udev tags are - * supported. If that is the case, filter by udev tag */ - if (priv->udev_tags) { - for (i = 0; priv->udev_tags[i]; i++) { - /* Check if the port was tagged */ - if (g_udev_device_get_property_as_boolean (port, - priv->udev_tags[i])) - break; - } - - /* If we didn't match any udev tag: unsupported */ - if (!priv->udev_tags[i]) - return TRUE; - } - - return FALSE; -} - -/* Returns TRUE if the support check request was filtered out */ -static gboolean -apply_post_probing_filters (MMPluginBase *self, - MMPortProbe *probe) -{ - MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self); - gboolean vendor_filtered = FALSE; - gboolean product_filtered = FALSE; - guint i; - - /* The plugin may specify that only some vendor strings are supported. If - * that is the case, filter by vendor string. */ - if (priv->vendor_strings) { - const gchar *vendor; - - vendor = mm_port_probe_get_vendor (probe); - - /* If we didn't get any vendor: filtered */ - if (!vendor) - vendor_filtered = TRUE; - else { - for (i = 0; priv->vendor_strings[i]; i++) { - gboolean found; - gchar *casefolded; - - casefolded = g_utf8_casefold (priv->vendor_strings[i], -1); - found = !!strstr (vendor, casefolded); - g_free (casefolded); - if (found) - break; - } - - /* If we didn't match any vendor: filtered */ - if (!priv->vendor_strings[i]) - vendor_filtered = TRUE; - } - - if (vendor_filtered) { - if (!priv->product_strings) - return TRUE; - } else - /* Vendor matched */ - return FALSE; - } - - /* The plugin may specify that only some vendor+product string pairs are - * supported. If that is the case, filter by product string */ - if (priv->product_strings) { - const gchar *vendor; - const gchar *product; - - vendor = mm_port_probe_get_vendor (probe); - product = mm_port_probe_get_product (probe); - - /* If we didn't get any vendor or product: filtered */ - if (!vendor || !product) - product_filtered = TRUE; - else { - for (i = 0; priv->product_strings[i].l; i++) { - gboolean found; - gchar *casefolded_vendor; - gchar *casefolded_product; - - casefolded_vendor = g_utf8_casefold (priv->product_strings[i].l, -1); - casefolded_product = g_utf8_casefold (priv->product_strings[i].r, -1); - found = (!!strstr (vendor, casefolded_vendor) && - !!strstr (product, casefolded_product)); - g_free (casefolded_vendor); - g_free (casefolded_product); - if (found) - break; - } - - /* If we didn't match any product: unsupported */ - if (!priv->product_strings[i].l) - product_filtered = TRUE; - } - - return product_filtered; - } - - return FALSE; -} - -/* Context for the asynchronous probing operation */ -typedef struct { - GSimpleAsyncResult *result; - MMPluginBase *plugin; - MMPortProbeFlag flags; -} PortProbeRunContext; - -static void -cancel_at_probing_in_other_probes (const gchar *key, - MMPortProbe *other, - MMPortProbe *self) -{ - if (self != other && - g_str_equal (mm_port_probe_get_port_physdev (self), - mm_port_probe_get_port_physdev (other))) - mm_port_probe_run_cancel_at_probing (other); -} - -static void -port_probe_run_ready (MMPortProbe *probe, - GAsyncResult *probe_result, - PortProbeRunContext *ctx) -{ - MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (ctx->plugin); - GError *error = NULL; - gboolean keep_probe = FALSE; - - if (!mm_port_probe_run_finish (probe, probe_result, &error)) { - /* Probing failed */ - g_simple_async_result_take_error (ctx->result, error); - } else { - /* Probing succeeded */ - MMPluginSupportsResult supports_result; - - if (!apply_post_probing_filters (ctx->plugin, probe)) { - /* Port is supported! Leave it in the internal HT until port gets - * grabbed. */ - supports_result = MM_PLUGIN_SUPPORTS_PORT_SUPPORTED; - keep_probe = TRUE; - - /* If we were looking for AT ports, and the port is AT, - * and we were told that only one AT port is expected, cancel AT - * probings in the other available support tasks of the SAME - * device. */ - if (priv->single_at && - ctx->flags & MM_PORT_PROBE_AT && - mm_port_probe_is_at (probe)) { - g_hash_table_foreach (priv->tasks, - (GHFunc) cancel_at_probing_in_other_probes, - probe); - } - - } else { - /* Unsupported port, remove from internal tracking HT */ - supports_result = MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED; - } - - g_simple_async_result_set_op_res_gpointer (ctx->result, - GUINT_TO_POINTER (supports_result), - NULL); - } - - /* Complete the async supports port request */ - g_simple_async_result_complete_in_idle (ctx->result); - - /* If no longer needed, Remove probe from internal HT */ - if (!keep_probe) { - gchar *key; - - key = get_key (mm_port_probe_get_port_subsys (probe), - mm_port_probe_get_port_name (probe)); - g_hash_table_remove (priv->tasks, key); - g_free (key); - } - - g_object_unref (ctx->result); - g_object_unref (ctx->plugin); - g_free (ctx); -} - -static MMPluginSupportsResult -supports_port_finish (MMPlugin *self, - GAsyncResult *result, - GError **error) -{ - g_return_val_if_fail (MM_IS_PLUGIN (self), - MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED); - g_return_val_if_fail (G_IS_ASYNC_RESULT (result), - MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED); - - /* Propagate error, if any */ - if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), - error)) { - return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED; - } - - return (MMPluginSupportsResult) GPOINTER_TO_UINT (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result))); -} - -static void -supports_port (MMPlugin *plugin, - const gchar *subsys, - const gchar *name, - const gchar *physdev_path, - MMBaseModem *existing, - GAsyncReadyCallback callback, - gpointer user_data) -{ - MMPluginBase *self = MM_PLUGIN_BASE (plugin); - MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self); - GUdevDevice *port = NULL; - gchar *driver = NULL; - gchar *key = NULL; - MMPortProbe *probe; - GSimpleAsyncResult *async_result; - PortProbeRunContext *ctx; - gboolean need_vendor_probing; - gboolean need_product_probing; - MMPortProbeFlag probe_run_flags; - - /* Setup key */ - key = get_key (subsys, name); - - async_result = g_simple_async_result_new (G_OBJECT (self), - callback, - user_data, - supports_port); - - /* Get port device */ - if (!(port = g_udev_client_query_by_subsystem_and_name (priv->client, - subsys, - name))) { - g_simple_async_result_set_error (async_result, - MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Couldn't find port for (%s/%s)", - subsys, - name); - g_simple_async_result_complete_in_idle (async_result); - goto out; - } - - /* Detect any modems accessible through the list of virtual ports */ - if (!(driver = (is_virtual_port (name) ? - g_strdup ("virtual") : - get_driver_name (port)))) { - g_simple_async_result_set_error (async_result, - MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Couldn't find driver for (%s/%s)", - subsys, - name); - g_simple_async_result_complete_in_idle (async_result); - goto out; - } - - /* Apply filters before launching the probing */ - if (apply_pre_probing_filters (self, - port, - subsys, - name, - driver, - &need_vendor_probing, - &need_product_probing)) { - /* Filtered! */ - g_simple_async_result_set_op_res_gpointer (async_result, - GUINT_TO_POINTER (MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED), - NULL); - g_simple_async_result_complete_in_idle (async_result); - goto out; - } - - mm_dbg ("(%s) checking port support (%s,%s)", priv->name, subsys, name); - - /* Need to launch new probing */ - - /* Lookup current probes, there shouldn't be any (unless for net devices) */ - probe = g_hash_table_lookup (priv->tasks, key); - if (!probe) - probe = mm_port_probe_cache_get (port, physdev_path, driver); - g_assert (probe); - - /* Before launching any probing, check if the port is a net device (which - * cannot be probed). - * TODO: With the new defer-until-suggested we probably don't need the modem - * object being passed down here just for this. */ - if (g_str_equal (subsys, "net")) { - /* Keep track of the probe object, which is considered finished */ - if (!g_hash_table_lookup (priv->tasks, key)) - g_hash_table_insert (priv->tasks, - g_strdup (key), - g_object_ref (probe)); - - /* If we already have a existing modem, then mark it as supported. - * Otherwise, just defer a bit */ - g_simple_async_result_set_op_res_gpointer ( - async_result, - GUINT_TO_POINTER ((existing ? - MM_PLUGIN_SUPPORTS_PORT_SUPPORTED : - MM_PLUGIN_SUPPORTS_PORT_DEFER_UNTIL_SUGGESTED)), - NULL); - g_simple_async_result_complete_in_idle (async_result); - goto out; - } - - /* Build flags depending on what probing needed */ - probe_run_flags = MM_PORT_PROBE_NONE; - if (priv->at) - probe_run_flags |= MM_PORT_PROBE_AT; - else if (priv->single_at) - probe_run_flags |= MM_PORT_PROBE_AT; - if (need_vendor_probing) - probe_run_flags |= (MM_PORT_PROBE_AT | MM_PORT_PROBE_AT_VENDOR); - if (need_product_probing) - probe_run_flags |= (MM_PORT_PROBE_AT | MM_PORT_PROBE_AT_PRODUCT); - if (priv->qcdm) - probe_run_flags |= MM_PORT_PROBE_QCDM; - - g_assert (probe_run_flags != MM_PORT_PROBE_NONE); - - /* If a modem is already available and the plugin says that only one AT port is - * expected, check if we alredy got the single AT port. And if so, we know this - * port being probed won't be AT. */ - if (priv->single_at && - existing && - mm_base_modem_has_at_port (existing)) { - mm_dbg ("(%s) not setting up AT probing tasks for (%s,%s): " - "modem already has the expected single AT port", - priv->name, subsys, name); - - /* Assuming it won't be an AT port. We still run the probe anyway, in - * case we need to check for other port types (e.g. QCDM) */ - mm_port_probe_set_result_at (probe, FALSE); - } - - /* Setup async call context */ - ctx = g_new (PortProbeRunContext, 1); - ctx->plugin = g_object_ref (self); - ctx->result = g_object_ref (async_result); - ctx->flags = probe_run_flags; - - /* Launch the probe */ - mm_dbg ("(%s) launching probe for (%s,%s)", priv->name, subsys, name); - mm_port_probe_run (probe, - ctx->flags, - priv->send_delay, - priv->custom_init, - (GAsyncReadyCallback)port_probe_run_ready, - ctx); - - /* Keep track of the probe. Note that we got a new reference already - * from the cache. */ - g_hash_table_insert (priv->tasks, - g_strdup (key), - probe); - -out: - if (port) - g_object_unref (port); - g_free (key); - g_free (driver); - g_object_unref (async_result); -} - -static void -supports_port_cancel (MMPlugin *plugin, - const char *subsys, - const char *name) -{ - MMPluginBase *self = MM_PLUGIN_BASE (plugin); - MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self); - MMPortProbe *probe; - gchar *key; - - key = get_key (subsys, name); - probe = g_hash_table_lookup (priv->tasks, key); - if (probe) { - mm_port_probe_run_cancel (probe); - g_hash_table_remove (priv->tasks, key); - } - - g_free (key); -} - -static MMBaseModem * -create_modem (MMPlugin *self, - GList *ports, - GError **error) -{ - MMBaseModem *modem = NULL; - MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self); - GList *probes = NULL; - GList *l; - const gchar *name, *subsys, *sysfs_path, *driver; - guint16 vendor = 0, product = 0; - - /* Get the port probe results for each of the ports */ - for (l = ports; l; l = g_list_next (l)) { - MMPortProbe *probe; - gchar *key; - - subsys = g_udev_device_get_subsystem (G_UDEV_DEVICE (l->data)); - name = g_udev_device_get_name (G_UDEV_DEVICE (l->data)); - - key = get_key (subsys, name); - probe = g_hash_table_lookup (priv->tasks, key); - if (!probe) - mm_warn ("(%s/%s) Ignoring port when creating modem with plugin '%s'", - subsys, - name, - priv->name); - else - probes = g_list_prepend (probes, g_object_ref (probe)); - g_free (key); - } - - /* Get info from the first probe in the list */ - subsys = mm_port_probe_get_port_subsys (probes->data); - name = mm_port_probe_get_port_name (probes->data); - sysfs_path = mm_port_probe_get_port_physdev (probes->data); - driver = mm_port_probe_get_port_driver (probes->data); - - /* Vendor and Product IDs are really optional, we'll just warn if they - * cannot get loaded */ - if (!get_device_ids (MM_PLUGIN_BASE (self), subsys, name, &vendor, &product)) - mm_warn ("Could not get modem vendor/product ID"); - - /* Let the plugin create the modem from the port probe results */ - modem = MM_PLUGIN_BASE_GET_CLASS (self)->create_modem (MM_PLUGIN_BASE (self), - sysfs_path, - driver, - vendor, - product, - probes, - error); - if (modem) { - /* Grab each port */ - for (l = probes; l; l = g_list_next (l)) { - GError *inner_error = NULL; - - /* If grabbing a port fails, just warn. We'll decide if the modem is - * valid or not when all ports get organized */ - if (!MM_PLUGIN_BASE_GET_CLASS (self)->grab_port (MM_PLUGIN_BASE (self), - modem, - MM_PORT_PROBE (l->data), - &inner_error)) { - mm_warn ("Could not grab port (%s/%s): '%s'", - mm_port_probe_get_port_subsys (MM_PORT_PROBE (l->data)), - mm_port_probe_get_port_name (MM_PORT_PROBE (l->data)), - inner_error ? inner_error->message : "unknown error"); - g_clear_error (&inner_error); - } - } - - /* If organizing ports fails, consider the modem invalid */ - if (!mm_base_modem_organize_ports (modem, error)) - g_clear_object (&modem); - } - - for (l = probes; l; l = g_list_next (l)) { - gchar *key; - - key = get_key (mm_port_probe_get_port_subsys (l->data), - mm_port_probe_get_port_name (l->data)); - g_hash_table_remove (priv->tasks, key); - g_free (key); - } - - g_list_free_full (probes, (GDestroyNotify) g_object_unref); - - return modem; -} - -/*****************************************************************************/ - -static void -plugin_init (MMPlugin *plugin_class) -{ - /* interface implementation */ - plugin_class->get_name = get_name; - plugin_class->get_sort_last = get_sort_last; - plugin_class->supports_port = supports_port; - plugin_class->supports_port_finish = supports_port_finish; - plugin_class->supports_port_cancel = supports_port_cancel; - plugin_class->create_modem = create_modem; -} - -static void -mm_plugin_base_init (MMPluginBase *self) -{ - MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self); - - /* We pass NULL as we won't need to get notified about uevents, - * we just use this client for sync queries. */ - priv->client = g_udev_client_new (NULL); - - priv->tasks = g_hash_table_new_full (g_str_hash, - g_str_equal, - g_free, - (GDestroyNotify) g_object_unref); - /* Defaults */ - priv->send_delay = 100000; -} - -static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_NAME: - /* Construct only */ - priv->name = g_value_dup_string (value); - break; - case PROP_ALLOWED_SUBSYSTEMS: - /* Construct only */ - priv->subsystems = g_value_dup_boxed (value); - break; - case PROP_ALLOWED_DRIVERS: - /* Construct only */ - priv->drivers = g_value_dup_boxed (value); - break; - case PROP_ALLOWED_VENDOR_IDS: - /* Construct only */ - priv->vendor_ids = g_value_dup_boxed (value); - break; - case PROP_ALLOWED_PRODUCT_IDS: - /* Construct only */ - priv->product_ids = g_value_dup_boxed (value); - break; - case PROP_ALLOWED_VENDOR_STRINGS: - /* Construct only */ - priv->vendor_strings = g_value_dup_boxed (value); - break; - case PROP_ALLOWED_PRODUCT_STRINGS: - /* Construct only */ - priv->product_strings = g_value_dup_boxed (value); - break; - case PROP_ALLOWED_UDEV_TAGS: - /* Construct only */ - priv->udev_tags = g_value_dup_boxed (value); - break; - case PROP_ALLOWED_AT: - /* Construct only */ - priv->at = g_value_get_boolean (value); - break; - case PROP_ALLOWED_SINGLE_AT: - /* Construct only */ - priv->single_at = g_value_get_boolean (value); - break; - case PROP_ALLOWED_QCDM: - /* Construct only */ - priv->qcdm = g_value_get_boolean (value); - break; - case PROP_CUSTOM_INIT: - /* Construct only */ - priv->custom_init = g_value_dup_boxed (value); - break; - case PROP_SEND_DELAY: - /* Construct only */ - priv->send_delay = (guint64)g_value_get_uint64 (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_NAME: - g_value_set_string (value, priv->name); - break; - case PROP_ALLOWED_SUBSYSTEMS: - g_value_set_boxed (value, priv->subsystems); - break; - case PROP_ALLOWED_DRIVERS: - g_value_set_boxed (value, priv->drivers); - break; - case PROP_ALLOWED_VENDOR_IDS: - g_value_set_boxed (value, priv->vendor_ids); - break; - case PROP_ALLOWED_PRODUCT_IDS: - g_value_set_boxed (value, priv->product_ids); - break; - case PROP_ALLOWED_VENDOR_STRINGS: - g_value_set_boxed (value, priv->vendor_strings); - break; - case PROP_ALLOWED_PRODUCT_STRINGS: - g_value_set_boxed (value, priv->product_strings); - break; - case PROP_ALLOWED_AT: - g_value_set_boolean (value, priv->at); - break; - case PROP_ALLOWED_SINGLE_AT: - g_value_set_boolean (value, priv->single_at); - break; - case PROP_ALLOWED_QCDM: - g_value_set_boolean (value, priv->qcdm); - break; - case PROP_ALLOWED_UDEV_TAGS: - g_value_set_boxed (value, priv->udev_tags); - break; - case PROP_CUSTOM_INIT: - g_value_set_boxed (value, priv->custom_init); - break; - case PROP_SEND_DELAY: - g_value_set_uint64 (value, priv->send_delay); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -finalize (GObject *object) -{ - MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (object); - - g_free (priv->name); - - g_object_unref (priv->client); - - g_hash_table_destroy (priv->tasks); - - G_OBJECT_CLASS (mm_plugin_base_parent_class)->finalize (object); -} - -static void -mm_plugin_base_class_init (MMPluginBaseClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (object_class, sizeof (MMPluginBasePrivate)); - - /* Virtual methods */ - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; - - g_object_class_install_property - (object_class, PROP_NAME, - g_param_spec_string (MM_PLUGIN_BASE_NAME, - "Name", - "Name", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_ALLOWED_SUBSYSTEMS, - g_param_spec_boxed (MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, - "Allowed subsystems", - "List of subsystems this plugin can support, " - "should be an array of strings finished with 'NULL'", - G_TYPE_STRV, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_ALLOWED_DRIVERS, - g_param_spec_boxed (MM_PLUGIN_BASE_ALLOWED_DRIVERS, - "Allowed drivers", - "List of drivers this plugin can support, " - "should be an array of strings finished with 'NULL'", - G_TYPE_STRV, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_ALLOWED_VENDOR_IDS, - g_param_spec_boxed (MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, - "Allowed vendor IDs", - "List of vendor IDs this plugin can support, " - "should be an array of guint16 finished with '0'", - MM_TYPE_UINT16_ARRAY, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_ALLOWED_PRODUCT_IDS, - g_param_spec_boxed (MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS, - "Allowed product IDs", - "List of vendor+product ID pairs this plugin can support, " - "should be an array of mm_uint16_pair finished with '0,0'", - MM_TYPE_UINT16_PAIR_ARRAY, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - - g_object_class_install_property - (object_class, PROP_ALLOWED_VENDOR_STRINGS, - g_param_spec_boxed (MM_PLUGIN_BASE_ALLOWED_VENDOR_STRINGS, - "Allowed vendor strings", - "List of vendor strings this plugin can support, " - "should be an array of strings finished with 'NULL'", - G_TYPE_STRV, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_ALLOWED_PRODUCT_STRINGS, - g_param_spec_boxed (MM_PLUGIN_BASE_ALLOWED_PRODUCT_STRINGS, - "Allowed product strings", - "List of vendor+product string pairs this plugin can support, " - "should be an array of mm_str_pair finished with 'NULL,NULL'", - MM_TYPE_STR_PAIR_ARRAY, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_ALLOWED_UDEV_TAGS, - g_param_spec_boxed (MM_PLUGIN_BASE_ALLOWED_UDEV_TAGS, - "Allowed Udev tags", - "List of udev tags this plugin may expect, " - "should be an array of strings finished with 'NULL'", - G_TYPE_STRV, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_ALLOWED_AT, - g_param_spec_boolean (MM_PLUGIN_BASE_ALLOWED_AT, - "Allowed AT", - "Whether AT ports are allowed in this plugin", - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_ALLOWED_SINGLE_AT, - g_param_spec_boolean (MM_PLUGIN_BASE_ALLOWED_SINGLE_AT, - "Allowed single AT", - "Whether just a single AT port is allowed in this plugin. ", - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_ALLOWED_QCDM, - g_param_spec_boolean (MM_PLUGIN_BASE_ALLOWED_QCDM, - "Allowed QCDM", - "Whether QCDM ports are allowed in this plugin", - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_CUSTOM_INIT, - g_param_spec_boxed (MM_PLUGIN_BASE_CUSTOM_INIT, - "Custom initialization", - "List of custom initializations this plugin needs, " - "should be an array of MMPortProbeAtCommand structs " - "finished with 'NULL'", - MM_TYPE_POINTER_ARRAY, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property - (object_class, PROP_SEND_DELAY, - g_param_spec_uint64 (MM_PLUGIN_BASE_SEND_DELAY, - "Send delay", - "Send delay for characters in the AT port, " - "in microseconds", - 0, G_MAXUINT64, 100000, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); -} diff --git a/src/mm-plugin-base.h b/src/mm-plugin-base.h deleted file mode 100644 index 804f706f..00000000 --- a/src/mm-plugin-base.h +++ /dev/null @@ -1,79 +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) 2009 Red Hat, Inc. - */ - -#ifndef MM_PLUGIN_BASE_H -#define MM_PLUGIN_BASE_H - -#include <glib.h> -#include <glib-object.h> -#include <gudev/gudev.h> - -#include "mm-plugin.h" -#include "mm-base-modem.h" -#include "mm-port.h" -#include "mm-port-probe.h" - -#define MM_TYPE_PLUGIN_BASE (mm_plugin_base_get_type ()) -#define MM_PLUGIN_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBase)) -#define MM_PLUGIN_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_BASE, MMPluginBaseClass)) -#define MM_IS_PLUGIN_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_BASE)) -#define MM_IS_PLUBIN_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_BASE)) -#define MM_PLUGIN_BASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBaseClass)) - -#define MM_PLUGIN_BASE_NAME "name" -#define MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS "allowed-subsystems" -#define MM_PLUGIN_BASE_ALLOWED_DRIVERS "allowed-drivers" -#define MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS "allowed-vendor-ids" -#define MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS "allowed-product-ids" -#define MM_PLUGIN_BASE_ALLOWED_VENDOR_STRINGS "allowed-vendor-strings" -#define MM_PLUGIN_BASE_ALLOWED_PRODUCT_STRINGS "allowed-product-strings" -#define MM_PLUGIN_BASE_ALLOWED_UDEV_TAGS "allowed-udev-tags" -#define MM_PLUGIN_BASE_ALLOWED_AT "allowed-at" -#define MM_PLUGIN_BASE_ALLOWED_SINGLE_AT "allowed-single-at" -#define MM_PLUGIN_BASE_ALLOWED_QCDM "allowed-qcdm" -#define MM_PLUGIN_BASE_CUSTOM_INIT "custom-init" -#define MM_PLUGIN_BASE_SEND_DELAY "send-delay" -#define MM_PLUGIN_BASE_SORT_LAST "sort-last" - -typedef struct _MMPluginBase MMPluginBase; -typedef struct _MMPluginBaseClass MMPluginBaseClass; - -struct _MMPluginBase { - GObject parent; -}; - -struct _MMPluginBaseClass { - GObjectClass parent; - - /* Mandatory subclass functions */ - - MMBaseModem *(*create_modem) (MMPluginBase *plugin, - const gchar *sysfs_path, - const gchar *driver, - guint16 vendor, - guint16 product, - GList *probes, - GError **error); - - gboolean (*grab_port) (MMPluginBase *plugin, - MMBaseModem *modem, - MMPortProbe *probe, - GError **error); -}; - -GType mm_plugin_base_get_type (void); - - -#endif /* MM_PLUGIN_BASE_H */ diff --git a/src/mm-plugin.c b/src/mm-plugin.c index 6418e295..c2b75f97 100644 --- a/src/mm-plugin.c +++ b/src/mm-plugin.c @@ -10,50 +10,546 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details: * - * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2009 Red Hat, Inc. + * Copyright (C) 2008 - 2009 Novell, Inc. + * Copyright (C) 2009 - 2012 Red Hat, Inc. + * Copyright (C) 2012 Google, Inc. */ +#define _GNU_SOURCE /* for strcasestr */ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <unistd.h> +#include <string.h> + +#include <gudev/gudev.h> + +#include <ModemManager.h> +#include <mm-errors-types.h> + #include "mm-plugin.h" +#include "mm-port-probe-cache.h" +#include "mm-at-serial-port.h" +#include "mm-qcdm-serial-port.h" +#include "mm-serial-parsers.h" +#include "mm-marshal.h" +#include "mm-utils.h" +#include "mm-private-boxed-types.h" +#include "libqcdm/src/commands.h" +#include "libqcdm/src/utils.h" +#include "libqcdm/src/errors.h" +#include "mm-log.h" + +G_DEFINE_TYPE (MMPlugin, mm_plugin, G_TYPE_OBJECT) + +#define MM_PLUGIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_PLUGIN, MMPluginPrivate)) + +/* Virtual port corresponding to the embeded modem */ +static gchar *virtual_port[] = {"smd0", NULL}; + +typedef struct { + gchar *name; + GUdevClient *client; + GHashTable *tasks; + + /* Plugin-specific setups */ + gchar **subsystems; + gchar **drivers; + guint16 *vendor_ids; + mm_uint16_pair *product_ids; + gchar **vendor_strings; + mm_str_pair *product_strings; + gchar **udev_tags; + gboolean at; + gboolean single_at; + gboolean qcdm; + MMPortProbeAtCommand *custom_init; + guint64 send_delay; +} MMPluginPrivate; + +enum { + PROP_0, + PROP_NAME, + PROP_ALLOWED_SUBSYSTEMS, + PROP_ALLOWED_DRIVERS, + PROP_ALLOWED_VENDOR_IDS, + PROP_ALLOWED_PRODUCT_IDS, + PROP_ALLOWED_VENDOR_STRINGS, + PROP_ALLOWED_PRODUCT_STRINGS, + PROP_ALLOWED_UDEV_TAGS, + PROP_ALLOWED_AT, + PROP_ALLOWED_SINGLE_AT, + PROP_ALLOWED_QCDM, + PROP_CUSTOM_INIT, + PROP_SEND_DELAY, + LAST_PROP +}; + +/*****************************************************************************/ + +static gboolean +get_device_ids (MMPlugin *self, + const char *subsys, + const char *name, + guint16 *vendor, + guint16 *product) +{ + MMPluginPrivate *priv; + GUdevDevice *device = NULL, *parent = NULL; + const char *vid = NULL, *pid = NULL, *parent_subsys; + gboolean success = FALSE; + + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (MM_IS_PLUGIN (self), FALSE); + g_return_val_if_fail (subsys != NULL, FALSE); + g_return_val_if_fail (name != NULL, FALSE); + if (vendor) + g_return_val_if_fail (*vendor == 0, FALSE); + if (product) + g_return_val_if_fail (*product == 0, FALSE); + + priv = MM_PLUGIN_GET_PRIVATE (self); + + device = g_udev_client_query_by_subsystem_and_name (priv->client, subsys, name); + if (!device) + goto out; + + parent = g_udev_device_get_parent (device); + if (parent) { + parent_subsys = g_udev_device_get_subsystem (parent); + if (parent_subsys) { + if (!strcmp (parent_subsys, "bluetooth")) { + /* Bluetooth devices report the VID/PID of the BT adapter here, + * which isn't really what we want. Just return null IDs instead. + */ + success = TRUE; + goto out; + } else if (!strcmp (parent_subsys, "pcmcia")) { + /* For PCMCIA devices we need to grab the PCMCIA subsystem's + * manfid and cardid, since any IDs on the tty device itself + * may be from PCMCIA controller or something else. + */ + vid = g_udev_device_get_sysfs_attr (parent, "manf_id"); + pid = g_udev_device_get_sysfs_attr (parent, "card_id"); + if (!vid || !pid) + goto out; + } else if (!strcmp (parent_subsys, "platform")) { + /* Platform devices don't usually have a VID/PID */ + success = TRUE; + goto out; + } + } + } + + if (!vid) + vid = g_udev_device_get_property (device, "ID_VENDOR_ID"); + if (!vid) + goto out; + + if (strncmp (vid, "0x", 2) == 0) + vid += 2; + if (strlen (vid) != 4) + goto out; + + if (vendor) { + *vendor = (guint16) (utils_hex2byte (vid + 2) & 0xFF); + *vendor |= (guint16) ((utils_hex2byte (vid) & 0xFF) << 8); + } + + if (!pid) + pid = g_udev_device_get_property (device, "ID_MODEL_ID"); + if (!pid) { + *vendor = 0; + goto out; + } + + if (strncmp (pid, "0x", 2) == 0) + pid += 2; + if (strlen (pid) != 4) { + *vendor = 0; + goto out; + } + + if (product) { + *product = (guint16) (utils_hex2byte (pid + 2) & 0xFF); + *product |= (guint16) ((utils_hex2byte (pid) & 0xFF) << 8); + } + + success = TRUE; + +out: + if (device) + g_object_unref (device); + if (parent) + g_object_unref (parent); + return success; +} + +static char * +get_key (const char *subsys, const char *name) +{ + return g_strdup_printf ("%s%s", subsys, name); +} const char * mm_plugin_get_name (MMPlugin *plugin) { - g_return_val_if_fail (MM_IS_PLUGIN (plugin), NULL); - - return MM_PLUGIN_GET_INTERFACE (plugin)->get_name (plugin); + return MM_PLUGIN_GET_PRIVATE (plugin)->name; } gboolean mm_plugin_get_sort_last (const MMPlugin *plugin) { - g_return_val_if_fail (MM_IS_PLUGIN (plugin), FALSE); + MMPluginPrivate *priv = MM_PLUGIN_GET_PRIVATE (plugin); - return MM_PLUGIN_GET_INTERFACE (plugin)->get_sort_last (plugin); + /* If we have any post-probing filter, we need to sort the plugin last */ + return (priv->vendor_strings || priv->product_strings); } -void -mm_plugin_supports_port (MMPlugin *self, - const gchar *subsys, - const gchar *name, - const gchar *physdev_path, - MMBaseModem *existing, - GAsyncReadyCallback callback, - gpointer user_data) +static char * +get_driver_name (GUdevDevice *device) +{ + GUdevDevice *parent = NULL; + const char *driver, *subsys; + char *ret = NULL; + + 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); + + /* Check for bluetooth; it's driver is a bunch of levels up so we + * just check for the subsystem of the parent being bluetooth. + */ + if (!driver && parent) { + subsys = g_udev_device_get_subsystem (parent); + if (subsys && !strcmp (subsys, "bluetooth")) + driver = "bluetooth"; + } + } + + if (driver) + ret = g_strdup (driver); + if (parent) + g_object_unref (parent); + + return ret; +} + +static gboolean +device_file_exists (const char *name) +{ + char *devfile; + struct stat s; + int result; + + devfile = g_strdup_printf ("/dev/%s", name); + result = stat (devfile, &s); + g_free (devfile); + + return (0 == result) ? TRUE : FALSE; +} + +static gboolean +is_virtual_port (const gchar *device_name) +{ + guint idx; + + /* Detect any modems accessible through the list of virtual ports */ + for (idx = 0; virtual_port[idx]; idx++) { + if (strcmp (device_name, virtual_port[idx])) + continue; + if (!device_file_exists (virtual_port[idx])) + continue; + + return TRUE; + } + + return FALSE; +} + +/* Returns TRUE if the support check request was filtered out */ +static gboolean +apply_pre_probing_filters (MMPlugin *self, + GUdevDevice *port, + const gchar *subsys, + const gchar *name, + const gchar *driver, + gboolean *need_vendor_probing, + gboolean *need_product_probing) +{ + MMPluginPrivate *priv = MM_PLUGIN_GET_PRIVATE (self); + guint16 vendor = 0; + guint16 product = 0; + gboolean product_filtered = FALSE; + gboolean vendor_filtered = FALSE; + guint i; + + *need_vendor_probing = FALSE; + *need_product_probing = FALSE; + + /* The plugin may specify that only some subsystems are supported. If that + * is the case, filter by subsystem */ + if (priv->subsystems) { + for (i = 0; priv->subsystems[i]; i++) { + if (g_str_equal (subsys, priv->subsystems[i])) + break; + } + + /* If we didn't match any subsystem: unsupported */ + if (!priv->subsystems[i]) + return TRUE; + } + + /* The plugin may specify that only some drivers are supported. If that + * is the case, filter by driver */ + if (priv->drivers) { + for (i = 0; priv->drivers[i]; i++) { + if (g_str_equal (driver, priv->drivers[i])) + break; + } + + /* If we didn't match any driver: unsupported */ + if (!priv->drivers[i]) + return TRUE; + } + + get_device_ids (self, subsys, name, &vendor, &product); + + /* The plugin may specify that only some vendor IDs are supported. If that + * is the case, filter by vendor ID. */ + if (priv->vendor_ids) { + /* If we didn't get any vendor: filtered */ + if (!vendor) + vendor_filtered = TRUE; + else { + for (i = 0; priv->vendor_ids[i]; i++) + if (vendor == priv->vendor_ids[i]) + break; + + /* If we didn't match any vendor: filtered */ + if (!priv->vendor_ids[i]) + vendor_filtered = TRUE; + } + } + + /* The plugin may specify that only some product IDs are supported. If + * that is the case, filter by vendor+product ID pair */ + if (priv->product_ids) { + /* If we didn't get any product: filtered */ + if (!product) + product_filtered = TRUE; + else { + for (i = 0; priv->product_ids[i].l; i++) + if (vendor == priv->product_ids[i].l && + product == priv->product_ids[i].r) + break; + + /* If we didn't match any product: filtered */ + if (!priv->product_ids[i].l) + product_filtered = TRUE; + } + } + + /* If we got filtered by vendor or product IDs and we do not have vendor + * or product strings to compare with: unsupported */ + if ((vendor_filtered || product_filtered) && + !priv->vendor_strings && + !priv->product_strings) + return TRUE; + + /* If we need to filter by vendor/product strings, need to probe for both. + * This covers the case where a RS232 modem is connected via a USB<->RS232 + * adaptor, and we get in udev the vendor ID of the adaptor */ + + if (priv->product_strings) { + *need_vendor_probing = TRUE; + *need_product_probing = TRUE; + } else if (priv->vendor_strings) + *need_vendor_probing = TRUE; + + /* The plugin may specify that only ports with some given udev tags are + * supported. If that is the case, filter by udev tag */ + if (priv->udev_tags) { + for (i = 0; priv->udev_tags[i]; i++) { + /* Check if the port was tagged */ + if (g_udev_device_get_property_as_boolean (port, + priv->udev_tags[i])) + break; + } + + /* If we didn't match any udev tag: unsupported */ + if (!priv->udev_tags[i]) + return TRUE; + } + + return FALSE; +} + +/* Returns TRUE if the support check request was filtered out */ +static gboolean +apply_post_probing_filters (MMPlugin *self, + MMPortProbe *probe) +{ + MMPluginPrivate *priv = MM_PLUGIN_GET_PRIVATE (self); + gboolean vendor_filtered = FALSE; + gboolean product_filtered = FALSE; + guint i; + + /* The plugin may specify that only some vendor strings are supported. If + * that is the case, filter by vendor string. */ + if (priv->vendor_strings) { + const gchar *vendor; + + vendor = mm_port_probe_get_vendor (probe); + + /* If we didn't get any vendor: filtered */ + if (!vendor) + vendor_filtered = TRUE; + else { + for (i = 0; priv->vendor_strings[i]; i++) { + gboolean found; + gchar *casefolded; + + casefolded = g_utf8_casefold (priv->vendor_strings[i], -1); + found = !!strstr (vendor, casefolded); + g_free (casefolded); + if (found) + break; + } + + /* If we didn't match any vendor: filtered */ + if (!priv->vendor_strings[i]) + vendor_filtered = TRUE; + } + + if (vendor_filtered) { + if (!priv->product_strings) + return TRUE; + } else + /* Vendor matched */ + return FALSE; + } + + /* The plugin may specify that only some vendor+product string pairs are + * supported. If that is the case, filter by product string */ + if (priv->product_strings) { + const gchar *vendor; + const gchar *product; + + vendor = mm_port_probe_get_vendor (probe); + product = mm_port_probe_get_product (probe); + + /* If we didn't get any vendor or product: filtered */ + if (!vendor || !product) + product_filtered = TRUE; + else { + for (i = 0; priv->product_strings[i].l; i++) { + gboolean found; + gchar *casefolded_vendor; + gchar *casefolded_product; + + casefolded_vendor = g_utf8_casefold (priv->product_strings[i].l, -1); + casefolded_product = g_utf8_casefold (priv->product_strings[i].r, -1); + found = (!!strstr (vendor, casefolded_vendor) && + !!strstr (product, casefolded_product)); + g_free (casefolded_vendor); + g_free (casefolded_product); + if (found) + break; + } + + /* If we didn't match any product: unsupported */ + if (!priv->product_strings[i].l) + product_filtered = TRUE; + } + + return product_filtered; + } + + return FALSE; +} + +/* Context for the asynchronous probing operation */ +typedef struct { + GSimpleAsyncResult *result; + MMPlugin *plugin; + MMPortProbeFlag flags; +} PortProbeRunContext; + +static void +cancel_at_probing_in_other_probes (const gchar *key, + MMPortProbe *other, + MMPortProbe *self) { - g_return_if_fail (MM_IS_PLUGIN (self)); - g_return_if_fail (subsys != NULL); - g_return_if_fail (name != NULL); - g_return_if_fail (physdev_path != NULL); - g_return_if_fail (callback != NULL); + if (self != other && + g_str_equal (mm_port_probe_get_port_physdev (self), + mm_port_probe_get_port_physdev (other))) + mm_port_probe_run_cancel_at_probing (other); +} + +static void +port_probe_run_ready (MMPortProbe *probe, + GAsyncResult *probe_result, + PortProbeRunContext *ctx) +{ + MMPluginPrivate *priv = MM_PLUGIN_GET_PRIVATE (ctx->plugin); + GError *error = NULL; + gboolean keep_probe = FALSE; + + if (!mm_port_probe_run_finish (probe, probe_result, &error)) { + /* Probing failed */ + g_simple_async_result_take_error (ctx->result, error); + } else { + /* Probing succeeded */ + MMPluginSupportsResult supports_result; + + if (!apply_post_probing_filters (ctx->plugin, probe)) { + /* Port is supported! Leave it in the internal HT until port gets + * grabbed. */ + supports_result = MM_PLUGIN_SUPPORTS_PORT_SUPPORTED; + keep_probe = TRUE; + + /* If we were looking for AT ports, and the port is AT, + * and we were told that only one AT port is expected, cancel AT + * probings in the other available support tasks of the SAME + * device. */ + if (priv->single_at && + ctx->flags & MM_PORT_PROBE_AT && + mm_port_probe_is_at (probe)) { + g_hash_table_foreach (priv->tasks, + (GHFunc) cancel_at_probing_in_other_probes, + probe); + } + + } else { + /* Unsupported port, remove from internal tracking HT */ + supports_result = MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED; + } + + g_simple_async_result_set_op_res_gpointer (ctx->result, + GUINT_TO_POINTER (supports_result), + NULL); + } + + /* Complete the async supports port request */ + g_simple_async_result_complete_in_idle (ctx->result); - MM_PLUGIN_GET_INTERFACE (self)->supports_port (self, - subsys, - name, - physdev_path, - existing, - callback, - user_data); + /* If no longer needed, Remove probe from internal HT */ + if (!keep_probe) { + gchar *key; + + key = get_key (mm_port_probe_get_port_subsys (probe), + mm_port_probe_get_port_name (probe)); + g_hash_table_remove (priv->tasks, key); + g_free (key); + } + + g_object_unref (ctx->result); + g_object_unref (ctx->plugin); + g_free (ctx); } MMPluginSupportsResult @@ -66,9 +562,178 @@ mm_plugin_supports_port_finish (MMPlugin *self, g_return_val_if_fail (G_IS_ASYNC_RESULT (result), MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED); - return MM_PLUGIN_GET_INTERFACE (self)->supports_port_finish (self, - result, - error); + /* Propagate error, if any */ + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), + error)) { + return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED; + } + + return (MMPluginSupportsResult) GPOINTER_TO_UINT (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result))); +} + +void +mm_plugin_supports_port (MMPlugin *plugin, + const gchar *subsys, + const gchar *name, + const gchar *physdev_path, + MMBaseModem *existing, + GAsyncReadyCallback callback, + gpointer user_data) +{ + MMPlugin *self = MM_PLUGIN (plugin); + MMPluginPrivate *priv = MM_PLUGIN_GET_PRIVATE (self); + GUdevDevice *port = NULL; + gchar *driver = NULL; + gchar *key = NULL; + MMPortProbe *probe; + GSimpleAsyncResult *async_result; + PortProbeRunContext *ctx; + gboolean need_vendor_probing; + gboolean need_product_probing; + MMPortProbeFlag probe_run_flags; + + /* Setup key */ + key = get_key (subsys, name); + + async_result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + mm_plugin_supports_port); + + /* Get port device */ + if (!(port = g_udev_client_query_by_subsystem_and_name (priv->client, + subsys, + name))) { + g_simple_async_result_set_error (async_result, + MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Couldn't find port for (%s/%s)", + subsys, + name); + g_simple_async_result_complete_in_idle (async_result); + goto out; + } + + /* Detect any modems accessible through the list of virtual ports */ + if (!(driver = (is_virtual_port (name) ? + g_strdup ("virtual") : + get_driver_name (port)))) { + g_simple_async_result_set_error (async_result, + MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Couldn't find driver for (%s/%s)", + subsys, + name); + g_simple_async_result_complete_in_idle (async_result); + goto out; + } + + /* Apply filters before launching the probing */ + if (apply_pre_probing_filters (self, + port, + subsys, + name, + driver, + &need_vendor_probing, + &need_product_probing)) { + /* Filtered! */ + g_simple_async_result_set_op_res_gpointer (async_result, + GUINT_TO_POINTER (MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED), + NULL); + g_simple_async_result_complete_in_idle (async_result); + goto out; + } + + mm_dbg ("(%s) checking port support (%s,%s)", priv->name, subsys, name); + + /* Need to launch new probing */ + + /* Lookup current probes, there shouldn't be any (unless for net devices) */ + probe = g_hash_table_lookup (priv->tasks, key); + if (!probe) + probe = mm_port_probe_cache_get (port, physdev_path, driver); + g_assert (probe); + + /* Before launching any probing, check if the port is a net device (which + * cannot be probed). + * TODO: With the new defer-until-suggested we probably don't need the modem + * object being passed down here just for this. */ + if (g_str_equal (subsys, "net")) { + /* Keep track of the probe object, which is considered finished */ + if (!g_hash_table_lookup (priv->tasks, key)) + g_hash_table_insert (priv->tasks, + g_strdup (key), + g_object_ref (probe)); + + /* If we already have a existing modem, then mark it as supported. + * Otherwise, just defer a bit */ + g_simple_async_result_set_op_res_gpointer ( + async_result, + GUINT_TO_POINTER ((existing ? + MM_PLUGIN_SUPPORTS_PORT_SUPPORTED : + MM_PLUGIN_SUPPORTS_PORT_DEFER_UNTIL_SUGGESTED)), + NULL); + g_simple_async_result_complete_in_idle (async_result); + goto out; + } + + /* Build flags depending on what probing needed */ + probe_run_flags = MM_PORT_PROBE_NONE; + if (priv->at) + probe_run_flags |= MM_PORT_PROBE_AT; + else if (priv->single_at) + probe_run_flags |= MM_PORT_PROBE_AT; + if (need_vendor_probing) + probe_run_flags |= (MM_PORT_PROBE_AT | MM_PORT_PROBE_AT_VENDOR); + if (need_product_probing) + probe_run_flags |= (MM_PORT_PROBE_AT | MM_PORT_PROBE_AT_PRODUCT); + if (priv->qcdm) + probe_run_flags |= MM_PORT_PROBE_QCDM; + + g_assert (probe_run_flags != MM_PORT_PROBE_NONE); + + /* If a modem is already available and the plugin says that only one AT port is + * expected, check if we alredy got the single AT port. And if so, we know this + * port being probed won't be AT. */ + if (priv->single_at && + existing && + mm_base_modem_has_at_port (existing)) { + mm_dbg ("(%s) not setting up AT probing tasks for (%s,%s): " + "modem already has the expected single AT port", + priv->name, subsys, name); + + /* Assuming it won't be an AT port. We still run the probe anyway, in + * case we need to check for other port types (e.g. QCDM) */ + mm_port_probe_set_result_at (probe, FALSE); + } + + /* Setup async call context */ + ctx = g_new (PortProbeRunContext, 1); + ctx->plugin = g_object_ref (self); + ctx->result = g_object_ref (async_result); + ctx->flags = probe_run_flags; + + /* Launch the probe */ + mm_dbg ("(%s) launching probe for (%s,%s)", priv->name, subsys, name); + mm_port_probe_run (probe, + ctx->flags, + priv->send_delay, + priv->custom_init, + (GAsyncReadyCallback)port_probe_run_ready, + ctx); + + /* Keep track of the probe. Note that we got a new reference already + * from the cache. */ + g_hash_table_insert (priv->tasks, + g_strdup (key), + probe); + +out: + if (port) + g_object_unref (port); + g_free (key); + g_free (driver); + g_object_unref (async_result); } void @@ -76,55 +741,384 @@ mm_plugin_supports_port_cancel (MMPlugin *plugin, const char *subsys, const char *name) { - g_return_if_fail (MM_IS_PLUGIN (plugin)); - g_return_if_fail (subsys != NULL); - g_return_if_fail (name != NULL); + MMPlugin *self = MM_PLUGIN (plugin); + MMPluginPrivate *priv = MM_PLUGIN_GET_PRIVATE (self); + MMPortProbe *probe; + gchar *key; + + key = get_key (subsys, name); + probe = g_hash_table_lookup (priv->tasks, key); + if (probe) { + mm_port_probe_run_cancel (probe); + g_hash_table_remove (priv->tasks, key); + } - MM_PLUGIN_GET_INTERFACE (plugin)->supports_port_cancel (plugin, subsys, name); + g_free (key); } MMBaseModem * -mm_plugin_create_modem (MMPlugin *plugin, - GList *ports, - GError **error) +mm_plugin_create_modem (MMPlugin *self, + GList *ports, + GError **error) { - if (MM_PLUGIN_GET_INTERFACE (plugin)->create_modem) - return MM_PLUGIN_GET_INTERFACE (plugin)->create_modem (plugin, ports, error); + MMBaseModem *modem = NULL; + MMPluginPrivate *priv = MM_PLUGIN_GET_PRIVATE (self); + GList *probes = NULL; + GList *l; + const gchar *name, *subsys, *sysfs_path, *driver; + guint16 vendor = 0, product = 0; + + /* Get the port probe results for each of the ports */ + for (l = ports; l; l = g_list_next (l)) { + MMPortProbe *probe; + gchar *key; + + subsys = g_udev_device_get_subsystem (G_UDEV_DEVICE (l->data)); + name = g_udev_device_get_name (G_UDEV_DEVICE (l->data)); + + key = get_key (subsys, name); + probe = g_hash_table_lookup (priv->tasks, key); + if (!probe) + mm_warn ("(%s/%s) Ignoring port when creating modem with plugin '%s'", + subsys, + name, + priv->name); + else + probes = g_list_prepend (probes, g_object_ref (probe)); + g_free (key); + } + + /* Get info from the first probe in the list */ + subsys = mm_port_probe_get_port_subsys (probes->data); + name = mm_port_probe_get_port_name (probes->data); + sysfs_path = mm_port_probe_get_port_physdev (probes->data); + driver = mm_port_probe_get_port_driver (probes->data); + + /* Vendor and Product IDs are really optional, we'll just warn if they + * cannot get loaded */ + if (!get_device_ids (MM_PLUGIN (self), subsys, name, &vendor, &product)) + mm_warn ("Could not get modem vendor/product ID"); + + /* Let the plugin create the modem from the port probe results */ + modem = MM_PLUGIN_GET_CLASS (self)->create_modem (MM_PLUGIN (self), + sysfs_path, + driver, + vendor, + product, + probes, + error); + if (modem) { + /* Grab each port */ + for (l = probes; l; l = g_list_next (l)) { + GError *inner_error = NULL; + + /* If grabbing a port fails, just warn. We'll decide if the modem is + * valid or not when all ports get organized */ + if (!MM_PLUGIN_GET_CLASS (self)->grab_port (MM_PLUGIN (self), + modem, + MM_PORT_PROBE (l->data), + &inner_error)) { + mm_warn ("Could not grab port (%s/%s): '%s'", + mm_port_probe_get_port_subsys (MM_PORT_PROBE (l->data)), + mm_port_probe_get_port_name (MM_PORT_PROBE (l->data)), + inner_error ? inner_error->message : "unknown error"); + g_clear_error (&inner_error); + } + } + + /* If organizing ports fails, consider the modem invalid */ + if (!mm_base_modem_organize_ports (modem, error)) + g_clear_object (&modem); + } - return NULL; + for (l = probes; l; l = g_list_next (l)) { + gchar *key; + + key = get_key (mm_port_probe_get_port_subsys (l->data), + mm_port_probe_get_port_name (l->data)); + g_hash_table_remove (priv->tasks, key); + g_free (key); + } + + g_list_free_full (probes, (GDestroyNotify) g_object_unref); + + return modem; } /*****************************************************************************/ static void -mm_plugin_init (gpointer g_iface) +mm_plugin_init (MMPlugin *self) { + MMPluginPrivate *priv = MM_PLUGIN_GET_PRIVATE (self); + + /* We pass NULL as we won't need to get notified about uevents, + * we just use this client for sync queries. */ + priv->client = g_udev_client_new (NULL); + + priv->tasks = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + (GDestroyNotify) g_object_unref); + /* Defaults */ + priv->send_delay = 100000; } -GType -mm_plugin_get_type (void) +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) { - static GType plugin_type = 0; + MMPluginPrivate *priv = MM_PLUGIN_GET_PRIVATE (object); - if (!G_UNLIKELY (plugin_type)) { - const GTypeInfo plugin_info = { - sizeof (MMPlugin), /* class_size */ - mm_plugin_init, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; + switch (prop_id) { + case PROP_NAME: + /* Construct only */ + priv->name = g_value_dup_string (value); + break; + case PROP_ALLOWED_SUBSYSTEMS: + /* Construct only */ + priv->subsystems = g_value_dup_boxed (value); + break; + case PROP_ALLOWED_DRIVERS: + /* Construct only */ + priv->drivers = g_value_dup_boxed (value); + break; + case PROP_ALLOWED_VENDOR_IDS: + /* Construct only */ + priv->vendor_ids = g_value_dup_boxed (value); + break; + case PROP_ALLOWED_PRODUCT_IDS: + /* Construct only */ + priv->product_ids = g_value_dup_boxed (value); + break; + case PROP_ALLOWED_VENDOR_STRINGS: + /* Construct only */ + priv->vendor_strings = g_value_dup_boxed (value); + break; + case PROP_ALLOWED_PRODUCT_STRINGS: + /* Construct only */ + priv->product_strings = g_value_dup_boxed (value); + break; + case PROP_ALLOWED_UDEV_TAGS: + /* Construct only */ + priv->udev_tags = g_value_dup_boxed (value); + break; + case PROP_ALLOWED_AT: + /* Construct only */ + priv->at = g_value_get_boolean (value); + break; + case PROP_ALLOWED_SINGLE_AT: + /* Construct only */ + priv->single_at = g_value_get_boolean (value); + break; + case PROP_ALLOWED_QCDM: + /* Construct only */ + priv->qcdm = g_value_get_boolean (value); + break; + case PROP_CUSTOM_INIT: + /* Construct only */ + priv->custom_init = g_value_dup_boxed (value); + break; + case PROP_SEND_DELAY: + /* Construct only */ + priv->send_delay = (guint64)g_value_get_uint64 (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} - plugin_type = g_type_register_static (G_TYPE_INTERFACE, - "MMPlugin", - &plugin_info, 0); +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + MMPluginPrivate *priv = MM_PLUGIN_GET_PRIVATE (object); - g_type_interface_add_prerequisite (plugin_type, G_TYPE_OBJECT); + switch (prop_id) { + case PROP_NAME: + g_value_set_string (value, priv->name); + break; + case PROP_ALLOWED_SUBSYSTEMS: + g_value_set_boxed (value, priv->subsystems); + break; + case PROP_ALLOWED_DRIVERS: + g_value_set_boxed (value, priv->drivers); + break; + case PROP_ALLOWED_VENDOR_IDS: + g_value_set_boxed (value, priv->vendor_ids); + break; + case PROP_ALLOWED_PRODUCT_IDS: + g_value_set_boxed (value, priv->product_ids); + break; + case PROP_ALLOWED_VENDOR_STRINGS: + g_value_set_boxed (value, priv->vendor_strings); + break; + case PROP_ALLOWED_PRODUCT_STRINGS: + g_value_set_boxed (value, priv->product_strings); + break; + case PROP_ALLOWED_AT: + g_value_set_boolean (value, priv->at); + break; + case PROP_ALLOWED_SINGLE_AT: + g_value_set_boolean (value, priv->single_at); + break; + case PROP_ALLOWED_QCDM: + g_value_set_boolean (value, priv->qcdm); + break; + case PROP_ALLOWED_UDEV_TAGS: + g_value_set_boxed (value, priv->udev_tags); + break; + case PROP_CUSTOM_INIT: + g_value_set_boxed (value, priv->custom_init); + break; + case PROP_SEND_DELAY: + g_value_set_uint64 (value, priv->send_delay); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; } +} + +static void +finalize (GObject *object) +{ + MMPluginPrivate *priv = MM_PLUGIN_GET_PRIVATE (object); + + g_free (priv->name); + + g_object_unref (priv->client); + + g_hash_table_destroy (priv->tasks); + + G_OBJECT_CLASS (mm_plugin_parent_class)->finalize (object); +} + +static void +mm_plugin_class_init (MMPluginClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (MMPluginPrivate)); + + /* Virtual methods */ + object_class->get_property = get_property; + object_class->set_property = set_property; + object_class->finalize = finalize; + + g_object_class_install_property + (object_class, PROP_NAME, + g_param_spec_string (MM_PLUGIN_NAME, + "Name", + "Name", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_ALLOWED_SUBSYSTEMS, + g_param_spec_boxed (MM_PLUGIN_ALLOWED_SUBSYSTEMS, + "Allowed subsystems", + "List of subsystems this plugin can support, " + "should be an array of strings finished with 'NULL'", + G_TYPE_STRV, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_ALLOWED_DRIVERS, + g_param_spec_boxed (MM_PLUGIN_ALLOWED_DRIVERS, + "Allowed drivers", + "List of drivers this plugin can support, " + "should be an array of strings finished with 'NULL'", + G_TYPE_STRV, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_ALLOWED_VENDOR_IDS, + g_param_spec_boxed (MM_PLUGIN_ALLOWED_VENDOR_IDS, + "Allowed vendor IDs", + "List of vendor IDs this plugin can support, " + "should be an array of guint16 finished with '0'", + MM_TYPE_UINT16_ARRAY, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_ALLOWED_PRODUCT_IDS, + g_param_spec_boxed (MM_PLUGIN_ALLOWED_PRODUCT_IDS, + "Allowed product IDs", + "List of vendor+product ID pairs this plugin can support, " + "should be an array of mm_uint16_pair finished with '0,0'", + MM_TYPE_UINT16_PAIR_ARRAY, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + + g_object_class_install_property + (object_class, PROP_ALLOWED_VENDOR_STRINGS, + g_param_spec_boxed (MM_PLUGIN_ALLOWED_VENDOR_STRINGS, + "Allowed vendor strings", + "List of vendor strings this plugin can support, " + "should be an array of strings finished with 'NULL'", + G_TYPE_STRV, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_ALLOWED_PRODUCT_STRINGS, + g_param_spec_boxed (MM_PLUGIN_ALLOWED_PRODUCT_STRINGS, + "Allowed product strings", + "List of vendor+product string pairs this plugin can support, " + "should be an array of mm_str_pair finished with 'NULL,NULL'", + MM_TYPE_STR_PAIR_ARRAY, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_ALLOWED_UDEV_TAGS, + g_param_spec_boxed (MM_PLUGIN_ALLOWED_UDEV_TAGS, + "Allowed Udev tags", + "List of udev tags this plugin may expect, " + "should be an array of strings finished with 'NULL'", + G_TYPE_STRV, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_ALLOWED_AT, + g_param_spec_boolean (MM_PLUGIN_ALLOWED_AT, + "Allowed AT", + "Whether AT ports are allowed in this plugin", + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_ALLOWED_SINGLE_AT, + g_param_spec_boolean (MM_PLUGIN_ALLOWED_SINGLE_AT, + "Allowed single AT", + "Whether just a single AT port is allowed in this plugin. ", + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_ALLOWED_QCDM, + g_param_spec_boolean (MM_PLUGIN_ALLOWED_QCDM, + "Allowed QCDM", + "Whether QCDM ports are allowed in this plugin", + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property + (object_class, PROP_CUSTOM_INIT, + g_param_spec_boxed (MM_PLUGIN_CUSTOM_INIT, + "Custom initialization", + "List of custom initializations this plugin needs, " + "should be an array of MMPortProbeAtCommand structs " + "finished with 'NULL'", + MM_TYPE_POINTER_ARRAY, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - return plugin_type; + g_object_class_install_property + (object_class, PROP_SEND_DELAY, + g_param_spec_uint64 (MM_PLUGIN_SEND_DELAY, + "Send delay", + "Send delay for characters in the AT port, " + "in microseconds", + 0, G_MAXUINT64, 100000, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } diff --git a/src/mm-plugin.h b/src/mm-plugin.h index d31be1e4..89eeca67 100644 --- a/src/mm-plugin.h +++ b/src/mm-plugin.h @@ -11,30 +11,46 @@ * GNU General Public License for more details: * * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2009 Red Hat, Inc. + * Copyright (C) 2009 - 2012 Red Hat, Inc. + * Copyright (C) 2012 Google, Inc. */ #ifndef MM_PLUGIN_H #define MM_PLUGIN_H +#include <glib.h> #include <glib-object.h> -#include <gio/gio.h> +#include <gudev/gudev.h> #include "mm-base-modem.h" +#include "mm-port.h" +#include "mm-port-probe.h" #define MM_PLUGIN_GENERIC_NAME "Generic" - #define MM_PLUGIN_MAJOR_VERSION 4 #define MM_PLUGIN_MINOR_VERSION 0 -#define MM_TYPE_PLUGIN (mm_plugin_get_type ()) -#define MM_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN, MMPlugin)) -#define MM_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN)) -#define MM_PLUGIN_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_PLUGIN, MMPlugin)) - -typedef struct _MMPlugin MMPlugin; - -typedef MMPlugin *(*MMPluginCreateFunc) (void); +#define MM_TYPE_PLUGIN (mm_plugin_get_type ()) +#define MM_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN, MMPlugin)) +#define MM_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN, MMPluginClass)) +#define MM_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN)) +#define MM_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN)) +#define MM_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN, MMPluginClass)) + +#define MM_PLUGIN_NAME "name" +#define MM_PLUGIN_ALLOWED_SUBSYSTEMS "allowed-subsystems" +#define MM_PLUGIN_ALLOWED_DRIVERS "allowed-drivers" +#define MM_PLUGIN_ALLOWED_VENDOR_IDS "allowed-vendor-ids" +#define MM_PLUGIN_ALLOWED_PRODUCT_IDS "allowed-product-ids" +#define MM_PLUGIN_ALLOWED_VENDOR_STRINGS "allowed-vendor-strings" +#define MM_PLUGIN_ALLOWED_PRODUCT_STRINGS "allowed-product-strings" +#define MM_PLUGIN_ALLOWED_UDEV_TAGS "allowed-udev-tags" +#define MM_PLUGIN_ALLOWED_AT "allowed-at" +#define MM_PLUGIN_ALLOWED_SINGLE_AT "allowed-single-at" +#define MM_PLUGIN_ALLOWED_QCDM "allowed-qcdm" +#define MM_PLUGIN_CUSTOM_INIT "custom-init" +#define MM_PLUGIN_SEND_DELAY "send-delay" +#define MM_PLUGIN_SORT_LAST "sort-last" typedef enum { MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED = 0x0, @@ -43,73 +59,56 @@ typedef enum { MM_PLUGIN_SUPPORTS_PORT_SUPPORTED } MMPluginSupportsResult; +typedef struct _MMPlugin MMPlugin; +typedef struct _MMPluginClass MMPluginClass; + +typedef MMPlugin *(*MMPluginCreateFunc) (void); + struct _MMPlugin { - GTypeInterface g_iface; - - /* Get plugin name */ - const char *(*get_name) (MMPlugin *self); - - /* Returns TRUE if the plugin should be sorted last in the list of plugins - * loaded. This is useful to indicate plugins that need an additional check - * on the probed vendor ID to see if they can support it. */ - gboolean (*get_sort_last) (const MMPlugin *self); - - /* Check whether a plugin supports a particular modem port, and what level - * of support the plugin has for the device. - * The check is done always asynchronously. When the result of the check is - * ready, the passed callback will be called, and the result will be ready - * to get retrieved with supports_port_finish(). - */ - void (* supports_port) (MMPlugin *self, - const gchar *subsys, - const gchar *name, - const gchar *physdev_path, - MMBaseModem *existing, - GAsyncReadyCallback callback, - gpointer user_data); - - /* Allows to get the result of an asynchronous port support check. */ - MMPluginSupportsResult (* supports_port_finish) (MMPlugin *self, - GAsyncResult *result, - GError **error); - - /* Called to cancel an ongoing supports_port() operation or to notify the - * plugin to clean up that operation. For example, if two plugins support - * a particular port, but the first plugin grabs the port, this method will - * be called on the second plugin to allow that plugin to clean up resources - * used while determining it's level of support for the port. - */ - void (*supports_port_cancel) (MMPlugin *self, - const char *subsys, - const char *name); - - /* Given all the list of ports, launch creation of a new modem object */ - MMBaseModem * (*create_modem) (MMPlugin *self, - GList *ports, - GError **error); + GObject parent; }; -GType mm_plugin_get_type (void); - -const char *mm_plugin_get_name (MMPlugin *plugin); +struct _MMPluginClass { + GObjectClass parent; + + /* Mandatory subclass functions */ + + /* Plugins need to provide a method to create a modem object given + * a list of port probes */ + MMBaseModem *(*create_modem) (MMPlugin *plugin, + const gchar *sysfs_path, + const gchar *driver, + guint16 vendor, + guint16 product, + GList *probes, + GError **error); + + /* Plugins need to provide a method to grab independent ports + * identified by port probes */ + gboolean (*grab_port) (MMPlugin *plugin, + MMBaseModem *modem, + MMPortProbe *probe, + GError **error); +}; -gboolean mm_plugin_get_sort_last (const MMPlugin *plugin); +GType mm_plugin_get_type (void); -void mm_plugin_supports_port (MMPlugin *plugin, - const gchar *subsys, - const gchar *name, - const gchar *physdev_path, - MMBaseModem *existing, - GAsyncReadyCallback callback, - gpointer user_data); +const char *mm_plugin_get_name (MMPlugin *plugin); +gboolean mm_plugin_get_sort_last (const MMPlugin *plugin); +void mm_plugin_supports_port (MMPlugin *plugin, + const gchar *subsys, + const gchar *name, + const gchar *physdev_path, + MMBaseModem *existing, + GAsyncReadyCallback callback, + gpointer user_data); MMPluginSupportsResult mm_plugin_supports_port_finish (MMPlugin *plugin, GAsyncResult *result, GError **error); - -void mm_plugin_supports_port_cancel (MMPlugin *plugin, - const char *subsys, - const char *name); +void mm_plugin_supports_port_cancel (MMPlugin *plugin, + const char *subsys, + const char *name); MMBaseModem *mm_plugin_create_modem (MMPlugin *plugin, GList *ports, |