Richard Hughes | 02c90d8 | 2018-08-09 12:13:03 +0100 | [diff] [blame] | 1 | /* |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 2 | * Copyright (C) 2017 Richard Hughes <richard@hughsie.com> |
| 3 | * |
Mario Limonciello | 51308e6 | 2018-05-28 20:05:46 -0500 | [diff] [blame] | 4 | * SPDX-License-Identifier: LGPL-2.1+ |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Richard Hughes | bfd946e | 2019-02-09 08:21:40 +0000 | [diff] [blame] | 7 | #pragma once |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 8 | |
Richard Hughes | 481aa2a | 2018-09-18 20:51:46 +0100 | [diff] [blame] | 9 | #include <xmlb.h> |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 10 | #include <glib-object.h> |
Richard Hughes | d5aab65 | 2020-02-25 12:47:50 +0000 | [diff] [blame] | 11 | #include <jcat.h> |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 12 | |
Richard Hughes | 80893e2 | 2017-09-15 16:09:22 +0100 | [diff] [blame] | 13 | #include "fwupd-device.h" |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 14 | #include "fwupd-enums.h" |
| 15 | |
Richard Hughes | 5b5f655 | 2018-05-18 10:22:39 +0100 | [diff] [blame] | 16 | #include "fu-common.h" |
Richard Hughes | b333e00 | 2021-04-01 10:40:02 +0100 | [diff] [blame] | 17 | #include "fu-context.h" |
Richard Hughes | df89cd5 | 2020-06-26 20:25:18 +0100 | [diff] [blame] | 18 | #include "fu-engine-request.h" |
Richard Hughes | 1d1f5cf | 2018-05-19 23:06:03 +0100 | [diff] [blame] | 19 | #include "fu-install-task.h" |
Richard Hughes | 7769fb8 | 2017-09-17 21:14:48 +0100 | [diff] [blame] | 20 | #include "fu-plugin.h" |
Richard Hughes | f58ac73 | 2020-05-12 15:23:44 +0100 | [diff] [blame] | 21 | #include "fu-security-attrs.h" |
Richard Hughes | 7769fb8 | 2017-09-17 21:14:48 +0100 | [diff] [blame] | 22 | |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 23 | #define FU_TYPE_ENGINE (fu_engine_get_type ()) |
| 24 | G_DECLARE_FINAL_TYPE (FuEngine, fu_engine, FU, ENGINE, GObject) |
| 25 | |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 26 | /** |
| 27 | * FuEngineLoadFlags: |
| 28 | * @FU_ENGINE_LOAD_FLAG_NONE: No flags set |
Richard Hughes | c7d870a | 2020-12-10 10:05:35 +0000 | [diff] [blame] | 29 | * @FU_ENGINE_LOAD_FLAG_READONLY: Ignore readonly filesystem errors |
| 30 | * @FU_ENGINE_LOAD_FLAG_COLDPLUG: Enumerate devices |
| 31 | * @FU_ENGINE_LOAD_FLAG_REMOTES: Enumerate remotes |
| 32 | * @FU_ENGINE_LOAD_FLAG_HWINFO: Load details about the hardware |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 33 | * |
| 34 | * The flags to use when loading the engine. |
| 35 | **/ |
Richard Hughes | c8cc77c | 2019-03-07 11:57:24 +0000 | [diff] [blame] | 36 | typedef enum { |
| 37 | FU_ENGINE_LOAD_FLAG_NONE = 0, |
Richard Hughes | c7d870a | 2020-12-10 10:05:35 +0000 | [diff] [blame] | 38 | FU_ENGINE_LOAD_FLAG_READONLY = 1 << 0, |
| 39 | FU_ENGINE_LOAD_FLAG_COLDPLUG = 1 << 1, |
| 40 | FU_ENGINE_LOAD_FLAG_REMOTES = 1 << 2, |
| 41 | FU_ENGINE_LOAD_FLAG_HWINFO = 1 << 3, |
Mario Limonciello | 3960265 | 2019-04-29 21:08:58 -0500 | [diff] [blame] | 42 | /*< private >*/ |
Richard Hughes | c8cc77c | 2019-03-07 11:57:24 +0000 | [diff] [blame] | 43 | FU_ENGINE_LOAD_FLAG_LAST |
| 44 | } FuEngineLoadFlags; |
| 45 | |
Richard Hughes | 5b5f655 | 2018-05-18 10:22:39 +0100 | [diff] [blame] | 46 | FuEngine *fu_engine_new (FuAppFlags app_flags); |
Richard Hughes | f517c9a | 2019-03-22 19:50:35 +0000 | [diff] [blame] | 47 | void fu_engine_add_app_flag (FuEngine *self, |
| 48 | FuAppFlags app_flags); |
Richard Hughes | c02ee4d | 2018-05-22 15:46:03 +0100 | [diff] [blame] | 49 | void fu_engine_add_plugin_filter (FuEngine *self, |
| 50 | const gchar *plugin_glob); |
Richard Hughes | 75b965d | 2018-11-15 13:51:21 +0000 | [diff] [blame] | 51 | void fu_engine_idle_reset (FuEngine *self); |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 52 | gboolean fu_engine_load (FuEngine *self, |
Richard Hughes | c8cc77c | 2019-03-07 11:57:24 +0000 | [diff] [blame] | 53 | FuEngineLoadFlags flags, |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 54 | GError **error); |
Richard Hughes | 8c71a3f | 2018-05-22 19:19:52 +0100 | [diff] [blame] | 55 | gboolean fu_engine_load_plugins (FuEngine *self, |
| 56 | GError **error); |
Richard Hughes | f425d29 | 2019-01-18 17:57:39 +0000 | [diff] [blame] | 57 | gboolean fu_engine_get_tainted (FuEngine *self); |
Richard Hughes | 0c6efe2 | 2020-05-20 18:31:48 +0100 | [diff] [blame] | 58 | const gchar *fu_engine_get_host_product (FuEngine *self); |
| 59 | const gchar *fu_engine_get_host_machine_id (FuEngine *self); |
Richard Hughes | 196c6c6 | 2020-05-11 19:42:47 +0100 | [diff] [blame] | 60 | const gchar *fu_engine_get_host_security_id (FuEngine *self); |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 61 | FwupdStatus fu_engine_get_status (FuEngine *self); |
Richard Hughes | 481aa2a | 2018-09-18 20:51:46 +0100 | [diff] [blame] | 62 | XbSilo *fu_engine_get_silo_from_blob (FuEngine *self, |
Richard Hughes | 4eada34 | 2017-10-03 21:20:32 +0100 | [diff] [blame] | 63 | GBytes *blob_cab, |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 64 | GError **error); |
Richard Hughes | c7bbbc2 | 2018-01-02 22:22:25 +0000 | [diff] [blame] | 65 | guint64 fu_engine_get_archive_size_max (FuEngine *self); |
Richard Hughes | 8c71a3f | 2018-05-22 19:19:52 +0100 | [diff] [blame] | 66 | GPtrArray *fu_engine_get_plugins (FuEngine *self); |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 67 | GPtrArray *fu_engine_get_devices (FuEngine *self, |
| 68 | GError **error); |
Richard Hughes | 4ad41f0 | 2018-05-08 14:35:36 +0100 | [diff] [blame] | 69 | FuDevice *fu_engine_get_device (FuEngine *self, |
| 70 | const gchar *device_id, |
| 71 | GError **error); |
Richard Hughes | 3aaf53c | 2020-04-20 09:39:46 +0100 | [diff] [blame] | 72 | GPtrArray *fu_engine_get_devices_by_guid (FuEngine *self, |
| 73 | const gchar *guid, |
| 74 | GError **error); |
Richard Hughes | 63bc42e | 2021-04-22 09:32:07 +0100 | [diff] [blame] | 75 | GPtrArray *fu_engine_get_devices_by_composite_id (FuEngine *self, |
| 76 | const gchar *composite_id, |
| 77 | GError **error); |
Richard Hughes | 476363a | 2018-01-11 10:08:58 +0000 | [diff] [blame] | 78 | GPtrArray *fu_engine_get_history (FuEngine *self, |
| 79 | GError **error); |
Mario Limonciello | 46aaee8 | 2019-01-10 12:58:00 -0600 | [diff] [blame] | 80 | FwupdRemote *fu_engine_get_remote_by_id (FuEngine *self, |
| 81 | const gchar *remote_id, |
| 82 | GError **error); |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 83 | GPtrArray *fu_engine_get_remotes (FuEngine *self, |
| 84 | GError **error); |
| 85 | GPtrArray *fu_engine_get_releases (FuEngine *self, |
Richard Hughes | df89cd5 | 2020-06-26 20:25:18 +0100 | [diff] [blame] | 86 | FuEngineRequest *request, |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 87 | const gchar *device_id, |
| 88 | GError **error); |
Richard Hughes | 97284b1 | 2017-09-13 17:07:58 +0100 | [diff] [blame] | 89 | GPtrArray *fu_engine_get_downgrades (FuEngine *self, |
Richard Hughes | df89cd5 | 2020-06-26 20:25:18 +0100 | [diff] [blame] | 90 | FuEngineRequest *request, |
Richard Hughes | 97284b1 | 2017-09-13 17:07:58 +0100 | [diff] [blame] | 91 | const gchar *device_id, |
| 92 | GError **error); |
Richard Hughes | a96413a | 2017-09-13 17:19:59 +0100 | [diff] [blame] | 93 | GPtrArray *fu_engine_get_upgrades (FuEngine *self, |
Richard Hughes | df89cd5 | 2020-06-26 20:25:18 +0100 | [diff] [blame] | 94 | FuEngineRequest *request, |
Richard Hughes | a96413a | 2017-09-13 17:19:59 +0100 | [diff] [blame] | 95 | const gchar *device_id, |
| 96 | GError **error); |
Richard Hughes | 93b1576 | 2017-09-15 11:05:23 +0100 | [diff] [blame] | 97 | FwupdDevice *fu_engine_get_results (FuEngine *self, |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 98 | const gchar *device_id, |
| 99 | GError **error); |
Richard Hughes | 56e7ae5 | 2020-05-17 21:00:23 +0100 | [diff] [blame] | 100 | FuSecurityAttrs *fu_engine_get_host_security_attrs (FuEngine *self); |
Richard Hughes | 6ecc4ca | 2020-05-20 18:42:46 +0100 | [diff] [blame] | 101 | GHashTable *fu_engine_get_report_metadata (FuEngine *self, |
| 102 | GError **error); |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 103 | gboolean fu_engine_clear_results (FuEngine *self, |
| 104 | const gchar *device_id, |
| 105 | GError **error); |
| 106 | gboolean fu_engine_update_metadata (FuEngine *self, |
| 107 | const gchar *remote_id, |
| 108 | gint fd, |
| 109 | gint fd_sig, |
| 110 | GError **error); |
Richard Hughes | be5b019 | 2020-01-17 14:32:23 +0000 | [diff] [blame] | 111 | gboolean fu_engine_update_metadata_bytes (FuEngine *self, |
| 112 | const gchar *remote_id, |
| 113 | GBytes *bytes_raw, |
| 114 | GBytes *bytes_sig, |
| 115 | GError **error); |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 116 | gboolean fu_engine_unlock (FuEngine *self, |
| 117 | const gchar *device_id, |
| 118 | GError **error); |
| 119 | gboolean fu_engine_verify (FuEngine *self, |
| 120 | const gchar *device_id, |
| 121 | GError **error); |
| 122 | gboolean fu_engine_verify_update (FuEngine *self, |
| 123 | const gchar *device_id, |
| 124 | GError **error); |
Richard Hughes | fbd8b5d | 2020-09-24 11:48:59 +0100 | [diff] [blame] | 125 | GBytes *fu_engine_firmware_dump (FuEngine *self, |
Richard Hughes | a58510b | 2019-10-30 10:03:12 +0000 | [diff] [blame] | 126 | FuDevice *device, |
| 127 | FwupdInstallFlags flags, |
| 128 | GError **error); |
Richard Hughes | a6bd558 | 2017-09-07 14:32:22 +0100 | [diff] [blame] | 129 | gboolean fu_engine_modify_remote (FuEngine *self, |
| 130 | const gchar *remote_id, |
| 131 | const gchar *key, |
| 132 | const gchar *value, |
| 133 | GError **error); |
Richard Hughes | 6b22295 | 2018-01-11 10:20:48 +0000 | [diff] [blame] | 134 | gboolean fu_engine_modify_device (FuEngine *self, |
| 135 | const gchar *device_id, |
| 136 | const gchar *key, |
| 137 | const gchar *value, |
| 138 | GError **error); |
Richard Hughes | dbd8c76 | 2018-06-15 20:31:40 +0100 | [diff] [blame] | 139 | gboolean fu_engine_composite_prepare (FuEngine *self, |
| 140 | GPtrArray *devices, |
| 141 | GError **error); |
| 142 | gboolean fu_engine_composite_cleanup (FuEngine *self, |
| 143 | GPtrArray *devices, |
| 144 | GError **error); |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 145 | gboolean fu_engine_install (FuEngine *self, |
Richard Hughes | 1d1f5cf | 2018-05-19 23:06:03 +0100 | [diff] [blame] | 146 | FuInstallTask *task, |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 147 | GBytes *blob_cab, |
| 148 | FwupdInstallFlags flags, |
| 149 | GError **error); |
Richard Hughes | 6e7419d | 2018-05-18 10:11:36 +0100 | [diff] [blame] | 150 | gboolean fu_engine_install_blob (FuEngine *self, |
| 151 | FuDevice *device, |
Richard Hughes | 6e7419d | 2018-05-18 10:11:36 +0100 | [diff] [blame] | 152 | GBytes *blob_fw, |
Richard Hughes | 6e7419d | 2018-05-18 10:11:36 +0100 | [diff] [blame] | 153 | FwupdInstallFlags flags, |
| 154 | GError **error); |
Richard Hughes | dbd8c76 | 2018-06-15 20:31:40 +0100 | [diff] [blame] | 155 | gboolean fu_engine_install_tasks (FuEngine *self, |
Richard Hughes | df89cd5 | 2020-06-26 20:25:18 +0100 | [diff] [blame] | 156 | FuEngineRequest *request, |
Richard Hughes | dbd8c76 | 2018-06-15 20:31:40 +0100 | [diff] [blame] | 157 | GPtrArray *install_tasks, |
| 158 | GBytes *blob_cab, |
| 159 | FwupdInstallFlags flags, |
| 160 | GError **error); |
Richard Hughes | 07f963a | 2017-09-15 14:28:47 +0100 | [diff] [blame] | 161 | GPtrArray *fu_engine_get_details (FuEngine *self, |
Richard Hughes | df89cd5 | 2020-06-26 20:25:18 +0100 | [diff] [blame] | 162 | FuEngineRequest *request, |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 163 | gint fd, |
| 164 | GError **error); |
Mario Limonciello | 96a0dd5 | 2019-02-25 13:50:03 -0600 | [diff] [blame] | 165 | gboolean fu_engine_activate (FuEngine *self, |
| 166 | const gchar *device_id, |
| 167 | GError **error); |
Richard Hughes | 8dd4c1c | 2019-03-03 18:27:57 +0000 | [diff] [blame] | 168 | GPtrArray *fu_engine_get_approved_firmware (FuEngine *self); |
| 169 | void fu_engine_add_approved_firmware (FuEngine *self, |
| 170 | const gchar *checksum); |
Richard Hughes | 3120683 | 2020-07-27 15:31:11 +0100 | [diff] [blame] | 171 | void fu_engine_set_approved_firmware (FuEngine *self, |
| 172 | GPtrArray *checksums); |
| 173 | GPtrArray *fu_engine_get_blocked_firmware (FuEngine *self); |
| 174 | void fu_engine_add_blocked_firmware (FuEngine *self, |
| 175 | const gchar *checksum); |
| 176 | gboolean fu_engine_set_blocked_firmware (FuEngine *self, |
| 177 | GPtrArray *checksums, |
| 178 | GError **error); |
Richard Hughes | 3d60762 | 2019-03-07 16:59:27 +0000 | [diff] [blame] | 179 | gchar *fu_engine_self_sign (FuEngine *self, |
| 180 | const gchar *value, |
Richard Hughes | d5aab65 | 2020-02-25 12:47:50 +0000 | [diff] [blame] | 181 | JcatSignFlags flags, |
Richard Hughes | 3d60762 | 2019-03-07 16:59:27 +0000 | [diff] [blame] | 182 | GError **error); |
Mario Limonciello | bfcf75b | 2019-04-17 15:05:39 +0100 | [diff] [blame] | 183 | gboolean fu_engine_modify_config (FuEngine *self, |
| 184 | const gchar *key, |
| 185 | const gchar *value, |
| 186 | GError **error); |
Richard Hughes | b333e00 | 2021-04-01 10:40:02 +0100 | [diff] [blame] | 187 | FuContext *fu_engine_get_context (FuEngine *engine); |
Mario Limonciello | 537da0e | 2020-03-09 15:38:17 -0500 | [diff] [blame] | 188 | void fu_engine_md_refresh_device_from_component (FuEngine *self, |
| 189 | FuDevice *device, |
| 190 | XbNode *component); |
Filipe LaĆns | d3a4fd3 | 2020-03-30 21:05:14 +0100 | [diff] [blame] | 191 | GPtrArray *fu_engine_get_releases_for_device (FuEngine *self, |
Richard Hughes | df89cd5 | 2020-06-26 20:25:18 +0100 | [diff] [blame] | 192 | FuEngineRequest *request, |
| 193 | FuDevice *device, |
| 194 | GError **error); |
Richard Hughes | 9945edb | 2017-06-19 10:03:55 +0100 | [diff] [blame] | 195 | |
Richard Hughes | 7769fb8 | 2017-09-17 21:14:48 +0100 | [diff] [blame] | 196 | /* for the self tests */ |
| 197 | void fu_engine_add_device (FuEngine *self, |
Richard Hughes | 7769fb8 | 2017-09-17 21:14:48 +0100 | [diff] [blame] | 198 | FuDevice *device); |
Richard Hughes | 3483410 | 2017-11-21 21:55:00 +0000 | [diff] [blame] | 199 | void fu_engine_add_plugin (FuEngine *self, |
| 200 | FuPlugin *plugin); |
Richard Hughes | 0eb123b | 2018-04-19 12:00:04 +0100 | [diff] [blame] | 201 | void fu_engine_add_runtime_version (FuEngine *self, |
| 202 | const gchar *component_id, |
| 203 | const gchar *version); |
Mario Limonciello | 381c27c | 2020-10-23 16:32:26 -0500 | [diff] [blame] | 204 | gboolean fu_engine_check_trust (FuInstallTask *task, |
| 205 | GError **error); |
Richard Hughes | 0eb123b | 2018-04-19 12:00:04 +0100 | [diff] [blame] | 206 | gboolean fu_engine_check_requirements (FuEngine *self, |
Richard Hughes | df89cd5 | 2020-06-26 20:25:18 +0100 | [diff] [blame] | 207 | FuEngineRequest *request, |
Richard Hughes | 1d1f5cf | 2018-05-19 23:06:03 +0100 | [diff] [blame] | 208 | FuInstallTask *task, |
| 209 | FwupdInstallFlags flags, |
Richard Hughes | 0eb123b | 2018-04-19 12:00:04 +0100 | [diff] [blame] | 210 | GError **error); |
Richard Hughes | 481aa2a | 2018-09-18 20:51:46 +0100 | [diff] [blame] | 211 | void fu_engine_set_silo (FuEngine *self, |
| 212 | XbSilo *silo); |
Mario Limonciello | 4f24d0b | 2019-01-26 01:19:59 -0600 | [diff] [blame] | 213 | XbNode *fu_engine_get_component_by_guids (FuEngine *self, |
| 214 | FuDevice *device); |
Richard Hughes | 019a1bc | 2019-11-26 10:19:33 +0000 | [diff] [blame] | 215 | gboolean fu_engine_schedule_update (FuEngine *self, |
| 216 | FuDevice *device, |
| 217 | FwupdRelease *release, |
| 218 | GBytes *blob_cab, |
| 219 | FwupdInstallFlags flags, |
| 220 | GError **error); |