aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-07-11 07:03:56 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-08-06 20:06:46 +0200
commitf5fdf946c9a2eefb049155f476888742c5901643 (patch)
tree03ab0ffd082d9b68e6f6c644896444e95b330046
parent1078b246b0ccea5a85dbef713c527e22c9cc64a2 (diff)
plugin: new `MM_PLUGIN_FORBIDDEN_DRIVERS' property
It allows plugins to specify whether they cannot support ports handled by specific drivers.
-rw-r--r--docs/reference/api/ModemManager-overview.xml10
-rw-r--r--src/mm-plugin.c50
-rw-r--r--src/mm-plugin.h1
3 files changed, 48 insertions, 13 deletions
diff --git a/docs/reference/api/ModemManager-overview.xml b/docs/reference/api/ModemManager-overview.xml
index f5661e6f..79147e13 100644
--- a/docs/reference/api/ModemManager-overview.xml
+++ b/docs/reference/api/ModemManager-overview.xml
@@ -142,9 +142,13 @@
any port detected being managed by a driver not listed by the plugin.
</para>
<para>
- This filter is specified by the <type>MM_PLUGIN_ALLOWED_DRIVERS</type>
- property in the <structname>MMPlugin</structname> object provided
- by the plugin.
+ Plugins can also specify which drivers they do not expect, so that we
+ filter out any port detected being managed by a driver listed by the plugin.
+ </para>
+ <para>
+ These filters are specified by the <type>MM_PLUGIN_ALLOWED_DRIVERS</type>
+ and <type>MM_PLUGIN_FORBIDDEN_DRIVERS</type> properties in the
+ <structname>MMPlugin</structname> object provided by the plugin.
</para>
</listitem>
<listitem>
diff --git a/src/mm-plugin.c b/src/mm-plugin.c
index e50211bb..9a9faa93 100644
--- a/src/mm-plugin.c
+++ b/src/mm-plugin.c
@@ -52,6 +52,7 @@ struct _MMPluginPrivate {
/* Plugin-specific setups */
gchar **subsystems;
gchar **drivers;
+ gchar **forbidden_drivers;
guint16 *vendor_ids;
mm_uint16_pair *product_ids;
gchar **vendor_strings;
@@ -69,6 +70,7 @@ enum {
PROP_NAME,
PROP_ALLOWED_SUBSYSTEMS,
PROP_ALLOWED_DRIVERS,
+ PROP_FORBIDDEN_DRIVERS,
PROP_ALLOWED_VENDOR_IDS,
PROP_ALLOWED_PRODUCT_IDS,
PROP_ALLOWED_VENDOR_STRINGS,
@@ -162,9 +164,10 @@ apply_pre_probing_filters (MMPlugin *self,
return TRUE;
}
- /* The plugin may specify that only some drivers are supported. If that
- * is the case, filter by driver */
- if (self->priv->drivers) {
+ /* The plugin may specify that only some drivers are supported, or that some
+ * drivers are not supported. If that is the case, filter by driver */
+ if (self->priv->drivers ||
+ self->priv->forbidden_drivers) {
const gchar *driver;
/* Detect any modems accessible through the list of virtual ports */
@@ -176,14 +179,25 @@ apply_pre_probing_filters (MMPlugin *self,
if (!driver)
return TRUE;
- for (i = 0; self->priv->drivers[i]; i++) {
- if (g_str_equal (driver, self->priv->drivers[i]))
- break;
- }
+ /* Filtering by allowed drivers */
+ if (self->priv->drivers) {
+ for (i = 0; self->priv->drivers[i]; i++) {
+ if (g_str_equal (driver, self->priv->drivers[i]))
+ break;
+ }
- /* If we didn't match any driver: unsupported */
- if (!self->priv->drivers[i])
- return TRUE;
+ /* If we didn't match any driver: unsupported */
+ if (!self->priv->drivers[i])
+ return TRUE;
+ }
+ /* Filtering by forbidden drivers */
+ else {
+ for (i = 0; self->priv->forbidden_drivers[i]; i++) {
+ /* If we match a forbidden driver: unsupported */
+ if (g_str_equal (driver, self->priv->forbidden_drivers[i]))
+ return TRUE;
+ }
+ }
}
vendor = mm_device_get_vendor (device);
@@ -614,6 +628,10 @@ set_property (GObject *object,
/* Construct only */
self->priv->drivers = g_value_dup_boxed (value);
break;
+ case PROP_FORBIDDEN_DRIVERS:
+ /* Construct only */
+ self->priv->forbidden_drivers = g_value_dup_boxed (value);
+ break;
case PROP_ALLOWED_VENDOR_IDS:
/* Construct only */
self->priv->vendor_ids = g_value_dup_boxed (value);
@@ -678,6 +696,9 @@ get_property (GObject *object,
case PROP_ALLOWED_DRIVERS:
g_value_set_boxed (value, self->priv->drivers);
break;
+ case PROP_FORBIDDEN_DRIVERS:
+ g_value_set_boxed (value, self->priv->forbidden_drivers);
+ break;
case PROP_ALLOWED_VENDOR_IDS:
g_value_set_boxed (value, self->priv->vendor_ids);
break;
@@ -763,6 +784,15 @@ mm_plugin_class_init (MMPluginClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
+ (object_class, PROP_FORBIDDEN_DRIVERS,
+ g_param_spec_boxed (MM_PLUGIN_FORBIDDEN_DRIVERS,
+ "Forbidden drivers",
+ "List of drivers this plugin cannot 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",
diff --git a/src/mm-plugin.h b/src/mm-plugin.h
index 71a6d106..d63a734f 100644
--- a/src/mm-plugin.h
+++ b/src/mm-plugin.h
@@ -40,6 +40,7 @@
#define MM_PLUGIN_NAME "name"
#define MM_PLUGIN_ALLOWED_SUBSYSTEMS "allowed-subsystems"
#define MM_PLUGIN_ALLOWED_DRIVERS "allowed-drivers"
+#define MM_PLUGIN_FORBIDDEN_DRIVERS "forbidden-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"