aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/connector/gc
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/connector/gc')
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java14
-rw-r--r--main/src/cgeo/geocaching/connector/gc/Login.java50
2 files changed, 31 insertions, 33 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index cf7c762..7143058 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -186,15 +186,11 @@ public abstract class GCParser {
if (StringUtils.isNotBlank(inventoryPre)) {
final Matcher matcherTbsInside = GCConstants.PATTERN_SEARCH_TRACKABLESINSIDE.matcher(inventoryPre);
while (matcherTbsInside.find()) {
- if (matcherTbsInside.groupCount() == 2 && matcherTbsInside.group(2) != null) {
- final String inventoryItem = matcherTbsInside.group(2).toLowerCase();
- if (inventoryItem.equals("premium member only cache")) {
- continue;
- } else {
- if (cache.getInventoryItems() <= 0) {
- cache.setInventoryItems(1);
- }
- }
+ if (matcherTbsInside.groupCount() == 2 &&
+ matcherTbsInside.group(2) != null &&
+ !matcherTbsInside.group(2).equalsIgnoreCase("premium member only cache") &&
+ cache.getInventoryItems() <= 0) {
+ cache.setInventoryItems(1);
}
}
}
diff --git a/main/src/cgeo/geocaching/connector/gc/Login.java b/main/src/cgeo/geocaching/connector/gc/Login.java
index 1e614df..24f916a 100644
--- a/main/src/cgeo/geocaching/connector/gc/Login.java
+++ b/main/src/cgeo/geocaching/connector/gc/Login.java
@@ -106,28 +106,28 @@ public abstract class Login {
loginResponse = Network.postRequest("https://www.geocaching.com/login/default.aspx", params);
loginData = Network.getResponseData(loginResponse);
- if (StringUtils.isNotBlank(loginData)) {
- if (Login.getLoginStatus(loginData)) {
- Log.i("Successfully logged in Geocaching.com as " + login.left);
-
- Login.switchToEnglish(loginData);
- Settings.setCookieStore(Cookies.dumpCookieStore());
-
- return StatusCode.NO_ERROR; // logged in
- } else {
- if (loginData.contains("Your username/password combination does not match.")) {
- Log.i("Failed to log in Geocaching.com as " + login.left + " because of wrong username/password");
- return StatusCode.WRONG_LOGIN_DATA; // wrong login
- } else {
- Log.i("Failed to log in Geocaching.com as " + login.left + " for some unknown reason");
- return StatusCode.UNKNOWN_ERROR; // can't login
- }
- }
- } else {
+ if (StringUtils.isBlank(loginData)) {
Log.e("cgeoBase.login: Failed to retrieve login page (2nd)");
// FIXME: should it be CONNECTION_FAILED to match the first attempt?
return StatusCode.COMMUNICATION_ERROR; // no login page
}
+
+ if (Login.getLoginStatus(loginData)) {
+ Log.i("Successfully logged in Geocaching.com as " + login.left);
+
+ Login.switchToEnglish(loginData);
+ Settings.setCookieStore(Cookies.dumpCookieStore());
+
+ return StatusCode.NO_ERROR; // logged in
+ }
+
+ if (loginData.contains("Your username/password combination does not match.")) {
+ Log.i("Failed to log in Geocaching.com as " + login.left + " because of wrong username/password");
+ return StatusCode.WRONG_LOGIN_DATA; // wrong login
+ }
+
+ Log.i("Failed to log in Geocaching.com as " + login.left + " for some unknown reason");
+ return StatusCode.UNKNOWN_ERROR; // can't login
}
public static StatusCode logout() {
@@ -421,13 +421,15 @@ public abstract class Login {
public static String getRequestLogged(final String uri, final Parameters params) {
final String data = Network.getResponseData(Network.getRequest(uri, params));
- if (!getLoginStatus(data)) {
- if (login() == StatusCode.NO_ERROR) {
- return Network.getResponseData(Network.getRequest(uri, params));
- } else {
- Log.i("Working as guest.");
- }
+ if (getLoginStatus(data)) {
+ return data;
}
+
+ if (login() == StatusCode.NO_ERROR) {
+ return Network.getResponseData(Network.getRequest(uri, params));
+ }
+
+ Log.w("Working as guest.");
return data;
}