diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-02-01 19:15:05 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-02-01 19:15:05 +0100 |
| commit | 789088381a654b37a18962533b9a4b38a51bc8fe (patch) | |
| tree | 61d800885af3dc2eace53bbe418abf48ef74ed51 | |
| parent | d77a15f7a53185f025b0cd6cfb87cefb57f59852 (diff) | |
| download | cgeo-789088381a654b37a18962533b9a4b38a51bc8fe.zip cgeo-789088381a654b37a18962533b9a4b38a51bc8fe.tar.gz cgeo-789088381a654b37a18962533b9a4b38a51bc8fe.tar.bz2 | |
new: log images for opencaching.de
| -rw-r--r-- | main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java | 26 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/connector/oc/OCXMLClient.java | 14 |
2 files changed, 33 insertions, 7 deletions
diff --git a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java index 002556a..73bfc7d 100644 --- a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java +++ b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java @@ -58,6 +58,7 @@ public class OC11XMLParser { } private static class CacheLog { + public String id; public String cacheId; public LogEntry logEntry; } @@ -71,9 +72,9 @@ public class OC11XMLParser { private static class ImageHolder { public String url; - public String cacheId; + public String objectId; protected String title; - protected boolean isSpoiler; + protected boolean isSpoiler = false; } private static Date parseFullDate(final String date) { @@ -215,6 +216,7 @@ public class OC11XMLParser { public static Collection<cgCache> parseCaches(final InputStream stream) throws IOException { final Map<String, cgCache> caches = new HashMap<String, cgCache>(); + final Map<String, LogEntry> logs = new HashMap<String, LogEntry>(); final CacheHolder cacheHolder = new CacheHolder(); final CacheLog logHolder = new CacheLog(); @@ -478,6 +480,7 @@ public class OC11XMLParser { public void end() { final cgCache cache = caches.get(logHolder.cacheId); if (cache != null && logHolder.logEntry.type != LogType.UNKNOWN) { + logs.put(logHolder.id, logHolder.logEntry); cache.getLogs().prepend(logHolder.logEntry); if (logHolder.logEntry.type == LogType.FOUND_IT && StringUtils.equalsIgnoreCase(logHolder.logEntry.author, Settings.getOCConnectorUserName())) { @@ -488,6 +491,15 @@ public class OC11XMLParser { } }); + // cachelog.id + cacheLog.getChild("id").setEndTextElementListener(new EndTextElementListener() { + + @Override + public void end(String body) { + logHolder.id = StringUtils.trim(body); + } + }); + // cachelog.cacheid cacheLog.getChild("cacheid").setEndTextElementListener(new EndTextElementListener() { @@ -561,12 +573,18 @@ public class OC11XMLParser { @Override public void end() { if (imageHolder.isSpoiler) { - final cgCache cache = caches.get(imageHolder.cacheId); + final cgCache cache = caches.get(imageHolder.objectId); if (cache != null) { Image spoiler = new Image(imageHolder.url, imageHolder.title); cache.addSpoiler(spoiler); } } + else { + final LogEntry log = logs.get(imageHolder.objectId); + if (log != null) { + log.addLogImage(new Image(imageHolder.url, imageHolder.title)); + } + } } }); @@ -575,7 +593,7 @@ public class OC11XMLParser { @Override public void end(String body) { - imageHolder.cacheId = StringUtils.trim(body); + imageHolder.objectId = StringUtils.trim(body); } }); diff --git a/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java b/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java index 3758f7e..69bcda0 100644 --- a/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java +++ b/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java @@ -100,8 +100,16 @@ public class OCXMLClient { private static Parameters getOCXmlQueryParameters(final boolean withDescription, final boolean withLogs) { return new Parameters("modifiedsince", "20060320000000", - "user", "0", "cache", "1", "cachedesc", withDescription ? "1" : "0", - "cachelog", withLogs ? "1" : "0", "picture", "1", "removedobject", "0", - "session", "0", "doctype", "0", "charset", "utf-8", "zip", "gzip"); + "user", "0", + "cache", "1", + "cachedesc", withDescription ? "1" : "0", + "cachelog", withLogs ? "1" : "0", + "picture", "1", + "removedobject", "0", + "session", "0", + "doctype", "0", + "charset", "utf-8", + "zip", "gzip", + "picturefromcachelog", "1"); } } |
