blob: 0499201ce9f06478d3e7461e357fc81edf14b3cd [file] [log] [blame]
Richard Hughes02c90d82018-08-09 12:13:03 +01001/*
Richard Hughes5c9b1fc2021-01-07 14:20:49 +00002 * Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
Richard Hughesf7616402018-05-18 09:53:18 +01003 *
Mario Limonciello51308e62018-05-28 20:05:46 -05004 * SPDX-License-Identifier: LGPL-2.1+
Richard Hughesf7616402018-05-18 09:53:18 +01005 */
6
Richard Hughesbfd946e2019-02-09 08:21:40 +00007#pragma once
Richard Hughesf7616402018-05-18 09:53:18 +01008
9#include <glib.h>
Mario Limonciellod1775bc2018-07-17 00:28:52 -050010#include <fwupd.h>
Mario Limonciello75835b42021-01-21 12:47:32 -060011#include "fwupd-security-attr-private.h"
Richard Hughesf7616402018-05-18 09:53:18 +010012
Mario Limonciello3f243a92019-01-21 22:05:23 -060013/* this is only valid for tools */
14#define FWUPD_ERROR_INVALID_ARGS (FWUPD_ERROR_LAST+1)
15
Richard Hughesc77e1112019-03-01 10:16:26 +000016typedef struct FuUtilPrivate FuUtilPrivate;
17typedef gboolean (*FuUtilCmdFunc) (FuUtilPrivate *util,
18 gchar **values,
19 GError **error);
20typedef struct {
21 gchar *name;
22 gchar *arguments;
23 gchar *description;
24 FuUtilCmdFunc callback;
25} FuUtilCmd;
26
Richard Hughes5c82b942020-09-14 12:24:06 +010027typedef enum {
28 FU_SECURITY_ATTR_TO_STRING_FLAG_NONE = 0,
29 FU_SECURITY_ATTR_TO_STRING_FLAG_SHOW_OBSOLETES = 1 << 0,
30 FU_SECURITY_ATTR_TO_STRING_FLAG_SHOW_URLS = 1 << 1,
31 /*< private >*/
32 FU_SECURITY_ATTR_TO_STRING_FLAG_LAST
33} FuSecurityAttrToStringFlags;
34
Richard Hughes7bcb8d42020-10-08 15:47:47 +010035typedef enum {
36 FU_UTIL_CLI_COLOR_BLACK = 30,
37 FU_UTIL_TERM_COLOR_RED = 31,
38 FU_UTIL_CLI_COLOR_GREEN = 32,
39 FU_UTIL_CLI_COLOR_YELLOW = 33,
40 FU_UTIL_CLI_COLOR_BLUE = 34,
41 FU_UTIL_CLI_COLOR_MAGENTA = 35,
42 FU_UTIL_CLI_COLOR_CYAN = 36,
43 FU_UTIL_CLI_COLOR_WHITE = 37,
44} FuUtilTermColor;
45
Richard Hughesf7616402018-05-18 09:53:18 +010046void fu_util_print_data (const gchar *title,
47 const gchar *msg);
Richard Hughes7bcb8d42020-10-08 15:47:47 +010048gchar *fu_util_term_format (const gchar *text,
49 FuUtilTermColor fg_color);
Richard Hughesf7616402018-05-18 09:53:18 +010050guint fu_util_prompt_for_number (guint maxnum);
51gboolean fu_util_prompt_for_boolean (gboolean def);
52
Mario Limonciello4250d9d2019-08-29 09:53:44 -050053void fu_util_print_tree (GNode *n, gpointer data);
Mario Limonciellod1775bc2018-07-17 00:28:52 -050054gboolean fu_util_is_interesting_device (FwupdDevice *dev);
Richard Hughes798cb062018-08-30 14:17:42 +010055gchar *fu_util_get_user_cache_path (const gchar *fn);
Mario Limonciello2d4b7a52018-09-12 22:08:04 -050056gchar *fu_util_get_versions (void);
57
Richard Hughese69f0f52021-04-22 11:10:23 +010058void fu_util_warning_box (const gchar *title,
59 const gchar *body,
Richard Hughesacfa4ef2019-05-01 12:18:25 +010060 guint width);
Mario Limonciello98b95162019-10-30 09:20:43 -050061gboolean fu_util_prompt_warning (FwupdDevice *device,
62 const gchar *machine,
63 GError **error);
Mario Limonciello3f243a92019-01-21 22:05:23 -060064gboolean fu_util_prompt_complete (FwupdDeviceFlags flags,
65 gboolean prompt,
66 GError **error);
Richard Hughes4499d192019-03-08 11:44:44 +000067gboolean fu_util_update_reboot (GError **error);
Richard Hughes2d3287a2019-02-10 17:32:14 +000068
Richard Hughesc77e1112019-03-01 10:16:26 +000069GPtrArray *fu_util_cmd_array_new (void);
70void fu_util_cmd_array_add (GPtrArray *array,
71 const gchar *name,
72 const gchar *arguments,
73 const gchar *description,
74 FuUtilCmdFunc callback);
75gchar *fu_util_cmd_array_to_string (GPtrArray *array);
76void fu_util_cmd_array_sort (GPtrArray *array);
77gboolean fu_util_cmd_array_run (GPtrArray *array,
78 FuUtilPrivate *priv,
79 const gchar *command,
80 gchar **values,
81 GError **error);
Richard Hughes02ac92c2019-03-29 17:56:46 +000082gchar *fu_util_release_get_name (FwupdRelease *release);
Richard Hughes89ee9ed2021-01-20 16:15:29 +000083const gchar *fu_util_branch_for_display (const gchar *branch);
Richard Hughesc77e1112019-03-01 10:16:26 +000084
Richard Hughes3d005222019-05-17 14:02:41 +010085const gchar *fu_util_get_systemd_unit (void);
Mario Limonciello88f8b7f2019-05-07 15:52:39 -050086gboolean fu_util_using_correct_daemon (GError **error);
Richard Hughesfb9cfff2019-04-17 15:01:03 +010087
Richard Hughes747f5702019-08-06 14:27:26 +010088gboolean fu_util_parse_filter_flags (const gchar *filter,
89 FwupdDeviceFlags *include,
90 FwupdDeviceFlags *exclude,
91 GError **error);
Mario Limonciellofee8f492019-08-18 12:16:07 -050092gchar *fu_util_convert_description (const gchar *xml,
93 GError **error);
Mario Limoncielloeb442ea2020-01-10 10:56:05 -060094gchar *fu_util_time_to_str (guint64 tmp);
95
Mario Limonciellofee8f492019-08-18 12:16:07 -050096gchar *fu_util_device_to_string (FwupdDevice *dev,
97 guint idt);
Richard Hughes7bcb8d42020-10-08 15:47:47 +010098gchar *fu_util_plugin_to_string (FwupdPlugin *plugin,
99 guint idt);
100const gchar *fu_util_plugin_flag_to_string (FwupdPluginFlags plugin_flag);
Mario Limonciellofee8f492019-08-18 12:16:07 -0500101gchar *fu_util_release_to_string (FwupdRelease *rel,
102 guint idt);
Mario Limonciello4250d9d2019-08-29 09:53:44 -0500103gchar *fu_util_remote_to_string (FwupdRemote *remote,
104 guint idt);
Richard Hughes5c82b942020-09-14 12:24:06 +0100105gchar *fu_util_security_attrs_to_string (GPtrArray *attrs,
106 FuSecurityAttrToStringFlags flags);
Richard Hughes9b6d6162020-07-07 16:24:57 +0100107gboolean fu_util_send_report (FwupdClient *client,
Richard Hughes6d9ae622020-06-16 15:20:23 +0100108 const gchar *report_uri,
109 const gchar *data,
110 const gchar *sig,
111 gchar **uri,
112 GError **error);
Mario Limoncielloeb7be162020-07-01 15:38:47 -0500113gint fu_util_sort_devices_by_flags_cb (gconstpointer a,
114 gconstpointer b);
Mario Limonciello02085a02020-09-11 14:59:35 -0500115gint fu_util_device_order_sort_cb (gconstpointer a,
116 gconstpointer b);
Mario Limonciello02f2cc32020-10-20 15:39:47 -0500117
118gboolean fu_util_switch_branch_warning (FwupdDevice *dev,
119 FwupdRelease *rel,
120 gboolean assume_yes,
121 GError **error);
Mario Limonciellobd60de12020-11-11 13:09:43 -0600122void fu_util_show_unsupported_warn (void);
Richard Hughes3a73c342020-11-13 13:25:22 +0000123gboolean fu_util_is_url (const gchar *perhaps_url);