mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Share state using session control object, add missing licenses, fix wrong license.
This commit is contained in:
@@ -1,6 +1,24 @@
|
||||
|
||||
package net.sourceforge.guacamole.net.basic;
|
||||
|
||||
/*
|
||||
* Guacamole - Clientless Remote Desktop
|
||||
* Copyright (C) 2010 Michael Jumper
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
@@ -20,7 +20,6 @@ package net.sourceforge.guacamole.net.basic;
|
||||
*/
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import net.sourceforge.guacamole.net.auth.AuthenticationProvider;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
@@ -31,6 +30,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.sourceforge.guacamole.GuacamoleException;
|
||||
import net.sourceforge.guacamole.net.auth.AuthenticationProvider;
|
||||
import net.sourceforge.guacamole.net.auth.Credentials;
|
||||
import net.sourceforge.guacamole.properties.FileGuacamoleProperty;
|
||||
import net.sourceforge.guacamole.properties.GuacamoleProperties;
|
||||
|
@@ -22,10 +22,8 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
|
||||
|
||||
/**
|
||||
|
@@ -1,41 +1,23 @@
|
||||
|
||||
package net.sourceforge.guacamole.net.basic;
|
||||
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
/*
|
||||
* Guacamole - Clientless Remote Desktop
|
||||
* Copyright (C) 2010 Michael Jumper
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* The Original Code is guacamole-common.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Michael Jumper.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
@@ -1,5 +1,23 @@
|
||||
package net.sourceforge.guacamole.net.basic.event;
|
||||
|
||||
/*
|
||||
* Guacamole - Clientless Remote Desktop
|
||||
* Copyright (C) 2010 Michael Jumper
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.ArrayList;
|
||||
|
@@ -68,6 +68,7 @@
|
||||
<script type="text/javascript" src="guacamole-common-js/oskeyboard.js"></script>
|
||||
|
||||
<!-- guacamole-default-webapp scripts -->
|
||||
<script type="text/javascript" src="scripts/session.js"></script>
|
||||
<script type="text/javascript" src="scripts/interface.js"></script>
|
||||
|
||||
<!-- Init -->
|
||||
|
@@ -96,32 +96,22 @@
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="scripts/connections.js"></script>
|
||||
<script type="text/javascript" src="scripts/session.js"></script>
|
||||
|
||||
<!-- Init -->
|
||||
<script type="text/javascript"> /* <![CDATA[ */
|
||||
|
||||
var clients = [];
|
||||
var state = new GuacamoleSessionState();
|
||||
var clipboard = document.getElementById("clipboard");
|
||||
|
||||
clipboard.onchange = function() {
|
||||
propagateClipboard(clipboard.value);
|
||||
state.setProperty("clipboard", clipboard.value);
|
||||
};
|
||||
|
||||
function setClipboard(text) {
|
||||
clipboard.value = text;
|
||||
propagateClipboard(text);
|
||||
}
|
||||
|
||||
// Propogate clipboard data across all open clients
|
||||
function propagateClipboard(text) {
|
||||
for (var i=0; i<clients.length; i++) {
|
||||
|
||||
var guac = clients[i].GuacamoleUI.client;
|
||||
if (guac)
|
||||
guac.setClipboard(text);
|
||||
|
||||
}
|
||||
}
|
||||
state.onchange = function(old_state, new_state, name) {
|
||||
if (name == "clipboard")
|
||||
clipboard.value = new_state[name];
|
||||
};
|
||||
|
||||
// Constructs the URL for a client which connects to the connection
|
||||
// with the given id.
|
||||
@@ -198,7 +188,7 @@
|
||||
|
||||
function new_client(url) {
|
||||
return function() {
|
||||
clients.push(window.open(url));
|
||||
window.open(url);
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,21 @@
|
||||
|
||||
/*
|
||||
* Guacamole - Clientless Remote Desktop
|
||||
* Copyright (C) 2010 Michael Jumper
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function Config(protocol, id) {
|
||||
this.protocol = protocol;
|
||||
|
@@ -1,4 +1,22 @@
|
||||
|
||||
/*
|
||||
* Guacamole - Clientless Remote Desktop
|
||||
* Copyright (C) 2010 Michael Jumper
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// UI Definition
|
||||
var GuacamoleUI = {
|
||||
|
||||
@@ -530,9 +548,16 @@ GuacamoleUI.attach = function(guac) {
|
||||
|
||||
};
|
||||
|
||||
var state = new GuacamoleSessionState();
|
||||
|
||||
// Server copy handler
|
||||
guac.onclipboard = function(data) {
|
||||
window.opener.setClipboard(data);
|
||||
state.setProperty("clipboard", data);
|
||||
};
|
||||
|
||||
state.onchange = function(old_state, new_state, name) {
|
||||
if (name == "clipboard")
|
||||
guac.setClipboard(new_state[name]);
|
||||
};
|
||||
|
||||
};
|
||||
|
93
guacamole/src/main/webapp/scripts/session.js
Normal file
93
guacamole/src/main/webapp/scripts/session.js
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
/*
|
||||
* Guacamole - Clientless Remote Desktop
|
||||
* Copyright (C) 2010 Michael Jumper
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Maintains state across multiple Guacamole pages via HTML5 Web Storage.
|
||||
*/
|
||||
function GuacamoleSessionState() {
|
||||
|
||||
/**
|
||||
* Reference to this GuacamoleSessionState.
|
||||
* @private
|
||||
*/
|
||||
var guac_state = this;
|
||||
|
||||
/**
|
||||
* The last read state object.
|
||||
* @private
|
||||
*/
|
||||
var state = localStorage.getItem("GUACAMOLE_STATE") || {};
|
||||
|
||||
/**
|
||||
* Reloads the internal state, sending onchange events for all changed,
|
||||
* deleted, or new properties.
|
||||
*/
|
||||
this.reload = function() {
|
||||
|
||||
// Pull current state
|
||||
var new_state = JSON.parse(localStorage.getItem("GUACAMOLE_STATE") || "{}");
|
||||
|
||||
// Check if value is different
|
||||
for (var name in new_state) {
|
||||
|
||||
// If value changed, call handler
|
||||
var old = state[name];
|
||||
if (old != new_state[name]) {
|
||||
|
||||
// Call change handler
|
||||
if (guac_state.onchange)
|
||||
guac_state.onchange(state, new_state, name);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Assign new state
|
||||
state = new_state;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the given property to the given value.
|
||||
*
|
||||
* @param {String} name The name of the property to change.
|
||||
* @param value An arbitrary value.
|
||||
*/
|
||||
this.setProperty = function(name, value) {
|
||||
state[name] = value;
|
||||
localStorage.setItem("GUACAMOLE_STATE", JSON.stringify(state));
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the value stored under the property having the given name.
|
||||
*
|
||||
* @param {String} name The name of the property to read.
|
||||
* @return The value of the given property.
|
||||
*/
|
||||
this.getProperty = function(name) {
|
||||
return state[name];
|
||||
};
|
||||
|
||||
// Reload properties every 5 seconds
|
||||
window.setInterval(guac_state.reload, 1000);
|
||||
|
||||
// Initial load
|
||||
guac_state.reload();
|
||||
|
||||
}
|
Reference in New Issue
Block a user