Author: jflesch
Date: 2007-08-29 15:51:08 +0000 (Wed, 29 Aug 2007)
New Revision: 14912

Modified:
   trunk/apps/Thaw/src/thaw/core/Config.java
   trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
   trunk/apps/Thaw/src/thaw/core/Core.java
   trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java
   trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
   trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
   trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
Log:
Make it possible to never download automatically files from the node (advanced 
mode only)

Modified: trunk/apps/Thaw/src/thaw/core/Config.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Config.java   2007-08-29 03:46:21 UTC (rev 
14911)
+++ trunk/apps/Thaw/src/thaw/core/Config.java   2007-08-29 15:51:08 UTC (rev 
14912)
@@ -353,6 +353,9 @@
                        setValue(name, val);
        }

+       /**
+        * don't override the values if already existing
+        */
        public void setDefaultValues() {
                setDefaultValue("nodeAddress", "127.0.0.1");
                setDefaultValue("nodePort", "9481");
@@ -363,6 +366,7 @@
                setDefaultValue("advancedMode", "false");
                setDefaultValue("userNickname", "Another anonymous");
                setDefaultValue("multipleSockets", "true");
+               setDefaultValue("downloadLocally", "true");
                setDefaultValue("sameComputer", "true");
        }


Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java     2007-08-29 03:46:21 UTC 
(rev 14911)
+++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java     2007-08-29 15:51:08 UTC 
(rev 14912)
@@ -79,10 +79,10 @@
                configWin.getContentPane().add(tabs, BorderLayout.CENTER);
                configWin.getContentPane().add(buttons, BorderLayout.SOUTH);

-               tabs.setSize(600, 360);
-               okButton.setSize(100, 40);
+               //tabs.setSize(600, 360);
+               //okButton.setSize(100, 40);

-               configWin.setSize(600, 450);
+               configWin.setSize(600, 470);
                //configWin.setResizable(false);

                okButton.addActionListener(this);

Modified: trunk/apps/Thaw/src/thaw/core/Core.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Core.java     2007-08-29 03:46:21 UTC (rev 
14911)
+++ trunk/apps/Thaw/src/thaw/core/Core.java     2007-08-29 15:51:08 UTC (rev 
14912)
@@ -159,10 +159,10 @@
        public boolean initConfig() {
                config = new Config(this, Config.CONFIG_FILE_NAME);

-               if(!config.loadConfig()){
-                       config.setDefaultValues();
-               }
+               config.loadConfig();

+               config.setDefaultValues();
+
                if (config.getValue("tmpDir") != null)
                        System.setProperty("java.io.tmpdir", 
config.getValue("tmpDir"));

@@ -270,7 +270,8 @@
                                                               
Integer.parseInt(config.getValue("nodePort")),
                                                               
Integer.parseInt(config.getValue("maxUploadSpeed")),
                                                               
Boolean.valueOf(config.getValue("multipleSockets")).booleanValue(),
-                                                              
Boolean.valueOf(config.getValue("sameComputer")).booleanValue());
+                                                              
Boolean.valueOf(config.getValue("sameComputer")).booleanValue(),
+                                                              
Boolean.valueOf(config.getValue("downloadLocally")).booleanValue());
                        } else { /* connection is not recreate to avoid 
troubles with possible observers etc */
                                connection.deleteObserver(this);
                                
connection.setNodeAddress(config.getValue("nodeAddress"));
@@ -278,6 +279,7 @@
                                
connection.setMaxUploadSpeed(Integer.parseInt(config.getValue("maxUploadSpeed")));
                                
connection.setDuplicationAllowed(Boolean.valueOf(config.getValue("multipleSockets")).booleanValue());
                                
connection.setLocalSocket(Boolean.valueOf(config.getValue("sameComputer")).booleanValue());
+                               
connection.setAutoDownload(Boolean.valueOf(config.getValue("downloadLocally")).booleanValue());
                        }

                        if(!connection.connect()) {

Modified: trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java  2007-08-29 03:46:21 UTC 
(rev 14911)
+++ trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java  2007-08-29 15:51:08 UTC 
(rev 14912)
@@ -11,11 +11,15 @@
 import javax.swing.JTextField;
 import javax.swing.JButton;

+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
 /**
  * NodeConfigPanel. Creates and manages the panel containing all the things to 
configure
  *  the settings to access the node.
  */
-public class NodeConfigPanel implements Observer {
+public class NodeConfigPanel implements Observer, ActionListener {
+
        private Core core;
        private JPanel nodeConfigPanel = null;

@@ -52,6 +56,7 @@
        private ConfigWindow configWindow = null;

        private JCheckBox multipleSockets = null;
+       private JCheckBox downloadLocally = null;
        private JCheckBox sameComputer = null; /* if thaw and the node are on 
the same computer */


@@ -63,9 +68,10 @@
                                             
I18n.getMessage("thaw.config.desactivateIfTroubles"),
                                             
Boolean.valueOf(core.getConfig().getValue("sameComputer")).booleanValue());
                sameComputer.setVisible(true);
+               sameComputer.addActionListener(this);

                nodeConfigPanel = new JPanel();
-               nodeConfigPanel.setLayout(new GridLayout(16, 1));
+               nodeConfigPanel.setLayout(new GridLayout(17, 1));

                for(int i=0; i < NodeConfigPanel.paramNames.length ; i++) {
                        String value;
@@ -102,8 +108,11 @@

                multipleSockets = new 
JCheckBox(I18n.getMessage("thaw.config.multipleSockets"),
                                                
Boolean.valueOf(core.getConfig().getValue("multipleSockets")).booleanValue());
+               downloadLocally = new 
JCheckBox(I18n.getMessage("thaw.config.downloadLocally"),
+                                               
Boolean.valueOf(core.getConfig().getValue("downloadLocally")).booleanValue());

                nodeConfigPanel.add(new JLabel(" "));
+               nodeConfigPanel.add(downloadLocally);
                nodeConfigPanel.add(multipleSockets);

                
setVisibility(Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue());
@@ -127,6 +136,7 @@
                        paramFields[i].setVisible(advancedMode);
                }

+               downloadLocally.setVisible(advancedMode);
                multipleSockets.setVisible(advancedMode);
        }

@@ -145,6 +155,10 @@
                    || 
!core.getConfig().getValue("sameComputer").equals(Boolean.toString(sameComputer.isSelected())))
                        return true;

+               if ((core.getConfig().getValue("downloadLocally") == null)
+                   || 
!core.getConfig().getValue("downloadLocally").equals(Boolean.toString(downloadLocally.isSelected())))
+                       return true;
+
                return false;
        }

@@ -172,6 +186,7 @@

                        core.getConfig().setValue("multipleSockets", 
Boolean.toString(multipleSockets.isSelected()));
                        core.getConfig().setValue("sameComputer", 
Boolean.toString(sameComputer.isSelected()));
+                       core.getConfig().setValue("downloadLocally", 
Boolean.toString(downloadLocally.isSelected()));

                        
setVisibility(Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue());
                }
@@ -195,6 +210,11 @@

                
multipleSockets.setSelected(Boolean.valueOf(core.getConfig().getValue("multipleSockets")).booleanValue());
                
sameComputer.setSelected(Boolean.valueOf(core.getConfig().getValue("sameComputer")).booleanValue());
+               
downloadLocally.setSelected(Boolean.valueOf(core.getConfig().getValue("downloadLocally")).booleanValue());
        }

+
+       public void actionPerformed(ActionEvent e) {
+               downloadLocally.setEnabled(!sameComputer.isSelected());
+       }
 }

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2007-08-29 03:46:21 UTC 
(rev 14911)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2007-08-29 15:51:08 UTC 
(rev 14912)
@@ -352,8 +352,9 @@
                                        if(isPersistent()
                                           || 
(queueManager.getQueryManager().getConnection().isLocalSocket() && !noDDA)) {
                                                if(destinationDir != null) {
-                                                       if(!fileExists()
-                                                          && 
!(queueManager.getQueryManager().getConnection().isLocalSocket() && !noDDA)) {
+                                                       if (!fileExists()
+                                                           && 
!(queueManager.getQueryManager().getConnection().isLocalSocket() && !noDDA)
+                                                           && 
queueManager.getQueryManager().getConnection().getAutoDownload()) {
                                                                status = 
"Requesting file from the node";
                                                                progress = 99;
                                                                running = true;

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java     2007-08-29 03:46:21 UTC 
(rev 14911)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java     2007-08-29 15:51:08 UTC 
(rev 14912)
@@ -49,6 +49,7 @@

        private boolean duplicationAllowed = true;
        private boolean localSocket = false;
+       private boolean autoDownload = true;

        private FCPClientHello clientHello;

@@ -58,12 +59,15 @@
         * @param maxUploadSpeed in KB: -1 means no limit
         * @param duplicationAllowed FCPClientGet and FCPClientPut will be 
allowed to
         *                           open a separate socket to transfer the 
files
+        * @param autoDownload If !localSocket and if autoDownload, then files 
are automatically downloaded
+        *                     when the transfer ends
         */
        public FCPConnection(final String nodeAddress,
                             final int port,
                             int maxUploadSpeed,
                             boolean duplicationAllowed,
-                            final boolean localSocket)
+                            final boolean localSocket,
+                            final boolean autoDownload)
        {
                if (localSocket)
                        duplicationAllowed = false;
@@ -81,6 +85,7 @@
                setMaxUploadSpeed(maxUploadSpeed);
                setDuplicationAllowed(duplicationAllowed);
                setLocalSocket(localSocket);
+               setAutoDownload(autoDownload);

                writersWaiting = 0;
        }
@@ -106,6 +111,14 @@
                localSocket = local;
        }

+       public void setAutoDownload(final boolean autoDownload) {
+               this.autoDownload = autoDownload;
+       }
+
+       public boolean getAutoDownload() {
+               return autoDownload;
+       }
+
        public boolean isLocalSocket() {
                return localSocket;
        }
@@ -477,7 +490,8 @@
                /* upload limit is useless here, since we can't do a global 
limit
                 * on all the connections */
                newConnection = new FCPConnection(nodeAddress, port, -1,
-                                                 duplicationAllowed, 
localSocket);
+                                                 duplicationAllowed, 
localSocket,
+                                                 autoDownload);

                if (!newConnection.connect()) {
                        Logger.warning(this, "Unable to duplicate socket !");

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-08-29 
03:46:21 UTC (rev 14911)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-08-29 
15:51:08 UTC (rev 14912)
@@ -154,7 +154,9 @@

 thaw.config.uncheckIfProblem=(D?sactiver cette option en cas de probl?me)

+thaw.config.downloadLocally=T?l?charger les fichiers depuis la node

+
 ## Plugins
 thaw.plugin.queueWatcher=Transferts


Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-08-29 03:46:21 UTC 
(rev 14911)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-08-29 15:51:08 UTC 
(rev 14912)
@@ -153,9 +153,9 @@

 thaw.config.uncheckIfProblem=(Uncheck this option if you have any troubles)

+thaw.config.downloadLocally=Download files from the node


-
 ######## Plugins

 thaw.plugin.queueWatcher=Transfers


Reply via email to