Changeset 5898 in josm for trunk


Ignore:
Timestamp:
2013-04-21T16:27:21+02:00 (7 years ago)
Author:
Don-vip
Message:

see #8606 - Set User-Agent for JMapViewer connections

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r5779 r5898  
    1111import java.awt.Point;
    1212import java.awt.Rectangle;
    13 import java.io.File;
    1413import java.io.IOException;
    1514import java.util.ArrayList;
     
    2726import org.openstreetmap.gui.jmapviewer.MapMarkerDot;
    2827import org.openstreetmap.gui.jmapviewer.MemoryTileCache;
    29 import org.openstreetmap.gui.jmapviewer.OsmFileCacheTileLoader;
    3028import org.openstreetmap.gui.jmapviewer.OsmMercator;
    3129import org.openstreetmap.gui.jmapviewer.OsmTileLoader;
    3230import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker;
    33 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader;
    34 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener;
    3531import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
    3632import org.openstreetmap.gui.jmapviewer.tilesources.MapQuestOpenAerialTileSource;
     
    3935import org.openstreetmap.josm.Main;
    4036import org.openstreetmap.josm.data.Bounds;
     37import org.openstreetmap.josm.data.Version;
    4138import org.openstreetmap.josm.data.coor.LatLon;
    4239import org.openstreetmap.josm.data.imagery.ImageryInfo;
     
    171168    public static final String RESIZE_PROP = SlippyMapBBoxChooser.class.getName() + ".resize";
    172169
    173     private TileLoader cachedLoader;
    174     private TileLoader uncachedLoader;
     170    private OsmTileLoader cachedLoader;
     171    private OsmTileLoader uncachedLoader;
    175172
    176173    private final SizeButton iSizeButton = new SizeButton();
     
    189186
    190187        uncachedLoader = new OsmTileLoader(this);
     188        uncachedLoader.headers.put("User-Agent", Version.getInstance().getFullAgentString());
    191189        setZoomContolsVisible(Main.pref.getBoolean("slippy_map_chooser.zoomcontrols",false));
    192190        setMapMarkerVisible(false);
  • trunk/src/org/openstreetmap/josm/gui/bbox/TileSelectionBBoxChooser.java

    r5886 r5898  
    4242import org.openstreetmap.gui.jmapviewer.MapMarkerDot;
    4343import org.openstreetmap.gui.jmapviewer.OsmMercator;
     44import org.openstreetmap.gui.jmapviewer.OsmTileLoader;
    4445import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker;
     46import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader;
    4547import org.openstreetmap.josm.data.Bounds;
     48import org.openstreetmap.josm.data.Version;
    4649import org.openstreetmap.josm.data.coor.LatLon;
    4750import org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator;
     
    120123    }
    121124
     125    /**
     126     * Constructs a new {@code TileSelectionBBoxChooser}.
     127     */
    122128    public TileSelectionBBoxChooser() {
    123129        build();
     
    655661        public TileBoundsMapView() {
    656662            setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
     663            TileLoader loader = tileController.getTileLoader();
     664            if (loader instanceof OsmTileLoader) {
     665                ((OsmTileLoader)loader).headers.put("User-Agent", Version.getInstance().getFullAgentString());
     666            }
    657667        }
    658668
  • trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java

    r4336 r5898  
    66
    77import java.awt.Dimension;
    8 import java.awt.Graphics;
    98import java.awt.Toolkit;
    10 
    119import java.beans.PropertyChangeEvent;
    1210import java.beans.PropertyChangeListener;
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r5874 r5898  
    5757import org.openstreetmap.josm.actions.RenameLayerAction;
    5858import org.openstreetmap.josm.data.Bounds;
     59import org.openstreetmap.josm.data.Version;
    5960import org.openstreetmap.josm.data.coor.EastNorth;
    6061import org.openstreetmap.josm.data.coor.LatLon;
     
    133134            if (cachePath != null && !cachePath.isEmpty()) {
    134135                try {
    135                     return new OsmFileCacheTileLoader(listener, new File(cachePath));
     136                    OsmFileCacheTileLoader loader = new OsmFileCacheTileLoader(listener, new File(cachePath));
     137                    loader.headers.put("User-Agent", Version.getInstance().getFullAgentString());
     138                    return loader;
    136139                } catch (IOException e) {
    137140                }
     
    418421            }
    419422        }
     423        tileLoader.headers.put("User-Agent", Version.getInstance().getFullAgentString());
    420424    }
    421425
Note: See TracChangeset for help on using the changeset viewer.