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

Christophe Fergeau cfergeau at redhat.com
Tue Jun 2 05:25:23 PDT 2015


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150602/7277eb60/attachment-0001.sig>


More information about the Spice-devel mailing list