Add FuDevice->prepare() and FuDevice->cleanup() vfuncs for future use

This commit is contained in:
Richard Hughes 2019-10-17 13:31:50 +01:00
parent 9e4bf87184
commit b05d39adff
2 changed files with 69 additions and 1 deletions

View File

@ -2015,6 +2015,62 @@ fu_device_reload (FuDevice *self, GError **error)
return klass->reload (self, error);
}
/**
* fu_device_prepare:
* @self: A #FuDevice
* @error: A #GError
*
* Prepares a device for update. A different plugin can handle each of
* FuDevice->prepare(), FuDevice->detach() and FuDevice->write_firmware().
*
* Returns: %TRUE on success
*
* Since: 1.3.3
**/
gboolean
fu_device_prepare (FuDevice *self, FwupdInstallFlags flags, GError **error)
{
FuDeviceClass *klass = FU_DEVICE_GET_CLASS (self);
g_return_val_if_fail (FU_IS_DEVICE (self), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* no plugin-specific method */
if (klass->prepare == NULL)
return TRUE;
/* call vfunc */
return klass->prepare (self, flags, error);
}
/**
* fu_device_cleanup:
* @self: A #FuDevice
* @error: A #GError
*
* Cleans up a device after an update. A different plugin can handle each of
* FuDevice->write_firmware(), FuDevice->attach() and FuDevice->cleanup().
*
* Returns: %TRUE on success
*
* Since: 1.3.3
**/
gboolean
fu_device_cleanup (FuDevice *self, FwupdInstallFlags flags, GError **error)
{
FuDeviceClass *klass = FU_DEVICE_GET_CLASS (self);
g_return_val_if_fail (FU_IS_DEVICE (self), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* no plugin-specific method */
if (klass->cleanup == NULL)
return TRUE;
/* call vfunc */
return klass->cleanup (self, flags, error);
}
/**
* fu_device_open:
* @self: A #FuDevice

View File

@ -58,8 +58,14 @@ struct _FuDeviceClass
GError **error);
gboolean (*reload) (FuDevice *self,
GError **error);
gboolean (*prepare) (FuDevice *self,
FwupdInstallFlags flags,
GError **error);
gboolean (*cleanup) (FuDevice *self,
FwupdInstallFlags flags,
GError **error);
/*< private >*/
gpointer padding[18];
gpointer padding[16];
};
/**
@ -227,6 +233,12 @@ gboolean fu_device_detach (FuDevice *self,
GError **error);
gboolean fu_device_reload (FuDevice *self,
GError **error);
gboolean fu_device_prepare (FuDevice *self,
FwupdInstallFlags flags,
GError **error);
gboolean fu_device_cleanup (FuDevice *self,
FwupdInstallFlags flags,
GError **error);
void fu_device_incorporate (FuDevice *self,
FuDevice *donor);
gboolean fu_device_open (FuDevice *self,