mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Implement file:// URI resource support in client.
This commit is contained in:
@@ -32,6 +32,9 @@
|
||||
|
||||
<body>
|
||||
|
||||
<!-- Download-facilitating iframe -->
|
||||
<iframe id="download"/>
|
||||
|
||||
<!-- Menu -->
|
||||
<div id="menu">
|
||||
|
||||
|
@@ -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);
|
||||
};
|
||||
|
@@ -298,3 +298,6 @@ div#touchClipboardDiv textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
iframe#download {
|
||||
display: none;
|
||||
}
|
||||
|
Reference in New Issue
Block a user