Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 20411)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java	(revision 20412)
@@ -65,5 +65,5 @@
     final  int cRetriesGetCookie = 10; // 10 times every 3 seconds means 30 seconds trying to get a cookie
 
-    public boolean retrieveInterface(WMSLayer wmsLayer) throws DuplicateLayerException {
+    public boolean retrieveInterface(WMSLayer wmsLayer) throws DuplicateLayerException, WMSException {
         if (wmsLayer.getName().equals(""))
             return false;
@@ -75,11 +75,9 @@
             if (cookie == null || isCookieExpired())
                 getCookie();
-            if (cookie != null && interfaceRef == null) {
+            if (cookie == null)
+                throw new WMSException(tr("Cannot open a new client session.\nServer in maintenance or temporary overloaded."));
+            if (interfaceRef == null) {
                     getInterface(wmsLayer);
                     this.lastWMSLayerName = wmsLayer.getName();
-            } else {
-                JOptionPane.showMessageDialog(Main.parent,
-                        tr("Cannot open a new client session.\nServer in maintenance or temporary overloaded."));
-                return false;
             }
             openInterface();
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 20411)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java	(revision 20412)
@@ -90,5 +90,5 @@
  * 1.6 28-Nov-2009 - Fix minor issues if Grab is called without layer (possible since projection rework)
  * 1.7 12-Dec-2009 - Change URL's changes for cookie and downgrade imgs resolution due to WMS changes
- * 1.8 09-Mar-2010 - filter the mouse button 1 during georeferencing
+ * 1.8 11-Mar-2010 - filter the mouse button 1 during georeferencing
  *                 - retry if getting a new cookie failed (10 times during 30 seconds)
  *                 - cookie expiration automatically detected and renewed (after 30 minutes)
@@ -101,9 +101,11 @@
  *                 - image resolution configurable (high, medium, low) like the online interface
  *                 - layer selection configurable for vectorized images
+ *                 - improved download cancellation
  *                 - from Erik Amzallag:
  *                 -     possibility to modify the auto-sourcing text just before upload 
  *                 - from Clément Ménier:
  *                 -     new option allowing an auto-selection of the first cadastre layer for grab
- *                 -     non-modal JDialog in MenuActionGrabPlanImage  
+ *                 -     non-modal JDialog in MenuActionGrabPlanImage
+ *                 -     new options in the image filter (bilinear, bicubic)
  */
 public class CadastrePlugin extends Plugin {
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java	(revision 20411)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java	(revision 20412)
@@ -42,4 +42,6 @@
     private static EastNorthBound currentView = null;
     private EastNorthBound viewBox = null;
+    private static String errorMessage;
+
 
     public DownloadSVGBuilding(WMSLayer wmsLayer) {
@@ -53,4 +55,5 @@
     public void realRun() throws IOException, OsmTransferException {
     	progressMonitor.indeterminateSubTask(tr("Contacting WMS Server..."));
+        errorMessage = null;
         try {
             if (wmsInterface.retrieveInterface(wmsLayer)) {
@@ -65,4 +68,7 @@
         } catch (DuplicateLayerException e) {
             System.err.println("removed a duplicated layer");
+        } catch (WMSException e) {
+            errorMessage = e.getMessage();
+            grabber.getWmsInterface().resetCookie();
         }
     }
@@ -272,4 +278,6 @@
         }
         Main.worker.execute(new DownloadSVGBuilding(wmsLayer));
+        if (errorMessage != null)
+            JOptionPane.showMessageDialog(Main.parent, errorMessage);
     }
 
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java	(revision 20411)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java	(revision 20412)
@@ -46,4 +46,5 @@
     private String svg = null;
     private EastNorthBound viewBox = null;
+    private static String errorMessage;
 
     public DownloadSVGTask(WMSLayer wmsLayer) {
@@ -57,4 +58,5 @@
     public void realRun() throws IOException, OsmTransferException {
     	progressMonitor.indeterminateSubTask(tr("Contacting WMS Server..."));
+        errorMessage = null;
         try {
             if (wmsInterface.retrieveInterface(wmsLayer)) {
@@ -71,4 +73,7 @@
         } catch (DuplicateLayerException e) {
             System.err.println("removed a duplicated layer");
+        } catch (WMSException e) {
+            errorMessage = e.getMessage();
+            grabber.getWmsInterface().resetCookie();
         }
     }
@@ -218,4 +223,6 @@
         }
         Main.worker.execute(new DownloadSVGTask(wmsLayer));
+        if (errorMessage != null)
+            JOptionPane.showMessageDialog(Main.parent, errorMessage);
     }
 
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSPlanImage.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSPlanImage.java	(revision 20411)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSPlanImage.java	(revision 20412)
@@ -21,4 +21,5 @@
     private Bounds bounds;
     private boolean dontGeoreference = false;
+    private static String errorMessage;
     
     private class Task extends PleaseWaitRunnable {
@@ -31,4 +32,5 @@
         public void realRun() throws IOException {
             progressMonitor.indeterminateSubTask(tr("Contacting cadastre WMS ..."));
+            errorMessage = null;
             try {
                 if (grabber.getWmsInterface().retrieveInterface(wmsLayer)) {
@@ -85,4 +87,7 @@
                 // we tried to grab onto a duplicated layer (removed)
                 System.err.println("removed a duplicated layer");
+            } catch (WMSException e) {
+                errorMessage = e.getMessage();
+                grabber.getWmsInterface().resetCookie();
             }
         }
@@ -108,4 +113,6 @@
         this.bounds = bounds;
         task = Main.worker.submit(t, t);
+        if (errorMessage != null)
+            JOptionPane.showMessageDialog(Main.parent, errorMessage);
     }
 
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java	(revision 20411)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java	(revision 20412)
@@ -5,4 +5,6 @@
 
 import java.io.IOException;
+
+import javax.swing.JOptionPane;
 
 import org.openstreetmap.josm.Main;
@@ -14,8 +16,7 @@
 
     private WMSLayer wmsLayer;
-
-    private Bounds bounds;
-    
-    private CadastreGrabber grabber = CadastrePlugin.cadastreGrabber;
+    private Bounds bounds;    
+    private CadastreGrabber grabber = CadastrePlugin.cadastreGrabber;    
+    private static String errorMessage;
 
     public DownloadWMSVectorImage(WMSLayer wmsLayer, Bounds bounds, boolean buildingsOnly) {
@@ -30,4 +31,5 @@
     public void realRun() throws IOException {
         progressMonitor.indeterminateSubTask(tr("Contacting WMS Server..."));
+        errorMessage = null;
         try {
             if (grabber.getWmsInterface().retrieveInterface(wmsLayer)) {
@@ -62,4 +64,7 @@
             // we tried to grab onto a duplicated layer (removed)
             System.err.println("removed a duplicated layer");
+        } catch (WMSException e) {
+            errorMessage = e.getMessage();
+            grabber.getWmsInterface().resetCookie();
         }
     }
@@ -68,4 +73,6 @@
     protected void cancel() {
         grabber.getWmsInterface().cancel();
+        if (wmsLayer != null)
+            wmsLayer.cancelled = true;
     }
 
@@ -79,5 +86,6 @@
 
         Main.worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds, buildingsOnly));
-
+        if (errorMessage != null)
+            JOptionPane.showMessageDialog(Main.parent, errorMessage);
     }
 }
Index: /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
===================================================================
--- /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 20411)
+++ /applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java	(revision 20412)
@@ -72,4 +72,6 @@
     public EastNorthBound communeBBox = new EastNorthBound(new EastNorth(0,0), new EastNorth(0,0));
 
+    public boolean cancelled;
+
     private boolean isRaster = false;
     private boolean isAlreadyGeoreferenced = false;
@@ -132,4 +134,5 @@
     
     public void grab(CadastreGrabber grabber, Bounds b, boolean useFactor) throws IOException {
+        cancelled = false;
         if (useFactor) {
             if (isRaster) {
@@ -146,4 +149,6 @@
         int lastSavedImage = images.size();
         for (EastNorthBound n : dividedBbox) {
+            if (cancelled)
+                return;
             GeorefImage newImage;
             try {
