001    // License: GPL. For details, see LICENSE file.
002    package org.openstreetmap.josm.io.remotecontrol;
003    
004    import org.openstreetmap.josm.data.preferences.BooleanProperty;
005    import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler;
006    
007    /**
008     * Manager class for remote control operations.
009     *
010     * IMPORTANT! increment the minor version on compatible API extensions
011     * and increment the major version and set minor to 0 on incompatible changes.
012     */
013    public class RemoteControl
014    {
015        /**
016         * If the remote cotrol feature is enabled or disabled. If disabled,
017         * it should not start the server.
018         */
019        public static final BooleanProperty PROP_REMOTECONTROL_ENABLED = new BooleanProperty("remotecontrol.enabled", false);
020    
021        /**
022         * RemoteControl HTTP protocol version. Change minor number for compatible
023         * interface extensions. Change major number in case of incompatible
024         * changes.
025         */
026        static final int protocolMajorVersion = 1;
027        static final int protocolMinorVersion = 4;
028    
029        /**
030         * Starts the remote control server
031         */
032        public static void start() {
033            RemoteControlHttpServer.restartRemoteControlHttpServer();
034        }
035    
036        /**
037         * Adds external request handler.
038         * Can be used by plugins that want to use remote control.
039         * 
040         * @param command The command name.
041         * @param handlerClass The additional request handler.
042         */
043        public void addRequestHandler(String command, Class<? extends RequestHandler> handlerClass)
044        {
045            RequestProcessor.addRequestHandlerClass(command, handlerClass);
046        }
047    }