mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-27 09:46:25 +00:00
trivial: Remove 'dfu-tool watch'
It's been broken for a long time, and nobody has noticed.
This commit is contained in:
parent
98972f4a34
commit
f849a76766
@ -32,17 +32,6 @@ typedef struct {
|
|||||||
FuQuirks *quirks;
|
FuQuirks *quirks;
|
||||||
} DfuToolPrivate;
|
} DfuToolPrivate;
|
||||||
|
|
||||||
static void
|
|
||||||
dfu_tool_print_indent (const gchar *title, const gchar *message, guint indent)
|
|
||||||
{
|
|
||||||
for (gsize i = 0; i < indent; i++)
|
|
||||||
g_print (" ");
|
|
||||||
g_print ("%s:", title);
|
|
||||||
for (gsize i = strlen (title) + indent; i < 15; i++)
|
|
||||||
g_print (" ");
|
|
||||||
g_print ("%s\n", message);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dfu_tool_private_free (DfuToolPrivate *priv)
|
dfu_tool_private_free (DfuToolPrivate *priv)
|
||||||
{
|
{
|
||||||
@ -648,112 +637,6 @@ dfu_tool_read (DfuToolPrivate *priv, gchar **values, GError **error)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
|
||||||
dfu_tool_get_device_string (DfuToolPrivate *priv, DfuDevice *device)
|
|
||||||
{
|
|
||||||
GUsbDevice *usb_device = fu_usb_device_get_dev (FU_USB_DEVICE (device));
|
|
||||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
|
||||||
|
|
||||||
/* open if required, and get status */
|
|
||||||
if (usb_device == NULL) {
|
|
||||||
return g_strdup_printf ("%04x:%04x [%s]",
|
|
||||||
dfu_device_get_runtime_vid (device),
|
|
||||||
dfu_device_get_runtime_pid (device),
|
|
||||||
"removed");
|
|
||||||
}
|
|
||||||
if (!fu_usb_device_is_open (FU_USB_DEVICE (device))) {
|
|
||||||
g_autoptr(GError) error = NULL;
|
|
||||||
locker = fu_device_locker_new (device, &error);
|
|
||||||
if (locker == NULL) {
|
|
||||||
return g_strdup_printf ("%04x:%04x [%s]",
|
|
||||||
fu_usb_device_get_vid (FU_USB_DEVICE (device)),
|
|
||||||
fu_usb_device_get_pid (FU_USB_DEVICE (device)),
|
|
||||||
error->message);
|
|
||||||
}
|
|
||||||
if (!dfu_device_refresh (device, &error))
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return g_strdup_printf ("%04x:%04x [%s:%s]",
|
|
||||||
fu_usb_device_get_vid (FU_USB_DEVICE (device)),
|
|
||||||
fu_usb_device_get_pid (FU_USB_DEVICE (device)),
|
|
||||||
dfu_state_to_string (dfu_device_get_state (device)),
|
|
||||||
dfu_status_to_string (dfu_device_get_status (device)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
dfu_tool_device_added_cb (GUsbContext *context,
|
|
||||||
DfuDevice *device,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
DfuToolPrivate *priv = (DfuToolPrivate *) user_data;
|
|
||||||
g_autofree gchar *tmp = dfu_tool_get_device_string (priv, device);
|
|
||||||
/* TRANSLATORS: this is when a device is hotplugged */
|
|
||||||
dfu_tool_print_indent (_("Added"), tmp, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
dfu_tool_device_removed_cb (GUsbContext *context,
|
|
||||||
DfuDevice *device,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
DfuToolPrivate *priv = (DfuToolPrivate *) user_data;
|
|
||||||
g_autofree gchar *tmp = dfu_tool_get_device_string (priv, device);
|
|
||||||
/* TRANSLATORS: this is when a device is hotplugged */
|
|
||||||
dfu_tool_print_indent (_("Removed"), tmp, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
dfu_tool_device_changed_cb (GUsbContext *context, DfuDevice *device, gpointer user_data)
|
|
||||||
{
|
|
||||||
DfuToolPrivate *priv = (DfuToolPrivate *) user_data;
|
|
||||||
g_autofree gchar *tmp = dfu_tool_get_device_string (priv, device);
|
|
||||||
/* TRANSLATORS: this is when a device is hotplugged */
|
|
||||||
dfu_tool_print_indent (_("Changed"), tmp, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
dfu_tool_watch_cancelled_cb (GCancellable *cancellable, gpointer user_data)
|
|
||||||
{
|
|
||||||
GMainLoop *loop = (GMainLoop *) user_data;
|
|
||||||
/* TRANSLATORS: this is when a device ctrl+c's a watch */
|
|
||||||
g_print ("%s\n", _("Cancelled"));
|
|
||||||
g_main_loop_quit (loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
dfu_tool_watch (DfuToolPrivate *priv, gchar **values, GError **error)
|
|
||||||
{
|
|
||||||
g_autoptr(GUsbContext) usb_context = NULL;
|
|
||||||
g_autoptr(GMainLoop) loop = NULL;
|
|
||||||
g_autoptr(GPtrArray) devices = NULL;
|
|
||||||
|
|
||||||
/* get all the DFU devices */
|
|
||||||
usb_context = g_usb_context_new (error);
|
|
||||||
if (usb_context == NULL)
|
|
||||||
return FALSE;
|
|
||||||
g_usb_context_enumerate (usb_context);
|
|
||||||
|
|
||||||
/* print what's already attached */
|
|
||||||
devices = g_usb_context_get_devices (usb_context);
|
|
||||||
for (guint i = 0; i < devices->len; i++) {
|
|
||||||
DfuDevice *device = g_ptr_array_index (devices, i);
|
|
||||||
dfu_tool_device_added_cb (usb_context, device, priv);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* watch for any hotplugged device */
|
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
|
||||||
g_signal_connect (usb_context, "device-added",
|
|
||||||
G_CALLBACK (dfu_tool_device_added_cb), priv);
|
|
||||||
g_signal_connect (usb_context, "device-removed",
|
|
||||||
G_CALLBACK (dfu_tool_device_removed_cb), priv);
|
|
||||||
g_signal_connect (usb_context, "device-changed",
|
|
||||||
G_CALLBACK (dfu_tool_device_changed_cb), priv);
|
|
||||||
g_signal_connect (priv->cancellable, "cancelled",
|
|
||||||
G_CALLBACK (dfu_tool_watch_cancelled_cb), loop);
|
|
||||||
g_main_loop_run (loop);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
dfu_tool_write_alt (DfuToolPrivate *priv, gchar **values, GError **error)
|
dfu_tool_write_alt (DfuToolPrivate *priv, gchar **values, GError **error)
|
||||||
{
|
{
|
||||||
@ -1019,12 +902,6 @@ main (int argc, char *argv[])
|
|||||||
/* TRANSLATORS: command description */
|
/* TRANSLATORS: command description */
|
||||||
_("Write firmware from file into one partition"),
|
_("Write firmware from file into one partition"),
|
||||||
dfu_tool_write_alt);
|
dfu_tool_write_alt);
|
||||||
dfu_tool_add (priv->cmd_array,
|
|
||||||
"watch",
|
|
||||||
NULL,
|
|
||||||
/* TRANSLATORS: command description */
|
|
||||||
_("Watch DFU devices being hotplugged"),
|
|
||||||
dfu_tool_watch);
|
|
||||||
dfu_tool_add (priv->cmd_array,
|
dfu_tool_add (priv->cmd_array,
|
||||||
"replace-data",
|
"replace-data",
|
||||||
NULL,
|
NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user