mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-27 15:03:59 +00:00
trivial: Connect the device signals in one place only
This commit is contained in:
parent
5d3bcdc2ef
commit
386fbb34c7
@ -95,6 +95,10 @@ fu_util_client_notify_cb(GObject *object, GParamSpec *pspec, FuUtilPrivate *priv
|
|||||||
static void
|
static void
|
||||||
fu_util_update_device_request_cb(FwupdClient *client, FwupdRequest *request, FuUtilPrivate *priv)
|
fu_util_update_device_request_cb(FwupdClient *client, FwupdRequest *request, FuUtilPrivate *priv)
|
||||||
{
|
{
|
||||||
|
/* action has not been assigned yet */
|
||||||
|
if (priv->current_operation == FU_UTIL_OPERATION_UNKNOWN)
|
||||||
|
return;
|
||||||
|
|
||||||
/* nothing sensible to show */
|
/* nothing sensible to show */
|
||||||
if (fwupd_request_get_message(request) == NULL)
|
if (fwupd_request_get_message(request) == NULL)
|
||||||
return;
|
return;
|
||||||
@ -120,6 +124,10 @@ fu_util_update_device_changed_cb(FwupdClient *client, FwupdDevice *device, FuUti
|
|||||||
{
|
{
|
||||||
g_autofree gchar *str = NULL;
|
g_autofree gchar *str = NULL;
|
||||||
|
|
||||||
|
/* action has not been assigned yet */
|
||||||
|
if (priv->current_operation == FU_UTIL_OPERATION_UNKNOWN)
|
||||||
|
return;
|
||||||
|
|
||||||
/* allowed to set whenever the device has changed */
|
/* allowed to set whenever the device has changed */
|
||||||
if (fwupd_device_has_flag(device, FWUPD_DEVICE_FLAG_NEEDS_SHUTDOWN))
|
if (fwupd_device_has_flag(device, FWUPD_DEVICE_FLAG_NEEDS_SHUTDOWN))
|
||||||
priv->completion_flags |= FWUPD_DEVICE_FLAG_NEEDS_SHUTDOWN;
|
priv->completion_flags |= FWUPD_DEVICE_FLAG_NEEDS_SHUTDOWN;
|
||||||
@ -985,10 +993,7 @@ fu_util_device_test(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
.name = "Unknown"};
|
.name = "Unknown"};
|
||||||
|
|
||||||
/* required for interactive devices */
|
/* required for interactive devices */
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
priv->current_operation = FU_UTIL_OPERATION_UPDATE;
|
||||||
"device-request",
|
|
||||||
G_CALLBACK(fu_util_update_device_request_cb),
|
|
||||||
priv);
|
|
||||||
|
|
||||||
/* at least one argument required */
|
/* at least one argument required */
|
||||||
if (g_strv_length(values) == 0) {
|
if (g_strv_length(values) == 0) {
|
||||||
@ -1097,14 +1102,6 @@ fu_util_install(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
priv->current_operation = FU_UTIL_OPERATION_INSTALL;
|
priv->current_operation = FU_UTIL_OPERATION_INSTALL;
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-changed",
|
|
||||||
G_CALLBACK(fu_util_update_device_changed_cb),
|
|
||||||
priv);
|
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-request",
|
|
||||||
G_CALLBACK(fu_util_update_device_request_cb),
|
|
||||||
priv);
|
|
||||||
|
|
||||||
/* install with flags chosen by the user */
|
/* install with flags chosen by the user */
|
||||||
filename = fu_util_download_if_required(priv, values[0], error);
|
filename = fu_util_download_if_required(priv, values[0], error);
|
||||||
@ -2372,14 +2369,6 @@ fu_util_update(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
if (devices == NULL)
|
if (devices == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
priv->current_operation = FU_UTIL_OPERATION_UPDATE;
|
priv->current_operation = FU_UTIL_OPERATION_UPDATE;
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-changed",
|
|
||||||
G_CALLBACK(fu_util_update_device_changed_cb),
|
|
||||||
priv);
|
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-request",
|
|
||||||
G_CALLBACK(fu_util_update_device_request_cb),
|
|
||||||
priv);
|
|
||||||
g_ptr_array_sort(devices, fu_util_sort_devices_by_flags_cb);
|
g_ptr_array_sort(devices, fu_util_sort_devices_by_flags_cb);
|
||||||
for (guint i = 0; i < devices->len; i++) {
|
for (guint i = 0; i < devices->len; i++) {
|
||||||
FwupdDevice *dev = g_ptr_array_index(devices, i);
|
FwupdDevice *dev = g_ptr_array_index(devices, i);
|
||||||
@ -2619,14 +2608,6 @@ fu_util_downgrade(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
|
|
||||||
/* update the console if composite devices are also updated */
|
/* update the console if composite devices are also updated */
|
||||||
priv->current_operation = FU_UTIL_OPERATION_DOWNGRADE;
|
priv->current_operation = FU_UTIL_OPERATION_DOWNGRADE;
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-changed",
|
|
||||||
G_CALLBACK(fu_util_update_device_changed_cb),
|
|
||||||
priv);
|
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-request",
|
|
||||||
G_CALLBACK(fu_util_update_device_request_cb),
|
|
||||||
priv);
|
|
||||||
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_OLDER;
|
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_OLDER;
|
||||||
if (!fu_util_update_device_with_release(priv, dev, rel, error))
|
if (!fu_util_update_device_with_release(priv, dev, rel, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -2688,14 +2669,6 @@ fu_util_reinstall(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
|
|
||||||
/* update the console if composite devices are also updated */
|
/* update the console if composite devices are also updated */
|
||||||
priv->current_operation = FU_UTIL_OPERATION_INSTALL;
|
priv->current_operation = FU_UTIL_OPERATION_INSTALL;
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-changed",
|
|
||||||
G_CALLBACK(fu_util_update_device_changed_cb),
|
|
||||||
priv);
|
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-request",
|
|
||||||
G_CALLBACK(fu_util_update_device_request_cb),
|
|
||||||
priv);
|
|
||||||
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_REINSTALL;
|
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_REINSTALL;
|
||||||
if (!fu_util_update_device_with_release(priv, dev, rel, error))
|
if (!fu_util_update_device_with_release(priv, dev, rel, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -2819,14 +2792,6 @@ fu_util_switch_branch(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
|
|
||||||
/* update the console if composite devices are also updated */
|
/* update the console if composite devices are also updated */
|
||||||
priv->current_operation = FU_UTIL_OPERATION_INSTALL;
|
priv->current_operation = FU_UTIL_OPERATION_INSTALL;
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-changed",
|
|
||||||
G_CALLBACK(fu_util_update_device_changed_cb),
|
|
||||||
priv);
|
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-request",
|
|
||||||
G_CALLBACK(fu_util_update_device_request_cb),
|
|
||||||
priv);
|
|
||||||
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_REINSTALL;
|
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_REINSTALL;
|
||||||
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_BRANCH_SWITCH;
|
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_BRANCH_SWITCH;
|
||||||
if (!fu_util_update_device_with_release(priv, dev, rel, error))
|
if (!fu_util_update_device_with_release(priv, dev, rel, error))
|
||||||
@ -3287,14 +3252,6 @@ fu_util_sync_bkc(FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
|
|
||||||
/* update the console if composite devices are also updated */
|
/* update the console if composite devices are also updated */
|
||||||
priv->current_operation = FU_UTIL_OPERATION_INSTALL;
|
priv->current_operation = FU_UTIL_OPERATION_INSTALL;
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-changed",
|
|
||||||
G_CALLBACK(fu_util_update_device_changed_cb),
|
|
||||||
priv);
|
|
||||||
g_signal_connect(FWUPD_CLIENT(priv->client),
|
|
||||||
"device-request",
|
|
||||||
G_CALLBACK(fu_util_update_device_request_cb),
|
|
||||||
priv);
|
|
||||||
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_OLDER;
|
priv->flags |= FWUPD_INSTALL_FLAG_ALLOW_OLDER;
|
||||||
|
|
||||||
/* for each device, find the release that matches the tag */
|
/* for each device, find the release that matches the tag */
|
||||||
@ -4361,6 +4318,14 @@ main(int argc, char *argv[])
|
|||||||
"notify::status",
|
"notify::status",
|
||||||
G_CALLBACK(fu_util_client_notify_cb),
|
G_CALLBACK(fu_util_client_notify_cb),
|
||||||
priv);
|
priv);
|
||||||
|
g_signal_connect(FWUPD_CLIENT(priv->client),
|
||||||
|
"device-changed",
|
||||||
|
G_CALLBACK(fu_util_update_device_changed_cb),
|
||||||
|
priv);
|
||||||
|
g_signal_connect(FWUPD_CLIENT(priv->client),
|
||||||
|
"device-request",
|
||||||
|
G_CALLBACK(fu_util_update_device_request_cb),
|
||||||
|
priv);
|
||||||
|
|
||||||
/* show a warning if the daemon is tainted */
|
/* show a warning if the daemon is tainted */
|
||||||
if (!fwupd_client_connect(priv->client, priv->cancellable, &error)) {
|
if (!fwupd_client_connect(priv->client, priv->cancellable, &error)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user