diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2011-10-18 21:35:14 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2011-10-18 21:35:14 +0200 |
| commit | b27a9b70122107491946d357c8b39c1bc8916485 (patch) | |
| tree | cd30e08aff08a793acef902d9f2394f510d0c7c3 | |
| parent | 06d457ca0951e7dd3d9c9919d2939b5c8c40bcdd (diff) | |
| download | cgeo-b27a9b70122107491946d357c8b39c1bc8916485.zip cgeo-b27a9b70122107491946d357c8b39c1bc8916485.tar.gz cgeo-b27a9b70122107491946d357c8b39c1bc8916485.tar.bz2 | |
Do not use viewstates from an unrelated page before a request
Using the viewstates from another page will result in an error
from the web server (500). Load the requested page to get the
viewstates first.
This should close #684.
| -rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index 82a55ae..0615c0f 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -458,7 +458,7 @@ public class cgBase { if (checkLogin(loginData)) { Log.i(Settings.tag, "Already logged in Geocaching.com as " + loginStart.left); - switchToEnglish(viewstates); + switchToEnglish(); return StatusCode.NO_ERROR; // logged in } @@ -493,7 +493,7 @@ public class cgBase { if (checkLogin(loginData)) { Log.i(Settings.tag, "Successfully logged in Geocaching.com as " + login.left); - switchToEnglish(getViewstates(loginData)); + switchToEnglish(); return StatusCode.NO_ERROR; // logged in } else { @@ -535,12 +535,15 @@ public class cgBase { return false; } - public static void switchToEnglish(final String[] viewstates) { + public static void switchToEnglish() { + final String page = getResponseData(request("http://www.geocaching.com/default.aspx", null, false)); + if (page == null) { + Log.e(Settings.tag, "Failed to read viewstates to set geocaching.com language"); + } final Parameters params = new Parameters( "__EVENTTARGET", "ctl00$uxLocaleList$uxLocaleList$ctl00$uxLocaleItem", // switch to english "__EVENTARGUMENT", ""); - putViewstates(params, viewstates); - + transferViewstates(page, params); final HttpResponse response = postRequest("http://www.geocaching.com/default.aspx", params); if (!isSuccess(response)) { Log.e(Settings.tag, "Failed to set geocaching.com language to English"); |
