k-9/k9mail-library/src/main/java/com/fsck/k9/mail/K9MailLib.java

102 lines
2.5 KiB
Java
Raw Normal View History

2014-12-16 06:51:52 -05:00
package com.fsck.k9.mail;
2014-12-19 03:48:02 -05:00
2014-12-16 06:51:52 -05:00
public class K9MailLib {
2014-12-18 06:48:10 -05:00
private static DebugStatus debugStatus = new DefaultDebugStatus();
2014-12-16 06:51:52 -05:00
2014-12-19 03:48:02 -05:00
private K9MailLib() {
}
public static final String LOG_TAG = "k9";
2014-12-18 06:22:01 -05:00
public static final int PUSH_WAKE_LOCK_TIMEOUT = 60000;
2014-12-19 03:48:02 -05:00
public static final String IDENTITY_HEADER = "X-K9mail-Identity";
2014-12-16 06:51:52 -05:00
/**
* 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;
public static boolean isDebug() {
2014-12-18 06:48:10 -05:00
return debugStatus.enabled();
2014-12-16 06:51:52 -05:00
}
public static boolean isDebugSensitive() {
2014-12-18 06:48:10 -05:00
return debugStatus.debugSensitive();
}
public static void setDebugSensitive(boolean b) {
if (debugStatus instanceof WritableDebugStatus) {
2014-12-19 03:48:02 -05:00
((WritableDebugStatus) debugStatus).setSensitive(b);
2014-12-18 06:48:10 -05:00
}
}
public static void setDebug(boolean b) {
if (debugStatus instanceof WritableDebugStatus) {
2014-12-19 03:48:02 -05:00
((WritableDebugStatus) debugStatus).setEnabled(b);
2014-12-18 06:48:10 -05:00
}
}
public static interface DebugStatus {
boolean enabled();
2014-12-19 03:48:02 -05:00
2014-12-18 06:48:10 -05:00
boolean debugSensitive();
}
public static void setDebugStatus(DebugStatus status) {
if (status == null) {
throw new IllegalArgumentException("status cannot be null");
}
debugStatus = status;
}
private static interface WritableDebugStatus extends DebugStatus {
void setEnabled(boolean enabled);
2014-12-19 03:48:02 -05:00
2014-12-18 06:48:10 -05:00
void setSensitive(boolean sensitive);
}
private static class DefaultDebugStatus implements WritableDebugStatus {
private boolean enabled;
private boolean sensitive;
2014-12-19 03:48:02 -05:00
@Override
public boolean enabled() {
return enabled;
}
@Override
public boolean debugSensitive() {
return sensitive;
}
@Override
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
@Override
public void setSensitive(boolean sensitive) {
this.sensitive = sensitive;
}
2014-12-16 06:51:52 -05:00
}
}