aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/network
diff options
context:
space:
mode:
authorBananeweizen <Bananeweizen@gmx.de>2012-04-12 19:31:13 +0200
committerBananeweizen <Bananeweizen@gmx.de>2012-04-12 19:31:13 +0200
commitb2f4fa6db9e262d087d715c497b1241833a0599d (patch)
treec3972bf51ce2776cfca4d564d05f5eb66a1fbe64 /main/src/cgeo/geocaching/network
parent90a0c8b78f121ddf7295a97e257aa2605a371434 (diff)
downloadcgeo-b2f4fa6db9e262d087d715c497b1241833a0599d.zip
cgeo-b2f4fa6db9e262d087d715c497b1241833a0599d.tar.gz
cgeo-b2f4fa6db9e262d087d715c497b1241833a0599d.tar.bz2
refactoring: remove the logging tag from settings
Diffstat (limited to 'main/src/cgeo/geocaching/network')
-rw-r--r--main/src/cgeo/geocaching/network/HtmlImage.java13
-rw-r--r--main/src/cgeo/geocaching/network/Login.java34
-rw-r--r--main/src/cgeo/geocaching/network/Network.java23
3 files changed, 34 insertions, 36 deletions
diff --git a/main/src/cgeo/geocaching/network/HtmlImage.java b/main/src/cgeo/geocaching/network/HtmlImage.java
index 6cb4b86..cd89a06 100644
--- a/main/src/cgeo/geocaching/network/HtmlImage.java
+++ b/main/src/cgeo/geocaching/network/HtmlImage.java
@@ -1,7 +1,6 @@
package cgeo.geocaching.network;
import cgeo.geocaching.R;
-import cgeo.geocaching.Settings;
import cgeo.geocaching.StoredList;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.files.LocalStorage;
@@ -91,7 +90,7 @@ public class HtmlImage implements Html.ImageGetter {
}
}
} catch (Exception e) {
- Log.e(Settings.tag, "HtmlImage.getDrawable (downloading from web)", e);
+ Log.e("HtmlImage.getDrawable (downloading from web)", e);
}
}
}
@@ -107,7 +106,7 @@ public class HtmlImage implements Html.ImageGetter {
// get image and return
if (imagePre == null) {
- Log.d(Settings.tag, "HtmlImage.getDrawable: Failed to obtain image");
+ Log.d("HtmlImage.getDrawable: Failed to obtain image");
if (returnErrorImage) {
imagePre = BitmapFactory.decodeResource(context.getResources(), R.drawable.image_not_loaded);
@@ -130,7 +129,7 @@ public class HtmlImage implements Html.ImageGetter {
try {
imagePre = Bitmap.createScaledBitmap(imagePre, width, height, true);
} catch (Exception e) {
- Log.d(Settings.tag, "HtmlImage.getDrawable: Failed to scale image");
+ Log.d("HtmlImage.getDrawable: Failed to scale image");
return null;
}
} else {
@@ -158,7 +157,7 @@ public class HtmlImage implements Html.ImageGetter {
final File fileSec = LocalStorage.getStorageSecFile(geocode, url, true);
return loadCachedImage(fileSec);
} catch (Exception e) {
- Log.w(Settings.tag, "HtmlImage.getDrawable (reading cache): " + e.toString());
+ Log.w("HtmlImage.getDrawable (reading cache): " + e.toString());
}
return null;
}
@@ -182,7 +181,7 @@ public class HtmlImage implements Html.ImageGetter {
}
}
} catch (Exception e) {
- Log.e(Settings.tag, "HtmlImage.makeAbsoluteURL (parse URL)", e);
+ Log.e("HtmlImage.makeAbsoluteURL (parse URL)", e);
}
return null;
}
@@ -207,7 +206,7 @@ public class HtmlImage implements Html.ImageGetter {
fis = new FileInputStream(file);
BitmapFactory.decodeStream(fis, null, options);
} catch (FileNotFoundException e) {
- Log.e(Settings.tag, "HtmlImage.setSampleSize", e);
+ Log.e("HtmlImage.setSampleSize", e);
} finally {
if (fis != null) {
try {
diff --git a/main/src/cgeo/geocaching/network/Login.java b/main/src/cgeo/geocaching/network/Login.java
index fe78978..200daaf 100644
--- a/main/src/cgeo/geocaching/network/Login.java
+++ b/main/src/cgeo/geocaching/network/Login.java
@@ -61,7 +61,7 @@ public abstract class Login {
if (login == null || StringUtils.isEmpty(login.left) || StringUtils.isEmpty(login.right)) {
Login.setActualStatus(cgBase.res.getString(R.string.err_login));
- Log.e(Settings.tag, "cgeoBase.login: No login information stored");
+ Log.e("cgeoBase.login: No login information stored");
return StatusCode.NO_LOGIN_INFO_STORED;
}
@@ -76,12 +76,12 @@ public abstract class Login {
}
if (StringUtils.isBlank(loginData)) {
- Log.e(Settings.tag, "cgeoBase.login: Failed to retrieve login page (1st)");
+ Log.e("cgeoBase.login: Failed to retrieve login page (1st)");
return StatusCode.CONNECTION_FAILED; // no loginpage
}
if (Login.getLoginStatus(loginData)) {
- Log.i(Settings.tag, "Already logged in Geocaching.com as " + login.left);
+ Log.i("Already logged in Geocaching.com as " + login.left);
Login.switchToEnglish(loginData);
return StatusCode.NO_ERROR; // logged in
}
@@ -98,7 +98,7 @@ public abstract class Login {
"ctl00$ContentBody$btnSignIn", "Login");
final String[] viewstates = Login.getViewstates(loginData);
if (cgBase.isEmpty(viewstates)) {
- Log.e(Settings.tag, "cgeoBase.login: Failed to find viewstates");
+ Log.e("cgeoBase.login: Failed to find viewstates");
return StatusCode.LOGIN_PARSE_ERROR; // no viewstates
}
Login.putViewstates(params, viewstates);
@@ -108,7 +108,7 @@ public abstract class Login {
if (StringUtils.isNotBlank(loginData)) {
if (Login.getLoginStatus(loginData)) {
- Log.i(Settings.tag, "Successfully logged in Geocaching.com as " + login.left);
+ Log.i("Successfully logged in Geocaching.com as " + login.left);
Login.switchToEnglish(loginData);
Settings.setCookieStore(Network.dumpCookieStore());
@@ -116,15 +116,15 @@ public abstract class Login {
return StatusCode.NO_ERROR; // logged in
} else {
if (loginData.contains("Your username/password combination does not match.")) {
- Log.i(Settings.tag, "Failed to log in Geocaching.com as " + login.left + " because of wrong username/password");
+ 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(Settings.tag, "Failed to log in Geocaching.com as " + login.left + " for some unknown reason");
+ Log.i("Failed to log in Geocaching.com as " + login.left + " for some unknown reason");
return StatusCode.UNKNOWN_ERROR; // can't login
}
}
} else {
- Log.e(Settings.tag, "cgeoBase.login: Failed to retrieve login page (2nd)");
+ 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
}
@@ -182,7 +182,7 @@ public abstract class Login {
*/
public static boolean getLoginStatus(final String page) {
if (StringUtils.isBlank(page)) {
- Log.e(Settings.tag, "cgeoBase.checkLogin: No page given");
+ Log.e("cgeoBase.checkLogin: No page given");
return false;
}
@@ -216,14 +216,14 @@ public abstract class Login {
private static void switchToEnglish(String previousPage) {
if (previousPage != null && previousPage.indexOf(ENGLISH) >= 0) {
- Log.i(Settings.tag, "Geocaching.com language already set to English");
+ Log.i("Geocaching.com language already set to English");
// get find count
getLoginStatus(Network.getResponseData(Network.request("http://www.geocaching.com/email/", null, false)));
} else {
final String page = Network.getResponseData(Network.request("http://www.geocaching.com/default.aspx", null, false));
getLoginStatus(page);
if (page == null) {
- Log.e(Settings.tag, "Failed to read viewstates to set geocaching.com language");
+ Log.e("Failed to read viewstates to set geocaching.com language");
}
final Parameters params = new Parameters(
"__EVENTTARGET", "ctl00$uxLocaleList$uxLocaleList$ctl00$uxLocaleItem", // switch to english
@@ -231,7 +231,7 @@ public abstract class Login {
Login.transferViewstates(page, params);
final HttpResponse response = Network.postRequest("http://www.geocaching.com/default.aspx", params);
if (!Network.isSuccess(response)) {
- Log.e(Settings.tag, "Failed to set geocaching.com language to English");
+ Log.e("Failed to set geocaching.com language to English");
}
}
}
@@ -250,9 +250,9 @@ public abstract class Login {
return imgGetter.getDrawable(avatarURL);
}
// No match? There may be no avatar set by user.
- Log.d(Settings.tag, "No avatar set for user");
+ Log.d("No avatar set for user");
} catch (Exception e) {
- Log.w(Settings.tag, "Error when retrieving user avatar", e);
+ Log.w("Error when retrieving user avatar", e);
}
return null;
}
@@ -265,7 +265,7 @@ public abstract class Login {
final String result = Network.getResponseData(Network.request("http://www.geocaching.com/account/ManagePreferences.aspx", null, false, false, false));
if (null == result) {
- Log.w(Settings.tag, "cgeoBase.detectGcCustomDate: result is null");
+ Log.w("cgeoBase.detectGcCustomDate: result is null");
return;
}
@@ -322,7 +322,7 @@ public abstract class Login {
try {
count = Integer.parseInt(matcherViewstateCount.group(1));
} catch (NumberFormatException e) {
- Log.e(Settings.tag, "getViewStates", e);
+ Log.e("getViewStates", e);
}
}
@@ -340,7 +340,7 @@ public abstract class Login {
try {
no = Integer.parseInt(sno);
} catch (NumberFormatException e) {
- Log.e(Settings.tag, "getViewStates", e);
+ Log.e("getViewStates", e);
no = 0;
}
}
diff --git a/main/src/cgeo/geocaching/network/Network.java b/main/src/cgeo/geocaching/network/Network.java
index 502db33..008f887 100644
--- a/main/src/cgeo/geocaching/network/Network.java
+++ b/main/src/cgeo/geocaching/network/Network.java
@@ -1,6 +1,5 @@
package cgeo.geocaching.network;
-import cgeo.geocaching.Settings;
import cgeo.geocaching.cgBase;
import cgeo.geocaching.enumerations.StatusCode;
import cgeo.geocaching.files.LocalStorage;
@@ -117,7 +116,7 @@ public abstract class Network {
HeaderElement[] codecs = ceheader.getElements();
for (int i = 0; i < codecs.length; i++) {
if (codecs[i].getName().equalsIgnoreCase("gzip")) {
- Log.d(Settings.tag, "Decompressing response");
+ Log.d("Decompressing response");
response.setEntity(
new Network.GzipDecompressingEntity(response.getEntity()));
return;
@@ -183,7 +182,7 @@ public abstract class Network {
return Network.request(request);
} catch (Exception e) {
// Can be UnsupportedEncodingException, ClientProtocolException or IOException
- Log.e(Settings.tag, "postRequest", e);
+ Log.e("postRequest", e);
return null;
}
}
@@ -258,7 +257,7 @@ public abstract class Network {
private static HttpResponse doRequest(final HttpRequestBase request) {
final String reqLogStr = request.getMethod() + " " + hidePassword(request.getURI().toString());
- Log.d(Settings.tag, reqLogStr);
+ Log.d(reqLogStr);
final HttpClient client = getHttpClient();
for (int i = 0; i <= NB_DOWNLOAD_RETRIES; i++) {
@@ -267,18 +266,18 @@ public abstract class Network {
final HttpResponse response = client.execute(request);
int status = response.getStatusLine().getStatusCode();
if (status == 200) {
- Log.d(Settings.tag, status + Network.formatTimeSpan(before) + reqLogStr);
+ Log.d(status + Network.formatTimeSpan(before) + reqLogStr);
} else {
- Log.w(Settings.tag, status + " [" + response.getStatusLine().getReasonPhrase() + "]" + Network.formatTimeSpan(before) + reqLogStr);
+ Log.w(status + " [" + response.getStatusLine().getReasonPhrase() + "]" + Network.formatTimeSpan(before) + reqLogStr);
}
return response;
} catch (IOException e) {
final String timeSpan = Network.formatTimeSpan(before);
final String tries = (i + 1) + "/" + (NB_DOWNLOAD_RETRIES + 1);
if (i == NB_DOWNLOAD_RETRIES) {
- Log.e(Settings.tag, "Failure " + tries + timeSpan + reqLogStr, e);
+ Log.e("Failure " + tries + timeSpan + reqLogStr, e);
} else {
- Log.e(Settings.tag, "Failure " + tries + " (" + e.toString() + ")" + timeSpan + "- retrying " + reqLogStr);
+ Log.e("Failure " + tries + " (" + e.toString() + ")" + timeSpan + "- retrying " + reqLogStr);
}
}
}
@@ -306,7 +305,7 @@ public abstract class Network {
try {
return new JSONObject(Network.getResponseData(response));
} catch (JSONException e) {
- Log.e(Settings.tag, "Network.requestJSON", e);
+ Log.e("Network.requestJSON", e);
}
}
@@ -322,7 +321,7 @@ public abstract class Network {
String data = EntityUtils.toString(response.getEntity(), HTTP.UTF_8);
return replaceWhitespace ? BaseUtils.replaceWhitespace(data) : data;
} catch (Exception e) {
- Log.e(Settings.tag, "getResponseData", e);
+ Log.e("getResponseData", e);
return null;
}
}
@@ -353,7 +352,7 @@ public abstract class Network {
response = postRequest(uri, null);
data = getResponseData(response);
} else {
- Log.i(Settings.tag, "Working as guest.");
+ Log.i("Working as guest.");
}
}
return data;
@@ -378,7 +377,7 @@ public abstract class Network {
response = request(uri, params, xContentType, my, addF);
data = getResponseData(response);
} else {
- Log.i(Settings.tag, "Working as guest.");
+ Log.i("Working as guest.");
}
}
return data;