Author: jflesch
Date: 2007-08-27 23:02:33 +0000 (Mon, 27 Aug 2007)
New Revision: 14892
Modified:
trunk/apps/Thaw/src/thaw/fcp/FCPGetNode.java
trunk/apps/Thaw/src/thaw/fcp/FCPListPeers.java
trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java
trunk/apps/Thaw/src/thaw/plugins/index/Index.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexContainer.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java
trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/GraphBuilder.java
trunk/apps/Thaw/src/thaw/plugins/peerMonitor/Peer.java
trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
Log:
Fix the peer monitor panel bug with opennet peers
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPGetNode.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPGetNode.java 2007-08-27 20:31:03 UTC
(rev 14891)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPGetNode.java 2007-08-27 23:02:33 UTC
(rev 14892)
@@ -5,7 +5,9 @@
import java.util.Hashtable;
+import thaw.core.Logger;
+
public class FCPGetNode extends Observable implements FCPQuery, Observer {
public final static String[] refElements = {
"identity",
@@ -84,6 +86,8 @@
|| !msg.getMessageName().equals("NodeData"))
return;
+ Logger.info(this, msg.toString());
+
ref = "";
for (int i = 0 ; i < refElements.length ; i++) {
@@ -114,6 +118,10 @@
}
+ /**
+ * Darknet ref.
+ * Not really maintained anymore. Please report if outdated
+ */
public String getRef() {
return ref;
}
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPListPeers.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPListPeers.java 2007-08-27 20:31:03 UTC
(rev 14891)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPListPeers.java 2007-08-27 23:02:33 UTC
(rev 14892)
@@ -6,6 +6,9 @@
import java.util.Vector;
import java.util.Hashtable;
+import thaw.core.Logger;
+
+
public class FCPListPeers extends Observable implements FCPQuery, Observer {
private boolean withMetadata;
Modified: trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java 2007-08-27
20:31:03 UTC (rev 14891)
+++ trunk/apps/Thaw/src/thaw/plugins/IndexWebGrapher.java 2007-08-27
23:02:33 UTC (rev 14892)
@@ -162,10 +162,21 @@
lastBuilder.stop();
}
}
+
} else if (e.getSource() == zoomIn) {
+
graphPanel.zoomIn();
+
+
scrollPane.getHorizontalScrollBar().setValue(scrollPane.getHorizontalScrollBar().getValue()*2);
+
scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getValue()*2);
+
} else if (e.getSource() == zoomOut) {
+
+
scrollPane.getHorizontalScrollBar().setValue(scrollPane.getHorizontalScrollBar().getValue()/2);
+
scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getValue()/2);
+
graphPanel.zoomOut();
+
} else if (e.getSource() == refresh) {
graphPanel.refresh();
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-08-27 20:31:03 UTC
(rev 14891)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-08-27 23:02:33 UTC
(rev 14892)
@@ -1208,7 +1208,7 @@
}
- public void addFile(String key, long size, String mime) {
+ public boolean addFile(String key, long size, String mime) {
try {
synchronized(db.dbLock) {
PreparedStatement st;
@@ -1229,10 +1229,14 @@
st.setInt(5, id);
st.execute();
+
+ return true;
}
} catch(SQLException e) {
Logger.error(this, "Error while adding file to index
'"+toString()+"' : "+e.toString());
}
+
+ return false;
}
@@ -1292,14 +1296,13 @@
}
- public void addLink(String key) {
+ public boolean addLink(String key) {
try {
if (key == null) /* it was the beginning of the index */
- return;
+ return true;
key = key.trim();
-
boolean blackListed = (BlackList.isBlackListed(db, key)
>= 0);
synchronized(db.dbLock) {
@@ -1315,10 +1318,14 @@
st.setBoolean(4, blackListed);
st.execute();
+
+ return true;
}
} catch(SQLException e) {
Logger.error(this, "Error while adding link to index
'"+toString()+"' : "+e.toString());
}
+
+ return false;
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexContainer.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexContainer.java 2007-08-27
20:31:03 UTC (rev 14891)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexContainer.java 2007-08-27
23:02:33 UTC (rev 14892)
@@ -63,8 +63,12 @@
public void setInsertionDate(java.util.Date date);
- public void addFile(String publicKey, long size, String mime);
- public void addLink(String publicKey);
+ /**
+ * return false if the parsing must be interrupted
+ * (because of db errors or anything else)
+ */
+ public boolean addFile(String publicKey, long size, String mime);
+ public boolean addLink(String publicKey);
public void setCommentKeys(String publicKey, String privateKey);
public void addBlackListedRev(int rev);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java 2007-08-27
20:31:03 UTC (rev 14891)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexParser.java 2007-08-27
23:02:33 UTC (rev 14892)
@@ -380,14 +380,18 @@
} else if ("link".equals(rawName)
|| "index".equals(rawName)) { /* links */
- index.addLink(attrs.getValue("key"));
+ if (!index.addLink(attrs.getValue("key"))) {
+ throw new SAXException("Index parsing
interrupted because of a backend error (did you delete the index while it was
downloading ?)");
+ }
return;
} else if ("file".equals(rawName)) {
- index.addFile(attrs.getValue("key"),
-
Long.parseLong(attrs.getValue("size")),
- attrs.getValue("mime"));
+ if (!index.addFile(attrs.getValue("key"),
+
Long.parseLong(attrs.getValue("size")),
+ attrs.getValue("mime"))) {
+ throw new SAXException("Index parsing
interrupted because of a backend error (did you delete the index while it was
downloading ?)");
+ }
} else if ("comments".equals(rawName)) {
String pub = attrs.getValue("publicKey");
@@ -589,6 +593,8 @@
Logger.error(this, "Error (2) while parsing index:
"+e.toString());
} catch(java.io.IOException e) {
Logger.error(this, "Error (3) while parsing index:
"+e.toString());
+ } catch(Exception e) {
+ Logger.error(this, "Error (4) while parsing index:
"+e.toString());
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/GraphBuilder.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/GraphBuilder.java
2007-08-27 20:31:03 UTC (rev 14891)
+++ trunk/apps/Thaw/src/thaw/plugins/indexWebGrapher/GraphBuilder.java
2007-08-27 23:02:33 UTC (rev 14892)
@@ -262,7 +262,6 @@
plugin.setProgress(9);
Logger.info(this, "Drawing ...");
- graphPanel.guessZoom();
graphPanel.refresh();
/* === */
Modified: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/Peer.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/Peer.java 2007-08-27
20:31:03 UTC (rev 14891)
+++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/Peer.java 2007-08-27
23:02:33 UTC (rev 14892)
@@ -16,7 +16,12 @@
public Peer(Hashtable parameters) {
this.parameters = parameters;
+
displayName = (String)parameters.get("myName");
+
+ if (displayName == null)
+ displayName = (String)parameters.get("physical.udp");
+
identity = (String)parameters.get("identity");
String status = (String)parameters.get("volatile.status");
Modified: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
2007-08-27 20:31:03 UTC (rev 14891)
+++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java
2007-08-27 23:02:33 UTC (rev 14892)
@@ -451,50 +451,50 @@
/* PEERS */
- if (result == null &&
"volatile.lastRoutingBackoffReason".equals(key))
+ if ("volatile.lastRoutingBackoffReason".equals(key))
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.lastRoutingBackoffReason"),
value
};
- if (result == null &&
"volatile.routingBackoffPercent".equals(key))
+ else if ("volatile.routingBackoffPercent".equals(key))
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.routingBackoffPercent"),
value + "%"
};
- if (result == null && "version".equals(key))
+ else if ("version".equals(key))
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.version"),
value
};
- if (result == null && "volatile.status".equals(key))
+ else if ("volatile.status".equals(key))
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.status"),
value
};
- if (result == null && "myName".equals(key))
+ else if ("myName".equals(key))
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.myName"),
value
};
- if (result == null && "physical.udp".equals(key))
+ else if ("physical.udp".equals(key))
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.physical.udp"),
value
};
- if (result == null && "volatile.averagePingTime".equals(key))
+ else if ("volatile.averagePingTime".equals(key))
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.averagePingTime"),
Integer.toString(new Float(value).intValue()) +
" ms"
};
- if (result == null && "volatile.idle".equals(key))
+ else if ("volatile.idle".equals(key))
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.peer.idle"),
"~" +
thaw.gui.GUIHelper.getPrintableTime(Long.parseLong(value) / 1000)
@@ -502,34 +502,34 @@
/* NODE */
- if (result == null && "volatile.overallSize".equals(key))
+ else if ("volatile.overallSize".equals(key))
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.node.overallSize"),
"~" +
thaw.gui.GUIHelper.getPrintableSize(Long.parseLong(value))
};
- if (result == null && "volatile.uptimeSeconds".equals(key)) {
+ else if ("volatile.uptimeSeconds".equals(key)) {
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.node.uptimeSeconds"),
"~" +
thaw.gui.GUIHelper.getPrintableTime(Long.parseLong(value))
};
}
- if (result == null &&
"volatile.networkSizeEstimateSession".equals(key)) {
+ else if ("volatile.networkSizeEstimateSession".equals(key)) {
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.node.networkSizeEstimateSession"),
value
};
}
- if (result == null &&
"volatile.runningThreadCount".equals(key)) {
+ else if ("volatile.runningThreadCount".equals(key)) {
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.node.runningThreads"),
value
};
}
- if (result == null && "myName".equals(key)) {
+ else if ("myName".equals(key)) {
result = new String[] {
I18n.getMessage("thaw.plugin.peerMonitor.infos.node.myName"),
value