From b27a9b70122107491946d357c8b39c1bc8916485 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Tue, 18 Oct 2011 21:35:14 +0200 Subject: 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. --- main/src/cgeo/geocaching/cgBase.java | 13 ++++++++----- 1 file 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"); -- cgit v1.1