Implement file:// URI resource support in client.

This commit is contained in:
Michael Jumper
2012-09-11 18:31:52 -07:00
parent 03ac523688
commit 15758cc662
3 changed files with 60 additions and 0 deletions

View File

@@ -32,6 +32,9 @@
<body>
<!-- Download-facilitating iframe -->
<iframe id="download"/>
<!-- Menu -->
<div id="menu">

View File

@@ -33,6 +33,7 @@ var GuacamoleUI = {
"touchMenu" : document.getElementById("touchMenu"),
"logo" : document.getElementById("status-logo"),
"eventTarget" : document.getElementById("eventTarget"),
"download" : document.getElementById("download"),
"buttons": {
@@ -757,6 +758,59 @@ GuacamoleUI.attach = function(guac) {
GuacamoleUI.touchClipboard.value = data;
};
// Resource handler
guac.onresource = function(index, uri, mimetypes) {
// Get tunnel UUID
var uuid = guac.getTunnel().getUUID();
// If UUID not defined, there is currently no way to get resource
// content. Reject the resource.
if (!uuid) {
guac.rejectResource(index);
return;
}
// File resource
if (uri.substring(0, 7) == "file://") {
// Get name from URI
var name = uri.substring(7);
// Prompt user for download
var download = window.confirm(
"The remote desktop you are connected to is offering to send "
+ "a file (" + name + "). Would you like to accept and "
+ "download it?"
);
// Accept file
if (download) {
// Accept file resource
guac.acceptResource(index, mimetypes[0]);
// Start download
GuacamoleUI.download.src =
"resource?index=" + index
+ "&name=" + name
+ "&uuid=" + uuid;
}
// User rejected resource
else
guac.rejectResource(index);
}
// Otherwise, reject (unknown URI)
else
guac.rejectResource(index);
};
GuacamoleUI.keyboard.onkeydown = function(keysym) {
guac.sendKeyEvent(1, keysym);
};

View File

@@ -298,3 +298,6 @@ div#touchClipboardDiv textarea {
width: 100%;
}
iframe#download {
display: none;
}