Author: jflesch
Date: 2007-05-13 18:18:13 +0000 (Sun, 13 May 2007)
New Revision: 13236

Modified:
   trunk/apps/Thaw/src/thaw/core/Core.java
   trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.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
Log:
Fix issue #1363 : Thaw now display a popup asking for desactive the DDA if a 
ProtocolError is received

Modified: trunk/apps/Thaw/src/thaw/core/Core.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Core.java     2007-05-13 16:13:35 UTC (rev 
13235)
+++ trunk/apps/Thaw/src/thaw/core/Core.java     2007-05-13 18:18:13 UTC (rev 
13236)
@@ -17,6 +17,7 @@
 import thaw.fcp.FCPQueueLoader;
 import thaw.fcp.FCPQueueManager;
 import thaw.fcp.FCPWatchGlobal;
+import thaw.fcp.FCPMessage;

 import thaw.gui.IconBox;

@@ -44,7 +45,7 @@
        public final static int TIME_BETWEEN_EACH_TRY = 5000;

        private ReconnectionManager reconnectionManager = null;
-       
+
        private static final Random RANDOM = new Yarrow();

        // MDNS stuffs
@@ -290,8 +291,10 @@
                                ret = false;
                        }

-                       if(queryManager == null)
+                       if(queryManager == null) {
                                queryManager = new FCPQueryManager(connection);
+                               queryManager.addObserver(this);
+                       }

                        if(queueManager == null)
                                queueManager = new FCPQueueManager(queryManager,
@@ -591,12 +594,57 @@
        }


+       public void askToDisableDDA() {
+               String text =
+                       I18n.getMessage("thaw.warning.DDA.l0") + "\n" +
+                       I18n.getMessage("thaw.warning.DDA.l1") + "\n" +
+                       I18n.getMessage("thaw.warning.DDA.l2") + "\n" +
+                       I18n.getMessage("thaw.warning.DDA.l3") + "\n" +
+                       I18n.getMessage("thaw.warning.DDA.l4");
+
+               text = text.replace("#", 
I18n.getMessage("thaw.config.sameComputer"));
+
+               int ret = 
JOptionPane.showConfirmDialog(mainWindow.getMainFrame(),
+                                                       text,
+                                                       
I18n.getMessage("thaw.warning.title"),
+                                                       
JOptionPane.YES_NO_OPTION,
+                                                       
JOptionPane.WARNING_MESSAGE);
+
+               if (ret == JOptionPane.YES_OPTION) {
+                       getConfig().setValue("sameComputer", 
Boolean.toString(false));
+                       getConnectionManager().setLocalSocket(false);
+                       getConfigWindow().close(true, false);
+                       /* if we are lucky, it's enought */
+               }
+       }
+
+
        public void update(final Observable o, final Object target) {
                Logger.debug(this, "Move on the connection (?)");

-               if((o == connection) && !connection.isConnected()) {
+               if ((o == connection) && !connection.isConnected()) {
                        reconnect();
                }
+
+               if ((o == queryManager) && target instanceof FCPMessage) {
+                       FCPMessage m = (FCPMessage)target;
+
+                       if ("ProtocolError".equals(m.getMessageName())) {
+                               int code = Integer.parseInt(m.getValue("Code"));
+
+                               if (code == 9 /* File not found */
+                                   || code == 10 /* Disk target exists */
+                                   || code == 12 /* Couldn't create file */
+                                   || code == 13 /* Couldn't write file */
+                                   || code == 14 /* Couldn't rename file */
+                                   || code == 22 /* File parse error */
+                                   || code == 25 /* DDA denied */
+                                   || code == 26 /* Could not read file */) {
+                                       askToDisableDDA();
+                               }
+
+                       }
+               }
        }



Modified: trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java  2007-05-13 16:13:35 UTC 
(rev 13235)
+++ trunk/apps/Thaw/src/thaw/core/NodeConfigPanel.java  2007-05-13 18:18:13 UTC 
(rev 13236)
@@ -62,10 +62,11 @@
        public NodeConfigPanel(final ConfigWindow configWindow, final Core 
core) {
                this.core = core;
                this.configWindow = configWindow;
-               
+
                mdnsPanel = new MDNSDiscoveryPanel(configWindow.getFrame(), 
core, this);

-               sameComputer = new 
JCheckBox(I18n.getMessage("thaw.config.sameComputer"),
+               sameComputer = new 
JCheckBox(I18n.getMessage("thaw.config.sameComputer") + " " +
+                                            
I18n.getMessage("thaw.config.desactivateIfTroubles"),
                                             
Boolean.valueOf(core.getConfig().getValue("sameComputer")).booleanValue());
                sameComputer.setVisible(true);

@@ -196,6 +197,7 @@
                }

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

        public void actionPerformed(java.awt.event.ActionEvent event) {

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-05-13 
16:13:35 UTC (rev 13235)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-05-13 
18:18:13 UTC (rev 13236)
@@ -130,8 +130,10 @@

 thaw.config.multipleSockets=Autoriser Thaw ? echanger plusieurs fichiers ? la 
fois avec le noeud

-thaw.config.sameComputer=Thaw et le noeud Freenet sont sur le m?me ordinateur 
(? d?sactiver en cas de probl?me)
+thaw.config.sameComputer=Thaw et le noeud Freenet sont sur le m?me ordinateur
+thaw.config.desactivateIfTroubles=(? d?sactiver en cas de probl?me)

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



Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-05-13 16:13:35 UTC 
(rev 13235)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-05-13 18:18:13 UTC 
(rev 13236)
@@ -131,7 +131,8 @@

 thaw.config.multipleSockets=Allow Thaw to exchange many files at once with the 
node

-thaw.config.sameComputer=Thaw and the Freenet node are on the same computer. 
(Uncheck it if any problem)
+thaw.config.sameComputer=Thaw and the Freenet node are on the same computer.
+thaw.config.desactivateIfTroubles=(Uncheck it if any problem)

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

@@ -209,7 +210,13 @@
 thaw.warning.autoreconnecting=Disconnected. Thaw is trying to automatically 
reconnect ...


+thaw.warning.DDA.l0=Thaw had some troubles using Direct Disk Access.
+thaw.warning.DDA.l1=Do you want to desactivate this option?
+thaw.warning.DDA.l2=This option can be reactivated by checking
+thaw.warning.DDA.l3='#' in the configuration.
+thaw.warning.DDA.l4=If you desactive it, you may have to restart some 
transfers.

+
 ## Toolbar
 thaw.toolbar.title=Toolbar Thaw
 thaw.toolbar.button.connect=Connect

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-05-13 16:13:35 UTC 
(rev 13235)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-05-13 18:18:13 UTC 
(rev 13236)
@@ -130,8 +130,10 @@

 thaw.config.multipleSockets=Autoriser Thaw \u00e0 echanger plusieurs fichiers 
\u00e0 la fois avec le noeud

-thaw.config.sameComputer=Thaw et le noeud Freenet sont sur le m\u00eame 
ordinateur (\u00c0 d\u00e9sactiver en cas de probl\u00e8me)
+thaw.config.sameComputer=Thaw et le noeud Freenet sont sur le m\u00eame 
ordinateur
+thaw.config.desactivateIfTroubles=(\u00c0 d\u00e9sactiver en cas de 
probl\u00e8me)

+
 thaw.config.uncheckIfProblem=(D\u00e9sactiver cette option en cas de 
probl\u00e8me)




Reply via email to