Author: nextgens
Date: 2006-08-26 15:14:36 +0000 (Sat, 26 Aug 2006)
New Revision: 10265
Modified:
trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
Log:
implement 682:
* Now we can set the "private comment" when adding a new peer
* We don't show all useless stuffs if there is no peer on the /darknet/
page
Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-08-26 13:52:21 UTC (rev 10264)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-08-26 15:14:36 UTC (rev 10265)
@@ -95,7 +95,6 @@
/* gather connection statistics */
PeerNodeStatus[] peerNodeStatuses = node.getPeerNodeStatuses();
-
Arrays.sort(peerNodeStatuses, new Comparator() {
public int compare(Object first, Object second) {
PeerNodeStatus firstNode = (PeerNodeStatus)
first;
@@ -125,7 +124,7 @@
if(advancedEnabled) {
titleCountString = "(" + numberOfConnected + "/" +
numberOfRoutingBackedOff + "/" + numberOfTooNew + "/" + numberOfTooOld + "/" +
numberOfNotConnected + ")";
} else {
- titleCountString =
String.valueOf(numberOfSimpleConnected);
+ titleCountString = (numberOfNotConnected +
numberOfSimpleConnected)>0 ? String.valueOf(numberOfSimpleConnected) : "";
}
HTMLNode pageNode =
ctx.getPageMaker().getPageNode(titleCountString + " Darknet Peers of " +
node.getMyName());
@@ -133,9 +132,11 @@
// FIXME! We need some nice images
long now = System.currentTimeMillis();
+
+ contentNode.addChild(core.alerts.createSummary());
- contentNode.addChild(core.alerts.createSummary());
-
+ if(peerNodeStatuses.length>0){
+
/* node status values */
int bwlimitDelayTime = (int) node.getBwlimitDelayTime();
int nodeAveragePingTime = (int) node.getNodeAveragePingTime();
@@ -463,6 +464,8 @@
}
// END PEER TABLE
+ }
+
// BEGIN PEER ADDITION BOX
HTMLNode peerAdditionInfobox = contentNode.addChild("div",
"class", "infobox infobox-normal");
peerAdditionInfobox.addChild("div", "class", "infobox-header",
"Add another peer");
@@ -479,6 +482,9 @@
peerAdditionForm.addChild("#", "Choose the file containing the
reference here: ");
peerAdditionForm.addChild("input", new String[] { "id", "type",
"name" }, new String[] { "reffile", "file", "reffile" });
peerAdditionForm.addChild("br");
+ peerAdditionForm.addChild("#", "Enter a node description: ");
+ peerAdditionForm.addChild("input", new String[] { "id", "type",
"name", "size", "maxlength", "value" }, new String[] { "peerPrivateNote",
"text", "peerPrivateNote", "16", "250", "" });
+ peerAdditionForm.addChild("br");
peerAdditionForm.addChild("input", new String[] { "type",
"name", "value" }, new String[] { "submit", "add", "Add" });
// our reference
@@ -520,6 +526,7 @@
reftext = request.getPartAsString("reffile",
2000);
reftext = reftext.trim();
}
+ String privateComment =
request.getPartAsString("peerPrivateNote", 250).trim();
StringBuffer ref = new StringBuffer(1024);
if (urltext.length() > 0) {
@@ -565,6 +572,7 @@
PeerNode pn;
try {
pn = new PeerNode(fs, this.node, false);
+ pn.setPrivateDarknetCommentNote(privateComment);
} catch (FSParseException e1) {
this.sendErrorPage(ctx, 200, "Failed To Add
Node", "Unable to parse the given text as a node reference. Please try again.");
return;