plugin-base: new 'allowed-vendor-ids' and 'allowed-product-ids' properties

The plugins can set these properties to filter support check requests by
udev-reported Vendor ID and Product ID.

The value given to the properties should be a 0-terminated array of guint16s,
e.g.,

    static const guint16 vendor_ids[] = { 0x0421 , 0 };
This commit is contained in:
Aleksander Morgado
2011-09-07 18:28:28 +02:00
committed by Aleksander Morgado
parent 59c783eb61
commit 806aabd22d
2 changed files with 39 additions and 3 deletions

View File

@@ -70,12 +70,16 @@ typedef struct {
/* Plugin-specific setups */ /* Plugin-specific setups */
const gchar **subsystems; const gchar **subsystems;
const guint16 *vendor_ids;
const guint16 *product_ids;
} MMPluginBasePrivate; } MMPluginBasePrivate;
enum { enum {
PROP_0, PROP_0,
PROP_NAME, PROP_NAME,
PROP_ALLOWED_SUBSYSTEMS, PROP_ALLOWED_SUBSYSTEMS,
PROP_ALLOWED_VENDOR_IDS,
PROP_ALLOWED_PRODUCT_IDS,
PROP_SORT_LAST, PROP_SORT_LAST,
LAST_PROP LAST_PROP
}; };
@@ -1552,6 +1556,14 @@ set_property (GObject *object, guint prop_id,
/* Construct only */ /* Construct only */
priv->subsystems = (const gchar **)g_value_get_pointer (value); priv->subsystems = (const gchar **)g_value_get_pointer (value);
break; break;
case PROP_ALLOWED_VENDOR_IDS:
/* Construct only */
priv->vendor_ids = (const guint16 *)g_value_get_pointer (value);
break;
case PROP_ALLOWED_PRODUCT_IDS:
/* Construct only */
priv->product_ids = (const guint16 *)g_value_get_pointer (value);
break;
case PROP_SORT_LAST: case PROP_SORT_LAST:
/* Construct only */ /* Construct only */
priv->sort_last = g_value_get_boolean (value); priv->sort_last = g_value_get_boolean (value);
@@ -1575,6 +1587,12 @@ get_property (GObject *object, guint prop_id,
case PROP_ALLOWED_SUBSYSTEMS: case PROP_ALLOWED_SUBSYSTEMS:
g_value_set_pointer (value, (gpointer)priv->subsystems); g_value_set_pointer (value, (gpointer)priv->subsystems);
break; break;
case PROP_ALLOWED_VENDOR_IDS:
g_value_set_pointer (value, (gpointer)priv->vendor_ids);
break;
case PROP_ALLOWED_PRODUCT_IDS:
g_value_set_pointer (value, (gpointer)priv->product_ids);
break;
case PROP_SORT_LAST: case PROP_SORT_LAST:
g_value_set_boolean (value, priv->sort_last); g_value_set_boolean (value, priv->sort_last);
break; break;
@@ -1628,6 +1646,22 @@ mm_plugin_base_class_init (MMPluginBaseClass *klass)
"should be an array of strings finished with 'NULL'", "should be an array of strings finished with 'NULL'",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_ALLOWED_VENDOR_IDS,
g_param_spec_pointer (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'",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property
(object_class, PROP_ALLOWED_PRODUCT_IDS,
g_param_spec_pointer (MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS,
"Allowed product IDs",
"List of product IDs this plugin can support, "
"should be an array of guint16 finished with '0'",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property g_object_class_install_property
(object_class, PROP_SORT_LAST, (object_class, PROP_SORT_LAST,
g_param_spec_boolean (MM_PLUGIN_BASE_SORT_LAST, g_param_spec_boolean (MM_PLUGIN_BASE_SORT_LAST,

View File

@@ -112,9 +112,11 @@ void mm_plugin_base_supports_task_add_custom_init_command (MMPluginBaseSupportsT
#define MM_IS_PLUBIN_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), 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_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_BASE, MMPluginBaseClass))
#define MM_PLUGIN_BASE_NAME "name" #define MM_PLUGIN_BASE_NAME "name"
#define MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS "allowed-subsystems" #define MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS "allowed-subsystems"
#define MM_PLUGIN_BASE_SORT_LAST "sort-last" #define MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS "allowed-vendor-ids"
#define MM_PLUGIN_BASE_ALLOWED_PRODUCT_IDS "allowed-product-ids"
#define MM_PLUGIN_BASE_SORT_LAST "sort-last"
typedef struct _MMPluginBase MMPluginBase; typedef struct _MMPluginBase MMPluginBase;
typedef struct _MMPluginBaseClass MMPluginBaseClass; typedef struct _MMPluginBaseClass MMPluginBaseClass;