Add a vfunc that gets run after the device has been added

This allows per-plugin actions after the device has been open()ed and started.
This commit is contained in:
Richard Hughes 2020-05-09 20:36:33 +01:00
parent 9223c89019
commit 6a07870fa2
4 changed files with 45 additions and 0 deletions

View File

@ -89,6 +89,8 @@ gboolean fu_plugin_runner_udev_device_changed (FuPlugin *self,
gboolean fu_plugin_runner_device_created (FuPlugin *self,
FuDevice *device,
GError **error);
void fu_plugin_runner_device_added (FuPlugin *self,
FuDevice *device);
void fu_plugin_runner_device_removed (FuPlugin *self,
FuDevice *device);
void fu_plugin_runner_device_register (FuPlugin *self,

View File

@ -311,6 +311,17 @@ gboolean fu_plugin_udev_device_added (FuPlugin *plugin,
gboolean fu_plugin_udev_device_changed (FuPlugin *plugin,
FuUdevDevice *device,
GError **error);
/**
* fu_plugin_device_added
* @plugin: A #FuPlugin
* @device: A #FuDevice
*
* Function run when the subclassed device has been added.
*
* Since: 1.5.0
**/
void fu_plugin_device_added (FuPlugin *plugin,
FuDevice *dev);
/**
* fu_plugin_device_removed
* @plugin: A #FuPlugin

View File

@ -1691,6 +1691,7 @@ fu_plugin_usb_device_added (FuPlugin *self, FuUsbDevice *device, GError **error)
if (locker == NULL)
return FALSE;
fu_plugin_device_add (self, dev);
fu_plugin_runner_device_added (self, dev);
return TRUE;
}
@ -1742,6 +1743,7 @@ fu_plugin_udev_device_added (FuPlugin *self, FuUdevDevice *device, GError **erro
if (locker == NULL)
return FALSE;
fu_plugin_device_add (self, FU_DEVICE (dev));
fu_plugin_runner_device_added (self, dev);
return TRUE;
}
@ -1910,6 +1912,35 @@ fu_plugin_runner_udev_device_changed (FuPlugin *self, FuUdevDevice *device, GErr
return TRUE;
}
/**
* fu_plugin_runner_device_added:
* @self: a #FuPlugin
* @device: a #FuDevice
*
* Call the device_added routine for the plugin
*
* Since: 1.5.0
**/
void
fu_plugin_runner_device_added (FuPlugin *self, FuDevice *device)
{
FuPluginPrivate *priv = GET_PRIVATE (self);
FuPluginDeviceRegisterFunc func = NULL;
/* not enabled */
if (!priv->enabled)
return;
if (priv->module == NULL)
return;
/* optional */
g_module_symbol (priv->module, "fu_plugin_device_added", (gpointer *) &func);
if (func == NULL)
return;
g_debug ("performing fu_plugin_device_added() on %s", priv->name);
func (self, device);
}
/**
* fu_plugin_runner_device_removed:
* @self: a #FuPlugin

View File

@ -585,6 +585,7 @@ LIBFWUPDPLUGIN_1.5.0 {
global:
fu_common_filename_glob;
fu_common_is_cpu_intel;
fu_plugin_runner_device_added;
fu_udev_device_get_parent_name;
fu_udev_device_get_sysfs_attr;
local: *;