mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-14 10:22:17 +00:00
Add a plugin vfunc to run after subclassed FuDevice creation
Sometimes the plugin will want to influence the subclassed device, for instance by reading a per-plugin config file. At the moment there's no way to do this, as even _device_registered() is explicitly designed for devices *not* created by the plugin itself. Even if _device_registered() was changed to include the plugin creating the object it would still happen well after the device has done _probe() and/or _setup() and would probably be too late to do anything useful.
This commit is contained in:
parent
457a7c37ec
commit
0f66a0236e
@ -86,6 +86,9 @@ gboolean fu_plugin_runner_udev_device_added (FuPlugin *self,
|
||||
gboolean fu_plugin_runner_udev_device_changed (FuPlugin *self,
|
||||
FuUdevDevice *device,
|
||||
GError **error);
|
||||
gboolean fu_plugin_runner_device_created (FuPlugin *self,
|
||||
FuDevice *device,
|
||||
GError **error);
|
||||
void fu_plugin_runner_device_removed (FuPlugin *self,
|
||||
FuDevice *device);
|
||||
void fu_plugin_runner_device_register (FuPlugin *self,
|
||||
|
@ -324,6 +324,19 @@ gboolean fu_plugin_udev_device_changed (FuPlugin *plugin,
|
||||
gboolean fu_plugin_device_removed (FuPlugin *plugin,
|
||||
FuDevice *device,
|
||||
GError **error);
|
||||
/**
|
||||
* fu_plugin_device_created
|
||||
* @plugin: A #FuPlugin
|
||||
* @device: A #FuDevice
|
||||
* @error: A #GError or %NULL
|
||||
*
|
||||
* Function run when the subclassed device has been created.
|
||||
*
|
||||
* Since: 1.3.9
|
||||
**/
|
||||
gboolean fu_plugin_device_created (FuPlugin *plugin,
|
||||
FuDevice *dev,
|
||||
GError **error);
|
||||
/**
|
||||
* fu_plugin_device_registered
|
||||
* @plugin: A #FuPlugin
|
||||
|
@ -1678,6 +1678,8 @@ fu_plugin_usb_device_added (FuPlugin *self, FuUsbDevice *device, GError **error)
|
||||
/* create new device and incorporate existing properties */
|
||||
dev = g_object_new (device_gtype, NULL);
|
||||
fu_device_incorporate (dev, FU_DEVICE (device));
|
||||
if (!fu_plugin_runner_device_created (self, dev, error))
|
||||
return FALSE;
|
||||
|
||||
/* there are a lot of different devices that match, but not all respond
|
||||
* well to opening -- so limit some ones with issued updates */
|
||||
@ -1715,6 +1717,8 @@ fu_plugin_udev_device_added (FuPlugin *self, FuUdevDevice *device, GError **erro
|
||||
/* create new device and incorporate existing properties */
|
||||
dev = g_object_new (device_gtype, NULL);
|
||||
fu_device_incorporate (FU_DEVICE (dev), FU_DEVICE (device));
|
||||
if (!fu_plugin_runner_device_created (self, dev, error))
|
||||
return FALSE;
|
||||
|
||||
/* there are a lot of different devices that match, but not all respond
|
||||
* well to opening -- so limit some ones with issued updates */
|
||||
@ -1950,6 +1954,38 @@ fu_plugin_runner_device_register (FuPlugin *self, FuDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* fu_plugin_runner_device_created:
|
||||
* @self: a #FuPlugin
|
||||
* @device: a #FuDevice
|
||||
* @error: a #GError or NULL
|
||||
*
|
||||
* Call the device_created routine for the plugin
|
||||
*
|
||||
* Returns: #TRUE for success, #FALSE for failure
|
||||
*
|
||||
* Since: 1.3.9
|
||||
**/
|
||||
gboolean
|
||||
fu_plugin_runner_device_created (FuPlugin *self, FuDevice *device, GError **error)
|
||||
{
|
||||
FuPluginPrivate *priv = GET_PRIVATE (self);
|
||||
FuPluginDeviceFunc func = NULL;
|
||||
|
||||
/* not enabled */
|
||||
if (!priv->enabled)
|
||||
return TRUE;
|
||||
if (priv->module == NULL)
|
||||
return TRUE;
|
||||
|
||||
/* optional */
|
||||
g_module_symbol (priv->module, "fu_plugin_device_created", (gpointer *) &func);
|
||||
if (func == NULL)
|
||||
return TRUE;
|
||||
g_debug ("performing fu_plugin_device_created() on %s", priv->name);
|
||||
return func (self, device, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* fu_plugin_runner_verify:
|
||||
* @self: a #FuPlugin
|
||||
|
@ -531,3 +531,9 @@ LIBFWUPDPLUGIN_1.3.8 {
|
||||
fu_common_kernel_locked_down;
|
||||
local: *;
|
||||
} LIBFWUPDPLUGIN_1.3.6;
|
||||
|
||||
LIBFWUPDPLUGIN_1.3.9 {
|
||||
global:
|
||||
fu_plugin_runner_device_created;
|
||||
local: *;
|
||||
} LIBFWUPDPLUGIN_1.3.8;
|
||||
|
Loading…
Reference in New Issue
Block a user