aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/connector/oc/OCApiLiveConnector.java
diff options
context:
space:
mode:
authorrsudev <rasch@munin-soft.de>2013-05-26 17:44:10 +0200
committerrsudev <rasch@munin-soft.de>2013-05-26 17:44:10 +0200
commit8e2ec9dd830d9c5c370ae8aa77163c22364e47e0 (patch)
tree2ed070f00896c636867b01f0c5dadf78ac2a828f /main/src/cgeo/geocaching/connector/oc/OCApiLiveConnector.java
parentea5cfa107123deaf358bf75a7cf8835fc95acc8f (diff)
downloadcgeo-8e2ec9dd830d9c5c370ae8aa77163c22364e47e0.zip
cgeo-8e2ec9dd830d9c5c370ae8aa77163c22364e47e0.tar.gz
cgeo-8e2ec9dd830d9c5c370ae8aa77163c22364e47e0.tar.bz2
Implements OKAPI access for oc.de
Enable OKAPI for opencaching.de Enhance OKAPI to allow nearby and livemap searches Enhance OKAPI to allow posting logs and watchlist changes
Diffstat (limited to 'main/src/cgeo/geocaching/connector/oc/OCApiLiveConnector.java')
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OCApiLiveConnector.java78
1 files changed, 78 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/connector/oc/OCApiLiveConnector.java b/main/src/cgeo/geocaching/connector/oc/OCApiLiveConnector.java
new file mode 100644
index 0000000..a578aac
--- /dev/null
+++ b/main/src/cgeo/geocaching/connector/oc/OCApiLiveConnector.java
@@ -0,0 +1,78 @@
+package cgeo.geocaching.connector.oc;
+
+import cgeo.geocaching.Geocache;
+import cgeo.geocaching.SearchResult;
+import cgeo.geocaching.cgData;
+import cgeo.geocaching.cgeoapplication;
+import cgeo.geocaching.connector.ILoggingManager;
+import cgeo.geocaching.connector.capability.ISearchByCenter;
+import cgeo.geocaching.connector.capability.ISearchByViewPort;
+import cgeo.geocaching.geopoint.Geopoint;
+import cgeo.geocaching.geopoint.Viewport;
+import cgeo.geocaching.utils.CryptUtils;
+
+import android.app.Activity;
+
+public class OCApiLiveConnector extends OCApiConnector implements ISearchByCenter, ISearchByViewPort {
+
+ private String cS;
+
+ public OCApiLiveConnector(String name, String host, String prefix, int cKResId, int cSResId) {
+ super(name, host, prefix, CryptUtils.rot13(cgeoapplication.getInstance().getResources().getString(cKResId)));
+
+ cS = CryptUtils.rot13(cgeoapplication.getInstance().getResources().getString(cSResId));
+ }
+
+ @Override
+ public SearchResult searchByViewport(Viewport viewport, String[] tokens) {
+ return new SearchResult(OkapiClient.getCachesBBox(viewport, this));
+ }
+
+ @Override
+ public SearchResult searchByCenter(Geopoint center) {
+
+ return new SearchResult(OkapiClient.getCachesAround(center, this));
+ }
+
+ public String getCS() {
+ return CryptUtils.rot13(cS);
+ }
+
+ @Override
+ public boolean supportsWatchList() {
+ return true;
+ }
+
+ @Override
+ public boolean addToWatchlist(Geocache cache) {
+ final boolean added = OkapiClient.setWatchState(cache, true, this);
+
+ if (added) {
+ cgData.saveChangedCache(cache);
+ }
+
+ return added;
+ }
+
+ @Override
+ public boolean removeFromWatchlist(Geocache cache) {
+ final boolean removed = OkapiClient.setWatchState(cache, false, this);
+
+ if (removed) {
+ cgData.saveChangedCache(cache);
+ }
+
+ return removed;
+ }
+
+ @Override
+ public boolean supportsLogging() {
+ return true;
+ }
+
+ @Override
+ public ILoggingManager getLoggingManager(Activity activity, Geocache cache) {
+ return new OkapiLoggingManager(activity, this, cache);
+ }
+
+}