Skip to content

Commit 2660156

Browse files
author
stoecker
committed
fix #24298 - add JOSM API indication to remote control
git-svn-id: https://josm.openstreetmap.de/svn/trunk@19416 0c6e7542-c601-0410-84e7-c038aed88b3b
1 parent 645e60f commit 2660156

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/org/openstreetmap/josm/io/remotecontrol/RemoteControl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class RemoteControl {
3131
* changes.
3232
*/
3333
static final int protocolMajorVersion = 1;
34-
static final int protocolMinorVersion = 12;
34+
static final int protocolMinorVersion = 13;
3535

3636
/**
3737
* Starts the remote control server

src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import jakarta.json.Json;
2929

3030
import org.openstreetmap.josm.data.Version;
31+
import org.openstreetmap.josm.data.preferences.JosmUrls;
3132
import org.openstreetmap.josm.gui.help.HelpUtil;
33+
import org.openstreetmap.josm.io.OsmApi;
3234
import org.openstreetmap.josm.io.remotecontrol.handler.AddNodeHandler;
3335
import org.openstreetmap.josm.io.remotecontrol.handler.AddWayHandler;
3436
import org.openstreetmap.josm.io.remotecontrol.handler.AuthorizationHandler;
@@ -71,13 +73,18 @@ public class RequestProcessor extends Thread {
7173
* interface extensions. Change major number in case of incompatible
7274
* changes.
7375
*/
74-
public static final String PROTOCOLVERSION = Json.createObjectBuilder()
75-
.add("protocolversion", Json.createObjectBuilder()
76-
.add("major", RemoteControl.protocolMajorVersion)
77-
.add("minor", RemoteControl.protocolMinorVersion))
78-
.add("application", JOSM_REMOTE_CONTROL)
79-
.add("version", Version.getInstance().getVersion())
80-
.build().toString();
76+
public static String getProtocolVersion() {
77+
String OsmServerUrl = OsmApi.getOsmApi().getServerUrl();
78+
String defaultOsmApiUrl = JosmUrls.getInstance().getDefaultOsmApiUrl();
79+
return Json.createObjectBuilder()
80+
.add("protocolversion", Json.createObjectBuilder()
81+
.add("major", RemoteControl.protocolMajorVersion)
82+
.add("minor", RemoteControl.protocolMinorVersion))
83+
.add("application", JOSM_REMOTE_CONTROL)
84+
.add("version", Version.getInstance().getVersion())
85+
.add("osm_server", OsmServerUrl.equals(defaultOsmApiUrl) ? "default" : "custom")
86+
.build().toString();
87+
}
8188

8289
/** The socket this processor listens on */
8390
private final Socket request;

src/org/openstreetmap/josm/io/remotecontrol/handler/VersionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class VersionHandler extends RequestHandler {
1919
@Override
2020
protected void handleRequest() throws RequestHandlerErrorException,
2121
RequestHandlerBadRequestException {
22-
content = RequestProcessor.PROTOCOLVERSION;
22+
content = RequestProcessor.getProtocolVersion();
2323
contentType = "application/json";
2424
if (args.containsKey("jsonp")) {
2525
content = args.get("jsonp") + " && " + args.get("jsonp") + '(' + content + ')';

0 commit comments

Comments
 (0)