From 09422472f4230ba92ff8747b54d1908847f764d4 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Mon, 11 Feb 2013 20:32:02 +0100 Subject: #2441: cache owner information for OC --- main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java index fcd5cbd..9739beb 100644 --- a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java +++ b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java @@ -404,6 +404,14 @@ public class OC11XMLParser { } }); + cacheNode.getChild("userid").setEndTextElementListener(new EndTextElementListener() { + + @Override + public void end(String body) { + cacheHolder.cache.setOwnerDisplayName(body); + } + }); + // cache.attributes.attribute final Element attributeNode = cacheNode.getChild("attributes").getChild("attribute"); -- cgit v1.1 From 770b16ebbc0f89d088aa3a8dfca2277864b61b24 Mon Sep 17 00:00:00 2001 From: rsudev Date: Mon, 11 Feb 2013 20:53:00 +0100 Subject: Fix #2441, Owner information not shown for OC.de caches Extended oc connector to return owner state as well --- main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java | 4 +++- .../cgeo/geocaching/connector/oc/OCXMLApiConnector.java | 8 ++++++++ .../cgeo/geocaching/connector/opencaching/OCXMLTest.java | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java index 9739beb..6d2de02 100644 --- a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java +++ b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java @@ -394,7 +394,7 @@ public class OC11XMLParser { } }); - // cache.terrain + // cache.datehidden cacheNode.getChild("datehidden").setEndTextElementListener(new EndTextElementListener() { @Override @@ -404,11 +404,13 @@ public class OC11XMLParser { } }); + // cache.userid cacheNode.getChild("userid").setEndTextElementListener(new EndTextElementListener() { @Override public void end(String body) { cacheHolder.cache.setOwnerDisplayName(body); + cacheHolder.cache.setOwnerUserId(body); } }); diff --git a/main/src/cgeo/geocaching/connector/oc/OCXMLApiConnector.java b/main/src/cgeo/geocaching/connector/oc/OCXMLApiConnector.java index 69707b9..d361a7e 100644 --- a/main/src/cgeo/geocaching/connector/oc/OCXMLApiConnector.java +++ b/main/src/cgeo/geocaching/connector/oc/OCXMLApiConnector.java @@ -1,6 +1,7 @@ package cgeo.geocaching.connector.oc; import cgeo.geocaching.Geocache; +import cgeo.geocaching.ICache; import cgeo.geocaching.SearchResult; import cgeo.geocaching.Settings; import cgeo.geocaching.connector.capability.ISearchByCenter; @@ -10,6 +11,8 @@ import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.utils.CancellableHandler; +import org.apache.commons.lang3.StringUtils; + public class OCXMLApiConnector extends OCConnector implements ISearchByGeocode, ISearchByCenter, ISearchByViewPort { private final static double SEARCH_DISTANCE_LIMIT = 15.0; @@ -49,4 +52,9 @@ public class OCXMLApiConnector extends OCConnector implements ISearchByGeocode, return Settings.isOCConnectorActive(); } + @Override + public boolean isOwner(ICache cache) { + return StringUtils.equalsIgnoreCase(cache.getOwnerUserId(), Settings.getOCConnectorUserName()); + } + } diff --git a/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java b/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java index 7cfd261..0957a0d 100644 --- a/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java +++ b/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java @@ -34,4 +34,18 @@ public class OCXMLTest extends CGeoTestCase { Settings.setOCConnectorUserName(oldOCName); } } + + public static void testOCOwner() { + String oldOCName = Settings.getOCConnectorUserName(); + try { + Settings.setOCConnectorUserName("andi12.2"); + String geoCode = "OCC9BE"; + Geocache cache = OCXMLClient.getCache(geoCode); + assertNotNull(cache); + + assertTrue(cache.isOwner()); + } finally { + Settings.setOCConnectorUserName(oldOCName); + } + } } -- cgit v1.1 From 5536a37f79649656563238d2dfe21a7e6743b87e Mon Sep 17 00:00:00 2001 From: rsudev Date: Mon, 11 Feb 2013 21:37:58 +0100 Subject: Fix #2348, Cache description is missing for OC0537 Added failing testcase and fixed modifiedsince in query-string --- main/src/cgeo/geocaching/connector/oc/OCXMLClient.java | 2 +- tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java b/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java index 3e4d5b6..dee7bb9 100644 --- a/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java +++ b/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java @@ -99,7 +99,7 @@ public class OCXMLClient { } private static Parameters getOCXmlQueryParameters(final boolean withDescription, final boolean withLogs, final boolean withImages) { - return new Parameters("modifiedsince", "20060320000000", + return new Parameters("modifiedsince", "20000101000000", "user", "0", "cache", "1", "cachedesc", withDescription ? "1" : "0", diff --git a/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java b/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java index 0957a0d..92c2063 100644 --- a/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java +++ b/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java @@ -48,4 +48,12 @@ public class OCXMLTest extends CGeoTestCase { Settings.setOCConnectorUserName(oldOCName); } } + + public static void testOC0537Description() { + String geoCode = "OC0537"; + Geocache cache = OCXMLClient.getCache(geoCode); + assertNotNull(cache); + + assertFalse(cache.getDescription().length() < 100); + } } -- cgit v1.1 From 277c86c9b9df5b19c8e9602b8497370fed7e421b Mon Sep 17 00:00:00 2001 From: Marco Jacob Date: Mon, 11 Feb 2013 22:31:25 +0100 Subject: fixes #2436 - new colletion type needs remove on old cache instance --- main/src/cgeo/geocaching/maps/CGeoMap.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 88cf2dc..921412b 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -8,10 +8,10 @@ import cgeo.geocaching.SearchResult; import cgeo.geocaching.Settings; import cgeo.geocaching.StoredList; import cgeo.geocaching.Waypoint; -import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.cgData; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.cgeocaches; +import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.connector.ConnectorFactory; import cgeo.geocaching.connector.gc.Login; import cgeo.geocaching.enumerations.CacheType; @@ -494,6 +494,8 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto for (String geocode : dirtyCaches) { Geocache cache = cgData.loadCache(geocode, LoadFlags.LOAD_WAYPOINTS); if (cache != null) { + // new collection type needs to remove first + caches.remove(cache); // re-add to update the freshness caches.add(cache); } -- cgit v1.1