HTMLNode summaryContent = pageMaker.getInfobox("#", NodeL10n.getBase().getString("ConnectivityToadlet.summaryTitle"), contentNode, "connectivity-summary", true);
HTMLNode table = summaryContent.addChild("table", "border", "0");
for(UdpSocketHandler handler: handlers) {
AddressTracker tracker = handler.getAddressTracker();
HTMLNode row = table.addChild("tr");
row.addChild("td", handler.getTitle());
row.addChild("td", AddressTracker.statusString(tracker.getPortForwardStatus()));
}
if(ctx.isAdvancedModeEnabled()) {
// One box per port
String noreply = l10n("noreply");
String local = l10n("local");
String remote = l10n("remote");
long now = System.currentTimeMillis();
for(UdpSocketHandler handler: handlers) {
// Peers
AddressTracker tracker = handler.getAddressTracker();
HTMLNode portsContent = pageMaker.getInfobox("#", NodeL10n.getBase().getString("ConnectivityToadlet.byPortTitle", new String[] { "port", "status", "tunnelLength" }, new String[] { handler.getTitle(), AddressTracker.statusString(tracker.getPortForwardStatus()), TimeUtil.formatTime(tracker.getLongestSendReceiveGap()) }), contentNode, "connectivity-port", false);
PeerAddressTrackerItem[] items = tracker.getPeerAddressTrackerItems();
table = portsContent.addChild("table");
HTMLNode row = table.addChild("tr");
row.addChild("th", l10n("addressTitle"));
row.addChild("th", l10n("sentReceivedTitle"));
row.addChild("th", l10n("localRemoteTitle"));
row.addChild("th", l10n("firstSendLeadTime"));
row.addChild("th", l10n("firstReceiveLeadTime"));
for(int j=0;j<AddressTrackerItem.TRACK_GAPS;j++) {
row.addChild("th", " "); // FIXME is <th/> valid??
}
for(PeerAddressTrackerItem item: items) {
row = table.addChild("tr");
// Address
row.addChild("td", item.peer.toString());
// Sent/received packets
row.addChild("td", item.packetsSent() + "/ " + item.packetsReceived());
// Initiator: local/remote FIXME something more graphical e.g. colored cells
row.addChild("td", item.packetsReceived() == 0 ? noreply :
(item.weSentFirst() ? local : remote));
// Lead in time to first packet sent
row.addChild("td", TimeUtil.formatTime(item.timeFromStartupToFirstSentPacket()));
// Lead in time to first packet received
row.addChild("td", TimeUtil.formatTime(item.timeFromStartupToFirstReceivedPacket()));
Gap[] gaps = item.getGaps();
for(int k=0;k<AddressTrackerItem.TRACK_GAPS;k++) {
row.addChild("td", gaps[k].receivedPacketAt == 0 ? "" :
(TimeUtil.formatTime(gaps[k].gapLength)+" @ "+TimeUtil.formatTime(now - gaps[k].receivedPacketAt)+" ago" /* fixme l10n */));
}
}
// IPs
portsContent = pageMaker.getInfobox("#", NodeL10n.getBase().getString("ConnectivityToadlet.byIPTitle", new String[] { "ip", "status", "tunnelLength" }, new String[] { handler.getTitle(), AddressTracker.statusString(tracker.getPortForwardStatus()), TimeUtil.formatTime(tracker.getLongestSendReceiveGap()) }), contentNode, "connectivity-ip", false);
InetAddressAddressTrackerItem[] ipItems = tracker.getInetAddressTrackerItems();
table = portsContent.addChild("table");
row = table.addChild("tr");
row.addChild("th", l10n("addressTitle"));
row.addChild("th", l10n("sentReceivedTitle"));
row.addChild("th", l10n("localRemoteTitle"));