diff --git a/src/com/fsck/k9/K9.java b/src/com/fsck/k9/K9.java index 53198cf5f..0898b87da 100644 --- a/src/com/fsck/k9/K9.java +++ b/src/com/fsck/k9/K9.java @@ -58,6 +58,37 @@ public class K9 extends Application */ public static boolean DEBUG = false; + /** + * Should K-9 log the conversation it has over the wire with + * SMTP servers? + */ + + public static boolean DEBUG_PROTOCOL_SMTP = true; + + /** + * Should K-9 log the conversation it has over the wire with + * IMAP servers? + */ + + public static boolean DEBUG_PROTOCOL_IMAP = true; + + + /** + * Should K-9 log the conversation it has over the wire with + * POP3 servers? + */ + + public static boolean DEBUG_PROTOCOL_POP3 = true; + + /** + * Should K-9 log the conversation it has over the wire with + * WebDAV servers? + */ + + public static boolean DEBUG_PROTOCOL_WEBDAV = true; + + + /** * If this is enabled than logging that normally hides sensitive information * like passwords will show that information. diff --git a/src/com/fsck/k9/mail/store/ImapResponseParser.java b/src/com/fsck/k9/mail/store/ImapResponseParser.java index 5d9564948..655a01993 100644 --- a/src/com/fsck/k9/mail/store/ImapResponseParser.java +++ b/src/com/fsck/k9/mail/store/ImapResponseParser.java @@ -65,7 +65,7 @@ public class ImapResponseParser response.mTag = parseTaggedResponse(); readTokens(response); } - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_IMAP) { Log.v(K9.LOG_TAG, "<<< " + response.toString()); } diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index caafb1fcc..8e03a2060 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -2168,7 +2168,7 @@ public class ImapStore extends Store capabilities.clear(); ImapResponse nullResponse = mParser.readResponse(); - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_IMAP) Log.v(K9.LOG_TAG, getLogId() + "<<<" + nullResponse); List nullResponses = new LinkedList(); @@ -2566,7 +2566,7 @@ public class ImapStore extends Store try { ImapResponse response = mParser.readResponse(callback); - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_IMAP) Log.v(K9.LOG_TAG, getLogId() + "<<<" + response); return response; @@ -2596,7 +2596,7 @@ public class ImapStore extends Store mOut.write('\n'); mOut.flush(); - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_IMAP) Log.v(K9.LOG_TAG, getLogId() + ">>> " + continuation); } @@ -2614,7 +2614,7 @@ public class ImapStore extends Store mOut.write('\n'); mOut.flush(); - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_IMAP) { if (sensitive && !K9.DEBUG_SENSITIVE) { @@ -2680,7 +2680,7 @@ public class ImapStore extends Store do { response = mParser.readResponse(); - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_IMAP) Log.v(K9.LOG_TAG, getLogId() + "<<<" + response); if (response.mTag != null && response.mTag.equalsIgnoreCase(tag) == false) diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index d70928ec5..6572eab36 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -960,7 +960,7 @@ public class Pop3Store extends Store String ret = sb.toString(); if (Config.LOGD) { - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_POP3) { Log.d(K9.LOG_TAG, "<<< " + ret); } @@ -972,7 +972,7 @@ public class Pop3Store extends Store { if (Config.LOGD) { - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_POP3) { Log.d(K9.LOG_TAG, ">>> " + s); } diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java index b0fb03331..321fe3d16 100644 --- a/src/com/fsck/k9/mail/store/WebDavStore.java +++ b/src/com/fsck/k9/mail/store/WebDavStore.java @@ -1032,7 +1032,7 @@ public class WebDavStore extends Store throws MessagingException { DataSet dataset = new DataSet(); - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_WEBDAV) { Log.v(K9.LOG_TAG, "processRequest url = '" + url + "', method = '" + method + "', messageBody = '" + messageBody + "'"); } @@ -2607,7 +2607,7 @@ public class WebDavStore extends Store url = urlParts[i]; } } - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_WEBDAV) { Log.v(K9.LOG_TAG, "url = '" + url + "' length = " + url.length() + ", end = '" + end + "' length = " + end.length()); diff --git a/src/com/fsck/k9/mail/transport/SmtpTransport.java b/src/com/fsck/k9/mail/transport/SmtpTransport.java index cbb2b3aa5..29d8c18cb 100644 --- a/src/com/fsck/k9/mail/transport/SmtpTransport.java +++ b/src/com/fsck/k9/mail/transport/SmtpTransport.java @@ -416,7 +416,7 @@ public class SmtpTransport extends Transport } } String ret = sb.toString(); - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_SMTP) Log.d(K9.LOG_TAG, "SMTP <<< " + ret); return ret; @@ -424,7 +424,7 @@ public class SmtpTransport extends Transport private void writeLine(String s, boolean sensitive) throws IOException { - if (K9.DEBUG) + if (K9.DEBUG && K9.DEBUG_PROTOCOL_SMTP) { final String commandToLog; if (sensitive && !K9.DEBUG_SENSITIVE)