diff --git a/libfwupd/fwupd-enums.c b/libfwupd/fwupd-enums.c index 812707d26..84de98307 100644 --- a/libfwupd/fwupd-enums.c +++ b/libfwupd/fwupd-enums.c @@ -108,10 +108,10 @@ fwupd_device_flag_to_string (FwupdDeviceFlags device_flag) return "none"; if (device_flag == FWUPD_DEVICE_FLAG_INTERNAL) return "internal"; - if (device_flag == FWUPD_DEVICE_FLAG_ALLOW_ONLINE) - return "allow-online"; - if (device_flag == FWUPD_DEVICE_FLAG_ALLOW_OFFLINE) - return "allow-offline"; + if (device_flag == FWUPD_DEVICE_FLAG_UPDATABLE) + return "updatable"; + if (device_flag == FWUPD_DEVICE_FLAG_ONLY_OFFLINE) + return "only-offline"; if (device_flag == FWUPD_DEVICE_FLAG_REQUIRE_AC) return "require-ac"; if (device_flag == FWUPD_DEVICE_FLAG_LOCKED) @@ -122,6 +122,8 @@ fwupd_device_flag_to_string (FwupdDeviceFlags device_flag) return "needs-bootloader"; if (device_flag == FWUPD_DEVICE_FLAG_REGISTERED) return "registered"; + if (device_flag == FWUPD_DEVICE_FLAG_NEEDS_REBOOT) + return "needs-reboot"; if (device_flag == FWUPD_DEVICE_FLAG_UNKNOWN) return "unknown"; return NULL; @@ -144,10 +146,12 @@ fwupd_device_flag_from_string (const gchar *device_flag) return FWUPD_DEVICE_FLAG_NONE; if (g_strcmp0 (device_flag, "internal") == 0) return FWUPD_DEVICE_FLAG_INTERNAL; - if (g_strcmp0 (device_flag, "allow-online") == 0) - return FWUPD_DEVICE_FLAG_ALLOW_ONLINE; - if (g_strcmp0 (device_flag, "allow-offline") == 0) - return FWUPD_DEVICE_FLAG_ALLOW_OFFLINE; + if (g_strcmp0 (device_flag, "updatable") == 0 || + g_strcmp0 (device_flag, "allow-online") == 0) + return FWUPD_DEVICE_FLAG_UPDATABLE; + if (g_strcmp0 (device_flag, "only-offline") == 0 || + g_strcmp0 (device_flag, "allow-offline") == 0) + return FWUPD_DEVICE_FLAG_ONLY_OFFLINE; if (g_strcmp0 (device_flag, "require-ac") == 0) return FWUPD_DEVICE_FLAG_REQUIRE_AC; if (g_strcmp0 (device_flag, "locked") == 0) @@ -158,6 +162,8 @@ fwupd_device_flag_from_string (const gchar *device_flag) return FWUPD_DEVICE_FLAG_NEEDS_BOOTLOADER; if (g_strcmp0 (device_flag, "registered") == 0) return FWUPD_DEVICE_FLAG_REGISTERED; + if (g_strcmp0 (device_flag, "needs-reboot") == 0) + return FWUPD_DEVICE_FLAG_NEEDS_REBOOT; return FWUPD_DEVICE_FLAG_UNKNOWN; } diff --git a/libfwupd/fwupd-enums.h b/libfwupd/fwupd-enums.h index c8d620270..2d305d2f1 100644 --- a/libfwupd/fwupd-enums.h +++ b/libfwupd/fwupd-enums.h @@ -72,13 +72,14 @@ typedef enum { * FwupdDeviceFlags: * @FWUPD_DEVICE_FLAG_NONE: No flags set * @FWUPD_DEVICE_FLAG_INTERNAL: Device cannot be removed easily - * @FWUPD_DEVICE_FLAG_ALLOW_ONLINE: Is capable of 'live' updating - * @FWUPD_DEVICE_FLAG_ALLOW_OFFLINE: Is capable of 'offline' updating + * @FWUPD_DEVICE_FLAG_UPDATABLE: Device is updatable + * @FWUPD_DEVICE_FLAG_ONLY_OFFLINE: Update can only be done from offline mode * @FWUPD_DEVICE_FLAG_REQUIRE_AC: Requires AC power * @FWUPD_DEVICE_FLAG_LOCKED: Is locked and can be unlocked * @FWUPD_DEVICE_FLAG_SUPPORTED: Is found in current metadata * @FWUPD_DEVICE_FLAG_NEEDS_BOOTLOADER: Requires a bootloader mode * @FWUPD_DEVICE_FLAG_REGISTERED: Has been registered with other plugins + * @FWUPD_DEVICE_FLAG_NEEDS_REBOOT: Requires a reboot to apply firmware or to reload hardware * * FIXME: rename FU_DEVICE_ -> FWUPD_DEVICE_ when we break API * @@ -86,31 +87,34 @@ typedef enum { **/ #define FWUPD_DEVICE_FLAG_NONE (0u) /* Since: 0.1.3 */ #define FWUPD_DEVICE_FLAG_INTERNAL (1u << 0) /* Since: 0.1.3 */ -#define FWUPD_DEVICE_FLAG_ALLOW_ONLINE (1u << 1) /* Since: 0.1.3 */ -#define FWUPD_DEVICE_FLAG_ALLOW_OFFLINE (1u << 2) /* Since: 0.1.3 */ +#define FWUPD_DEVICE_FLAG_UPDATABLE (1u << 1) /* Since: 0.9.7 */ +#define FWUPD_DEVICE_FLAG_ONLY_OFFLINE (1u << 2) /* Since: 0.9.7 */ #define FWUPD_DEVICE_FLAG_REQUIRE_AC (1u << 3) /* Since: 0.6.3 */ #define FWUPD_DEVICE_FLAG_LOCKED (1u << 4) /* Since: 0.6.3 */ #define FWUPD_DEVICE_FLAG_SUPPORTED (1u << 5) /* Since: 0.7.1 */ #define FWUPD_DEVICE_FLAG_NEEDS_BOOTLOADER (1u << 6) /* Since: 0.7.3 */ #define FWUPD_DEVICE_FLAG_REGISTERED (1u << 7) /* Since: 0.9.7 */ +#define FWUPD_DEVICE_FLAG_NEEDS_REBOOT (1u << 8) /* Since: 0.9.7 */ #define FWUPD_DEVICE_FLAG_UNKNOWN G_MAXUINT64 /* Since: 0.7.3 */ typedef guint64 FwupdDeviceFlags; /* deprecated names */ #define FU_DEVICE_FLAG_NONE FWUPD_DEVICE_FLAG_NONE #define FU_DEVICE_FLAG_INTERNAL FWUPD_DEVICE_FLAG_INTERNAL -#define FU_DEVICE_FLAG_ALLOW_ONLINE FWUPD_DEVICE_FLAG_ALLOW_ONLINE -#define FU_DEVICE_FLAG_ALLOW_OFFLINE FWUPD_DEVICE_FLAG_ALLOW_OFFLINE +#define FU_DEVICE_FLAG_ALLOW_ONLINE FWUPD_DEVICE_FLAG_UPDATABLE +#define FU_DEVICE_FLAG_ALLOW_OFFLINE FWUPD_DEVICE_FLAG_ONLY_OFFLINE #define FU_DEVICE_FLAG_REQUIRE_AC FWUPD_DEVICE_FLAG_REQUIRE_AC #define FU_DEVICE_FLAG_LOCKED FWUPD_DEVICE_FLAG_LOCKED #define FU_DEVICE_FLAG_SUPPORTED FWUPD_DEVICE_FLAG_SUPPORTED #define FU_DEVICE_FLAG_NEEDS_BOOTLOADER FWUPD_DEVICE_FLAG_NEEDS_BOOTLOADER #define FU_DEVICE_FLAG_UNKNOWN FWUPD_DEVICE_FLAG_UNKNOWN +#define FWUPD_DEVICE_FLAG_ALLOW_ONLINE FWUPD_DEVICE_FLAG_UPDATABLE +#define FWUPD_DEVICE_FLAG_ALLOW_OFFLINE FWUPD_DEVICE_FLAG_ONLY_OFFLINE /** * FwupdInstallFlags: * @FWUPD_INSTALL_FLAG_NONE: No flags set - * @FWUPD_INSTALL_FLAG_OFFLINE: Perform this offline + * @FWUPD_INSTALL_FLAG_OFFLINE: Schedule this for next boot * @FWUPD_INSTALL_FLAG_ALLOW_REINSTALL: Allow reinstalling the same version * @FWUPD_INSTALL_FLAG_ALLOW_OLDER: Allow downgrading firmware * diff --git a/libfwupd/fwupd-self-test.c b/libfwupd/fwupd-self-test.c index e581ccb10..a1bdabed9 100644 --- a/libfwupd/fwupd-self-test.c +++ b/libfwupd/fwupd-self-test.c @@ -188,7 +188,7 @@ fwupd_result_func (void) dev = fwupd_result_get_device (result); fwupd_device_add_checksum (dev, "beefdead"); fwupd_device_set_created (dev, 1); - fwupd_device_set_flags (dev, FWUPD_DEVICE_FLAG_ALLOW_OFFLINE); + fwupd_device_set_flags (dev, FWUPD_DEVICE_FLAG_UPDATABLE); fwupd_device_set_id (dev, "USB:foo"); fwupd_device_set_modified (dev, 60 * 60 * 24); fwupd_device_set_name (dev, "ColorHug2"); @@ -218,7 +218,7 @@ fwupd_result_func (void) " DeviceID: USB:foo\n" " Guid: 2082b5e0-7a64-478a-b1b2-e3404fab6dad\n" " Guid: 00000000-0000-0000-0000-000000000000\n" - " Flags: allow-offline|require-ac\n" + " Flags: updatable|require-ac\n" " FirmwareHash: SHA1(beefdead)\n" " Created: 1970-01-01\n" " Modified: 1970-01-02\n" diff --git a/plugins/altos/fu-plugin-altos.c b/plugins/altos/fu-plugin-altos.c index e89163756..32344c7a4 100644 --- a/plugins/altos/fu-plugin-altos.c +++ b/plugins/altos/fu-plugin-altos.c @@ -127,11 +127,11 @@ fu_plugin_verify (FuPlugin *plugin, } gboolean -fu_plugin_update_online (FuPlugin *plugin, - FuDevice *dev, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) +fu_plugin_update (FuPlugin *plugin, + FuDevice *dev, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_WRITE); if (!fu_device_altos_write_firmware (FU_DEVICE_ALTOS (dev), diff --git a/plugins/colorhug/fu-plugin-colorhug.c b/plugins/colorhug/fu-plugin-colorhug.c index f493941c2..534f2bdee 100644 --- a/plugins/colorhug/fu-plugin-colorhug.c +++ b/plugins/colorhug/fu-plugin-colorhug.c @@ -225,11 +225,11 @@ fu_plugin_verify (FuPlugin *plugin, } gboolean -fu_plugin_update_online (FuPlugin *plugin, - FuDevice *device, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) +fu_plugin_update (FuPlugin *plugin, + FuDevice *device, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { FuPluginData *data = fu_plugin_get_data (plugin); FuPluginItem *item; @@ -444,8 +444,7 @@ fu_plugin_colorhug_device_added_cb (GUsbContext *ctx, fu_device_set_equivalent_id (item->device, g_usb_device_get_platform_id (device)); fu_device_add_guid (item->device, ch_device_get_guid (device)); - fu_device_add_flag (item->device, FWUPD_DEVICE_FLAG_ALLOW_OFFLINE); - fu_device_add_flag (item->device, FWUPD_DEVICE_FLAG_ALLOW_ONLINE); + fu_device_add_flag (item->device, FWUPD_DEVICE_FLAG_UPDATABLE); /* try to get the serial number -- if opening failed then * poll until the device is not busy */ diff --git a/plugins/dell/fu-plugin-dell.c b/plugins/dell/fu-plugin-dell.c index b4893dd07..e1619750c 100644 --- a/plugins/dell/fu-plugin-dell.c +++ b/plugins/dell/fu-plugin-dell.c @@ -258,9 +258,10 @@ fu_plugin_dock_node (FuPlugin *plugin, GUsbDevice *device, fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_REQUIRE_AC); if (version != NULL) { fu_device_set_version (dev, version); - if (fu_plugin_dell_capsule_supported (plugin)) - fu_device_add_flag (dev, - FWUPD_DEVICE_FLAG_ALLOW_OFFLINE); + if (fu_plugin_dell_capsule_supported (plugin)) { + fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE); + fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_NEEDS_REBOOT); + } } fu_plugin_device_add (plugin, dev); @@ -605,8 +606,10 @@ fu_plugin_dell_detect_tpm (FuPlugin *plugin, GError **error) fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_INTERNAL); fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_REQUIRE_AC); if (out->flashes_left > 0) { - if (fu_plugin_dell_capsule_supported (plugin)) - fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_ALLOW_OFFLINE); + if (fu_plugin_dell_capsule_supported (plugin)) { + fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE); + fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_NEEDS_REBOOT); + } fu_device_set_flashes_left (dev, out->flashes_left); } fu_plugin_device_add (plugin, dev); @@ -687,7 +690,7 @@ fu_plugin_unlock (FuPlugin *plugin, FuDevice *device, GError **error) /* clone the info from real device but prevent it from being flashed */ device_flags_alt = fu_device_get_flags (device_alt); fu_device_set_flags (device, device_flags_alt); - fu_device_set_flags (device_alt, device_flags_alt & ~FWUPD_DEVICE_FLAG_ALLOW_OFFLINE); + fu_device_set_flags (device_alt, device_flags_alt & ~FWUPD_DEVICE_FLAG_UPDATABLE); /* make sure that this unlocked device can be updated */ fu_device_set_version (device, "0.0.0.0"); @@ -696,11 +699,11 @@ fu_plugin_unlock (FuPlugin *plugin, FuDevice *device, GError **error) } gboolean -fu_plugin_update_offline (FuPlugin *plugin, - FuDevice *device, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) +fu_plugin_update (FuPlugin *plugin, + FuDevice *device, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { FuPluginData *data = fu_plugin_get_data (plugin); g_autoptr (fwup_resource_iter) iter = NULL; diff --git a/plugins/dell/fu-self-test.c b/plugins/dell/fu-self-test.c index 367497c95..5e2f669f2 100644 --- a/plugins/dell/fu-self-test.c +++ b/plugins/dell/fu-self-test.c @@ -106,7 +106,7 @@ fu_plugin_dell_tpm_func (void) /* make sure not allowed to flash 1.2 */ flags = fu_device_get_flags (device_alt); - g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_ALLOW_OFFLINE, !=, 1); + g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_UPDATABLE, !=, 1); /* try to unlock 2.0 */ ret = fu_plugin_runner_unlock (plugin, device, &error); @@ -138,7 +138,7 @@ fu_plugin_dell_tpm_func (void) /* make sure allowed to flash 1.2 */ flags = fu_device_get_flags (device_alt); - g_assert_cmpint(flags & FWUPD_DEVICE_FLAG_ALLOW_OFFLINE, >, 0); + g_assert_cmpint(flags & FWUPD_DEVICE_FLAG_UPDATABLE, >, 0); /* try to unlock 2.0 */ ret = fu_plugin_runner_unlock (plugin, device, &error); @@ -170,9 +170,9 @@ fu_plugin_dell_tpm_func (void) /* make sure allowed to flash 1.2 but not 2.0 */ flags = fu_device_get_flags (device_alt); - g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_ALLOW_OFFLINE, >, 0); + g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_UPDATABLE, >, 0); flags = fu_device_get_flags (device); - g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_ALLOW_OFFLINE, ==, 0); + g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_UPDATABLE, ==, 0); /* try to unlock 2.0 */ ret = fu_plugin_runner_unlock (plugin, device, &error); @@ -181,9 +181,9 @@ fu_plugin_dell_tpm_func (void) /* make sure no longer allowed to flash 1.2 but can flash 2.0 */ flags = fu_device_get_flags (device_alt); - g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_ALLOW_OFFLINE, ==, 0); + g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_UPDATABLE, ==, 0); flags = fu_device_get_flags (device); - g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_ALLOW_OFFLINE, >, 0); + g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_UPDATABLE, >, 0); /* cleanup */ fu_plugin_device_remove (plugin, device_alt); @@ -209,21 +209,20 @@ fu_plugin_dell_tpm_func (void) /* make sure allowed to flash 2.0 but not 1.2 */ flags = fu_device_get_flags (device_alt); - g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_ALLOW_OFFLINE, >, 0); + g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_UPDATABLE, >, 0); flags = fu_device_get_flags (device); - g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_ALLOW_OFFLINE, ==, 0); + g_assert_cmpint (flags & FWUPD_DEVICE_FLAG_UPDATABLE, ==, 0); /* With one flash left we need an override */ ret = fu_plugin_runner_update (plugin, device_alt, NULL, NULL, - FWUPD_INSTALL_FLAG_OFFLINE, &error); + FWUPD_INSTALL_FLAG_NONE, &error); g_assert (!ret); g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED); g_clear_error (&error); /* test override */ ret = fu_plugin_runner_update (plugin, device_alt, NULL, NULL, - FWUPD_INSTALL_FLAG_FORCE | - FWUPD_INSTALL_FLAG_OFFLINE, &error); + FWUPD_INSTALL_FLAG_FORCE, &error); g_assert (ret); g_assert_no_error (error); diff --git a/plugins/dfu/fu-plugin-dfu.c b/plugins/dfu/fu-plugin-dfu.c index e04592a69..40e22a38b 100644 --- a/plugins/dfu/fu-plugin-dfu.c +++ b/plugins/dfu/fu-plugin-dfu.c @@ -56,10 +56,8 @@ fu_plugin_dfu_device_update (FuPlugin *plugin, } /* check capabilities */ - if (dfu_device_can_download (device)) { - fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_ALLOW_ONLINE); - fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_ALLOW_OFFLINE); - } + if (dfu_device_can_download (device)) + fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE); /* needs a manual action */ if (dfu_device_has_quirk (device, DFU_DEVICE_QUIRK_NO_DFU_RUNTIME)) { @@ -212,11 +210,11 @@ fu_plugin_dfu_percentage_changed_cb (DfuDevice *device, } gboolean -fu_plugin_update_online (FuPlugin *plugin, - FuDevice *dev, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) +fu_plugin_update (FuPlugin *plugin, + FuDevice *dev, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { FuPluginData *data = fu_plugin_get_data (plugin); DfuDevice *device; diff --git a/plugins/ebitdo/fu-plugin-ebitdo.c b/plugins/ebitdo/fu-plugin-ebitdo.c index 69c55724b..d2c7e6684 100644 --- a/plugins/ebitdo/fu-plugin-ebitdo.c +++ b/plugins/ebitdo/fu-plugin-ebitdo.c @@ -102,11 +102,11 @@ ebitdo_write_progress_cb (goffset current, goffset total, gpointer user_data) } gboolean -fu_plugin_update_online (FuPlugin *plugin, - FuDevice *dev, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) +fu_plugin_update (FuPlugin *plugin, + FuDevice *dev, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { GUsbContext *usb_ctx = fu_plugin_get_usb_context (plugin); const gchar *platform_id; diff --git a/plugins/raspberrypi/fu-plugin-raspberrypi.c b/plugins/raspberrypi/fu-plugin-raspberrypi.c index 6797dad41..bd0991897 100644 --- a/plugins/raspberrypi/fu-plugin-raspberrypi.c +++ b/plugins/raspberrypi/fu-plugin-raspberrypi.c @@ -142,11 +142,11 @@ fu_plugin_raspberrypi_parse_firmware (FuDevice *device, const gchar *fn, GError } gboolean -fu_plugin_update_online (FuPlugin *plugin, - FuDevice *device, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) +fu_plugin_update (FuPlugin *plugin, + FuDevice *device, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { FuPluginData *data = fu_plugin_get_data (plugin); g_autofree gchar *fwfn = NULL; @@ -220,8 +220,7 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) fu_device_add_guid (device, "raspberrypi"); fu_device_set_name (device, "Raspberry Pi"); fu_device_add_flag (device, FWUPD_DEVICE_FLAG_INTERNAL); - fu_device_add_flag (device, FWUPD_DEVICE_FLAG_ALLOW_OFFLINE); - fu_device_add_flag (device, FWUPD_DEVICE_FLAG_ALLOW_ONLINE); + fu_device_add_flag (device, FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag (device, FWUPD_DEVICE_FLAG_REQUIRE_AC); /* get the VC build info */ diff --git a/plugins/synapticsmst/fu-plugin-synapticsmst.c b/plugins/synapticsmst/fu-plugin-synapticsmst.c index 98a5f05ce..1c12640e9 100644 --- a/plugins/synapticsmst/fu-plugin-synapticsmst.c +++ b/plugins/synapticsmst/fu-plugin-synapticsmst.c @@ -110,7 +110,7 @@ fu_plugin_synaptics_add_device (FuPlugin *plugin, /* create the device */ dev = fu_device_new (); fu_device_set_id (dev, dev_id_str); - fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_ALLOW_ONLINE); + fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_set_name (dev, name); fu_device_set_version (dev, synapticsmst_device_get_version (device)); fu_device_add_guid (dev, guid_str); @@ -281,11 +281,11 @@ fu_synapticsmst_write_progress_cb (goffset current, goffset total, gpointer user } gboolean -fu_plugin_update_online (FuPlugin *plugin, - FuDevice *dev, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) +fu_plugin_update (FuPlugin *plugin, + FuDevice *dev, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { g_autoptr(SynapticsMSTDevice) device = NULL; const gchar *device_id; diff --git a/plugins/test/fu-plugin-test.c b/plugins/test/fu-plugin-test.c index 50a8200af..fde5d321b 100644 --- a/plugins/test/fu-plugin-test.c +++ b/plugins/test/fu-plugin-test.c @@ -64,7 +64,7 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) fu_device_set_id (device, "FakeDevice"); fu_device_add_guid (device, "b585990a-003e-5270-89d5-3705a17f9a43"); fu_device_set_name (device, "Integrated_Webcam(TM)"); - fu_device_add_flag (device, FWUPD_DEVICE_FLAG_ALLOW_ONLINE); + fu_device_add_flag (device, FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_set_description (device, "A fake webcam"); fu_device_set_vendor (device, "ACME Corp."); fu_device_set_vendor_id (device, "USB:0x046D"); @@ -113,18 +113,12 @@ fu_plugin_verify (FuPlugin *plugin, } gboolean -fu_plugin_update_online (FuPlugin *plugin, - FuDevice *device, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) +fu_plugin_update (FuPlugin *plugin, + FuDevice *device, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { - if (flags & FWUPD_INSTALL_FLAG_OFFLINE) { - g_set_error_literal (error, - FWUPD_ERROR, - FWUPD_ERROR_INTERNAL, - "cannot handle offline"); - } fu_plugin_set_status (plugin, FWUPD_STATUS_DECOMPRESSING); for (guint i = 1; i <= 100; i++) { g_usleep (1000); diff --git a/plugins/thunderbolt/fu-plugin-thunderbolt.c b/plugins/thunderbolt/fu-plugin-thunderbolt.c index a9a3232d7..c126d8a11 100644 --- a/plugins/thunderbolt/fu-plugin-thunderbolt.c +++ b/plugins/thunderbolt/fu-plugin-thunderbolt.c @@ -237,7 +237,7 @@ fu_plugin_thunderbolt_add (FuPlugin *plugin, GUdevDevice *device) fu_device_add_guid (dev, device_id); if (version != NULL) fu_device_set_version (dev, version); - fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_ALLOW_ONLINE); + fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE); if (is_host) fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_INTERNAL); if (is_safemode) @@ -710,11 +710,11 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) gboolean -fu_plugin_update_online (FuPlugin *plugin, - FuDevice *dev, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) +fu_plugin_update (FuPlugin *plugin, + FuDevice *dev, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { FuPluginData *data = fu_plugin_get_data (plugin); const gchar *devpath; diff --git a/plugins/uefi/fu-plugin-uefi.c b/plugins/uefi/fu-plugin-uefi.c index af8112343..c088df0c6 100644 --- a/plugins/uefi/fu-plugin-uefi.c +++ b/plugins/uefi/fu-plugin-uefi.c @@ -170,11 +170,11 @@ fu_plugin_get_results (FuPlugin *plugin, FuDevice *device, GError **error) } gboolean -fu_plugin_update_offline (FuPlugin *plugin, - FuDevice *device, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) +fu_plugin_update (FuPlugin *plugin, + FuDevice *device, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { g_autoptr(GError) error_local = NULL; fwup_resource *re = NULL; @@ -336,7 +336,7 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) fu_device_set_id (dev, "UEFI-dummy-dev0"); fu_device_add_guid (dev, "2d47f29b-83a2-4f31-a2e8-63474f4d4c2e"); fu_device_set_version (dev, "0"); - fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_ALLOW_ONLINE); + fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_LOCKED); fu_plugin_device_add (plugin, dev); return TRUE; @@ -405,10 +405,12 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) } fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_INTERNAL); if (g_file_test ("/sys/firmware/efi/efivars", G_FILE_TEST_IS_DIR) || - g_file_test ("/sys/firmware/efi/vars", G_FILE_TEST_IS_DIR)) - fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_ALLOW_OFFLINE); - else + g_file_test ("/sys/firmware/efi/vars", G_FILE_TEST_IS_DIR)) { + fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE); + fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_NEEDS_REBOOT); + } else { g_warning ("Kernel support for EFI variables missing"); + } fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_REQUIRE_AC); fu_plugin_device_add (plugin, dev); } diff --git a/plugins/unifying/fu-plugin-unifying.c b/plugins/unifying/fu-plugin-unifying.c index 189271b8a..41d4a4b6d 100644 --- a/plugins/unifying/fu-plugin-unifying.c +++ b/plugins/unifying/fu-plugin-unifying.c @@ -60,7 +60,7 @@ fu_plugin_unifying_device_added (FuPlugin *plugin, /* create new FuDevice */ dev = fu_device_new (); if (lu_device_has_flag (device, LU_DEVICE_FLAG_CAN_FLASH)) - fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_ALLOW_ONLINE); + fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_set_id (dev, lu_device_get_platform_id (device)); fu_device_set_name (dev, lu_device_get_product (device)); fu_device_set_vendor (dev, lu_device_get_vendor (device)); @@ -140,11 +140,11 @@ fu_plugin_unifying_attach_cb (gpointer user_data) } gboolean -fu_plugin_update_online (FuPlugin *plugin, - FuDevice *dev, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) +fu_plugin_update (FuPlugin *plugin, + FuDevice *dev, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { FuPluginData *data = fu_plugin_get_data (plugin); g_autoptr(LuDevice) device = NULL; diff --git a/src/fu-device.h b/src/fu-device.h index 072d31e1a..b74b8a3df 100644 --- a/src/fu-device.h +++ b/src/fu-device.h @@ -1,6 +1,6 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * Copyright (C) 2015 Richard Hughes + * Copyright (C) 2015-2017 Richard Hughes * * Licensed under the GNU General Public License Version 2 * diff --git a/src/fu-engine.c b/src/fu-engine.c index 854ffbed0..14695be56 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -905,7 +905,7 @@ fu_engine_get_item_by_wildcard (FuEngine *self, AsStore *store, GError **error) * @device_id: A device ID * @store: The #AsStore with the firmware metadata * @blob_cab: The #GBytes of the .cab file - * @flags: The #FwupdInstallFlags, e.g. %FWUPD_DEVICE_FLAG_ALLOW_ONLINE + * @flags: The #FwupdInstallFlags, e.g. %FWUPD_DEVICE_FLAG_UPDATABLE * @error: A #GError, or %NULL * * Installs a specfic firmware file on a device. @@ -960,8 +960,7 @@ fu_engine_install (FuEngine *self, } /* no update abilities */ - if (!fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_ALLOW_OFFLINE) && - !fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_ALLOW_ONLINE)) { + if (!fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_UPDATABLE)) { g_set_error (error, FWUPD_ERROR, FWUPD_ERROR_INTERNAL, @@ -970,24 +969,14 @@ fu_engine_install (FuEngine *self, return FALSE; } - /* Called with online update, test if device is supposed to allow this */ - if (!(flags & FWUPD_INSTALL_FLAG_OFFLINE) && - !fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_ALLOW_ONLINE)) { - g_set_error(error, - FWUPD_ERROR, - FWUPD_ERROR_NOT_SUPPORTED, - "Device %s does not allow online updates", - device_id); - return FALSE; - } - /* Called with offline update, test if device is supposed to allow this */ - if (flags & FWUPD_INSTALL_FLAG_OFFLINE && - !fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_ALLOW_OFFLINE)) { + /* called with online update, test if device is supposed to allow this */ + if ((flags & FWUPD_INSTALL_FLAG_OFFLINE) == 0 && + fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_ONLY_OFFLINE)) { g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED, - "Device %s does not allow offline updates", + "Device %s only allows offline updates", device_id); return FALSE; } @@ -1243,7 +1232,7 @@ fu_engine_get_item_by_id_fallback_pending (FuEngine *self, const gchar *id, GErr * @self: A #FuEngine * @device_id: A device ID * @store: The #AsStore with the firmware metadata - * @flags: The #FwupdInstallFlags, e.g. %FWUPD_DEVICE_FLAG_ALLOW_ONLINE + * @flags: The #FwupdInstallFlags, e.g. %FWUPD_DEVICE_FLAG_UPDATABLE * @error: A #GError, or %NULL * * Gets the PolicyKit action ID to use for the install operation. @@ -1665,9 +1654,8 @@ fu_engine_get_updates_item_update (FuEngine *self, FuDeviceItem *item) } /* only show devices that can be updated */ - if (!fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_ALLOW_OFFLINE) && - !fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_ALLOW_ONLINE)) { - g_debug ("ignoring %s [%s] as not updatable live or offline", + if (!fu_device_has_flag (item->device, FWUPD_DEVICE_FLAG_UPDATABLE)) { + g_debug ("ignoring %s [%s] as not updatable", fu_device_get_id (item->device), fu_device_get_name (item->device)); return FALSE; diff --git a/src/fu-plugin-vfuncs.h b/src/fu-plugin-vfuncs.h index 3b467fb32..749650c25 100644 --- a/src/fu-plugin-vfuncs.h +++ b/src/fu-plugin-vfuncs.h @@ -1,6 +1,6 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * Copyright (C) 2016 Richard Hughes + * Copyright (C) 2016-2017 Richard Hughes * * Licensed under the GNU General Public License Version 2 * @@ -37,12 +37,7 @@ gboolean fu_plugin_coldplug_prepare (FuPlugin *plugin, GError **error); gboolean fu_plugin_coldplug_cleanup (FuPlugin *plugin, GError **error); -gboolean fu_plugin_update_online (FuPlugin *plugin, - FuDevice *dev, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error); -gboolean fu_plugin_update_offline (FuPlugin *plugin, +gboolean fu_plugin_update (FuPlugin *plugin, FuDevice *dev, GBytes *blob_fw, FwupdInstallFlags flags, diff --git a/src/fu-plugin.c b/src/fu-plugin.c index dc959bc6a..e0ca46c21 100644 --- a/src/fu-plugin.c +++ b/src/fu-plugin.c @@ -1,6 +1,6 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * Copyright (C) 2016 Richard Hughes + * Copyright (C) 2016-2017 Richard Hughes * * Licensed under the GNU General Public License Version 2 * @@ -919,15 +919,14 @@ fu_plugin_runner_unlock (FuPlugin *plugin, FuDevice *device, GError **error) gboolean fu_plugin_runner_update (FuPlugin *plugin, - FuDevice *device, - GBytes *blob_cab, - GBytes *blob_fw, - FwupdInstallFlags flags, - GError **error) + FuDevice *device, + GBytes *blob_cab, + GBytes *blob_fw, + FwupdInstallFlags flags, + GError **error) { FuPluginPrivate *priv = GET_PRIVATE (plugin); - FuPluginUpdateFunc func_online; - FuPluginUpdateFunc func_offline; + FuPluginUpdateFunc update_func; g_autoptr(FuPending) pending = NULL; g_autoptr(FwupdResult) res_pending = NULL; GError *error_update = NULL; @@ -938,18 +937,21 @@ fu_plugin_runner_update (FuPlugin *plugin, return TRUE; /* optional */ - g_module_symbol (priv->module, "fu_plugin_update_online", (gpointer *) &func_online); - g_module_symbol (priv->module, "fu_plugin_update_offline", (gpointer *) &func_offline); + g_module_symbol (priv->module, "fu_plugin_update", (gpointer *) &update_func); + if (update_func == NULL) { + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "No update possible"); + return FALSE; + } - /* schedule for next reboot, or handle in the plugin */ + /* just schedule this for the next reboot */ if (flags & FWUPD_INSTALL_FLAG_OFFLINE) { - if (func_offline == NULL) { - return fu_plugin_runner_schedule_update (plugin, - device, - blob_cab, - error); - } - return func_offline (plugin, device, blob_fw, flags, error); + return fu_plugin_runner_schedule_update (plugin, + device, + blob_cab, + error); } /* cancel the pending action */ @@ -957,16 +959,9 @@ fu_plugin_runner_update (FuPlugin *plugin, return FALSE; /* online */ - if (func_online == NULL) { - g_set_error_literal (error, - FWUPD_ERROR, - FWUPD_ERROR_NOT_SUPPORTED, - "No online update possible"); - return FALSE; - } pending = fu_pending_new (); res_pending = fu_pending_get_device (pending, fu_device_get_id (device), NULL); - if (!func_online (plugin, device, blob_fw, flags, &error_update)) { + if (!update_func (plugin, device, blob_fw, flags, &error_update)) { /* save the error to the database */ if (res_pending != NULL) { fu_pending_set_error_msg (pending, FWUPD_RESULT (device),