Index: applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/PermissionPref.java
===================================================================
--- applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/PermissionPref.java	(revision 22734)
+++ applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/PermissionPref.java	(revision 23189)
@@ -7,18 +7,18 @@
  *
  * Use @see PermissionPrefWithDefault instead of this class.
- * 
+ *
  * @author Bodo Meissner
  */
  @Deprecated
 public class PermissionPref {
-	/** name of the preference setting to permit the remote operation */
-	String pref;
-	/** message to be displayed if operation is not permitted */
-	String message;
-	
-	public PermissionPref(String pref, String message)
-	{
-		this.pref = pref;
-		this.message = message;
-	}
+    /** name of the preference setting to permit the remote operation */
+    String pref;
+    /** message to be displayed if operation is not permitted */
+    String message;
+
+    public PermissionPref(String pref, String message)
+    {
+        this.pref = pref;
+        this.message = message;
+    }
 }
Index: applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/PermissionPrefWithDefault.java
===================================================================
--- applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/PermissionPrefWithDefault.java	(revision 22734)
+++ applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/PermissionPrefWithDefault.java	(revision 23189)
@@ -2,7 +2,7 @@
 
 /**
- * This class should replace PermissionPref because it allows explicit 
+ * This class should replace PermissionPref because it allows explicit
  * specification of the permission's default value.
- * 
+ *
  * @author Bodo Meissner
  */
@@ -10,13 +10,13 @@
 public class PermissionPrefWithDefault extends PermissionPref {
 
-	boolean defaultVal = true;
+    boolean defaultVal = true;
 
-	public PermissionPrefWithDefault(String pref, boolean defaultVal, String message) {
-		super(pref, message);
-		this.defaultVal = defaultVal;
-	}
+    public PermissionPrefWithDefault(String pref, boolean defaultVal, String message) {
+        super(pref, message);
+        this.defaultVal = defaultVal;
+    }
 
-	public PermissionPrefWithDefault(PermissionPref prefWithoutDefault) {
-		super(prefWithoutDefault.pref, prefWithoutDefault.message);
-	}
+    public PermissionPrefWithDefault(PermissionPref prefWithoutDefault) {
+        super(prefWithoutDefault.pref, prefWithoutDefault.message);
+    }
 }
Index: applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RemoteControlPlugin.java
===================================================================
--- applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RemoteControlPlugin.java	(revision 22734)
+++ applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RemoteControlPlugin.java	(revision 23189)
@@ -8,11 +8,11 @@
 
 /**
- * Base plugin for remote control operations. 
+ * Base plugin for remote control operations.
  * This plugin contains operations that use JOSM core only.
- * 
- * Other plugins can register additional operations by calling 
+ *
+ * Other plugins can register additional operations by calling
  * @see addRequestHandler().
  * To allow API changes this plugin contains a @see getVersion() method.
- * 
+ *
  * IMPORTANT! increment the minor version on compatible API extensions
  * and increment the major version and set minor to 0 on incompatible changes.
@@ -20,37 +20,37 @@
 public class RemoteControlPlugin extends Plugin
 {
-	/** API version
-	 * IMPORTANT! update the version number on API changes.
-	 */
-	static final int apiMajorVersion = 1;
-	static final int apiMinorVersion = 0;
-	
-	/**
-	 * RemoteControl HTTP protocol version. Change minor number for compatible
-	 * interface extensions. Change major number in case of incompatible
-	 * changes.
-	 */
-	static final int protocolMajorVersion = 1;
-	static final int protocolMinorVersion = 2;
-	
+    /** API version
+     * IMPORTANT! update the version number on API changes.
+     */
+    static final int apiMajorVersion = 1;
+    static final int apiMinorVersion = 0;
+
+    /**
+     * RemoteControl HTTP protocol version. Change minor number for compatible
+     * interface extensions. Change major number in case of incompatible
+     * changes.
+     */
+    static final int protocolMajorVersion = 1;
+    static final int protocolMinorVersion = 2;
+
     /** The HTTP server this plugin launches */
     static HttpServer server;
 
     /**
-     * Returns an array of int values with major and minor API version 
+     * Returns an array of int values with major and minor API version
      * and major and minor HTTP protocol version.
-     *  
+     *
      * The function returns an int[4] instead of an object with fields
      * to avoid ClassNotFound errors with old versions of remotecontrol.
-     *  
-     * @return array of integer version numbers: 
+     *
+     * @return array of integer version numbers:
      *    apiMajorVersion, apiMinorVersion, protocolMajorVersion, protocolMajorVersion
      */
     public int[] getVersion()
     {
-    	int versions[] = {apiMajorVersion, apiMinorVersion, protocolMajorVersion, protocolMajorVersion};
-    	return versions;
+        int versions[] = {apiMajorVersion, apiMinorVersion, protocolMajorVersion, protocolMajorVersion};
+        return versions;
     }
-    
+
     /**
      * Creates the plugin, and starts the HTTP server
@@ -58,9 +58,9 @@
     public RemoteControlPlugin(PluginInformation info)
     {
-    	super(info);
-    	/*
-		System.out.println("constructor " + this.getClass().getName() + " (" + info.name +
-				" v " + info.version + " stage " + info.stage + ")");
-		*/
+        super(info);
+        /*
+        System.out.println("constructor " + this.getClass().getName() + " (" + info.name +
+                " v " + info.version + " stage " + info.stage + ")");
+        */
         restartServer();
     }
@@ -103,4 +103,4 @@
         RequestProcessor.addRequestHandlerClass(command, handlerClass);
     }
-    
+
 }
Index: applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RequestHandler.java
===================================================================
--- applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RequestHandler.java	(revision 22734)
+++ applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RequestHandler.java	(revision 23189)
@@ -11,18 +11,18 @@
 
 /**
- * This is the parent of all classes that handle a specific command 
+ * This is the parent of all classes that handle a specific command
  * in remote control plug-in.
- *   
+ *
  * @author Bodo Meissner
  */
 public abstract class RequestHandler
 {
-	public static final String globalConfirmationKey = "remotecontrol.always-confirm";
-	public static final boolean globalConfirmationDefault = false;
-	
-	/** The GET request arguments */
-	protected HashMap<String,String> args;
-	
-	/** The request URL without "GET". */
+    public static final String globalConfirmationKey = "remotecontrol.always-confirm";
+    public static final boolean globalConfirmationDefault = false;
+
+    /** The GET request arguments */
+    protected HashMap<String,String> args;
+
+    /** The request URL without "GET". */
     protected String request;
 
@@ -34,8 +34,8 @@
     /** will be filled with the command assigned to the subclass */
     protected String myCommand;
-    
+
     /**
      * Check permission and parameters and handle request.
-     * 
+     *
      * @throws RequestHandlerForbiddenException
      * @throws RequestHandlerBadRequestException
@@ -44,16 +44,16 @@
     final void handle() throws RequestHandlerForbiddenException, RequestHandlerBadRequestException, RequestHandlerErrorException
     {
-    	checkPermission();
-    	checkMandatoryParams();
-    	handleRequest();
-    }
-    
+        checkPermission();
+        checkMandatoryParams();
+        handleRequest();
+    }
+
     /**
      * Handle a specific command sent as remote control.
-     * 
-     * This method of the subclass will do the real work.  
-     * 
+     *
+     * This method of the subclass will do the real work.
+     *
      * @throws RequestHandlerErrorException
-     * @throws RequestHandlerBadRequestException 
+     * @throws RequestHandlerBadRequestException
      */
     protected abstract void handleRequest() throws RequestHandlerErrorException, RequestHandlerBadRequestException;
@@ -62,8 +62,8 @@
      * Get a specific message to ask the user for permission for the operation
      * requested via remote control.
-     * 
+     *
      * This message will be displayed to the user if the preference
      * remotecontrol.always-confirm is true.
-     * 
+     *
      * @return the message
      */
@@ -74,12 +74,12 @@
      * preference to individually allow the requested operation and an error
      * message to be displayed when a disabled operation is requested.
-     * 
-     * Default is not to check any special preference. Override this in a 
+     *
+     * Default is not to check any special preference. Override this in a
      * subclass to define permission preference and error message.
-     * 
+     *
      * @return the preference name and error message or null
      */
-	@SuppressWarnings("deprecation")
-	public PermissionPref getPermissionPref()
+    @SuppressWarnings("deprecation")
+    public PermissionPref getPermissionPref()
     {
         /* Example:
@@ -93,20 +93,20 @@
     protected String[] getMandatoryParams()
     {
-    	return null;
-    }
-    
-    /**
-     * Check permissions in preferences and display error message 
+        return null;
+    }
+
+    /**
+     * Check permissions in preferences and display error message
      * or ask for permission.
-     * 
+     *
      * @throws RequestHandlerForbiddenException
      */
     @SuppressWarnings("deprecation")
-	final public void checkPermission() throws RequestHandlerForbiddenException
-    {
-        /* 
+    final public void checkPermission() throws RequestHandlerForbiddenException
+    {
+        /*
          * If the subclass defines a specific preference and if this is set
          * to false, abort with an error message.
-         * 
+         *
          * Note: we use the deprecated class here for compatibility with
          * older versions of WMSPlugin.
@@ -118,12 +118,12 @@
             if(permissionPref instanceof PermissionPrefWithDefault)
             {
-            	permissionPrefWithDefault = (PermissionPrefWithDefault) permissionPref;
-            }
-            else 
+                permissionPrefWithDefault = (PermissionPrefWithDefault) permissionPref;
+            }
+            else
             {
-            	permissionPrefWithDefault = new PermissionPrefWithDefault(permissionPref);
+                permissionPrefWithDefault = new PermissionPrefWithDefault(permissionPref);
             }
             if (!Main.pref.getBoolean(permissionPrefWithDefault.pref,
-            		permissionPrefWithDefault.defaultVal)) {
+                    permissionPrefWithDefault.defaultVal)) {
                 System.out.println(permissionPrefWithDefault.message);
                 throw new RequestHandlerForbiddenException();
@@ -147,61 +147,61 @@
     /**
      * Set request URL and parse args.
-     * 
+     *
      * @param url The request URL.
      */
-	public void setUrl(String url) {
-		this.request = url;
-		parseArgs();
-	}
-
-	/**
-	 * Parse the request parameters as key=value pairs.
-	 * The result will be stored in this.args.
-	 * 
-	 * Can be overridden by subclass.
-	 */
-	protected void parseArgs() {
-		StringTokenizer st = new StringTokenizer(this.request, "&?");
-		HashMap<String, String> args = new HashMap<String, String>();
-		// ignore first token which is the command
-		if(st.hasMoreTokens()) st.nextToken();
-		while (st.hasMoreTokens()) {
-			String param = st.nextToken();
-			int eq = param.indexOf("=");
-			if (eq > -1)
-				args.put(param.substring(0, eq),
+    public void setUrl(String url) {
+        this.request = url;
+        parseArgs();
+    }
+
+    /**
+     * Parse the request parameters as key=value pairs.
+     * The result will be stored in this.args.
+     *
+     * Can be overridden by subclass.
+     */
+    protected void parseArgs() {
+        StringTokenizer st = new StringTokenizer(this.request, "&?");
+        HashMap<String, String> args = new HashMap<String, String>();
+        // ignore first token which is the command
+        if(st.hasMoreTokens()) st.nextToken();
+        while (st.hasMoreTokens()) {
+            String param = st.nextToken();
+            int eq = param.indexOf("=");
+            if (eq > -1)
+                args.put(param.substring(0, eq),
                          param.substring(eq + 1));
-		}
-		this.args = args;
-	}
-	
-	void checkMandatoryParams() throws RequestHandlerBadRequestException
-	{
-		String[] mandatory = getMandatoryParams();
-		if(mandatory == null) return;
-		
-		boolean error = false;
-		for(int i = 0; i < mandatory.length; ++i)
-		{
-			String key = mandatory[i];
-			String value = args.get(key);
-			if((value == null) || (value.length() == 0))
-			{
-				error = true;
-				System.out.println("'" + myCommand + "' remote control request must have '" + key + "' parameter");
-			}
-		}
-		if(error) throw new RequestHandlerBadRequestException();
-	}
-	
-	/**
-	 * Save command associated with this handler.
-	 * 
-	 * @param command The command.
-	 */
-	public void setCommand(String command)
-	{
-		if(command.charAt(0) == '/') command = command.substring(1);
-		myCommand = command;
-	}
+        }
+        this.args = args;
+    }
+
+    void checkMandatoryParams() throws RequestHandlerBadRequestException
+    {
+        String[] mandatory = getMandatoryParams();
+        if(mandatory == null) return;
+
+        boolean error = false;
+        for(int i = 0; i < mandatory.length; ++i)
+        {
+            String key = mandatory[i];
+            String value = args.get(key);
+            if((value == null) || (value.length() == 0))
+            {
+                error = true;
+                System.out.println("'" + myCommand + "' remote control request must have '" + key + "' parameter");
+            }
+        }
+        if(error) throw new RequestHandlerBadRequestException();
+    }
+
+    /**
+     * Save command associated with this handler.
+     *
+     * @param command The command.
+     */
+    public void setCommand(String command)
+    {
+        if(command.charAt(0) == '/') command = command.substring(1);
+        myCommand = command;
+    }
 }
Index: applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RequestHandlerForbiddenException.java
===================================================================
--- applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RequestHandlerForbiddenException.java	(revision 22734)
+++ applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RequestHandlerForbiddenException.java	(revision 23189)
@@ -2,4 +2,4 @@
 
 public class RequestHandlerForbiddenException extends RequestHandlerException {
-	private static final long serialVersionUID = 2263904699747115423L;
+    private static final long serialVersionUID = 2263904699747115423L;
 }
Index: applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RequestProcessor.java
===================================================================
--- applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RequestProcessor.java	(revision 22734)
+++ applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RequestProcessor.java	(revision 23189)
@@ -23,286 +23,286 @@
  */
 public class RequestProcessor extends Thread {
-	/**
-	 * RemoteControl protocol version. Change minor number for compatible
-	 * interface extensions. Change major number in case of incompatible
-	 * changes.
-	 */
-	public static final String PROTOCOLVERSION = "{\"protocolversion\": {\"major\": " +
-		RemoteControlPlugin.protocolMajorVersion + ", \"minor\": " + 
-		RemoteControlPlugin.protocolMinorVersion +
-		"}, \"application\": \"JOSM RemoteControl\"}";
-
-	/** The socket this processor listens on */
-	private Socket request;
-
-	/**
-	 * Collection of request handlers.
-	 * Will be initialized with default handlers here. Other plug-ins
-	 * can extend this list by using @see addRequestHandler 
-	 */
-	private static HashMap<String, Class<? extends RequestHandler>> handlers = new HashMap<String, Class<? extends RequestHandler>>();
-
-	/**
-	 * Constructor
-	 * 
-	 * @param request A socket to read the request.
-	 */
-	public RequestProcessor(Socket request) {
-		super("RemoteControl request processor");
-		this.setDaemon(true);
-		this.request = request;
-	}
-
-	/**
-	 * Spawns a new thread for the request
-	 * 
-	 * @param request
-	 *            The WMS request
-	 */
-	public static void processRequest(Socket request) {
-		RequestProcessor processor = new RequestProcessor(request);
-		processor.start();
-	}
-
-	/**
-	 * Add external request handler. Can be used by other plug-ins that
-	 * want to use remote control.
-	 * @param command The command to handle.
-	 * @param handler The additional request handler.
-	 */
-	static void addRequestHandlerClass(String command,
-			Class<? extends RequestHandler> handler) {
-		addRequestHandlerClass(command, handler, false);
-	}
-
-	/**
-	 * Add external request handler. Message can be suppressed.
-	 * (for internal use)
-	 * @param command The command to handle.
-	 * @param handler The additional request handler.
-	 * @param silent Don't show message if true.
-	 */
-	private static void addRequestHandlerClass(String command,
-				Class<? extends RequestHandler> handler, boolean silent) {
-		if(command.charAt(0) == '/')
-		{
-			command = command.substring(1);
-		}
-		String commandWithSlash = "/" + command;
-		if (handlers.get(commandWithSlash) != null) {
-			System.out.println("RemoteControl: ignoring duplicate command " + command
-					+ " with handler " + handler.getName());
-		} else {
-			if(!silent) System.out.println("RemoteControl: adding command \"" + 
-					command + "\" (handled by " + handler.getSimpleName() + ")");
-			handlers.put(commandWithSlash, handler);
-		}
-	}
-
-	/** Add default request handlers */
-	static {
-		addRequestHandlerClass(LoadAndZoomHandler.command,
-				LoadAndZoomHandler.class, true);
-		addRequestHandlerClass(LoadAndZoomHandler.command2,
-				LoadAndZoomHandler.class, true);
-		addRequestHandlerClass(AddNodeHandler.command, AddNodeHandler.class, true);
-		addRequestHandlerClass(ImportHandler.command, ImportHandler.class, true);
-		addRequestHandlerClass(VersionHandler.command, VersionHandler.class, true);
-	}
-
-	/**
-	 * The work is done here.
-	 */
-	public void run() {
-		Writer out = null;
-		try {
-			OutputStream raw = new BufferedOutputStream(
-					request.getOutputStream());
-			out = new OutputStreamWriter(raw);
-			Reader in = new InputStreamReader(new BufferedInputStream(
-					request.getInputStream()), "ASCII");
-
-			StringBuffer requestLine = new StringBuffer();
-			while (requestLine.length() < 1024) {
-				int c = in.read();
-				if (c == '\r' || c == '\n')
-					break;
-				requestLine.append((char) c);
-			}
-
-			System.out.println("RemoteControl received: " + requestLine);
-			String get = requestLine.toString();
-			StringTokenizer st = new StringTokenizer(get);
-			if (!st.hasMoreTokens()) {
-				sendError(out);
-				return;
-			}
-			String method = st.nextToken();
-			if (!st.hasMoreTokens()) {
-				sendError(out);
-				return;
-			}
-			String url = st.nextToken();
-
-			if (!method.equals("GET")) {
-				sendNotImplemented(out);
-				return;
-			}
-
-			String command = null;
-			int questionPos = url.indexOf('?');
-			if(questionPos < 0)
-			{
-				command = url;
-			}
-			else
-			{
-				command = url.substring(0, questionPos);
-			}
-
-			// find a handler for this command
-			Class<? extends RequestHandler> handlerClass = handlers
-					.get(command);
-			if (handlerClass == null) {
-				// no handler found
-				sendBadRequest(out);
-			} else {
-				// create handler object
-				RequestHandler handler = handlerClass.newInstance();
-				try {
-					handler.setCommand(command);
-					handler.setUrl(url);
-					handler.checkPermission();
-					handler.handle();
-					sendHeader(out, "200 OK", handler.contentType, false);
-					out.write("Content-length: " + handler.content.length()
-							+ "\r\n");
-					out.write("\r\n");
-					out.write(handler.content);
-					out.flush();
-				} catch (RequestHandlerErrorException ex) {
-					sendError(out);
-				} catch (RequestHandlerBadRequestException ex) {
-					sendBadRequest(out);
-				} catch (RequestHandlerForbiddenException ex) {
-					sendForbidden(out);
-				}
-			}
-
-		} catch (IOException ioe) {
-		} catch (Exception e) {
-			e.printStackTrace();
-			try {
-				sendError(out);
-			} catch (IOException e1) {
-			}
-		} finally {
-			try {
-				request.close();
-			} catch (IOException e) {
-			}
-		}
-	}
-
-	/**
-	 * Sends a 500 error: server error
-	 * 
-	 * @param out
-	 *            The writer where the error is written
-	 * @throws IOException
-	 *             If the error can not be written
-	 */
-	private void sendError(Writer out) throws IOException {
-		sendHeader(out, "500 Internal Server Error", "text/html", true);
-		out.write("<HTML>\r\n");
-		out.write("<HEAD><TITLE>Internal Error</TITLE>\r\n");
-		out.write("</HEAD>\r\n");
-		out.write("<BODY>");
-		out.write("<H1>HTTP Error 500: Internal Server Error</h2>\r\n");
-		out.write("</BODY></HTML>\r\n");
-		out.flush();
-	}
-
-	/**
-	 * Sends a 501 error: not implemented
-	 * 
-	 * @param out
-	 *            The writer where the error is written
-	 * @throws IOException
-	 *             If the error can not be written
-	 */
-	private void sendNotImplemented(Writer out) throws IOException {
-		sendHeader(out, "501 Not Implemented", "text/html", true);
-		out.write("<HTML>\r\n");
-		out.write("<HEAD><TITLE>Not Implemented</TITLE>\r\n");
-		out.write("</HEAD>\r\n");
-		out.write("<BODY>");
-		out.write("<H1>HTTP Error 501: Not Implemented</h2>\r\n");
-		out.write("</BODY></HTML>\r\n");
-		out.flush();
-	}
-
-	/**
-	 * Sends a 403 error: forbidden
-	 * 
-	 * @param out
-	 *            The writer where the error is written
-	 * @throws IOException
-	 *             If the error can not be written
-	 */
-	private void sendForbidden(Writer out) throws IOException {
-		sendHeader(out, "403 Forbidden", "text/html", true);
-		out.write("<HTML>\r\n");
-		out.write("<HEAD><TITLE>Forbidden</TITLE>\r\n");
-		out.write("</HEAD>\r\n");
-		out.write("<BODY>");
-		out.write("<H1>HTTP Error 403: Forbidden</h2>\r\n");
-		out.write("</BODY></HTML>\r\n");
-		out.flush();
-	}
-
-	/**
-	 * Sends a 403 error: forbidden
-	 * 
-	 * @param out
-	 *            The writer where the error is written
-	 * @throws IOException
-	 *             If the error can not be written
-	 */
-	private void sendBadRequest(Writer out) throws IOException {
-		sendHeader(out, "400 Bad Request", "text/html", true);
-		out.write("<HTML>\r\n");
-		out.write("<HEAD><TITLE>Bad Request</TITLE>\r\n");
-		out.write("</HEAD>\r\n");
-		out.write("<BODY>");
-		out.write("<H1>HTTP Error 400: Bad Request</h2>\r\n");
-		out.write("</BODY></HTML>\r\n");
-		out.flush();
-	}
-
-	/**
-	 * Send common HTTP headers to the client.
-	 * 
-	 * @param out
-	 *            The Writer
-	 * @param status
-	 *            The status string ("200 OK", "500", etc)
-	 * @param contentType
-	 *            The content type of the data sent
-	 * @param endHeaders
-	 *            If true, adds a new line, ending the headers.
-	 * @throws IOException
-	 *             When error
-	 */
-	private void sendHeader(Writer out, String status, String contentType,
-			boolean endHeaders) throws IOException {
-		out.write("HTTP/1.1 " + status + "\r\n");
-		Date now = new Date();
-		out.write("Date: " + now + "\r\n");
-		out.write("Server: JOSM RemoteControl\r\n");
-		out.write("Content-type: " + contentType + "\r\n");
-		out.write("Access-Control-Allow-Origin: *\r\n");
-		if (endHeaders)
-			out.write("\r\n");
-	}
+    /**
+     * RemoteControl protocol version. Change minor number for compatible
+     * interface extensions. Change major number in case of incompatible
+     * changes.
+     */
+    public static final String PROTOCOLVERSION = "{\"protocolversion\": {\"major\": " +
+        RemoteControlPlugin.protocolMajorVersion + ", \"minor\": " +
+        RemoteControlPlugin.protocolMinorVersion +
+        "}, \"application\": \"JOSM RemoteControl\"}";
+
+    /** The socket this processor listens on */
+    private Socket request;
+
+    /**
+     * Collection of request handlers.
+     * Will be initialized with default handlers here. Other plug-ins
+     * can extend this list by using @see addRequestHandler
+     */
+    private static HashMap<String, Class<? extends RequestHandler>> handlers = new HashMap<String, Class<? extends RequestHandler>>();
+
+    /**
+     * Constructor
+     *
+     * @param request A socket to read the request.
+     */
+    public RequestProcessor(Socket request) {
+        super("RemoteControl request processor");
+        this.setDaemon(true);
+        this.request = request;
+    }
+
+    /**
+     * Spawns a new thread for the request
+     *
+     * @param request
+     *            The WMS request
+     */
+    public static void processRequest(Socket request) {
+        RequestProcessor processor = new RequestProcessor(request);
+        processor.start();
+    }
+
+    /**
+     * Add external request handler. Can be used by other plug-ins that
+     * want to use remote control.
+     * @param command The command to handle.
+     * @param handler The additional request handler.
+     */
+    static void addRequestHandlerClass(String command,
+            Class<? extends RequestHandler> handler) {
+        addRequestHandlerClass(command, handler, false);
+    }
+
+    /**
+     * Add external request handler. Message can be suppressed.
+     * (for internal use)
+     * @param command The command to handle.
+     * @param handler The additional request handler.
+     * @param silent Don't show message if true.
+     */
+    private static void addRequestHandlerClass(String command,
+                Class<? extends RequestHandler> handler, boolean silent) {
+        if(command.charAt(0) == '/')
+        {
+            command = command.substring(1);
+        }
+        String commandWithSlash = "/" + command;
+        if (handlers.get(commandWithSlash) != null) {
+            System.out.println("RemoteControl: ignoring duplicate command " + command
+                    + " with handler " + handler.getName());
+        } else {
+            if(!silent) System.out.println("RemoteControl: adding command \"" +
+                    command + "\" (handled by " + handler.getSimpleName() + ")");
+            handlers.put(commandWithSlash, handler);
+        }
+    }
+
+    /** Add default request handlers */
+    static {
+        addRequestHandlerClass(LoadAndZoomHandler.command,
+                LoadAndZoomHandler.class, true);
+        addRequestHandlerClass(LoadAndZoomHandler.command2,
+                LoadAndZoomHandler.class, true);
+        addRequestHandlerClass(AddNodeHandler.command, AddNodeHandler.class, true);
+        addRequestHandlerClass(ImportHandler.command, ImportHandler.class, true);
+        addRequestHandlerClass(VersionHandler.command, VersionHandler.class, true);
+    }
+
+    /**
+     * The work is done here.
+     */
+    public void run() {
+        Writer out = null;
+        try {
+            OutputStream raw = new BufferedOutputStream(
+                    request.getOutputStream());
+            out = new OutputStreamWriter(raw);
+            Reader in = new InputStreamReader(new BufferedInputStream(
+                    request.getInputStream()), "ASCII");
+
+            StringBuffer requestLine = new StringBuffer();
+            while (requestLine.length() < 1024) {
+                int c = in.read();
+                if (c == '\r' || c == '\n')
+                    break;
+                requestLine.append((char) c);
+            }
+
+            System.out.println("RemoteControl received: " + requestLine);
+            String get = requestLine.toString();
+            StringTokenizer st = new StringTokenizer(get);
+            if (!st.hasMoreTokens()) {
+                sendError(out);
+                return;
+            }
+            String method = st.nextToken();
+            if (!st.hasMoreTokens()) {
+                sendError(out);
+                return;
+            }
+            String url = st.nextToken();
+
+            if (!method.equals("GET")) {
+                sendNotImplemented(out);
+                return;
+            }
+
+            String command = null;
+            int questionPos = url.indexOf('?');
+            if(questionPos < 0)
+            {
+                command = url;
+            }
+            else
+            {
+                command = url.substring(0, questionPos);
+            }
+
+            // find a handler for this command
+            Class<? extends RequestHandler> handlerClass = handlers
+                    .get(command);
+            if (handlerClass == null) {
+                // no handler found
+                sendBadRequest(out);
+            } else {
+                // create handler object
+                RequestHandler handler = handlerClass.newInstance();
+                try {
+                    handler.setCommand(command);
+                    handler.setUrl(url);
+                    handler.checkPermission();
+                    handler.handle();
+                    sendHeader(out, "200 OK", handler.contentType, false);
+                    out.write("Content-length: " + handler.content.length()
+                            + "\r\n");
+                    out.write("\r\n");
+                    out.write(handler.content);
+                    out.flush();
+                } catch (RequestHandlerErrorException ex) {
+                    sendError(out);
+                } catch (RequestHandlerBadRequestException ex) {
+                    sendBadRequest(out);
+                } catch (RequestHandlerForbiddenException ex) {
+                    sendForbidden(out);
+                }
+            }
+
+        } catch (IOException ioe) {
+        } catch (Exception e) {
+            e.printStackTrace();
+            try {
+                sendError(out);
+            } catch (IOException e1) {
+            }
+        } finally {
+            try {
+                request.close();
+            } catch (IOException e) {
+            }
+        }
+    }
+
+    /**
+     * Sends a 500 error: server error
+     *
+     * @param out
+     *            The writer where the error is written
+     * @throws IOException
+     *             If the error can not be written
+     */
+    private void sendError(Writer out) throws IOException {
+        sendHeader(out, "500 Internal Server Error", "text/html", true);
+        out.write("<HTML>\r\n");
+        out.write("<HEAD><TITLE>Internal Error</TITLE>\r\n");
+        out.write("</HEAD>\r\n");
+        out.write("<BODY>");
+        out.write("<H1>HTTP Error 500: Internal Server Error</h2>\r\n");
+        out.write("</BODY></HTML>\r\n");
+        out.flush();
+    }
+
+    /**
+     * Sends a 501 error: not implemented
+     *
+     * @param out
+     *            The writer where the error is written
+     * @throws IOException
+     *             If the error can not be written
+     */
+    private void sendNotImplemented(Writer out) throws IOException {
+        sendHeader(out, "501 Not Implemented", "text/html", true);
+        out.write("<HTML>\r\n");
+        out.write("<HEAD><TITLE>Not Implemented</TITLE>\r\n");
+        out.write("</HEAD>\r\n");
+        out.write("<BODY>");
+        out.write("<H1>HTTP Error 501: Not Implemented</h2>\r\n");
+        out.write("</BODY></HTML>\r\n");
+        out.flush();
+    }
+
+    /**
+     * Sends a 403 error: forbidden
+     *
+     * @param out
+     *            The writer where the error is written
+     * @throws IOException
+     *             If the error can not be written
+     */
+    private void sendForbidden(Writer out) throws IOException {
+        sendHeader(out, "403 Forbidden", "text/html", true);
+        out.write("<HTML>\r\n");
+        out.write("<HEAD><TITLE>Forbidden</TITLE>\r\n");
+        out.write("</HEAD>\r\n");
+        out.write("<BODY>");
+        out.write("<H1>HTTP Error 403: Forbidden</h2>\r\n");
+        out.write("</BODY></HTML>\r\n");
+        out.flush();
+    }
+
+    /**
+     * Sends a 403 error: forbidden
+     *
+     * @param out
+     *            The writer where the error is written
+     * @throws IOException
+     *             If the error can not be written
+     */
+    private void sendBadRequest(Writer out) throws IOException {
+        sendHeader(out, "400 Bad Request", "text/html", true);
+        out.write("<HTML>\r\n");
+        out.write("<HEAD><TITLE>Bad Request</TITLE>\r\n");
+        out.write("</HEAD>\r\n");
+        out.write("<BODY>");
+        out.write("<H1>HTTP Error 400: Bad Request</h2>\r\n");
+        out.write("</BODY></HTML>\r\n");
+        out.flush();
+    }
+
+    /**
+     * Send common HTTP headers to the client.
+     *
+     * @param out
+     *            The Writer
+     * @param status
+     *            The status string ("200 OK", "500", etc)
+     * @param contentType
+     *            The content type of the data sent
+     * @param endHeaders
+     *            If true, adds a new line, ending the headers.
+     * @throws IOException
+     *             When error
+     */
+    private void sendHeader(Writer out, String status, String contentType,
+            boolean endHeaders) throws IOException {
+        out.write("HTTP/1.1 " + status + "\r\n");
+        Date now = new Date();
+        out.write("Date: " + now + "\r\n");
+        out.write("Server: JOSM RemoteControl\r\n");
+        out.write("Content-type: " + contentType + "\r\n");
+        out.write("Access-Control-Allow-Origin: *\r\n");
+        if (endHeaders)
+            out.write("\r\n");
+    }
 }
Index: applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/AddNodeHandler.java
===================================================================
--- applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/AddNodeHandler.java	(revision 22734)
+++ applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/AddNodeHandler.java	(revision 23189)
@@ -17,31 +17,31 @@
 public class AddNodeHandler extends RequestHandler {
 
-	public static final String command = "add_node";
-	public static final String permissionKey = "remotecontrol.permission.create-objects";
-	public static final boolean permissionDefault = false;
+    public static final String command = "add_node";
+    public static final String permissionKey = "remotecontrol.permission.create-objects";
+    public static final boolean permissionDefault = false;
 
-	@Override
-	protected void handleRequest() {
+    @Override
+    protected void handleRequest() {
         addNode(args);
-	}
+    }
 
-	@Override
-	protected String[] getMandatoryParams()
-	{
-		return new String[] { "lat", "lon" };
-	}
-	
-	@Override
-	public String getPermissionMessage() {
-		return tr("Remote Control has been asked to create a new node.");
-	}
+    @Override
+    protected String[] getMandatoryParams()
+    {
+        return new String[] { "lat", "lon" };
+    }
 
-	@Override
-	public PermissionPrefWithDefault getPermissionPref()
-	{
-		return new PermissionPrefWithDefault(permissionKey, permissionDefault,
-				"RemoteControl: creating objects forbidden by preferences");
-	}
-	
+    @Override
+    public String getPermissionMessage() {
+        return tr("Remote Control has been asked to create a new node.");
+    }
+
+    @Override
+    public PermissionPrefWithDefault getPermissionPref()
+    {
+        return new PermissionPrefWithDefault(permissionKey, permissionDefault,
+                "RemoteControl: creating objects forbidden by preferences");
+    }
+
     /**
      * Adds a node, implements the GET /add_node?lon=...&amp;lat=... request.
Index: applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/ImportHandler.java
===================================================================
--- applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/ImportHandler.java	(revision 22734)
+++ applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/ImportHandler.java	(revision 23189)
@@ -16,10 +16,10 @@
 public class ImportHandler extends RequestHandler {
 
-	public static final String command = "import";
-	public static final String permissionKey = "remotecontrol.permission.import";
-	public static final boolean permissionDefault = true;
+    public static final String command = "import";
+    public static final String permissionKey = "remotecontrol.permission.import";
+    public static final boolean permissionDefault = true;
 
-	@Override
-	protected void handleRequest() throws RequestHandlerErrorException {
+    @Override
+    protected void handleRequest() throws RequestHandlerErrorException {
         try {
             DownloadTask osmTask = new DownloadOsmTask();
@@ -30,23 +30,23 @@
             throw new RequestHandlerErrorException();
         }
-	}
+    }
 
-	@Override
-	protected String[] getMandatoryParams()
-	{
-		return new String[] { "url" };
-	}
-	
-	@Override
-	public String getPermissionMessage() {
-		return tr("Remote Control has been asked to import data from the following URL:") +
+    @Override
+    protected String[] getMandatoryParams()
+    {
+        return new String[] { "url" };
+    }
+
+    @Override
+    public String getPermissionMessage() {
+        return tr("Remote Control has been asked to import data from the following URL:") +
         "<br>" + request;
-	}
+    }
 
-	@Override
-	public PermissionPrefWithDefault getPermissionPref()
-	{
-		return new PermissionPrefWithDefault(permissionKey, permissionDefault,
-				"RemoteControl: import forbidden by preferences");
-	}
+    @Override
+    public PermissionPrefWithDefault getPermissionPref()
+    {
+        return new PermissionPrefWithDefault(permissionKey, permissionDefault,
+                "RemoteControl: import forbidden by preferences");
+    }
 }
Index: applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/LoadAndZoomHandler.java
===================================================================
--- applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/LoadAndZoomHandler.java	(revision 22734)
+++ applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/LoadAndZoomHandler.java	(revision 23189)
@@ -29,139 +29,139 @@
 public class LoadAndZoomHandler extends RequestHandler
 {
-	public static final String command = "load_and_zoom";
-	public static final String command2 = "zoom";
-	
-	public static final String loadDataPermissionKey = "remotecontrol.permission.load-data";
-	public static final boolean loadDataPermissionDefault = true;
-	public static final String changeSelectionPermissionKey = "remotecontrol.permission.change-selection";
-	public static final boolean changeSelectionPermissionDefault = true;
-	public static final String changeViewportPermissionKey = "remotecontrol.permission.change-viewport";
-	public static final boolean changeViewportPermissionDefault = true;
-	
+    public static final String command = "load_and_zoom";
+    public static final String command2 = "zoom";
+
+    public static final String loadDataPermissionKey = "remotecontrol.permission.load-data";
+    public static final boolean loadDataPermissionDefault = true;
+    public static final String changeSelectionPermissionKey = "remotecontrol.permission.change-selection";
+    public static final boolean changeSelectionPermissionDefault = true;
+    public static final String changeViewportPermissionKey = "remotecontrol.permission.change-viewport";
+    public static final boolean changeViewportPermissionDefault = true;
+
     @Override
     public String getPermissionMessage()
     {
-    	return tr("Remote Control has been asked to load data from the API.") +
+        return tr("Remote Control has been asked to load data from the API.") +
         "<br>" + tr("Request details: {0}", request);
     }
 
-	@Override
-	protected String[] getMandatoryParams()
-	{
-		return new String[] { "bottom", "top", "left", "right" };
-	}
-	
-	@Override
-	protected void handleRequest() throws RequestHandlerErrorException
-	{
-		DownloadTask osmTask = new DownloadOsmTask();
-		double minlat = 0;
-		double maxlat = 0;
-		double minlon = 0;
-		double maxlon = 0;
-		try {
-			minlat = Double.parseDouble(args.get("bottom"));
-			maxlat = Double.parseDouble(args.get("top"));
-			minlon = Double.parseDouble(args.get("left"));
-			maxlon = Double.parseDouble(args.get("right"));
+    @Override
+    protected String[] getMandatoryParams()
+    {
+        return new String[] { "bottom", "top", "left", "right" };
+    }
 
-			if(command.equals(myCommand))
-			{
-				if (!Main.pref.getBoolean(loadDataPermissionKey, loadDataPermissionDefault))
-				{
-					System.out.println("RemoteControl: download forbidden by preferences");
-				}
-				else
-				{
-	
-					// find out whether some data has already been downloaded
-					Area present = null;
-					Area toDownload = null;
-					DataSet ds = Main.main.getCurrentDataSet();
-					if (ds != null)
-						present = ds.getDataSourceArea();
-					if (present != null && !present.isEmpty()) {
-						toDownload = new Area(new Rectangle2D.Double(minlon,minlat,maxlon-minlon,maxlat-minlat));
-						toDownload.subtract(present);
-						if (!toDownload.isEmpty())
-						{
-							// the result might not be a rectangle (L shaped etc)
-							Rectangle2D downloadBounds = toDownload.getBounds2D();
-							minlat = downloadBounds.getMinY();
-							minlon = downloadBounds.getMinX();
-							maxlat = downloadBounds.getMaxY();
-							maxlon = downloadBounds.getMaxX();
-						}
-					}
-					if((toDownload != null) && toDownload.isEmpty())
-					{
-						System.out.println("RemoteControl: no download necessary");
-					}
-					else
-					{
-	                    Future<?> future = osmTask.download(false /*no new layer*/, new Bounds(minlat,minlon,maxlat,maxlon), null /* let the task manage the progress monitor */);
-	                    Main.worker.submit(new PostDownloadHandler(osmTask, future));
-					}
-				}
-			}
-		} catch (Exception ex) {
-			System.out.println("RemoteControl: Error parsing load_and_zoom remote control request:");
-			ex.printStackTrace();
-			throw new RequestHandlerErrorException();
-		}
-		if (args.containsKey("select") && Main.pref.getBoolean(changeSelectionPermissionKey, changeSelectionPermissionDefault)) {
-			// select objects after downloading, zoom to selection.
-			final String selection = args.get("select");
-			Main.worker.execute(new Runnable() {
-				public void run() {
-					HashSet<Long> ways = new HashSet<Long>();
-					HashSet<Long> nodes = new HashSet<Long>();
-					HashSet<Long> relations = new HashSet<Long>();
-					HashSet<OsmPrimitive> newSel = new HashSet<OsmPrimitive>();
-					for (String item : selection.split(",")) {
-						if (item.startsWith("way")) {
-							ways.add(Long.parseLong(item.substring(3)));
-						} else if (item.startsWith("node")) {
-							nodes.add(Long.parseLong(item.substring(4)));
-						} else if (item.startsWith("relation")) {
-							relations.add(Long.parseLong(item.substring(8)));
-						} else if (item.startsWith("rel")) {
-							relations.add(Long.parseLong(item.substring(3)));
-						} else {
-							System.out.println("RemoteControl: invalid selection '"+item+"' ignored");
-						}
-					}
-					DataSet ds = Main.main.getCurrentDataSet();
-					if(ds == null) // e.g. download failed
-						return;
-					for (Way w : ds.getWays()) if (ways.contains(w.getId())) newSel.add(w);
-					for (Node n : ds.getNodes()) if (nodes.contains(n.getId())) newSel.add(n);
-					for (Relation r : ds.getRelations()) if (relations.contains(r.getId())) newSel.add(r);
-					ds.setSelected(newSel);
-					if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault))
-						new AutoScaleAction("selection").actionPerformed(null);
-				}
-			});
-		} else if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault)) {
-			// after downloading, zoom to downloaded area.
-			zoom(minlat, maxlat, minlon, maxlon);
-		}
-	}
+    @Override
+    protected void handleRequest() throws RequestHandlerErrorException
+    {
+        DownloadTask osmTask = new DownloadOsmTask();
+        double minlat = 0;
+        double maxlat = 0;
+        double minlon = 0;
+        double maxlon = 0;
+        try {
+            minlat = Double.parseDouble(args.get("bottom"));
+            maxlat = Double.parseDouble(args.get("top"));
+            minlon = Double.parseDouble(args.get("left"));
+            maxlon = Double.parseDouble(args.get("right"));
 
-	protected void zoom(double minlat, double maxlat, double minlon, double maxlon) {
-		final Bounds bounds = new Bounds(new LatLon(minlat, minlon),
-				new LatLon(maxlat, maxlon));
+            if(command.equals(myCommand))
+            {
+                if (!Main.pref.getBoolean(loadDataPermissionKey, loadDataPermissionDefault))
+                {
+                    System.out.println("RemoteControl: download forbidden by preferences");
+                }
+                else
+                {
 
-		// make sure this isn't called unless there *is* a MapView
-		//
-		if (Main.map != null && Main.map.mapView != null) {
-			Main.worker.execute(new Runnable() {
-				public void run() {
-					BoundingXYVisitor bbox = new BoundingXYVisitor();
-					bbox.visit(bounds);
-					Main.map.mapView.recalculateCenterScale(bbox);
-				}
-			});
-		}
-	}
+                    // find out whether some data has already been downloaded
+                    Area present = null;
+                    Area toDownload = null;
+                    DataSet ds = Main.main.getCurrentDataSet();
+                    if (ds != null)
+                        present = ds.getDataSourceArea();
+                    if (present != null && !present.isEmpty()) {
+                        toDownload = new Area(new Rectangle2D.Double(minlon,minlat,maxlon-minlon,maxlat-minlat));
+                        toDownload.subtract(present);
+                        if (!toDownload.isEmpty())
+                        {
+                            // the result might not be a rectangle (L shaped etc)
+                            Rectangle2D downloadBounds = toDownload.getBounds2D();
+                            minlat = downloadBounds.getMinY();
+                            minlon = downloadBounds.getMinX();
+                            maxlat = downloadBounds.getMaxY();
+                            maxlon = downloadBounds.getMaxX();
+                        }
+                    }
+                    if((toDownload != null) && toDownload.isEmpty())
+                    {
+                        System.out.println("RemoteControl: no download necessary");
+                    }
+                    else
+                    {
+                        Future<?> future = osmTask.download(false /*no new layer*/, new Bounds(minlat,minlon,maxlat,maxlon), null /* let the task manage the progress monitor */);
+                        Main.worker.submit(new PostDownloadHandler(osmTask, future));
+                    }
+                }
+            }
+        } catch (Exception ex) {
+            System.out.println("RemoteControl: Error parsing load_and_zoom remote control request:");
+            ex.printStackTrace();
+            throw new RequestHandlerErrorException();
+        }
+        if (args.containsKey("select") && Main.pref.getBoolean(changeSelectionPermissionKey, changeSelectionPermissionDefault)) {
+            // select objects after downloading, zoom to selection.
+            final String selection = args.get("select");
+            Main.worker.execute(new Runnable() {
+                public void run() {
+                    HashSet<Long> ways = new HashSet<Long>();
+                    HashSet<Long> nodes = new HashSet<Long>();
+                    HashSet<Long> relations = new HashSet<Long>();
+                    HashSet<OsmPrimitive> newSel = new HashSet<OsmPrimitive>();
+                    for (String item : selection.split(",")) {
+                        if (item.startsWith("way")) {
+                            ways.add(Long.parseLong(item.substring(3)));
+                        } else if (item.startsWith("node")) {
+                            nodes.add(Long.parseLong(item.substring(4)));
+                        } else if (item.startsWith("relation")) {
+                            relations.add(Long.parseLong(item.substring(8)));
+                        } else if (item.startsWith("rel")) {
+                            relations.add(Long.parseLong(item.substring(3)));
+                        } else {
+                            System.out.println("RemoteControl: invalid selection '"+item+"' ignored");
+                        }
+                    }
+                    DataSet ds = Main.main.getCurrentDataSet();
+                    if(ds == null) // e.g. download failed
+                        return;
+                    for (Way w : ds.getWays()) if (ways.contains(w.getId())) newSel.add(w);
+                    for (Node n : ds.getNodes()) if (nodes.contains(n.getId())) newSel.add(n);
+                    for (Relation r : ds.getRelations()) if (relations.contains(r.getId())) newSel.add(r);
+                    ds.setSelected(newSel);
+                    if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault))
+                        new AutoScaleAction("selection").actionPerformed(null);
+                }
+            });
+        } else if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault)) {
+            // after downloading, zoom to downloaded area.
+            zoom(minlat, maxlat, minlon, maxlon);
+        }
+    }
+
+    protected void zoom(double minlat, double maxlat, double minlon, double maxlon) {
+        final Bounds bounds = new Bounds(new LatLon(minlat, minlon),
+                new LatLon(maxlat, maxlon));
+
+        // make sure this isn't called unless there *is* a MapView
+        //
+        if (Main.map != null && Main.map.mapView != null) {
+            Main.worker.execute(new Runnable() {
+                public void run() {
+                    BoundingXYVisitor bbox = new BoundingXYVisitor();
+                    bbox.visit(bounds);
+                    Main.map.mapView.recalculateCenterScale(bbox);
+                }
+            });
+        }
+    }
 }
Index: applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/VersionHandler.java
===================================================================
--- applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/VersionHandler.java	(revision 22734)
+++ applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/handler/VersionHandler.java	(revision 23189)
@@ -14,28 +14,28 @@
 public class VersionHandler extends RequestHandler {
 
-	public static final String command = "version";
-	public static final String permissionKey = "remotecontrol.permission.read-protocolversion";
-	public static final boolean permissionDefault = true;
+    public static final String command = "version";
+    public static final String permissionKey = "remotecontrol.permission.read-protocolversion";
+    public static final boolean permissionDefault = true;
 
-	@Override
-	protected void handleRequest() throws RequestHandlerErrorException,
-			RequestHandlerBadRequestException {
-		content = RequestProcessor.PROTOCOLVERSION;
-		contentType = "application/json";
-		if (args.containsKey("jsonp")) {
-			content = args.get("jsonp")+ " && " + args.get("jsonp") + "(" + content + ")";
-		}
-	}
+    @Override
+    protected void handleRequest() throws RequestHandlerErrorException,
+            RequestHandlerBadRequestException {
+        content = RequestProcessor.PROTOCOLVERSION;
+        contentType = "application/json";
+        if (args.containsKey("jsonp")) {
+            content = args.get("jsonp")+ " && " + args.get("jsonp") + "(" + content + ")";
+        }
+    }
 
-	@Override
-	public String getPermissionMessage() {
-		return tr("Remote Control has been asked to report its protocol version. This enables web sites to detect a running JOSM.");
-	}
+    @Override
+    public String getPermissionMessage() {
+        return tr("Remote Control has been asked to report its protocol version. This enables web sites to detect a running JOSM.");
+    }
 
-	@Override
-	public PermissionPrefWithDefault getPermissionPref()
-	{
-		return new PermissionPrefWithDefault(permissionKey, permissionDefault,
-				"RemoteControl: /version forbidden by preferences");
-	}
+    @Override
+    public PermissionPrefWithDefault getPermissionPref()
+    {
+        return new PermissionPrefWithDefault(permissionKey, permissionDefault,
+                "RemoteControl: /version forbidden by preferences");
+    }
 }
