[Spice-devel] [RFC spice-vdagent 6/8] clipboard: add vdagent_clipboards_set_protocol()

Jakub Janků janku.jakub.jj at gmail.com
Thu May 31 20:52:23 UTC 2018


---
 src/vdagent/clipboard.c | 11 +++++++++++
 src/vdagent/clipboard.h |  2 ++
 src/vdagent/vdagent.c   |  3 +++
 3 files changed, 16 insertions(+)

diff --git a/src/vdagent/clipboard.c b/src/vdagent/clipboard.c
index 101e535..63f8527 100644
--- a/src/vdagent/clipboard.c
+++ b/src/vdagent/clipboard.c
@@ -24,6 +24,7 @@
 #include <syslog.h>
 
 #include "vdagentd-proto.h"
+#include "vdagentd-proto-strings.h"
 #include "spice/vd_agent.h"
 
 #include "clipboard.h"
@@ -60,6 +61,7 @@ typedef struct {
 struct VDAgentClipboards {
     struct udscs_connection *conn;
     Selection                selections[SELECTION_COUNT];
+    guint                    protocol;
 };
 
 static const struct {
@@ -401,6 +403,14 @@ err:
                 VD_AGENT_CLIPBOARD_NONE, NULL, 0);
 }
 
+void vdagent_clipboards_set_protocol(VDAgentClipboards *c, guint protocol)
+{
+    g_return_if_fail(protocol <= CLIPBOARD_PROTOCOL_SELECTION);
+    c->protocol = protocol;
+    syslog(LOG_DEBUG, "Clipboard protocol set to %s",
+                      vdagentd_clipboard_protocols[protocol]);
+}
+
 VDAgentClipboards *vdagent_clipboards_init(struct udscs_connection *conn)
 {
     guint sel_id;
@@ -412,6 +422,7 @@ VDAgentClipboards *vdagent_clipboards_init(struct udscs_connection *conn)
     VDAgentClipboards *c;
     c = g_new0(VDAgentClipboards, 1);
     c->conn = conn;
+    c->protocol = CLIPBOARD_PROTOCOL_COMPATIBILITY;
 
     for (sel_id = 0; sel_id < SELECTION_COUNT; sel_id++) {
         GtkClipboard *clipboard = gtk_clipboard_get(sel_atom[sel_id]);
diff --git a/src/vdagent/clipboard.h b/src/vdagent/clipboard.h
index e007a37..d9cc22c 100644
--- a/src/vdagent/clipboard.h
+++ b/src/vdagent/clipboard.h
@@ -28,6 +28,8 @@ typedef struct VDAgentClipboards VDAgentClipboards;
 VDAgentClipboards *vdagent_clipboards_init(struct udscs_connection *conn);
 void vdagent_clipboards_finalize(VDAgentClipboards *c, gboolean conn_alive);
 
+void vdagent_clipboards_set_protocol(VDAgentClipboards *c, guint protocol);
+
 void vdagent_clipboard_request(VDAgentClipboards *c, guint sel_id, guint type);
 
 void vdagent_clipboard_release(VDAgentClipboards *c, guint sel_id);
diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
index 711e4f8..85aa6ae 100644
--- a/src/vdagent/vdagent.c
+++ b/src/vdagent/vdagent.c
@@ -192,6 +192,9 @@ static void daemon_read_complete(struct udscs_connection **connp,
     case VDAGENTD_CLIPBOARD_RELEASE:
         vdagent_clipboard_release(agent->clipboards, header->arg1);
         break;
+    case VDAGENTD_CLIPBOARD_PROTOCOL:
+        vdagent_clipboards_set_protocol(agent->clipboards, header->arg1);
+        break;
     case VDAGENTD_VERSION:
         if (strcmp((char *)data, VERSION) != 0) {
             syslog(LOG_INFO, "vdagentd version mismatch: got %s expected %s",
-- 
2.17.0



More information about the Spice-devel mailing list