[Spice-devel] [spice-server 3/3] dcc: Add debug log when setting compression
Christophe Fergeau
cfergeau at redhat.com
Thu Oct 4 16:01:44 UTC 2018
Without this it's not obvious that a compression setting took effect.
---
server/dcc.c | 3 +++
server/utils.c | 42 ++++++++++++++++++++++++++++++++++++++++++
server/utils.h | 3 +++
3 files changed, 48 insertions(+)
diff --git a/server/dcc.c b/server/dcc.c
index 826dd28fe..e27d3dcad 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -1093,6 +1093,9 @@ static bool dcc_handle_preferred_compression(DisplayChannelClient *dcc,
default:
spice_warning("preferred-compression: unsupported image compression setting");
}
+ g_debug("Setting preferred compression to %s",
+ spice_util_genum_get_nick(SPICE_TYPE_SPICE_IMAGE_COMPRESSION_T,
+ dcc->priv->image_compression));
return TRUE;
}
diff --git a/server/utils.c b/server/utils.c
index b8a40b1d9..4b53aa290 100644
--- a/server/utils.c
+++ b/server/utils.c
@@ -114,3 +114,45 @@ int red_channel_name_to_type(const char *name)
}
return -1;
}
+
+/* These 2 functions come from
+ * libvirt-glib/libvirt-gconfig/libvirt-gconfig-helpers.c
+ * Copyright (C) 2010, 2011 Red Hat, Inc.
+ * LGPLv2.1+ licensed */
+G_GNUC_INTERNAL const char *
+spice_util_genum_get_nick(GType enum_type, gint value)
+{
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
+
+ enum_class = g_type_class_ref(enum_type);
+ enum_value = g_enum_get_value(enum_class, value);
+ g_type_class_unref(enum_class);
+
+ if (enum_value != NULL)
+ return enum_value->value_nick;
+
+ g_return_val_if_reached(NULL);
+}
+
+G_GNUC_INTERNAL int
+spice_util_genum_get_value(GType enum_type, const char *nick,
+ gint default_value)
+{
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ g_return_val_if_fail(G_TYPE_IS_ENUM(enum_type), default_value);
+ g_return_val_if_fail(nick != NULL, default_value);
+
+ enum_class = g_type_class_ref(enum_type);
+ enum_value = g_enum_get_value_by_nick(enum_class, nick);
+ g_type_class_unref(enum_class);
+
+ if (enum_value != NULL)
+ return enum_value->value;
+
+ g_return_val_if_reached(default_value);
+}
diff --git a/server/utils.h b/server/utils.h
index 5cb0eb0ee..52b7f5b3e 100644
--- a/server/utils.h
+++ b/server/utils.h
@@ -21,6 +21,7 @@
#include <stdint.h>
#include <glib.h>
+#include <glib-object.h>
#define SPICE_GNUC_VISIBLE __attribute__ ((visibility ("default")))
@@ -55,5 +56,7 @@ int rgb32_data_has_alpha(int width, int height, size_t stride,
const char *red_channel_type_to_str(int type);
int red_channel_name_to_type(const char *name);
+int spice_util_genum_get_value(GType enum_type, const char *nick, gint default_value);
+const char *spice_util_genum_get_nick(GType enum_type, gint value);
#endif /* UTILS_H_ */
--
2.19.0
More information about the Spice-devel
mailing list