Author: jflesch
Date: 2007-04-23 01:52:33 +0000 (Mon, 23 Apr 2007)
New Revision: 12891
Modified:
trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
trunk/apps/Thaw/src/thaw/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/plugins/Signatures.java
trunk/apps/Thaw/src/thaw/plugins/index/Comment.java
trunk/apps/Thaw/src/thaw/plugins/index/CommentTab.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java
trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java
Log:
Allow to ignore messages signed with a signature below a given level of trust
Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-23
01:07:57 UTC (rev 12890)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties 2007-04-23
01:52:33 UTC (rev 12891)
@@ -412,6 +412,9 @@
thaw.plugin.signature.trustLevel.evil=DIABOLIQUE
thaw.plugin.signature.trustLevel.me=MOI
+thaw.plugin.signature.ignoreLowerThan=Ignorer les signatures avec un status
inf?rieur ?
+
+
# Zeroconf
thaw.zeroconf.searchingNode=Recherche de noeuds Freenet ...
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-23 01:07:57 UTC
(rev 12890)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-04-23 01:52:33 UTC
(rev 12891)
@@ -421,6 +421,7 @@
thaw.plugin.signature.trustLevel.me=ME
+thaw.plugin.signature.ignoreLowerThan=Ignore signatures with a status lower
than
# ZeroConf
Modified: trunk/apps/Thaw/src/thaw/plugins/Signatures.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/Signatures.java 2007-04-23 01:07:57 UTC
(rev 12890)
+++ trunk/apps/Thaw/src/thaw/plugins/Signatures.java 2007-04-23 01:52:33 UTC
(rev 12891)
@@ -1,6 +1,10 @@
package thaw.plugins;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+
import thaw.core.I18n;
import thaw.core.Core;
import thaw.core.Logger;
@@ -12,11 +16,13 @@
import thaw.plugins.signatures.*;
-public class Signatures extends LibraryPlugin {
- public Core core;
- public Hsqldb db;
- public SigConfigTab configTab;
+public class Signatures extends LibraryPlugin implements ActionListener {
+ private Core core;
+ private Hsqldb db;
+ private SigConfigTab configTab;
+ public final static int DEFAULT_MIN_TRUST_LEVEL = -1; /* see
Identity.trustLevelInt */
+
/**
* because we must be sure that we won't be used anymore when we will
* unregister from the db
@@ -50,12 +56,18 @@
DatabaseManager.init(db, core.getConfig(),
core.getSplashScreen());
- configTab = new SigConfigTab(core.getConfigWindow(), db);
+ if (core.getConfig().getValue("minTrustLevel") == null)
+ core.getConfig().setValue("minTrustLevel",
Integer.toString(DEFAULT_MIN_TRUST_LEVEL));
+ configTab = new SigConfigTab(core.getConfig(),
core.getConfigWindow(), db);
+
core.getConfigWindow().addTab(I18n.getMessage("thaw.plugin.signature.signatures"),
null
/*thaw.gui.IconBox.minIdentities*/,
configTab.getPanel());
+ core.getConfigWindow().getOkButton().addActionListener(this);
+
core.getConfigWindow().getCancelButton().addActionListener(this);
+
return true;
}
@@ -92,4 +104,16 @@
return IconBox.identity;
}
+
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == core.getConfigWindow().getOkButton()) {
+ configTab.apply();
+ return;
+ }
+
+ if (e.getSource() == core.getConfigWindow().getCancelButton()) {
+ configTab.reset();
+ return;
+ }
+ }
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Comment.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-04-23 01:07:57 UTC
(rev 12890)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-04-23 01:52:33 UTC
(rev 12891)
@@ -180,7 +180,7 @@
changeTrust = new JButton(I18n.getMessage("thaw.common.apply"));
changeTrust.addActionListener(this);
- JPanel trustPanel = new JPanel(new BorderLayout());
+ JPanel trustPanel = new JPanel(new BorderLayout(5, 5));
trustPanel.add(trust, BorderLayout.CENTER);
trustPanel.add(changeTrust, BorderLayout.EAST);
@@ -202,6 +202,11 @@
}
+ public boolean mustBeIgnored(Config config) {
+ return author.mustBeIgnored(config);
+ }
+
+
public void actionPerformed(ActionEvent e) {
if (e.getSource() == changeTrust) {
if (author == null)
Modified: trunk/apps/Thaw/src/thaw/plugins/index/CommentTab.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/CommentTab.java 2007-04-23
01:07:57 UTC (rev 12890)
+++ trunk/apps/Thaw/src/thaw/plugins/index/CommentTab.java 2007-04-23
01:52:33 UTC (rev 12891)
@@ -40,13 +40,15 @@
private Vector buttonActions;
-
+ private Config config;
private IndexBrowserPanel indexBrowser;
- public CommentTab(FCPQueueManager queueManager,
+ public CommentTab(Config config,
+ FCPQueueManager queueManager,
IndexBrowserPanel indexBrowser) {
this.indexBrowser = indexBrowser;
+ this.config = config;
visible = false;
@@ -96,13 +98,26 @@
comments = index.getComments();
if (comments != null) {
- insidePanel.setLayout(new GridLayout(comments.size(),
1, 20, 20));
+ int nmbCommentToDisplay = 0;
for (Iterator it = comments.iterator();
it.hasNext();) {
- JPanel panel =
((Comment)it.next()).getPanel(this);
+ if
(!(((Comment)it.next()).mustBeIgnored(config)))
+ nmbCommentToDisplay++;
+ }
- insidePanel.add(panel);
+ insidePanel.setLayout(new
GridLayout(nmbCommentToDisplay, 1, 20, 20));
+
+ for (Iterator it = comments.iterator();
+ it.hasNext();) {
+ Comment c = ((Comment)it.next());
+
+ if (!c.mustBeIgnored(config)) {
+ JPanel panel = c.getPanel(this);
+
+ if (panel != null)
+ insidePanel.add(panel);
+ }
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2007-04-23 01:07:57 UTC (rev 12890)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2007-04-23 01:52:33 UTC (rev 12891)
@@ -51,7 +51,8 @@
indexTree = new
IndexTree(I18n.getMessage("thaw.plugin.index.indexes"),
false, queueManager, this, config);
- commentTab = new CommentTab(core.getQueueManager(),
+ commentTab = new CommentTab(core.getConfig(),
+ core.getQueueManager(),
this);
leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
Modified: trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java 2007-04-23
01:07:57 UTC (rev 12890)
+++ trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java 2007-04-23
01:52:33 UTC (rev 12891)
@@ -21,8 +21,8 @@
import thaw.core.Logger;
import thaw.core.I18n;
import thaw.plugins.Hsqldb;
+import thaw.core.Config;
-
public class Identity {
public final static int[] trustLevelInt = {
@@ -183,6 +183,13 @@
}
+ public boolean mustBeIgnored(Config config) {
+ int min = Integer.parseInt(config.getValue("minTrustLevel"));
+
+ return (trustLevel < min);
+ }
+
+
/**
* if the identity doesn't exists, it will be created
*/
Modified: trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java
2007-04-23 01:07:57 UTC (rev 12890)
+++ trunk/apps/Thaw/src/thaw/plugins/signatures/SigConfigTab.java
2007-04-23 01:52:33 UTC (rev 12891)
@@ -14,6 +14,7 @@
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
+import javax.swing.JComboBox;
import java.awt.BorderLayout;
import java.awt.GridLayout;
@@ -26,6 +27,8 @@
import thaw.core.I18n;
import thaw.core.ConfigWindow;
+import thaw.core.Config;
+import thaw.core.Logger;
import thaw.gui.IconBox;
@@ -36,20 +39,26 @@
public class SigConfigTab implements ActionListener {
private Hsqldb db;
private ConfigWindow configWindow;
+ private Config config;
-
private JPanel configPanel;
private JButton yourIdentitiesButton;
private JButton otherIdentitiesButton;
+ private JComboBox minLevel;
- public SigConfigTab(ConfigWindow configWin, Hsqldb db) {
+
+ public SigConfigTab(Config config, ConfigWindow configWin, Hsqldb db) {
this.db = db;
this.configWindow = configWin;
+ this.config = config;
- configPanel = new JPanel();
+ configPanel = new JPanel(new BorderLayout(5, 5));
+
+ JPanel topPanel = new JPanel();
+
yourIdentitiesButton = new
JButton(I18n.getMessage("thaw.plugin.signature.yourIdentities"));
otherIdentitiesButton = new
JButton(I18n.getMessage("thaw.plugin.signature.otherIdentities"));
@@ -57,16 +66,74 @@
otherIdentitiesButton.addActionListener(this);
- configPanel.add(yourIdentitiesButton);
- configPanel.add(otherIdentitiesButton);
+ topPanel.add(yourIdentitiesButton);
+ topPanel.add(otherIdentitiesButton);
+
+ configPanel.add(topPanel, BorderLayout.NORTH);
+
+ JPanel middlePanel = new JPanel();
+
+ JLabel l = new
JLabel(I18n.getMessage("thaw.plugin.signature.ignoreLowerThan")+" : ");
+ Vector possibleLevels = new Vector();
+
+ for (int i = 0 ; i < Identity.trustLevelInt.length ; i++) {
+ if (Identity.trustLevelInt[i] < 100)
+
possibleLevels.add(I18n.getMessage(Identity.trustLevelStr[i]));
+ }
+
+ minLevel = new JComboBox(possibleLevels);
+
+ reset();
+
+ middlePanel.add(l);
+ middlePanel.add(minLevel);
+
+ configPanel.add(middlePanel, BorderLayout.CENTER);
}
public JPanel getPanel() {
return configPanel;
}
+ public void apply() {
+ int i ;
+ String val = (String)minLevel.getSelectedItem();
+ if (val == null) {
+ Logger.error(this, "no value selected ?!");
+ return;
+ }
+
+ for (i = 0 ; i < Identity.trustLevelStr.length ; i++) {
+ if
(I18n.getMessage(Identity.trustLevelStr[i]).equals(val))
+ break;
+ }
+
+ if (i >= Identity.trustLevelStr.length)
+ return;
+
+ Logger.error(this, "Setting min trust level to :
"+Integer.toString(Identity.trustLevelInt[i]));
+
+ config.setValue("minTrustLevel",
Integer.toString(Identity.trustLevelInt[i]));
+ }
+
+ public void reset() {
+ int i;
+
+ int min = Integer.parseInt(config.getValue("minTrustLevel"));
+
+ for (i = 0 ; i < Identity.trustLevelInt.length ; i++) {
+ if (Identity.trustLevelInt[i] == min)
+ break;
+ }
+
+ if (i >= Identity.trustLevelInt.length)
+ return;
+
+
minLevel.setSelectedItem(I18n.getMessage(Identity.trustLevelStr[i]));
+ }
+
protected class YourIdentitiesPanel implements ActionListener {
private JDialog dialog;