[Spice-devel] [PATCH spice-gtk 05/14] usb: use win-usb uninstall_finish()
Jonathon Jongsma
jjongsma at redhat.com
Wed Apr 23 13:46:41 PDT 2014
ACK
----- Original Message -----
> From: "Marc-André Lureau" <marcandre.lureau at gmail.com>
> To: spice-devel at freedesktop.org
> Sent: Wednesday, April 23, 2014 1:09:10 PM
> Subject: [Spice-devel] [PATCH spice-gtk 05/14] usb: use win-usb uninstall_finish()
>
> ---
> gtk/usb-device-manager.c | 55
> ++++++++++++++++++++++++++++++------------------
> 1 file changed, 35 insertions(+), 20 deletions(-)
>
> diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
> index a79bf70..147026c 100644
> --- a/gtk/usb-device-manager.c
> +++ b/gtk/usb-device-manager.c
> @@ -1043,7 +1043,6 @@ typedef struct _UsbInstallCbInfo {
> GCancellable *cancellable;
> GAsyncReadyCallback callback;
> gpointer user_data;
> - gboolean is_install;
> } UsbInstallCbInfo;
>
> /**
> @@ -1072,8 +1071,6 @@ static void
> spice_usb_device_manager_drv_install_cb(GObject *gobject,
> UsbInstallCbInfo *cbinfo;
> GCancellable *cancellable;
> GAsyncReadyCallback callback;
> - gboolean is_install;
> - const gchar *opstr;
>
> g_return_if_fail(user_data != NULL);
>
> @@ -1084,7 +1081,6 @@ static void
> spice_usb_device_manager_drv_install_cb(GObject *gobject,
> cancellable = cbinfo->cancellable;
> callback = cbinfo->callback;
> user_data = cbinfo->user_data;
> - is_install = cbinfo->is_install;
>
> g_free(cbinfo);
>
> @@ -1092,31 +1088,21 @@ static void
> spice_usb_device_manager_drv_install_cb(GObject *gobject,
> g_return_if_fail(SPICE_IS_WIN_USB_DRIVER(installer));
> g_return_if_fail(device!= NULL);
>
> - opstr = is_install ? "install" : "uninstall";
> - SPICE_DEBUG("Win USB driver %s finished", opstr);
> + SPICE_DEBUG("Win USB driver install finished");
>
> status = spice_win_usb_driver_install_finish(installer, res, &err);
>
> - spice_usb_device_unref(device);
> -
> - if (is_install) {
> - spice_usb_device_set_state(device,
> SPICE_USB_DEVICE_STATE_INSTALLED);
> - } else {
> - spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_NONE);
> - }
> -
> if (err) {
> - g_warning("win usb driver %s failed -- %s", opstr, err->message);
> + g_warning("win usb driver install failed -- %s", err->message);
> g_error_free(err);
> }
>
> if (!status) {
> - g_warning("failed to %s win usb driver (status=0)", opstr);
> + g_warning("failed to install win usb driver (status=0)");
> }
>
> - if (! is_install) {
> - return;
> - }
> + spice_usb_device_unref(device);
> + spice_usb_device_set_state(device, SPICE_USB_DEVICE_STATE_INSTALLED);
>
> /* device is already ref'ed */
> _spice_usb_device_manager_connect_device_async(self,
> @@ -1126,6 +1112,35 @@ static void
> spice_usb_device_manager_drv_install_cb(GObject *gobject,
> user_data);
>
> }
> +
> +static void spice_usb_device_manager_drv_uninstall_cb(GObject *gobject,
> + GAsyncResult *res,
> + gpointer user_data)
> +{
> + UsbInstallCbInfo *cbinfo = user_data;
> + SpiceUsbDeviceManager *self = cbinfo->manager;
> + GError *err = NULL;
> + gint status;
> +
> + SPICE_DEBUG("Win USB driver uninstall finished");
> + g_return_if_fail(SPICE_IS_USB_DEVICE_MANAGER(self));
> +
> + status = spice_win_usb_driver_uninstall_finish(cbinfo->installer, res,
> &err);
> + if (err) {
> + g_warning("win usb driver uninstall failed -- %s", err->message);
> + g_clear_error(&err);
> + }
> +
> + if (!status) {
> + g_warning("failed to uninstall win usb driver (status=0)");
> + }
> +
> + spice_usb_device_unref(cbinfo->device);
> + spice_usb_device_set_state(cbinfo->device, SPICE_USB_DEVICE_STATE_NONE);
> +
> + g_free(cbinfo);
> +}
> +
> #endif
>
> /* ------------------------------------------------------------------ */
> @@ -1571,7 +1586,7 @@ void
> spice_usb_device_manager_disconnect_device(SpiceUsbDeviceManager *self,
> cbinfo->user_data = NULL;
>
> spice_win_usb_driver_uninstall_async(installer, device, NULL,
> -
> spice_usb_device_manager_drv_install_cb,
> +
> spice_usb_device_manager_drv_uninstall_cb,
> cbinfo);
> #endif
>
> --
> 1.8.5.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
More information about the Spice-devel
mailing list