Merge pull request #2423 from k9mail/timberLibrary

Move k9mail-library to Timber
This commit is contained in:
cketti 2017-03-26 05:29:03 +02:00 committed by GitHub
commit 3cd7e26bb9
45 changed files with 247 additions and 357 deletions

View file

@ -1,6 +1,7 @@
androidCompileSdkVersion=25 androidCompileSdkVersion=25
androidBuildToolsVersion=25.0.2 androidBuildToolsVersion=25.0.2
androidSupportLibraryVersion=25.2.0 androidSupportLibraryVersion=25.2.0
timberVersion=4.5.1
robolectricVersion=3.2.2 robolectricVersion=3.2.2
junitVersion=4.12 junitVersion=4.12

View file

@ -20,6 +20,7 @@ dependencies {
compile 'com.jcraft:jzlib:1.0.7' compile 'com.jcraft:jzlib:1.0.7'
compile 'com.beetstra.jutf7:jutf7:1.0.0' compile 'com.beetstra.jutf7:jutf7:1.0.0'
compile "com.android.support:support-annotations:${androidSupportLibraryVersion}" compile "com.android.support:support-annotations:${androidSupportLibraryVersion}"
compile "com.jakewharton.timber:timber:${timberVersion}"
androidTestCompile 'com.android.support.test:runner:0.4.1' androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.madgag.spongycastle:pg:1.51.0.0' androidTestCompile 'com.madgag.spongycastle:pg:1.51.0.0'

View file

@ -12,13 +12,11 @@ import org.apache.james.mime4j.codec.EncoderUtil;
import org.apache.james.mime4j.dom.address.Mailbox; import org.apache.james.mime4j.dom.address.Mailbox;
import org.apache.james.mime4j.dom.address.MailboxList; import org.apache.james.mime4j.dom.address.MailboxList;
import org.apache.james.mime4j.field.address.AddressBuilder; import org.apache.james.mime4j.field.address.AddressBuilder;
import timber.log.Timber;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.util.Rfc822Token; import android.text.util.Rfc822Token;
import android.text.util.Rfc822Tokenizer; import android.text.util.Rfc822Tokenizer;
import android.util.Log;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public class Address implements Serializable { public class Address implements Serializable {
private static final Pattern ATOM = Pattern.compile("^(?:[a-zA-Z0-9!#$%&'*+\\-/=?^_`{|}~]|\\s)+$"); private static final Pattern ATOM = Pattern.compile("^(?:[a-zA-Z0-9!#$%&'*+\\-/=?^_`{|}~]|\\s)+$");
@ -152,12 +150,11 @@ public class Address implements Serializable {
Mailbox mailbox = (Mailbox) address; Mailbox mailbox = (Mailbox) address;
addresses.add(new Address(mailbox.getLocalPart() + "@" + mailbox.getDomain(), mailbox.getName(), false)); addresses.add(new Address(mailbox.getLocalPart() + "@" + mailbox.getDomain(), mailbox.getName(), false));
} else { } else {
Log.e(LOG_TAG, "Unknown address type from Mime4J: " Timber.e("Unknown address type from Mime4J: %s", address.getClass().toString());
+ address.getClass().toString());
} }
} }
} catch (MimeException pe) { } catch (MimeException pe) {
Log.e(LOG_TAG, "MimeException in Address.parse()", pe); Timber.e(pe, "MimeException in Address.parse()");
//but we do an silent failover : we just use the given string as name with empty address //but we do an silent failover : we just use the given string as name with empty address
addresses.add(new Address(null, addressList, false)); addresses.add(new Address(null, addressList, false));
} }

View file

@ -6,9 +6,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import android.util.Log; import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public abstract class Folder<T extends Message> { public abstract class Folder<T extends Message> {
private String status = null; private String status = null;
@ -133,8 +132,7 @@ public abstract class Folder<T extends Message> {
// This is causing trouble. Disabled for now. See issue 1733 // This is causing trouble. Disabled for now. See issue 1733
//throw new RuntimeException("fetchPart() not implemented."); //throw new RuntimeException("fetchPart() not implemented.");
if (K9MailLib.isDebug()) Timber.d("fetchPart() not implemented.");
Log.d(LOG_TAG, "fetchPart() not implemented.");
} }
public abstract void delete(boolean recurse) throws MessagingException; public abstract void delete(boolean recurse) throws MessagingException;

View file

@ -7,7 +7,6 @@ public class K9MailLib {
private K9MailLib() { private K9MailLib() {
} }
public static final String LOG_TAG = "k9";
public static final int PUSH_WAKE_LOCK_TIMEOUT = 60000; public static final int PUSH_WAKE_LOCK_TIMEOUT = 60000;
public static final String IDENTITY_HEADER = "X-K9mail-Identity"; public static final String IDENTITY_HEADER = "X-K9mail-Identity";

View file

@ -8,12 +8,11 @@ import java.util.EnumSet;
import java.util.Set; import java.util.Set;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.util.Log;
import com.fsck.k9.mail.filter.CountingOutputStream; import com.fsck.k9.mail.filter.CountingOutputStream;
import com.fsck.k9.mail.filter.EOLConvertingOutputStream; import com.fsck.k9.mail.filter.EOLConvertingOutputStream;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public abstract class Message implements Part, Body { public abstract class Message implements Part, Body {
@ -208,9 +207,9 @@ public abstract class Message implements Part, Body {
eolOut.flush(); eolOut.flush();
return out.getCount(); return out.getCount();
} catch (IOException e) { } catch (IOException e) {
Log.e(LOG_TAG, "Failed to calculate a message size", e); Timber.e(e, "Failed to calculate a message size");
} catch (MessagingException e) { } catch (MessagingException e) {
Log.e(LOG_TAG, "Failed to calculate a message size", e); Timber.e(e, "Failed to calculate a message size");
} }
return 0; return 0;
} }

View file

@ -2,7 +2,6 @@
package com.fsck.k9.mail; package com.fsck.k9.mail;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;

View file

@ -9,14 +9,12 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.filter.Base64OutputStream; import com.fsck.k9.mail.filter.Base64OutputStream;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.codec.QuotedPrintableOutputStream; import org.apache.james.mime4j.codec.QuotedPrintableOutputStream;
import org.apache.james.mime4j.util.MimeUtil; import org.apache.james.mime4j.util.MimeUtil;
import timber.log.Timber;
/** /**
@ -136,7 +134,7 @@ public class BinaryTempFileBody implements RawDataBody, SizeAware {
try { try {
super.close(); super.close();
} finally { } finally {
Log.d(K9MailLib.LOG_TAG, "deleting temp file"); Timber.d("Deleting temporary binary file");
mFile.delete(); mFile.delete();
} }
} }

View file

@ -1,12 +1,11 @@
package com.fsck.k9.mail.internet; package com.fsck.k9.mail.internet;
import android.util.Log;
import com.fsck.k9.mail.Message; import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Part; import com.fsck.k9.mail.Part;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import timber.log.Timber;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -14,7 +13,6 @@ import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.IllegalCharsetNameException;
import java.util.Locale; import java.util.Locale;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.internet.JisSupport.SHIFT_JIS; import static com.fsck.k9.mail.internet.JisSupport.SHIFT_JIS;
public class CharsetSupport { public class CharsetSupport {
@ -111,8 +109,7 @@ public class CharsetSupport {
} }
if (charset.matches(rule[0])) { if (charset.matches(rule[0])) {
Log.e(LOG_TAG, "I don't know how to deal with the charset " + charset + Timber.e("I don't know how to deal with the charset %s. Falling back to %s", charset, rule[1]);
". Falling back to " + rule[1]);
charset = rule[1]; charset = rule[1];
try { try {
supported = Charset.isSupported(charset); supported = Charset.isSupported(charset);

View file

@ -1,7 +1,6 @@
package com.fsck.k9.mail.internet; package com.fsck.k9.mail.internet;
import android.util.Log;
import com.fsck.k9.mail.Message; import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mail.MessagingException;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -11,8 +10,7 @@ import java.nio.charset.Charset;
import org.apache.james.mime4j.codec.Base64InputStream; import org.apache.james.mime4j.codec.Base64InputStream;
import org.apache.james.mime4j.codec.QuotedPrintableInputStream; import org.apache.james.mime4j.codec.QuotedPrintableInputStream;
import org.apache.james.mime4j.util.CharsetUtil; import org.apache.james.mime4j.util.CharsetUtil;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
/** /**
@ -169,7 +167,7 @@ class DecoderUtil {
} }
if (encodedText.isEmpty()) { if (encodedText.isEmpty()) {
Log.w(LOG_TAG, "Missing encoded text in encoded word: '" + body.substring(begin, end) + "'"); Timber.w("Missing encoded text in encoded word: '%s'", body.substring(begin, end));
return null; return null;
} }
@ -178,7 +176,7 @@ class DecoderUtil {
} else if (encoding.equalsIgnoreCase("B")) { } else if (encoding.equalsIgnoreCase("B")) {
return DecoderUtil.decodeB(encodedText, charset); return DecoderUtil.decodeB(encodedText, charset);
} else { } else {
Log.w(LOG_TAG, "Warning: Unknown encoding in encoded word '" + body.substring(begin, end) + "'"); Timber.w("Warning: Unknown encoding in encoded word '%s'", body.substring(begin, end));
return null; return null;
} }
} }

View file

@ -12,7 +12,6 @@ import java.util.regex.Pattern;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.Log;
import com.fsck.k9.mail.Body; import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.BodyPart; import com.fsck.k9.mail.BodyPart;
@ -22,8 +21,8 @@ import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part; import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.internet.Viewable.Flowed; import com.fsck.k9.mail.internet.Viewable.Flowed;
import org.apache.commons.io.input.BoundedInputStream; import org.apache.commons.io.input.BoundedInputStream;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.internet.CharsetSupport.fixupCharset; import static com.fsck.k9.mail.internet.CharsetSupport.fixupCharset;
import static com.fsck.k9.mail.internet.MimeUtility.getHeaderParameter; import static com.fsck.k9.mail.internet.MimeUtility.getHeaderParameter;
import static com.fsck.k9.mail.internet.MimeUtility.isFormatFlowed; import static com.fsck.k9.mail.internet.MimeUtility.isFormatFlowed;
@ -62,9 +61,9 @@ public class MessageExtractor {
throw new MessagingException("Provided invalid part"); throw new MessagingException("Provided invalid part");
} }
} catch (IOException e) { } catch (IOException e) {
Log.e(LOG_TAG, "Unable to getTextFromPart", e); Timber.e(e, "Unable to getTextFromPart");
} catch (MessagingException e) { } catch (MessagingException e) {
Log.e(LOG_TAG, "Unable to getTextFromPart", e); Timber.e("Unable to getTextFromPart");
} }
return null; return null;
} }

View file

@ -9,7 +9,6 @@ import java.util.Locale;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.util.Log;
import com.fsck.k9.mail.Body; import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.BodyPart; import com.fsck.k9.mail.BodyPart;
@ -21,8 +20,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.james.mime4j.codec.Base64InputStream; import org.apache.james.mime4j.codec.Base64InputStream;
import org.apache.james.mime4j.codec.QuotedPrintableInputStream; import org.apache.james.mime4j.codec.QuotedPrintableInputStream;
import org.apache.james.mime4j.util.MimeUtil; import org.apache.james.mime4j.util.MimeUtil;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public class MimeUtility { public class MimeUtility {
@ -1050,7 +1048,7 @@ public class MimeUtility {
} }
}; };
} else { } else {
Log.w(LOG_TAG, "Unsupported encoding: " + encoding); Timber.w("Unsupported encoding: %s", encoding);
inputStream = rawInputStream; inputStream = rawInputStream;
} }
} else { } else {

View file

@ -9,15 +9,15 @@ import java.io.OutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.Log;
import com.fsck.k9.mail.Body; import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.filter.CountingOutputStream; import com.fsck.k9.mail.filter.CountingOutputStream;
import com.fsck.k9.mail.filter.SignSafeOutputStream; import com.fsck.k9.mail.filter.SignSafeOutputStream;
import org.apache.james.mime4j.codec.QuotedPrintableOutputStream; import org.apache.james.mime4j.codec.QuotedPrintableOutputStream;
import org.apache.james.mime4j.util.MimeUtil; import org.apache.james.mime4j.util.MimeUtil;
import timber.log.Timber;
public class TextBody implements Body, SizeAware { public class TextBody implements Body, SizeAware {
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
@ -67,7 +67,7 @@ public class TextBody implements Body, SizeAware {
} }
return new ByteArrayInputStream(b); return new ByteArrayInputStream(b);
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException uee) {
Log.e(K9MailLib.LOG_TAG, "Unsupported charset: " + charset, uee); Timber.e(uee, "Unsupported charset: %s", charset);
return null; return null;
} }
} }

View file

@ -1,14 +1,11 @@
package com.fsck.k9.mail.oauth; package com.fsck.k9.mail.oauth;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib; import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.filter.Base64; import com.fsck.k9.mail.filter.Base64;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
/** /**
@ -23,7 +20,7 @@ public class XOAuth2ChallengeParser {
String decodedResponse = Base64.decode(response); String decodedResponse = Base64.decode(response);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Challenge response: " + decodedResponse); Timber.v("Challenge response: %s", decodedResponse);
} }
try { try {
@ -33,7 +30,7 @@ public class XOAuth2ChallengeParser {
return false; return false;
} }
} catch (JSONException jsonException) { } catch (JSONException jsonException) {
Log.e(LOG_TAG, "Error decoding JSON response from: " + host + ". Response was: " + decodedResponse); Timber.e("Error decoding JSON response from: %s. Response was: %s", host, decodedResponse);
} }
return true; return true;

View file

@ -1,5 +1,6 @@
package com.fsck.k9.mail.power; package com.fsck.k9.mail.power;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -8,11 +9,9 @@ import android.content.Context;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.PowerManager.WakeLock; import android.os.PowerManager.WakeLock;
import android.os.SystemClock; import android.os.SystemClock;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib; import com.fsck.k9.mail.K9MailLib;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public class TracingPowerManager { public class TracingPowerManager {
@ -26,7 +25,7 @@ public class TracingPowerManager {
Context appContext = context.getApplicationContext(); Context appContext = context.getApplicationContext();
if (tracingPowerManager == null) { if (tracingPowerManager == null) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Creating TracingPowerManager"); Timber.v("Creating TracingPowerManager");
} }
tracingPowerManager = new TracingPowerManager(appContext); tracingPowerManager = new TracingPowerManager(appContext);
} }
@ -56,7 +55,7 @@ public class TracingPowerManager {
wakeLock = pm.newWakeLock(flags, tag); wakeLock = pm.newWakeLock(flags, tag);
id = wakeLockId.getAndIncrement(); id = wakeLockId.getAndIncrement();
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": Create"); Timber.v("TracingWakeLock for tag %s / id %d: Create", tag, id);
} }
} }
public void acquire(long timeout) { public void acquire(long timeout) {
@ -64,7 +63,7 @@ public class TracingPowerManager {
wakeLock.acquire(timeout); wakeLock.acquire(timeout);
} }
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + " for " + timeout + " ms: acquired"); Timber.v("TracingWakeLock for tag %s / id %d for %d ms: acquired", tag, id, timeout);
} }
raiseNotification(); raiseNotification();
if (startTime == null) { if (startTime == null) {
@ -78,7 +77,8 @@ public class TracingPowerManager {
} }
raiseNotification(); raiseNotification();
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.w(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": acquired with no timeout. K-9 Mail should not do this"); Timber.w("TracingWakeLock for tag %s / id %d: acquired with no timeout. K-9 Mail should not do this",
tag, id);
} }
if (startTime == null) { if (startTime == null) {
startTime = SystemClock.elapsedRealtime(); startTime = SystemClock.elapsedRealtime();
@ -94,11 +94,12 @@ public class TracingPowerManager {
if (startTime != null) { if (startTime != null) {
Long endTime = SystemClock.elapsedRealtime(); Long endTime = SystemClock.elapsedRealtime();
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": releasing after " + (endTime - startTime) + " ms, timeout = " + timeout + " ms"); Timber.v("TracingWakeLock for tag %s / id %d: releasing after %d ms, timeout = %d ms",
tag, id, endTime - startTime, timeout);
} }
} else { } else {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ", timeout = " + timeout + " ms: releasing"); Timber.v("TracingWakeLock for tag %s / id %d, timeout = %d ms: releasing", tag, id, timeout);
} }
} }
cancelNotification(); cancelNotification();
@ -128,11 +129,12 @@ public class TracingPowerManager {
public void run() { public void run() {
if (startTime != null) { if (startTime != null) {
Long endTime = SystemClock.elapsedRealtime(); Long endTime = SystemClock.elapsedRealtime();
Log.i(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": has been active for " Timber.i("TracingWakeLock for tag %s / id %d: has been active for %d ms, timeout = %d ms",
+ (endTime - startTime) + " ms, timeout = " + timeout + " ms"); tag, id, endTime - startTime, timeout);
} else { } else {
Log.i(LOG_TAG, "TracingWakeLock for tag " + tag + " / id " + id + ": still active, timeout = " + timeout + " ms"); Timber.i("TracingWakeLock for tag %s / id %d: still active, timeout = %d ms",
tag, id, timeout);
} }
} }

View file

@ -13,7 +13,6 @@ import android.content.Context;
import android.net.SSLCertificateSocketFactory; import android.net.SSLCertificateSocketFactory;
import android.os.Build; import android.os.Build;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mail.MessagingException;
import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManager;
@ -21,8 +20,7 @@ import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
/** /**
@ -113,8 +111,7 @@ public class DefaultTrustedSocketFactory implements TrustedSocketFactory {
*/ */
supportedProtocols = sock.getSupportedProtocols(); supportedProtocols = sock.getSupportedProtocols();
} catch (Exception e) { } catch (Exception e) {
Log.e(LOG_TAG, "Error getting information about available SSL/TLS ciphers and " + Timber.e(e, "Error getting information about available SSL/TLS ciphers and protocols");
"protocols", e);
} }
if (hasWeakSslImplementation()) { if (hasWeakSslImplementation()) {
@ -232,7 +229,7 @@ public class DefaultTrustedSocketFactory implements TrustedSocketFactory {
try { try {
socket.getClass().getMethod("setHostname", String.class).invoke(socket, hostname); socket.getClass().getMethod("setHostname", String.class).invoke(socket, hostname);
} catch (Throwable e) { } catch (Throwable e) {
Log.e(LOG_TAG, "Could not call SSLSocket#setHostname(String) method ", e); Timber.e(e, "Could not call SSLSocket#setHostname(String) method ");
} }
} }
} }

View file

@ -18,12 +18,11 @@ import android.content.Context;
import android.os.Build; import android.os.Build;
import android.security.KeyChain; import android.security.KeyChain;
import android.security.KeyChainException; import android.security.KeyChainException;
import android.util.Log;
import com.fsck.k9.mail.CertificateValidationException; import com.fsck.k9.mail.CertificateValidationException;
import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mail.MessagingException;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.CertificateValidationException.Reason; import static com.fsck.k9.mail.CertificateValidationException.Reason;
import static com.fsck.k9.mail.CertificateValidationException.Reason.RetrievalFailure; import static com.fsck.k9.mail.CertificateValidationException.Reason.RetrievalFailure;
@ -204,10 +203,10 @@ class KeyChainKeyManager extends X509ExtendedKeyManager {
return mAlias; return mAlias;
} }
} }
Log.w(LOG_TAG, "Client certificate " + mAlias + " not issued by any of the requested issuers"); Timber.w("Client certificate %s not issued by any of the requested issuers", mAlias);
return null; return null;
} }
Log.w(LOG_TAG, "Client certificate " + mAlias + " does not match any of the requested key types"); Timber.w("Client certificate %s does not match any of the requested key types", mAlias);
return null; return null;
} }
} }

View file

@ -12,10 +12,8 @@ import java.security.cert.CertificateException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import timber.log.Timber;
import android.util.Log;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public class LocalKeyStore { public class LocalKeyStore {
private static final int KEY_STORE_FILE_VERSION = 1; private static final int KEY_STORE_FILE_VERSION = 1;
@ -50,7 +48,7 @@ public class LocalKeyStore {
* error, presuming setKeyStoreFile(File) is called next with a * error, presuming setKeyStoreFile(File) is called next with a
* non-null File. * non-null File.
*/ */
Log.w(LOG_TAG, "Local key store has not been initialized"); Timber.w("Local key store has not been initialized");
} }
} }
@ -77,7 +75,7 @@ public class LocalKeyStore {
* Keystore.load. Instead, we let it be created anew. * Keystore.load. Instead, we let it be created anew.
*/ */
if (file.exists() && !file.delete()) { if (file.exists() && !file.delete()) {
Log.d(LOG_TAG, "Failed to delete empty keystore file: " + file.getAbsolutePath()); Timber.d("Failed to delete empty keystore file: %s", file.getAbsolutePath());
} }
} }
@ -94,7 +92,7 @@ public class LocalKeyStore {
mKeyStore = store; mKeyStore = store;
mKeyStoreFile = file; mKeyStoreFile = file;
} catch (Exception e) { } catch (Exception e) {
Log.e(LOG_TAG, "Failed to initialize local key store", e); Timber.e(e, "Failed to initialize local key store");
// Use of the local key store is effectively disabled. // Use of the local key store is effectively disabled.
mKeyStore = null; mKeyStore = null;
mKeyStoreFile = null; mKeyStoreFile = null;
@ -171,7 +169,7 @@ public class LocalKeyStore {
} catch (KeyStoreException e) { } catch (KeyStoreException e) {
// Ignore: most likely there was no cert. found // Ignore: most likely there was no cert. found
} catch (CertificateException e) { } catch (CertificateException e) {
Log.e(LOG_TAG, "Error updating the local key store file", e); Timber.e(e, "Error updating the local key store file");
} }
} }
@ -180,7 +178,7 @@ public class LocalKeyStore {
// Blow away version "0" because certificate aliases have changed. // Blow away version "0" because certificate aliases have changed.
File versionZeroFile = new File(getKeyStoreFilePath(0)); File versionZeroFile = new File(getKeyStoreFilePath(0));
if (versionZeroFile.exists() && !versionZeroFile.delete()) { if (versionZeroFile.exists() && !versionZeroFile.delete()) {
Log.d(LOG_TAG, "Failed to delete old key-store file: " + versionZeroFile.getAbsolutePath()); Timber.d("Failed to delete old key-store file: %s", versionZeroFile.getAbsolutePath());
} }
} }
} }

View file

@ -1,8 +1,6 @@
package com.fsck.k9.mail.ssl; package com.fsck.k9.mail.ssl;
import android.util.Log;
import com.fsck.k9.mail.CertificateChainException; import com.fsck.k9.mail.CertificateChainException;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
@ -10,6 +8,7 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import org.apache.http.conn.ssl.StrictHostnameVerifier; import org.apache.http.conn.ssl.StrictHostnameVerifier;
import timber.log.Timber;
import java.security.KeyStore; import java.security.KeyStore;
import java.security.KeyStoreException; import java.security.KeyStoreException;
@ -20,8 +19,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public final class TrustManagerFactory { public final class TrustManagerFactory {
private static final String LOG_TAG = "TrustManagerFactory";
private static X509TrustManager defaultTrustManager; private static X509TrustManager defaultTrustManager;
private static LocalKeyStore keyStore; private static LocalKeyStore keyStore;
@ -108,9 +105,9 @@ public final class TrustManagerFactory {
} }
} }
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
Log.e(LOG_TAG, "Unable to get X509 Trust Manager ", e); Timber.e(e, "Unable to get X509 Trust Manager ");
} catch (KeyStoreException e) { } catch (KeyStoreException e) {
Log.e(LOG_TAG, "Key Store exception while initializing TrustManagerFactory ", e); Timber.e(e, "Key Store exception while initializing TrustManagerFactory");
} }
} }

View file

@ -3,7 +3,6 @@ package com.fsck.k9.mail.store.imap;
import java.io.IOException; import java.io.IOException;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Part; import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.filter.FixedLengthInputStream; import com.fsck.k9.mail.filter.FixedLengthInputStream;
import com.fsck.k9.mail.internet.MimeHeader; import com.fsck.k9.mail.internet.MimeHeader;

View file

@ -28,7 +28,6 @@ import java.util.zip.InflaterInputStream;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.util.Log;
import com.fsck.k9.mail.Authentication; import com.fsck.k9.mail.Authentication;
import com.fsck.k9.mail.AuthenticationFailedException; import com.fsck.k9.mail.AuthenticationFailedException;
@ -46,10 +45,10 @@ import com.jcraft.jzlib.JZlib;
import com.jcraft.jzlib.ZOutputStream; import com.jcraft.jzlib.ZOutputStream;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import timber.log.Timber;
import static com.fsck.k9.mail.ConnectionSecurity.STARTTLS_REQUIRED; import static com.fsck.k9.mail.ConnectionSecurity.STARTTLS_REQUIRED;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_IMAP; import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_IMAP;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.store.RemoteStore.SOCKET_CONNECT_TIMEOUT; import static com.fsck.k9.mail.store.RemoteStore.SOCKET_CONNECT_TIMEOUT;
import static com.fsck.k9.mail.store.RemoteStore.SOCKET_READ_TIMEOUT; import static com.fsck.k9.mail.store.RemoteStore.SOCKET_READ_TIMEOUT;
import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase; import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase;
@ -141,7 +140,7 @@ class ImapConnection {
throw new MessagingException("Unable to open connection to IMAP server due to security error.", e); throw new MessagingException("Unable to open connection to IMAP server due to security error.", e);
} finally { } finally {
if (!authSuccess) { if (!authSuccess) {
Log.e(LOG_TAG, "Failed to login, closing connection for " + getLogId()); Timber.e("Failed to login, closing connection for %s", getLogId());
close(); close();
} }
} }
@ -160,7 +159,7 @@ class ImapConnection {
String[] tokens = message.split("-"); String[] tokens = message.split("-");
if (tokens.length > 1 && tokens[1] != null) { if (tokens.length > 1 && tokens[1] != null) {
Log.e(LOG_TAG, "Stripping host/port from ConnectionException for " + getLogId(), e); Timber.e(e, "Stripping host/port from ConnectionException for %s", getLogId());
throw new ConnectException(tokens[1].trim()); throw new ConnectException(tokens[1].trim());
} else { } else {
throw e; throw e;
@ -176,13 +175,13 @@ class ImapConnection {
try { try {
Security.setProperty("networkaddress.cache.ttl", "0"); Security.setProperty("networkaddress.cache.ttl", "0");
} catch (Exception e) { } catch (Exception e) {
Log.w(LOG_TAG, "Could not set DNS ttl to 0 for " + getLogId(), e); Timber.w(e, "Could not set DNS ttl to 0 for %s", getLogId());
} }
try { try {
Security.setProperty("networkaddress.cache.negative.ttl", "0"); Security.setProperty("networkaddress.cache.negative.ttl", "0");
} catch (Exception e) { } catch (Exception e) {
Log.w(LOG_TAG, "Could not set DNS negative ttl to 0 for " + getLogId(), e); Timber.w(e, "Could not set DNS negative ttl to 0 for %s", getLogId());
} }
} }
@ -194,7 +193,7 @@ class ImapConnection {
try { try {
return connectToAddress(address); return connectToAddress(address);
} catch (IOException e) { } catch (IOException e) {
Log.w(LOG_TAG, "Could not connect to " + address, e); Timber.w(e, "Could not connect to %s", address);
connectException = e; connectException = e;
} }
} }
@ -210,7 +209,7 @@ class ImapConnection {
String clientCertificateAlias = settings.getClientCertificateAlias(); String clientCertificateAlias = settings.getClientCertificateAlias();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
Log.d(LOG_TAG, "Connecting to " + host + " as " + address); Timber.d("Connecting to %s as %s", host, address);
} }
SocketAddress socketAddress = new InetSocketAddress(address, port); SocketAddress socketAddress = new InetSocketAddress(address, port);
@ -245,7 +244,7 @@ class ImapConnection {
ImapResponse initialResponse = responseParser.readResponse(); ImapResponse initialResponse = responseParser.readResponse();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
Log.v(LOG_TAG, getLogId() + "<<<" + initialResponse); Timber.v("%s <<< %s", getLogId(), initialResponse);
} }
extractCapabilities(Collections.singletonList(initialResponse)); extractCapabilities(Collections.singletonList(initialResponse));
@ -258,7 +257,7 @@ class ImapConnection {
Set<String> receivedCapabilities = capabilityResponse.getCapabilities(); Set<String> receivedCapabilities = capabilityResponse.getCapabilities();
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Saving " + receivedCapabilities + " capabilities for " + getLogId()); Timber.d("Saving %s capabilities for %s", receivedCapabilities, getLogId());
} }
capabilities = receivedCapabilities; capabilities = receivedCapabilities;
@ -273,7 +272,7 @@ class ImapConnection {
} }
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Did not get capabilities in banner, requesting CAPABILITY for " + getLogId()); Timber.i("Did not get capabilities in banner, requesting CAPABILITY for %s", getLogId());
} }
requestCapabilities(); requestCapabilities();
@ -320,7 +319,7 @@ class ImapConnection {
// Per RFC 2595 (3.1): Once TLS has been started, reissue CAPABILITY command // Per RFC 2595 (3.1): Once TLS has been started, reissue CAPABILITY command
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Updating capabilities after STARTTLS for " + getLogId()); Timber.i("Updating capabilities after STARTTLS for %s", getLogId());
} }
requestCapabilities(); requestCapabilities();
@ -388,7 +387,7 @@ class ImapConnection {
} }
private void handlePermanentXoauth2Failure(NegativeImapResponseException e) throws AuthenticationFailedException { private void handlePermanentXoauth2Failure(NegativeImapResponseException e) throws AuthenticationFailedException {
Log.v(LOG_TAG, "Permanent failure during XOAUTH2", e); Timber.v(e, "Permanent failure during XOAUTH2");
throw new AuthenticationFailedException(e.getMessage(), e); throw new AuthenticationFailedException(e.getMessage(), e);
} }
@ -398,13 +397,13 @@ class ImapConnection {
//if a token was invalid before use (e.g. due to expiry). But we don't //if a token was invalid before use (e.g. due to expiry). But we don't
//This is the intended behaviour per AccountManager //This is the intended behaviour per AccountManager
Log.v(LOG_TAG, "Temporary failure - retrying with new token", e); Timber.v(e, "Temporary failure - retrying with new token");
try { try {
attemptXOAuth2(); attemptXOAuth2();
} catch (NegativeImapResponseException e2) { } catch (NegativeImapResponseException e2) {
//Okay, we failed on a new token. //Okay, we failed on a new token.
//Invalidate the token anyway but assume it's permanent. //Invalidate the token anyway but assume it's permanent.
Log.v(LOG_TAG, "Authentication exception for new token, permanent error assumed", e); Timber.v(e, "Authentication exception for new token, permanent error assumed");
oauthTokenProvider.invalidateToken(settings.getUsername()); oauthTokenProvider.invalidateToken(settings.getUsername());
handlePermanentXoauth2Failure(e2); handlePermanentXoauth2Failure(e2);
} }
@ -548,7 +547,7 @@ class ImapConnection {
if (networkInfo != null) { if (networkInfo != null) {
int type = networkInfo.getType(); int type = networkInfo.getType();
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "On network type " + type); Timber.d("On network type %s", type);
} }
NetworkType networkType = NetworkType.fromConnectivityManagerType(type); NetworkType networkType = NetworkType.fromConnectivityManagerType(type);
@ -556,7 +555,7 @@ class ImapConnection {
} }
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "useCompression " + useCompression); Timber.d("useCompression: %b", useCompression);
} }
return useCompression; return useCompression;
@ -566,7 +565,7 @@ class ImapConnection {
try { try {
executeSimpleCommand(Commands.COMPRESS_DEFLATE); executeSimpleCommand(Commands.COMPRESS_DEFLATE);
} catch (NegativeImapResponseException e) { } catch (NegativeImapResponseException e) {
Log.d(LOG_TAG, "Unable to negotiate compression: " + e.getMessage()); Timber.d(e, "Unable to negotiate compression: ");
return; return;
} }
@ -578,11 +577,11 @@ class ImapConnection {
setUpStreamsAndParser(input, output); setUpStreamsAndParser(input, output);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Compression enabled for " + getLogId()); Timber.i("Compression enabled for %s", getLogId());
} }
} catch (IOException e) { } catch (IOException e) {
close(); close();
Log.e(LOG_TAG, "Error enabling compression", e); Timber.e(e, "Error enabling compression");
} }
} }
@ -593,12 +592,12 @@ class ImapConnection {
if (hasCapability(Capabilities.NAMESPACE)) { if (hasCapability(Capabilities.NAMESPACE)) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "pathPrefix is unset and server has NAMESPACE capability"); Timber.i("pathPrefix is unset and server has NAMESPACE capability");
} }
handleNamespace(); handleNamespace();
} else { } else {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "pathPrefix is unset but server does not have NAMESPACE capability"); Timber.i("pathPrefix is unset but server does not have NAMESPACE capability");
} }
settings.setPathPrefix(""); settings.setPathPrefix("");
} }
@ -617,7 +616,7 @@ class ImapConnection {
settings.setCombinedPrefix(null); settings.setCombinedPrefix(null);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got path '" + prefix + "' and separator '" + hierarchyDelimiter + "'"); Timber.d("Got path '%s' and separator '%s'", prefix, hierarchyDelimiter);
} }
} }
} }
@ -633,7 +632,7 @@ class ImapConnection {
try { try {
listResponses = executeSimpleCommand(Commands.LIST + " \"\" \"\""); listResponses = executeSimpleCommand(Commands.LIST + " \"\" \"\"");
} catch (NegativeImapResponseException e) { } catch (NegativeImapResponseException e) {
Log.d(LOG_TAG, "Error getting path delimiter using LIST command", e); Timber.d(e, "Error getting path delimiter using LIST command");
return; return;
} }
@ -644,7 +643,7 @@ class ImapConnection {
settings.setCombinedPrefix(null); settings.setCombinedPrefix(null);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got path delimiter '" + settings.getPathDelimiter() + "' for " + getLogId()); Timber.d("Got path delimiter '%s' for %s", settings.getPathDelimiter(), getLogId());
} }
break; break;
@ -670,7 +669,7 @@ class ImapConnection {
protected boolean isIdleCapable() { protected boolean isIdleCapable() {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Connection " + getLogId() + " has " + capabilities.size() + " capabilities"); Timber.v("Connection %s has %d capabilities", getLogId(), capabilities.size());
} }
return capabilities.contains(Capabilities.IDLE); return capabilities.contains(Capabilities.IDLE);
@ -736,9 +735,9 @@ class ImapConnection {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
if (sensitive && !K9MailLib.isDebugSensitive()) { if (sensitive && !K9MailLib.isDebugSensitive()) {
Log.v(LOG_TAG, getLogId() + ">>> [Command Hidden, Enable Sensitive Debug Logging To Show]"); Timber.v("%s>>> [Command Hidden, Enable Sensitive Debug Logging To Show]", getLogId());
} else { } else {
Log.v(LOG_TAG, getLogId() + ">>> " + tag + " " + command + " " + initialClientResponse); Timber.v("%s>>> %s %s %s", getLogId(), tag, command, initialClientResponse);
} }
} }
@ -760,9 +759,9 @@ class ImapConnection {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
if (sensitive && !K9MailLib.isDebugSensitive()) { if (sensitive && !K9MailLib.isDebugSensitive()) {
Log.v(LOG_TAG, getLogId() + ">>> [Command Hidden, Enable Sensitive Debug Logging To Show]"); Timber.v("%s>>> [Command Hidden, Enable Sensitive Debug Logging To Show]", getLogId());
} else { } else {
Log.v(LOG_TAG, getLogId() + ">>> " + tag + " " + command); Timber.v("%s>>> %s %s", getLogId(), tag, command);
} }
} }
@ -780,7 +779,7 @@ class ImapConnection {
outputStream.flush(); outputStream.flush();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
Log.v(LOG_TAG, getLogId() + ">>> " + continuation); Timber.v("%s>>> %s", getLogId(), continuation);
} }
} }
@ -793,7 +792,7 @@ class ImapConnection {
ImapResponse response = responseParser.readResponse(callback); ImapResponse response = responseParser.readResponse(callback);
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
Log.v(LOG_TAG, getLogId() + "<<<" + response); Timber.v("%s<<<%s", getLogId(), response);
} }
return response; return response;
@ -820,8 +819,8 @@ class ImapConnection {
if (responseTag.equalsIgnoreCase(tag)) { if (responseTag.equalsIgnoreCase(tag)) {
throw new MessagingException("Command continuation aborted: " + response); throw new MessagingException("Command continuation aborted: " + response);
} else { } else {
Log.w(LOG_TAG, "After sending tag " + tag + ", got tag response from previous command " + Timber.w("After sending tag %s, got tag response from previous command %s for %s",
response + " for " + getLogId()); tag, response, getLogId());
} }
} }
} while (!response.isContinuationRequested()); } while (!response.isContinuationRequested());

View file

@ -17,7 +17,6 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.fsck.k9.mail.Body; import com.fsck.k9.mail.Body;
import com.fsck.k9.mail.FetchProfile; import com.fsck.k9.mail.FetchProfile;
@ -34,8 +33,8 @@ import com.fsck.k9.mail.internet.MimeHeader;
import com.fsck.k9.mail.internet.MimeMessageHelper; import com.fsck.k9.mail.internet.MimeMessageHelper;
import com.fsck.k9.mail.internet.MimeMultipart; import com.fsck.k9.mail.internet.MimeMultipart;
import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.mail.internet.MimeUtility;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.store.imap.ImapUtility.getLastResponse; import static com.fsck.k9.mail.store.imap.ImapUtility.getLastResponse;
@ -162,7 +161,7 @@ class ImapFolder extends Folder<ImapMessage> {
} catch (IOException ioe) { } catch (IOException ioe) {
throw ioExceptionHandler(connection, ioe); throw ioExceptionHandler(connection, ioe);
} catch (MessagingException me) { } catch (MessagingException me) {
Log.e(LOG_TAG, "Unable to open connection for " + getLogId(), me); Timber.e(me, "Unable to open connection for %s", getLogId());
throw me; throw me;
} }
} }
@ -211,7 +210,7 @@ class ImapFolder extends Folder<ImapMessage> {
synchronized (this) { synchronized (this) {
// If we are mid-search and we get a close request, we gotta trash the connection. // If we are mid-search and we get a close request, we gotta trash the connection.
if (inSearch && connection != null) { if (inSearch && connection != null) {
Log.i(LOG_TAG, "IMAP search was aborted, shutting down connection."); Timber.i("IMAP search was aborted, shutting down connection.");
connection.close(); connection.close();
} else { } else {
store.releaseConnection(connection); store.releaseConnection(connection);
@ -354,8 +353,8 @@ class ImapFolder extends Folder<ImapMessage> {
// operation fails. This will save a roundtrip if the folder already exists. // operation fails. This will save a roundtrip if the folder already exists.
if (!exists(escapedDestinationFolderName)) { if (!exists(escapedDestinationFolderName)) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "ImapFolder.copyMessages: attempting to create remote folder '" + Timber.i("ImapFolder.copyMessages: attempting to create remote folder '%s' for %s",
escapedDestinationFolderName + "' for " + getLogId()); escapedDestinationFolderName, getLogId());
} }
imapFolder.create(FolderType.HOLDS_MESSAGES); imapFolder.create(FolderType.HOLDS_MESSAGES);
@ -407,16 +406,16 @@ class ImapFolder extends Folder<ImapMessage> {
if (!exists(escapedTrashFolderName)) { if (!exists(escapedTrashFolderName)) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "IMAPMessage.delete: attempting to create remote '" + trashFolderName + "' folder " + Timber.i("IMAPMessage.delete: attempting to create remote '%s' folder for %s",
"for " + getLogId()); trashFolderName, getLogId());
} }
remoteTrashFolder.create(FolderType.HOLDS_MESSAGES); remoteTrashFolder.create(FolderType.HOLDS_MESSAGES);
} }
if (exists(escapedTrashFolderName)) { if (exists(escapedTrashFolderName)) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "IMAPMessage.delete: copying remote " + messages.size() + " messages to '" + Timber.d("IMAPMessage.delete: copying remote %d messages to '%s' for %s",
trashFolderName + "' for " + getLogId()); messages.size(), trashFolderName, getLogId());
} }
moveMessages(messages, remoteTrashFolder); moveMessages(messages, remoteTrashFolder);
@ -728,18 +727,17 @@ class ImapFolder extends Folder<ImapMessage> {
try { try {
msgSeqUidMap.put(msgSeq, uid); msgSeqUidMap.put(msgSeq, uid);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Stored uid '" + uid + "' for msgSeq " + msgSeq + " into map"); Timber.v("Stored uid '%s' for msgSeq %d into map", uid, msgSeq);
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(LOG_TAG, "Unable to store uid '" + uid + "' for msgSeq " + msgSeq); Timber.e("Unable to store uid '%s' for msgSeq %d", uid, msgSeq);
} }
} }
Message message = messageMap.get(uid); Message message = messageMap.get(uid);
if (message == null) { if (message == null) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Do not have message in messageMap for UID " + uid + " for " + Timber.d("Do not have message in messageMap for UID %s for %s", uid, getLogId());
getLogId());
} }
handleUntaggedResponse(response); handleUntaggedResponse(response);
@ -813,7 +811,7 @@ class ImapFolder extends Folder<ImapMessage> {
if (!message.getUid().equals(uid)) { if (!message.getUid().equals(uid)) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Did not ask for UID " + uid + " for " + getLogId()); Timber.d("Did not ask for UID %s for %s", uid, getLogId());
} }
handleUntaggedResponse(response); handleUntaggedResponse(response);
@ -902,7 +900,7 @@ class ImapFolder extends Folder<ImapMessage> {
parseBodyStructure(bs, message, "TEXT"); parseBodyStructure(bs, message, "TEXT");
} catch (MessagingException e) { } catch (MessagingException e) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Error handling message for " + getLogId(), e); Timber.d(e, "Error handling message for %s", getLogId());
} }
message.setBody(null); message.setBody(null);
} }
@ -949,7 +947,7 @@ class ImapFolder extends Folder<ImapMessage> {
if ("UIDNEXT".equalsIgnoreCase(key)) { if ("UIDNEXT".equalsIgnoreCase(key)) {
uidNext = bracketed.getLong(1); uidNext = bracketed.getLong(1);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got UidNext = " + uidNext + " for " + getLogId()); Timber.d("Got UidNext = %s for %s", uidNext, getLogId());
} }
} }
} }
@ -966,7 +964,7 @@ class ImapFolder extends Folder<ImapMessage> {
if (ImapResponseParser.equalsIgnoreCase(response.get(1), "EXISTS")) { if (ImapResponseParser.equalsIgnoreCase(response.get(1), "EXISTS")) {
messageCount = response.getNumber(0); messageCount = response.getNumber(0);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got untagged EXISTS with value " + messageCount + " for " + getLogId()); Timber.d("Got untagged EXISTS with value %d for %s", messageCount, getLogId());
} }
} }
@ -975,7 +973,7 @@ class ImapFolder extends Folder<ImapMessage> {
if (ImapResponseParser.equalsIgnoreCase(response.get(1), "EXPUNGE") && messageCount > 0) { if (ImapResponseParser.equalsIgnoreCase(response.get(1), "EXPUNGE") && messageCount > 0) {
messageCount--; messageCount--;
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got untagged EXPUNGE with messageCount " + messageCount + " for " + getLogId()); Timber.d("Got untagged EXPUNGE with messageCount %d for %s", messageCount, getLogId());
} }
} }
} }
@ -1204,7 +1202,7 @@ class ImapFolder extends Folder<ImapMessage> {
*/ */
String newUid = getUidFromMessageId(message); String newUid = getUidFromMessageId(message);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got UID " + newUid + " for message for " + getLogId()); Timber.d("Got UID %s for message for %s", newUid, getLogId());
} }
if (!TextUtils.isEmpty(newUid)) { if (!TextUtils.isEmpty(newUid)) {
@ -1235,14 +1233,14 @@ class ImapFolder extends Folder<ImapMessage> {
if (messageIdHeader.length == 0) { if (messageIdHeader.length == 0) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Did not get a message-id in order to search for UID for " + getLogId()); Timber.d("Did not get a message-id in order to search for UID for %s", getLogId());
} }
return null; return null;
} }
String messageId = messageIdHeader[0]; String messageId = messageIdHeader[0];
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Looking for UID for message with message-id " + messageId + " for " + getLogId()); Timber.d("Looking for UID for message with message-id %s for %s", messageId, getLogId());
} }
String command = String.format("UID SEARCH HEADER MESSAGE-ID %s", ImapUtility.encodeString(messageId)); String command = String.format("UID SEARCH HEADER MESSAGE-ID %s", ImapUtility.encodeString(messageId));
@ -1323,7 +1321,7 @@ class ImapFolder extends Folder<ImapMessage> {
return null; return null;
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(LOG_TAG, "Exception while updated push state for " + getLogId(), e); Timber.e(e, "Exception while updated push state for %s", getLogId());
return null; return null;
} }
} }
@ -1355,7 +1353,7 @@ class ImapFolder extends Folder<ImapMessage> {
} }
private MessagingException ioExceptionHandler(ImapConnection connection, IOException ioe) { private MessagingException ioExceptionHandler(ImapConnection connection, IOException ioe) {
Log.e(LOG_TAG, "IOException for " + getLogId(), ioe); Timber.e(ioe, "IOException for %s", getLogId());
if (connection != null) { if (connection != null) {
connection.close(); connection.close();

View file

@ -11,7 +11,6 @@ import java.util.List;
import android.content.Context; import android.content.Context;
import android.os.PowerManager; import android.os.PowerManager;
import android.util.Log;
import com.fsck.k9.mail.AuthenticationFailedException; import com.fsck.k9.mail.AuthenticationFailedException;
import com.fsck.k9.mail.Flag; import com.fsck.k9.mail.Flag;
@ -22,8 +21,8 @@ import com.fsck.k9.mail.PushReceiver;
import com.fsck.k9.mail.power.TracingPowerManager; import com.fsck.k9.mail.power.TracingPowerManager;
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock; import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
import com.fsck.k9.mail.store.RemoteStore; import com.fsck.k9.mail.store.RemoteStore;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.K9MailLib.PUSH_WAKE_LOCK_TIMEOUT; import static com.fsck.k9.mail.K9MailLib.PUSH_WAKE_LOCK_TIMEOUT;
import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase; import static com.fsck.k9.mail.store.imap.ImapResponseParser.equalsIgnoreCase;
@ -89,12 +88,12 @@ class ImapFolderPusher extends ImapFolder {
ImapConnection conn = connection; ImapConnection conn = connection;
if (conn != null) { if (conn != null) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Closing connection to stop pushing for " + getLogId()); Timber.v("Closing connection to stop pushing for %s", getLogId());
} }
conn.close(); conn.close();
} else { } else {
Log.w(LOG_TAG, "Attempt to interrupt null connection to stop pushing on folderPusher for " + getLogId()); Timber.w("Attempt to interrupt null connection to stop pushing on folderPusher for %s", getLogId());
} }
} }
@ -106,7 +105,7 @@ class ImapFolderPusher extends ImapFolder {
equalsIgnoreCase(responseType, "EXISTS")) { equalsIgnoreCase(responseType, "EXISTS")) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Storing response " + response + " for later processing"); Timber.d("Storing response %s for later processing", response);
} }
synchronized (storedUntaggedResponses) { synchronized (storedUntaggedResponses) {
@ -133,7 +132,7 @@ class ImapFolderPusher extends ImapFolder {
wakeLock.acquire(PUSH_WAKE_LOCK_TIMEOUT); wakeLock.acquire(PUSH_WAKE_LOCK_TIMEOUT);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Pusher starting for " + getLogId()); Timber.i("Pusher starting for %s", getLogId());
} }
long lastUidNext = -1L; long lastUidNext = -1L;
@ -178,7 +177,7 @@ class ImapFolderPusher extends ImapFolder {
processStoredUntaggedResponses(); processStoredUntaggedResponses();
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "About to IDLE for " + getLogId()); Timber.i("About to IDLE for %s", getLogId());
} }
prepareForIdle(); prepareForIdle();
@ -193,7 +192,7 @@ class ImapFolderPusher extends ImapFolder {
reacquireWakeLockAndCleanUp(); reacquireWakeLockAndCleanUp();
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.e(K9MailLib.LOG_TAG, "Authentication failed. Stopping ImapFolderPusher.", e); Timber.e(e, "Authentication failed. Stopping ImapFolderPusher.");
} }
pushReceiver.authenticationFailed(); pushReceiver.authenticationFailed();
@ -202,10 +201,10 @@ class ImapFolderPusher extends ImapFolder {
reacquireWakeLockAndCleanUp(); reacquireWakeLockAndCleanUp();
if (stop) { if (stop) {
Log.i(LOG_TAG, "Got exception while idling, but stop is set for " + getLogId()); Timber.i("Got exception while idling, but stop is set for %s", getLogId());
} else { } else {
pushReceiver.pushError("Push error for " + getName(), e); pushReceiver.pushError("Push error for " + getName(), e);
Log.e(LOG_TAG, "Got exception while idling for " + getLogId(), e); Timber.e("Got exception while idling for %s", getLogId());
pushReceiver.sleep(wakeLock, delayTime); pushReceiver.sleep(wakeLock, delayTime);
@ -216,8 +215,7 @@ class ImapFolderPusher extends ImapFolder {
idleFailureCount++; idleFailureCount++;
if (idleFailureCount > IDLE_FAILURE_COUNT_LIMIT) { if (idleFailureCount > IDLE_FAILURE_COUNT_LIMIT) {
Log.e(LOG_TAG, "Disabling pusher for " + getLogId() + " after " + idleFailureCount + Timber.e("Disabling pusher for %s after %d consecutive errors", getLogId(), idleFailureCount);
" consecutive errors");
pushReceiver.pushError("Push disabled for " + getName() + " after " + idleFailureCount + pushReceiver.pushError("Push disabled for " + getName() + " after " + idleFailureCount +
" consecutive errors", e); " consecutive errors", e);
stop = true; stop = true;
@ -230,12 +228,12 @@ class ImapFolderPusher extends ImapFolder {
try { try {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Pusher for " + getLogId() + " is exiting"); Timber.i("Pusher for %s is exiting", getLogId());
} }
close(); close();
} catch (Exception me) { } catch (Exception me) {
Log.e(LOG_TAG, "Got exception while closing for " + getLogId(), me); Timber.e(me, "Got exception while closing for %s", getLogId());
} finally { } finally {
wakeLock.release(); wakeLock.release();
} }
@ -251,7 +249,7 @@ class ImapFolderPusher extends ImapFolder {
try { try {
connection.close(); connection.close();
} catch (Exception me) { } catch (Exception me) {
Log.e(LOG_TAG, "Got exception while closing for exception for " + getLogId(), me); Timber.e(me, "Got exception while closing for exception for %s", getLogId());
} }
connection = null; connection = null;
@ -264,7 +262,7 @@ class ImapFolderPusher extends ImapFolder {
} }
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "uidNext is -1, using search to find highest UID"); Timber.d("uidNext is -1, using search to find highest UID");
} }
long highestUid = getHighestUid(); long highestUid = getHighestUid();
@ -275,7 +273,7 @@ class ImapFolderPusher extends ImapFolder {
newUidNext = highestUid + 1; newUidNext = highestUid + 1;
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "highest UID = " + highestUid + ", set newUidNext to " + newUidNext); Timber.d("highest UID = %d, set newUidNext to %d", highestUid, newUidNext);
} }
return newUidNext; return newUidNext;
@ -365,12 +363,12 @@ class ImapFolderPusher extends ImapFolder {
@Override @Override
public void handleAsyncUntaggedResponse(ImapResponse response) { public void handleAsyncUntaggedResponse(ImapResponse response) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Got async response: " + response); Timber.v("Got async response: %s", response);
} }
if (stop) { if (stop) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got async untagged response: " + response + ", but stop is set for " + getLogId()); Timber.d("Got async untagged response: %s, but stop is set for %s", response, getLogId());
} }
idleStopper.stopIdle(); idleStopper.stopIdle();
@ -384,14 +382,14 @@ class ImapFolderPusher extends ImapFolder {
wakeLock.acquire(PUSH_WAKE_LOCK_TIMEOUT); wakeLock.acquire(PUSH_WAKE_LOCK_TIMEOUT);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got useful async untagged response: " + response + " for " + getLogId()); Timber.d("Got useful async untagged response: %s for %s", response, getLogId());
} }
idleStopper.stopIdle(); idleStopper.stopIdle();
} }
} else if (response.isContinuationRequested()) { } else if (response.isContinuationRequested()) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Idling " + getLogId()); Timber.d("Idling %s", getLogId());
} }
idleStopper.startAcceptingDoneContinuation(connection); idleStopper.startAcceptingDoneContinuation(connection);
@ -415,8 +413,8 @@ class ImapFolderPusher extends ImapFolder {
} }
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Processing " + untaggedResponses.size() + " untagged responses from previous " + Timber.i("Processing %d untagged responses from previous commands for %s",
"commands for " + getLogId()); untaggedResponses.size(), getLogId());
} }
processUntaggedResponses(untaggedResponses); processUntaggedResponses(untaggedResponses);
@ -462,7 +460,7 @@ class ImapFolderPusher extends ImapFolder {
} }
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "UIDs for messages needing flag sync are " + flagSyncMsgSeqs + " for " + getLogId()); Timber.d("UIDs for messages needing flag sync are %s for %s", flagSyncMsgSeqs, getLogId());
} }
if (!flagSyncMsgSeqs.isEmpty()) { if (!flagSyncMsgSeqs.isEmpty()) {
@ -483,12 +481,12 @@ class ImapFolderPusher extends ImapFolder {
try { try {
Object responseType = response.get(1); Object responseType = response.get(1);
if (equalsIgnoreCase(responseType, "FETCH")) { if (equalsIgnoreCase(responseType, "FETCH")) {
Log.i(LOG_TAG, "Got FETCH " + response); Timber.i("Got FETCH %s", response);
long msgSeq = response.getLong(0); long msgSeq = response.getLong(0);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got untagged FETCH for msgseq " + msgSeq + " for " + getLogId()); Timber.d("Got untagged FETCH for msgseq %d for %s", msgSeq, getLogId());
} }
if (!flagSyncMsgSeqs.contains(msgSeq)) { if (!flagSyncMsgSeqs.contains(msgSeq)) {
@ -503,7 +501,7 @@ class ImapFolderPusher extends ImapFolder {
} }
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Got untagged EXPUNGE for msgseq " + msgSeq + " for " + getLogId()); Timber.d("Got untagged EXPUNGE for msgseq %d for %s", msgSeq, getLogId());
} }
List<Long> newSeqs = new ArrayList<Long>(); List<Long> newSeqs = new ArrayList<Long>();
@ -525,15 +523,14 @@ class ImapFolderPusher extends ImapFolder {
for (long msgSeqNum : msgSeqs) { for (long msgSeqNum : msgSeqs) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Comparing EXPUNGEd msgSeq " + msgSeq + " to " + msgSeqNum); Timber.v("Comparing EXPUNGEd msgSeq %d to %d", msgSeq, msgSeqNum);
} }
if (msgSeqNum == msgSeq) { if (msgSeqNum == msgSeq) {
String uid = msgSeqUidMap.get(msgSeqNum); String uid = msgSeqUidMap.get(msgSeqNum);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Scheduling removal of UID " + uid + " because msgSeq " + msgSeqNum + Timber.d("Scheduling removal of UID %s because msgSeq %d was expunged", uid, msgSeqNum);
" was expunged");
} }
removeMsgUids.add(uid); removeMsgUids.add(uid);
@ -542,8 +539,7 @@ class ImapFolderPusher extends ImapFolder {
String uid = msgSeqUidMap.get(msgSeqNum); String uid = msgSeqUidMap.get(msgSeqNum);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Reducing msgSeq for UID " + uid + " from " + msgSeqNum + " to " + Timber.d("Reducing msgSeq for UID %s from %d to %d", uid, msgSeqNum, (msgSeqNum - 1));
(msgSeqNum - 1));
} }
msgSeqUidMap.remove(msgSeqNum); msgSeqUidMap.remove(msgSeqNum);
@ -552,7 +548,7 @@ class ImapFolderPusher extends ImapFolder {
} }
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(LOG_TAG, "Could not handle untagged FETCH for " + getLogId(), e); Timber.e(e, "Could not handle untagged FETCH for %s", getLogId());
} }
} }
@ -568,7 +564,7 @@ class ImapFolderPusher extends ImapFolder {
long newUid = Long.parseLong(messageList.get(0).getUid()); long newUid = Long.parseLong(messageList.get(0).getUid());
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Got newUid " + newUid + " for message " + end + " on " + getLogId()); Timber.i("Got newUid %s for message %d on %s", newUid, end, getLogId());
} }
long startUid = oldUidNext; long startUid = oldUidNext;
@ -582,7 +578,7 @@ class ImapFolderPusher extends ImapFolder {
if (newUid >= startUid) { if (newUid >= startUid) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Needs sync from uid " + startUid + " to " + newUid + " for " + getLogId()); Timber.i("Needs sync from uid %d to %d for %s", startUid, newUid, getLogId());
} }
List<Message> messages = new ArrayList<Message>(); List<Message> messages = new ArrayList<Message>();
@ -620,7 +616,7 @@ class ImapFolderPusher extends ImapFolder {
msgSeqUidMap.clear(); msgSeqUidMap.clear();
String existingUid = existingMessage.getUid(); String existingUid = existingMessage.getUid();
Log.w(LOG_TAG, "Message with UID " + existingUid + " still exists on server, not expunging"); Timber.w("Message with UID %s still exists on server, not expunging", existingUid);
removeUids.remove(existingUid); removeUids.remove(existingUid);
} }
@ -631,7 +627,7 @@ class ImapFolderPusher extends ImapFolder {
try { try {
message.setFlagInternal(Flag.DELETED, true); message.setFlagInternal(Flag.DELETED, true);
} catch (MessagingException me) { } catch (MessagingException me) {
Log.e(LOG_TAG, "Unable to set DELETED flag on message " + message.getUid()); Timber.e("Unable to set DELETED flag on message %s", message.getUid());
} }
messages.add(message); messages.add(message);
@ -639,7 +635,7 @@ class ImapFolderPusher extends ImapFolder {
pushReceiver.messagesRemoved(ImapFolderPusher.this, messages); pushReceiver.messagesRemoved(ImapFolderPusher.this, messages);
} catch (Exception e) { } catch (Exception e) {
Log.e(LOG_TAG, "Cannot remove EXPUNGEd messages", e); Timber.e("Cannot remove EXPUNGEd messages");
} }
} }
@ -655,7 +651,7 @@ class ImapFolderPusher extends ImapFolder {
private void notifyMessagesArrived(long startUid, long uidNext) { private void notifyMessagesArrived(long startUid, long uidNext) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Needs sync from uid " + startUid + " to " + uidNext + " for " + getLogId()); Timber.i("Needs sync from uid %d to %d for %s", startUid, uidNext, getLogId());
} }
int count = (int) (uidNext - startUid); int count = (int) (uidNext - startUid);
@ -677,10 +673,10 @@ class ImapFolderPusher extends ImapFolder {
oldUidNext = pushState.uidNext; oldUidNext = pushState.uidNext;
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Got oldUidNext " + oldUidNext + " for " + getLogId()); Timber.i("Got oldUidNext %d for %s", oldUidNext, getLogId());
} }
} catch (Exception e) { } catch (Exception e) {
Log.e(LOG_TAG, "Unable to get oldUidNext for " + getLogId(), e); Timber.e(e, "Unable to get oldUidNext for %s", getLogId());
} }
return oldUidNext; return oldUidNext;

View file

@ -1,9 +1,7 @@
package com.fsck.k9.mail.store.imap; package com.fsck.k9.mail.store.imap;
import android.util.Log; import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
class ImapPushState { class ImapPushState {
@ -25,7 +23,7 @@ class ImapPushState {
return new ImapPushState(newUidNext); return new ImapPushState(newUidNext);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Log.e(LOG_TAG, "Unable to part uidNext value " + value, e); Timber.e(e, "Unable to part uidNext value %s", value);
} }
return createDefaultImapPushState(); return createDefaultImapPushState();

View file

@ -4,13 +4,10 @@ package com.fsck.k9.mail.store.imap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib; import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.PushReceiver; import com.fsck.k9.mail.PushReceiver;
import com.fsck.k9.mail.Pusher; import com.fsck.k9.mail.Pusher;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
class ImapPusher implements Pusher { class ImapPusher implements Pusher {
@ -50,7 +47,7 @@ class ImapPusher implements Pusher {
try { try {
folderPusher.refresh(); folderPusher.refresh();
} catch (Exception e) { } catch (Exception e) {
Log.e(LOG_TAG, "Got exception while refreshing for " + folderPusher.getName(), e); Timber.e(e, "Got exception while refreshing for %s", folderPusher.getName());
} }
} }
} }
@ -59,19 +56,19 @@ class ImapPusher implements Pusher {
@Override @Override
public void stop() { public void stop() {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Requested stop of IMAP pusher"); Timber.i("Requested stop of IMAP pusher");
} }
synchronized (folderPushers) { synchronized (folderPushers) {
for (ImapFolderPusher folderPusher : folderPushers) { for (ImapFolderPusher folderPusher : folderPushers) {
try { try {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.i(LOG_TAG, "Requesting stop of IMAP folderPusher " + folderPusher.getName()); Timber.i("Requesting stop of IMAP folderPusher %s", folderPusher.getName());
} }
folderPusher.stop(); folderPusher.stop();
} catch (Exception e) { } catch (Exception e) {
Log.e(LOG_TAG, "Got exception while stopping " + folderPusher.getName(), e); Timber.e(e, "Got exception while stopping %s", folderPusher.getName());
} }
} }

View file

@ -6,14 +6,12 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib; import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.filter.FixedLengthInputStream; import com.fsck.k9.mail.filter.FixedLengthInputStream;
import com.fsck.k9.mail.filter.PeekableInputStream; import com.fsck.k9.mail.filter.PeekableInputStream;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_IMAP; import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_IMAP;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
class ImapResponseParser { class ImapResponseParser {
@ -88,12 +86,11 @@ class ImapResponseParser {
response = readResponse(); response = readResponse();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
Log.v(LOG_TAG, logId + "<<<" + response); Timber.v("%s<<<%s", logId, response);
} }
if (response.getTag() != null && !response.getTag().equalsIgnoreCase(tag)) { if (response.getTag() != null && !response.getTag().equalsIgnoreCase(tag)) {
Log.w(LOG_TAG, "After sending tag " + tag + ", got tag response from previous command " + response + Timber.w("After sending tag %s, got tag response from previous command %s for %s", tag, response, logId);
" for " + logId);
Iterator<ImapResponse> responseIterator = responses.iterator(); Iterator<ImapResponse> responseIterator = responses.iterator();

View file

@ -14,9 +14,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import android.accounts.AccountManager;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.util.Log;
import com.fsck.k9.mail.AuthType; import com.fsck.k9.mail.AuthType;
import com.fsck.k9.mail.ConnectionSecurity; import com.fsck.k9.mail.ConnectionSecurity;
@ -31,8 +29,7 @@ import com.fsck.k9.mail.oauth.OAuth2TokenProvider;
import com.fsck.k9.mail.ssl.TrustedSocketFactory; import com.fsck.k9.mail.ssl.TrustedSocketFactory;
import com.fsck.k9.mail.store.RemoteStore; import com.fsck.k9.mail.store.RemoteStore;
import com.fsck.k9.mail.store.StoreConfig; import com.fsck.k9.mail.store.StoreConfig;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
/** /**
@ -183,8 +180,9 @@ public class ImapStore extends RemoteStore {
try { try {
decodedFolderName = folderNameCodec.decode(listResponse.getName()); decodedFolderName = folderNameCodec.decode(listResponse.getName());
} catch (CharacterCodingException e) { } catch (CharacterCodingException e) {
Log.w(LOG_TAG, "Folder name not correctly encoded with the UTF-7 variant " + Timber.w(e,
"as defined by RFC 3501: " + listResponse.getName(), e); "Folder name not correctly encoded with the UTF-7 variant as defined by RFC 3501: %s",
listResponse.getName());
//TODO: Use the raw name returned by the server for all commands that require //TODO: Use the raw name returned by the server for all commands that require
// a folder name. Use the decoded name only for showing it to the user. // a folder name. Use the decoded name only for showing it to the user.
@ -239,13 +237,13 @@ public class ImapStore extends RemoteStore {
void autoconfigureFolders(final ImapConnection connection) throws IOException, MessagingException { void autoconfigureFolders(final ImapConnection connection) throws IOException, MessagingException {
if (!connection.hasCapability(Capabilities.SPECIAL_USE)) { if (!connection.hasCapability(Capabilities.SPECIAL_USE)) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "No detected folder auto-configuration methods."); Timber.d("No detected folder auto-configuration methods.");
} }
return; return;
} }
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration: Using RFC6154/SPECIAL-USE."); Timber.d("Folder auto-configuration: Using RFC6154/SPECIAL-USE.");
} }
String command = String.format("LIST (SPECIAL-USE) \"\" %s", ImapUtility.encodeString(getCombinedPrefix() + "*")); String command = String.format("LIST (SPECIAL-USE) \"\" %s", ImapUtility.encodeString(getCombinedPrefix() + "*"));
@ -258,8 +256,8 @@ public class ImapStore extends RemoteStore {
try { try {
decodedFolderName = folderNameCodec.decode(listResponse.getName()); decodedFolderName = folderNameCodec.decode(listResponse.getName());
} catch (CharacterCodingException e) { } catch (CharacterCodingException e) {
Log.w(LOG_TAG, "Folder name not correctly encoded with the UTF-7 variant " + Timber.w(e, "Folder name not correctly encoded with the UTF-7 variant as defined by RFC 3501: %s",
"as defined by RFC 3501: " + listResponse.getName(), e); listResponse.getName());
// We currently just skip folders with malformed names. // We currently just skip folders with malformed names.
continue; continue;
} }
@ -272,27 +270,27 @@ public class ImapStore extends RemoteStore {
if (listResponse.hasAttribute("\\Archive") || listResponse.hasAttribute("\\All")) { if (listResponse.hasAttribute("\\Archive") || listResponse.hasAttribute("\\All")) {
mStoreConfig.setArchiveFolderName(decodedFolderName); mStoreConfig.setArchiveFolderName(decodedFolderName);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration detected Archive folder: " + decodedFolderName); Timber.d("Folder auto-configuration detected Archive folder: %s", decodedFolderName);
} }
} else if (listResponse.hasAttribute("\\Drafts")) { } else if (listResponse.hasAttribute("\\Drafts")) {
mStoreConfig.setDraftsFolderName(decodedFolderName); mStoreConfig.setDraftsFolderName(decodedFolderName);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration detected Drafts folder: " + decodedFolderName); Timber.d("Folder auto-configuration detected Drafts folder: %s", decodedFolderName);
} }
} else if (listResponse.hasAttribute("\\Sent")) { } else if (listResponse.hasAttribute("\\Sent")) {
mStoreConfig.setSentFolderName(decodedFolderName); mStoreConfig.setSentFolderName(decodedFolderName);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration detected Sent folder: " + decodedFolderName); Timber.d("Folder auto-configuration detected Sent folder: %s", decodedFolderName);
} }
} else if (listResponse.hasAttribute("\\Junk")) { } else if (listResponse.hasAttribute("\\Junk")) {
mStoreConfig.setSpamFolderName(decodedFolderName); mStoreConfig.setSpamFolderName(decodedFolderName);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration detected Spam folder: " + decodedFolderName); Timber.d("Folder auto-configuration detected Spam folder: %s", decodedFolderName);
} }
} else if (listResponse.hasAttribute("\\Trash")) { } else if (listResponse.hasAttribute("\\Trash")) {
mStoreConfig.setTrashFolderName(decodedFolderName); mStoreConfig.setTrashFolderName(decodedFolderName);
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.d(LOG_TAG, "Folder auto-configuration detected Trash folder: " + decodedFolderName); Timber.d("Folder auto-configuration detected Trash folder: %s", decodedFolderName);
} }
} }
} }

View file

@ -17,12 +17,11 @@
package com.fsck.k9.mail.store.imap; package com.fsck.k9.mail.store.imap;
import android.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG; import timber.log.Timber;
/** /**
* Utility methods for use with IMAP. * Utility methods for use with IMAP.
@ -101,12 +100,12 @@ class ImapUtility {
} }
} }
} else { } else {
Log.d(LOG_TAG, "Invalid range: " + range); Timber.d("Invalid range: %s", range);
} }
} }
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Log.d(LOG_TAG, "Invalid range value: " + range, e); Timber.d(e, "Invalid range value: %s", range);
} }
return list; return list;
@ -122,7 +121,7 @@ class ImapUtility {
// do nothing // do nothing
} }
Log.d(LOG_TAG, "Invalid UID value: " + number); Timber.d("Invalid UID value: %s", number);
return false; return false;
} }

View file

@ -2,20 +2,18 @@
package com.fsck.k9.mail.store.pop3; package com.fsck.k9.mail.store.pop3;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.util.Log;
import com.fsck.k9.mail.*; import com.fsck.k9.mail.*;
import com.fsck.k9.mail.filter.Base64; import com.fsck.k9.mail.filter.Base64;
import com.fsck.k9.mail.filter.Hex; import com.fsck.k9.mail.filter.Hex;
import com.fsck.k9.mail.internet.MimeMessage; import com.fsck.k9.mail.internet.MimeMessage;
import com.fsck.k9.mail.CertificateValidationException;
import com.fsck.k9.mail.MessageRetrievalListener;
import com.fsck.k9.mail.ServerSettings.Type; import com.fsck.k9.mail.ServerSettings.Type;
import com.fsck.k9.mail.ssl.TrustedSocketFactory; import com.fsck.k9.mail.ssl.TrustedSocketFactory;
import com.fsck.k9.mail.store.RemoteStore; import com.fsck.k9.mail.store.RemoteStore;
import com.fsck.k9.mail.store.StoreConfig; import com.fsck.k9.mail.store.StoreConfig;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
import timber.log.Timber;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
@ -36,7 +34,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_POP3; import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_POP3;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.CertificateValidationException.Reason.MissingCapability; import static com.fsck.k9.mail.CertificateValidationException.Reason.MissingCapability;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8; import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8; import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8;
@ -664,7 +661,7 @@ public class Pop3Store extends RemoteStore {
// response = "+OK msgNum msgUid" // response = "+OK msgNum msgUid"
String[] uidParts = response.split(" +"); String[] uidParts = response.split(" +");
if (uidParts.length < 3 || !"+OK".equals(uidParts[0])) { if (uidParts.length < 3 || !"+OK".equals(uidParts[0])) {
Log.e(LOG_TAG, "ERR response: " + response); Timber.e("ERR response: %s", response);
return; return;
} }
String msgUid = uidParts[2]; String msgUid = uidParts[2];
@ -723,7 +720,7 @@ public class Pop3Store extends RemoteStore {
for (String uid : uids) { for (String uid : uids) {
if (mUidToMsgMap.get(uid) == null) { if (mUidToMsgMap.get(uid) == null) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Log.d(LOG_TAG, "Need to index UID " + uid); Timber.d("Need to index UID %s", uid);
} }
unindexedUids.add(uid); unindexedUids.add(uid);
} }
@ -749,7 +746,7 @@ public class Pop3Store extends RemoteStore {
String msgUid = uidParts[1]; String msgUid = uidParts[1];
if (unindexedUids.contains(msgUid)) { if (unindexedUids.contains(msgUid)) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Log.d(LOG_TAG, "Got msgNum " + msgNum + " for UID " + msgUid); Timber.d("Got msgNum %d for UID %s", msgNum, msgUid);
} }
Pop3Message message = mUidToMsgMap.get(msgUid); Pop3Message message = mUidToMsgMap.get(msgUid);
@ -764,7 +761,7 @@ public class Pop3Store extends RemoteStore {
private void indexMessage(int msgNum, Pop3Message message) { private void indexMessage(int msgNum, Pop3Message message) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Log.d(LOG_TAG, "Adding index for UID " + message.getUid() + " to msgNum " + msgNum); Timber.d("Adding index for UID %s to msgNum %d", message.getUid(), msgNum);
} }
mMsgNumToMsgMap.put(msgNum, message); mMsgNumToMsgMap.put(msgNum, message);
mUidToMsgMap.put(message.getUid(), message); mUidToMsgMap.put(message.getUid(), message);
@ -917,7 +914,7 @@ public class Pop3Store extends RemoteStore {
if (lines != -1 && (!mTopNotSupported || mCapabilities.top)) { if (lines != -1 && (!mTopNotSupported || mCapabilities.top)) {
try { try {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3 && !mCapabilities.top) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3 && !mCapabilities.top) {
Log.d(LOG_TAG, "This server doesn't support the CAPA command. " + Timber.d("This server doesn't support the CAPA command. " +
"Checking to see if the TOP command is supported nevertheless."); "Checking to see if the TOP command is supported nevertheless.");
} }
@ -932,7 +929,7 @@ public class Pop3Store extends RemoteStore {
throw e; throw e;
} else { } else {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Log.d(LOG_TAG, "The server really doesn't support the TOP " + Timber.d("The server really doesn't support the TOP " +
"command. Using RETR instead."); "command. Using RETR instead.");
} }
@ -1040,7 +1037,7 @@ public class Pop3Store extends RemoteStore {
} while ((d = mIn.read()) != -1); } while ((d = mIn.read()) != -1);
String ret = sb.toString(); String ret = sb.toString();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
Log.d(LOG_TAG, "<<< " + ret); Timber.d("<<< %s", ret);
} }
return ret; return ret;
} }
@ -1134,10 +1131,9 @@ public class Pop3Store extends RemoteStore {
if (command != null) { if (command != null) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_POP3) {
if (sensitive && !K9MailLib.isDebugSensitive()) { if (sensitive && !K9MailLib.isDebugSensitive()) {
Log.d(LOG_TAG, ">>> " Timber.d(">>> [Command Hidden, Enable Sensitive Debug Logging To Show]");
+ "[Command Hidden, Enable Sensitive Debug Logging To Show]");
} else { } else {
Log.d(LOG_TAG, ">>> " + command); Timber.d(">>> %s", command);
} }
} }

View file

@ -1,7 +1,5 @@
package com.fsck.k9.mail.store.webdav; package com.fsck.k9.mail.store.webdav;
import android.util.Log;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -11,7 +9,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG; import timber.log.Timber;
/** /**
* Maintains WebDAV data * Maintains WebDAV data
@ -189,7 +187,7 @@ class DataSet {
Date parsedDate = dfInput.parse(date); Date parsedDate = dfInput.parse(date);
tempDate = dfOutput.format(parsedDate); tempDate = dfOutput.format(parsedDate);
} catch (java.text.ParseException pe) { } catch (java.text.ParseException pe) {
Log.e(LOG_TAG, "Error parsing date: " + pe + "\nTrace: " + WebDavUtils.processException(pe)); Timber.e(pe, "Error parsing date: %s", date);
} }
envelope.addHeader(header, tempDate); envelope.addHeader(header, tempDate);
} else { } else {

View file

@ -1,15 +1,13 @@
package com.fsck.k9.mail.store.webdav; package com.fsck.k9.mail.store.webdav;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib; import com.fsck.k9.mail.K9MailLib;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import timber.log.Timber;
import java.net.URI; import java.net.URI;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_WEBDAV; import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_WEBDAV;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8; import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8; import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8;
@ -36,9 +34,7 @@ public class HttpGeneric extends HttpEntityEnclosingRequestBase {
public HttpGeneric(final String uri) { public HttpGeneric(final String uri) {
super(); super();
if (K9MailLib.isDebug()) { Timber.v("Starting uri = '%s'", uri);
Log.v(LOG_TAG, "Starting uri = '" + uri + "'");
}
String[] urlParts = uri.split("/"); String[] urlParts = uri.split("/");
int length = urlParts.length; int length = urlParts.length;
@ -55,8 +51,7 @@ public class HttpGeneric extends HttpEntityEnclosingRequestBase {
end = end.replaceAll("\\+", "%20"); end = end.replaceAll("\\+", "%20");
} }
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
Log.e(LOG_TAG, "IllegalArgumentException caught in HttpGeneric(String uri): " + iae + "\nTrace: " Timber.e(iae, "IllegalArgumentException caught in HttpGeneric(String uri): %s", end);
+ WebDavUtils.processException(iae));
} }
for (int i = 0; i < length - 1; i++) { for (int i = 0; i < length - 1; i++) {
@ -67,12 +62,11 @@ public class HttpGeneric extends HttpEntityEnclosingRequestBase {
} }
} }
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) {
Log.v(LOG_TAG, "url = '" + url + "' length = " + url.length() Timber.v("url = '%s' length = %s, end = '%s' length = %s", url, url.length(), end, end.length());
+ ", end = '" + end + "' length = " + end.length());
} }
url = url + "/" + end; url = url + "/" + end;
Log.i(LOG_TAG, "url = " + url); Timber.d("url = %s", url);
setURI(URI.create(url)); setURI(URI.create(url));
} }

View file

@ -1,7 +1,5 @@
package com.fsck.k9.mail.store.webdav; package com.fsck.k9.mail.store.webdav;
import android.util.Log;
import com.fsck.k9.mail.FetchProfile; import com.fsck.k9.mail.FetchProfile;
import com.fsck.k9.mail.Flag; import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder; import com.fsck.k9.mail.Folder;
@ -16,6 +14,7 @@ import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import timber.log.Timber;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -35,7 +34,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_WEBDAV; import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_WEBDAV;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8; import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8;
/** /**
@ -137,7 +135,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
headers.put("Brief", "t"); headers.put("Brief", "t");
headers.put("If-Match", "*"); headers.put("If-Match", "*");
String action = (isMove ? "BMOVE" : "BCOPY"); String action = (isMove ? "BMOVE" : "BCOPY");
Log.i(LOG_TAG, "Moving " + messages.size() + " messages to " + destFolder.mFolderUrl); Timber.v("Moving %d messages to %s", messages.size(), destFolder.mFolderUrl);
store.processRequest(mFolderUrl, action, messageBody, headers, false); store.processRequest(mFolderUrl, action, messageBody, headers, false);
} }
@ -161,7 +159,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
messageCount = dataset.getMessageCount(); messageCount = dataset.getMessageCount();
} }
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) {
Log.v(LOG_TAG, "Counted messages and webdav returned: " + messageCount); Timber.v("Counted messages and webdav returned: %d", messageCount);
} }
return messageCount; return messageCount;
@ -354,16 +352,14 @@ class WebDavFolder extends Folder<WebDavMessage> {
*/ */
if (wdMessage.getUrl().equals("")) { if (wdMessage.getUrl().equals("")) {
wdMessage.setUrl(getMessageUrls(new String[]{wdMessage.getUid()}).get(wdMessage.getUid())); wdMessage.setUrl(getMessageUrls(new String[]{wdMessage.getUid()}).get(wdMessage.getUid()));
Log.i(LOG_TAG, "Fetching messages with UID = '" + wdMessage.getUid() + "', URL = '" Timber.i("Fetching messages with UID = '%s', URL = '%s'", wdMessage.getUid(), wdMessage.getUrl());
+ wdMessage.getUrl() + "'");
if (wdMessage.getUrl().equals("")) { if (wdMessage.getUrl().equals("")) {
throw new MessagingException("Unable to get URL for message"); throw new MessagingException("Unable to get URL for message");
} }
} }
try { try {
Log.i(LOG_TAG, "Fetching message with UID = '" + wdMessage.getUid() + "', URL = '" Timber.i("Fetching message with UID = '%s', URL = '%s'", wdMessage.getUid(), wdMessage.getUrl());
+ wdMessage.getUrl() + "'");
HttpGet httpget = new HttpGet(new URI(wdMessage.getUrl())); HttpGet httpget = new HttpGet(new URI(wdMessage.getUrl()));
HttpResponse response; HttpResponse response;
HttpEntity entity; HttpEntity entity;
@ -415,27 +411,25 @@ class WebDavFolder extends Folder<WebDavMessage> {
wdMessage.parse(istream); wdMessage.parse(istream);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.e(LOG_TAG, "IOException: " + ioe.getMessage() + "\nTrace: " Timber.e(ioe, "IOException during message parsing");
+ WebDavUtils.processException(ioe));
throw new MessagingException("I/O Error", ioe); throw new MessagingException("I/O Error", ioe);
} finally { } finally {
IOUtils.closeQuietly(reader); IOUtils.closeQuietly(reader);
IOUtils.closeQuietly(istream); IOUtils.closeQuietly(istream);
} }
} else { } else {
Log.v(LOG_TAG, "Empty response"); Timber.v("Empty response");
} }
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
Log.e(LOG_TAG, "IllegalArgumentException caught " + iae + "\nTrace: " + WebDavUtils.processException(iae)); Timber.e(iae, "IllegalArgumentException caught");
throw new MessagingException("IllegalArgumentException caught", iae); throw new MessagingException("IllegalArgumentException caught", iae);
} catch (URISyntaxException use) { } catch (URISyntaxException use) {
Log.e(LOG_TAG, "URISyntaxException caught " + use + "\nTrace: " + WebDavUtils.processException(use)); Timber.e(use, "URISyntaxException caught");
throw new MessagingException("URISyntaxException caught", use); throw new MessagingException("URISyntaxException caught", use);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.e(LOG_TAG, "Non-success response code loading message, response code was " + statusCode Timber.e(ioe, "Non-success response code loading message, response code was %d, URL: %s",
+ "\nURL: " + wdMessage.getUrl() + "\nError: " + ioe.getMessage() + "\nTrace: " statusCode, wdMessage.getUrl());
+ WebDavUtils.processException(ioe));
throw new MessagingException("Failure code " + statusCode, ioe); throw new MessagingException("Failure code " + statusCode, ioe);
} }
@ -500,7 +494,8 @@ class WebDavFolder extends Folder<WebDavMessage> {
try { try {
wdMessage.setFlagInternal(Flag.SEEN, uidToReadStatus.get(wdMessage.getUid())); wdMessage.setFlagInternal(Flag.SEEN, uidToReadStatus.get(wdMessage.getUid()));
} catch (NullPointerException e) { } catch (NullPointerException e) {
Log.v(LOG_TAG, "Under some weird circumstances, setting the read status when syncing from webdav threw an NPE. Skipping."); Timber.v(e, "Under some weird circumstances, " +
"setting the read status when syncing from webdav threw an NPE. Skipping.");
} }
} }
@ -562,7 +557,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
message.setNewHeaders(envelope); message.setNewHeaders(envelope);
message.setFlagInternal(Flag.SEEN, envelope.getReadStatus()); message.setFlagInternal(Flag.SEEN, envelope.getReadStatus());
} else { } else {
Log.e(LOG_TAG, "Asked to get metadata for a non-existent message: " + message.getUid()); Timber.e("Asked to get metadata for a non-existent message: %s", message.getUid());
} }
if (listener != null) { if (listener != null) {
@ -676,7 +671,7 @@ class WebDavFolder extends Folder<WebDavMessage> {
} }
messageURL += encodeUtf8(message.getUid() + ":" + System.currentTimeMillis() + ".eml"); messageURL += encodeUtf8(message.getUid() + ":" + System.currentTimeMillis() + ".eml");
Log.i(LOG_TAG, "Uploading message as " + messageURL); Timber.i("Uploading message as %s", messageURL);
store.sendRequest(messageURL, "PUT", bodyEntity, null, true); store.sendRequest(messageURL, "PUT", bodyEntity, null, true);
@ -701,16 +696,14 @@ class WebDavFolder extends Folder<WebDavMessage> {
@Override @Override
public String getUidFromMessageId(Message message) throws MessagingException { public String getUidFromMessageId(Message message) throws MessagingException {
Log.e(LOG_TAG, Timber.e("Unimplemented method getUidFromMessageId in WebDavStore.WebDavFolder could lead to duplicate messages "
"Unimplemented method getUidFromMessageId in WebDavStore.WebDavFolder could lead to duplicate messages "
+ " being uploaded to the Sent folder"); + " being uploaded to the Sent folder");
return null; return null;
} }
@Override @Override
public void setFlags(final Set<Flag> flags, boolean value) throws MessagingException { public void setFlags(final Set<Flag> flags, boolean value) throws MessagingException {
Log.e(LOG_TAG, Timber.e("Unimplemented method setFlags(Set<Flag>, boolean) breaks markAllMessagesAsRead and EmptyTrash");
"Unimplemented method setFlags(Set<Flag>, boolean) breaks markAllMessagesAsRead and EmptyTrash");
// Try to make this efficient by not retrieving all of the messages // Try to make this efficient by not retrieving all of the messages
} }

View file

@ -1,7 +1,5 @@
package com.fsck.k9.mail.store.webdav; package com.fsck.k9.mail.store.webdav;
import android.util.Log;
import org.apache.http.Header; import org.apache.http.Header;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpRequest; import org.apache.http.HttpRequest;
@ -9,13 +7,12 @@ import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpContext;
import timber.log.Timber;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
/** /**
* HTTP client for WebDAV communication * HTTP client for WebDAV communication
*/ */
@ -41,7 +38,7 @@ public class WebDavHttpClient extends DefaultHttpClient {
} }
public static void modifyRequestToAcceptGzipResponse(HttpRequest request) { public static void modifyRequestToAcceptGzipResponse(HttpRequest request) {
Log.i(LOG_TAG, "Requesting gzipped data"); Timber.i("Requesting gzipped data");
request.addHeader("Accept-Encoding", "gzip"); request.addHeader("Accept-Encoding", "gzip");
} }
@ -57,7 +54,7 @@ public class WebDavHttpClient extends DefaultHttpClient {
if (contentEncoding == null) if (contentEncoding == null)
return responseStream; return responseStream;
if (contentEncoding.contains("gzip")) { if (contentEncoding.contains("gzip")) {
Log.i(LOG_TAG, "Response is gzipped"); Timber.i("Response is gzipped");
responseStream = new GZIPInputStream(responseStream); responseStream = new GZIPInputStream(responseStream);
} }
return responseStream; return responseStream;

View file

@ -1,17 +1,15 @@
package com.fsck.k9.mail.store.webdav; package com.fsck.k9.mail.store.webdav;
import android.util.Log;
import com.fsck.k9.mail.Flag; import com.fsck.k9.mail.Flag;
import com.fsck.k9.mail.Folder; import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.internet.MimeMessage; import com.fsck.k9.mail.internet.MimeMessage;
import timber.log.Timber;
import java.util.Collections; import java.util.Collections;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8; import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8; import static com.fsck.k9.mail.helper.UrlEncodingHelper.encodeUtf8;
@ -52,8 +50,7 @@ class WebDavMessage extends MimeMessage {
end = encodeUtf8(end); end = encodeUtf8(end);
end = end.replaceAll("\\+", "%20"); end = end.replaceAll("\\+", "%20");
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
Log.e(LOG_TAG, "IllegalArgumentException caught in setUrl: " + iae + "\nTrace: " Timber.e(iae, "IllegalArgumentException caught in setUrl: ");
+ WebDavUtils.processException(iae));
} }
for (int i = 0; i < length - 1; i++) { for (int i = 0; i < length - 1; i++) {
@ -101,7 +98,7 @@ class WebDavMessage extends MimeMessage {
@Override @Override
public void delete(String trashFolderName) throws MessagingException { public void delete(String trashFolderName) throws MessagingException {
WebDavFolder wdFolder = (WebDavFolder) getFolder(); WebDavFolder wdFolder = (WebDavFolder) getFolder();
Log.i(LOG_TAG, "Deleting message by moving to " + trashFolderName); Timber.i("Deleting message by moving to %s", trashFolderName);
wdFolder.moveMessages(Collections.singletonList(this), wdFolder.getStore().getFolder(trashFolderName)); wdFolder.moveMessages(Collections.singletonList(this), wdFolder.getStore().getFolder(trashFolderName));
} }

View file

@ -16,8 +16,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import android.util.Log;
import com.fsck.k9.mail.CertificateValidationException; import com.fsck.k9.mail.CertificateValidationException;
import com.fsck.k9.mail.ConnectionSecurity; import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.Folder; import com.fsck.k9.mail.Folder;
@ -48,9 +46,9 @@ import org.apache.http.protocol.HttpContext;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import timber.log.Timber;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_WEBDAV; import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_WEBDAV;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8; import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
@ -525,7 +523,7 @@ public class WebDavStore extends RemoteStore {
performFormBasedAuthentication(null); performFormBasedAuthentication(null);
} }
} catch (IOException ioe) { } catch (IOException ioe) {
Log.e(LOG_TAG, "Error during authentication: " + ioe + "\nStack: " + WebDavUtils.processException(ioe)); Timber.e(ioe, "Error during authentication");
throw new MessagingException("Error during authentication", ioe); throw new MessagingException("Error during authentication", ioe);
} }
@ -589,7 +587,7 @@ public class WebDavStore extends RemoteStore {
} catch (SSLException e) { } catch (SSLException e) {
throw new CertificateValidationException(e.getMessage(), e); throw new CertificateValidationException(e.getMessage(), e);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.e(LOG_TAG, "IOException: " + ioe + "\nTrace: " + WebDavUtils.processException(ioe)); Timber.e(ioe, "IOException during initial connection");
throw new MessagingException("IOException", ioe); throw new MessagingException("IOException", ioe);
} }
@ -688,7 +686,7 @@ public class WebDavStore extends RemoteStore {
response = httpClient.executeOverride(request, httpContext); response = httpClient.executeOverride(request, httpContext);
authenticated = testAuthenticationResponse(response); authenticated = testAuthenticationResponse(response);
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
Log.e(LOG_TAG, "URISyntaxException caught " + e + "\nTrace: " + WebDavUtils.processException(e)); Timber.e(e, "URISyntaxException caught");
throw new MessagingException("URISyntaxException caught", e); throw new MessagingException("URISyntaxException caught", e);
} }
} else { } else {
@ -778,7 +776,7 @@ public class WebDavStore extends RemoteStore {
} }
} }
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
Log.e(LOG_TAG, "URISyntaxException caught " + e + "\nTrace: " + WebDavUtils.processException(e)); Timber.e(e, "URISyntaxException");
throw new MessagingException("URISyntaxException caught", e); throw new MessagingException("URISyntaxException caught", e);
} }
} }
@ -815,11 +813,11 @@ public class WebDavStore extends RemoteStore {
Scheme s = new Scheme("https", new WebDavSocketFactory(hostname, 443), 443); Scheme s = new Scheme("https", new WebDavSocketFactory(hostname, 443), 443);
reg.register(s); reg.register(s);
} catch (NoSuchAlgorithmException nsa) { } catch (NoSuchAlgorithmException nsa) {
Log.e(LOG_TAG, "NoSuchAlgorithmException in getHttpClient: " + nsa); Timber.e(nsa, "NoSuchAlgorithmException in getHttpClient");
throw new MessagingException("NoSuchAlgorithmException in getHttpClient: " + nsa); throw new MessagingException("NoSuchAlgorithmException in getHttpClient: ", nsa);
} catch (KeyManagementException kme) { } catch (KeyManagementException kme) {
Log.e(LOG_TAG, "KeyManagementException in getHttpClient: " + kme); Timber.e(kme, "KeyManagementException in getHttpClient");
throw new MessagingException("KeyManagementException in getHttpClient: " + kme); throw new MessagingException("KeyManagementException in getHttpClient: ", kme);
} }
} }
return httpClient; return httpClient;
@ -885,10 +883,10 @@ public class WebDavStore extends RemoteStore {
return WebDavHttpClient.getUngzippedContent(entity); return WebDavHttpClient.getUngzippedContent(entity);
} }
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException uee) {
Log.e(LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + WebDavUtils.processException(uee)); Timber.e(uee, "UnsupportedEncodingException: ");
throw new MessagingException("UnsupportedEncodingException", uee); throw new MessagingException("UnsupportedEncodingException", uee);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.e(LOG_TAG, "IOException: " + ioe + "\nTrace: " + WebDavUtils.processException(ioe)); Timber.e(ioe, "IOException: ");
throw new MessagingException("IOException", ioe); throw new MessagingException("IOException", ioe);
} }
@ -926,8 +924,7 @@ public class WebDavStore extends RemoteStore {
throws MessagingException { throws MessagingException {
DataSet dataset = new DataSet(); DataSet dataset = new DataSet();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) {
Log.v(LOG_TAG, "processRequest url = '" + url + "', method = '" + method + "', messageBody = '" Timber.v("processRequest url = '%s', method = '%s', messageBody = '%s'", url, method, messageBody);
+ messageBody + "'");
} }
if (url == null || if (url == null ||
@ -959,22 +956,20 @@ public class WebDavStore extends RemoteStore {
dataset = myHandler.getDataSet(); dataset = myHandler.getDataSet();
} catch (SAXException se) { } catch (SAXException se) {
Log.e(LOG_TAG, Timber.e(se, "SAXException in processRequest()");
"SAXException in processRequest() " + se + "\nTrace: " + WebDavUtils.processException(se));
throw new MessagingException("SAXException in processRequest() ", se); throw new MessagingException("SAXException in processRequest() ", se);
} catch (ParserConfigurationException pce) { } catch (ParserConfigurationException pce) {
Log.e(LOG_TAG, "ParserConfigurationException in processRequest() " + pce + "\nTrace: " Timber.e(pce, "ParserConfigurationException in processRequest()");
+ WebDavUtils.processException(pce));
throw new MessagingException("ParserConfigurationException in processRequest() ", pce); throw new MessagingException("ParserConfigurationException in processRequest() ", pce);
} }
istream.close(); istream.close();
} }
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException uee) {
Log.e(LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + WebDavUtils.processException(uee)); Timber.e(uee, "UnsupportedEncodingException: ");
throw new MessagingException("UnsupportedEncodingException in processRequest() ", uee); throw new MessagingException("UnsupportedEncodingException in processRequest() ", uee);
} catch (IOException ioe) { } catch (IOException ioe) {
Log.e(LOG_TAG, "IOException: " + ioe + "\nTrace: " + WebDavUtils.processException(ioe)); Timber.e(ioe, "IOException: ");
throw new MessagingException("IOException in processRequest() ", ioe); throw new MessagingException("IOException in processRequest() ", ioe);
} }

View file

@ -4,12 +4,9 @@ import com.fsck.k9.mail.AuthType;
import com.fsck.k9.mail.ConnectionSecurity; import com.fsck.k9.mail.ConnectionSecurity;
import com.fsck.k9.mail.ServerSettings; import com.fsck.k9.mail.ServerSettings;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static com.fsck.k9.mail.helper.UrlEncodingHelper.decodeUtf8;
/** /**
* This class is used to store the decoded contents of an WebDavStore URI. * This class is used to store the decoded contents of an WebDavStore URI.

View file

@ -1,23 +0,0 @@
package com.fsck.k9.mail.store.webdav;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
/**
* Utility methods for WebDAV code.
*/
class WebDavUtils {
/**
* Returns a string of the stacktrace for a Throwable to allow for easy inline printing of errors.
*/
static String processException(Throwable t) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
t.printStackTrace(ps);
ps.close();
return baos.toString();
}
}

View file

@ -1,8 +1,6 @@
package com.fsck.k9.mail.transport; package com.fsck.k9.mail.transport;
import android.util.Log;
import com.fsck.k9.mail.K9MailLib; import com.fsck.k9.mail.K9MailLib;
import com.fsck.k9.mail.Message; import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException; import com.fsck.k9.mail.MessagingException;
@ -11,11 +9,10 @@ import com.fsck.k9.mail.Transport;
import com.fsck.k9.mail.store.StoreConfig; import com.fsck.k9.mail.store.StoreConfig;
import com.fsck.k9.mail.store.webdav.WebDavHttpClient; import com.fsck.k9.mail.store.webdav.WebDavHttpClient;
import com.fsck.k9.mail.store.webdav.WebDavStore; import com.fsck.k9.mail.store.webdav.WebDavStore;
import timber.log.Timber;
import java.util.Collections; import java.util.Collections;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public class WebDavTransport extends Transport { public class WebDavTransport extends Transport {
/** /**
@ -49,13 +46,13 @@ public class WebDavTransport extends Transport {
store = new WebDavStore(storeConfig, new WebDavHttpClient.WebDavHttpClientFactory()); store = new WebDavStore(storeConfig, new WebDavHttpClient.WebDavHttpClientFactory());
if (K9MailLib.isDebug()) if (K9MailLib.isDebug())
Log.d(LOG_TAG, ">>> New WebDavTransport creation complete"); Timber.d(">>> New WebDavTransport creation complete");
} }
@Override @Override
public void open() throws MessagingException { public void open() throws MessagingException {
if (K9MailLib.isDebug()) if (K9MailLib.isDebug())
Log.d(LOG_TAG, ">>> open called on WebDavTransport "); Timber.d( ">>> open called on WebDavTransport ");
store.getHttpClient(); store.getHttpClient();
} }

View file

@ -24,7 +24,6 @@ import java.util.Map;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.fsck.k9.mail.Address; import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.AuthType; import com.fsck.k9.mail.AuthType;
@ -50,10 +49,10 @@ import com.fsck.k9.mail.ssl.TrustedSocketFactory;
import com.fsck.k9.mail.store.StoreConfig; import com.fsck.k9.mail.store.StoreConfig;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import timber.log.Timber;
import static com.fsck.k9.mail.CertificateValidationException.Reason.MissingCapability; import static com.fsck.k9.mail.CertificateValidationException.Reason.MissingCapability;
import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_SMTP; import static com.fsck.k9.mail.K9MailLib.DEBUG_PROTOCOL_SMTP;
import static com.fsck.k9.mail.K9MailLib.LOG_TAG;
public class SmtpTransport extends Transport { public class SmtpTransport extends Transport {
public static final int SMTP_CONTINUE_REQUEST = 334; public static final int SMTP_CONTINUE_REQUEST = 334;
@ -463,7 +462,7 @@ public class SmtpTransport extends Transport {
mLargestAcceptableMessage = Integer.parseInt(optionalsizeValue); mLargestAcceptableMessage = Integer.parseInt(optionalsizeValue);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP) { if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP) {
Log.d(LOG_TAG, "Tried to parse " + optionalsizeValue + " and get an int", e); Timber.d(e, "Tried to parse %s and get an int", optionalsizeValue);
} }
} }
} }
@ -502,13 +501,13 @@ public class SmtpTransport extends Transport {
} }
} catch (NegativeSmtpReplyException e) { } catch (NegativeSmtpReplyException e) {
if (K9MailLib.isDebug()) { if (K9MailLib.isDebug()) {
Log.v(LOG_TAG, "Server doesn't support the EHLO command. Trying HELO..."); Timber.v("Server doesn't support the EHLO command. Trying HELO...");
} }
try { try {
executeCommand("HELO %s", host); executeCommand("HELO %s", host);
} catch (NegativeSmtpReplyException e2) { } catch (NegativeSmtpReplyException e2) {
Log.w(LOG_TAG, "Server doesn't support the HELO command. Continuing anyway."); Timber.w("Server doesn't support the HELO command. Continuing anyway.");
} }
} }
return extensions; return extensions;
@ -552,7 +551,7 @@ public class SmtpTransport extends Transport {
open(); open();
if (!m8bitEncodingAllowed) { if (!m8bitEncodingAllowed) {
Log.d(LOG_TAG, "Server does not support 8bit transfer encoding"); Timber.d("Server does not support 8bit transfer encoding");
} }
// If the message has attachments and our server has told us about a limit on // If the message has attachments and our server has told us about a limit on
// the size of messages, count the message's size before sending it // the size of messages, count the message's size before sending it
@ -628,7 +627,7 @@ public class SmtpTransport extends Transport {
} }
String ret = sb.toString(); String ret = sb.toString();
if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP) if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP)
Log.d(LOG_TAG, "SMTP <<< " + ret); Timber.d("SMTP <<< %s", ret);
return ret; return ret;
} }
@ -641,7 +640,7 @@ public class SmtpTransport extends Transport {
} else { } else {
commandToLog = "SMTP >>> " + s; commandToLog = "SMTP >>> " + s;
} }
Log.d(LOG_TAG, commandToLog); Timber.d(commandToLog);
} }
byte[] data = s.concat("\r\n").getBytes(); byte[] data = s.concat("\r\n").getBytes();
@ -860,7 +859,7 @@ public class SmtpTransport extends Transport {
//if a token was invalid before use (e.g. due to expiry). But we don't //if a token was invalid before use (e.g. due to expiry). But we don't
//This is the intended behaviour per AccountManager //This is the intended behaviour per AccountManager
Log.v(LOG_TAG, "Authentication exception, re-trying with new token", negativeResponseFromOldToken); Timber.v(negativeResponseFromOldToken, "Authentication exception, re-trying with new token");
try { try {
attemptXoauth2(username); attemptXoauth2(username);
} catch (NegativeSmtpReplyException negativeResponseFromNewToken) { } catch (NegativeSmtpReplyException negativeResponseFromNewToken) {
@ -870,8 +869,7 @@ public class SmtpTransport extends Transport {
//Okay, we failed on a new token. //Okay, we failed on a new token.
//Invalidate the token anyway but assume it's permanent. //Invalidate the token anyway but assume it's permanent.
Log.v(LOG_TAG, "Authentication exception for new token, permanent error assumed", Timber.v(negativeResponseFromNewToken, "Authentication exception for new token, permanent error assumed");
negativeResponseFromNewToken);
oauthTokenProvider.invalidateToken(username); oauthTokenProvider.invalidateToken(username);

View file

@ -3,7 +3,6 @@ package com.fsck.k9.mail;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;

View file

@ -27,7 +27,6 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;

View file

@ -11,7 +11,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class ImapListTest { public class ImapListTest {

View file

@ -38,7 +38,6 @@ import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyMapOf; import static org.mockito.Matchers.anyMapOf;
import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq; import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;

View file

@ -44,7 +44,6 @@ import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.mockito.stubbing.OngoingStubbing; import org.mockito.stubbing.OngoingStubbing;
import org.robolectric.annotation.Config;
import static junit.framework.Assert.assertSame; import static junit.framework.Assert.assertSame;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;

View file

@ -34,7 +34,7 @@ dependencies {
compile 'de.cketti.safecontentresolver:safe-content-resolver-v14:0.9.0' compile 'de.cketti.safecontentresolver:safe-content-resolver-v14:0.9.0'
compile 'com.github.amlcurran.showcaseview:library:5.4.1' compile 'com.github.amlcurran.showcaseview:library:5.4.1'
compile 'com.squareup.moshi:moshi:1.2.0' compile 'com.squareup.moshi:moshi:1.2.0'
compile 'com.jakewharton.timber:timber:4.5.1' compile "com.jakewharton.timber:timber:${timberVersion}"
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'