summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2013-11-06 21:56:37 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2013-11-19 17:48:58 +0100
commit296c8e31101b6e7a4515a7cf6a17b05ad25f7c6c (patch)
treec626d39d7921bcfcfff8e471144f670bd0d39d16
parentcf470e608e7f612d489563d52caff13aa3c68ee4 (diff)
main: send max-clipboard to agent
Send configured max-clipboard size to the agent, after receiving agent capabilities. See also spice-protocol patch description: http://lists.freedesktop.org/archives/spice-devel/2013-November/015254.html
-rw-r--r--gtk/channel-main.c41
m---------spice-common0
2 files changed, 38 insertions, 3 deletions
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 08138d6..ef2a5e5 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -170,6 +170,7 @@ static void spice_main_channel_send_migration_handshake(SpiceChannel *channel);
static void file_xfer_continue_read(SpiceFileXferTask *task);
static void file_xfer_completed(SpiceFileXferTask *task, GError *error);
static void file_xfer_flushed(SpiceMainChannel *channel, gboolean success);
+static void spice_main_set_max_clipboard(SpiceMainChannel *self, gint max);
/* ------------------------------------------------------------------ */
@@ -196,6 +197,7 @@ static const char *agent_caps[] = {
[ VD_AGENT_CAP_SPARSE_MONITORS_CONFIG ] = "sparse monitors",
[ VD_AGENT_CAP_GUEST_LINEEND_LF ] = "line-end lf",
[ VD_AGENT_CAP_GUEST_LINEEND_CRLF ] = "line-end crlf",
+ [ VD_AGENT_CAP_MAX_CLIPBOARD ] = "max-clipboard",
};
#define NAME(_a, _i) ((_i) < SPICE_N_ELEMENTS(_a) ? (_a[(_i)] ?: "?") : "?")
@@ -288,7 +290,8 @@ static void spice_main_get_property(GObject *object,
static void spice_main_set_property(GObject *gobject, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
- SpiceMainChannelPrivate *c = SPICE_MAIN_CHANNEL(gobject)->priv;
+ SpiceMainChannel *self = SPICE_MAIN_CHANNEL(gobject);
+ SpiceMainChannelPrivate *c = self->priv;
switch (prop_id) {
case PROP_DISPLAY_DISABLE_WALLPAPER:
@@ -313,7 +316,7 @@ static void spice_main_set_property(GObject *gobject, guint prop_id,
c->disable_display_align = g_value_get_boolean(value);
break;
case PROP_MAX_CLIPBOARD:
- c->max_clipboard = g_value_get_int(value);
+ spice_main_set_max_clipboard(self, g_value_get_int(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
@@ -1816,6 +1819,34 @@ static void file_xfer_handle_status(SpiceMainChannel *channel,
file_xfer_completed(task, error);
}
+/* any context: the message is not flushed immediately,
+ you can wakeup() the channel coroutine or send_msg_queue() */
+static void agent_max_clipboard(SpiceMainChannel *self)
+{
+ VDAgentMaxClipboard msg = { .max = spice_main_get_max_clipboard(self) };
+
+ if (!test_agent_cap(self, VD_AGENT_CAP_MAX_CLIPBOARD))
+ return;
+
+ agent_msg_queue(self, VD_AGENT_MAX_CLIPBOARD, sizeof(VDAgentMaxClipboard), &msg);
+}
+
+static void spice_main_set_max_clipboard(SpiceMainChannel *self, gint max)
+{
+ SpiceMainChannelPrivate *c;
+
+ g_return_if_fail(SPICE_IS_MAIN_CHANNEL(self));
+ g_return_if_fail(max >= -1);
+
+ c = self->priv;
+ if (max == spice_main_get_max_clipboard(self))
+ return;
+
+ c->max_clipboard = max;
+ agent_max_clipboard(self);
+ spice_channel_wakeup(SPICE_CHANNEL(self), FALSE);
+}
+
/* coroutine context */
static void main_agent_handle_msg(SpiceChannel *channel,
VDAgentMessage *msg, gpointer payload)
@@ -1867,9 +1898,13 @@ static void main_agent_handle_msg(SpiceChannel *channel,
if (test_agent_cap(self, VD_AGENT_CAP_DISPLAY_CONFIG) &&
!c->agent_display_config_sent) {
agent_display_config(self);
- agent_send_msg_queue(self);
c->agent_display_config_sent = true;
}
+
+ agent_max_clipboard(self);
+
+ agent_send_msg_queue(self);
+
break;
}
case VD_AGENT_CLIPBOARD:
diff --git a/spice-common b/spice-common
-Subproject 1450bb4ddbd8ceab9192e4f84606aa5ae54c5ea
+Subproject 261d270cc8e9af0915d5248df240828214ec996