Skip to content

Commit

Permalink
Merge pull request #5 from itsMatoosh/standalone-ui-overhaul
Browse files Browse the repository at this point in the history
UI redone for the standalone version
  • Loading branch information
itsMatoosh authored Jan 15, 2019
2 parents d924837 + 50b2c4f commit 9b5b72a
Show file tree
Hide file tree
Showing 66 changed files with 3,405 additions and 1,461 deletions.
15 changes: 9 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Thumbs.db
.DS_Store
/build
/captures
.idea

.externalNativeBuild
/*/out
/*/build
Expand All @@ -31,14 +33,15 @@ Thumbs.db
*.ipr
*~
*.swp
.idea/runConfigurations.xml

#Standalone test files.
standalone/network.yaml
standalone/standalone.yaml
standalone/cache/entry.nodes
standalone/cache/me.identity
standalone/cache/*
standalone/content
standalone/build
standalone/debug.log
standalone/random.id
*.id
*.resources
.idea/modules.xml
cache
standalone.yaml
network.yaml
4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/resourceBundles.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
allprojects {

}
subprojects {
apply plugin: "java"
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
group 'me.matoosh.undernet'
version '0.3'

}
subprojects {
repositories {
mavenCentral()
jcenter()
}

dependencies {
Expand Down
8 changes: 3 additions & 5 deletions shared/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
dependencies {
// https://mvnrepository.com/artifact/io.netty/netty-all
compile group: 'io.netty', name: 'netty-all', version: '4.1.22.Final'
compile group: 'org.apache.commons', name: 'commons-crypto', version: '1.0.0'
// https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk16
compile group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.45'
implementation group: 'io.netty', name: 'netty-all', version: '4.1.22.Final'
implementation group: 'org.apache.commons', name: 'commons-crypto', version: '1.0.0'
implementation group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.45'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.matoosh.undernet.event.resource.transfer;

import me.matoosh.undernet.p2p.router.data.resource.FileResource;
import me.matoosh.undernet.p2p.router.data.resource.transfer.ResourceTransferHandler;

/**
Expand All @@ -12,7 +11,7 @@ public class ResourceTransferErrorEvent extends ResourceTransferEvent {
/**
* The exception.
*/
public Exception exception;
private Exception exception;

public ResourceTransferErrorEvent(ResourceTransferHandler transferHandler, Exception exception) {
super(transferHandler);
Expand All @@ -21,11 +20,10 @@ public ResourceTransferErrorEvent(ResourceTransferHandler transferHandler, Excep

@Override
public void onCalled() {
logger.error("Error occurred transferring resource: " + transferHandler.getResource(), exception);

//Deleting the remainders of the transferred file.
if(this.transferHandler.getResource() instanceof FileResource) {
logger.error("Error occurred transferring resource: " + getTransferHandler().getResource(), exception);
}

}
public Exception getException() {
return exception;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ public abstract class ResourceTransferEvent extends Event {
/**
* The file transfer.
*/
public ResourceTransferHandler transferHandler;
private ResourceTransferHandler transferHandler;

public ResourceTransferEvent(ResourceTransferHandler transferHandler) {
this.transferHandler = transferHandler;
}

public ResourceTransferHandler getTransferHandler() {
return transferHandler;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,16 @@
* Called when a resource transfer finishes.
*/
public class ResourceTransferFinishedEvent extends ResourceTransferEvent {

private String reason;

public ResourceTransferFinishedEvent(ResourceTransferHandler transferHandler, String reason) {
public ResourceTransferFinishedEvent(ResourceTransferHandler transferHandler) {
super(transferHandler);
this.reason = reason;
}

@Override
public void onCalled() {
if(this.transferHandler.getTransferType() == ResourceTransferType.INBOUND) {
logger.info("Transfer of resource {}, from {}, finished!, {}", this.transferHandler.getResource(), this.transferHandler.getTunnel().getDestination(), this.reason);
if(this.getTransferHandler().getTransferType() == ResourceTransferType.INBOUND) {
logger.info("Transfer of resource {}, from {}, finished!", this.getTransferHandler().getResource(), this.getTransferHandler().getTunnel().getDestination());
} else {
logger.info("Transfer of resource {}, to {}, finished!, {}", this.transferHandler.getResource(), this.transferHandler.getTunnel().getDestination(), this.reason);
logger.info("Transfer of resource {}, to {}, finished!", this.getTransferHandler().getResource(), this.getTransferHandler().getTunnel().getDestination());
}
}

public void setReason(String reason) {
this.reason = reason;
}

public String getReason() {
return reason;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public ResourceTransferStartedEvent(ResourceTransferHandler transferHandler) {

@Override
public void onCalled() {
if(this.transferHandler.getTransferType() == ResourceTransferType.INBOUND) {
logger.info("Transfer of resource {}, from {}, started!", this.transferHandler.getResource(), this.transferHandler.getTunnel().getDestination());
if(this.getTransferHandler().getTransferType() == ResourceTransferType.INBOUND) {
logger.info("Transfer of resource {}, from {}, started!", this.getTransferHandler().getResource(), this.getTransferHandler().getTunnel().getDestination());
} else {
logger.info("Transfer of resource {}, to {}, started!", this.transferHandler.getResource(), this.transferHandler.getTunnel().getDestination());
logger.info("Transfer of resource {}, to {}, started!", this.getTransferHandler().getResource(), this.getTransferHandler().getTunnel().getDestination());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package me.matoosh.undernet.event.router;

import me.matoosh.undernet.p2p.router.Router;

public class RouterControlLoopEvent extends RouterEvent {
public RouterControlLoopEvent(Router r) {
super(r);
}

@Override
public void onCalled() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

import java.io.*;
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;

/**
Expand Down Expand Up @@ -95,6 +93,7 @@ public static Node addNode(String host) {
}
}
node.setAddress(new InetSocketAddress(addressSplit[0], port));
if(node.getAddress() == null || node.getAddress().getAddress() == null) return null;

//Adding the node to the cache.
EntryNodeCache.addNode(node);
Expand All @@ -106,7 +105,7 @@ public static Node addNode(String host) {
* @param node
*/
public static void addNode(Node node) {
if(Node.isLocalAddress(node.getAddress())) {
if(node == null || Node.isLocalAddress(node.getAddress())) {
logger.warn("Can't add a local address to Node Cache!");
return;
}
Expand Down
6 changes: 5 additions & 1 deletion shared/src/main/java/me/matoosh/undernet/p2p/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ public boolean isConnected() {
* @param msg
*/
public void sendRaw(NetworkMessage msg) {
logger.info("Sending a {} message to: {}", msg.getContent().getType(), address);
if(msg.getContent() != null)
logger.info("Sending a {} message to: {}", msg.getContent().getType(), address);
else
logger.info("Sending a message to: {}", address);

if(channel == null) {
logger.error("Node {} is not a neighboring node, can't send the message!", this);
} else {
Expand Down
Loading

0 comments on commit 9b5b72a

Please sign in to comment.