Author: bback
Date: 2006-02-11 21:43:18 +0000 (Sat, 11 Feb 2006)
New Revision: 8021

Removed:
   trunk/apps/frost-0.7/source/frost/threads/getKeyThread.java
Modified:
   trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java
   trunk/apps/frost-0.7/source/frost/fcp/FcpInsert.java
   trunk/apps/frost-0.7/source/frost/fcp/FcpRequest.java
   trunk/apps/frost-0.7/source/frost/threads/MessageDownloadThread.java
   trunk/apps/frost-0.7/source/frost/threads/MessageUploadThread.java
   trunk/apps/frost-0.7/source/frost/threads/UpdateIdThread.java
Log:
cleanups

Modified: trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java    2006-02-11 
19:40:07 UTC (rev 8020)
+++ trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java    2006-02-11 
21:43:18 UTC (rev 8021)
@@ -136,7 +136,6 @@
         }
     }

-    
     /**
      * Retrieves the specified key and saves it to the file
      * specified.
@@ -146,19 +145,6 @@
      * @param htl the HTL to use in this request
      * @return the results filled with metadata
      */
-    public FcpResults getKeyToFile(String keyString, String filename, int htl) 
-    throws IOException, FcpToolsException, InterruptedIOException {
-        return getKeyToFile( keyString, filename, htl, false );
-    }
-    /**
-     * Retrieves the specified key and saves it to the file
-     * specified.
-     *
-     * @param key  the key to be retrieved
-     * @param filename  the filename to which the data should be saved
-     * @param htl the HTL to use in this request
-     * @return the results filled with metadata
-     */
     public FcpResults getKeyToFile(String keyString,
                                    String filename,
                                    int htl,

Modified: trunk/apps/frost-0.7/source/frost/fcp/FcpInsert.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/fcp/FcpInsert.java        2006-02-11 
19:40:07 UTC (rev 8020)
+++ trunk/apps/frost-0.7/source/frost/fcp/FcpInsert.java        2006-02-11 
21:43:18 UTC (rev 8021)
@@ -119,21 +119,7 @@

         return result;
     }
-
-    /**
-     * Inserts a file into freenet.
-     * The boardfilename is needed for FEC splitfile puts, 
-     * for inserting e.g. the pubkey.txt file set it to null.
-     * This method wraps the calls without the uploadItem.
-     */
-//    public static String[] putFile(String uri, File file, int htl, boolean 
doRedirect) {
-//        return putFile(uri, file, null, htl, doRedirect, null);
-//    }

-    public static String[] putFile(String uri, File file, byte[]metadata, int 
htl, boolean doRedirect) {
-        return putFile(uri, file, metadata, htl, doRedirect, null);
-    }
-    
     /**
      * Inserts a file into freenet.
      * The maximum file size for a KSK/SSK direct insert is 32kb! (metadata + 
data!!!)
@@ -186,39 +172,39 @@
     }


-    public static String getCHK(File file){
-       String ERROR="CHK@";
-       if (file.length() == 0) {
-            logger.log(Level.SEVERE, "Error: Can't generate CHK empty file: 
"+file.getPath());
-            System.out.println("Error: Can't generate CHK for empty file: 
"+file.getPath());
-                       JOptionPane.showMessageDialog(MainFrame.getInstance(), 
-                                                        "FcpInsert: File 
"+file.getPath()+" is empty!", // message
-                                                        "Warning", 
-                                                        
JOptionPane.WARNING_MESSAGE);
-            return ERROR;
-        }
-        
-        try {
-            FcpConnection connection = FcpFactory.getFcpConnectionInstance();
-            if( connection == null ) {
-                return ERROR;
-            }
-                
-            byte[] data = FileAccess.readByteArray(file);
-            String output = connection.getCHK(data);
-
-            return output;
-
-        } catch( UnknownHostException e ) {
-               
-                       logger.log(Level.SEVERE, "UnknownHostException", e);
-        } catch( Throwable e ) {
-               
-               logger.log(Level.SEVERE, "Throwable", e);
-        }
-        
-        return ERROR;
-    }
+//    public static String getCHK(File file){
+//     String ERROR="CHK@";
+//     if (file.length() == 0) {
+//            logger.log(Level.SEVERE, "Error: Can't generate CHK empty file: 
"+file.getPath());
+//            System.out.println("Error: Can't generate CHK for empty file: 
"+file.getPath());
+//                     JOptionPane.showMessageDialog(MainFrame.getInstance(), 
+//                                                      "FcpInsert: File 
"+file.getPath()+" is empty!", // message
+//                                                      "Warning", 
+//                                                      
JOptionPane.WARNING_MESSAGE);
+//            return ERROR;
+//        }
+//        
+//        try {
+//            FcpConnection connection = FcpFactory.getFcpConnectionInstance();
+//            if( connection == null ) {
+//                return ERROR;
+//            }
+//                
+//            byte[] data = FileAccess.readByteArray(file);
+//            String output = connection.getCHK(data);
+//
+//            return output;
+//
+//        } catch( UnknownHostException e ) {
+//             
+//                     logger.log(Level.SEVERE, "UnknownHostException", e);
+//        } catch( Throwable e ) {
+//             
+//             logger.log(Level.SEVERE, "Throwable", e);
+//        }
+//        
+//        return ERROR;
+//    }

     /**
      * Method calls FcpConnection.putKeyFromArray() and works around a freenet 
bug:

Modified: trunk/apps/frost-0.7/source/frost/fcp/FcpRequest.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/fcp/FcpRequest.java       2006-02-11 
19:40:07 UTC (rev 8020)
+++ trunk/apps/frost-0.7/source/frost/fcp/FcpRequest.java       2006-02-11 
21:43:18 UTC (rev 8021)
@@ -27,9 +27,7 @@
 /**
  * Requests a key from freenet
  */
-
 // while requesting / inserting, show chunks left to try (incl. trying chunks) 
-> Warte (9) / 18% (9)
-
 public class FcpRequest
 {
        final static boolean DEBUG = true;
@@ -52,27 +50,6 @@
                                   Long size, 
                                   File target, 
                                   int htl, 
-                                  boolean doRedirect)
-    {
-        // use temp file by default, only filedownload needs the target file 
to monitor download progress
-        return getFile(key,size,target,htl,doRedirect, false, true, null);
-    }
-    
-    public static FcpResults getFile(String key, 
-                                  Long size, 
-                                  File target, 
-                                  int htl, 
-                                  boolean doRedirect, 
-                                  boolean fastDownload)
-    {
-        // use temp file by default, only filedownload needs the target file 
to monitor download progress
-        return getFile(key,size,target,htl,doRedirect, fastDownload, true, 
null);
-    }
-
-    public static FcpResults getFile(String key, 
-                                  Long size, 
-                                  File target, 
-                                  int htl, 
                                   boolean doRedirect,
                                   boolean fastDownload, 
                                   boolean createTempFile, 
@@ -121,45 +98,39 @@
     }

     // used by getFile
-    private static FcpResults getKey(String key, File target, int htl, boolean 
fastDownload)
-    {
-        if( key == null || key.length() == 0 || key.startsWith("null") )
+    private static FcpResults getKey(String key, File target, int htl, boolean 
fastDownload) {
+
+        if( key == null || key.length() == 0 || key.startsWith("null") ) {
             return null;
+        }

         FcpResults results = null;

         FcpConnection connection = FcpFactory.getFcpConnectionInstance();
-        if( connection != null )
-        {
+        if( connection != null ) {
             int tries = 0;
             int maxtries = 3;
-            while( tries < maxtries || results != null )
-            {
-                try
-                {
+            while( tries < maxtries || results != null ) {
+                try {
                     results = connection.getKeyToFile(key, target.getPath(), 
htl, fastDownload);
                     break;
                 }
-                catch( java.net.ConnectException e )
-                {
+                catch( java.net.ConnectException e ) {
                     tries++;
                     continue;
                 }
-                catch( DataNotFoundException ex ) // 
frost.FcpTools.DataNotFoundException
-                {
+                catch( DataNotFoundException ex ) { // 
frost.FcpTools.DataNotFoundException
                     // do nothing, data not found is usual ...
                                        logger.log(Level.INFO, 
"FcpRequest.getKey(1): DataNotFoundException (usual if not found)", ex);
                                        System.out.println( 
"FcpRequest.getKey(1): DataNotFoundException (usual if not found)");
                     break;
                 }
-                catch( FcpToolsException e )
-                {
+                catch( FcpToolsException e ) {
                                        logger.log(Level.SEVERE, 
"FcpRequest.getKey(1): FcpToolsException", e);
                                        
System.out.println("FcpRequest.getKey(1): FcpToolsException");
                     break;
                 }
-                catch( IOException e )
-                {
+                catch( IOException e ) {
                                        logger.log(Level.SEVERE, 
"FcpRequest.getKey(1): IOException", e);
                                        
System.out.println("FcpRequest.getKey(1): IOException");
                     break;
@@ -168,8 +139,7 @@
         }

         String printableKey = null;
-        if( DEBUG )
-        {
+        if( DEBUG ) {
             String keyPrefix = "";
             if( key.indexOf("@") > -1 )  keyPrefix = key.substring(0, 
key.indexOf("@")+1);
             String keyUrl = "";
@@ -181,10 +151,7 @@

         boolean metadataAvailable = results!=null && 
results.getRawMetadata()!=null && 
                                     results.getRawMetadata().length > 0; 
-        if( results != null && 
-            ( target.length() > 0 || metadataAvailable )
-          )  
-        {
+        if( results != null && ( target.length() > 0 || metadataAvailable ) ) {
             logger.info("getKey - Success: " + printableKey );
             System.out.println("getKey - Success: " + printableKey );
             return results;

Modified: trunk/apps/frost-0.7/source/frost/threads/MessageDownloadThread.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/threads/MessageDownloadThread.java        
2006-02-11 19:40:07 UTC (rev 8020)
+++ trunk/apps/frost-0.7/source/frost/threads/MessageDownloadThread.java        
2006-02-11 21:43:18 UTC (rev 8021)
@@ -239,7 +239,9 @@
                         testMe,
                         downloadHtl,
                         false,
-                        fastDownload);
+                        fastDownload,
+                        true, // createTempFile
+                        null); // no DownloadItem

                 if (res == null) {
                     metadata = null; // if metadata==null its NOT a signed 
message

Modified: trunk/apps/frost-0.7/source/frost/threads/MessageUploadThread.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/threads/MessageUploadThread.java  
2006-02-11 19:40:07 UTC (rev 8020)
+++ trunk/apps/frost-0.7/source/frost/threads/MessageUploadThread.java  
2006-02-11 21:43:18 UTC (rev 8021)
@@ -639,7 +639,13 @@

             try {
                 // signMetadata is null for unsigned upload. Do not do 
redirect (false)
-                result = FcpInsert.putFile(upKey, uploadFile, signMetadata, 
messageUploadHtl, false);
+                result = FcpInsert.putFile(
+                        upKey, 
+                        uploadFile, 
+                        signMetadata, 
+                        messageUploadHtl, 
+                        false, // doRedirect
+                        null); // UploadItem
             } catch (Throwable t) {
                 logger.log(Level.SEVERE, "TOFUP: Error in 
run()/FcpInsert.putFile", t);
                 System.out.println("TOFUP: Error in run()/FcpInsert.putFile");

Modified: trunk/apps/frost-0.7/source/frost/threads/UpdateIdThread.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/threads/UpdateIdThread.java       
2006-02-11 19:40:07 UTC (rev 8020)
+++ trunk/apps/frost-0.7/source/frost/threads/UpdateIdThread.java       
2006-02-11 21:43:18 UTC (rev 8021)
@@ -143,7 +143,8 @@
                         zippedIndexFile, 
                         metadata, 
                         insertHtl, 
-                        false); // doRedirect
+                        false, // doRedirect
+                        null); // UploadItem

                 if( result[0].equals("PutSuccessful") ) {
                     success = true;
@@ -227,7 +228,10 @@
                                        null, 
                         target, 
                         requestHtl, // we need it faster, same as for messages
-                        false); // doRedirect, like in uploadIndexFile()
+                        false, // doRedirect, like in uploadIndexFile()
+                        false, // fastDownload
+                        true,  // createTempFile
+                        null); // DownloadItem

                 if (fcpresults == null || target.length() == 0) {
                     // download failed. Sometimes there are some 0 byte

Deleted: trunk/apps/frost-0.7/source/frost/threads/getKeyThread.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/threads/getKeyThread.java 2006-02-11 
19:40:07 UTC (rev 8020)
+++ trunk/apps/frost-0.7/source/frost/threads/getKeyThread.java 2006-02-11 
21:43:18 UTC (rev 8021)
@@ -1,106 +0,0 @@
-/*
-  getKeyThread.java / Frost
-  Copyright (C) 2001  Jan-Thomas Czornack <jantho at users.sourceforge.net>
-
-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License as
-  published by the Free Software Foundation; either version 2 of
-  the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-package frost.threads;
-
-import java.io.*;
-import java.util.logging.Logger;
-
-import frost.fcp.*;
-
-/**
- * Reads a key from Freenet
- * 
- * ATTN: this class is only used by the obsolete old non-fec splitfile 
download.
- *   Could maybe be removed completely.
- * 
- * @author Jan-Thomas Czornack
- * @version 010711
- */
-public class getKeyThread extends Thread
-{
-       private static Logger logger = 
Logger.getLogger(getKeyThread.class.getName());
-
-    private String key;
-    private File file;
-    private int htl;
-    private boolean[] results;
-    private int index;
-    private int checkSize;
-
-//    // remove later
-//    private static String[] keywords = {"Success",
-//        "RouteNotFound",
-//        "KeyCollision",
-//        "SizeError",
-//        "DataNotFound"};
-//
-//    // remove later
-//    private static String[] result(String text) {
-//        String[] result = new String[2];
-//        result[0] = "Error";
-//        result[1] = "Error";
-//
-//        for( int i = 0; i < keywords.length; i++ ) {
-//            if( text.indexOf(keywords[i]) != -1 )
-//                result[0] = keywords[i];
-//        }
-//        if( text.indexOf("CHK@") != -1 ) {
-//            result[1] = text.substring(text.lastIndexOf("CHK@"), 
text.lastIndexOf("EndMessage"));
-//            result[1] = result[1].trim();
-//        } else {
-//            result[1] = "Error";
-//        }
-//        return result;
-//    }
-
-    public void run() {
-
-        logger.fine("Requesting " + file.getName() + " with HTL " + htl + ". 
Size is " + checkSize + " bytes.");
-
-        boolean exception = false;
-        FcpConnection connection = FcpFactory.getFcpConnectionInstance();
-        if( connection != null ) {
-            try {
-                connection.getKeyToFile(key, file.getPath(), htl);
-            } catch (FcpToolsException e) {
-                exception = true;
-            } catch (IOException e) {
-                exception = true;
-            }
-        }
-
-        if( !exception && file.length() > 0 ) {
-            return; // we hope chunk download was OK ;)
-        } else {
-            // if we come here, something failed, delete file
-            results[index] = false;
-            file.delete();
-        }
-    }
-
-    public getKeyThread (String key, File file, int htl, boolean[] results, 
int index, int checkSize) {
-        this.key = key;
-        this.file = file;
-        this.htl = htl;
-        this.results = results;
-        this.index = index;
-        this.checkSize = checkSize;
-    }
-}


Reply via email to