Re: [PATCH spice-gtk v3 2/3] Cmdline: Get the preferred-compression property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You could change the "cmdline" in the subject.

On Mon, Jun 01, 2015 at 04:48:47PM +0200, Javier Celaya wrote:
> ---
>  gtk/spice-option.c | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> diff --git a/gtk/spice-option.c b/gtk/spice-option.c
> index 958e03c..463a3e3 100644
> --- a/gtk/spice-option.c
> +++ b/gtk/spice-option.c
> @@ -41,6 +41,7 @@ static gint cache_size = 0;
>  static gint glz_window_size = 0;
>  static gchar *secure_channels = NULL;
>  static gchar *shared_dir = NULL;
> +static SpiceImageCompress preferred_compression = SPICE_IMAGE_COMPRESS_INVALID;
>  
>  G_GNUC_NORETURN
>  static void option_version(void)
> @@ -149,6 +150,33 @@ static gboolean parse_usbredir_filter(const gchar *option_name,
>      return TRUE;
>  }
>  
> +static gboolean parse_preferred_compression(const gchar *option_name, const gchar *value,
> +                                            gpointer data, GError **error)
> +{
> +    if (!strcmp(value, "auto-glz")) {
> +        preferred_compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
> +    } else if (!strcmp(value, "auto-lz")) {
> +        preferred_compression = SPICE_IMAGE_COMPRESS_AUTO_LZ;
> +    } else if (!strcmp(value, "quic")) {
> +        preferred_compression = SPICE_IMAGE_COMPRESS_QUIC;
> +    } else if (!strcmp(value, "glz")) {
> +        preferred_compression = SPICE_IMAGE_COMPRESS_GLZ;
> +    } else if (!strcmp(value, "lz")) {
> +        preferred_compression = SPICE_IMAGE_COMPRESS_LZ;
> +#ifdef USE_LZ4
> +    } else if (!strcmp(value, "lz4")) {
> +        preferred_compression = SPICE_IMAGE_COMPRESS_LZ4;
> +#endif
> +    } else if (!strcmp(value, "off")) {
> +        preferred_compression = SPICE_IMAGE_COMPRESS_OFF;
> +    } else {
> +        preferred_compression = SPICE_IMAGE_COMPRESS_INVALID;
> +        g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
> +                    _("Image compression algorithm %s not supported"), value);
> +        return FALSE;
> +    }
> +    return TRUE;
> +}

For what it's worth, once your enum is registered as a GEnum, you can do
something like gvir_config_genum_get_value
https://libvirt.org/git/?p=libvirt-glib.git;a=blob;f=libvirt-gconfig/libvirt-gconfig-helpers.c;h=0314a72fd5dfcf8e47df34e7243610071f91b0ee;hb=HEAD#l264
in order to go from string representation to integer. As this is only
needed once here, maybe not worth it.

Christophe

Attachment: pgpjrPCCYKyHn.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]