[Spice-devel] [PATCH spice-gtk 1/4] Learn to disable specific capability by their name
Marc-André Lureau
marcandre.lureau at gmail.com
Fri Jun 8 03:13:26 PDT 2012
Allows to run spice-gtk with SPICE_FOO_CAP_BAR=0 disable channel FOO
capability BAR.
---
gtk/spice-channel-priv.h | 8 ++++++--
gtk/spice-channel.c | 12 +++++++-----
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index ac8bece..4f094d8 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -174,11 +174,15 @@ void spice_channel_handle_migrate(SpiceChannel *channel, SpiceMsgIn *in);
gint spice_channel_get_channel_id(SpiceChannel *channel);
gint spice_channel_get_channel_type(SpiceChannel *channel);
void spice_channel_swap(SpiceChannel *channel, SpiceChannel *swap);
-void spice_channel_set_common_capability(SpiceChannel *channel, guint32 cap);
gboolean spice_channel_get_read_only(SpiceChannel *channel);
-
void spice_channel_reset(SpiceChannel *channel, gboolean migrating);
+void spice_caps_set(GArray *caps, guint32 cap, const gchar *desc);
+#define spice_channel_set_common_capability(channel, cap) \
+ spice_caps_set(SPICE_CHANNEL(channel)->priv->common_caps, cap, #cap)
+#define spice_channel_set_capability(channel, cap) \
+ spice_caps_set(SPICE_CHANNEL(channel)->priv->caps, cap, #cap)
+
/* coroutine context */
#define emit_main_context(object, event, args...) \
G_STMT_START { \
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 3cd047d..75b171b 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2538,6 +2538,7 @@ static void set_capability(GArray *caps, guint32 cap)
*
* Enable specific channel-kind capability.
**/
+#undef spice_channel_set_capability
/* FIXME: we may want to make caps read only from outside */
void spice_channel_set_capability(SpiceChannel *channel, guint32 cap)
{
@@ -2550,14 +2551,15 @@ void spice_channel_set_capability(SpiceChannel *channel, guint32 cap)
}
G_GNUC_INTERNAL
-void spice_channel_set_common_capability(SpiceChannel *channel, guint32 cap)
+void spice_caps_set(GArray *caps, guint32 cap, const gchar *desc)
{
- SpiceChannelPrivate *c;
+ g_return_if_fail(caps != NULL);
+ g_return_if_fail(desc != NULL);
- g_return_if_fail(SPICE_IS_CHANNEL(channel));
+ if (g_strcmp0(g_getenv(desc), "0") == 0)
+ return;
- c = channel->priv;
- set_capability(c->common_caps, cap);
+ set_capability(caps, cap);
}
G_GNUC_INTERNAL
--
1.7.10.2
More information about the Spice-devel
mailing list