diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2014-01-03 14:28:14 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2014-01-03 14:28:14 +0100 |
| commit | 887071302a20937a98d601f59ac74f2b9bdaa215 (patch) | |
| tree | 0495c0ce6ae8caf34df46c2cb2f37045612cff29 | |
| parent | 1b5534d17cfe3aafa4e3eaeb6bcb9d79f024cc08 (diff) | |
| download | cgeo-887071302a20937a98d601f59ac74f2b9bdaa215.zip cgeo-887071302a20937a98d601f59ac74f2b9bdaa215.tar.gz cgeo-887071302a20937a98d601f59ac74f2b9bdaa215.tar.bz2 | |
fix #3508: gc.com find count incorrect if site is non-English
Now, when attempting to log in, if the site needs to be switched in
English, a new login is attempted in order to parse the requested
information from gc.com.
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCLogin.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCLogin.java b/main/src/cgeo/geocaching/connector/gc/GCLogin.java index 5e082b3..0c88cb5 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCLogin.java +++ b/main/src/cgeo/geocaching/connector/gc/GCLogin.java @@ -98,7 +98,9 @@ public class GCLogin extends AbstractLogin { if (getLoginStatus(loginData)) { Log.i("Already logged in Geocaching.com as " + username + " (" + Settings.getMemberStatus() + ')'); - switchToEnglish(loginData); + if (switchToEnglish(loginData) && retry) { + return login(false); + }; return StatusCode.NO_ERROR; // logged in } @@ -132,7 +134,9 @@ public class GCLogin extends AbstractLogin { if (getLoginStatus(loginData)) { Log.i("Successfully logged in Geocaching.com as " + username + " (" + Settings.getMemberStatus() + ')'); - switchToEnglish(loginData); + if (switchToEnglish(loginData) && retry) { + return login(false); + } Settings.setCookieStore(Cookies.dumpCookieStore()); return StatusCode.NO_ERROR; // logged in @@ -220,7 +224,13 @@ public class GCLogin extends AbstractLogin { return false; } - private void switchToEnglish(String previousPage) { + /** + * Ensure that the web site is in English. + * + * @param previousPage the content of the last loaded page + * @return <code>true</code> if a switch was necessary and succesfully performed (non-English -> English) + */ + private boolean switchToEnglish(String previousPage) { if (previousPage != null && previousPage.contains(ENGLISH)) { Log.i("Geocaching.com language already set to English"); // get find count @@ -238,10 +248,11 @@ public class GCLogin extends AbstractLogin { final HttpResponse response = Network.postRequest(LANGUAGE_CHANGE_URI, params, new Parameters("Referer", LANGUAGE_CHANGE_URI)); if (Network.isSuccess(response)) { Log.i("changed language on geocaching.com to English"); - } else { - Log.e("Failed to set geocaching.com language to English"); + return true; } + Log.e("Failed to set geocaching.com language to English"); } + return false; } public BitmapDrawable downloadAvatarAndGetMemberStatus() { |
