mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-61 Console proxy has plenty of files with CRLF line ending.
This commit is contained in:
parent
f03d438c4c
commit
0bf8c5a18f
@ -30,8 +30,8 @@ import com.cloud.consoleproxy.util.ImageHelper;
|
||||
import com.cloud.consoleproxy.util.TileInfo;
|
||||
|
||||
/**
|
||||
* A <code>BuffereImageCanvas</code> component represents frame buffer image on the
|
||||
* screen. It also notifies its subscribers when screen is repainted.
|
||||
* A <code>BuffereImageCanvas</code> component represents frame buffer image on
|
||||
* the screen. It also notifies its subscribers when screen is repainted.
|
||||
*/
|
||||
public class BufferedImageCanvas extends Canvas implements FrameBufferCanvas {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -92,8 +92,7 @@ public class BufferedImageCanvas extends Canvas implements FrameBufferCanvas {
|
||||
|
||||
public void copyTile(Graphics2D g, int x, int y, Rectangle rc) {
|
||||
synchronized (offlineImage) {
|
||||
g.drawImage(offlineImage, x, y, x + rc.width, y + rc.height,
|
||||
rc.x, rc.y, rc.x + rc.width, rc.y + rc.height, null);
|
||||
g.drawImage(offlineImage, x, y, x + rc.width, y + rc.height, rc.x, rc.y, rc.x + rc.width, rc.y + rc.height, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,8 +111,7 @@ public class BufferedImageCanvas extends Canvas implements FrameBufferCanvas {
|
||||
width = offlineImage.getWidth();
|
||||
height = offlineImage.getHeight();
|
||||
|
||||
BufferedImage bufferedImage = new BufferedImage(width, height,
|
||||
BufferedImage.TYPE_3BYTE_BGR);
|
||||
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
|
||||
Graphics2D g = bufferedImage.createGraphics();
|
||||
synchronized (offlineImage) {
|
||||
g.drawImage(offlineImage, 0, 0, width, height, 0, 0, width, height, null);
|
||||
@ -130,16 +128,14 @@ public class BufferedImageCanvas extends Canvas implements FrameBufferCanvas {
|
||||
@Override
|
||||
public byte[] getTilesMergedJpeg(List<TileInfo> tileList, int tileWidth, int tileHeight) {
|
||||
int width = Math.max(tileWidth, tileWidth * tileList.size());
|
||||
BufferedImage bufferedImage = new BufferedImage(width, tileHeight,
|
||||
BufferedImage.TYPE_3BYTE_BGR);
|
||||
BufferedImage bufferedImage = new BufferedImage(width, tileHeight, BufferedImage.TYPE_3BYTE_BGR);
|
||||
Graphics2D g = bufferedImage.createGraphics();
|
||||
|
||||
synchronized (offlineImage) {
|
||||
int i = 0;
|
||||
for (TileInfo tile : tileList) {
|
||||
Rectangle rc = tile.getTileRect();
|
||||
g.drawImage(offlineImage, i*tileWidth, 0, i*tileWidth + rc.width, rc.height,
|
||||
rc.x, rc.y, rc.x + rc.width, rc.y + rc.height, null);
|
||||
g.drawImage(offlineImage, i * tileWidth, 0, i * tileWidth + rc.width, rc.height, rc.x, rc.y, rc.x + rc.width, rc.y + rc.height, null);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,8 @@ import com.cloud.consoleproxy.util.TileInfo;
|
||||
|
||||
public interface FrameBufferCanvas {
|
||||
Image getFrameBufferScaledImage(int width, int height);
|
||||
|
||||
public byte[] getFrameBufferJpeg();
|
||||
|
||||
public byte[] getTilesMergedJpeg(List<TileInfo> tileList, int tileWidth, int tileHeight);
|
||||
}
|
||||
|
||||
@ -19,8 +19,8 @@ package com.cloud.consoleproxy.vnc;
|
||||
public interface FrameBufferUpdateListener {
|
||||
|
||||
/**
|
||||
* Notify listener, that frame buffer update packet is received, so client is
|
||||
* permitted (but not obligated) to ask server to send another update.
|
||||
* Notify listener, that frame buffer update packet is received, so client
|
||||
* is permitted (but not obligated) to ask server to send another update.
|
||||
*/
|
||||
void frameBufferPacketReceived();
|
||||
}
|
||||
|
||||
@ -19,8 +19,8 @@ package com.cloud.consoleproxy.vnc;
|
||||
public interface PaintNotificationListener {
|
||||
|
||||
/**
|
||||
* Notify subscriber that screen is updated, so client can send another frame
|
||||
* buffer update request to server.
|
||||
* Notify subscriber that screen is updated, so client can send another
|
||||
* frame buffer update request to server.
|
||||
*/
|
||||
void imagePaintedOnScreen();
|
||||
|
||||
|
||||
@ -33,8 +33,8 @@ public interface RfbConstants {
|
||||
/**
|
||||
* Client message types.
|
||||
*/
|
||||
public static final int CLIENT_SET_PIXEL_FORMAT = 0, CLIENT_FIX_COLOURMAP_ENTRIES = 1, CLIENT_SET_ENCODINGS = 2, CLIENT_FRAMEBUFFER_UPDATE_REQUEST = 3,
|
||||
CLIENT_KEYBOARD_EVENT = 4, CLIENT_POINTER_EVENT = 5, CLIENT_CUT_TEXT = 6;
|
||||
public static final int CLIENT_SET_PIXEL_FORMAT = 0, CLIENT_FIX_COLOURMAP_ENTRIES = 1, CLIENT_SET_ENCODINGS = 2, CLIENT_FRAMEBUFFER_UPDATE_REQUEST = 3, CLIENT_KEYBOARD_EVENT = 4,
|
||||
CLIENT_POINTER_EVENT = 5, CLIENT_CUT_TEXT = 6;
|
||||
|
||||
/**
|
||||
* Server authorization type
|
||||
@ -62,7 +62,8 @@ public interface RfbConstants {
|
||||
public final static int[] SUPPORTED_ENCODINGS_ARRAY = { ENCODING_RAW, ENCODING_COPY_RECT, ENCODING_DESKTOP_SIZE };
|
||||
|
||||
/**
|
||||
* Frame buffer update request type: update of whole screen or partial update.
|
||||
* Frame buffer update request type: update of whole screen or partial
|
||||
* update.
|
||||
*/
|
||||
public static final int FRAMEBUFFER_FULL_UPDATE_REQUEST = 0, FRAMEBUFFER_INCREMENTAL_UPDATE_REQUEST = 1;
|
||||
|
||||
|
||||
@ -90,8 +90,7 @@ public class VncClient {
|
||||
this.clientListener = clientListener;
|
||||
}
|
||||
|
||||
public VncClient(String host, int port, String password, boolean noUI, ConsoleProxyClientListener clientListener)
|
||||
throws UnknownHostException, IOException {
|
||||
public VncClient(String host, int port, String password, boolean noUI, ConsoleProxyClientListener clientListener) throws UnknownHostException, IOException {
|
||||
|
||||
this.noUI = noUI;
|
||||
this.clientListener = clientListener;
|
||||
@ -131,8 +130,7 @@ public class VncClient {
|
||||
return clientListener;
|
||||
}
|
||||
|
||||
public void connectTo(String host, int port, String path,
|
||||
String session, boolean useSSL, String sid) throws UnknownHostException, IOException {
|
||||
public void connectTo(String host, int port, String path, String session, boolean useSSL, String sid) throws UnknownHostException, IOException {
|
||||
if (port < 0) {
|
||||
if (useSSL)
|
||||
port = 443;
|
||||
@ -355,7 +353,8 @@ public class VncClient {
|
||||
* bit. E.g. 01001100 will become 00110010.
|
||||
*
|
||||
* See also: http://www.vidarholen.net/contents/junk/vnc.html ,
|
||||
* http://bytecrafter .blogspot.com/2010/09/des-encryption-as-used-in-vnc.html
|
||||
* http://bytecrafter
|
||||
* .blogspot.com/2010/09/des-encryption-as-used-in-vnc.html
|
||||
*
|
||||
* @param b
|
||||
* a byte
|
||||
|
||||
@ -97,16 +97,14 @@ public class VncClientPacketSender implements Runnable, PaintNotificationListene
|
||||
}
|
||||
|
||||
public void requestFullScreenUpdate() {
|
||||
queue.add(new FramebufferUpdateRequestPacket(RfbConstants.FRAMEBUFFER_FULL_UPDATE_REQUEST, 0, 0, screen.getFramebufferWidth(), screen
|
||||
.getFramebufferHeight()));
|
||||
queue.add(new FramebufferUpdateRequestPacket(RfbConstants.FRAMEBUFFER_FULL_UPDATE_REQUEST, 0, 0, screen.getFramebufferWidth(), screen.getFramebufferHeight()));
|
||||
updateRequestSent = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void imagePaintedOnScreen() {
|
||||
if (!updateRequestSent) {
|
||||
queue.add(new FramebufferUpdateRequestPacket(RfbConstants.FRAMEBUFFER_INCREMENTAL_UPDATE_REQUEST, 0, 0, screen.getFramebufferWidth(), screen
|
||||
.getFramebufferHeight()));
|
||||
queue.add(new FramebufferUpdateRequestPacket(RfbConstants.FRAMEBUFFER_INCREMENTAL_UPDATE_REQUEST, 0, 0, screen.getFramebufferWidth(), screen.getFramebufferHeight()));
|
||||
updateRequestSent = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,13 +41,12 @@ public class VncScreenDescription {
|
||||
/**
|
||||
* Store information about server pixel format.
|
||||
*/
|
||||
public void setPixelFormat(int bitsPerPixel, int depth, int bigEndianFlag, int trueColorFlag, int redMax, int greenMax, int blueMax, int redShift,
|
||||
int greenShift, int blueShift) {
|
||||
public void setPixelFormat(int bitsPerPixel, int depth, int bigEndianFlag, int trueColorFlag, int redMax, int greenMax, int blueMax, int redShift, int greenShift, int blueShift) {
|
||||
|
||||
bytesPerPixel = (bitsPerPixel + 7) / 8;
|
||||
|
||||
rgb888_32_le = (depth == 24 && bitsPerPixel == 32 && redShift == 16 && greenShift == 8 && blueShift == 0 && redMax == 255 && greenMax == 255
|
||||
&& blueMax == 255 && bigEndianFlag == RfbConstants.LITTLE_ENDIAN && trueColorFlag == RfbConstants.TRUE_COLOR);
|
||||
rgb888_32_le = (depth == 24 && bitsPerPixel == 32 && redShift == 16 && greenShift == 8 && blueShift == 0 && redMax == 255 && greenMax == 255 && blueMax == 255
|
||||
&& bigEndianFlag == RfbConstants.LITTLE_ENDIAN && trueColorFlag == RfbConstants.TRUE_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -38,8 +38,8 @@ public class VncServerPacketReceiver implements Runnable {
|
||||
private final FrameBufferUpdateListener fburListener;
|
||||
private final ConsoleProxyClientListener clientListener;
|
||||
|
||||
public VncServerPacketReceiver(DataInputStream is, BufferedImageCanvas canvas, VncScreenDescription screen, VncClient vncConnection,
|
||||
FrameBufferUpdateListener fburListener, ConsoleProxyClientListener clientListener) {
|
||||
public VncServerPacketReceiver(DataInputStream is, BufferedImageCanvas canvas, VncScreenDescription screen, VncClient vncConnection, FrameBufferUpdateListener fburListener,
|
||||
ConsoleProxyClientListener clientListener) {
|
||||
this.screen = screen;
|
||||
this.canvas = canvas;
|
||||
this.is = is;
|
||||
|
||||
@ -39,7 +39,6 @@ public class FramebufferUpdateRequestPacket implements ClientPacket {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream os) throws IOException {
|
||||
os.writeByte(RfbConstants.CLIENT_FRAMEBUFFER_UPDATE_REQUEST);
|
||||
|
||||
@ -25,22 +25,19 @@ public class SetEncodingsPacket implements ClientPacket {
|
||||
|
||||
private final int[] encodings;
|
||||
|
||||
public SetEncodingsPacket(int[] encodings)
|
||||
{
|
||||
public SetEncodingsPacket(int[] encodings) {
|
||||
this.encodings = encodings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream os) throws IOException
|
||||
{
|
||||
public void write(DataOutputStream os) throws IOException {
|
||||
os.writeByte(RfbConstants.CLIENT_SET_ENCODINGS);
|
||||
|
||||
os.writeByte(0);// padding
|
||||
|
||||
os.writeShort(encodings.length);
|
||||
|
||||
for(int i=0;i<encodings.length;i++)
|
||||
{
|
||||
for (int i = 0; i < encodings.length; i++) {
|
||||
os.writeInt(encodings[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,8 +28,8 @@ public class SetPixelFormatPacket implements ClientPacket {
|
||||
|
||||
private final VncScreenDescription screen;
|
||||
|
||||
public SetPixelFormatPacket(VncScreenDescription screen, int bitsPerPixel, int depth, int bigEndianFlag, int trueColorFlag, int redMax, int greenMax,
|
||||
int blueMax, int redShift, int greenShift, int blueShift) {
|
||||
public SetPixelFormatPacket(VncScreenDescription screen, int bitsPerPixel, int depth, int bigEndianFlag, int trueColorFlag, int redMax, int greenMax, int blueMax, int redShift, int greenShift,
|
||||
int blueShift) {
|
||||
this.screen = screen;
|
||||
this.bitsPerPixel = bitsPerPixel;
|
||||
this.depth = depth;
|
||||
|
||||
@ -33,8 +33,7 @@ public class FramebufferUpdatePacket {
|
||||
private final BufferedImageCanvas canvas;
|
||||
private final ConsoleProxyClientListener clientListener;
|
||||
|
||||
public FramebufferUpdatePacket(BufferedImageCanvas canvas, VncScreenDescription screen, DataInputStream is,
|
||||
ConsoleProxyClientListener clientListener) throws IOException {
|
||||
public FramebufferUpdatePacket(BufferedImageCanvas canvas, VncScreenDescription screen, DataInputStream is, ConsoleProxyClientListener clientListener) throws IOException {
|
||||
|
||||
this.screen = screen;
|
||||
this.canvas = canvas;
|
||||
|
||||
@ -69,8 +69,7 @@ public class RawRect extends AbstractRect {
|
||||
}
|
||||
|
||||
default:
|
||||
throw new RuntimeException("Unsupported data buffer in buffered image: expected data buffer of type int (DataBufferInt). Actual data buffer type: "
|
||||
+ dataBuf.getClass().getSimpleName());
|
||||
throw new RuntimeException("Unsupported data buffer in buffered image: expected data buffer of type int (DataBufferInt). Actual data buffer type: " + dataBuf.getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +24,10 @@ public interface Rect {
|
||||
void paint(BufferedImage offlineImage, Graphics2D graphics);
|
||||
|
||||
int getX();
|
||||
|
||||
int getY();
|
||||
|
||||
int getWidth();
|
||||
|
||||
int getHeight();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user