Commit Graph

70 Commits

Author SHA1 Message Date
Richard Hughes
a5a978b3f6 Rename some confusing API
More than one person has asked about 'why call fu_plugin_update() for a
reinstall or downgrade' and I didn't have a very good answer.

The plugin API is not officially stable, and we should fix things to be
less confusing. Use the same verbs as the FuDevice vfuncs instead.
2021-08-06 19:49:53 +01:00
Richard Hughes
55f6fd435a Add a ->get_results() vfunc that can be used by subclasses of FuDevice 2021-07-22 12:47:54 +01:00
Richard Hughes
15b668c0c6 Open the device proxy in the engine where required
The benefit of using the proxy device is that we can 'use' the proxy
device for device access, but 'report' the progress on the passed
FuDevice instance.

This means the front-end reports the device status correctly when
updating composite devices that us proxies.

The comment always said we should move it to the daemon if another
plugin started doing this, and that is now.
2021-07-17 17:20:01 +01:00
Richard Hughes
ef73701aa1 trivial: Provide FWUPD_PLUGIN_FLAG_AUTH_REQUIRED for future usage 2021-07-06 20:12:17 +01:00
Richard Hughes
dfaae2e837 Move amdgpu safety check into the plugin
There are now multiple plugins using drm_dp_aux_dev interface which
may potentially be combined with an amdgpu. Prevent exercising this
interface with any plugin using DP aux unless a new enough kernel is
installed.
2021-07-04 17:49:36 +01:00
Richard Hughes
7b209bb2c1 Watch for children added or removed after setup has been completed
Some devices may 'discover' child devices during poll, rather than the
more usual case of adding them as children during setup.
2021-07-02 13:27:10 +01:00
Richard Hughes
a02c1073f2 trivial: Fix up some of the developer docs
And add some missing content as requried.
2021-06-11 09:39:03 +01:00
Mario Limonciello
1e17457b16 Allow building the documentation with gi-docgen and gtk-doc
Until gi-docgen is declared stable support either of them.
This effectively means that hand builds and CI builds will use
gi-docgen, but distro builds use gtk-doc-tools.
2021-06-09 22:21:53 +01:00
Richard Hughes
20ef071b3c trivial: Style fixes to lots of gtk-doc 2021-05-10 14:35:10 +01:00
Richard Hughes
89d45a0d91 trivial: Standardize on introspection for @error and @cancellable
Also standarize on `Returns:` for the result.
2021-04-28 16:19:50 +01:00
Richard Hughes
7b23f95a21 trivial: Fix up some introspection bugs 2021-04-28 16:19:50 +01:00
Richard Hughes
248ea1b8a9 Fix a crash when shutting down the daemon
Unloading the GModule means that any GTypes registered by that plugin cannot be
queried.

Other plugins could unintentionally call methods like G_OBJECT_TYPE_NAME()
which makes the daemon explode. There's no need to actually close the module,
and so we're just making life diffult for ourselves for no good reason.

Fixes the other half of https://github.com/fwupd/fwupd/issues/3156
2021-04-20 15:09:58 +01:00
Richard Hughes
46f86a5c1e trivial: Enforce that fu_plugin_cache_add() uses a valid GObject 2021-04-20 15:09:58 +01:00
Richard Hughes
faa35e430b Show a warning if the device has no GType and the plugin has no default
This also renames a symbol to make it clear that you can call it more than once.

Fixes https://github.com/fwupd/fwupd/issues/3148
2021-04-15 16:52:56 +01:00
Daniel Campello
0b9b7ecc84 fu-engine: only disable coldplug if no HwId is found
This change only disables coldplug instead of the whole plugin if no
HwId is found when FWUPD_PLUGIN_FLAG_NO_HARDWARE is set.
2021-04-08 18:12:16 -06:00
Richard Hughes
b333e0045c Split out a shared system context
There is a lot of code in fwupd that just assigns a shared object type to
a FuPlugin, and then for each device on that plugin assigns that same shared
object to each FuDevice.

Rather than proxy several kinds of information stores over two different levels
of abstraction create a 'context' which contains the shared *system* state
between the daemon, the plugins and the daemon.

This will allow us to hold other per-machine state in the future, for instance
the system battery level or AC state.
2021-04-01 21:11:29 +01:00
Richard Hughes
c6569eff67 Remvoe the unused fu_plugin_set_coldplug_delay() 2021-04-01 16:01:06 +01:00
Richard Hughes
4ae7b5e837 Remove the unused fu_plugin_recoldplug() 2021-04-01 16:01:06 +01:00
Richard Hughes
250f30ceb9 trivial: Remove more deprecated API because we can
We bumped soversion, so lets clean up the API.
2021-04-01 13:12:45 +01:00
Richard Hughes
74ac5ab86d trivial: Add fu_device_remove_flag() as a proper symbol
This allows us to automatically uninhibit() like we do in fu_device_add_flag().
2021-03-31 19:19:46 +01:00
Richard Hughes
b9ac0bc029 Add fu_device_inhibit() to mark the device as non-updatable
We already have two things managing the UPDATABLE_HIDDEN->UPDATABLE transition,
and we're about to add a third.

Add a 'stackable' inhibit-style API so we do not accidentally mark a device as
updatable when it should remain hidden.
2021-03-31 19:19:46 +01:00
Richard Hughes
2d84386034 Remove unused, unsafe and deprecated functions from libfwupdplugin
Keeping *internal* API and ABI compatibility makes working with an already
complex codebase more mentally demanding than it needs to be.

Remember: plugins should be in-tree and upstream! If your out of tree plugin
stops working then it should be upstream.

The public-facing libfwupd will remain API and ABI stable for obvious reasons.
2021-03-09 15:47:56 +00:00
Richard Hughes
c81b755872 Be more strict for custom quirk keys
Rather than trying to guess typos, force each plugin to register the quirk
keys it supports, so we can show a sensible warning if required at startup on
the console.
2021-03-03 08:30:34 +00:00
Richard Hughes
7d132b728c Simplify the quirk file format
The best way of not getting something wrong is to not require it in the first
place...

All plugins now use DeviceInstanceId-style quirk matches and we can just drop
the prefix in all files. We were treating HwId=, Guid= and DeviceInstanceId= in
exactly the same way -- they're just converted to GUIDs when building the silo!
2021-03-03 08:30:34 +00:00
Mario Limonciello
3df7dd3708 libfwupdplugin: don't allow device updates while needing activation 2021-03-03 07:32:35 +00:00
Richard Hughes
53de7e25a4 trivial: Only allow verify-update for plugins that support _CAN_VERIFY
If the user explicitly specifies the device-id then we do not do the front-end
filtering. If the device detaches without being able to attach then the hardware
could be left in the bootloader state.

See https://github.com/fwupd/fwupd/issues/2926#issuecomment-784234180
2021-02-23 14:48:00 +00:00
Richard Hughes
ed0af24406 trivial: Use fwupd_device_remove_flag() to remove a single flag 2021-02-22 22:48:56 +00:00
Richard Hughes
525f71f54b Merge the _udev_device() and _usb_device() vfuncs
There are now two 'backends' of device plug/unplug events, and there is about
to become three. Rather than just adding two more vfuncs for every backend type
define common ones that all providers can use.

Also fix up the existing in-tree plugins to use the new vfunc names and filter
on the correct GType.
2021-02-10 12:04:05 +00:00
Richard Hughes
9e9b73f303 Remove fu_plugin_get_usb_context()
It's unused, and only encourages plugins to do the wrong thing.
2021-02-10 12:04:05 +00:00
Richard Hughes
382524d82f trivial: Fix potential crash when doing crazy things
Fix the asan crash when feeding the value back into itself, e.g

    fu_firmware_set_version (firmware, fu_firmware_get_version (firmware));
2021-01-28 14:13:59 +00:00
Richard Hughes
68ab1e44fd trivial: Add fu_plugin_get_devices() for general plugin use 2021-01-14 21:13:38 +00:00
Richard Hughes
faf2afed02 trivial: Rename the device cache store with a better name 2021-01-14 21:13:38 +00:00
Mario Limonciello
797da4fc60 trivial: adjust error for no UEFI capsules
Point people towards firwmare setup instead (Fixes: #1454)
2021-01-12 12:56:05 -06:00
Richard Hughes
5c9b1fcc81 Only include the start year in the copyright header
The end year is legally and functionally redundant, and more importantly causes
cherry-pick conflicts when trying to maintain old branches. Use git for history.
2021-01-07 14:48:16 +00:00
Richard Hughes
cf100293b5 Do not export useless device attributes to the client
That giant uint64_t isn't looking so big now, and we'll want to add even more
to it in the future. Split out some private flags that are never useful to the
client, although the #defines will have to remain until we break API again.
2021-01-06 14:36:23 +00:00
Mario Limonciello
9a6692eb84 Notify plugins of their own registrations
The Thunderbolt plugin wasn't actually working properly for
`DelayedActivation` because Thunderbolt devices weren't actually registered.

This only affected ChromeOS.
2021-01-06 09:11:00 +00:00
Richard Hughes
ebb10a5c4a trivial: Fix a tiny memory leak when using fu_plugin_add_firmware_gtype() 2021-01-05 15:59:30 +00:00
Richard Hughes
9f71fe3dc9 Make the 'id' for fu_plugin_add_firmware_gtype() optional
We can work out the correct value automatically in all cases but one, and it's
less for the plugin author to get wrong...
2021-01-04 15:27:10 +00:00
Richard Hughes
6a489a9eaf trivial: Add missing calls to g_return_val_if_fail() 2021-01-04 15:24:35 +00:00
Richard Hughes
6fca469737 trivial: Fix regression when using a custom GType
Although the fix in a21e025e46 is correct, we
also need to return TRUE higher up in the conditional.
2020-12-01 18:22:51 +00:00
Richard Hughes
a21e025e46 trivial: Return with an error if the device GType is unclear
Returning TRUE means this is really hard to debug...
2020-12-01 14:15:33 +00:00
Richard Hughes
2bbb7d2b40 trivial: Merge some GtkDoc introspection fixes 2020-11-30 09:18:45 +00:00
Richard Hughes
203ed841da trivial: Codespell fixes 2020-11-02 14:26:26 +00:00
Mario Limonciello
c3a8173a12 Show an error when a plugin is missing dependencies (Fixes: #1526)
```
$ sudo mv /usr/lib/x86_64-linux-gnu/libtss2-esys.so.0.0.0 /usr/lib/x86_64-linux-gnu/libtss2-esys.so.0.0.0.renamed
$ sudo fwupdtool get-devices --plugins=uefi
14:15:48:0735 FuEngine             cannot load: failed to open plugin /usr/local/lib/x86_64-linux-gnu/fwupd-plugins-3/libfu_plugin_uefi.so: libtss2-esys.so.0: cannot open shared object file: No such file or directory
Loading…                 [-                                      ]14:15:48:0753 FuEngine             failed to update history database: device ID b6c08fb9e5384d9d101853cc1ca20cf0ce2df2e2 was not found
Loading…                 [***************************************]
WARNING: Plugin depdendencies missing
No detected devices
```
2020-10-20 10:57:21 -05:00
Richard Hughes
7bcb8d4385 Export FwupdPlugin so we can convey enumerated system errors to the end user
For instance, we can tell the user that UEFI UpdateCapsule is disabled in the
system firmware, or that efivarfs is not mounted. This is much better than
creating "dummy" devices which are really just hacks around the problem because
no better API existed. THe dummy devices cause as many problems as they solve.

Plugins have to set FWUPD_PLUGIN_FLAG_USER_WARNING if a warning should be shown
to the user, and only one warning will be shown of each failure type.

It is expected that GUI clients like gnome-software and gnome-firmware would use
this API to notify the user the localized message for why firmware updates are
not being shown.

Fixes https://github.com/fwupd/fwupd/issues/2456
2020-10-13 15:56:49 +01:00
Richard Hughes
1a61258239 Allow devices to save the old firmware to disk for recovery
This would also help, for example, to go back to the nonfree firmware when the
alternate firmware did not work as well as hoped. It would also allow flashing
the firmware using an SPI programmer if everything went very wrong indeed.
2020-09-30 18:33:00 +01:00
Mario Limonciello
67a8b89453 trivial: clean up some debugging statements 2020-09-28 15:58:53 -05:00
Mario Limonciello
6d23514fb1 Revert "fu-plugin: add a new udev_device_changed function that calls rescan"
This reverts commit 096e3cfbb6.
2020-09-11 13:15:51 -05:00
Richard Hughes
aae22e4df5 trivial: Always clear the mutex before clearing the thing it protects 2020-06-22 21:55:50 +01:00
Richard Hughes
11c5941f23 libfwupdplugin: Make FuPlugin::rules lazy loaded 2020-06-22 21:55:50 +01:00