diff --git a/guacamole-common-js/src/main/resources/guacamole.js b/guacamole-common-js/src/main/resources/guacamole.js index ab0e8583c..cded51ba6 100644 --- a/guacamole-common-js/src/main/resources/guacamole.js +++ b/guacamole-common-js/src/main/resources/guacamole.js @@ -533,6 +533,53 @@ Guacamole.Client = function(tunnel) { tunnel.sendMessage("clipboard", data); }; + /** + * Opens a new file for writing, having the given index, mimetype and + * filename. + * + * @param {Number} index The index of the file to write to. This index must + * be unused. + * @param {String} mimetype The mimetype of the file being sent. + * @param {String} filename The filename of the file being sent. + */ + this.openFile = function(index, mimetype, filename) { + + // Do not send requests if not connected + if (!isConnected()) + return; + + tunnel.sendMessage("file", index, mimetype, filename); + }; + + /** + * Given the index of a file, writes a blob of data to that file. + * + * @param {Number} index The index of the file to write to. + * @param {String} data Base64-encoded data to write to the file. + */ + this.sendBlob = function(index, data) { + + // Do not send requests if not connected + if (!isConnected()) + return; + + tunnel.sendMessage("blob", index, data); + }; + + /** + * Marks a currently-open file as closed. + * + * @param {Number} index The index of the file to close. + */ + this.closeFile = function(index) { + + // Do not send requests if not connected + if (!isConnected()) + return; + + tunnel.sendMessage("end", index); + }; + /** * Fired whenever the state of this Guacamole.Client changes. * diff --git a/guacamole/src/main/webapp/scripts/client-ui.js b/guacamole/src/main/webapp/scripts/client-ui.js index ede0e33fd..1456910da 100644 --- a/guacamole/src/main/webapp/scripts/client-ui.js +++ b/guacamole/src/main/webapp/scripts/client-ui.js @@ -1042,5 +1042,79 @@ GuacUI.Client.attach = function(guac) { // Stop detection if press stops GuacUI.Client.display.addEventListener('touchend', GuacUI.Client.stopLongPressDetect, true); + function _ignore(e) { + e.preventDefault(); + e.stopPropagation(); + } + + function _get_base64(buffer) { + + var data = ""; + var bytes = new Uint8Array(buffer); + + // Produce binary string from bytes in buffer + for (var i=0; i