plugin: don't match generic plugin by name
This commit is contained in:
@@ -95,7 +95,8 @@ mm_plugin_create (void)
|
|||||||
|
|
||||||
return MM_PLUGIN (
|
return MM_PLUGIN (
|
||||||
g_object_new (MM_TYPE_PLUGIN_GENERIC,
|
g_object_new (MM_TYPE_PLUGIN_GENERIC,
|
||||||
MM_PLUGIN_NAME, MM_PLUGIN_GENERIC_NAME,
|
MM_PLUGIN_NAME, MM_MODULE_NAME,
|
||||||
|
MM_PLUGIN_IS_GENERIC, TRUE,
|
||||||
MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
|
MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
|
||||||
MM_PLUGIN_ALLOWED_AT, TRUE,
|
MM_PLUGIN_ALLOWED_AT, TRUE,
|
||||||
MM_PLUGIN_ALLOWED_QCDM, TRUE,
|
MM_PLUGIN_ALLOWED_QCDM, TRUE,
|
||||||
|
@@ -51,7 +51,7 @@ test_enable_disable (TestFixture *fixture)
|
|||||||
/* Set the test profile */
|
/* Set the test profile */
|
||||||
test_fixture_set_profile (fixture,
|
test_fixture_set_profile (fixture,
|
||||||
"test-enable-disable",
|
"test-enable-disable",
|
||||||
"Generic",
|
"generic",
|
||||||
(const gchar *const *)ports);
|
(const gchar *const *)ports);
|
||||||
|
|
||||||
/* Wait and get the modem object */
|
/* Wait and get the modem object */
|
||||||
|
@@ -363,7 +363,7 @@ port_context_set_suggestion (PortContext *port_context,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* The GENERIC plugin is NEVER suggested to others */
|
/* The GENERIC plugin is NEVER suggested to others */
|
||||||
if (g_str_equal (mm_plugin_get_name (suggested_plugin), MM_PLUGIN_GENERIC_NAME))
|
if (mm_plugin_is_generic (suggested_plugin))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* If the plugin has MM_PLUGIN_FORBIDDEN_ICERA set, we do *not* suggest
|
/* If the plugin has MM_PLUGIN_FORBIDDEN_ICERA set, we do *not* suggest
|
||||||
@@ -974,10 +974,10 @@ device_context_set_best_plugin (DeviceContext *device_context,
|
|||||||
* one and now we're reporting a more specific one, use the new one.
|
* one and now we're reporting a more specific one, use the new one.
|
||||||
*/
|
*/
|
||||||
if (!device_context->best_plugin ||
|
if (!device_context->best_plugin ||
|
||||||
(g_str_equal (mm_plugin_get_name (device_context->best_plugin), MM_PLUGIN_GENERIC_NAME) &&
|
(mm_plugin_is_generic (device_context->best_plugin) &&
|
||||||
device_context->best_plugin != best_plugin)) {
|
device_context->best_plugin != best_plugin)) {
|
||||||
/* Only log best plugin if it's not the generic one */
|
/* Only log best plugin if it's not the generic one */
|
||||||
if (!g_str_equal (mm_plugin_get_name (best_plugin), MM_PLUGIN_GENERIC_NAME))
|
if (!mm_plugin_is_generic (best_plugin))
|
||||||
mm_obj_dbg (self, "task %s: found best plugin: %s",
|
mm_obj_dbg (self, "task %s: found best plugin: %s",
|
||||||
port_context->name, mm_plugin_get_name (best_plugin));
|
port_context->name, mm_plugin_get_name (best_plugin));
|
||||||
/* Store and suggest this plugin also to other port probes */
|
/* Store and suggest this plugin also to other port probes */
|
||||||
@@ -1170,10 +1170,8 @@ device_context_run_port_context (DeviceContext *device_context,
|
|||||||
|
|
||||||
/* If we got one already set in the device context, it will be the first one,
|
/* If we got one already set in the device context, it will be the first one,
|
||||||
* unless it is the generic plugin */
|
* unless it is the generic plugin */
|
||||||
if (device_context->best_plugin &&
|
if (device_context->best_plugin && !mm_plugin_is_generic (device_context->best_plugin))
|
||||||
!g_str_equal (mm_plugin_get_name (device_context->best_plugin), MM_PLUGIN_GENERIC_NAME)) {
|
|
||||||
suggested = device_context->best_plugin;
|
suggested = device_context->best_plugin;
|
||||||
}
|
|
||||||
|
|
||||||
port_context_run (self,
|
port_context_run (self,
|
||||||
port_context,
|
port_context,
|
||||||
@@ -1805,11 +1803,12 @@ load_plugins (MMPluginManager *self,
|
|||||||
if (!plugin)
|
if (!plugin)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (g_str_equal (mm_plugin_get_name (plugin), MM_PLUGIN_GENERIC_NAME))
|
if (mm_plugin_is_generic (plugin)) {
|
||||||
/* Generic plugin */
|
if (self->priv->generic)
|
||||||
self->priv->generic = plugin;
|
mm_obj_warn (self, "cannot register more than one generic plugin");
|
||||||
else
|
else
|
||||||
/* Vendor specific plugin */
|
self->priv->generic = plugin;
|
||||||
|
} else
|
||||||
self->priv->plugins = g_list_append (self->priv->plugins, plugin);
|
self->priv->plugins = g_list_append (self->priv->plugins, plugin);
|
||||||
|
|
||||||
/* Register plugin whitelist rules in filter, if any */
|
/* Register plugin whitelist rules in filter, if any */
|
||||||
|
@@ -64,8 +64,9 @@ static const gchar *virtual_port[] = {"smd0", NULL};
|
|||||||
|
|
||||||
|
|
||||||
struct _MMPluginPrivate {
|
struct _MMPluginPrivate {
|
||||||
gchar *name;
|
gchar *name;
|
||||||
GHashTable *tasks;
|
GHashTable *tasks;
|
||||||
|
gboolean is_generic;
|
||||||
|
|
||||||
/* Pre-probing filters */
|
/* Pre-probing filters */
|
||||||
gchar **subsystems;
|
gchar **subsystems;
|
||||||
@@ -107,6 +108,7 @@ struct _MMPluginPrivate {
|
|||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_NAME,
|
PROP_NAME,
|
||||||
|
PROP_IS_GENERIC,
|
||||||
PROP_ALLOWED_SUBSYSTEMS,
|
PROP_ALLOWED_SUBSYSTEMS,
|
||||||
PROP_ALLOWED_DRIVERS,
|
PROP_ALLOWED_DRIVERS,
|
||||||
PROP_FORBIDDEN_DRIVERS,
|
PROP_FORBIDDEN_DRIVERS,
|
||||||
@@ -156,6 +158,12 @@ mm_plugin_get_allowed_product_ids (MMPlugin *self)
|
|||||||
return self->priv->product_ids;
|
return self->priv->product_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
mm_plugin_is_generic (MMPlugin *self)
|
||||||
|
{
|
||||||
|
return self->priv->is_generic;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -1110,6 +1118,10 @@ set_property (GObject *object,
|
|||||||
/* Construct only */
|
/* Construct only */
|
||||||
self->priv->name = g_value_dup_string (value);
|
self->priv->name = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_IS_GENERIC:
|
||||||
|
/* Construct only */
|
||||||
|
self->priv->is_generic = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
case PROP_ALLOWED_SUBSYSTEMS:
|
case PROP_ALLOWED_SUBSYSTEMS:
|
||||||
/* Construct only */
|
/* Construct only */
|
||||||
self->priv->subsystems = g_value_dup_boxed (value);
|
self->priv->subsystems = g_value_dup_boxed (value);
|
||||||
@@ -1232,6 +1244,9 @@ get_property (GObject *object,
|
|||||||
case PROP_NAME:
|
case PROP_NAME:
|
||||||
g_value_set_string (value, self->priv->name);
|
g_value_set_string (value, self->priv->name);
|
||||||
break;
|
break;
|
||||||
|
case PROP_IS_GENERIC:
|
||||||
|
g_value_set_boolean (value, self->priv->is_generic);
|
||||||
|
break;
|
||||||
case PROP_ALLOWED_SUBSYSTEMS:
|
case PROP_ALLOWED_SUBSYSTEMS:
|
||||||
g_value_set_boxed (value, self->priv->subsystems);
|
g_value_set_boxed (value, self->priv->subsystems);
|
||||||
break;
|
break;
|
||||||
@@ -1369,6 +1384,14 @@ mm_plugin_class_init (MMPluginClass *klass)
|
|||||||
NULL,
|
NULL,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_IS_GENERIC,
|
||||||
|
g_param_spec_boolean (MM_PLUGIN_IS_GENERIC,
|
||||||
|
"Generic",
|
||||||
|
"Whether the plugin is the generic one",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_ALLOWED_SUBSYSTEMS,
|
(object_class, PROP_ALLOWED_SUBSYSTEMS,
|
||||||
g_param_spec_boxed (MM_PLUGIN_ALLOWED_SUBSYSTEMS,
|
g_param_spec_boxed (MM_PLUGIN_ALLOWED_SUBSYSTEMS,
|
||||||
|
@@ -27,7 +27,6 @@
|
|||||||
#include "mm-device.h"
|
#include "mm-device.h"
|
||||||
#include "mm-kernel-device.h"
|
#include "mm-kernel-device.h"
|
||||||
|
|
||||||
#define MM_PLUGIN_GENERIC_NAME "Generic"
|
|
||||||
#define MM_PLUGIN_MAJOR_VERSION 4
|
#define MM_PLUGIN_MAJOR_VERSION 4
|
||||||
#define MM_PLUGIN_MINOR_VERSION 0
|
#define MM_PLUGIN_MINOR_VERSION 0
|
||||||
|
|
||||||
@@ -48,6 +47,7 @@
|
|||||||
#define MM_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN, MMPluginClass))
|
#define MM_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN, MMPluginClass))
|
||||||
|
|
||||||
#define MM_PLUGIN_NAME "name"
|
#define MM_PLUGIN_NAME "name"
|
||||||
|
#define MM_PLUGIN_IS_GENERIC "is-generic"
|
||||||
#define MM_PLUGIN_ALLOWED_SUBSYSTEMS "allowed-subsystems"
|
#define MM_PLUGIN_ALLOWED_SUBSYSTEMS "allowed-subsystems"
|
||||||
#define MM_PLUGIN_ALLOWED_DRIVERS "allowed-drivers"
|
#define MM_PLUGIN_ALLOWED_DRIVERS "allowed-drivers"
|
||||||
#define MM_PLUGIN_FORBIDDEN_DRIVERS "forbidden-drivers"
|
#define MM_PLUGIN_FORBIDDEN_DRIVERS "forbidden-drivers"
|
||||||
@@ -127,6 +127,7 @@ GType mm_plugin_get_type (void);
|
|||||||
const gchar *mm_plugin_get_name (MMPlugin *self);
|
const gchar *mm_plugin_get_name (MMPlugin *self);
|
||||||
const gchar **mm_plugin_get_allowed_udev_tags (MMPlugin *self);
|
const gchar **mm_plugin_get_allowed_udev_tags (MMPlugin *self);
|
||||||
const mm_uint16_pair *mm_plugin_get_allowed_product_ids (MMPlugin *self);
|
const mm_uint16_pair *mm_plugin_get_allowed_product_ids (MMPlugin *self);
|
||||||
|
gboolean mm_plugin_is_generic (MMPlugin *self);
|
||||||
|
|
||||||
/* This method will run all pre-probing filters, to see if we can discard this
|
/* This method will run all pre-probing filters, to see if we can discard this
|
||||||
* plugin from the probing logic as soon as possible. */
|
* plugin from the probing logic as soon as possible. */
|
||||||
|
Reference in New Issue
Block a user