From 5961dde12fbc16fdf046a81acf274a06f6f5894e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 8 Apr 2014 13:21:43 -0700 Subject: [PATCH] GUAC-608: Migrate to streamed inbound clipboard data. --- .../src/main/webapp/scripts/client-ui.js | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/guacamole/src/main/webapp/scripts/client-ui.js b/guacamole/src/main/webapp/scripts/client-ui.js index 8f41a567b..b62c53cf7 100644 --- a/guacamole/src/main/webapp/scripts/client-ui.js +++ b/guacamole/src/main/webapp/scripts/client-ui.js @@ -1112,8 +1112,28 @@ GuacUI.Client.attach = function(guac) { }; // Server copy handler - guac.onclipboard = function(data) { - GuacUI.sessionState.setProperty("clipboard", data); + guac.onclipboard = function(stream, mimetype) { + + // Only text/plain is supported for now + if (mimetype !== "text/plain") { + stream.sendAck("Only text/plain supported", Guacamole.Status.Code.UNSUPPORTED); + return; + } + + var reader = new Guacamole.StringReader(stream); + var data = ""; + + // Append any received data to buffer + reader.ontext = function clipboard_text_received(text) { + data += text; + stream.sendAck("Received", Guacamole.Status.Code.SUCCESS); + }; + + // Set contents when done + reader.onend = function clipboard_text_end() { + GuacUI.sessionState.setProperty("clipboard", data); + }; + }; /*