aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/files
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-12-16 12:48:31 +0100
committerBananeweizen <bananeweizen@gmx.de>2013-12-16 12:48:31 +0100
commitfc124633817d4d15cd6bf58487f19a1d73e64459 (patch)
treeb3208a5c12fc2136bc0f38fe8ee7bc78b141d1ca /main/src/cgeo/geocaching/files
parent14874d409a6547bc36c3b3946d55a81ad61da97a (diff)
downloadcgeo-fc124633817d4d15cd6bf58487f19a1d73e64459.zip
cgeo-fc124633817d4d15cd6bf58487f19a1d73e64459.tar.gz
cgeo-fc124633817d4d15cd6bf58487f19a1d73e64459.tar.bz2
integrate extremcaching.com
* cherry-pick existing commits and have some basic tests * disable EC connector by default * fix faked geocodes during GPX import * parse wrongly encoded container size
Diffstat (limited to 'main/src/cgeo/geocaching/files')
-rw-r--r--main/src/cgeo/geocaching/files/GPXParser.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java
index 3e96291..4ebbb45 100644
--- a/main/src/cgeo/geocaching/files/GPXParser.java
+++ b/main/src/cgeo/geocaching/files/GPXParser.java
@@ -104,6 +104,10 @@ public abstract class GPXParser extends FileParser {
*/
private final Set<String> result = new HashSet<String>(100);
private ProgressInputStream progressStream;
+ /**
+ * URL contained in the header of the GPX file. Used to guess where the file is coming from.
+ */
+ protected String scriptUrl;
private final class UserDataListener implements EndTextElementListener {
private final int index;
@@ -265,6 +269,14 @@ public abstract class GPXParser extends FileParser {
final RootElement root = new RootElement(namespace, "gpx");
final Element waypoint = root.getChild(namespace, "wpt");
+ root.getChild(namespace, "url").setEndTextElementListener(new EndTextElementListener() {
+
+ @Override
+ public void end(String body) {
+ scriptUrl = body;
+ }
+ });
+
// waypoint - attributes
waypoint.setStartElementListener(new StartElementListener() {
@@ -382,14 +394,19 @@ public abstract class GPXParser extends FileParser {
}
});
- // waypoint.getName()
+ // waypoint.name
waypoint.getChild(namespace, "name").setEndTextElementListener(new EndTextElementListener() {
@Override
public void end(String body) {
name = body;
- final String content = body.trim();
+ String content = body.trim();
+
+ // extremcaching.com manipulates the GC code by adding GC in front of ECxxx
+ if (StringUtils.startsWithIgnoreCase(content, "GCEC") && StringUtils.containsIgnoreCase(scriptUrl, "extremcaching")) {
+ content = content.substring(2);
+ }
cache.setName(content);
findGeoCode(cache.getName());