[Spice-devel] [PATCH spice-gtk 2/6] usbredir: Treat the user cancelling the policykit dialog as a cancel

Marc-André Lureau marcandre.lureau at gmail.com
Wed Feb 22 04:51:53 PST 2012


ack

On Tue, Feb 21, 2012 at 3:12 PM, Hans de Goede <hdegoede at redhat.com> wrote:
> Rather then treating it as any other error. This avoids showing an error
> dialog after the user pressed cancel in the policykit dialog.
>
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  gtk/spice-client-glib-usb-acl-helper.c |    5 +++++
>  gtk/usb-acl-helper.c                   |   13 ++++++++++---
>  2 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/gtk/spice-client-glib-usb-acl-helper.c b/gtk/spice-client-glib-usb-acl-helper.c
> index bd01979..aaa1180 100644
> --- a/gtk/spice-client-glib-usb-acl-helper.c
> +++ b/gtk/spice-client-glib-usb-acl-helper.c
> @@ -177,6 +177,11 @@ static void check_authorization_cb(PolkitAuthority *authority,
>         return;
>     }
>
> +    if (polkit_authorization_result_get_dismissed(result)) {
> +        ERROR("CANCELED\n");
> +        return;
> +    }
> +
>     if (!polkit_authorization_result_get_is_authorized(result)) {
>         ERROR("Not authorized\n");
>         return;
> diff --git a/gtk/usb-acl-helper.c b/gtk/usb-acl-helper.c
> index b79e122..6a459c5 100644
> --- a/gtk/usb-acl-helper.c
> +++ b/gtk/usb-acl-helper.c
> @@ -87,6 +87,13 @@ static void spice_usb_acl_helper_class_init(SpiceUsbAclHelperClass *klass)
>  /* ------------------------------------------------------------------ */
>  /* callbacks                                                          */
>
> +static void async_result_set_cancelled(GSimpleAsyncResult *result)
> +{
> +    g_simple_async_result_set_error(result,
> +                G_IO_ERROR, G_IO_ERROR_CANCELLED,
> +                "Setting USB device node ACL cancelled");
> +}
> +
>  static gboolean cb_out_watch(GIOChannel    *channel,
>                              GIOCondition   cond,
>                              gpointer      *user_data)
> @@ -111,6 +118,8 @@ static gboolean cb_out_watch(GIOChannel    *channel,
>             string[strlen(string) - 1] = 0;
>             if (!strcmp(string, "SUCCESS")) {
>                 success = TRUE;
> +            } else if (!strcmp(string, "CANCELED")) {
> +                async_result_set_cancelled(priv->result);
>             } else {
>                 g_simple_async_result_set_error(priv->result,
>                             SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> @@ -278,9 +287,7 @@ void spice_usb_acl_helper_close_acl(SpiceUsbAclHelper *self)
>
>     /* If the acl open has not completed yet report it as cancelled */
>     if (priv->result) {
> -        g_simple_async_result_set_error(priv->result,
> -                    G_IO_ERROR, G_IO_ERROR_CANCELLED,
> -                    "Setting USB device node ACL cancelled");
> +        async_result_set_cancelled(priv->result);
>         g_simple_async_result_complete_in_idle(priv->result);
>     }
>
> --
> 1.7.7.6
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel



-- 
Marc-André Lureau


More information about the Spice-devel mailing list