From jflesch at freenetproject.org Sun Apr 1 13:56:29 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 1 Apr 2007 13:56:29 +0000 (UTC) Subject: [Thaw-dev] r12510 - in trunk/apps/Thaw/src/thaw: core plugins plugins/index Message-ID: <20070401135629.79FA1479F87@emu.freenetproject.org> Author: jflesch Date: 2007-04-01 13:56:29 +0000 (Sun, 01 Apr 2007) New Revision: 12510 Modified: trunk/apps/Thaw/src/thaw/core/Main.java trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java trunk/apps/Thaw/src/thaw/plugins/index/Link.java trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java Log: Add an option to sort the unknown index list alphabetically Modified: trunk/apps/Thaw/src/thaw/core/Main.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/Main.java 2007-04-01 13:25:08 UTC (rev 12509) +++ trunk/apps/Thaw/src/thaw/core/Main.java 2007-04-01 13:56:29 UTC (rev 12510) @@ -21,7 +21,7 @@ _svnBuildNumber = "@custom@"; public final static String - VERSION = Main._major + "." + Main._minor + "." + Main._update + " Beta r"+Main._svnBuildNumber; + VERSION = Main._major + "." + Main._minor + "." + Main._update + " r"+Main._svnBuildNumber; /** Modified: trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java 2007-04-01 13:25:08 UTC (rev 12509) +++ trunk/apps/Thaw/src/thaw/plugins/Hsqldb.java 2007-04-01 13:56:29 UTC (rev 12510) @@ -67,7 +67,9 @@ } public void disconnect() throws java.sql.SQLException { - connection.close(); + synchronized(dbLock) { + connection.close(); + } } Modified: trunk/apps/Thaw/src/thaw/plugins/index/Link.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2007-04-01 13:25:08 UTC (rev 12509) +++ trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2007-04-01 13:56:29 UTC (rev 12510) @@ -11,7 +11,7 @@ import thaw.core.Logger; import thaw.plugins.Hsqldb; -public class Link extends java.util.Observable { +public class Link extends java.util.Observable implements Comparable { private int id; private final Hsqldb db; @@ -248,4 +248,12 @@ return index.isModifiable(); } + + public int compareTo(Object o) { + if (o instanceof Link) { + return getIndexName().compareTo(((Link)o).getIndexName()); + } + + return 0; + } } Modified: trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java 2007-04-01 13:25:08 UTC (rev 12509) +++ trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java 2007-04-01 13:56:29 UTC (rev 12510) @@ -3,6 +3,8 @@ import java.awt.BorderLayout; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.Iterator; import java.util.Vector; @@ -19,7 +21,8 @@ import thaw.fcp.FCPQueueManager; import thaw.plugins.ToolbarModifier; -public class UnknownIndexList implements MouseListener { + +public class UnknownIndexList implements MouseListener, ActionListener { public final static int MAX_INDEXES = 50; private int offset; @@ -36,6 +39,8 @@ private JPopupMenu rightClickMenu = null; private Vector rightClickActions = null; + private JMenuItem sortItem = null; + private ToolbarModifier toolbarModifier; private Vector toolbarActions; @@ -221,6 +226,11 @@ rightClickMenu.add(item); rightClickActions.add(new LinkManagementHelper.IndexAdder(item, queueManager, indexBrowser, false)); + sortItem = new JMenuItem(I18n.getMessage("thaw.plugin.index.sortAlphabetically")); + rightClickMenu.add(sortItem); + sortItem.addActionListener(this); + + item = new JMenuItem(I18n.getMessage("thaw.plugin.index.copyKeys")); rightClickMenu.add(item); rightClickActions.add(new LinkManagementHelper.PublicKeyCopier(item)); @@ -277,6 +287,38 @@ list.repaint(); } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == sortItem) { + + Vector v; + + if (full) { + v = new Vector(linkList.length); + + for (int i = 0 ; i < linkList.length ; i++) { + if (linkList[i] != null) + v.add(linkList[i]); + } + } else + v = vList; + + java.util.Collections.sort(v); + + if (full) { + for (int i = 0 ; i < linkList.length ; i++) { + linkList[i] = null; + } + + v.toArray(linkList); + } else + vList = v; + + refresh(); + } + } + + public void mouseClicked(final MouseEvent e) { Vector selection; From jflesch at freenetproject.org Sun Apr 1 14:28:09 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 1 Apr 2007 14:28:09 +0000 (UTC) Subject: [Thaw-dev] r12511 - in trunk/apps/Thaw/src/thaw: i18n plugins/index Message-ID: <20070401142809.58AA5479EFC@emu.freenetproject.org> Author: jflesch Date: 2007-04-01 14:28:09 +0000 (Sun, 01 Apr 2007) New Revision: 12511 Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java Log: Add a warning when trying to copy the public key of an index not inserted Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-01 13:56:29 UTC (rev 12510) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-01 14:28:09 UTC (rev 12511) @@ -324,8 +324,10 @@ thaw.plugin.index.editBlackList=Editer la liste noire d'indexes thaw.plugin.index.addToBlackList=Ajouter ? la liste noire d'indexes +thaw.plugin.index.stillRev0=N'oubliez pas d'ins?rer cet index sur Freenet avant de donner la clef ? quelqu'un + thaw.plugin.peerMonitor.peerMonitor=Connexion thaw.plugin.peerMonitor.yourReference=Votre r?f?rence: thaw.plugin.peerMonitor.copyReference=Copier votre r?f?rence vers le presse-papier Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-01 13:56:29 UTC (rev 12510) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-01 14:28:09 UTC (rev 12511) @@ -318,7 +318,9 @@ thaw.plugin.index.ultimateWarning=You're about to delete all your indexes ! ARE YOU SURE ? +thaw.plugin.index.stillRev0=Don't forget to insert this index on Freenet before giving the key to someone + thaw.plugin.peerMonitor.peerMonitor=Connection thaw.plugin.peerMonitor.yourReference=Your reference: thaw.plugin.peerMonitor.copyReference=Copy your reference to the clipboard Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-01 13:56:29 UTC (rev 12510) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-01 14:28:09 UTC (rev 12511) @@ -324,8 +324,10 @@ thaw.plugin.index.editBlackList=Editer la liste noire d'indexes thaw.plugin.index.addToBlackList=Ajouter \u00e0 la liste noire d'indexes +thaw.plugin.index.stillRev0=N'oubliez pas d'ins\u00e9rer cet index sur Freenet avant de donner la clef \u00e0 quelqu'un + thaw.plugin.peerMonitor.peerMonitor=Connexion thaw.plugin.peerMonitor.yourReference=Votre r\u00e9f\u00e9rence: thaw.plugin.peerMonitor.copyReference=Copier votre r\u00e9f\u00e9rence vers le presse-papier Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-04-01 13:56:29 UTC (rev 12510) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-04-01 14:28:09 UTC (rev 12511) @@ -847,6 +847,12 @@ if (node == null) return; + if (node instanceof Index) { + if (((Index)node).getRevision() <= 0) { + new thaw.core.WarningWindow(null, I18n.getMessage("thaw.plugin.index.stillRev0")); + } + } + thaw.gui.GUIHelper.copyToClipboard(node.getPublicKey()); } From jflesch at freenetproject.org Sun Apr 1 14:34:14 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 1 Apr 2007 14:34:14 +0000 (UTC) Subject: [Thaw-dev] r12512 - in trunk/apps/Thaw/src/thaw: core gui plugins plugins/fetchPlugin plugins/index plugins/insertPlugin Message-ID: <20070401143414.B561A479F2E@emu.freenetproject.org> Author: jflesch Date: 2007-04-01 14:34:14 +0000 (Sun, 01 Apr 2007) New Revision: 12512 Added: trunk/apps/Thaw/src/thaw/gui/WarningWindow.java Removed: trunk/apps/Thaw/src/thaw/core/WarningWindow.java Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java trunk/apps/Thaw/src/thaw/core/Core.java trunk/apps/Thaw/src/thaw/core/MainWindow.java trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/FetchPanel.java trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java Log: Move WarningWindow class from the core package to the gui package Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-04-01 14:28:09 UTC (rev 12511) +++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-04-01 14:34:14 UTC (rev 12512) @@ -215,7 +215,7 @@ core.getPluginManager().stopPlugins(); if (resetConnection && !core.initConnection()) { - new WarningWindow(core, I18n.getMessage("thaw.warning.unableToConnectTo")+ " "+core.getConfig().getValue("nodeAddress")+":"+ core.getConfig().getValue("nodePort")); + new thaw.gui.WarningWindow(core, I18n.getMessage("thaw.warning.unableToConnectTo")+ " "+core.getConfig().getValue("nodeAddress")+":"+ core.getConfig().getValue("nodePort")); } needConnectionReset = false; Modified: trunk/apps/Thaw/src/thaw/core/Core.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/Core.java 2007-04-01 14:28:09 UTC (rev 12511) +++ trunk/apps/Thaw/src/thaw/core/Core.java 2007-04-01 14:34:14 UTC (rev 12512) @@ -175,9 +175,9 @@ splashScreen.setProgressionAndStatus(20, "Connecting ..."); splashScreen.addIcon(IconBox.connectAction); if(!initConnection()) - new WarningWindow(this, I18n.getMessage("thaw.warning.unableToConnectTo")+ - " "+ config.getValue("nodeAddress")+ - ":"+ config.getValue("nodePort")); + new thaw.gui.WarningWindow(this, I18n.getMessage("thaw.warning.unableToConnectTo")+ + " "+ config.getValue("nodeAddress")+ + ":"+ config.getValue("nodePort")); splashScreen.setProgressionAndStatus(30, "Preparing the main window ..."); Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/MainWindow.java 2007-04-01 14:28:09 UTC (rev 12511) +++ trunk/apps/Thaw/src/thaw/core/MainWindow.java 2007-04-01 14:34:14 UTC (rev 12512) @@ -451,9 +451,9 @@ * Warns the user by a popup. */ protected void unableToConnect() { - new WarningWindow(core, - I18n.getMessage("thaw.warning.unableToConnectTo")+ - " "+core.getConfig().getValue("nodeAddress")+":"+ core.getConfig().getValue("nodePort")); + new thaw.gui.WarningWindow(core, + I18n.getMessage("thaw.warning.unableToConnectTo")+ + " "+core.getConfig().getValue("nodeAddress")+":"+ core.getConfig().getValue("nodePort")); } public void update(final java.util.Observable o, final Object arg) { Modified: trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java 2007-04-01 14:28:09 UTC (rev 12511) +++ trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java 2007-04-01 14:34:14 UTC (rev 12512) @@ -156,11 +156,11 @@ !paramFields[0].getText().equals(currentValues[0]) && !"127.0.0.1".equals(paramFields[0].getText())) { - new WarningWindow(core, - I18n.getMessage("thaw.config.sameComputerButNotLocalhost.l0")+"\n"+ - I18n.getMessage("thaw.config.sameComputerButNotLocalhost.l1")+"\n"+ - I18n.getMessage("thaw.config.sameComputerButNotLocalhost.l2")+"\n\n"+ - I18n.getMessage("thaw.config.sameComputerButNotLocalhost.l4")); + new thaw.gui.WarningWindow(core, + I18n.getMessage("thaw.config.sameComputerButNotLocalhost.l0")+"\n"+ + I18n.getMessage("thaw.config.sameComputerButNotLocalhost.l1")+"\n"+ + I18n.getMessage("thaw.config.sameComputerButNotLocalhost.l2")+"\n\n"+ + I18n.getMessage("thaw.config.sameComputerButNotLocalhost.l4")); } } @@ -214,4 +214,4 @@ if(!hasBeenCancelled) resetValues(); } -} \ No newline at end of file +} Deleted: trunk/apps/Thaw/src/thaw/core/WarningWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/WarningWindow.java 2007-04-01 14:28:09 UTC (rev 12511) +++ trunk/apps/Thaw/src/thaw/core/WarningWindow.java 2007-04-01 14:34:14 UTC (rev 12512) @@ -1,29 +0,0 @@ -package thaw.core; - -import javax.swing.JOptionPane; - -/** - * Use to create a warning popup. - * Currently this popup is simple as possible, but - * in the future, it may become more complex, showing, - * for example, last log messages. - */ -public class WarningWindow { - - - public WarningWindow(final Core core, - final String warning) - { - if((core != null) && (core.getMainWindow() != null)) { - JOptionPane.showMessageDialog(core.getMainWindow().getMainFrame(), - warning, - "Thaw - "+I18n.getMessage("thaw.warning.title"), - JOptionPane.WARNING_MESSAGE); - } else { - JOptionPane.showMessageDialog(null, - warning, - "Thaw - "+I18n.getMessage("thaw.warning.title"), - JOptionPane.WARNING_MESSAGE); - } - } -} Copied: trunk/apps/Thaw/src/thaw/gui/WarningWindow.java (from rev 12507, trunk/apps/Thaw/src/thaw/core/WarningWindow.java) =================================================================== --- trunk/apps/Thaw/src/thaw/gui/WarningWindow.java (rev 0) +++ trunk/apps/Thaw/src/thaw/gui/WarningWindow.java 2007-04-01 14:34:14 UTC (rev 12512) @@ -0,0 +1,32 @@ +package thaw.gui; + +import javax.swing.JOptionPane; + +import thaw.core.Core; +import thaw.core.I18n; + +/** + * Use to create a warning popup. + * Currently this popup is simple as possible, but + * in the future, it may become more complex, showing, + * for example, last log messages. + */ +public class WarningWindow { + + + public WarningWindow(final Core core, + final String warning) + { + if((core != null) && (core.getMainWindow() != null)) { + JOptionPane.showMessageDialog(core.getMainWindow().getMainFrame(), + warning, + "Thaw - "+I18n.getMessage("thaw.warning.title"), + JOptionPane.WARNING_MESSAGE); + } else { + JOptionPane.showMessageDialog(null, + warning, + "Thaw - "+I18n.getMessage("thaw.warning.title"), + JOptionPane.WARNING_MESSAGE); + } + } +} Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2007-04-01 14:28:09 UTC (rev 12511) +++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2007-04-01 14:34:14 UTC (rev 12512) @@ -133,13 +133,13 @@ fetchFrame.setVisible(false); if (trollDetected) { - new thaw.core.WarningWindow(core, - I18n.getMessage("thaw.plugin.fetch.freenet0.5.l1")+"\n" - + I18n.getMessage("thaw.plugin.fetch.freenet0.5.l2")+"\n" - + I18n.getMessage("thaw.plugin.fetch.freenet0.5.l3")+"\n" - + I18n.getMessage("thaw.plugin.fetch.freenet0.5.l4")+"\n" - + I18n.getMessage("thaw.plugin.fetch.freenet0.5.l5")+"\n" - + I18n.getMessage("thaw.plugin.fetch.freenet0.5.l6")); + new thaw.gui.WarningWindow(core, + I18n.getMessage("thaw.plugin.fetch.freenet0.5.l1")+"\n" + + I18n.getMessage("thaw.plugin.fetch.freenet0.5.l2")+"\n" + + I18n.getMessage("thaw.plugin.fetch.freenet0.5.l3")+"\n" + + I18n.getMessage("thaw.plugin.fetch.freenet0.5.l4")+"\n" + + I18n.getMessage("thaw.plugin.fetch.freenet0.5.l5")+"\n" + + I18n.getMessage("thaw.plugin.fetch.freenet0.5.l6")); } } Modified: trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2007-04-01 14:28:09 UTC (rev 12511) +++ trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2007-04-01 14:34:14 UTC (rev 12512) @@ -14,10 +14,11 @@ import thaw.core.I18n; import thaw.gui.IconBox; import thaw.core.Logger; -import thaw.core.WarningWindow; +import thaw.gui.WarningWindow; import thaw.fcp.FCPClientPut; import thaw.plugins.insertPlugin.InsertPanel; + public class InsertPlugin implements thaw.core.Plugin, ActionListener { private Core core; Modified: trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/FetchPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/FetchPanel.java 2007-04-01 14:28:09 UTC (rev 12511) +++ trunk/apps/Thaw/src/thaw/plugins/fetchPlugin/FetchPanel.java 2007-04-01 14:34:14 UTC (rev 12512) @@ -25,7 +25,7 @@ import thaw.gui.GUIHelper; import thaw.core.I18n; import thaw.core.Logger; -import thaw.core.WarningWindow; +import thaw.gui.WarningWindow; import thaw.plugins.FetchPlugin; public class FetchPanel implements java.awt.event.ActionListener, MouseListener { @@ -217,7 +217,7 @@ } if((destinationField.getText() == null) || "".equals( destinationField.getText() )) { - new thaw.core.WarningWindow(core, I18n.getMessage("thaw.plugin.fetch.chooseADestination")); + new WarningWindow(core, I18n.getMessage("thaw.plugin.fetch.chooseADestination")); return; } Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-04-01 14:28:09 UTC (rev 12511) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-04-01 14:34:14 UTC (rev 12512) @@ -849,7 +849,7 @@ if (node instanceof Index) { if (((Index)node).getRevision() <= 0) { - new thaw.core.WarningWindow(null, I18n.getMessage("thaw.plugin.index.stillRev0")); + new thaw.gui.WarningWindow(null, I18n.getMessage("thaw.plugin.index.stillRev0")); } } Modified: trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java 2007-04-01 14:28:09 UTC (rev 12511) +++ trunk/apps/Thaw/src/thaw/plugins/insertPlugin/InsertPanel.java 2007-04-01 14:34:14 UTC (rev 12512) @@ -27,7 +27,7 @@ import thaw.core.FileChooser; import thaw.core.I18n; import thaw.core.Logger; -import thaw.core.WarningWindow; +import thaw.gui.WarningWindow; import thaw.fcp.FCPClientPut; import thaw.plugins.InsertPlugin; From jflesch at freenetproject.org Sun Apr 1 15:09:39 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sun, 1 Apr 2007 15:09:39 +0000 (UTC) Subject: [Thaw-dev] r12513 - in trunk/apps/Thaw/src/thaw: fcp i18n plugins plugins/peerMonitor Message-ID: <20070401150939.33B4A47919E@emu.freenetproject.org> Author: jflesch Date: 2007-04-01 15:09:39 +0000 (Sun, 01 Apr 2007) New Revision: 12513 Added: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/Peer.java trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java Modified: trunk/apps/Thaw/src/thaw/fcp/FCPGetNode.java trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java trunk/apps/Thaw/src/thaw/plugins/StatusBar.java trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java Log: Implement a thread counter in the PeerMonitor panel Modified: trunk/apps/Thaw/src/thaw/fcp/FCPGetNode.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPGetNode.java 2007-04-01 14:34:14 UTC (rev 12512) +++ trunk/apps/Thaw/src/thaw/fcp/FCPGetNode.java 2007-04-01 15:09:39 UTC (rev 12513) @@ -37,7 +37,10 @@ public final static String netSizeSessionElement = "volatile.networkSizeEstimateSession"; private int netSizeSession = 0; + public final static String nmbThreadsElement = "volatile.runningThreadCount"; + private int nmbThreads = 0; + private boolean withPrivate; private boolean withVolatile; @@ -98,6 +101,9 @@ if (msg.getValue(usedMemElement) != null) usedMem = Long.parseLong(msg.getValue(usedMemElement)); + + if (msg.getValue(nmbThreadsElement) != null) + nmbThreads = Integer.parseInt(msg.getValue(nmbThreadsElement)); } allParameters = msg.getValues(); @@ -120,6 +126,10 @@ return usedMem; } + public int getNmbThreads() { + return nmbThreads; + } + public Hashtable getAllParameters() { return allParameters; } Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-01 14:34:14 UTC (rev 12512) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-01 15:09:39 UTC (rev 12513) @@ -349,12 +349,14 @@ thaw.plugin.peerMonitor.infos.node.uptimeSeconds=Uptime thaw.plugin.peerMonitor.infos.node.networkSizeEstimateSession=Estimation de la taille du r?seau thaw.plugin.peerMonitor.infos.node.myName=Nom du noeud + thaw.plugin.peerMonitor.infos.nodeMemory=Memoire du noeud thaw.plugin.peerMonitor.infos.thawMemory=Memoire de Thaw +thaw.plugin.peerMonitor.infos.nodeThreads=Threads (node) +thaw.plugin.peerMonitor.infos.thawThreads=Threads (Thaw) - thaw.plugin.themeSelector.themeSelector=S?lecteur de th?me thaw.plugin.themeSelector.selectATheme=Selectionnez un th?me: thaw.plugin.themeSelector.theme=Th?me Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-01 14:34:14 UTC (rev 12512) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-01 15:09:39 UTC (rev 12513) @@ -97,6 +97,7 @@ thaw.statusBar.disconnected=DISCONNECTED thaw.statusBar.connecting=Connecting ... + ## Config thaw.config.windowName=Configuration thaw.config.okButton=Ok @@ -345,9 +346,10 @@ thaw.plugin.peerMonitor.infos.nodeMemory=Node memory thaw.plugin.peerMonitor.infos.thawMemory=Thaw memory +thaw.plugin.peerMonitor.infos.nodeThreads=Node threads +thaw.plugin.peerMonitor.infos.thawThreads=Thaw threads - thaw.plugin.themeSelector.themeSelector=Theme selector thaw.plugin.themeSelector.selectATheme=Select a theme: thaw.plugin.themeSelector.theme=Theme Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-01 14:34:14 UTC (rev 12512) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-01 15:09:39 UTC (rev 12513) @@ -349,12 +349,14 @@ thaw.plugin.peerMonitor.infos.node.uptimeSeconds=Uptime thaw.plugin.peerMonitor.infos.node.networkSizeEstimateSession=Estimation de la taille du r\u00e9seau thaw.plugin.peerMonitor.infos.node.myName=Nom du noeud + thaw.plugin.peerMonitor.infos.nodeMemory=Memoire du noeud thaw.plugin.peerMonitor.infos.thawMemory=Memoire de Thaw +thaw.plugin.peerMonitor.infos.nodeThreads=Threads (node) +thaw.plugin.peerMonitor.infos.thawThreads=Threads (Thaw) - thaw.plugin.themeSelector.themeSelector=S\u00e9lecteur de th\u00e8me thaw.plugin.themeSelector.selectATheme=Selectionnez un th\u00e8me: thaw.plugin.themeSelector.theme=Th\u00e8me Modified: trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java 2007-04-01 14:34:14 UTC (rev 12512) +++ trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java 2007-04-01 15:09:39 UTC (rev 12513) @@ -27,6 +27,7 @@ private boolean advancedMode; + public PeerMonitor() { } @@ -76,6 +77,7 @@ FCPGetNode gN = (FCPGetNode)o; peerPanel.setMemBar(gN.getUsedJavaMemory(), gN.getMaxJavaMemory()); + peerPanel.setNmbThreads(gN.getNmbThreads()); peerPanel.setNodeInfos(gN.getAllParameters()); if (!isRefSet) { Modified: trunk/apps/Thaw/src/thaw/plugins/StatusBar.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/StatusBar.java 2007-04-01 14:34:14 UTC (rev 12512) +++ trunk/apps/Thaw/src/thaw/plugins/StatusBar.java 2007-04-01 15:09:39 UTC (rev 12513) @@ -123,6 +123,10 @@ + Integer.toString(progressDone) + "/" + Integer.toString(progressTotal); } + + int nmbThread = Thread.activeCount(); + + status = status + StatusBar.SEPARATOR + I18n.getMessage("thaw.plugin.statistics.finished")+ " " + Integer.toString(finished) + "/" + Integer.toString(total) Added: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/Peer.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/Peer.java (rev 0) +++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/Peer.java 2007-04-01 15:09:39 UTC (rev 12513) @@ -0,0 +1,42 @@ +package thaw.plugins.peerMonitor; + + +import java.awt.Color; + +import java.util.Hashtable; + + +public class Peer { + + private String displayName = null; + private Color textColor = Color.BLACK; + private Hashtable parameters = null; + + public Peer(Hashtable parameters) { + this.parameters = parameters; + displayName = (String)parameters.get("myName"); + + String status = (String)parameters.get("volatile.status"); + + for (int i = 0 ; i < PeerMonitorPanel.STR_STATUS.length ; i++) { + if (PeerMonitorPanel.STR_STATUS[i].equals(status)) + setTextColor(PeerMonitorPanel.COLOR_STATUS[i]); + } + } + + public void setTextColor(Color c) { + textColor = c; + } + + public Color getTextColor() { + return textColor; + } + + public Hashtable getParameters() { + return parameters; + } + + public String toString() { + return displayName; + } +} Added: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java (rev 0) +++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java 2007-04-01 15:09:39 UTC (rev 12513) @@ -0,0 +1,9 @@ +package thaw.plugins.peerMonitor; + + +public class PeerHelper { + + + +} + Modified: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java 2007-04-01 14:34:14 UTC (rev 12512) +++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java 2007-04-01 15:09:39 UTC (rev 12513) @@ -41,7 +41,6 @@ */ public class PeerMonitorPanel extends Observable implements ActionListener, ListSelectionListener { - /* must match with color list */ public final static String[] STR_STATUS = { "CONNECTED", "BACKED OFF", @@ -82,6 +81,9 @@ private JProgressBar thawMemBar; private JProgressBar nodeMemBar; + private JLabel nodeThreads; + private JLabel thawThreads; + private JLabel detailsLabel; private JPanel detailsPanel; @@ -120,13 +122,20 @@ setMemBar(0, 134217728); + nodeThreads = new JLabel(""); + thawThreads = new JLabel(""); + JPanel threadPanel = new JPanel(new GridLayout(1, 2)); + threadPanel.add(nodeThreads); + threadPanel.add(thawThreads); + peerPanel.add(peerListLabel, BorderLayout.NORTH); peerPanel.add(new JScrollPane(peerList), BorderLayout.CENTER); - JPanel memPanel = new JPanel(new GridLayout(2, 1)); + JPanel memPanel = new JPanel(new GridLayout(3, 1)); memPanel.add(nodeMemBar); memPanel.add(thawMemBar); + memPanel.add(threadPanel); peerPanel.add(memPanel, BorderLayout.SOUTH); @@ -206,47 +215,20 @@ } - public void setRef(String ref) { - refArea.setText(ref); + public void setNmbThreads(int nmbNodeThreads) { + nodeThreads.setText(I18n.getMessage("thaw.plugin.peerMonitor.infos.nodeThreads") + + ": "+ Integer.toString(nmbNodeThreads)); + thawThreads.setText(I18n.getMessage("thaw.plugin.peerMonitor.infos.thawThreads") + + ": "+ Integer.toString(Thread.activeCount())); } - - protected class Peer { - private String displayName = null; - private Color textColor = Color.BLACK; - private Hashtable parameters = null; - - public Peer(Hashtable parameters) { - this.parameters = parameters; - displayName = (String)parameters.get("myName"); - - String status = (String)parameters.get("volatile.status"); - - for (int i = 0 ; i < STR_STATUS.length ; i++) { - if (STR_STATUS[i].equals(status)) - setTextColor(COLOR_STATUS[i]); - } - } - - public void setTextColor(Color c) { - textColor = c; - } - - public Color getTextColor() { - return textColor; - } - - public Hashtable getParameters() { - return parameters; - } - - public String toString() { - return displayName; - } + public void setRef(String ref) { + refArea.setText(ref); } + protected class PeerCellRenderer extends JLabel implements ListCellRenderer { public PeerCellRenderer() { From jflesch at freenetproject.org Mon Apr 2 11:33:12 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Mon, 2 Apr 2007 11:33:12 +0000 (UTC) Subject: [Thaw-dev] r12522 - in trunk/apps/Thaw/src/thaw: i18n plugins plugins/index plugins/peerMonitor plugins/queueWatcher Message-ID: <20070402113312.53B84479FBC@emu.freenetproject.org> Author: jflesch Date: 2007-04-02 11:33:12 +0000 (Mon, 02 Apr 2007) New Revision: 12522 Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java Log: Fix index creation Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-02 00:53:44 UTC (rev 12521) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-02 11:33:12 UTC (rev 12522) @@ -336,6 +336,11 @@ thaw.plugin.peerMonitor.nodeInfos=Informations sur votre noeud : thaw.plugin.peerMonitor.peerInfos=Informations relatives au peer + +thaw.plugin.peerMonitor.addPeer=Ajouter un peer +thaw.plugin.peerMonitor.removePeer=Enlever ce peer +thaw.plugin.peerMonitor.enterRef=R?f?rence: + thaw.plugin.peerMonitor.infos.peer.lastRoutingBackoffReason=Dernier motif de saturation thaw.plugin.peerMonitor.infos.peer.routingBackoffPercent=Pourcentage de saturation thaw.plugin.peerMonitor.infos.peer.version=Version du noeud @@ -349,6 +354,7 @@ thaw.plugin.peerMonitor.infos.node.uptimeSeconds=Uptime thaw.plugin.peerMonitor.infos.node.networkSizeEstimateSession=Estimation de la taille du r?seau thaw.plugin.peerMonitor.infos.node.myName=Nom du noeud +thaw.plugin.peerMonitor.infos.node.runningThreads=Nombre de threads thaw.plugin.peerMonitor.infos.nodeMemory=Memoire du noeud thaw.plugin.peerMonitor.infos.thawMemory=Memoire de Thaw Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-02 00:53:44 UTC (rev 12521) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-02 11:33:12 UTC (rev 12522) @@ -343,12 +343,16 @@ thaw.plugin.peerMonitor.infos.node.uptimeSeconds=Uptime thaw.plugin.peerMonitor.infos.node.networkSizeEstimateSession=Network size estimation thaw.plugin.peerMonitor.infos.node.myName=Node name +thaw.plugin.peerMonitor.infos.node.runningThreads=Running threads thaw.plugin.peerMonitor.infos.nodeMemory=Node memory thaw.plugin.peerMonitor.infos.thawMemory=Thaw memory thaw.plugin.peerMonitor.infos.nodeThreads=Node threads thaw.plugin.peerMonitor.infos.thawThreads=Thaw threads +thaw.plugin.peerMonitor.addPeer=Add a peer +thaw.plugin.peerMonitor.removePeer=Remove this peer +thaw.plugin.peerMonitor.enterRef=Reference: thaw.plugin.themeSelector.themeSelector=Theme selector thaw.plugin.themeSelector.selectATheme=Select a theme: Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-02 00:53:44 UTC (rev 12521) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-02 11:33:12 UTC (rev 12522) @@ -336,6 +336,11 @@ thaw.plugin.peerMonitor.nodeInfos=Informations sur votre noeud : thaw.plugin.peerMonitor.peerInfos=Informations relatives au peer + +thaw.plugin.peerMonitor.addPeer=Ajouter un peer +thaw.plugin.peerMonitor.removePeer=Enlever ce peer +thaw.plugin.peerMonitor.enterRef=R\u00e9f\u00e9rence: + thaw.plugin.peerMonitor.infos.peer.lastRoutingBackoffReason=Dernier motif de saturation thaw.plugin.peerMonitor.infos.peer.routingBackoffPercent=Pourcentage de saturation thaw.plugin.peerMonitor.infos.peer.version=Version du noeud @@ -349,6 +354,7 @@ thaw.plugin.peerMonitor.infos.node.uptimeSeconds=Uptime thaw.plugin.peerMonitor.infos.node.networkSizeEstimateSession=Estimation de la taille du r\u00e9seau thaw.plugin.peerMonitor.infos.node.myName=Nom du noeud +thaw.plugin.peerMonitor.infos.node.runningThreads=Nombre de threads thaw.plugin.peerMonitor.infos.nodeMemory=Memoire du noeud thaw.plugin.peerMonitor.infos.thawMemory=Memoire de Thaw Modified: trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java 2007-04-02 00:53:44 UTC (rev 12521) +++ trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java 2007-04-02 11:33:12 UTC (rev 12522) @@ -102,7 +102,7 @@ advancedMode = Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue(); - peerPanel = new PeerMonitorPanel(core.getConfig()); + peerPanel = new PeerMonitorPanel(core.getQueueManager(), core.getConfig(), core.getMainWindow()); core.getMainWindow().addTab(I18n.getMessage("thaw.plugin.peerMonitor.peerMonitor"), thaw.gui.IconBox.minPeerMonitor, Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2007-04-02 00:53:44 UTC (rev 12521) +++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2007-04-02 11:33:12 UTC (rev 12522) @@ -37,7 +37,7 @@ private JSplitPane split; - private final static int DIVIDER_LOCATION = 310; /* about the details panel */ + public final static int DIVIDER_LOCATION = 250; /* about the details panel */ private long lastChange = 0; private boolean folded = false; Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-04-02 00:53:44 UTC (rev 12521) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-04-02 11:33:12 UTC (rev 12522) @@ -54,6 +54,7 @@ return JOptionPane.showInputDialog(parent, prompt, defVal); } + /** * Class implementing IndexAction will automatically do an addActionListener if necessary */ @@ -191,7 +192,7 @@ " publicKey, privateKey, author, "+ " positionInTree, revision, "+ " newRev, parent) "+ - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); /* TODO : Author */ @@ -214,7 +215,7 @@ if (getTarget().getId() >= 0) st.setInt(10, getTarget().getId()); else - st.setNull(11, Types.INTEGER); + st.setNull(10, Types.INTEGER); st.execute(); @@ -318,7 +319,7 @@ publishPrivateKeyBox = new JCheckBox(I18n.getMessage("thaw.plugin.index.publishPrivateKey"), defaultPublishPrivateKey); publishPrivateKeyBox.setEnabled(enablePublishPrivateKeyChoice); - final JPanel subPanelA = new JPanel(); /* left => labels */ + final JPanel subPanelA = new JPanel(); /* left => labels */ final JPanel subPanelB = new JPanel(); /* right => textfield */ subPanelA.setLayout(new GridLayout(askPrivateKey ? 2 : 1, 1)); Modified: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java 2007-04-02 00:53:44 UTC (rev 12521) +++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerHelper.java 2007-04-02 11:33:12 UTC (rev 12522) @@ -1,9 +1,120 @@ package thaw.plugins.peerMonitor; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JLabel; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import javax.swing.JTextArea; +import javax.swing.JButton; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +import javax.swing.AbstractButton; + + +import thaw.fcp.*; /* I'm lazy */ +import thaw.core.MainWindow; +import thaw.core.I18n; + public class PeerHelper { + public interface PeerAction extends ActionListener { + public void setTarget(Peer peer); + } + public static class PeerAdder implements PeerAction { + private FCPQueueManager queueManager; + private AbstractButton src; + private MainWindow mainWindow; + + private JDialog dialog; + private JButton okButton; + private JButton cancelButton; + private JTextArea refArea; + + public PeerAdder(FCPQueueManager queueManager, MainWindow mainWindow, AbstractButton actionSource) { + this.queueManager = queueManager; + this.src = actionSource; + this.mainWindow = mainWindow; + + if (actionSource != null) + actionSource.addActionListener(this); + } + + public void setTarget(Peer peer) { + /* we ignore */ + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == src) { + dialog = new JDialog(mainWindow.getMainFrame(), + I18n.getMessage("thaw.plugin.peerMonitor.addPeer")); + + dialog.setLayout(new BorderLayout()); + + JPanel buttonPanel = new JPanel(new GridLayout(1, 2)); + + okButton = new JButton(I18n.getMessage("thaw.common.ok")); + okButton.addActionListener(this); + buttonPanel.add(okButton); + + cancelButton = new JButton(I18n.getMessage("thaw.common.cancel")); + cancelButton.addActionListener(this); + buttonPanel.add(cancelButton); + + refArea = new JTextArea(""); + + JLabel label = new JLabel(I18n.getMessage("thaw.plugin.peerMonitor.enterRef")); + + dialog.getContentPane().add(label, BorderLayout.NORTH); + dialog.getContentPane().add(refArea, BorderLayout.CENTER); + dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH); + + dialog.setSize(700, 300); + dialog.setVisible(true); + + return; + } + + + if (e.getSource() == okButton) { + /* TODO */ + dialog.setVisible(false); + } + + if (e.getSource() == cancelButton) { + dialog.setVisible(false); + } + } + } + + + public static class PeerRemover implements PeerAction { + private FCPQueueManager queueManager; + private AbstractButton src; + + public PeerRemover(FCPQueueManager queueManager, AbstractButton actionSource) { + this.queueManager = queueManager; + this.src = actionSource; + + if (actionSource != null) + actionSource.addActionListener(this); + } + + public void setTarget(Peer peer) { + if (src != null) { + src.setEnabled(peer != null); + } + } + + public void actionPerformed(ActionEvent e) { + /* TODO */ + } + } + } Modified: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java 2007-04-02 00:53:44 UTC (rev 12521) +++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java 2007-04-02 11:33:12 UTC (rev 12522) @@ -10,8 +10,14 @@ import javax.swing.ListCellRenderer; import javax.swing.BorderFactory; +import javax.swing.JMenu; +import javax.swing.JPopupMenu; +import javax.swing.JMenuItem; + import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; @@ -33,13 +39,15 @@ import thaw.core.I18n; import thaw.core.Logger; +import thaw.fcp.FCPQueueManager; + import thaw.gui.IconBox; /** * In fact, here is two panels : A panel with the peer list * and a panel with various details (ref, etc) */ -public class PeerMonitorPanel extends Observable implements ActionListener, ListSelectionListener +public class PeerMonitorPanel extends Observable implements ActionListener, MouseListener { public final static String[] STR_STATUS = { "CONNECTED", @@ -87,10 +95,15 @@ private JLabel detailsLabel; private JPanel detailsPanel; + + private JPopupMenu rightClickMenu; + private Vector rightClickActions; + + private boolean advanced; - public PeerMonitorPanel(Config config) { + public PeerMonitorPanel(FCPQueueManager queueManager, Config config, thaw.core.MainWindow mainWindow) { advanced = Boolean.valueOf(config.getValue("advancedMode")).booleanValue(); @@ -101,7 +114,7 @@ peerList = new JList(); peerList.setCellRenderer(new PeerCellRenderer()); - peerList.addListSelectionListener(this); + //peerList.addListSelectionListener(this); Vector v = new Vector(); @@ -174,6 +187,25 @@ mainPanel.add(refPanel); tabPanel.add(mainPanel, BorderLayout.CENTER); + + + rightClickMenu = new JPopupMenu(); + rightClickActions = new Vector(); + + JMenuItem item; + + item = new JMenuItem(I18n.getMessage("thaw.plugin.peerMonitor.addPeer"), + IconBox.minAdd); + rightClickActions.add(new PeerHelper.PeerAdder(queueManager, mainWindow, item)); + rightClickMenu.add(item); + + + item = new JMenuItem(I18n.getMessage("thaw.plugin.peerMonitor.removePeer"), + IconBox.minDelete); + rightClickActions.add(new PeerHelper.PeerRemover(queueManager, item)); + rightClickMenu.add(item); + + peerList.addMouseListener(this); } @@ -217,9 +249,9 @@ public void setNmbThreads(int nmbNodeThreads) { nodeThreads.setText(I18n.getMessage("thaw.plugin.peerMonitor.infos.nodeThreads") - + ": "+ Integer.toString(nmbNodeThreads)); + + " : "+ Integer.toString(nmbNodeThreads)); thawThreads.setText(I18n.getMessage("thaw.plugin.peerMonitor.infos.thawThreads") - + ": "+ Integer.toString(Thread.activeCount())); + + " : "+ Integer.toString(Thread.activeCount())); } @@ -277,7 +309,7 @@ private Hashtable nodeInfos = null; /** - * \param peers : Vectors containing Hashmap containing the parameter list + * \param peers : Hashtable containing Hashtable containing the parameter list */ public synchronized void setPeerList(Hashtable pL) { @@ -406,6 +438,13 @@ }; } + if (result == null && "volatile.runningThreadCount".equals(key)) { + result = new String[] { + I18n.getMessage("thaw.plugin.peerMonitor.infos.node.runningThreads"), + value + }; + } + if (result == null && "myName".equals(key)) { result = new String[] { I18n.getMessage("thaw.plugin.peerMonitor.infos.node.myName"), @@ -413,12 +452,14 @@ }; } - if (advanced) { - if (result == null) - result = new String[] { key, value }; - else - result[0] = result[0] + " ("+key+")"; - } + /* + if (advanced) { + if (result == null) + result = new String[] { key, value }; + else + result[0] = result[0] + " ("+key+")"; + } + */ return result; } @@ -469,8 +510,9 @@ } - public void valueChanged(ListSelectionEvent e) { - if (e.getFirstIndex() == 0 && advanced) { + private void clicked() { + if (peerList.getSelectedValue() == null + || !(peerList.getSelectedValue() instanceof Peer)) { displayInfos(I18n.getMessage("thaw.plugin.peerMonitor.nodeInfos"), nodeInfos); } else { Peer peer; @@ -487,4 +529,38 @@ setChanged(); notifyObservers(); } + + + public void updateMenuState(Peer target) { + for (Iterator it = rightClickActions.iterator(); + it.hasNext();) { + PeerHelper.PeerAction a = ((PeerHelper.PeerAction)it.next()); + a.setTarget(target); + } + } + + + public void mouseClicked(final MouseEvent e) { + clicked(); + } + + public void mouseEntered(final MouseEvent e) { } + public void mouseExited(final MouseEvent e) { } + + public void mousePressed(final MouseEvent e) { + showPopupMenu(e); + } + + public void mouseReleased(final MouseEvent e) { + showPopupMenu(e); + } + + protected void showPopupMenu(final MouseEvent e) { + if(e.isPopupTrigger()) { + updateMenuState(((Peer)peerList.getSelectedValue())); + rightClickMenu.show(e.getComponent(), e.getX(), e.getY()); + } + } + + } Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java 2007-04-02 00:53:44 UTC (rev 12521) +++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/DetailPanel.java 2007-04-02 11:33:12 UTC (rev 12522) @@ -24,21 +24,21 @@ private JPanel subPanel; private JPanel panel; - private final JTextField file = new JTextField(); - private final JTextField size = new JTextField(); - private final JProgressBar progress = new JProgressBar(0, 100); + private final JTextField file = new JTextField(); + private final JTextField size = new JTextField(); + private final JProgressBar progress = new JProgressBar(0, 100); private final JProgressBar withTheNodeProgress = new JProgressBar(0, 100); - private final JTextField status = new JTextField(); - private final JTextField key = new JTextField(); - private final JTextField path = new JTextField(); - private final JTextField priority = new JTextField(); - private final JTextField identifier = new JTextField(); - private final JTextField globalQueue= new JTextField(); + private final JTextField status = new JTextField(); + private final JTextField key = new JTextField(); + private final JTextField path = new JTextField(); + private final JTextField priority = new JTextField(); + private final JTextField identifier = new JTextField(); + private final JTextField globalQueue = new JTextField(); private FCPTransferQuery query = null; - private final static Dimension dim = new Dimension(300, 400); + private final static Dimension dim = new Dimension(thaw.plugins.QueueWatcher.DIVIDER_LOCATION-10, 400); public DetailPanel() { @@ -46,15 +46,15 @@ subPanel = new JPanel(); final String[] fieldNames = { I18n.getMessage("thaw.common.file"), - I18n.getMessage("thaw.common.size"), - I18n.getMessage("thaw.common.progress"), - I18n.getMessage("thaw.common.withTheNodeProgress"), - I18n.getMessage("thaw.common.status"), - I18n.getMessage("thaw.common.key"), - I18n.getMessage("thaw.common.localPath"), - I18n.getMessage("thaw.common.priority"), - I18n.getMessage("thaw.common.identifier"), - I18n.getMessage("thaw.common.globalQueue") + I18n.getMessage("thaw.common.size"), + I18n.getMessage("thaw.common.progress"), + I18n.getMessage("thaw.common.withTheNodeProgress"), + I18n.getMessage("thaw.common.status"), + I18n.getMessage("thaw.common.key"), + I18n.getMessage("thaw.common.localPath"), + I18n.getMessage("thaw.common.priority"), + I18n.getMessage("thaw.common.identifier"), + I18n.getMessage("thaw.common.globalQueue") }; subPanel.setLayout(new GridLayout(fieldNames.length*2, 1)); From jflesch at freenetproject.org Tue Apr 10 19:32:02 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Tue, 10 Apr 2007 19:32:02 +0000 (UTC) Subject: [Thaw-dev] r12566 - in trunk/apps/Thaw/src/thaw: i18n plugins/index plugins/peerMonitor Message-ID: <20070410193202.D9E6D479FA1@emu.freenetproject.org> Author: jflesch Date: 2007-04-10 19:32:02 +0000 (Tue, 10 Apr 2007) New Revision: 12566 Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties trunk/apps/Thaw/src/thaw/plugins/index/Index.java trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java Log: Fix private key reading when loading an index Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-10 16:54:26 UTC (rev 12565) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-10 19:32:02 UTC (rev 12566) @@ -182,8 +182,8 @@ thaw.plugin.statistics.statistics=Statistiques dans la barre de status thaw.plugin.statistics.globalProgression=Progression globale: -thaw.plugin.statistics.finished=Fini: -thaw.plugin.statistics.failed=?chou?: +thaw.plugin.statistics.finished=Finis: +thaw.plugin.statistics.failed=?chou?s: thaw.plugin.statistics.running=En cours: thaw.plugin.statistics.pending=En attente: Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-10 16:54:26 UTC (rev 12565) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-10 19:32:02 UTC (rev 12566) @@ -182,8 +182,8 @@ thaw.plugin.statistics.statistics=Statistiques dans la barre de status thaw.plugin.statistics.globalProgression=Progression globale: -thaw.plugin.statistics.finished=Fini: -thaw.plugin.statistics.failed=\u00c9chou\u00e9: +thaw.plugin.statistics.finished=Finis: +thaw.plugin.statistics.failed=\u00c9chou\u00e9s: thaw.plugin.statistics.running=En cours: thaw.plugin.statistics.pending=En attente: Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-10 16:54:26 UTC (rev 12565) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-10 19:32:02 UTC (rev 12566) @@ -695,7 +695,13 @@ rewriteKey = true; publicKey = getPublicKey(); + String privateKey = getPrivateKey(); + if (rev <= 0 && privateKey != null) { + Logger.error(this, "Can't update an non-inserted index !"); + return 0; + } + if (tree != null && tree.isIndexUpdating(this)) { Logger.notice(this, "A transfer is already running !"); return 0; @@ -1255,7 +1261,15 @@ */ public void endElement(String nameSpaceURI, String localName, String rawName) throws SAXException { - /* \_o< */ + if ("owner".equals(rawName)) { + ownerTag = false; + return; + } + + if ("privateKey".equals(rawName)) { + privateKeyTag = false; + return; + } } @@ -1271,6 +1285,7 @@ if (ownerTag) { /* \_o< ==> TODO */ + return; } @@ -1280,13 +1295,17 @@ * the private key was published, we will have to do the same later */ setPublishPrivateKey(true); + } else { + /** + * the provided key doesn't match with the one we have, + * we won't publish it anymore + */ + Logger.notice(this, "A private key was provided, but didn't match with the one we have ; ignored."); + } - else - setPublishPrivateKey(false); if (privateKey == null) setPrivateKey(txt.trim()); - return; } Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2007-04-10 16:54:26 UTC (rev 12565) +++ trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2007-04-10 19:32:02 UTC (rev 12566) @@ -12,6 +12,7 @@ import java.util.Iterator; import java.util.Vector; +import javax.swing.JComponent; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JMenuItem; @@ -22,7 +23,14 @@ import javax.swing.event.TableModelEvent; import javax.swing.table.DefaultTableCellRenderer; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import javax.swing.SwingConstants; +import javax.swing.TransferHandler; + import thaw.core.I18n; +import thaw.core.Logger; import thaw.gui.IconBox; import thaw.fcp.FCPQueueManager; import thaw.plugins.ToolbarModifier; @@ -61,7 +69,13 @@ table = new JTable(linkListModel); table.setShowGrid(false); table.setDefaultRenderer(table.getColumnClass(0), new LinkRenderer()); + table.setDragEnabled(true); + table.setTransferHandler(new TransferHandler("text")); + + MouseListener mouseListener = new DragMouseAdapter(); /* see below */ + table.addMouseListener(mouseListener); + panel = new JPanel(); panel.setLayout(new BorderLayout()); @@ -113,6 +127,20 @@ updateRightClickMenu(null); } + + private class DragMouseAdapter extends MouseAdapter { + public void mousePressed(MouseEvent e) { + Logger.error(this, "MOOH"); + + JComponent src = (JComponent) e.getSource(); + TransferHandler handler = src.getTransferHandler(); + + handler.exportAsDrag(src, e, TransferHandler.COPY); + + } + } + + public ToolbarModifier getToolbarModifier() { return toolbarModifier; } Modified: trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java 2007-04-10 16:54:26 UTC (rev 12565) +++ trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java 2007-04-10 19:32:02 UTC (rev 12566) @@ -16,7 +16,14 @@ import javax.swing.JPopupMenu; import javax.swing.JScrollPane; +import java.awt.event.MouseAdapter; +import javax.swing.SwingConstants; +import javax.swing.TransferHandler; + +import javax.swing.JComponent; + import thaw.core.I18n; +import thaw.core.Logger; import thaw.gui.IconBox; import thaw.fcp.FCPQueueManager; import thaw.plugins.ToolbarModifier; @@ -64,6 +71,12 @@ list.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + list.setDragEnabled(true); + list.setTransferHandler(new TransferHandler("text")); + + MouseListener mouseListener = new DragMouseAdapter(); /* see below */ + list.addMouseListener(mouseListener); + panel = new JPanel(new BorderLayout()); panel.add(new JLabel(I18n.getMessage("thaw.plugin.index.unknownIndexes")), BorderLayout.NORTH); @@ -83,6 +96,18 @@ list.addMouseListener(this); } + private class DragMouseAdapter extends MouseAdapter { + public void mousePressed(MouseEvent e) { + Logger.error(this, "MOOH"); + + JComponent src = (JComponent) e.getSource(); + TransferHandler handler = src.getTransferHandler(); + + handler.exportAsDrag(src, e, TransferHandler.COPY); + + } + } + public ToolbarModifier getToolbarModifier() { return toolbarModifier; } Modified: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java 2007-04-10 16:54:26 UTC (rev 12565) +++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java 2007-04-10 19:32:02 UTC (rev 12566) @@ -35,10 +35,13 @@ import java.util.Observer; + + import thaw.core.Config; import thaw.core.I18n; import thaw.core.Logger; + import thaw.fcp.FCPQueueManager; import thaw.gui.IconBox; From jflesch at freenetproject.org Wed Apr 11 13:17:11 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 11 Apr 2007 13:17:11 +0000 (UTC) Subject: [Thaw-dev] r12572 - in trunk/apps/Thaw/src/thaw/plugins: . peerMonitor Message-ID: <20070411131711.20CA0479739@emu.freenetproject.org> Author: jflesch Date: 2007-04-11 13:17:11 +0000 (Wed, 11 Apr 2007) New Revision: 12572 Modified: trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java Log: Change PeerMonitor UI behavior Modified: trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java 2007-04-11 13:15:36 UTC (rev 12571) +++ trunk/apps/Thaw/src/thaw/plugins/PeerMonitor.java 2007-04-11 13:17:11 UTC (rev 12572) @@ -102,11 +102,8 @@ advancedMode = Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue(); - peerPanel = new PeerMonitorPanel(core.getQueueManager(), core.getConfig(), core.getMainWindow()); + peerPanel = new PeerMonitorPanel(this, core.getQueueManager(), core.getConfig(), core.getMainWindow()); - core.getMainWindow().addTab(I18n.getMessage("thaw.plugin.peerMonitor.peerMonitor"), - thaw.gui.IconBox.minPeerMonitor, - peerPanel.getTabPanel()); peerPanel.addObserver(this); @@ -142,6 +139,13 @@ public void update(Observable o, Object param) { + core.getMainWindow().addTab(I18n.getMessage("thaw.plugin.peerMonitor.peerMonitor"), + thaw.gui.IconBox.minPeerMonitor, + peerPanel.getTabPanel()); core.getMainWindow().setSelectedTab(peerPanel.getTabPanel()); } + + public void hideTab() { + core.getMainWindow().removeTab(peerPanel.getTabPanel()); + } } Modified: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java 2007-04-11 13:15:36 UTC (rev 12571) +++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java 2007-04-11 13:17:11 UTC (rev 12572) @@ -35,8 +35,8 @@ import java.util.Observer; +import thaw.plugins.PeerMonitor; - import thaw.core.Config; import thaw.core.I18n; import thaw.core.Logger; @@ -102,12 +102,19 @@ private JPopupMenu rightClickMenu; private Vector rightClickActions; + private JButton closeTabButton; private boolean advanced; + private PeerMonitor peerMonitor; - public PeerMonitorPanel(FCPQueueManager queueManager, Config config, thaw.core.MainWindow mainWindow) { + public PeerMonitorPanel(PeerMonitor peerMonitor, + FCPQueueManager queueManager, + Config config, + thaw.core.MainWindow mainWindow) { + this.peerMonitor = peerMonitor; + advanced = Boolean.valueOf(config.getValue("advancedMode")).booleanValue(); tabPanel = new JPanel(new BorderLayout(10, 10)); @@ -121,8 +128,7 @@ Vector v = new Vector(); - if (advanced) - v.add(I18n.getMessage("thaw.plugin.peerMonitor.nodeStats")); + v.add(I18n.getMessage("thaw.plugin.peerMonitor.nodeStats")); peerList.setListData(v); @@ -191,7 +197,16 @@ tabPanel.add(mainPanel, BorderLayout.CENTER); + closeTabButton = new JButton(IconBox.minClose); + closeTabButton.setBorderPainted(false); + closeTabButton.addActionListener(this); + JPanel headPanel = new JPanel(new BorderLayout()); + headPanel.add(new JLabel(""), BorderLayout.CENTER); + headPanel.add(closeTabButton, BorderLayout.EAST); + + tabPanel.add(headPanel, BorderLayout.NORTH); + rightClickMenu = new JPopupMenu(); rightClickActions = new Vector(); @@ -318,8 +333,7 @@ { peers = new Vector(); - if (advanced) - peers.add(I18n.getMessage("thaw.plugin.peerMonitor.nodeStats")); + peers.add(I18n.getMessage("thaw.plugin.peerMonitor.nodeStats")); /* TODO : dirty : should use comparator, etc */ for (int i = 0 ; i < STR_STATUS.length ; i++) { @@ -358,6 +372,10 @@ if (e.getSource() == refCopyButton) { thaw.gui.GUIHelper.copyToClipboard(refArea.getText()); } + + if (e.getSource() == closeTabButton) { + peerMonitor.hideTab(); + } } @@ -560,8 +578,10 @@ protected void showPopupMenu(final MouseEvent e) { if(e.isPopupTrigger()) { - updateMenuState(((Peer)peerList.getSelectedValue())); - rightClickMenu.show(e.getComponent(), e.getX(), e.getY()); + if (peerList.getSelectedValue() instanceof Peer) { + updateMenuState(((Peer)peerList.getSelectedValue())); + rightClickMenu.show(e.getComponent(), e.getX(), e.getY()); + } } } From jflesch at freenetproject.org Wed Apr 11 13:25:01 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 11 Apr 2007 13:25:01 +0000 (UTC) Subject: [Thaw-dev] r12574 - in trunk/apps/Thaw/src/thaw: fcp plugins/index Message-ID: <20070411132501.8BE38479941@emu.freenetproject.org> Author: jflesch Date: 2007-04-11 13:25:01 +0000 (Wed, 11 Apr 2007) New Revision: 12574 Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java trunk/apps/Thaw/src/thaw/plugins/index/Index.java Log: Force Thaw to not use the DDA when downloading indexes Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-04-11 13:21:23 UTC (rev 12573) +++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-04-11 13:25:01 UTC (rev 12574) @@ -45,6 +45,7 @@ private boolean alreadySaved = false; + private boolean noDDA = false; /** * See setParameters(). @@ -107,6 +108,20 @@ /** + * See the other entry point + * @param noDDA refuse the use of DDA (if true, request must be *NOT* *PERSISTENT*) + */ + public FCPClientGet(final String key, final int priority, + final int persistence, boolean globalQueue, + final int maxRetries, + String destinationDir, + boolean noDDA) { + this(key, priority, persistence, globalQueue, maxRetries, destinationDir); + this.noDDA = noDDA; + } + + + /** * Entry point: * Only for initial queries : To resume queries, use FCPClientGet(FCPQueueManager, Hashmap). * @param destinationDir if null => temporary file @@ -151,6 +166,20 @@ /** + * See the other entry point + * @param noDDA refuse the use of DDA (if true, request must be *NOT* *PERSISTENT*) + */ + public FCPClientGet(final String key, final int priority, + final int persistence, boolean globalQueue, + final int maxRetries, + String destinationDir, + long maxSize, + boolean noDDA) { + this(key, priority, persistence, globalQueue, maxRetries, destinationDir, maxSize); + this.noDDA = noDDA; + } + + /** * Another entry point allowing to specify a max size */ public FCPClientGet(final String key, final int priority, @@ -214,7 +243,7 @@ else queryMessage.setValue("Global", "false"); - if (!queueManager.getQueryManager().getConnection().isLocalSocket()) + if (!queueManager.getQueryManager().getConnection().isLocalSocket() && !noDDA) queryMessage.setValue("ReturnType", "direct"); else { queryMessage.setValue("ReturnType", "disk"); @@ -256,10 +285,10 @@ fileSize = (new Long(message.getValue("DataLength"))).longValue(); if(isPersistent() - || queueManager.getQueryManager().getConnection().isLocalSocket()) { + || (queueManager.getQueryManager().getConnection().isLocalSocket() && !noDDA)) { if(destinationDir != null) { if(!fileExists() - && !queueManager.getQueryManager().getConnection().isLocalSocket()) { + && !(queueManager.getQueryManager().getConnection().isLocalSocket() && !noDDA)) { status = "Requesting file from the node"; progress = 99; running = true; Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-11 13:21:23 UTC (rev 12573) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-11 13:25:01 UTC (rev 12574) @@ -738,7 +738,7 @@ clientGet = new FCPClientGet(key, 2, 2, false, -1, System.getProperty("java.io.tmpdir"), - MAX_SIZE); + MAX_SIZE, true /* <= noDDA */); /* * These requests are usually quite fast, and don't consume too much From jflesch at freenetproject.org Wed Apr 11 16:02:07 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 11 Apr 2007 16:02:07 +0000 (UTC) Subject: [Thaw-dev] r12577 - in trunk/apps/Thaw/src/thaw: core plugins/index Message-ID: <20070411160207.85A32479F1B@emu.freenetproject.org> Author: jflesch Date: 2007-04-11 16:02:07 +0000 (Wed, 11 Apr 2007) New Revision: 12577 Added: trunk/apps/Thaw/src/thaw/core/MDNSDiscovery.java Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java trunk/apps/Thaw/src/thaw/core/Core.java trunk/apps/Thaw/src/thaw/core/MDNSDiscoveryPanel.java trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java Log: Move MDNSDiscovery out of the Core Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-04-11 13:51:02 UTC (rev 12576) +++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-04-11 16:02:07 UTC (rev 12577) @@ -31,9 +31,9 @@ private JButton okButton; private JButton cancelButton; - protected ThawConfigPanel thawConfigPanel; - protected NodeConfigPanel nodeConfigPanel; - protected PluginConfigPanel pluginConfigPanel; + private ThawConfigPanel thawConfigPanel; + private NodeConfigPanel nodeConfigPanel; + private PluginConfigPanel pluginConfigPanel; private Core core; @@ -41,6 +41,7 @@ private boolean needConnectionReset = false; + public ConfigWindow(final Core core) { this.core = core; needConnectionReset = false; @@ -113,6 +114,10 @@ } configWin.setVisible(v); + + if (v == false) { + configWin.dispose(); + } } public boolean addTab(final String name, final java.awt.Component panel) { @@ -138,6 +143,13 @@ } /** + * Used to update the MDNSPanel + */ + public NodeConfigPanel getNodeConfigPanel() { + return nodeConfigPanel; + } + + /** * Get a ref to validation button. */ public JButton getOkButton() { Modified: trunk/apps/Thaw/src/thaw/core/Core.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/Core.java 2007-04-11 13:51:02 UTC (rev 12576) +++ trunk/apps/Thaw/src/thaw/core/Core.java 2007-04-11 16:02:07 UTC (rev 12577) @@ -5,10 +5,6 @@ import java.util.Observable; import java.util.Observer; -import javax.jmdns.JmDNS; -import javax.jmdns.ServiceEvent; -import javax.jmdns.ServiceInfo; -import javax.jmdns.ServiceListener; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JOptionPane; @@ -49,42 +45,8 @@ private ReconnectionManager reconnectionManager = null; // MDNS stuffs - private final JmDNS jmdns; - // SYNC IT!!! - protected final LinkedList foundNodes; + private MDNSDiscovery discovery; - private class FCPMDNSListener implements ServiceListener { - public void serviceAdded(ServiceEvent event) { - Logger.notice(this, "Service added : " + event.getName()+"."+event.getType()); - // Force the gathering of informations - jmdns.getServiceInfo(MDNSDiscoveryPanel.FCP_SERVICE_TYPE, event.getName()); - } - - public void serviceRemoved(ServiceEvent event) { - Logger.notice(this, "Service removed : " + event.getName()+"."+event.getType()); - ServiceInfo service = event.getInfo(); - - synchronized (foundNodes) { - foundNodes.remove(service); - synchronized (configWindow.nodeConfigPanel.mdnsPanel) { - configWindow.nodeConfigPanel.mdnsPanel.notifyAll(); - } - } - } - - public void serviceResolved(ServiceEvent event) { - Logger.debug(this, "Service resolved: " + event.getInfo()); - ServiceInfo service = event.getInfo(); - - synchronized (foundNodes) { - foundNodes.add(service); - synchronized (configWindow.nodeConfigPanel.mdnsPanel) { - configWindow.nodeConfigPanel.mdnsPanel.notifyAll(); - } - } - } - } - /** * Creates a core, but do nothing else (no initialization). */ @@ -92,29 +54,8 @@ Logger.info(this, "Thaw, version "+Main.VERSION, true); Logger.info(this, "2006(c) Freenet project", true); Logger.info(this, "Released under GPL license version 2 or later (see http://www.fsf.org/licensing/licenses/gpl.html)", true); - - this.foundNodes = new LinkedList(); - try { - // Spawn the mdns listener - Logger.info(this, "Starting JMDNS ..."); - this.jmdns = new JmDNS(); - - // Start listening for new nodes - jmdns.addServiceListener(MDNSDiscoveryPanel.FCP_SERVICE_TYPE, new FCPMDNSListener()); - - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Error loading MDNSDiscoveryPanel : " + e.getMessage()); - } } - protected boolean isHasTheSameIPAddress(ServiceInfo host) { - try{ - return (jmdns.getInterface().equals(host.getAddress()) ? true : false); - } catch (IOException e) { - return false; - } - } /** * Gives a ref to the object containing the config. @@ -172,20 +113,24 @@ if (!initializeLookAndFeel()) return false; - splashScreen.setProgressionAndStatus(20, "Connecting ..."); + splashScreen.setProgressionAndStatus(20, "Starting node autodection ..."); splashScreen.addIcon(IconBox.connectAction); + if (!initMDNS()) + return false; + + splashScreen.setProgressionAndStatus(25, "Connecting ..."); if(!initConnection()) new thaw.gui.WarningWindow(this, I18n.getMessage("thaw.warning.unableToConnectTo")+ " "+ config.getValue("nodeAddress")+ ":"+ config.getValue("nodePort")); - splashScreen.setProgressionAndStatus(30, "Preparing the main window ..."); + splashScreen.setProgressionAndStatus(40, "Preparing the main window ..."); splashScreen.addIcon(IconBox.mainWindow); if(!initGraphics()) return false; - splashScreen.setProgressionAndStatus(40, "Loading plugins ..."); + splashScreen.setProgressionAndStatus(50, "Loading plugins ..."); if(!initPluginManager()) return false; @@ -203,7 +148,18 @@ } + public boolean initMDNS() { + discovery = new MDNSDiscovery(this); + return true; + } + + + public MDNSDiscovery getMDNSDiscovery() { + return discovery; + } + + /** * Init configuration. May re-set I18n. */ @@ -515,9 +471,9 @@ return; } } - Logger.info(this, "Stopping JMDNS ..."); - jmdns.close(); + discovery.stop(); + Logger.info(this, "Stopping scheduler ..."); if(queueManager != null) queueManager.stopScheduler(); Added: trunk/apps/Thaw/src/thaw/core/MDNSDiscovery.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/MDNSDiscovery.java (rev 0) +++ trunk/apps/Thaw/src/thaw/core/MDNSDiscovery.java 2007-04-11 16:02:07 UTC (rev 12577) @@ -0,0 +1,90 @@ +/* This code is part of Freenet. It is distributed under the GNU General + * Public License, version 2 (or at your option any later version). See + * http://www.gnu.org/ for further details of the GPL. */ + +package thaw.core; + + +import java.util.LinkedList; + +import javax.jmdns.JmDNS; +import javax.jmdns.ServiceEvent; +import javax.jmdns.ServiceInfo; +import javax.jmdns.ServiceListener; + + +public class MDNSDiscovery { + // SYNC IT!!! + private final LinkedList foundNodes; + private final JmDNS jmdns; + private Core core; + + public MDNSDiscovery(Core core) { + this.core = core; + this.foundNodes = new LinkedList(); + + try { + // Spawn the mdns listener + Logger.info(this, "Starting JMDNS ..."); + this.jmdns = new JmDNS(); + + // Start listening for new nodes + jmdns.addServiceListener(MDNSDiscoveryPanel.FCP_SERVICE_TYPE, new FCPMDNSListener()); + + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Error loading MDNSDiscoveryPanel : " + e.getMessage()); + } + } + + + private class FCPMDNSListener implements ServiceListener { + public void serviceAdded(ServiceEvent event) { + Logger.notice(this, "Service added : " + event.getName()+"."+event.getType()); + // Force the gathering of informations + jmdns.getServiceInfo(MDNSDiscoveryPanel.FCP_SERVICE_TYPE, event.getName()); + } + + public void serviceRemoved(ServiceEvent event) { + Logger.notice(this, "Service removed : " + event.getName()+"."+event.getType()); + ServiceInfo service = event.getInfo(); + + synchronized (foundNodes) { + foundNodes.remove(service); + synchronized (core.getConfigWindow().getNodeConfigPanel().getMdnsPanel()) { + core.getConfigWindow().getNodeConfigPanel().getMdnsPanel().notifyAll(); + } + } + } + + public void serviceResolved(ServiceEvent event) { + Logger.debug(this, "Service resolved: " + event.getInfo()); + ServiceInfo service = event.getInfo(); + + synchronized (foundNodes) { + foundNodes.add(service); + synchronized (core.getConfigWindow().getNodeConfigPanel().getMdnsPanel()) { + core.getConfigWindow().getNodeConfigPanel().getMdnsPanel().notifyAll(); + } + } + } + } + + + public boolean isHasTheSameIPAddress(ServiceInfo host) { + try{ + return (jmdns.getInterface().equals(host.getAddress()) ? true : false); + } catch (java.io.IOException e) { + return false; + } + } + + public LinkedList getFoundNodes() { + return foundNodes; + } + + public void stop() { + Logger.info(this, "Stopping JMDNS ..."); + jmdns.close(); + } +} Modified: trunk/apps/Thaw/src/thaw/core/MDNSDiscoveryPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/MDNSDiscoveryPanel.java 2007-04-11 13:51:02 UTC (rev 12576) +++ trunk/apps/Thaw/src/thaw/core/MDNSDiscoveryPanel.java 2007-04-11 16:02:07 UTC (rev 12577) @@ -109,14 +109,13 @@ } - /** * The user has selected something: notify the main loop and process the data. */ public void actionPerformed(ActionEvent e) { Object source = e.getSource(); - + if ((source == okButton) || (source == cancelButton)){ goon = false; if(source == okButton) { @@ -124,7 +123,7 @@ selectedValue = (ServiceInfo) displayedServiceInfos.get(list.getSelectedValue()); } else cancelledByUser = true; - + synchronized (this) { notifyAll(); } @@ -140,28 +139,28 @@ super.setLocationRelativeTo(this.getParent()); this.setVisible(true); owner.setEnabled(false); - + Logger.notice(this, "Show the MDNSDiscoveryPanel"); Socket testSocket = null; boolean isConfigValid = false; goon = true; - + do { // Loop until a selection is done while(goon) { - synchronized (core.foundNodes) { - if(core.foundNodes.size() > 0) { + synchronized (core.getMDNSDiscovery().getFoundNodes()) { + if(core.getMDNSDiscovery().getFoundNodes().size() > 0) { listModel.clear(); - Iterator it = core.foundNodes.iterator(); + Iterator it = core.getMDNSDiscovery().getFoundNodes().iterator(); while(it.hasNext()) { ServiceInfo current = (ServiceInfo) it.next(); listModel.addElement(current.getName()); displayedServiceInfos.put(current.getName(), current); } list.repaint(); - } + } } - + try { synchronized (this) { wait(Integer.MAX_VALUE); @@ -185,12 +184,12 @@ } catch (IOException e) { isConfigValid = false; } - + Logger.debug(this, "isConfigValid ="+isConfigValid); // Reload, just in case it failed... goon = true; - list.removeSelectionInterval(0, core.foundNodes.size()); + list.removeSelectionInterval(0, core.getMDNSDiscovery().getFoundNodes().size()); } while(!isConfigValid); @@ -202,7 +201,7 @@ // Save the config. now that we know it's valid core.getConfig().setValue("nodeAddress", selectedValue.getHostAddress()); core.getConfig().setValue("nodePort", new Integer(selectedValue.getPort()).toString()); - core.getConfig().setValue("sameComputer", String.valueOf(core.isHasTheSameIPAddress(selectedValue))); + core.getConfig().setValue("sameComputer", String.valueOf(core.getMDNSDiscovery().isHasTheSameIPAddress(selectedValue))); Logger.info(this, "We are done : configuration has been saved sucessfully."); @@ -212,4 +211,6 @@ cb.onMDNSDiscoverPanelClosure(cancelledByUser); Logger.notice(this, "We got back from the MDNSDiscoveryPanel callback"); } + + } Modified: trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java 2007-04-11 13:51:02 UTC (rev 12576) +++ trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java 2007-04-11 16:02:07 UTC (rev 12577) @@ -20,7 +20,7 @@ public class NodeConfigPanel implements Observer, java.awt.event.ActionListener, MDNSDiscoveryPanelCallback { private Core core; private JPanel nodeConfigPanel = null; - protected final MDNSDiscoveryPanel mdnsPanel; + private final MDNSDiscoveryPanel mdnsPanel; private boolean isMDNSPanerShown = false; @@ -119,6 +119,10 @@ return nodeConfigPanel; } + public MDNSDiscoveryPanel getMdnsPanel() { + return mdnsPanel; + } + private void setVisibility(final boolean advancedMode) { for(int i= 2; i < NodeConfigPanel.paramNames.length;i++) { paramLabels[i].setVisible(advancedMode); Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java 2007-04-11 13:51:02 UTC (rev 12576) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexConfigPanel.java 2007-04-11 16:02:07 UTC (rev 12577) @@ -162,8 +162,8 @@ } if (e.getSource() == editBlackList) { + indexBrowser.getBlackList().displayPanel(); configWindow.close(); - indexBrowser.getBlackList().displayPanel(); } } From jflesch at freenetproject.org Wed Apr 11 22:05:54 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 11 Apr 2007 22:05:54 +0000 (UTC) Subject: [Thaw-dev] r12584 - in trunk/apps/Thaw/src/thaw: i18n plugins/peerMonitor Message-ID: <20070411220554.CC22D479F10@emu.freenetproject.org> Author: jflesch Date: 2007-04-11 22:05:54 +0000 (Wed, 11 Apr 2007) New Revision: 12584 Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties trunk/apps/Thaw/src/thaw/i18n/thaw.properties trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java Log: Reduce PeerMonitor panel width Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-11 19:04:30 UTC (rev 12583) +++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-11 22:05:54 UTC (rev 12584) @@ -331,7 +331,7 @@ thaw.plugin.peerMonitor.peerMonitor=Connexion thaw.plugin.peerMonitor.yourReference=Votre r?f?rence: thaw.plugin.peerMonitor.copyReference=Copier votre r?f?rence vers le presse-papier -thaw.plugin.peerMonitor.nodeStats=Informations sur votre noeud +thaw.plugin.peerMonitor.nodeStats=Votre noeud thaw.plugin.peerMonitor.peerList=Peers: thaw.plugin.peerMonitor.nodeInfos=Informations sur votre noeud : thaw.plugin.peerMonitor.peerInfos=Informations relatives au peer @@ -356,8 +356,8 @@ thaw.plugin.peerMonitor.infos.node.myName=Nom du noeud thaw.plugin.peerMonitor.infos.node.runningThreads=Nombre de threads -thaw.plugin.peerMonitor.infos.nodeMemory=Memoire du noeud -thaw.plugin.peerMonitor.infos.thawMemory=Memoire de Thaw +thaw.plugin.peerMonitor.infos.nodeMemory=Mem. du noeud +thaw.plugin.peerMonitor.infos.thawMemory=Mem. de Thaw thaw.plugin.peerMonitor.infos.nodeThreads=Threads (node) thaw.plugin.peerMonitor.infos.thawThreads=Threads (Thaw) Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-11 19:04:30 UTC (rev 12583) +++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-11 22:05:54 UTC (rev 12584) @@ -325,7 +325,7 @@ thaw.plugin.peerMonitor.peerMonitor=Connection thaw.plugin.peerMonitor.yourReference=Your reference: thaw.plugin.peerMonitor.copyReference=Copy your reference to the clipboard -thaw.plugin.peerMonitor.nodeStats=Node informations +thaw.plugin.peerMonitor.nodeStats=Your node thaw.plugin.peerMonitor.peerList=Peers: thaw.plugin.peerMonitor.nodeInfos=Node informations: thaw.plugin.peerMonitor.peerInfos=Informations relative to peer @@ -345,8 +345,8 @@ thaw.plugin.peerMonitor.infos.node.myName=Node name thaw.plugin.peerMonitor.infos.node.runningThreads=Running threads -thaw.plugin.peerMonitor.infos.nodeMemory=Node memory -thaw.plugin.peerMonitor.infos.thawMemory=Thaw memory +thaw.plugin.peerMonitor.infos.nodeMemory=Node mem. +thaw.plugin.peerMonitor.infos.thawMemory=Thaw mem. thaw.plugin.peerMonitor.infos.nodeThreads=Node threads thaw.plugin.peerMonitor.infos.thawThreads=Thaw threads Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties =================================================================== --- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-11 19:04:30 UTC (rev 12583) +++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2007-04-11 22:05:54 UTC (rev 12584) @@ -331,7 +331,7 @@ thaw.plugin.peerMonitor.peerMonitor=Connexion thaw.plugin.peerMonitor.yourReference=Votre r\u00e9f\u00e9rence: thaw.plugin.peerMonitor.copyReference=Copier votre r\u00e9f\u00e9rence vers le presse-papier -thaw.plugin.peerMonitor.nodeStats=Informations sur votre noeud +thaw.plugin.peerMonitor.nodeStats=Votre noeud thaw.plugin.peerMonitor.peerList=Peers: thaw.plugin.peerMonitor.nodeInfos=Informations sur votre noeud : thaw.plugin.peerMonitor.peerInfos=Informations relatives au peer @@ -356,8 +356,8 @@ thaw.plugin.peerMonitor.infos.node.myName=Nom du noeud thaw.plugin.peerMonitor.infos.node.runningThreads=Nombre de threads -thaw.plugin.peerMonitor.infos.nodeMemory=Memoire du noeud -thaw.plugin.peerMonitor.infos.thawMemory=Memoire de Thaw +thaw.plugin.peerMonitor.infos.nodeMemory=Mem. du noeud +thaw.plugin.peerMonitor.infos.thawMemory=Mem. de Thaw thaw.plugin.peerMonitor.infos.nodeThreads=Threads (node) thaw.plugin.peerMonitor.infos.thawThreads=Threads (Thaw) Modified: trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java 2007-04-11 19:04:30 UTC (rev 12583) +++ trunk/apps/Thaw/src/thaw/plugins/peerMonitor/PeerMonitorPanel.java 2007-04-11 22:05:54 UTC (rev 12584) @@ -146,7 +146,7 @@ nodeThreads = new JLabel(""); thawThreads = new JLabel(""); - JPanel threadPanel = new JPanel(new GridLayout(1, 2)); + JPanel threadPanel = new JPanel(new GridLayout(2, 1)); threadPanel.add(nodeThreads); threadPanel.add(thawThreads); @@ -237,8 +237,7 @@ nodeMemBar.setString(I18n.getMessage("thaw.plugin.peerMonitor.infos.nodeMemory")+ ": " + thaw.gui.GUIHelper.getPrintableSize(used) + " / " - + thaw.gui.GUIHelper.getPrintableSize(max) - + " ("+Integer.toString(pourcent)+"%)"); + + thaw.gui.GUIHelper.getPrintableSize(max)); nodeMemBar.setValue(pourcent); @@ -258,8 +257,7 @@ thawMemBar.setString(I18n.getMessage("thaw.plugin.peerMonitor.infos.thawMemory")+ ": " + thaw.gui.GUIHelper.getPrintableSize(used) + " / " - + thaw.gui.GUIHelper.getPrintableSize(max) - + " ("+Integer.toString(pourcent)+"%)"); + + thaw.gui.GUIHelper.getPrintableSize(max)); thawMemBar.setValue(pourcent); } @@ -301,8 +299,8 @@ if (value instanceof Peer) { String txt = ((Peer)value).toString(); - if (txt.length() > 35) { - txt = txt.substring(0, 35) + "(...)"; + if (txt.length() > 25) { + txt = txt.substring(0, 25) + "(...)"; } setText(txt); From jflesch at freenetproject.org Wed Apr 11 22:12:20 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Wed, 11 Apr 2007 22:12:20 +0000 (UTC) Subject: [Thaw-dev] r12585 - trunk/apps/Thaw/src/thaw/plugins Message-ID: <20070411221220.BCD6447983E@emu.freenetproject.org> Author: jflesch Date: 2007-04-11 22:12:20 +0000 (Wed, 11 Apr 2007) New Revision: 12585 Modified: trunk/apps/Thaw/src/thaw/plugins/ThemeSelector.java Log: Fix plugin 'ThemeSelector' Modified: trunk/apps/Thaw/src/thaw/plugins/ThemeSelector.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/ThemeSelector.java 2007-04-11 22:05:54 UTC (rev 12584) +++ trunk/apps/Thaw/src/thaw/plugins/ThemeSelector.java 2007-04-11 22:12:20 UTC (rev 12585) @@ -72,6 +72,7 @@ public boolean stop() { + core.getConfigWindow().deleteObserver(this); core.getConfigWindow().removeTab(panel); return false; @@ -113,7 +114,6 @@ if (themeList.getSelectedValue() != null) { core.getConfig().setValue("lookAndFeel", ((String)themeList.getSelectedValue())); - resetSelection(); } From jflesch at freenetproject.org Thu Apr 12 09:18:01 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 12 Apr 2007 09:18:01 +0000 (UTC) Subject: [Thaw-dev] r12592 - trunk/apps/Thaw/src/thaw/fcp Message-ID: <20070412091801.C9BD4479826@emu.freenetproject.org> Author: jflesch Date: 2007-04-12 09:18:01 +0000 (Thu, 12 Apr 2007) New Revision: 12592 Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java Log: Fix noDDA option in FCPClientGet Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-04-12 01:54:41 UTC (rev 12591) +++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-04-12 09:18:01 UTC (rev 12592) @@ -243,7 +243,7 @@ else queryMessage.setValue("Global", "false"); - if (!queueManager.getQueryManager().getConnection().isLocalSocket() && !noDDA) + if (!queueManager.getQueryManager().getConnection().isLocalSocket() || noDDA) queryMessage.setValue("ReturnType", "direct"); else { queryMessage.setValue("ReturnType", "disk"); From jflesch at freenetproject.org Thu Apr 12 10:04:40 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Thu, 12 Apr 2007 10:04:40 +0000 (UTC) Subject: [Thaw-dev] r12593 - in trunk/apps/Thaw/src/thaw: core plugins plugins/index Message-ID: <20070412100440.18B5C479F7A@emu.freenetproject.org> Author: jflesch Date: 2007-04-12 10:04:39 +0000 (Thu, 12 Apr 2007) New Revision: 12593 Modified: trunk/apps/Thaw/src/thaw/core/SplashScreen.java trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java trunk/apps/Thaw/src/thaw/plugins/index/Index.java trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java Log: Auto-update the corresponding links when a new revision of an index is found Modified: trunk/apps/Thaw/src/thaw/core/SplashScreen.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/SplashScreen.java 2007-04-12 09:18:01 UTC (rev 12592) +++ trunk/apps/Thaw/src/thaw/core/SplashScreen.java 2007-04-12 10:04:39 UTC (rev 12593) @@ -17,7 +17,7 @@ public final static int SIZE_X = 500; public final static int SIZE_Y = 150; - public final static int NMB_ICONS = 9; + public final static int NMB_ICONS = 10; public JDialog splashScreen; public JProgressBar progressBar; Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2007-04-12 09:18:01 UTC (rev 12592) +++ trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2007-04-12 10:04:39 UTC (rev 12593) @@ -19,7 +19,7 @@ public class IndexBrowser extends ToolbarModifier implements Plugin, ChangeListener { - public static final String DEFAULT_INDEX = "USK at G-ofLp2KlhHBNPezx~GDWDKThJ-QUxJK8c2xiF~-jwE,-55vLnqo3U1H5qmKA1LLADoYGQdk-Y3hSLxyKeUyHNc,AQABAAE/Thaw/2/Thaw.xml"; + public static final String DEFAULT_INDEX = "USK at G-ofLp2KlhHBNPezx~GDWDKThJ-QUxJK8c2xiF~-jwE,-55vLnqo3U1H5qmKA1LLADoYGQdk-Y3hSLxyKeUyHNc,AQABAAE/Thaw/9/Thaw.xml"; private Core core; private Hsqldb hsqldb; Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-12 09:18:01 UTC (rev 12592) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-12 10:04:39 UTC (rev 12593) @@ -462,6 +462,32 @@ st.setInt(3, id); st.execute(); + + + /* we update also all the links in the index with the private key */ + + st = db.getConnection().prepareStatement("SELECT links.id, links.publicKey "+ + "FROM LINKS JOIN INDEXES ON links.indexParent = indexes.id "+ + "WHERE indexes.privateKey IS NOT NULL AND LOWER(publicKey) LIKE ?"); + + st.setString(1, FreenetURIHelper.getComparablePart(publicKey)+"%"); + ResultSet res = st.executeQuery(); + + + PreparedStatement updateLinkSt; + + updateLinkSt = db.getConnection().prepareStatement("UPDATE links SET publicKey = ? WHERE id = ?"); + + while(res.next()) { + String pubKey = res.getString("publicKey").replaceAll(".xml", ".frdx"); + + if (FreenetURIHelper.compareKeys(pubKey, publicKey)) { + updateLinkSt.setString(1, publicKey); + updateLinkSt.setInt(2, res.getInt("id")); + updateLinkSt.execute(); + } + } + } catch(SQLException e) { Logger.error(this, "Unable to set public Key because: "+e.toString()); } Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2007-04-12 09:18:01 UTC (rev 12592) +++ trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2007-04-12 10:04:39 UTC (rev 12593) @@ -69,13 +69,7 @@ table = new JTable(linkListModel); table.setShowGrid(false); table.setDefaultRenderer(table.getColumnClass(0), new LinkRenderer()); - table.setDragEnabled(true); - table.setTransferHandler(new TransferHandler("text")); - - MouseListener mouseListener = new DragMouseAdapter(); /* see below */ - table.addMouseListener(mouseListener); - panel = new JPanel(); panel.setLayout(new BorderLayout()); @@ -128,19 +122,6 @@ } - private class DragMouseAdapter extends MouseAdapter { - public void mousePressed(MouseEvent e) { - Logger.error(this, "MOOH"); - - JComponent src = (JComponent) e.getSource(); - TransferHandler handler = src.getTransferHandler(); - - handler.exportAsDrag(src, e, TransferHandler.COPY); - - } - } - - public ToolbarModifier getToolbarModifier() { return toolbarModifier; } Modified: trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java 2007-04-12 09:18:01 UTC (rev 12592) +++ trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java 2007-04-12 10:04:39 UTC (rev 12593) @@ -71,12 +71,6 @@ list.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - list.setDragEnabled(true); - list.setTransferHandler(new TransferHandler("text")); - - MouseListener mouseListener = new DragMouseAdapter(); /* see below */ - list.addMouseListener(mouseListener); - panel = new JPanel(new BorderLayout()); panel.add(new JLabel(I18n.getMessage("thaw.plugin.index.unknownIndexes")), BorderLayout.NORTH); @@ -96,18 +90,7 @@ list.addMouseListener(this); } - private class DragMouseAdapter extends MouseAdapter { - public void mousePressed(MouseEvent e) { - Logger.error(this, "MOOH"); - JComponent src = (JComponent) e.getSource(); - TransferHandler handler = src.getTransferHandler(); - - handler.exportAsDrag(src, e, TransferHandler.COPY); - - } - } - public ToolbarModifier getToolbarModifier() { return toolbarModifier; } From jflesch at freenetproject.org Sat Apr 14 18:55:05 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sat, 14 Apr 2007 18:55:05 +0000 (UTC) Subject: [Thaw-dev] r12708 - in trunk/apps/Thaw/src/thaw: core fcp plugins plugins/index Message-ID: <20070414185505.41347479753@emu.freenetproject.org> Author: jflesch Date: 2007-04-14 18:55:05 +0000 (Sat, 14 Apr 2007) New Revision: 12708 Added: trunk/apps/Thaw/src/thaw/fcp/FreenetURIHelper.java Removed: trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java trunk/apps/Thaw/src/thaw/plugins/index/BlackList.java trunk/apps/Thaw/src/thaw/plugins/index/File.java trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java trunk/apps/Thaw/src/thaw/plugins/index/Index.java trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java trunk/apps/Thaw/src/thaw/plugins/index/Link.java Log: Move FreenetURIHelper from thaw.core to thaw.fcp + Add in the indexes the client version Deleted: trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -1,321 +0,0 @@ -package thaw.core; - -/** - * would be better called "FreenetKeyHelper" ... but too late :p - */ -public class FreenetURIHelper { - - private FreenetURIHelper() { - - } - - /** - * Quick test to see if the string could be a key - * only check the head, not the content (this property is used in FetchPlugin, - * please keep it) - */ - public static boolean isAKey(String key) { - if (key == null) - return false; - - return (key.startsWith("CHK@") - || key.startsWith("SSK@") - || key.startsWith("USK@") - || key.startsWith("KSK@")); - } - - public static String cleanURI(String uri) { - if (uri == null) - return uri; - - uri = uri.replaceFirst("http://127.0.0.1:8888/", ""); - uri = uri.replaceFirst("http://localhost/", ""); - uri = uri.replaceFirst("freenet:", ""); - - try { - uri = java.net.URLDecoder.decode(uri, "UTF-8"); - } catch (final java.io.UnsupportedEncodingException e) { - Logger.warning(new FreenetURIHelper(), "UnsupportedEncodingException (UTF-8): "+e.toString()); - } - - if ((uri.indexOf("CHK@") < 0) - && (uri.indexOf("USK@") < 0) - && (uri.indexOf("KSK@") < 0) - && (uri.indexOf("SSK@") < 0)) { - Logger.notice(new FreenetURIHelper(), "Not a valid key: "+uri); - return null; - } - - return uri; - } - - - public static String getFilenameFromKey(final String key) { - String filename; - final String cutcut[] = key.split("/"); - - if (key == null) - return null; - - if(!key.endsWith("/")) { - filename = cutcut[cutcut.length-1]; - } else { - filename = "index.html"; - } - - return filename; - } - - - public static String convertSSKtoUSK(String SSK) { - if ((SSK == null) || SSK.startsWith("USK@")) - return SSK; - - SSK = SSK.replaceFirst("SSK@", "USK@"); - - final String[] split = SSK.split("/"); - - SSK = ""; - - for (int i = 0 ; i < split.length ; i++) { - switch (i) { - case(0): - SSK = split[i]; - break; - case(1): - final String subsplit[] = split[i].split("-"); - - SSK = SSK + "/"; - - for (int j = 0 ; j < subsplit.length-1 ; j++) { - if (j == 0) - SSK = SSK + subsplit[j]; - else - SSK = SSK + "-" + subsplit[j]; - } - - SSK = SSK + "/" + subsplit[subsplit.length-1]; - - break; - default: - SSK = SSK + "/" + split[i]; - } - } - - return SSK; - } - - - public static String abs(final String val) { - try { - final java.math.BigDecimal bd = new java.math.BigDecimal(val); - return bd.abs().toString(); - } catch(final java.lang.NumberFormatException e) { - Logger.warning(new FreenetURIHelper(), "NumberFormatException while parsing '"+val+"'"); - return "0"; - } - } - - - public static String convertUSKtoSSK(String USK) { - if ((USK == null) || USK.startsWith("SSK@")) - return USK; - - USK = USK.replaceFirst("USK@", "SSK@"); - - final String[] split = USK.split("/"); - - USK = ""; - - for (int i = 0 ; i < split.length ; i++) { - switch (i) { - case(0): - USK = split[i]; - break; - case(2): - USK += "-" + FreenetURIHelper.abs(split[i]); - break; - default: - USK += "/" + split[i]; - break; - } - } - - return USK; - } - - - public static String getPublicInsertionSSK(String key) { - key = FreenetURIHelper.convertUSKtoSSK(key); - - final String split[] = key.split("/"); - - key = ""; - - for (int i = 0 ; i < split.length-1 ; i++) { - if (i == 0) - key = key + split[i]; - else - key = key + "/" + split[i]; - } - - return key; - } - - - protected static String changeRev(final String revStr, final int rev, final int offset) { - if (offset == 0) - return Integer.toString(rev); - - return Integer.toString(Integer.parseInt(revStr) + offset); - } - - /** - * @param offset if == 0, then rev is changed according to the given offset - */ - public static String changeSSKRevision(String key, final int rev, final int offset) { - - if (key == null) - return null; - - final String[] split = key.split("/"); - - key = ""; - - for (int i = 0 ; i < split.length ; i++) { - switch(i) { - case(0): - key = key + split[i]; - break; - case(1): - final String[] subsplit = split[i].split("-"); - - for (int j = 0 ; j < subsplit.length-1 ; j++) { - if (j == 0) - key = key + "/" + subsplit[j]; - else - key = key + "-" + subsplit[j]; - } - - key = key + "-" + FreenetURIHelper.changeRev(subsplit[subsplit.length-1], rev, offset); - break; - default: - key = key + "/" + split[i]; - } - } - - return key; - } - - - public static String changeUSKRevision(String key, int rev, int offset) { - if (key == null) - return null; - - final String[] split = key.split("/"); - - key = ""; - - for (int i = 0 ; i < split.length ; i++) { - switch(i) { - case(0): - key = key + split[i]; - break; - case(2): - key = key + "/" + FreenetURIHelper.changeRev(split[2], rev, offset); - break; - default: - key = key + "/" + split[i]; - } - } - - return key; - - } - - - public static int getUSKRevision(final String key) { - String[] split; - - if (key == null) - return -1; - - split = key.split("/"); - - if (split.length < 3) - return -1; - - try { - return Integer.parseInt(split[2]); - } catch(NumberFormatException e) { - Logger.warning(new FreenetURIHelper(), "Unable to parse '"+key +"'"); - return -1; - } - } - - - /** - * will lower the case ! - * will return the begining of the key. - */ - public static String getComparablePart(String key) { - if (key == null) - return null; - - if (key.startsWith("KSK@")) { - return key; - } - - if (key.length() <= 70) - return key.toLowerCase(); - - return key.substring(0, 70).toLowerCase(); - } - - - /** - * this process is not costless. - */ - public static boolean compareKeys(String keyA, String keyB) { - if (keyA == keyB) - return true; - - if (keyA == null || keyB == null) { - Logger.notice(new FreenetURIHelper(), "compareKeys : null argument ?!"); - return false; - } - - keyA = cleanURI(keyA); - keyB = cleanURI(keyB); - - if (keyA.startsWith("USK@")) - keyA = convertUSKtoSSK(keyA); - - if (keyB.startsWith("USK@")) - keyB = convertUSKtoSSK(keyB); - - if (!keyA.substring(0, 3).equals(keyB.substring(0, 3))) { - Logger.notice(new FreenetURIHelper(), "Not the same kind of key : "+ - keyA.substring(0, 3) + " vs " + keyB.substring(0, 3)); - return false; - } - - if (keyA.startsWith("CHK@")) { - return getComparablePart(keyA).equals(getComparablePart(keyB)); - } - - if (keyA.startsWith("SSK@")) { - keyA = changeSSKRevision(keyA, 0, 0); - keyB = changeSSKRevision(keyB, 0, 0); - - keyA = keyA.replaceAll(".frdx", ".xml"); /* we consider .frdx equivalent to .xml */ - keyB = keyB.replaceAll(".frdx", ".xml"); /* we consider .frdx equivalent to .xml */ - } - - if ( keyA.equals(keyB) ) - return true; - - return false; - } -} - Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -7,7 +7,6 @@ import java.util.Observable; import java.util.Observer; -import thaw.core.FreenetURIHelper; import thaw.core.Logger; public class FCPClientGet extends Observable implements Observer, FCPTransferQuery { @@ -47,6 +46,7 @@ private boolean noDDA = false; + /** * See setParameters(). */ Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -4,7 +4,6 @@ import java.util.Iterator; import java.util.Vector; -import thaw.core.FreenetURIHelper; import thaw.core.Logger; /** Copied: trunk/apps/Thaw/src/thaw/fcp/FreenetURIHelper.java (from rev 12680, trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java) =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FreenetURIHelper.java (rev 0) +++ trunk/apps/Thaw/src/thaw/fcp/FreenetURIHelper.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -0,0 +1,323 @@ +package thaw.fcp; + +import thaw.core.Logger; + +/** + * would be better called "FreenetKeyHelper" ... but too late :p + */ +public class FreenetURIHelper { + + private FreenetURIHelper() { + + } + + /** + * Quick test to see if the string could be a key + * only check the head, not the content (this property is used in FetchPlugin, + * please keep it) + */ + public static boolean isAKey(String key) { + if (key == null) + return false; + + return (key.startsWith("CHK@") + || key.startsWith("SSK@") + || key.startsWith("USK@") + || key.startsWith("KSK@")); + } + + public static String cleanURI(String uri) { + if (uri == null) + return uri; + + uri = uri.replaceFirst("http://127.0.0.1:8888/", ""); + uri = uri.replaceFirst("http://localhost/", ""); + uri = uri.replaceFirst("freenet:", ""); + + try { + uri = java.net.URLDecoder.decode(uri, "UTF-8"); + } catch (final java.io.UnsupportedEncodingException e) { + Logger.warning(new FreenetURIHelper(), "UnsupportedEncodingException (UTF-8): "+e.toString()); + } + + if ((uri.indexOf("CHK@") < 0) + && (uri.indexOf("USK@") < 0) + && (uri.indexOf("KSK@") < 0) + && (uri.indexOf("SSK@") < 0)) { + Logger.notice(new FreenetURIHelper(), "Not a valid key: "+uri); + return null; + } + + return uri; + } + + + public static String getFilenameFromKey(final String key) { + String filename; + final String cutcut[] = key.split("/"); + + if (key == null) + return null; + + if(!key.endsWith("/")) { + filename = cutcut[cutcut.length-1]; + } else { + filename = "index.html"; + } + + return filename; + } + + + public static String convertSSKtoUSK(String SSK) { + if ((SSK == null) || SSK.startsWith("USK@")) + return SSK; + + SSK = SSK.replaceFirst("SSK@", "USK@"); + + final String[] split = SSK.split("/"); + + SSK = ""; + + for (int i = 0 ; i < split.length ; i++) { + switch (i) { + case(0): + SSK = split[i]; + break; + case(1): + final String subsplit[] = split[i].split("-"); + + SSK = SSK + "/"; + + for (int j = 0 ; j < subsplit.length-1 ; j++) { + if (j == 0) + SSK = SSK + subsplit[j]; + else + SSK = SSK + "-" + subsplit[j]; + } + + SSK = SSK + "/" + subsplit[subsplit.length-1]; + + break; + default: + SSK = SSK + "/" + split[i]; + } + } + + return SSK; + } + + + public static String abs(final String val) { + try { + final java.math.BigDecimal bd = new java.math.BigDecimal(val); + return bd.abs().toString(); + } catch(final java.lang.NumberFormatException e) { + Logger.warning(new FreenetURIHelper(), "NumberFormatException while parsing '"+val+"'"); + return "0"; + } + } + + + public static String convertUSKtoSSK(String USK) { + if ((USK == null) || USK.startsWith("SSK@")) + return USK; + + USK = USK.replaceFirst("USK@", "SSK@"); + + final String[] split = USK.split("/"); + + USK = ""; + + for (int i = 0 ; i < split.length ; i++) { + switch (i) { + case(0): + USK = split[i]; + break; + case(2): + USK += "-" + FreenetURIHelper.abs(split[i]); + break; + default: + USK += "/" + split[i]; + break; + } + } + + return USK; + } + + + public static String getPublicInsertionSSK(String key) { + key = FreenetURIHelper.convertUSKtoSSK(key); + + final String split[] = key.split("/"); + + key = ""; + + for (int i = 0 ; i < split.length-1 ; i++) { + if (i == 0) + key = key + split[i]; + else + key = key + "/" + split[i]; + } + + return key; + } + + + protected static String changeRev(final String revStr, final int rev, final int offset) { + if (offset == 0) + return Integer.toString(rev); + + return Integer.toString(Integer.parseInt(revStr) + offset); + } + + /** + * @param offset if == 0, then rev is changed according to the given offset + */ + public static String changeSSKRevision(String key, final int rev, final int offset) { + + if (key == null) + return null; + + final String[] split = key.split("/"); + + key = ""; + + for (int i = 0 ; i < split.length ; i++) { + switch(i) { + case(0): + key = key + split[i]; + break; + case(1): + final String[] subsplit = split[i].split("-"); + + for (int j = 0 ; j < subsplit.length-1 ; j++) { + if (j == 0) + key = key + "/" + subsplit[j]; + else + key = key + "-" + subsplit[j]; + } + + key = key + "-" + FreenetURIHelper.changeRev(subsplit[subsplit.length-1], rev, offset); + break; + default: + key = key + "/" + split[i]; + } + } + + return key; + } + + + public static String changeUSKRevision(String key, int rev, int offset) { + if (key == null) + return null; + + final String[] split = key.split("/"); + + key = ""; + + for (int i = 0 ; i < split.length ; i++) { + switch(i) { + case(0): + key = key + split[i]; + break; + case(2): + key = key + "/" + FreenetURIHelper.changeRev(split[2], rev, offset); + break; + default: + key = key + "/" + split[i]; + } + } + + return key; + + } + + + public static int getUSKRevision(final String key) { + String[] split; + + if (key == null) + return -1; + + split = key.split("/"); + + if (split.length < 3) + return -1; + + try { + return Integer.parseInt(split[2]); + } catch(NumberFormatException e) { + Logger.warning(new FreenetURIHelper(), "Unable to parse '"+key +"'"); + return -1; + } + } + + + /** + * will lower the case ! + * will return the begining of the key. + */ + public static String getComparablePart(String key) { + if (key == null) + return null; + + if (key.startsWith("KSK@")) { + return key; + } + + if (key.length() <= 70) + return key.toLowerCase(); + + return key.substring(0, 70).toLowerCase(); + } + + + /** + * this process is not costless. + */ + public static boolean compareKeys(String keyA, String keyB) { + if (keyA == keyB) + return true; + + if (keyA == null || keyB == null) { + Logger.notice(new FreenetURIHelper(), "compareKeys : null argument ?!"); + return false; + } + + keyA = cleanURI(keyA); + keyB = cleanURI(keyB); + + if (keyA.startsWith("USK@")) + keyA = convertUSKtoSSK(keyA); + + if (keyB.startsWith("USK@")) + keyB = convertUSKtoSSK(keyB); + + if (!keyA.substring(0, 3).equals(keyB.substring(0, 3))) { + Logger.notice(new FreenetURIHelper(), "Not the same kind of key : "+ + keyA.substring(0, 3) + " vs " + keyB.substring(0, 3)); + return false; + } + + if (keyA.startsWith("CHK@")) { + return getComparablePart(keyA).equals(getComparablePart(keyB)); + } + + if (keyA.startsWith("SSK@")) { + keyA = changeSSKRevision(keyA, 0, 0); + keyB = changeSSKRevision(keyB, 0, 0); + + keyA = keyA.replaceAll(".frdx", ".xml"); /* we consider .frdx equivalent to .xml */ + keyB = keyB.replaceAll(".frdx", ".xml"); /* we consider .frdx equivalent to .xml */ + } + + if ( keyA.equals(keyB) ) + return true; + + return false; + } +} + Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -9,7 +9,7 @@ import javax.swing.WindowConstants; import thaw.core.Core; -import thaw.core.FreenetURIHelper; +import thaw.fcp.FreenetURIHelper; import thaw.core.I18n; import thaw.gui.IconBox; import thaw.core.Logger; Modified: trunk/apps/Thaw/src/thaw/plugins/index/BlackList.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/BlackList.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/plugins/index/BlackList.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -21,7 +21,7 @@ import thaw.core.I18n; import thaw.core.Logger; import thaw.core.Core; -import thaw.core.FreenetURIHelper; +import thaw.fcp.FreenetURIHelper; import thaw.gui.IconBox; Modified: trunk/apps/Thaw/src/thaw/plugins/index/File.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/File.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/plugins/index/File.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -12,7 +12,7 @@ import java.util.Vector; import java.util.Iterator; -import thaw.core.FreenetURIHelper; +import thaw.fcp.FreenetURIHelper; import thaw.core.Logger; import thaw.fcp.FCPClientGet; Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -28,7 +28,7 @@ import javax.swing.table.TableColumnModel; import thaw.core.Config; -import thaw.core.FreenetURIHelper; +import thaw.fcp.FreenetURIHelper; import thaw.core.I18n; import thaw.gui.IconBox; import thaw.core.Logger; @@ -381,7 +381,7 @@ if (column == 2) { String key = file.getPublicKey(); - if (key == null || !thaw.core.FreenetURIHelper.isAKey(key)) + if (key == null || !FreenetURIHelper.isAKey(key)) key = I18n.getMessage("thaw.common.unknown"); return key; Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -54,7 +54,7 @@ -import thaw.core.FreenetURIHelper; +import thaw.fcp.FreenetURIHelper; import thaw.core.I18n; import thaw.core.Logger; import thaw.fcp.FCPClientGet; @@ -997,6 +997,13 @@ header.appendChild(title); + + final Element thawVersion = xmlDoc.createElement("client"); + final Text versionText = xmlDoc.createTextNode("Thaw "+thaw.core.Main.VERSION); + thawVersion.appendChild(versionText); + + header.appendChild(thawVersion); + if (getPublishPrivateKey() && getPrivateKey() != null) { final Element privateKeyEl = xmlDoc.createElement("privateKey"); final Text privateKeyText = xmlDoc.createTextNode(getPrivateKey()); Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -37,7 +37,7 @@ import thaw.core.Config; import thaw.core.FileChooser; -import thaw.core.FreenetURIHelper; +import thaw.fcp.FreenetURIHelper; import thaw.core.I18n; import thaw.core.Logger; import thaw.fcp.FCPGenerateSSK; Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -13,7 +13,7 @@ import thaw.core.I18n; import thaw.core.Logger; -import thaw.core.FreenetURIHelper; +import thaw.fcp.FreenetURIHelper; import thaw.plugins.Hsqldb; /** Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -29,7 +29,7 @@ import javax.swing.tree.TreeSelectionModel; import thaw.core.Config; -import thaw.core.FreenetURIHelper; +import thaw.fcp.FreenetURIHelper; import thaw.core.I18n; import thaw.gui.IconBox; import thaw.core.Logger; Modified: trunk/apps/Thaw/src/thaw/plugins/index/Link.java =================================================================== --- trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2007-04-14 18:39:32 UTC (rev 12707) +++ trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2007-04-14 18:55:05 UTC (rev 12708) @@ -7,7 +7,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; -import thaw.core.FreenetURIHelper; +import thaw.fcp.FreenetURIHelper; import thaw.core.Logger; import thaw.plugins.Hsqldb; From jflesch at freenetproject.org Sat Apr 14 21:11:26 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sat, 14 Apr 2007 21:11:26 +0000 (UTC) Subject: [Thaw-dev] r12729 - in trunk/apps/Thaw/src/thaw: core fcp Message-ID: <20070414211126.75D264791BA@emu.freenetproject.org> Author: jflesch Date: 2007-04-14 21:11:26 +0000 (Sat, 14 Apr 2007) New Revision: 12729 Added: trunk/apps/Thaw/src/thaw/fcp/FCPTestDDA.java Modified: trunk/apps/Thaw/src/thaw/core/Logger.java trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java Log: Implement TestDDA for the ClientGet request (need testing !) Modified: trunk/apps/Thaw/src/thaw/core/Logger.java =================================================================== --- trunk/apps/Thaw/src/thaw/core/Logger.java 2007-04-14 21:03:34 UTC (rev 12728) +++ trunk/apps/Thaw/src/thaw/core/Logger.java 2007-04-14 21:11:26 UTC (rev 12729) @@ -22,7 +22,7 @@ * 2 or more is recommanded. * 4 or more is unhealthy */ - public final static int LOG_LEVEL = 2; + public final static int LOG_LEVEL = 3; private static Vector logListeners = null; Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-04-14 21:03:34 UTC (rev 12728) +++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java 2007-04-14 21:11:26 UTC (rev 12729) @@ -46,7 +46,9 @@ private boolean noDDA = false; + private FCPTestDDA testDDA = null; + /** * See setParameters(). */ @@ -200,6 +202,23 @@ this.queueManager = queueManager; + if (queueManager.getQueryManager().getConnection().isLocalSocket() + && !noDDA + && (destinationDir != null || finalPath != null)) { + + if (destinationDir == null) + destinationDir = new File(finalPath).getAbsoluteFile().getParent(); + + testDDA = new FCPTestDDA(destinationDir, false, true); + testDDA.addObserver(this); + return testDDA.start(queueManager); + } + + return sendClientGet(); + } + + public boolean sendClientGet() { + if (finalPath == null && destinationDir == null) { if ((destinationDir = System.getProperty("java.io.tmpdir")) == null) { Logger.error(this, "Unable to find temporary directory ! Will create troubles !"); @@ -262,7 +281,16 @@ public void update(final Observable o, final Object arg) { + if (o == testDDA) { + if (!testDDA.mayTheNodeWrite()) + noDDA = true; + sendClientGet(); + + return; + } + + FCPQueryManager queryManager = null; final FCPMessage message = (FCPMessage)arg; Modified: trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java 2007-04-14 21:03:34 UTC (rev 12728) +++ trunk/apps/Thaw/src/thaw/fcp/FCPMessage.java 2007-04-14 21:11:26 UTC (rev 12729) @@ -63,7 +63,7 @@ } if("ProtocolError".equals( getMessageName() )) { - Logger.notice(this, "PROTOCOL ERROR:"+toString()); + Logger.notice(this, "PROTOCOL ERROR:\n"+toString()); } return true; Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java 2007-04-14 21:03:34 UTC (rev 12728) +++ trunk/apps/Thaw/src/thaw/fcp/FCPQuery.java 2007-04-14 21:11:26 UTC (rev 12729) @@ -20,7 +20,7 @@ /** * Tell if the query is a download query or an upload query. * If >= 1 then *must* be Observable and implements FCPTransferQuery. - * @return 0 : Meaningless ; 1 : Download ; 2 : Upload ; >= 2 : ? + * @return 0 : Meaningless ; 1 : Download ; 2 : Upload */ public int getQueryType(); Added: trunk/apps/Thaw/src/thaw/fcp/FCPTestDDA.java =================================================================== --- trunk/apps/Thaw/src/thaw/fcp/FCPTestDDA.java (rev 0) +++ trunk/apps/Thaw/src/thaw/fcp/FCPTestDDA.java 2007-04-14 21:11:26 UTC (rev 12729) @@ -0,0 +1,206 @@ +package thaw.fcp; + +import java.util.Observable; +import java.util.Observer; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileInputStream; + +import thaw.core.Logger; + + +/** + * FCPClientGet do it automagically when using DDA, so you shouldn't have to bother about it + */ +public class FCPTestDDA extends Observable implements FCPQuery, Observer { + private String dir; + private boolean wantRead; + private boolean wantWrite; + + private String testFile; + + private boolean nodeCanRead; + private boolean nodeCanWrite; + + private FCPQueueManager queueManager; + + + public FCPTestDDA(String directory, + boolean wantTheNodeToRead, + boolean wantTheNodeToWrite) { + this.dir = directory; + this.wantRead = wantTheNodeToRead; + this.wantWrite = wantTheNodeToWrite; + } + + + public boolean start(FCPQueueManager queueManager) { + this.queueManager = queueManager; + + FCPMessage msg = new FCPMessage(); + msg.setMessageName("TestDDARequest"); + msg.setValue("Directory", dir); + msg.setValue("WantReadDirectory", Boolean.toString(wantRead)); + msg.setValue("WantWriteDirectory", Boolean.toString(wantWrite)); + + queueManager.getQueryManager().addObserver(this); + + return queueManager.getQueryManager().writeMessage(msg); + } + + public boolean stop(FCPQueueManager queueManager) { + /* Red Hot Chili Peppers - Can't stop */ + return false; + } + + + protected boolean writeFile(String filename, String content) { + try { + FileOutputStream stream = new FileOutputStream(filename, false); + + stream.write(content.getBytes()); + stream.close(); + + return true; + + } catch(java.io.FileNotFoundException e) { + + Logger.warning(this, "Unable to write file: "+e.toString()); + return false; + + } catch(java.io.IOException e) { + + Logger.warning(this, "Unable to write file: "+e.toString()); + return false; + } + } + + + + protected String readFile(String filename) { + byte[] raw = new byte[128]; + + String data = null; + + try { + FileInputStream stream = new FileInputStream(filename); + + data = ""; + + while(stream.available() > 0) { + stream.read(raw); + data += new String(raw); + } + + stream.close(); + + } catch(java.io.FileNotFoundException e) { + Logger.warning(this, "Unable to read file : "+e.toString()); + return null; + } catch(java.io.IOException e) { + Logger.warning(this, "Unable to read file : "+e.toString()); + return null; + } + + return data; + } + + + protected boolean deleteFile(String filename) { + return (new File(filename)).delete(); + } + + + public void update(Observable o, Object param) { + if (param == null || !(param instanceof FCPMessage)) + return; + + FCPMessage msg = (FCPMessage)param; + + if ("ProtocolError".equals(msg.getMessageName())) { + if ("7".equals(msg.getValue("Code"))) { + Logger.warning(this, "Node doesn't support TestDDA (-> ProtocolError) => DDA desactivated"); + + queueManager.getQueryManager().getConnection().setLocalSocket(false); + + nodeCanRead = false; + nodeCanWrite = false; + setChanged(); + notifyObservers(); + + return; + } + } + + + if (!dir.equals(msg.getValue("Directory"))) { + /* not for us */ + return; + } + + + if ("TestDDAReply".equals(msg.getMessageName())) { + FCPMessage answer = new FCPMessage(); + answer.setMessageName("TestDDAResponse"); + + answer.setValue("Directory", dir); + + if (wantWrite) { + testFile = msg.getValue("WriteFilename"); + writeFile(testFile, msg.getValue("ContentToWrite")); + } + + if (wantRead) { + String data = readFile(msg.getValue("ReadFilename")); + + if (data == null) { + Logger.error(this, "Thaw can't read the file written by the node !"); + } + + answer.setValue("ReadContent", data != null ? data : "bleh"); + } + + queueManager.getQueryManager().writeMessage(answer); + } + + + + + if ("TestDDAComplete".equals(msg.getMessageName())) { + nodeCanRead = false; + nodeCanWrite = false; + + if (wantRead) + nodeCanRead = Boolean.valueOf(msg.getValue("ReadDirectoryAllowed")).booleanValue(); + if (wantWrite) + nodeCanWrite = Boolean.valueOf(msg.getValue("WriteDirectoryAllowed")).booleanValue(); + + Logger.info(this, + "TestDDA : R : " +Boolean.toString(wantRead) + + " ; W : "+Boolean.toString(wantWrite)); + + if (wantWrite) + deleteFile(testFile); + + queueManager.getQueryManager().deleteObserver(this); + + setChanged(); + notifyObservers(); + } + } + + + public boolean mayTheNodeRead() { + return nodeCanRead; + } + + public boolean mayTheNodeWrite() { + return nodeCanWrite; + } + + + public int getQueryType() { + return 0; + } +} From jflesch at freenetproject.org Sat Apr 14 22:08:49 2007 From: jflesch at freenetproject.org (jflesch at freenetproject.org) Date: Sat, 14 Apr 2007 22:08:49 +0000 (UTC) Subject: [Thaw-dev] r12730 - in trunk/apps/Thaw/src: . freenet freenet/crypt freenet/support thaw/core thaw/fcp Message-ID: <20070414220849.6A813479946@emu.freenetproject.org> Author: jflesch Date: 2007-04-14 22:08:49 +0000 (Sat, 14 Apr 2007) New Revision: 12730 Added: trunk/apps/Thaw/src/freenet/ trunk/apps/Thaw/src/freenet/crypt/ trunk/apps/Thaw/src/freenet/crypt/Digest.java trunk/apps/Thaw/src/freenet/crypt/SHA256.java trunk/apps/Thaw/src/freenet/support/ trunk/apps/Thaw/src/freenet/support/Base64.java trunk/apps/Thaw/src/freenet/support/HexUtil.java trunk/apps/Thaw/src/freenet/support/IllegalBase64Exception.java trunk/apps/Thaw/src/thaw/fcp/SHA256Computer.java Modified: trunk/apps/Thaw/src/thaw/core/Logger.java trunk/apps/Thaw/src/thaw/fcp/FCPClientHello.java trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java Log: Implement FileHash attribute in ClientPut request (need testing !) Copied: trunk/apps/Thaw/src/freenet/crypt/Digest.java (from rev 12729, trunk/freenet/src/freenet/crypt/Digest.java) =================================================================== --- trunk/apps/Thaw/src/freenet/crypt/Digest.java (rev 0) +++ trunk/apps/Thaw/src/freenet/crypt/Digest.java 2007-04-14 22:08:49 UTC (rev 12730) @@ -0,0 +1,60 @@ +/* This code is part of Freenet. It is distributed under the GNU General + * Public License, version 2 (or at your option any later version). See + * http://www.gnu.org/ for further details of the GPL. */ +package freenet.crypt; + +public interface Digest { + + /** + * retrieve the value of a hash, by filling the provided int[] with + * n elements of the hash (where n is the bitlength of the hash/32) + * @param digest int[] into which to place n elements + * @param offset index of first of the n elements + */ + public void extract(int [] digest, int offset); + + /** + * Add one byte to the digest. When this is implemented + * all of the abstract class methods end up calling + * this method for types other than bytes. + * @param b byte to add + */ + public void update(byte b); + + /** + * Add many bytes to the digest. + * @param data byte data to add + * @param offset start byte + * @param length number of bytes to hash + */ + public void update(byte[] data, int offset, int length); + + /** + * Adds the entire contents of the byte array to the digest. + */ + public void update(byte[] data); + + /** + * Returns the completed digest, reinitializing the hash function. + * @return the byte array result + */ + public byte[] digest(); + + /** + * Write completed digest into the given buffer. + * @param buffer the buffer to write into + * @param offset the byte offset at which to start writing + * @param reset If true, the hash function is reinitialized + * after writing to the buffer. + */ + public void digest(boolean reset, byte[] buffer, int offset); + + /** + * Return the hash size of this digest in bits + */ + public int digestSize(); +} + + + + Copied: trunk/apps/Thaw/src/freenet/crypt/SHA256.java (from rev 12729, trunk/freenet/src/freenet/crypt/SHA256.java) =================================================================== --- trunk/apps/Thaw/src/freenet/crypt/SHA256.java (rev 0) +++ trunk/apps/Thaw/src/freenet/crypt/SHA256.java 2007-04-14 22:08:49 UTC (rev 12730) @@ -0,0 +1,413 @@ +/** + Cryptix General Licence + + Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 + The Cryptix Foundation Limited. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE CRYPTIX FOUNDATION LIMITED ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + * + * Copyright (C) 2000 The Cryptix Foundation Limited. All rights reserved. + * + * Use, modification, copying and distribution of this software is subject to + * the terms and conditions of the Cryptix General Licence. You should have + * received a copy of the Cryptix General Licence along with this library; + * if not, you can download a copy from http://www.cryptix.org/ . + */ + +package freenet.crypt; + +import java.io.IOException; +import java.io.InputStream; +import java.se