mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Removed old VNC client after all. Can't maintain - will need to make next release clear.
This commit is contained in:
@@ -20,8 +20,6 @@ package net.sourceforge.guacamole;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
import net.sourceforge.guacamole.event.KeyEvent;
|
|
||||||
import net.sourceforge.guacamole.event.PointerEvent;
|
|
||||||
|
|
||||||
public abstract class Client {
|
public abstract class Client {
|
||||||
|
|
||||||
|
@@ -32,10 +32,6 @@ import java.io.Writer;
|
|||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
|
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
import net.sourceforge.guacamole.event.EventQueue;
|
|
||||||
import net.sourceforge.guacamole.event.EventHandler;
|
|
||||||
import net.sourceforge.guacamole.event.KeyEvent;
|
|
||||||
import net.sourceforge.guacamole.event.PointerEvent;
|
|
||||||
|
|
||||||
public class GuacamoleClient extends Client {
|
public class GuacamoleClient extends Client {
|
||||||
|
|
||||||
|
@@ -1,35 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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 net.sourceforge.guacamole.instruction.Instruction;
|
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
|
||||||
import net.sourceforge.guacamole.event.KeyEvent;
|
|
||||||
import net.sourceforge.guacamole.event.PointerEvent;
|
|
||||||
|
|
||||||
public abstract class LegacyClient {
|
|
||||||
|
|
||||||
public abstract void send(KeyEvent event) throws GuacamoleException;
|
|
||||||
public abstract void send(PointerEvent event) throws GuacamoleException;
|
|
||||||
public abstract void setClipboard(String clipboard) throws GuacamoleException;
|
|
||||||
public abstract void disconnect() throws GuacamoleException;
|
|
||||||
public abstract Instruction nextInstruction(boolean blocking) throws GuacamoleException;
|
|
||||||
|
|
||||||
}
|
|
@@ -1,55 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public abstract class Event implements Comparable<Event> {
|
|
||||||
|
|
||||||
private long time;
|
|
||||||
private int index;
|
|
||||||
|
|
||||||
public Event(int index) {
|
|
||||||
this.time = System.currentTimeMillis();
|
|
||||||
this.index = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getIndex() {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTime() {
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode() {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (o == null) return false;
|
|
||||||
if (getClass() != o.getClass()) return false;
|
|
||||||
return getIndex() == ((Event) o).getIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compareTo(Event e) {
|
|
||||||
return getIndex() - e.getIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.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.io.IOException;
|
|
||||||
|
|
||||||
public interface EventHandler<E extends Event> {
|
|
||||||
|
|
||||||
public void handle(E e) throws IOException;
|
|
||||||
|
|
||||||
}
|
|
@@ -1,191 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.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.io.IOException;
|
|
||||||
import java.util.PriorityQueue;
|
|
||||||
|
|
||||||
public class EventQueue<E extends Event> {
|
|
||||||
|
|
||||||
private int nextIndex = 0;
|
|
||||||
private final PriorityQueue<E> queue = new PriorityQueue<E>();
|
|
||||||
private EventHandler<E> handler;
|
|
||||||
|
|
||||||
private final int deadline;
|
|
||||||
|
|
||||||
private AutoflushThread autoflush = new AutoflushThread();
|
|
||||||
|
|
||||||
private class AutoflushThread extends Thread {
|
|
||||||
|
|
||||||
private IOException error;
|
|
||||||
private long deadline;
|
|
||||||
private static final long ONE_YEAR = 31536000;
|
|
||||||
|
|
||||||
private boolean killed = false;
|
|
||||||
|
|
||||||
public AutoflushThread() {
|
|
||||||
this.deadline = ONE_YEAR;
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
while (!killed) {
|
|
||||||
try {
|
|
||||||
if (deadline > 0) sleep(deadline);
|
|
||||||
dropPendingEvents();
|
|
||||||
flush();
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
// Interrupt indicates event handled, or thread killed
|
|
||||||
if (killed) return;
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
error = e;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDeadline(long deadline) {
|
|
||||||
this.deadline = deadline;
|
|
||||||
interrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkError() throws IOException {
|
|
||||||
if (error != null) throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void kill() {
|
|
||||||
killed = true;
|
|
||||||
interrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
autoflush.kill();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Starts autoflush wait thread for any waiting events on the queue
|
|
||||||
private void startDeadlineAutoflush() {
|
|
||||||
synchronized (queue) {
|
|
||||||
|
|
||||||
// No need to autoflush if nothing waiting
|
|
||||||
if (queue.size() == 0) return;
|
|
||||||
|
|
||||||
// Get waiting event
|
|
||||||
E waiting = queue.peek();
|
|
||||||
|
|
||||||
if (waiting != null) {
|
|
||||||
long untilDeadline = deadline + waiting.getTime() - System.currentTimeMillis();
|
|
||||||
|
|
||||||
// Start autoflush thread which waits for time remaining until next
|
|
||||||
// event's deadline.
|
|
||||||
autoflush.setDeadline(untilDeadline);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
autoflush.setDeadline(AutoflushThread.ONE_YEAR);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventQueue(EventHandler<E> handler, int deadline) {
|
|
||||||
this.handler = handler;
|
|
||||||
this.deadline = deadline;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(E event) throws IOException {
|
|
||||||
synchronized (queue) {
|
|
||||||
|
|
||||||
autoflush.checkError();
|
|
||||||
|
|
||||||
if (event.getIndex() < nextIndex) {
|
|
||||||
//System.err.println("Past event dropped.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event == null)
|
|
||||||
throw new Error("Cannot add null event.");
|
|
||||||
|
|
||||||
queue.add(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
private E next() {
|
|
||||||
synchronized (queue) {
|
|
||||||
// If no events, return nothing.
|
|
||||||
if (queue.size() == 0) return null;
|
|
||||||
|
|
||||||
// If still waiting for true next event, return nothing.
|
|
||||||
E event = queue.peek();
|
|
||||||
if (event.getIndex() != nextIndex)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// If event found, expect next event, remove and return current.
|
|
||||||
queue.remove();
|
|
||||||
nextIndex++;
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return number of waiting events
|
|
||||||
public int getWaiting() {
|
|
||||||
synchronized (queue) {
|
|
||||||
// If no events, then none waiting.
|
|
||||||
if (queue.size() == 0) return 0;
|
|
||||||
|
|
||||||
// If we have the next event, then none waiting.
|
|
||||||
E event = queue.peek();
|
|
||||||
if (event.getIndex() == nextIndex)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// Otherwise, all events are waiting.
|
|
||||||
return queue.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop waiting for any unreceived events
|
|
||||||
private void dropPendingEvents() {
|
|
||||||
synchronized (queue) {
|
|
||||||
// If no events, nothing needs to be changed;
|
|
||||||
if (queue.size() == 0) return;
|
|
||||||
|
|
||||||
// Otherwise, update nextIndex to index of next event
|
|
||||||
E event = queue.peek();
|
|
||||||
nextIndex = event.getIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attempts to flush queue
|
|
||||||
// If any events remain, an autoflush thread is started.
|
|
||||||
private void flush() throws IOException {
|
|
||||||
synchronized (queue) {
|
|
||||||
E nextEvent;
|
|
||||||
while ((nextEvent = next()) != null)
|
|
||||||
handler.handle(nextEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start autoflush thread for any remaining events.
|
|
||||||
startDeadlineAutoflush();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
package net.sourceforge.guacamole.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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class KeyEvent extends Event {
|
|
||||||
|
|
||||||
private int keysym;
|
|
||||||
private boolean pressed;
|
|
||||||
|
|
||||||
public KeyEvent(int index, int keysym, boolean pressed) {
|
|
||||||
super(index);
|
|
||||||
this.keysym = keysym;
|
|
||||||
this.pressed = pressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getKeySym() {
|
|
||||||
return keysym;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getPressed() {
|
|
||||||
return pressed;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,69 +0,0 @@
|
|||||||
package net.sourceforge.guacamole.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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PointerEvent extends Event {
|
|
||||||
|
|
||||||
private boolean leftButtonPressed;
|
|
||||||
private boolean middleButtonPressed;
|
|
||||||
private boolean rightButtonPressed;
|
|
||||||
private boolean upButtonPressed;
|
|
||||||
private boolean downButtonPressed;
|
|
||||||
private int x;
|
|
||||||
private int y;
|
|
||||||
|
|
||||||
public PointerEvent(int index, boolean leftButtonPressed, boolean middleButtonPressed, boolean rightButtonPressed, boolean upButtonPressed, boolean downButtonPressed, int x, int y) {
|
|
||||||
super(index);
|
|
||||||
this.leftButtonPressed = leftButtonPressed;
|
|
||||||
this.middleButtonPressed = middleButtonPressed;
|
|
||||||
this.rightButtonPressed = rightButtonPressed;
|
|
||||||
this.upButtonPressed = upButtonPressed;
|
|
||||||
this.downButtonPressed = downButtonPressed;
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLeftButtonPressed() {
|
|
||||||
return leftButtonPressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMiddleButtonPressed() {
|
|
||||||
return middleButtonPressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRightButtonPressed() {
|
|
||||||
return rightButtonPressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUpButtonPressed() {
|
|
||||||
return upButtonPressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDownButtonPressed() {
|
|
||||||
return downButtonPressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.instruction;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ClipboardInstruction extends Instruction {
|
|
||||||
|
|
||||||
private String data;
|
|
||||||
|
|
||||||
public ClipboardInstruction(String data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "clipboard:" + escape(getData()) + ";";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.instruction;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ErrorInstruction extends Instruction {
|
|
||||||
|
|
||||||
private String error;
|
|
||||||
|
|
||||||
public ErrorInstruction(String error) {
|
|
||||||
this.error = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getError() {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "error:" + escape(getError()) + ";";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.instruction;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public abstract class Instruction {
|
|
||||||
|
|
||||||
|
|
||||||
// All Instructions must provide a toString() implementation
|
|
||||||
// which returns the properly formatted instruction:
|
|
||||||
// OPCODE:parm1,parm2,...,parmN;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract String toString();
|
|
||||||
|
|
||||||
public String escape(String str) {
|
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
|
|
||||||
for (int i=0; i<str.length(); i++) {
|
|
||||||
|
|
||||||
char c = str.charAt(i);
|
|
||||||
|
|
||||||
switch (c) {
|
|
||||||
case ',':
|
|
||||||
sb.append("\\c");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ';':
|
|
||||||
sb.append("\\s");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '\\':
|
|
||||||
sb.append("\\\\");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
sb.append(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.instruction;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class NameInstruction extends Instruction {
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public NameInstruction(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "name:" + escape(getName()) + ";";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,47 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.instruction;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class SizeInstruction extends Instruction {
|
|
||||||
|
|
||||||
private int width;
|
|
||||||
private int height;
|
|
||||||
|
|
||||||
public SizeInstruction(int width, int height) {
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "size:"
|
|
||||||
+ getWidth() + ","
|
|
||||||
+ getHeight() + ";";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,78 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.instruction.framebuffer;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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 net.sourceforge.guacamole.instruction.Instruction;
|
|
||||||
|
|
||||||
public class CopyRectInstruction extends Instruction {
|
|
||||||
|
|
||||||
private final int x;
|
|
||||||
private final int y;
|
|
||||||
private final int width;
|
|
||||||
private final int height;
|
|
||||||
|
|
||||||
private final int srcX;
|
|
||||||
private final int srcY;
|
|
||||||
|
|
||||||
public CopyRectInstruction(int x, int y, int width, int height, int srcX, int srcY) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
this.srcX = srcX;
|
|
||||||
this.srcY = srcY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSrcX() {
|
|
||||||
return srcX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSrcY() {
|
|
||||||
return srcY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "copy:"
|
|
||||||
+ getSrcX() + ","
|
|
||||||
+ getSrcY() + ","
|
|
||||||
+ getWidth() + ","
|
|
||||||
+ getHeight() + ","
|
|
||||||
+ getX() + ","
|
|
||||||
+ getY() + ";";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,66 +0,0 @@
|
|||||||
package net.sourceforge.guacamole.instruction.framebuffer;
|
|
||||||
|
|
||||||
import net.sourceforge.guacamole.net.Base64;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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 net.sourceforge.guacamole.instruction.Instruction;
|
|
||||||
|
|
||||||
public class CursorInstruction extends Instruction {
|
|
||||||
|
|
||||||
private int x;
|
|
||||||
private int y;
|
|
||||||
private PNGImage image;
|
|
||||||
|
|
||||||
public CursorInstruction(int x, int y, PNGImage image) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.image = image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PNGImage getImage() {
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return getImage().getWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return getImage().getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "cursor:"
|
|
||||||
+ getX() + ","
|
|
||||||
+ getY() + ","
|
|
||||||
+ Base64.toString(getImage().getData()) + ";";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@@ -1,72 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.instruction.framebuffer;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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 net.sourceforge.guacamole.instruction.Instruction;
|
|
||||||
|
|
||||||
public class DrawRectInstruction extends Instruction {
|
|
||||||
|
|
||||||
private final int x;
|
|
||||||
private final int y;
|
|
||||||
private final int width;
|
|
||||||
private final int height;
|
|
||||||
private final int color;
|
|
||||||
|
|
||||||
public DrawRectInstruction(int x, int y, int width, int height, int color) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getColor() {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
|
|
||||||
return "rect:"
|
|
||||||
+ getX() + ","
|
|
||||||
+ getY() + ","
|
|
||||||
+ getWidth() + ","
|
|
||||||
+ getHeight() + ","
|
|
||||||
+ String.format("#%06X", getColor()) + ";";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,95 +0,0 @@
|
|||||||
package net.sourceforge.guacamole.instruction.framebuffer;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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.awt.image.BufferedImage;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import javax.imageio.IIOImage;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.imageio.ImageWriter;
|
|
||||||
import javax.imageio.stream.ImageOutputStream;
|
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
|
||||||
|
|
||||||
public class PNGImage {
|
|
||||||
|
|
||||||
private int width;
|
|
||||||
private int height;
|
|
||||||
private byte[] data;
|
|
||||||
|
|
||||||
public PNGImage(BufferedImage image) throws GuacamoleException {
|
|
||||||
|
|
||||||
width = image.getWidth();
|
|
||||||
height = image.getHeight();
|
|
||||||
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
||||||
|
|
||||||
try {
|
|
||||||
writeImage(image, bos);
|
|
||||||
bos.flush();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
throw new GuacamoleException("I/O Error while creating PNG.", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
data = bos.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void writeImage(BufferedImage image, OutputStream outputStream) throws GuacamoleException, IOException {
|
|
||||||
|
|
||||||
// Obtain list of image writers
|
|
||||||
// If no such writers exist, fail with error, exit.
|
|
||||||
Iterator<ImageWriter> writers = ImageIO.getImageWritersByMIMEType("image/png");
|
|
||||||
if (!writers.hasNext())
|
|
||||||
throw new GuacamoleException("No useful image writers found.");
|
|
||||||
|
|
||||||
// Obtain JPEG writer
|
|
||||||
ImageWriter imageWriter = writers.next();
|
|
||||||
|
|
||||||
// Setup image parameters (including compression quality)
|
|
||||||
/*ImageWriteParam imageParameters = new JPEGImageWriteParam(Locale.ENGLISH);
|
|
||||||
imageParameters.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
|
|
||||||
imageParameters.setCompressionQuality(0.6f); // 60% quality, currently...
|
|
||||||
imageParameters.setProgressiveMode(ImageWriteParam.MODE_DEFAULT);*/
|
|
||||||
|
|
||||||
ImageOutputStream out = ImageIO.createImageOutputStream(outputStream);
|
|
||||||
|
|
||||||
// Write image
|
|
||||||
imageWriter.setOutput(out);
|
|
||||||
imageWriter.write(null, new IIOImage(image, null, null), null/*imageParameters*/);
|
|
||||||
imageWriter.dispose();
|
|
||||||
|
|
||||||
out.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,65 +0,0 @@
|
|||||||
package net.sourceforge.guacamole.instruction.framebuffer;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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 net.sourceforge.guacamole.instruction.Instruction;
|
|
||||||
import net.sourceforge.guacamole.net.Base64;
|
|
||||||
|
|
||||||
public class PNGInstruction extends Instruction {
|
|
||||||
|
|
||||||
private int x;
|
|
||||||
private int y;
|
|
||||||
private PNGImage image;
|
|
||||||
|
|
||||||
public PNGInstruction(int x, int y, PNGImage image) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.image = image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PNGImage getImage() {
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return getImage().getWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return getImage().getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "png:"
|
|
||||||
+ getX() + ","
|
|
||||||
+ getY() + ","
|
|
||||||
+ Base64.toString(getImage().getData()) + ";";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@@ -27,8 +27,6 @@ import javax.servlet.http.HttpSessionBindingListener;
|
|||||||
import net.sourceforge.guacamole.Client;
|
import net.sourceforge.guacamole.Client;
|
||||||
import net.sourceforge.guacamole.GuacamoleClient;
|
import net.sourceforge.guacamole.GuacamoleClient;
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
import net.sourceforge.guacamole.event.KeyEvent;
|
|
||||||
import net.sourceforge.guacamole.event.PointerEvent;
|
|
||||||
|
|
||||||
public class GuacamoleSession {
|
public class GuacamoleSession {
|
||||||
|
|
||||||
|
@@ -1,63 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.vnc;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
|
|
||||||
public class InputOutputStream extends InputStream {
|
|
||||||
|
|
||||||
private int pos = 0;
|
|
||||||
private byte[] current = null;
|
|
||||||
private LinkedList<byte[]> buffer = new LinkedList<byte[]>();
|
|
||||||
|
|
||||||
public void write(byte[] data) {
|
|
||||||
|
|
||||||
if (data.length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (current == null)
|
|
||||||
current = data;
|
|
||||||
else
|
|
||||||
buffer.addLast(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read() throws IOException {
|
|
||||||
|
|
||||||
if (pos >= current.length) {
|
|
||||||
if (buffer.size() == 0)
|
|
||||||
throw new IOException("Buffer underrun.");
|
|
||||||
|
|
||||||
current = buffer.removeFirst();
|
|
||||||
pos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0xFF & current[pos++];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read(byte[] data) throws IOException {
|
|
||||||
return read(data, 0, data.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read(byte[] data, int off, int len) throws IOException {
|
|
||||||
|
|
||||||
if (pos >= current.length) {
|
|
||||||
if (buffer.size() == 0)
|
|
||||||
throw new IOException("Buffer underrun.");
|
|
||||||
|
|
||||||
current = buffer.removeFirst();
|
|
||||||
pos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int amountRead = Math.min(current.length - pos, len);
|
|
||||||
System.arraycopy(current, pos, data, off, amountRead);
|
|
||||||
pos += amountRead;
|
|
||||||
|
|
||||||
return amountRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,60 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.vnc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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 net.sourceforge.guacamole.net.Configuration;
|
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
|
|
||||||
public class VNCConfiguration extends Configuration {
|
|
||||||
|
|
||||||
private String hostname;
|
|
||||||
private int port;
|
|
||||||
private String password;
|
|
||||||
private int bpp;
|
|
||||||
|
|
||||||
public VNCConfiguration(ServletContext context) throws GuacamoleException {
|
|
||||||
|
|
||||||
super(context);
|
|
||||||
|
|
||||||
hostname = readParameter("host", null);
|
|
||||||
port = readIntParameter("port", null);
|
|
||||||
password = context.getInitParameter("password");
|
|
||||||
bpp = readIntParameter("bpp", 24, 8, 16, 24);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBPP() {
|
|
||||||
return bpp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHostname() {
|
|
||||||
return hostname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPort() {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,32 +0,0 @@
|
|||||||
|
|
||||||
package net.sourceforge.guacamole.vnc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class VNCException extends Exception {
|
|
||||||
|
|
||||||
public VNCException(String message, Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VNCException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,239 +0,0 @@
|
|||||||
package net.sourceforge.guacamole.vnc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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.awt.image.BufferedImage;
|
|
||||||
import java.awt.image.IndexColorModel;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
|
|
||||||
public class VNCFullColorImageReader extends VNCImageReader {
|
|
||||||
|
|
||||||
private int bpp;
|
|
||||||
private int depth;
|
|
||||||
|
|
||||||
private int redBits;
|
|
||||||
private int greenBits;
|
|
||||||
private int blueBits;
|
|
||||||
|
|
||||||
private int redMax;
|
|
||||||
private int greenMax;
|
|
||||||
private int blueMax;
|
|
||||||
|
|
||||||
private int redShift;
|
|
||||||
private int greenShift;
|
|
||||||
private int blueShift;
|
|
||||||
|
|
||||||
private boolean readAsIndexed;
|
|
||||||
private boolean bigEndian;
|
|
||||||
|
|
||||||
private boolean swapRedAndBlue;
|
|
||||||
|
|
||||||
public boolean isBigEndian() {
|
|
||||||
return bigEndian;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBitsPerPixel() {
|
|
||||||
return bpp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDepth() {
|
|
||||||
return depth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRedMax() {
|
|
||||||
return redMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGreenMax() {
|
|
||||||
return greenMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBlueMax() {
|
|
||||||
return blueMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRedShift() {
|
|
||||||
return redShift;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGreenShift() {
|
|
||||||
return greenShift;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBlueShift() {
|
|
||||||
return blueShift;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up BGR reader
|
|
||||||
public VNCFullColorImageReader(boolean bigEndian, int redBits, int greenBits, int blueBits, int outputBPP, boolean swapRedAndBlue) throws VNCException {
|
|
||||||
|
|
||||||
this.swapRedAndBlue = swapRedAndBlue;
|
|
||||||
|
|
||||||
depth = redBits + greenBits + blueBits;
|
|
||||||
|
|
||||||
if (depth > 0 && depth <= 8)
|
|
||||||
bpp = 8;
|
|
||||||
else if (depth <= 16)
|
|
||||||
bpp = 16;
|
|
||||||
else if (depth <= 32)
|
|
||||||
bpp = 32;
|
|
||||||
else
|
|
||||||
throw new VNCException("Illegal bit depth for VNC images: " + bpp);
|
|
||||||
|
|
||||||
this.redBits = redBits;
|
|
||||||
this.greenBits = greenBits;
|
|
||||||
this.blueBits = blueBits;
|
|
||||||
|
|
||||||
blueMax = (1 << blueBits) - 1;
|
|
||||||
greenMax = (1 << greenBits) - 1;
|
|
||||||
redMax = (1 << redBits) - 1;
|
|
||||||
|
|
||||||
redShift = greenBits + blueBits;
|
|
||||||
greenShift = blueBits;
|
|
||||||
blueShift = 0;
|
|
||||||
|
|
||||||
if (outputBPP == 8)
|
|
||||||
this.readAsIndexed = true;
|
|
||||||
else if (outputBPP == 24)
|
|
||||||
this.readAsIndexed = false;
|
|
||||||
else
|
|
||||||
throw new VNCException("Only 8-bit or 24-bit output is supported.");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int readCPixel(DataInputStream input) throws IOException {
|
|
||||||
|
|
||||||
if (redBits != 8 || greenBits != 8 || blueBits != 8)
|
|
||||||
return readPixel(input);
|
|
||||||
|
|
||||||
int red;
|
|
||||||
int green;
|
|
||||||
int blue;
|
|
||||||
|
|
||||||
if (bigEndian) {
|
|
||||||
red = input.read();
|
|
||||||
green = input.read();
|
|
||||||
blue = input.read();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
blue = input.read();
|
|
||||||
green = input.read();
|
|
||||||
red = input.read();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (swapRedAndBlue)
|
|
||||||
return (blue << 16) | (green << 8) | red;
|
|
||||||
else
|
|
||||||
return (red << 16) | (green << 8) | blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int readPixel(DataInputStream input) throws IOException {
|
|
||||||
int value;
|
|
||||||
switch (bpp) {
|
|
||||||
case 8:
|
|
||||||
value = input.read();
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
|
|
||||||
short inputShort = input.readShort();
|
|
||||||
if (!bigEndian) inputShort = Short.reverseBytes(inputShort);
|
|
||||||
|
|
||||||
value = inputShort;
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
|
|
||||||
int inputInt = input.readInt();
|
|
||||||
if (!bigEndian) inputInt = Integer.reverseBytes(inputInt);
|
|
||||||
|
|
||||||
value = inputInt;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IOException("Invalid BPP.");
|
|
||||||
}
|
|
||||||
|
|
||||||
int red = (value >> redShift) & redMax;
|
|
||||||
int green = (value >> greenShift) & greenMax;
|
|
||||||
int blue = (value >> blueShift) & blueMax;
|
|
||||||
|
|
||||||
red <<= 8 - redBits;
|
|
||||||
green <<= 8 - greenBits;
|
|
||||||
blue <<= 8 - blueBits;
|
|
||||||
|
|
||||||
if (swapRedAndBlue)
|
|
||||||
return (blue << 16) | (green << 8) | red;
|
|
||||||
else
|
|
||||||
return (red << 16) | (green << 8) | blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BufferedImage generateBlankImage(int width, int height) {
|
|
||||||
if (readAsIndexed)
|
|
||||||
return new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, COLOR_MODEL);
|
|
||||||
return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load color model
|
|
||||||
public static final IndexColorModel COLOR_MODEL;
|
|
||||||
static {
|
|
||||||
// Construct color model
|
|
||||||
byte[] colorShade = {0, (byte) 51, (byte) 104, (byte) 153, (byte) 204, (byte) 255};
|
|
||||||
byte[] greyShade = new byte[39];
|
|
||||||
for (int i=1; i<40; i++)
|
|
||||||
greyShade[i-1] = (byte) (6*i);
|
|
||||||
|
|
||||||
byte[] red = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1];
|
|
||||||
byte[] green = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1];
|
|
||||||
byte[] blue = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1];
|
|
||||||
byte[] alpha = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1];
|
|
||||||
|
|
||||||
int color = 0;
|
|
||||||
for (int r=0; r<colorShade.length; r++) {
|
|
||||||
for (int g=0; g<colorShade.length; g++) {
|
|
||||||
for (int b=0; b<colorShade.length; b++) {
|
|
||||||
red[color] = colorShade[r];
|
|
||||||
green[color] = colorShade[g];
|
|
||||||
blue[color] = colorShade[b];
|
|
||||||
alpha[color] = (byte) 255;
|
|
||||||
color++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int grey=0; grey<greyShade.length; grey++) {
|
|
||||||
red[color] = greyShade[grey];
|
|
||||||
green[color] = greyShade[grey];
|
|
||||||
blue[color] = greyShade[grey];
|
|
||||||
alpha[color] = (byte) 255;
|
|
||||||
color++;
|
|
||||||
}
|
|
||||||
|
|
||||||
red[color] = 0;
|
|
||||||
green[color] = 0;
|
|
||||||
blue[color] = 0;
|
|
||||||
alpha[color] = (byte) 0;
|
|
||||||
|
|
||||||
COLOR_MODEL = new IndexColorModel(8, 256, red, green, blue, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@@ -1,64 +0,0 @@
|
|||||||
package net.sourceforge.guacamole.vnc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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.awt.image.BufferedImage;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public abstract class VNCImageReader {
|
|
||||||
|
|
||||||
public BufferedImage readCImage(DataInputStream input, int width, int height) throws IOException {
|
|
||||||
|
|
||||||
BufferedImage image = generateBlankImage(width, height);
|
|
||||||
// Read image
|
|
||||||
|
|
||||||
for (int pixelY=0; pixelY<height; pixelY++) {
|
|
||||||
for (int pixelX=0; pixelX<width; pixelX++) {
|
|
||||||
int color = 0xFF000000 | readCPixel(input);
|
|
||||||
image.setRGB(pixelX, pixelY, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BufferedImage readImage(DataInputStream input, int width, int height) throws IOException {
|
|
||||||
|
|
||||||
BufferedImage image = generateBlankImage(width, height);
|
|
||||||
// Read image
|
|
||||||
|
|
||||||
for (int pixelY=0; pixelY<height; pixelY++) {
|
|
||||||
for (int pixelX=0; pixelX<width; pixelX++) {
|
|
||||||
int color = 0xFF000000 | readPixel(input);
|
|
||||||
image.setRGB(pixelX, pixelY, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract BufferedImage generateBlankImage(int width, int height);
|
|
||||||
public abstract int readPixel(DataInputStream input) throws IOException;
|
|
||||||
public int readCPixel(DataInputStream input) throws IOException {
|
|
||||||
return readPixel(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@@ -1,104 +0,0 @@
|
|||||||
package net.sourceforge.guacamole.vnc;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Guacamole - Pure JavaScript/HTML VNC Client
|
|
||||||
* 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.awt.image.BufferedImage;
|
|
||||||
import java.awt.image.IndexColorModel;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
|
|
||||||
public class VNCIndexedImageReader extends VNCImageReader {
|
|
||||||
|
|
||||||
private IndexColorModel palette;
|
|
||||||
private byte[] red;
|
|
||||||
private byte[] green;
|
|
||||||
private byte[] blue;
|
|
||||||
|
|
||||||
// Set up BGR reader
|
|
||||||
public VNCIndexedImageReader(byte[] red, byte[] green, byte[] blue) throws VNCException {
|
|
||||||
|
|
||||||
this.red = red;
|
|
||||||
this.green = green;
|
|
||||||
this.blue = blue;
|
|
||||||
|
|
||||||
palette = new IndexColorModel(8, 256, red, green, blue);
|
|
||||||
if (palette.getMapSize() != 256)
|
|
||||||
throw new VNCException("Currently, only 256-color maps are supported.");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int readPixel(DataInputStream input) throws IOException {
|
|
||||||
int value = input.read();
|
|
||||||
int color = (red[value] << 16) | (green[value] << 8) | blue[value];
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BufferedImage generateBlankImage(int width, int height) {
|
|
||||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, palette);
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load color model
|
|
||||||
public static final IndexColorModel COLOR_MODEL;
|
|
||||||
static {
|
|
||||||
// Construct color model
|
|
||||||
byte[] colorShade = {0, (byte) 51, (byte) 104, (byte) 153, (byte) 204, (byte) 255};
|
|
||||||
byte[] greyShade = new byte[39];
|
|
||||||
for (int i=1; i<40; i++)
|
|
||||||
greyShade[i-1] = (byte) (6*i);
|
|
||||||
|
|
||||||
byte[] red = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1];
|
|
||||||
byte[] green = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1];
|
|
||||||
byte[] blue = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1];
|
|
||||||
byte[] alpha = new byte[colorShade.length*colorShade.length*colorShade.length+greyShade.length+1];
|
|
||||||
|
|
||||||
int color = 0;
|
|
||||||
for (int r=0; r<colorShade.length; r++) {
|
|
||||||
for (int g=0; g<colorShade.length; g++) {
|
|
||||||
for (int b=0; b<colorShade.length; b++) {
|
|
||||||
red[color] = colorShade[r];
|
|
||||||
green[color] = colorShade[g];
|
|
||||||
blue[color] = colorShade[b];
|
|
||||||
alpha[color] = (byte) 255;
|
|
||||||
color++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int grey=0; grey<greyShade.length; grey++) {
|
|
||||||
red[color] = greyShade[grey];
|
|
||||||
green[color] = greyShade[grey];
|
|
||||||
blue[color] = greyShade[grey];
|
|
||||||
alpha[color] = (byte) 255;
|
|
||||||
color++;
|
|
||||||
}
|
|
||||||
|
|
||||||
red[color] = 0;
|
|
||||||
green[color] = 0;
|
|
||||||
blue[color] = 0;
|
|
||||||
alpha[color] = (byte) 0;
|
|
||||||
|
|
||||||
COLOR_MODEL = new IndexColorModel(8, 256, red, green, blue, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
Reference in New Issue
Block a user