Author: jflesch
Date: 2008-02-14 19:16:28 +0000 (Thu, 14 Feb 2008)
New Revision: 17901

Added:
   trunk/apps/Thaw/src/thaw/plugins/webOfTrust/TrustListDownloader.java
Modified:
   trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
   trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
   trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java
   trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java
   trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
   trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java
   trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java
   trunk/apps/Thaw/src/thaw/plugins/WebOfTrust.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
   trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
   trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
   trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java
   trunk/apps/Thaw/src/thaw/plugins/webOfTrust/DatabaseManager.java
   trunk/apps/Thaw/src/thaw/plugins/webOfTrust/WebOfTrustConfigTab.java
Log:
QueueWatcher : Fix request refreshing when adding a request : Ignore 
non-persistent request (minifrost, etc)

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2008-02-14 19:09:56 UTC 
(rev 17900)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2008-02-14 19:16:28 UTC 
(rev 17901)
@@ -31,8 +31,6 @@
        private int attempt = -1;
        private String status;

-       private String identifier;
-
        private int fromTheNodeProgress = 0;
        private long fileSize;
        private long maxSize = 0;
@@ -59,7 +57,7 @@
         * See setParameters().
         */
        public FCPClientGet(final FCPQueueManager queueManager, final HashMap 
parameters) {
-               super(false);
+               super((String)parameters.get("Identifier"), false);

                this.queueManager = queueManager;
                setParameters(parameters);
@@ -68,7 +66,7 @@

                /* If isPersistent(), then start() won't be called, so must 
relisten the
                   queryManager by ourself */
-               if(isPersistent() && (identifier != null) && 
!identifier.equals("")) {
+               if(isPersistent() && (getIdentifier() != null) && 
!getIdentifier().equals("")) {
                        
this.queueManager.getQueryManager().deleteObserver(this);
                        this.queueManager.getQueryManager().addObserver(this);
                }
@@ -100,8 +98,9 @@
                        status = "(null)";
                }

-               identifier = id;
+               setIdentifier(id);

+
                /* FIX : This is a fix for the files inserted by Frost */
                /* To remove when bback will do his work correctly */
                if (filename == null && id != null) {
@@ -143,7 +142,7 @@
                            final int persistence, boolean globalQueue,
                            final int maxRetries,
                            String destinationDir) {
-               super(false);
+               super(null, false);

                if (globalQueue && (persistence >= 
PERSISTENCE_UNTIL_DISCONNECT))
                        globalQueue = false; /* else protocol error */
@@ -237,8 +236,8 @@

                status = "Requesting";

-               if((identifier == null) || "".equals( identifier ))
-                       identifier = queueManager.getAnID() + "-"+filename;;
+               if((getIdentifier() == null) || "".equals( getIdentifier() ))
+                       setIdentifier(queueManager.getAnID() + "-"+filename);

                Logger.debug(this, "Requesting key : "+getFileKey());

@@ -246,7 +245,7 @@

                queryMessage.setMessageName("ClientGet");
                queryMessage.setValue("URI", key);
-               queryMessage.setValue("Identifier", identifier);
+               queryMessage.setValue("Identifier", getIdentifier());
                queryMessage.setValue("Verbosity", "1");
                queryMessage.setValue("MaxRetries", 
Integer.toString(maxRetries));
                queryMessage.setValue("PriorityClass", 
Integer.toString(priority));
@@ -307,7 +306,7 @@
                        queryManager = queueManager.getQueryManager(); /* 
default one */

                if((message.getValue("Identifier") == null)
-                  || !message.getValue("Identifier").equals(identifier))
+                  || !message.getValue("Identifier").equals(getIdentifier()))
                        return;

                if("DataFound".equals( message.getMessageName() )) {
@@ -358,7 +357,7 @@
                if("IdentifierCollision".equals( message.getMessageName() )) {
                        Logger.notice(this, "IdentifierCollision ! Resending 
with another id");

-                       identifier = null;
+                       setIdentifier(null);
                        start(queueManager);

                        notifyChange();
@@ -540,7 +539,7 @@
                }

                if ("AllData".equals(message.getMessageName())) {
-                       Logger.debug(this, "AllData ! : " + identifier);
+                       Logger.debug(this, "AllData ! : " + getIdentifier());

                        fileSize = message.getAmountOfDataWaiting();

@@ -676,7 +675,7 @@
                Logger.info(this, "Duplicating socket ...");

                if (globalQueue) {
-                       duplicatedQueryManager = 
queueManager.getQueryManager().duplicate(identifier);
+                       duplicatedQueryManager = 
queueManager.getQueryManager().duplicate(getIdentifier());
                        duplicatedQueryManager.addObserver(this);
                } else { /* won't duplicate ; else it will use another id */
                        duplicatedQueryManager = queueManager.getQueryManager();
@@ -721,7 +720,7 @@
                final FCPMessage getRequestStatus = new FCPMessage();

                getRequestStatus.setMessageName("GetRequestStatus");
-               getRequestStatus.setValue("Identifier", identifier);
+               getRequestStatus.setValue("Identifier", getIdentifier());
                if(globalQueue)
                        getRequestStatus.setValue("Global", "true");
                else
@@ -873,7 +872,7 @@
                        return false;
                }

-               if(identifier == null) {
+               if(getIdentifier() == null) {
                        Logger.notice(this, "Can't remove non-started queries");
                        return true;
                }
@@ -885,7 +884,7 @@
                else
                        stopMessage.setValue("Global", "false");

-               stopMessage.setValue("Identifier", identifier);
+               stopMessage.setValue("Identifier", getIdentifier());

                queueManager.getQueryManager().writeMessage(stopMessage);

@@ -947,7 +946,7 @@

                msg.setMessageName("ModifyPersistentRequest");
                msg.setValue("Global", Boolean.toString(globalQueue));
-               msg.setValue("Identifier", identifier);
+               msg.setValue("Identifier", getIdentifier());
                msg.setValue("PriorityClass", Integer.toString(priority));

                if(clientToken && (destinationDir != null))
@@ -983,7 +982,7 @@
        }

        public String getFileKey() {
-               // TODO : It's fix due to Frost
+               // TODO : It's a fix due to Frost
                //        => to remove when it will become unneeded

                if (filename != null && key != null
@@ -1057,7 +1056,7 @@

                result.put("status", status);

-                       result.put("Identifier", identifier);
+               result.put("Identifier", getIdentifier());
                result.put("FileSize", Long.toString(fileSize));
                result.put("Running", Boolean.toString(isRunning()));
                result.put("Successful", Boolean.toString(isSuccessful()));
@@ -1079,9 +1078,9 @@
                destinationDir = (String)parameters.get("ClientToken");
                attempt        = 
Integer.parseInt((String)parameters.get("Attempt"));
                status         = (String)parameters.get("Status");
-               identifier     = (String)parameters.get("Identifier");
+               setIdentifier(   (String)parameters.get("Identifier"));

-               Logger.info(this, "Resuming id : "+identifier);
+               Logger.info(this, "Resuming id : "+getIdentifier());
                fileSize       = 
Long.parseLong((String)parameters.get("FileSize"));
                boolean running        = 
Boolean.valueOf((String)parameters.get("Running")).booleanValue();
                boolean successful     = 
Boolean.valueOf((String)parameters.get("Successful")).booleanValue();
@@ -1103,14 +1102,6 @@
                return (persistence < PERSISTENCE_UNTIL_DISCONNECT);
        }

-
-       public String getIdentifier() {
-               if((identifier == null) || identifier.equals(""))
-                       return null;
-
-               return identifier;
-       }
-
        public boolean isGlobal() {
                return globalQueue;
        }

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java      2008-02-14 19:09:56 UTC 
(rev 17900)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientPut.java      2008-02-14 19:16:28 UTC 
(rev 17901)
@@ -36,7 +36,6 @@
        private String status;

        private int attempt = 0;
-       private String identifier;

        private boolean fatal = true;
        private boolean sending = false;
@@ -56,7 +55,7 @@
         * To resume query from file. (see thaw.core.QueueKeeper)
         */
        public FCPClientPut(final FCPQueueManager queueManager, final HashMap 
parameters) {
-               super(true);
+               super((String)parameters.get("identifier"), true);

                this.queueManager = queueManager;
                setParameters(parameters);
@@ -85,7 +84,7 @@
                            final String privateKey, final int priority,
                            final boolean global, final int persistence,
                            final boolean getCHKOnly) {
-               super(true);
+               super(null, true);

                this.getCHKOnly = getCHKOnly;
                localFile = file;
@@ -119,7 +118,7 @@
                setBlockNumbers(-1, -1, -1, true);
                attempt = 0;

-               identifier = null;
+               setIdentifier(null);
                fatal = true;

        }
@@ -132,7 +131,7 @@
                            final int priority, final int persistence, final 
boolean global,
                            final String filePath, final String fileName, final 
String status, final int progress,
                            final long fileSize, final FCPQueueManager 
queueManager) {
-               super(true);
+               super(identifier, true);

                if(fileSize > 0)
                        this.fileSize = fileSize;
@@ -140,7 +139,6 @@
                toTheNodeProgress = 100;

                this.queueManager = queueManager;
-               this.identifier = identifier;

                if(publicKey.startsWith("CHK"))
                        keyType = KEY_TYPE_CHK;
@@ -175,7 +173,7 @@
        public boolean start(final FCPQueueManager queueManager) {
                this.queueManager = queueManager;
                putFailedCode = -1;
-               identifier = null;
+               setIdentifier(null);

                if((localFile != null) && (localFile.length() <= 0)) {
                        Logger.warning(this, "Empty or unreachable 
file:"+localFile.getPath());
@@ -202,10 +200,10 @@
                if 
(queueManager.getQueryManager().getConnection().isLocalSocket() && localFile != 
null) {
                        status = "Computing hash to get approval from the node 
...";

-                       identifier = queueManager.getAnID() + "-"+ 
localFile.getName();
+                       setIdentifier(queueManager.getAnID() + "-"+ 
localFile.getName());

                        String salt = 
queueManager.getQueryManager().getConnection().getClientHello().getConnectionId()
-                               +"-"+ identifier
+                               +"-"+ getIdentifier()
                                +"-";
                        Logger.info(this, "Salt used for this transfer: ~" + 
salt+ "~");

@@ -330,11 +328,11 @@

                status = "Sending to the node";

-               if(identifier == null) { /* see start() ; when computing hash */
+               if(getIdentifier() == null) { /* see start() ; when computing 
hash */
                        if (localFile != null)
-                               identifier = queueManager.getAnID() + "-"+ 
localFile.getName();
+                               setIdentifier(queueManager.getAnID() + "-"+ 
localFile.getName());
                        else
-                               identifier = queueManager.getAnID();
+                               setIdentifier(queueManager.getAnID());
                }

                notifyChange();
@@ -353,7 +351,7 @@
                        }
                }

-               msg.setValue("Identifier", identifier);
+               msg.setValue("Identifier", getIdentifier());
                msg.setValue("MaxRetries", "-1");
                msg.setValue("PriorityClass", Integer.toString(priority));

@@ -565,7 +563,7 @@

                        if((msg == null)
                           || (msg.getValue("Identifier") == null)
-                          || !msg.getValue("Identifier").equals(identifier))
+                          || 
!msg.getValue("Identifier").equals(getIdentifier()))
                                return;

                        if("URIGenerated".equals( msg.getMessageName() )
@@ -808,7 +806,7 @@
                if(isRunning() || isFinished()) {
                        final FCPMessage msg = new FCPMessage();
                        msg.setMessageName("RemovePersistentRequest");
-                       msg.setValue("Identifier", identifier);
+                       msg.setValue("Identifier", getIdentifier());

                        if(global)
                                msg.setValue("Global", "true");
@@ -836,7 +834,7 @@

                msg.setMessageName("ModifyPersistentRequest");
                msg.setValue("Global", Boolean.toString(global));
-               msg.setValue("Identifier", identifier);
+               msg.setValue("Identifier", getIdentifier());
                msg.setValue("PriorityClass", Integer.toString(priority));

                if(clientToken && (getPath() != null))
@@ -966,8 +964,8 @@
                result.put("status", status);

                result.put("attempt", Integer.toString(attempt));
-               if(identifier != null)
-                       result.put("identifier", identifier);
+               if(getIdentifier() != null)
+                       result.put("identifier", getIdentifier());
                result.put("running", Boolean.toString(isRunning()));
                result.put("successful", Boolean.toString(isSuccessful()));
                result.put("finished", Boolean.toString(isFinished()));
@@ -1002,9 +1000,7 @@
                status = (String)parameters.get("status");
                attempt = Integer.parseInt((String)parameters.get("attempt"));

-               identifier = (String)parameters.get("identifier");
-               if((identifier == null) || identifier.equals(""))
-                       identifier = null;
+               setIdentifier((String)parameters.get("identifier"));

                boolean running = 
Boolean.valueOf((String)parameters.get("running")).booleanValue();
                boolean successful = 
Boolean.valueOf((String)parameters.get("successful")).booleanValue();
@@ -1029,10 +1025,6 @@
                return global;
        }

-       public String getIdentifier() {
-               return identifier;
-       }
-
        public String getPrivateKey() {
                return privateKey;
        }

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java   2008-02-14 19:09:56 UTC 
(rev 17900)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPQueueManager.java   2008-02-14 19:16:28 UTC 
(rev 17901)
@@ -515,7 +515,7 @@
        public String getAnID() {
                lastId++;

-               if(lastId >= 65535) {
+               if(lastId >= 2147483647 /* 2^31 - 1 */) {
                        lastId = 0;
                }


Modified: trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java  2008-02-14 19:09:56 UTC 
(rev 17900)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPTransferQuery.java  2008-02-14 19:16:28 UTC 
(rev 17901)
@@ -47,8 +47,14 @@
        private long startupTime = -1;
        private long completionTime = -1;

+       private String id;

-       public FCPTransferQuery(boolean insertion) {
+       /**
+        * @param id can be null if currently unknown
+        * @param insertion
+        */
+       protected FCPTransferQuery(String id, boolean insertion) {
+               setIdentifier(id);
                this.insertion = insertion;

                reliable = insertion;
@@ -58,6 +64,17 @@
                }
        }

+       protected void setIdentifier(String id) {
+               if (id == null || "".equals(id.trim()))
+                       this.id = null;
+               else
+                       this.id = id.trim();
+       }
+       
+       public String getIdentifier() {
+               return id;
+       }
+       
        protected void setBlockNumbers(long required, long total, long 
transfered, boolean reliable) {
                synchronized(this) {
                        requiredBlocks = required;
@@ -279,8 +296,17 @@
                notifyObservers(o);
        }

+       public boolean equals(Object o) {
+               if (o == this) return true;
+               if (!(o instanceof FCPTransferQuery)) return false;
+               if (getIdentifier() == null) return false;
+               if (((FCPTransferQuery)o).getIdentifier() == null) return false;
+               if (((FCPTransferQuery)o).getIdentifier() == getIdentifier()) 
return true;
+               
+               return 
getIdentifier().equals(((FCPTransferQuery)o).getIdentifier());
+       }

-       /**** To implement : ****/
+       /**** To implement to implement a FCPTransferQuery: ****/



@@ -396,14 +422,9 @@
        public abstract boolean setParameters(HashMap parameters);


+       public abstract boolean isGlobal();
        public abstract boolean isPersistent();
-       public abstract boolean isGlobal();

-       /**
-        * @return can be null (if non active, or meaningless).
-        */
-       public abstract String getIdentifier();
-
        public abstract String getFilename();

 }

Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java   2008-02-14 19:09:56 UTC 
(rev 17900)
+++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java   2008-02-14 19:16:28 UTC 
(rev 17901)
@@ -80,11 +80,16 @@


        public void stop() {
+               queueWatcher.removeButtonListener(QueueWatcher.DOWNLOAD_PANEL, 
this);
+               
                Logger.info(this, "Stopping plugin \"FetchPlugin\" ...");

                if (queueWatcher != null)
                        
queueWatcher.removeButtonFromTheToolbar(buttonInToolBar);

+               fetchFrame.setVisible(false);
+               fetchFrame.dispose();
+               fetchFrame = null;
        }

        public String getNameForUser() {

Modified: trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java  2008-02-14 19:09:56 UTC 
(rev 17900)
+++ trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java  2008-02-14 19:16:28 UTC 
(rev 17901)
@@ -91,10 +91,16 @@


        public void stop() {
+               queueWatcher.removeButtonListener(QueueWatcher.INSERTION_PANEL, 
this);
+               
                Logger.info(this, "Stopping plugin \"InsertPlugin\" ...");

                if (queueWatcher != null)
                        
queueWatcher.removeButtonFromTheToolbar(buttonInToolBar);
+
+               insertionFrame.setVisible(false);
+               insertionFrame.dispose();
+               insertionFrame = null;
        }



Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java  2008-02-14 19:09:56 UTC 
(rev 17900)
+++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java  2008-02-14 19:16:28 UTC 
(rev 17901)
@@ -131,8 +131,12 @@
         * @param panel see DOWNLOAD_PANEL and INSERTION_PANEL
         */
        public void addButtonListener(final int panel, final ActionListener 
listener) {
-               queuePanels[panel].getButton().addActionListener(listener);
+               queuePanels[panel].addActionListenerToTheButton(listener);
        }
+       
+       public void removeButtonListener(final int panel, final ActionListener 
listener) {
+               queuePanels[panel].removeActionListenerFromTheButton(listener);
+       }


        public void stop() {

Modified: trunk/apps/Thaw/src/thaw/plugins/WebOfTrust.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/WebOfTrust.java    2008-02-14 19:09:56 UTC 
(rev 17900)
+++ trunk/apps/Thaw/src/thaw/plugins/WebOfTrust.java    2008-02-14 19:16:28 UTC 
(rev 17901)
@@ -1,6 +1,7 @@
 package thaw.plugins;

 import javax.swing.ImageIcon;
+import java.sql.*;

 import thaw.core.Core;
 import thaw.core.Logger;
@@ -113,10 +114,14 @@

        private TrucMucheThread thread;
        private TrustListUploader trustListUploader = null;
+       private TrustListDownloader trustListDownloader = null;

        private void initThread() {
                trustListUploader = new TrustListUploader(db, 
core.getQueueManager(), core.getConfig());
+               trustListDownloader = new TrustListDownloader(db, 
core.getQueueManager(), core.getConfig());
+
                trustListUploader.init();
+               trustListDownloader.init();

                thread = new TrucMucheThread();
                new ThawThread(thread, "WoT refresher", this).start();
@@ -125,6 +130,8 @@
        private void process() {
                if (trustListUploader != null)
                        trustListUploader.process();
+               if (trustListDownloader != null)
+                       trustListDownloader.process();
        }

        private void stopThread() {
@@ -137,6 +144,11 @@
                        trustListUploader.stop();
                        trustListUploader = null;
                }
+               
+               if (trustListDownloader != null) {
+                       trustListDownloader.stop();
+                       trustListDownloader = null;
+               }
        }

        public boolean run(Core core) {
@@ -184,8 +196,47 @@
                return null;
        }

-       public void addTrustList(Identity id, String publicKey) {
-               /* TODO */
+
+       public void addTrustList(Identity identity, String publicKey, 
java.util.Date dateOfTheKey) {
+               Logger.info(this, "Adding key to the WoT ...");
+               
+               try {
+                       synchronized(db.dbLock) {
+                               PreparedStatement st = 
db.getConnection().prepareStatement("SELECT id, date FROM wotKeys WHERE 
publicKey = ? OR sigId = ? LIMIT 1");
+                               st.setString(1, publicKey);
+                               st.setInt(2, identity.getId());
+                               
+                               ResultSet set = st.executeQuery();
+                               
+                               if (set.next()) {
+                                       Timestamp date = 
set.getTimestamp("date");
+                                       int id = set.getInt("id");
+                                       
+                                       if (date.getTime() >= 
dateOfTheKey.getTime()) {
+                                               Logger.info(this, "We already 
know the key => ignored");
+                                               return;
+                                       }
+                                       
+                                       PreparedStatement up = 
db.getConnection().prepareStatement("UPDATE wotKeys SET publicKey = ?, date = ? 
WHERE id = ?");
+                                       up.setString(1, publicKey);
+                                       up.setTimestamp(2, new 
java.sql.Timestamp(dateOfTheKey.getTime()));
+                                       up.setInt(3, id);
+                                       up.execute();
+                               }
+                               else
+                               {
+                                       PreparedStatement in = 
db.getConnection().prepareStatement("INSERT INTO wotKeys (publicKey, date, 
score, sigId) VALUES (?, ?, 0, ?)");
+                                       in.setString(1, publicKey);
+                                       in.setTimestamp(2, new 
java.sql.Timestamp(dateOfTheKey.getTime()));
+                                       in.setInt(3, identity.getId());
+                                       in.execute();
+                                       
+                                       /* TODO : the newly added identity may 
have a good mark from the WoT, so it would be interresting to refresh it 
immediatly */
+                               }
+                       }
+               } catch(SQLException e) {
+                       Logger.error(this, "Error while adding a key to the 
list of trust list");
+               }
        }

        public void stop() {

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java 
2008-02-14 19:09:56 UTC (rev 17900)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessage.java 
2008-02-14 19:16:28 UTC (rev 17901)
@@ -156,7 +156,9 @@
                                             date, rev, board.getName())) {

                                if (parser.getTrustListPublicKey() != null) {
-                                       
board.getFactory().getWoT().addTrustList(parser.getIdentity(), 
parser.getTrustListPublicKey());
+                                       
board.getFactory().getWoT().addTrustList(parser.getIdentity(),
+                                                                               
                                        parser.getTrustListPublicKey(),
+                                                                               
                                        parser.getDate());
                                }

                                new File(get.getPath()).delete();

Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java   
2008-02-14 19:09:56 UTC (rev 17900)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java   
2008-02-14 19:16:28 UTC (rev 17901)
@@ -178,8 +178,26 @@
                }
        }

+       
+       public java.util.Date getDate() {
+               date = date.trim();
+               time = time.trim();

+               date += " "+time;

+               java.util.Date dateUtil = null;
+
+               try {
+                       dateUtil = simpleFormat.parse(date);
+               } catch(java.text.ParseException e) {
+                       Logger.notice(this, "Can't parse the date !");
+                       return null;
+               }
+
+               return dateUtil;
+       }
+
+
        public boolean insert(Hsqldb db,
                              int boardId, java.util.Date boardDate, int rev,
                              String boardNameExpected) {

Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java       
2008-02-14 19:09:56 UTC (rev 17900)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java       
2008-02-14 19:16:28 UTC (rev 17901)
@@ -120,6 +120,8 @@
                        button = new 
JButton(I18n.getMessage("thaw.common.downloads"));
                        button.setIcon(IconBox.downloads);
                }
+               
+               button.setEnabled(false);

                button.setVerticalAlignment(SwingConstants.CENTER);
                button.setHorizontalAlignment(SwingConstants.LEFT);
@@ -218,11 +220,19 @@
                rightClickMenu.insert(item, 0);
        }

-       public JButton getButton() {
-               return button;
+       public void addActionListenerToTheButton(ActionListener a) {
+               button.setEnabled(true);
+               button.addActionListener(a);
        }
+       
+       public void removeActionListenerFromTheButton(ActionListener a) {
+               button.removeActionListener(a);
+               
+               if (button.getActionListeners() == null
+                               || button.getActionListeners().length == 0)
+                       button.setEnabled(false);
+       }

-
        public void reloadSelections() {
                selectedRows = table.getSelectedRows();


Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java  
2008-02-14 19:09:56 UTC (rev 17900)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueueTableModel.java  
2008-02-14 19:16:28 UTC (rev 17901)
@@ -250,6 +250,9 @@
        }

        public void addQuery(final FCPTransferQuery query) {
+               if (!query.isPersistent())
+                       return;
+               
                if(queries.contains(query)) {
                        Logger.debug(this, "addQuery() : Already known");
                        return;
@@ -345,6 +348,10 @@

                if (o == queueManager) {
                        final FCPTransferQuery query = (FCPTransferQuery)arg;
+                       
+                       /* we only display persistent queries */
+                       if (!query.isPersistent())
+                               return;

                        if((query.getQueryType() == 1) && isForInsertions)
                                return;
@@ -361,10 +368,12 @@
                                removeQuery(query);
                                return;
                        }
-               }
+                       
+                       /* else we don't know */
+                       reloadQueue();
+                       return;

-
-               if (o instanceof FCPTransferQuery
+               } else if (o instanceof FCPTransferQuery
                    && queries.indexOf(o) >= 0
                    && ((FCPTransferQuery)o).isFinished()
                    && (arg == null || !(arg instanceof Long /* update of the 
total time/ETA */)) ) {
@@ -388,28 +397,37 @@
                                TrayIcon.popMessage(pluginManager, "Thaw",
                                                    str, 
thaw.gui.SysTrayIcon.MSG_INFO);
                        }
+
                }

+               if (o instanceof FCPTransferQuery) {
+                       int oldPos = -1;
+                       int i = 0;

-               int oldPos = -1;
-               int i = 0;
+                       if (queries != null) {
+                               oldPos = queries.indexOf(o);
+                       }

-               if (queries != null && (i = queries.indexOf(o)) >= 0) {
-                       oldPos = i;
-               }
+                       sortTable();

-               sortTable();
+                       if (queries != null && (i = queries.indexOf(o)) >= 0) {
+                               if (oldPos != i && oldPos >= 0)
+                                       this.notifyObservers(oldPos);
+                               this.notifyObservers(i);
+                               return;
+                       }

-               if (queries != null && (i = queries.indexOf(o)) >= 0) {
-                       if (oldPos != i)
-                               this.notifyObservers(oldPos);
-                       this.notifyObservers(i);
-                       return;
-               }

+                       Logger.warning(this, "update(): unknow change");

-               Logger.debug(this, "update(): unknow change");
-               reloadQueue();
+                       try {
+                               throw new Exception("meh");
+                       } catch(Exception e) {
+                               e.printStackTrace();
+                       }
+
+                       reloadQueue();
+               }
        }



Modified: trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java   2008-02-14 
19:09:56 UTC (rev 17900)
+++ trunk/apps/Thaw/src/thaw/plugins/signatures/Identity.java   2008-02-14 
19:16:28 UTC (rev 17901)
@@ -429,9 +429,6 @@
        public static Identity generate(Hsqldb db, String nick) {
                Logger.info(null, "thaw.plugins.signatures.Identity : 
Generating new identity ...");

-               //DSAPrivateKey privateKey = new 
DSAPrivateKey(Global.DSAgroupBigA, Core.getRandom());
-               //DSAPublicKey publicKey = new 
DSAPublicKey(Global.DSAgroupBigA, privateKey);
-
                initFrostCrypt();

                String[] keys = frostCrypt.generateKeys();
@@ -768,6 +765,9 @@
        }

        public boolean equals(Object o) {
+               if (o == null)
+                       return false;
+               
                if (!(o instanceof Identity))
                        return false;


Modified: trunk/apps/Thaw/src/thaw/plugins/webOfTrust/DatabaseManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/webOfTrust/DatabaseManager.java    
2008-02-14 19:09:56 UTC (rev 17900)
+++ trunk/apps/Thaw/src/thaw/plugins/webOfTrust/DatabaseManager.java    
2008-02-14 19:16:28 UTC (rev 17901)
@@ -21,6 +21,8 @@
                        newDb = true;
                        config.setValue("wotDatabaseVersion", "0");
                } else {
+                       /* CONVERTIONS */
+                       
                        /* ... */                       
                }

@@ -30,20 +32,10 @@
        }

        public static void createTables(Hsqldb db) {
-               /*sendQuery(db,
-                                 "CREATE CACHED TABLE indexFolders ("
-                                 + "id INTEGER IDENTITY NOT NULL,"
-                                 + "name VARCHAR(255) NOT NULL,"
-                                 + "positionInTree INTEGER NOT NULL,"
-                                 + "modifiableIndexes BOOLEAN NOT NULL,"
-                                 + "parent INTEGER NULL,"
-                                 + "PRIMARY KEY (id),"
-                                 + "FOREIGN KEY (parent) REFERENCES 
indexFolders (id))");
-                */
-
-               sendQuery(db, "CREATE CACHED TABLE wot ("
+               sendQuery(db, "CREATE CACHED TABLE wotKeys ("
                                + "id INTEGER IDENTITY NOT NULL, "
                                + "publicKey VARCHAR(400) NOT NULL, "
+                               + "date TIMESTAMP NOT NULL, "
                                + "score SMALLINT NOT NULL, "
                                + "sigId INTEGER NOT NULL, "
                                + "PRIMARY KEY(id), "

Added: trunk/apps/Thaw/src/thaw/plugins/webOfTrust/TrustListDownloader.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/webOfTrust/TrustListDownloader.java        
                        (rev 0)
+++ trunk/apps/Thaw/src/thaw/plugins/webOfTrust/TrustListDownloader.java        
2008-02-14 19:16:28 UTC (rev 17901)
@@ -0,0 +1,32 @@
+package thaw.plugins.webOfTrust;
+
+
+import thaw.core.Config;
+
+import thaw.fcp.FCPQueueManager;
+import thaw.plugins.Hsqldb;
+
+
+public class TrustListDownloader {
+       private final FCPQueueManager queueManager;
+       private final Config config;
+       private final Hsqldb db;
+       
+       public TrustListDownloader(Hsqldb db, FCPQueueManager queueManager, 
Config config) {
+               this.queueManager = queueManager;
+               this.config = config;
+               this.db = db;
+       }
+       
+       public void init() {
+               
+       }
+       
+       public synchronized void process() {
+               
+       }
+       
+       public void stop() {
+               
+       }
+}

Modified: trunk/apps/Thaw/src/thaw/plugins/webOfTrust/WebOfTrustConfigTab.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/webOfTrust/WebOfTrustConfigTab.java        
2008-02-14 19:09:56 UTC (rev 17900)
+++ trunk/apps/Thaw/src/thaw/plugins/webOfTrust/WebOfTrustConfigTab.java        
2008-02-14 19:16:28 UTC (rev 17901)
@@ -64,6 +64,10 @@
        private void resetContentOfIdentitySelector() {
                Vector identities = Identity.getYourIdentities(db);

+               /* can happen if the database has been shutdowned */
+               if (identities == null)
+                       return;
+               
                identityUsed.removeAllItems();
                
identityUsed.addItem(I18n.getMessage("thaw.plugin.wot.usedIdentity.none"));



Reply via email to